akhauriyash/Code-Regression huggingface dataset:
package main

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

const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
)

func main() {
	S := getString()
	T := getString()
	fmt.Println(T + S)
}

type Graph struct {
	n     int
	edges [][]int
}

func NewGraph(n int) *Graph {
	g := &Graph{
		n:     n,
		edges: make([][]int, n),
	}
	return g
}

func (g *Graph) AddEdge(u, v int) {
	g.edges[v] = append(g.edges[v], u)
	g.edges[u] = append(g.edges[u], v)
}

func dfs(c int, edges [][]int, visited map[int]struct{}) {
	visited[c] = struct{}{}

	for _, v := range edges[c] {
		_, flag := visited[v]
		if flag {
			continue
		}
		dfs(v, edges, visited)
	}
}

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

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

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func powMod(n, p int) int {
	if p == 0 {
		return 1
	} else if p%2 == 0 {
		t := powMod(n, p/2)
		return calcMod(t * t)
	} else {
		return n * powMod(n, p-1)
	}
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func printIntArray(array []int) {
	strArray := fmt.Sprint(array)
	fmt.Println(strArray[1 : len(strArray)-1])
}

func calcMod(x int) int {
	return x % mod
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
  int s=a+b;
  int m=a*b;
  int sb=a-b;
  if(s>m && s>sb)
    cout<<s;
  else if(m>s && m>sb)
      cout<<m;
      else
    cout<<sb;
}


Measured memory_bytes: 256
package main

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

func newScanner() *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	return scanner
}

var sc = newScanner()

func scanInt() int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}

func scanInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt()
	}
	return a
}

func scanString() string {
	if sc.Scan() {
		return sc.Text()
	}
	panic(sc.Err())
}

type edge struct {
	from, to, cost int
}

func main() {
	v, e := scanInt(), scanInt()
	edges := make([]edge, e)
	for i := 0; i < e; i++ {
		edges[i] = edge{scanInt(), scanInt(), scanInt()}
	}
	warshallFloyd(v, e, edges)
}

func debug(a ...interface{}) {
	fmt.Println(a...)
}

const inf = 100000000000000000
const infMin = 100000000000000

func warshallFloyd(v, e int, edges []edge) {
	dp := make([][]int, v)
	for i := 0; i < v; i++ {
		dp[i] = make([]int, v)
		for j := 0; j < v; j++ {
			if i != j {
				dp[i][j] = inf
			}
		}
	}
	for _, e := range edges {
		dp[e.from][e.to] = e.cost
	}
	for k := 0; k < v; k++ {
		for i := 0; i < v; i++ {
			for j := 0; j < v; j++ {
				dp[i][j] = min(dp[i][j], dp[i][k]+dp[k][j])
			}
		}
	}
	for i := 0; i < v; i++ {
		if dp[i][i] < 0 {
			fmt.Println("NEGATIVE CYCLE")
			return
		}
	}
	for i := 0; i < v; i++ {
		for j := 0; j < v; j++ {
			if dp[i][j] > infMin {
				fmt.Print("INF")
			} else {
				fmt.Print(dp[i][j])
			}
			if j == v-1 {
				fmt.Print("\n")
			} else {
				fmt.Print(" ")
			}
		}
	}
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}



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

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

  bool t = false;

  for(char c='a';c<='z';c++) {
    t=false;
    for(int i=0;i<S.size();i++) {
      if(S.at(i)==c) t=true;
    }
    if(!t){
      cout << c << endl;
      return 0;
    }
  }
  if(t) cout << "None" << endl;
}


Measured memory_bytes: 512
package main

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

func main() {
	X := abs(nextInt64())
	K := nextInt64()
	D := nextInt64()

	n := X / D

	if n >= K {
		fmt.Println(X - D*K)
	} else if (K-n)%2 == 0 {
		fmt.Println(abs(X - D*n))
	} else {
		fmt.Println(abs(X - D*(n+1)))
	}
}

func abs(a int64) int64 {
	if a > 0 {
		return a
	}
	return -a
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}

func debug(args ...interface{}) {
	fmt.Fprintln(os.Stderr, args)
}


Measured memory_bytes: 1808
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
ll n;
int main(void)
{
	cin>>n;
	vector<ll> dp(n);
	vector<ll> sum(n);
	for (int i = 0; i < n; i++) {
		if(i==0){
			dp[i]=n%mod;
			sum[i]=(dp[i]+n-1)%mod;
			continue;
		}
		else if(i==1){
			dp[i]=n*n%mod;
		}
		else if(i==2){
			dp[i]=(dp[i-1]+(n-1)*n)%mod;
		}
		else {
			dp[i]=(dp[i-1]+sum[i-3]+n*(n-i+1))%mod;
		}
		sum[i]=(sum[i-1]+dp[i]+n-1)%mod;
	}
	cout<<dp[n-1]<<endl;
	return 0;
}


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

int n;
string s;

int main() {
    cin >> n >> s;

    vector<int> l(n+1, 0);
    vector<int> r(n+1, 0);

    for (int i = 0; i < n; ++i) 
        l.at(i+1) = l.at(i) + (s.at(i)=='W');

    for (int i = n-1; i >= 0; --i) 
        r.at(i) = r.at(i+1) + (s.at(i)=='E');

    int ans = 2000000000;
    for (int i = 0; i < n; ++i) 
        ans = min(ans, l.at(i)+r.at(i+1));

    cout << ans << endl;
}

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

using Container = std::vector<int>;

int main()
{
  std::string s;
  std::cin >> s;

  if (s == "Sunny") {
    std::cout << "Cloudy";
  } else if (s == "Cloudy") {
    std::cout << "Rainy";
  } else {
    std::cout << "Sunny";
  }
  std::cout << std::endl;
}


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

int main()
{
  long long X;
  cin >> X;
  
  long long v = 100.0;
  int N=0;
  for( ; ; N++)
  {
     long long v0 = v / 100;
     v = v + v0;
    
     if(X <= v)
     {
       cout << N+1 << endl;
       break;
     }
  }
}


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

int main(){
  int n;
  while(cin>>n,n){
    pair<double,string> p[50];
    string s;
    for(int i=0;i<n;i++){
      double pr,a,b,c,d,e,f,sh,m;
      cin>>s>>pr>>a>>b>>c>>d>>e>>f>>sh>>m;
      p[i]=make_pair(-(sh*f*m-pr)/(m*(e+d)+a+b+c),s);
    }
    sort(p,p+n);
    for(int i=0;i<n;i++)cout<<p[i].second<<endl;
    cout<<'#'<<endl;
  }
  return 0;
}

Measured memory_bytes: 3208
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint N, M; cin >> N >> M;
    vec<lint> H_list(N);
    range(i, 0, N) cin >> H_list.at(i);
    vec<vec<lint>> adj(N, vec<lint>());
    range(i, 0, M) {
        lint A, B; cin >> A >> B;
        A--; B--;
        adj.at(A).emplace_back(B);
        adj.at(B).emplace_back(A);
    }
    lint ans = 0;
    range(i, 0, N) {
        lint max_neighborhood_height = 0;
        for (const auto& neighbor : adj.at(i)) max_neighborhood_height = max(max_neighborhood_height, H_list.at(neighbor));
        ans += H_list.at(i) > max_neighborhood_height;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 9800
#!/usr/bin/python3
# -*- coding: utf-8 -*-
a, b, k = map(int, input().split())
if a - k >= 0:
    print(a-k, b)
else:
    x = k - a
    if b - x >= 0:
        print(0, b - x)
    else:
        print(0, 0)



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

int main() {
    string s;
    cin >> s;
    int counter = 0;
    if (s[0] == '1') ++counter;
    if (s[1] == '1') ++counter;
    if (s[2] == '1') ++counter;
    cout << counter << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>

using namespace std;
int main() {
    long long int n,m;
    cin >> n >> m;
    if (n < m) {
        swap(n,m);
    }

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

    if (m <= 1) {
        cout << n - 2 << endl;
        return 0;
    }

    cout << (n-2) * (m-2) << endl;
    return 0;
}


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

class Dijkstra {
public:
    struct edge { long long v, dist; };

    struct state {
        long long v, cost;
        bool operator>(const state s) const { return cost > s.cost; }
    };

    const long long INF = (1LL << 60);
    long long N;
    vector< vector<edge> > E;

    Dijkstra(long long n): N(n), E(n) {}

    void add_directed_edge(long long u, long long v, long long d) {
        E[u].push_back((edge) { v, d });
    }

    void add_undirected_edge(long long u, long long v, long long d) {
        E[u].push_back((edge) { v, d });
        E[v].push_back((edge) { u, d });
    }

    vector<long long> shortest_path(long long S) {
        vector<long long> dp(E.size(), INF);
        priority_queue<state, vector<state>, greater<state> > q;
        q.push((state) { S, 0 });
        while(!q.empty()) {
            long long v = q.top().v, cost = q.top().cost;
            q.pop();
            if(dp[v] <= cost) continue;
            dp[v] = cost;
            for(int i=0;i < E[v].size() ; i++) {
            long long nv = E[v][i].v, ncost = cost + E[v][i].dist;
            if(dp[nv] > ncost) q.push((state) { nv, ncost });
            }
        }
        return dp;
    }
};



int main(){
    long long n,m,s,t;
    cin>>n>>m>>s>>t;
    s--,t--;
    Dijkstra dm(n),ds(n);

    long long v,u,a,b;

    for(int i=0;i<m;i++){
        cin>>v>>u>>a>>b;
        u--,v--;
        dm.add_undirected_edge(u,v,a);
        ds.add_undirected_edge(u,v,b);
    }

    vector<long long> money=dm.shortest_path(s);
    vector<long long> snuke=ds.shortest_path(t);

    long long ans[n];
    long long x=1e18;
    for(int i=n-1;i>=0;i--){
        ans[i]=min(x,money[i]+snuke[i]);
        x=ans[i];
    }
    for(int i=0;i<n;i++){
        cout<<(long long)1e15-ans[i]<<endl;
    }


    
}

Measured memory_bytes: 19060
#include <stdio.h>
#include <stdlib.h>
#define min(a,b) (a>b?b:a)

int main(){
  int i,n,h[100010];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&h[i]);
  }

  int cost[100010]={0,abs(h[1]-h[0])};

  for(i=0;i<n-2;i++){
    cost[i+2]=min(cost[i+1]+abs(h[i+1]-h[i+2]),cost[i]+abs(h[i]-h[i+2]));
  }

  printf("%d",cost[n-1]);

}


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

int main() {
  
  int A, B;
  cin >> A >> B;
  
  if (A >= 1 && A <= 9 && B >= 1 && B <= 9) {
    cout << A * B << endl;
  } else {
    cout << -1 << endl;
  }
    
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const long long int INF= (long long int)1e15 + 1;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

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

    bool yabai = false;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (i == j && D[i][j] != 0) {
                yabai = true;
                break;
            }
            long long int mi = INF;
            for (int k = 0; k < N; k++) {
                mi = min(mi, D[i][k] + D[k][j]);
            }
            if (mi != D[i][j]) {
                yabai = true;
                break;
            }
        }
        if (yabai) break;
    }
    if (yabai) {
        cout << "-1" << endl;
        return 0;
    }

    long long int ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            ans += D[i][j];
            for (int k = 0; k < N; k++) {
                if (i == k || j == k) continue;
                if (D[i][k] + D[k][j] == D[i][j]) {
                    ans -= D[i][j];
                    break;
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1656
sx, sy, tx, ty = map(int, input().split())
print(abs(ty-sy) * 'U' + abs(tx-sx) * 'R', end='')
print(abs(ty-sy) * 'D' + abs(tx-sx) * 'L', end='')
print('L' + (abs(ty-sy)+1) * 'U' + (abs(tx-sx)+1) * 'R' + 'D', end='')
print('R' + (abs(ty-sy)+1) * 'D' + (abs(tx-sx)+1) * 'L' + 'U')


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
# define ll long long
# define int long long
# define mo 1000000000000007
#define gok ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int dp[105][4][2],nn;
string s;
int k;
int help(int n,int k,int ch,int ex,int id)
{
    if(n<=0 || k<0)
    {
        if(n==0 && k==0)
            return 1;
        return 0;
    }
    if(dp[n][k][ch]!=-1)
        return dp[n][k][ch];
    int an=0;
  if(ch==1)
  {
      for(int i=0;i<=s[id]-'0';i++){
             if(i==s[id]-'0'){
                    if(s[id]!='0'){
                an += help(n-1,k-1,1,i,id+1);
                    }
             else{
                an += help(n-1,k,1,i,id+1);
             }
             }
                else if(i==0){
            an += help(n-1,k,0,i,id+1);
                }
            else{

                an+=help(n-1,k-1,0,i,id+1);
            }
      }
  }
  else
  {
      for(int i=0;i<=9;i++)
      {
          if(i==0){
            an+=help(n-1,k,0,i,id+1);
          }
            else{

                an += help(n-1,k-1,0,i,id+1);
            }
      }
  }
  dp[n][k][ch]=an;
  return an;
}
signed main(){
    gok
    cin>>s>>k;
    nn=s.size();
    memset(dp,-1,sizeof(dp));
    int an = help(nn,k,1,10,0);
    cout<<an;
     return 0;
}


Measured memory_bytes: 256
Scanf.scanf "%d" (fun n ->
    let hist = Array.make 100001 0 in
    let rec loop i sum =
        if i = n then sum else
            let sum = Scanf.scanf " %d" (fun a -> hist.(a) <- hist.(a) + 1; sum + a) in
            loop (i + 1) sum
    in
    let sum = loop 0 0 in
    Scanf.scanf " %d" (fun q ->
        let rec loop i sum =
            if i = q then () else
                let sum = Scanf.scanf " %d %d" (fun b c ->
                    let sum = sum - b * hist.(b) in
                    let sum = sum + c * hist.(b) in
                    hist.(c) <- hist.(c) + hist.(b);
                    hist.(b) <- 0;
                    sum
                )
                in
                let () = Printf.printf "%d\n" sum in
                loop (i + 1) sum
        in
        loop 0 sum
    )
)

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


int main()
{
    string s, t, u;
    int a, b;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;
    if (u == s)
        a--;
    else
        b--;
    cout << a << " " << b << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
using namespace std;
#define PI 3.14159265358979
typedef  long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#include<set>


//---------------------------------------------
 


int main (void)
{
    ll n;
    cin>>n;

    set<string> st;

    rep(i,n)
    {
        string s;
        cin>>s;

        st.insert(s); 
    }


    cout<<st.size()<<endl;
    
}

Measured memory_bytes: 15672
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
int n,l;
cin >> n >> l;
int n_min = INF;
ll ans=0;
int count;
REP(i,n) {
  ans += l+i;
  if(n_min>abs(l+i)) {
    n_min = abs(l+i);
    count = i;
  }
}
ans -= l+count;
cout << ans << endl;
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;
const ll LINF=1e18;

int main(){
    string s;
    cin>>s;
    if(s=="SUN")cout<<7<<endl;
    else if(s=="MON")cout<<6<<endl;
    else if(s=="TUE")cout<<5<<endl;
    else if(s=="WED")cout<<4<<endl;
    else if(s=="THU")cout<<3<<endl;
    else if(s=="FRI")cout<<2<<endl;
    else cout<<1<<endl;
}

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

using namespace std;

long long n,i;
long double ans;
bool nol,z;
long long bil[100010];

int main()
{
	cin >> n;
	nol = false;
	for(i=0;i<n;i++)
	{
		cin >> bil[i];
		if(bil[i] == 0)
		{
			nol = true;
		}
	}
	if(not nol)
	{
		ans = 1;
		z = false;
		for(i=0;i<n;i++)
		{
			ans = ans * bil[i];
			if(ans > 1000000000000000000)
			{
				z = true;
				break;
			}
		}
		if(z)
		{
			cout << "-1" << endl;
		}
		else cout << fixed<< setprecision(0) <<ans << endl;
	}
	else cout << "0" << endl;
	
	
}

Measured memory_bytes: 4460
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	string N, S;
	cin >> S;
	int keta = S.size();
	int amari = 100 - keta;
	rep(i, amari) N += '0';
	N += S;
	int K;
	cin >> K;

	ll dp[101][4][2] = {};
	dp[0][0][0] = 1;
	
	rep(i, 100) {
		rep(j, K) {
			if (N[i] == '0') dp[i + 1][j][0] += dp[i][j][0];
			else {
				dp[i + 1][j + 1][0] += dp[i][j][0];
				dp[i + 1][j + 1][1] += dp[i][j][0] * (N[i] - '0' - 1);
				dp[i + 1][j][1] += dp[i][j][0];
			}
			dp[i + 1][j + 1][1] += dp[i][j][1] * 9;
			dp[i + 1][j][1] += dp[i][j][1];
		}
		if (N[i] == '0') dp[i + 1][K][0] += dp[i][K][0];
		else dp[i + 1][K][1] += dp[i][K][0];
		dp[i + 1][K][1] += dp[i][K][1];
	}

	co(dp[100][K][0] + dp[100][K][1]);





	Would you please return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int m, n;
		int i, j;
		try (Scanner sc = new Scanner(System.in)) {
			m = sc.nextInt();
			n = sc.nextInt();
			int a[][] = new int[m][n];
			int b[] = new int[n];
			int c[] = new int[m];
			for(i = 0; i < m; i++) {
				for(j = 0; j < n; j++) {
					a[i][j] = sc.nextInt();
				}
			}
			for(i = 0; i < n; i++) {
				b[i] = sc.nextInt();
			}
			for(i = 0; i < m; i++) {
				for(j = 0; j < n; j++) {
					c[i] += a[i][j] * b[j];
				}
			}
			for(i = 0; i < m; i++) System.out.println(c[i]);
		}
	}
}



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

int main () {
  char a;
  cin >> a;
  if(isupper(a)) cout << 'A';
  else cout << 'a';
}


Measured memory_bytes: 3620
#include<functional>
#include <algorithm>
#include <iostream>
#include <memory.h>
#include <string.h>
#include <string>
#include <math.h>
#include <time.h>
#include <vector>
#include <queue>
#include<stack>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <bitset>
#include <limits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long long ll;
const int M = 1e9 + 7;
const int N = 2e5;
const int oo = 1e9;
const double pi = acos(-1);
int main() {
	//freopen("src.txt", "r", stdin);
	string s, t;
	cin >> s >> t;
	int ans = 0;
	for (int i = 0; i < 3; ++i)
		if (s[i] == t[i])
			ans++;
	cout << ans << endl;
	return 0;
}

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

int main() {

  int K, N;
  cin >> K >> N;
  
  vector<int> A(N);
for (int i = 0; i < N; i++) {
  cin >> A.at(i);
}
  
  int route, min_route;
  
  min_route = A.at(N-1) - A.at(0);
  
  for ( int i = 0; i < N-1; i++) {
  route = K - (A.at(i+1) - A.at(i));
  min_route = min(route, min_route);
  }
  
 cout << min_route << endl;

}


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

int main()
{
  int H, W;
  string board[50];

  cin >> H >> W;
  for (int i = 0; i < H; i++)
    cin >> board[i];

  int xd[4] = {1, 0, -1, 0};
  int yd[4] = {0, 1, 0, -1};
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      if (board[i][j] == '.') continue;
      int cnt = 0;
      for (int k = 0; k < 4; k++)
      {
        int xnum = j + xd[k];
        int ynum = i + yd[k];
        if (xnum < 0 || W <= xnum) continue;
        if (ynum < 0 || H <= ynum) continue;
        if (board[ynum][xnum] == '#') cnt++;
      }
      if (cnt == 0)
      {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 3604
using System;
using System.Linq;

    class Program
    {
        static void Main(string[] args)
        {
            // 入力
            var inputs = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

            var A = inputs[0];
            var B = inputs[1];
            var C = inputs[2];
            var D = inputs[3];
            var E = inputs[4];
            var F = inputs[5];

            // 砂糖水の濃度、砂糖水の質量、砂糖の質量
            var maxSWRatio = 0.0d;
            var SWRatio = 0.0d;
            var ansSugarWater = 0;
            var ansSugar = 0;


            for (int a = 0; 100 * A * a <= F; a++)
            {
                for (int b = 0; 100 * A * a + 100 * B * b <= F; b++)
                {
                    for (int c = 0; 100 * A * a + 100 * B * b + C * c <= F; c++)
                    {
                        for (int d = 0; 100 * A * a + 100 * B * b + C * c + D * d <= F; d++)
                        {
                            if (C * c + D * d <= E * (A * a + B * b))
                            {
                                try
                                {
                                    SWRatio = (double)(C * c + D * d) / (double)(100 * A * a + 100 * B * b + C * c + D * d);
                                }
                                catch (DivideByZeroException)
                                {

                                    SWRatio = 0.0d;
                                }
                                if (SWRatio >= maxSWRatio)
                                {
                                    maxSWRatio = SWRatio;
                                    ansSugarWater = 100 * A * a + 100 * B * b + C * c + D * d;
                                    ansSugar = C * c + D * d;
                                }
                            }
                        }
                    }
                }
            }


            // 出力
            Console.WriteLine("{0} {1}", ansSugarWater.ToString(), ansSugar.ToString());
            Console.ReadLine();

        }
    }


Measured memory_bytes: 13396
#include <iostream>

int main(){
	int A,B,C,X;
	std::cin>>A>>B>>C;
	std::cin>>X;
	int count;

	for(int a=0;a<=A;a++){
		for(int b=0;b<=B;b++){
			for(int c=0;c<=C;c++)
				if(500*a+100*b+50*c == X){
					count += 1;
				}
		}
	}
	std::cout<<count;
	return 0;
}


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

using ll=long long; 

void solve(){
	int n,x,y;
	cin>>n>>x>>y;
	cout<<min(x,y)<<" "<<max(0, x+y-n)<<endl;
}

signed main(){
	//while(1)
	solve();
}

Measured memory_bytes: 256
n, k = map(int, input().split())

MOD = 10 ** 9 + 7

class ModCmb:
    def __init__(self, size):
        self.inv = [1] * (size + 1)
        self.fact = [1] * (size + 1)
        temp_inv = [1] * (size + 1)
        for i in range(2, size + 1):
            temp_inv[i] = ( -(MOD // i) * temp_inv[MOD%i] ) % MOD
        for i in range(2, size + 1):
            self.fact[i] = self.fact[i-1] * i % MOD
            self.inv[i] = self.inv[i-1] * temp_inv[i] % MOD

    def cmb(self, n, r):
        if n <= 1 or n == r:
            return 1
        elif r == 1:
            return n
        else:
            return  (self.fact[n] * self.inv[r] % MOD ) * self.inv[n-r] % MOD

mc = ModCmb(n)

ans = n * (n-1) + 1

for m in range(2, min(n, k+1)):
    ans = ( ans + ((mc.cmb(n, m) % MOD) * mc.cmb(n-1, m)) % MOD ) % MOD

print(ans)

Measured memory_bytes: 44528
/*
	考虑入栈的顺序和删除的优先级
	插入 0
	1  : 直接插入
	0  : 直接插入
	00 : 变成 1 个 0
	插入 1
	1  : 直接插入
	11 : 不插入
	0  : 抵消掉一个 0
*/
#include <bits/stdc++.h>
#define N 300005

using namespace std;

const int mod = 1e9 + 7;

int n, m;
char s[N];

int f[N][3][3];

void Inc(int &u, int v) { if((u += v) >= mod) u -= mod; }

int main() {
	scanf("%s", s + 1);
	n = strlen(s + 1);
	f[0][0][0] = 1;
	for(int i = 0; i < n; ++i) {
		if(s[i + 1] == '0' || s[i + 1] == '?') {
			for(int c1 = 0; c1 < 3; ++c1) {
				Inc(f[i + 1][c1][1], f[i][c1][0]);
				Inc(f[i + 1][c1][2], f[i][c1][1]);
				Inc(f[i + 1][c1][1], f[i][c1][2]);
			}
		}
		if(s[i + 1] == '1' || s[i + 1] == '?') {
			for(int c1 = 0; c1 < 3; ++c1) {
				Inc(f[i + 1][min(c1 + 1, 2)][0], f[i][c1][0]);
				Inc(f[i + 1][c1][0], f[i][c1][1]);
				Inc(f[i + 1][c1][1], f[i][c1][2]);
			}
		}
	}
	int ans = 0;
	for(int c0 = 0; c0 < 3; ++c0)
		for(int c1 = c0; c1 < 3; ++c1)
			Inc(ans, f[n][c1][c0]);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 11136
#include <stdio.h>

int cards[200];
int save[200];
int n;

void cut(int k) {
    int i;

    for (i=0;i < 2*n;i++) {
        save[i] = cards[i];
    }

    for (i=0;i < 2*n;i++) {
        cards[i] = save[(i+k)%(2*n)];
    }

    return;
}

void riffle() {
    int i;

    for (i=0;i < 2*n;i++) {
        save[i] = cards[i];
    }

    for (i=0;i < n*2;i++) {
        if (i % 2) {
            cards[i] = save[n+i/2];
        } else {
            cards[i] = save[i/2];
        }
    }

    return ;
}

int main() {
    int i, m;

    scanf("%d", &n);
    for (i=0;i<n*2;i++) {
        cards[i] = i+1;
    }

    scanf("%d", &m);
    for (i=0;i<m;i++) {
        int query;
        scanf("%d", &query);
        if (query == 0) {
            riffle();
        } else {
            cut(query);
        }
    }

    for (i=0;i<n*2;i++) {
        printf("%d\n", cards[i]);
    }
}

Measured memory_bytes: 1028
function Main(input) {
  input=input.split(/\n/)
    var n= parseInt(input[0]);
	const ip = input[1].split(" ").map(val => parseInt(val, 10));
	ip.sort(compareFunc);
	var c = parseInt(ip[0]);
	for(var i=1;i<n;i++){
	   c = (c+ip[i])/2;
	}
	console.log(c);
}
 
function compareFunc(a, b) {
    return parseFloat(a) - parseFloat(b);
}
     
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7756
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int a;
  cin >> a;
  int c = 0;

  for(int i = 0; i < a; i++){
    if(i >= 0 && i < 9){
      c++;
    }
    else if(i >= 99 && i < 999){
      c++;
    }
    else if(i >= 9999 && i < 99999){
      c++;
    }
  }
  cout << c << endl;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define maxs(a,b) a=max(a,b)
#define mins(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

int main(){

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

    rep(i,n){
       cout<<s[i]<<t[i];
    }
    cout<<"\n";

    return 0;

}

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

typedef long long ll;
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define SORT(s) sort((s).begin(),(s).end())

int main(){
    int N; cin >> N;
    vector<ll> L(N);
    REP(i,N){cin >> L[i];}

    SORT(L);
    ll sum_L = 0;
    REP(i,N-1){sum_L += L[i];}
    if(sum_L > L[N-1]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long X=1000000000+7;
const string d="dream";
const string e="erase";

int main() {
  long x,a,b;
  cin>>x>>a>>b;
  if(a>=b) cout<<"delicious"<<endl;
  else if(a+x>=b) cout<<"safe"<<endl;
  else cout<<"dangerous"<<endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
sys.setrecursionlimit(10**7)
from pprint import pprint as pp
from pprint import pformat as pf
# @pysnooper.snoop()
#import pysnooper # debug

import math
#from sortedcontainers import SortedList, SortedDict, SortedSet # no in atcoder
import bisect


if __name__ == '__main__':
    x, k = list(map(int, input().split()))
    m = math.inf
    if x > k:
        x = x % k
    for _ in range(3):
        x = abs(x - k)
        m = min(x, m)
    print(m)


    #print('\33[32m' + 'end' + '\033[0m') # debug


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

#define ll long long
#define mod 1000000007
#define ff first
#define ss second
#define pii pair<int,int>
#define pb push_back
#define IOS ios_base::sync_with_stdio(false),cin.tie(NULL);
#define endl '\n'
void tests(){
    int n;
  cin>>n;
  string s="";
  for(int i=0;i<n;i++)
    s+="ACL";
  cout<<s<<endl;
}
int main( int argc , char ** argv ){
	ios_base::sync_with_stdio(false) ; 
	cin.tie(NULL) ; 
	ll t = 1;
	//cin>>t;
	while(t--){
		tests();
	}
 	return 0 ; 
}

Measured memory_bytes: 3580
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
   int n=0;
   double a[110000],b=0;
   
   cin>>n;
   
    for(int i=0;i<n;i++){
       cin>>a[i];
   }
   sort(a,a+n);
   b+=a[0];
   
   for(int i=1;i<n;i++){
       b=(b+a[i])/2;
   }
   
   cout<<b<<endl;
   
    
}


Measured memory_bytes: 256
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000

typedef long long ll;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const int MAXN = 100010;

string name[MAXN];
int t[MAXN];

int main(void) {
    int n, q, time = 0;
    cin >> n >> q;
    queue<int> que;
    for (int i = 0; i < n; i++) {
        cin >> name[i] >> t[i];
        que.push(i);
    }
    while (que.size()) {
        int now = que.front();
        que.pop();
        if (t[now] > q) {
            t[now] -= q;
            que.push(now);
            time += q;
        } else {
            cout << name[now] << " " << time + t[now] << endl;
            time += t[now];
        }
    }
    return 0;
}

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

int main() {
    int n, m, x;
    cin >> n >> m >> x;
    int a[m];
    for (int i = 0; i < m; i++)
        cin >> a[i];
    int less = 0, more = 0;
    for (int i = 0; i < m; i++) {
        if (a[i] < x)
            less++;
        else
            more++;
    }
    cout << min(less, more) << endl;
    return 0;
}

Measured memory_bytes: 256
from functools import reduce
N, M = map(int, input().split())
L = 1 << N
table = {0: 0}
for _ in range(M):
    cost, _ = map(int, input().split())
    match = reduce(lambda a, b: a | b, (1 << shamt for shamt in map(lambda n: int(n) - 1, input().split())))
    for l, now in table.copy().items():
        table[l | match] = min(now + cost, table.get(l | match, 10 ** 7))
print(table[L - 1] if table.get(L - 1, False) else -1)

Measured memory_bytes: 78940
#![allow(non_snake_case, unused_macros, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,BTreeMap};

// Main
fn main(){
    input!{
        c: chars,
    }
    let vowel = ['a','i','u','e','o'];
    println!("{}", if vowel.into_iter().any(|v| *v==c[0]) {"vowel"}else{"consonant"});
}




Measured memory_bytes: 4352
#include<iostream>
#include<string>
using namespace std;
int main(){
  long long c=0,d[1001][1001]={};
  string a,b;
  cin>>a>>b;
  for(int i=0;i<a.size();i++){
    if(b[0]==a[i])d[0][i]++; 
  }
  for(int i=1;i<b.size();i++){
    c=0;
    for(int j=i;j<a.size();j++){
      c=(c+d[i-1][j-1])%1000000007;
      if(b[i]==a[j])d[i][j]=c;
    }
  }
  c=0;
  for(int i=0;i<a.size();i++)c=(c+d[b.size()-1][i])%1000000007;
  cout<<c<<endl;
  return 0;
}

Measured memory_bytes: 11028
a = [0] * 100000

for i in range(1, 101):
    for j in range(i, 101):
        for k in range(j, 101):
            tmp = 0
            if i != j and j != k:
                tmp = 6
            elif i == j and j != k:
                tmp = 3
            elif i != j and j == k:
                tmp = 3
            elif i == k:
                tmp = 1
            ind = pow(i, 2) + pow(j, 2) + pow(k, 2) + i*j + j*k + k*i
            a[ind] += tmp
N = int(input())
for i in range(1, N+1):
    print(a[i])

Measured memory_bytes: 9892
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/


typedef long long ll;
#define INF 1LL<<60
int N, M, A[2020], B[2020], C[2020];
ll ans[1010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> M;
    rep(i, 0, M) {
        cin >> A[i] >> B[i] >> C[i];
        A[i]--;
        B[i]--;
    }

    rep(i, 0, N) ans[i] = -INF;
    ans[0] = 0;

    rep(i, 0, N * 8) rep(j, 0, M) {
        int a = A[j], b = B[j];
        ans[b] = max(ans[b], ans[a] + C[j]);
    }
    
    ll pre = ans[N - 1];

    rep(i, 0, N * 8) rep(j, 0, M) {
        int a = A[j], b = B[j];
        ans[b] = max(ans[b], ans[a] + C[j]);
    }

    if (pre < ans[N - 1]) printf("inf\n");
    else printf("%lld\n", ans[N - 1]);
}

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

using namespace std;

#define cerr if(false)cerr
#define what(x) cerr<<#x<<" = "<<x<<endl
 
typedef long long ll;
typedef pair<ll, ll> ii;

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 322;


int n, m, x;
int cost[20];
int mat[20][20];
int min_cost = 1e9;

void solve(int indx, vector<bool>& arr){
	if(indx == n){
		int cos = 0;
		vector<int> sums(n, 0);
		for(int i = 0; i < n; i++){
			if(!arr[i])continue;
			cos += cost[i];
			for(int j= 0; j < m; j++){
				sums[j] += mat[i][j];
			}
		}
		bool flag = true;
		for(int j = 0; j < m; j++){
			if(sums[j] < x)flag = false;
		}
		if(flag){
			min_cost = min(min_cost, cos);
		}
	}else{
		arr[indx] = false;
		solve(indx + 1, arr);
		arr[indx] = true;
		solve(indx + 1, arr);
		arr[indx] = false;
	}
}

int main(){

	ios_base::sync_with_stdio(false); 
	cin.tie(0);
	cout.tie(0);


	cin >> n >> m >> x;

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

	vector<bool> arr(m, false); 
	solve(0, arr);

	cout << (min_cost == 1e9 ? -1 : min_cost) << endl;

	return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int sumd(int d){
    int s = 0;
    while(d > 0){
        s += d % 10;
        d /= 10;
    }
    return s;
}

int main() {

    int n, a, b;
    cin >> n >> a >> b;
    int ans = 0;
    rep(i, 1, n + 1){
        int tmp = sumd(i);
        if (a <= tmp && tmp <= b) ans += i;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

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

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

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

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

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)

	N, K := getInt(), getInt()
	s := getString()

	lr := 0
	rl := 0
	rr := 0
	ll := 0
	l := 0
	r := 0
	for i := 1; i < N; i++ {
		if s[i] == 'R' {
			r++
		}
		if s[i] == 'L' {
			l++
		}
		if s[i-1] == 'L' && s[i] == 'R' {
			lr++
		}
		if s[i-1] == 'R' && s[i] == 'L' {
			rl++
		}
		if s[i-1] == 'R' && s[i] == 'R' {
			rr++
		}
		if s[i-1] == 'L' && s[i] == 'L' {
			ll++
		}
	}
	ans := min(K*2, lr+rl)
	ans += ll + rr
	ans = min(N-1, ans)
	out(ans)
}


Measured memory_bytes: 896
package main

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

var sc = bufio.NewScanner(os.Stdin)

func b2i(a []byte) (n int) {
	for _, v := range a {
		n = n*10 + int(v-48)
	}
	return
}

func ri() int {
	sc.Scan()
	return b2i(sc.Bytes())
}

func rs() []byte {
	sc.Scan()
	return sc.Bytes()
}

func eq(a, b []byte) bool {
	for i := range a {
		if a[i] != b[i] {
			return false
		}
	}
	return true
}

func main() {
	sc.Split(bufio.ScanWords)
	n, m := ri(), ri()
	a := make([][]byte, n)
	for i := 0; i < n; i++ {
		a[i] = rs()
	}
	b := make([][]byte, m)
	for i := 0; i < m; i++ {
		b[i] = rs()
	}

	var fg int
	for i := 0; i < n-m+1; i++ {
		for j := 0; j < n-m+1; j++ {
			fg = 0
			for k := 0; k < m; k++ {
				if eq(a[i+k][j:j+m], b[k]) {
					fg++
				}
				if fg == k {
					break
				}
			}
			if fg == m {
				fmt.Println("Yes")
				return
			}
		}
	}
	fmt.Println("No")
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<vector>

#define INF 999999999
#define ll long long

using namespace std;

const int MAX_N = 1000;
const int MAX_M = 2000;

struct edge
{
	int from;  //?????????
	int to;    //??°??????
	int cost;  //??????
};

int d[MAX_N];
edge es[MAX_M];
bool flag;	//???????????????????????????

void shortest_path(int n,int m,int s)	//s???????????????????????????????????????????????¢????±???????
{
	int cnt = 0;
	fill(d,d+n,INF);
	d[s] = 0;
	while(true && cnt < n){
		bool update = false;
		for(int i=0;i<m;i++){
			edge e = es[i];
			if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost){
				d[e.to] = d[e.from] + e.cost;
				update = true;
			}
		}
		if(!update) break;
		cnt++;
	}
	if(cnt == n){
		flag = true;
	}
}

int main()
{
	int i,n,m,s;
	cin >> n;  //????????°
	cin >> m;  //?????°
	cin >> s;  //???????????????
	for(int i=0;i<m;i++){
		scanf("%d",&es[i].from);
		scanf("%d",&es[i].to);
		scanf("%d",&es[i].cost);
	}
	flag = false;
	shortest_path(n,m,s);
	if(!flag){
		for(int i=0;i<n;i++){
			if(d[i] == INF){
				cout << "INF\n";
			}else{
				cout << d[i] << "\n";
			}
		}
	}else{
		cout << "NEGATIVE CYCLE\n";
	}
}

Measured memory_bytes: 3240
n, m = map(int, input().split())

ps = list(map(int, input().split()))

par = [i for i in range(n)]
rank = [0]*n

def UnionFind(n):
    if par[n] == n:
        return n

    parent = par[n]
    par[n] = UnionFind(parent)
    return par[n]


def Unite(left, right):
    rootLeft = UnionFind(left)
    rootRight = UnionFind(right)
    if rootLeft != rootRight:
        if rank[rootRight] < rank[rootLeft]:
            par[rootRight] = rootLeft
        else:
            par[rootLeft] = rootRight
            if rank[rootLeft] == rank[rootRight]:
                rank[rootLeft] += 1



for i in range(m):
    a, b = (i-1 for i in map(int, input().split()))
    Unite(a, b)

sum = 0
for i, p in enumerate(ps):
    sourceRoot = UnionFind(i)
    targetRoot = UnionFind(p - 1)
    if sourceRoot == targetRoot:
       sum += 1

print(sum)



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

M = 0

for i in range(N):
  if B[N-1-i] < A[N-i]:
    M += B[N-1-i]
    B[N-1-i] = 0
  elif B[N-1-i] >= A[N-i] and B[N-1-i] < A[N-i] + A[N-i-1]:
    M += B[N-1-i]
    A[N-i-1] -= B[N-1-i] - A[N-i]
    B[N-1-i] = 0
  elif B[N-1-i] >= A[N-i] + A[N-1-i]:
    M += A[N-i] + A[N-1-i]
    A[N-i-1] = 0

print(M)

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

using namespace std;
using ll = long long int;
#define long ll

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

    ll n;
    cin >> n;
    vector<ll> a(n+2);
    for(ll i=0; i<n; i++)
        cin >> a[i+1];

    ll s = 0;
    for(ll i=1; i<n+2; i++)
        s += abs(a[i] - a[i-1]);

    for(ll i=1; i<=n; i++)
        cout << s - (abs(a[i-1] - a[i]) + abs(a[i] - a[i+1])) + abs(a[i+1] - a[i-1]) << endl;
}


Measured memory_bytes: 2048
import java.util.Scanner;

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

        String A = sc.next();
        String B = sc.next();
        String C = sc.next();

        System.out.println(solve(A, B, C) ? "YES" : "NO");

        sc.close();
    }

    static boolean solve(String A, String B, String C) {
        return A.charAt(A.length() - 1) == B.charAt(0) && B.charAt(B.length() - 1) == C.charAt(0);
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
#ifdef _debug
#define dout(i) cout << #i << ' ' << i << ' '
#else 
#define dout(i) 0&&0
#endif
#define rout(i) cout << i << '\n', 0
using ll = long long;
using ull = unsigned long long;
using ul = unsigned;
using db = double;
template<typename T, typename S>
istream& operator >> (istream &in, pair<T,S> &a){
	return in >> a.first >> a.second;
}
template<typename T, typename S>
ostream& operator << (ostream &ou, pair<T,S> &a){
	return ou << a.first << ' ' << a.second;
}
int n;
const int maxn = 1000;
int res;
set<int> sp;
pair<int,int> a[maxn], b[maxn];
int main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n;
	for(int i = 0;i < n;++i)cin >> a[i];
	for(int i = 0;i < n;++i)cin >> b[i];
	sort(a, a+n);
	sort(b, b+n);
	sp.insert(-1);
	for(int i = 0, j = 0;i < n;++i){
		for(;j < n and a[j].first < b[i].first;++j)sp.insert(a[j].second);
		auto it = prev(sp.lower_bound(b[i].second)); 
		if(*it != -1){
			++res;
			sp.erase(it);
		}
	}
	cout << res << '\n';
}

Measured memory_bytes: 256