akhauriyash/Code-Regression huggingface dataset:
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-04-05 18:37:07
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rev(x) greater<x>()
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

LL modpower(LL n, LL m, LL mod) {
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod) {
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod) {
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

int gcd(int k, int l) {
    if (l > 0) return gcd(l, k%l);
    else return k;
}

struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n) {
        for (int i = 0; i < n; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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

    queue<LL> que;
    for (int i = 1; i <= 9; i++)
        que.push(i);
    
    int cnt = 0;
    LL ans;
    while (!que.empty()) {
        LL x = que.front();
        que.pop();

        if (++cnt == k) {
            ans = x;
            break;
        }

        if (x % 10 > 0) que.push(10*x + (x%10) - 1);

        que.push(10*x + (x%10));

        if (x % 10 < 9) que.push(10*x + (x%10) + 1);
    }

    cout << ans << endl;

    return 0;
}


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

int main() {
  int N,sum=0;
  cin >> N;
  for(int n=N; n!=0; n/=10){
    sum+=n%10;
  }
  if(N%sum==0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int w = Integer.parseInt(sc.next());
		int h = Integer.parseInt(sc.next());
		String[] s = new String[w];
		char[][] c = new char[w][h];
		int[] x = {-1,-1,-1,0,0,1,1,1};
		int[] y = {-1,0,1,1,-1,-1,1,0};
		for (int i = 0; i < w; i++) {
			s[i] = sc.next();
		}
		for(int i = 0; i < w;i++) {
			for(int j = 0; j < h; j++) {
				c[i][j] = s[i].charAt(j);
			}
		}
		for (int i = 0; i < w ; i++) {
			for (int j = 0; j < h; j++) {
				int count = 0;
				if(c[i][j] == '.') {
					for(int k = 0;k < 8; k++) {
						if(x[k]+i>=0 && x[k]+i <w && y[k]+j >=0 &&y[k]+j<h) {
							if(c[x[k]+i][y[k]+j]=='#') {
							 count++;
							}
						}
					}
					String temp = String.valueOf( count);
					c[i][j] = temp.charAt(0);
				}
			}
		}
		for(int i = 0; i < w;i++) {
			for(int j = 0; j < h; j++) {
				System.out.print(c[i][j]);
			}
			System.out.println("");
		}
			}
		}

Measured memory_bytes: 21844
#include <stdio.h>

int main()
{
  int w,h,x,y,r;
  scanf("%i%i%i%i%i", &w, &h, &x, &y, &r);
  if (0 <= x - r && 0 <= y -r) {
    if (x + r <= w && y + r <= h) {
         puts("Yes");
    } else {
         puts("No");
    }
  } else {
    puts("No");
  }
}




Measured memory_bytes: 2148
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cctype>
using namespace std;

int main(){
    char s1[100];
    char s2[100];
    char s3[200];

    cin >> s1;
    cin >> s2;

    // cout << s1 << endl;
    // cout << s2 << endl;

    strcat(s3, s1);
    strcat(s3, s1);

    // cout << s3 << endl;
    // cout << s2 << endl;

    if(NULL == strstr(s3, s2)){
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }

    // cout << "0" << endl;

    return 0;
}


Measured memory_bytes: 3080
#include<iostream>
#include<complex>
#include<algorithm>
#define EPS 1e-10
using namespace std;

typedef complex<double> P;

int n,m;
P p[100][4];

double cross(P a,P b){return imag(conj(a)*b);}
double dot(P a,P b){return real(conj(a)*b);}

int ccw(P a,P b,P c){
  b -= a;c -= a;
  if (cross(b,c)>EPS) return 1;
  if (cross(b,c)<-EPS) return -1;
  if (dot(b, c)<-EPS) return 2;
  if (abs(b)<abs(c)) return -2;
  return 0;
}

bool is_cp(P a1, P a2, P b1, P b2){
  return (ccw(a1,a2,b1)*ccw(a1,a2,b2) <= 0 && ccw(b1,b2,a1)*ccw(b1,b2,a2) <= 0);
}

bool interp(int q, P x){
  for(int i=0;i<4;i++)
    if(ccw(p[q][i],p[q][(i+1)%4],x) == 1)return false;
  return true;
}

bool inter(int q1,int q2){
  for(int i=0;i<4;i++)if(interp(q1,p[q2][i]))return true;
  for(int i=0;i<4;i++)if(interp(q2,p[q1][i]))return true;
  for(int i=0;i<3;i++)
    for(int j=0;j<3;j++)
      if(is_cp(p[q1][i],p[q1][(i+1)%4],p[q2][j],p[q2][(j+1)%4]))return true;
  return false;
}

int par[100];
int rank[100];

void init(int n){
  for(int i=0;i<n;i++){
    par[i] = i;
    rank[i] = 0;
  }
}

int find(int x){
  if(par[x] == x)return x;
  return par[x] = find(par[x]);
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x==y)return;

  if(rank[x] < rank[y])par[x] = y;
  else{
    par[y] = x;
    if(rank[x] == rank[y])rank[x]++;
  }
}

int main(){
  while(cin >> n && n){
    for(int i=0;i<n;i++){
      cin >> m;
      for(int j=0;j<m;j++)
	for(int k=0;k<4;k++)cin >> p[j][k].real() >> p[j][k].imag();

      init(m);

      for(int j=0;j<m;j++)
	for(int k=0;k<j;k++)
	  if(find(j)!=find(k) && inter(j,k))unite(j,k);

      int ans = 0;
      for(int j=0;j<m;j++){
	find(j);
	if(par[j]==j)ans++;
      }
      cout << ans << endl;
    }
  }
}

Measured memory_bytes: 984
from collections import defaultdict


class UnionFind:
    def __init__(self, n: int):
        self.n = n
        self.parents = [-1] * n
    
    def find(self, x: int):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    
    def union(self, x: int, y: int):
        x = self.find(x)
        y = self.find(y)
        
        if x == y:
            return
        if self.parents[y] < self.parents[x]:
            x, y = y, x
        
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    
    def size(self, x: int):
        return -self.parents[self.find(x)]
    
    def same(self, x: int, y: int):
        return self.find(x) == self.find(y)
    
    def members(self, x: int):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
    
    def group_count(self):
        return len(self.roots())
    
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def solve():
    N, K, L = map(int, input().split())
    connect_road, connect_rail = UnionFind(N), UnionFind(N)
    for _ in range(K):
        p, q = map(lambda x: int(x) - 1, input().split())
        connect_road.union(p, q)
    for _ in range(L):
        r, s = map(lambda x: int(x) - 1, input().split())
        connect_rail.union(r, s)
    
    root = defaultdict(int)
    for i in range(N):
        root[(connect_road.find(i), connect_rail.find(i))] += 1
    for i in range(N):
        print(root[(connect_road.find(i), connect_rail.find(i))])


if __name__ == '__main__':
    solve()


Measured memory_bytes: 41568
// http://blog.myungwoo.kr/category/ICPC
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <set>
#include <string>

#include <cmath>
#include <vector>
#include <iostream>
#include <iomanip>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> PII;
typedef vector<PII> VP;


int main() {
	ios::sync_with_stdio(false);
	ll a, b, c;
	cin >> a >> b >> c;
	if (a%2 == 0 || b%2 == 0 || c%2 == 0) {
		cout << 0;
	} else
		cout << min(min(a*b, b*c), a*c);
}

Measured memory_bytes: 256
#include <iostream>

typedef long long ll;
const ll MOD = 1e9+7;

int N;
ll ar[200005];
ll sum[200005];

int main() {
  std::cin >> N;
  for (int i = 0; i < N; ++i)
    std::cin >> ar[i];

  sum[N-1] = ar[N-1] % MOD;
  for (int i = N-2; i >= 0; --i)
    sum[i] = (ar[i] + sum[i + 1]) % MOD;

  ll ans = 0;
  for (int i = 0; i < N-1; ++i)
    ans = (ans + (ar[i] * sum[i+1]) % MOD) % MOD;
  std::cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 6684
#include <stack>
#include <cstdio>
#include <queue>
#include <iostream>
using namespace std;

int main(){
  stack <int> s;
  int c;
  int count=0;
  while(cin >> c){
    if(c==0){
      cout << s.top() << endl;
      s.pop();
    }
    else
      s.push(c);
  }
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000000

int main()
{
     ll n;
     cin>>n;
     string a,b;
     cin>>a>>b;
     for(int i=0;i<n;i++)
        cout<<a[i]<<b[i];
 return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String args[]) {

        Scanner scn = new Scanner(System.in);
        int n = scn.nextInt();
        int count;
        int num = 130;
        int[] ans = new int[10000];
        Arrays.fill(ans, 0);


        for (int x = 1; x <= num; x++) {
            for (int y = 1; y <= num - x; y++) {
                for (int z = 1; z <= num - x - y; z++) {
                    long temp = (x + y + z) * (x + y + z) - ((x * y) + (y * z) + (x * z));
                    if (temp <= 10000 && temp > 0) {
                        int number = (int) temp;
                        ans[number - 1] += 1;
                    }
                }
            }
        }

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


        scn.close();

    }


}


Measured memory_bytes: 30080
#include<iostream>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<algorithm>
#include<stdio.h>
#include<utility>
int cnt[100];
using namespace std;
int main() {
	int n;
	cin >> n;
	
	if (n < 105) {
		cout << "0" << endl;
		
	}
	else if (n < 135) cout << "1" << endl;
	else if(n<165){
		cout << "2" << endl;
	}
	else if (n < 189) cout << "3" << endl;
	else if (n < 195) cout << "4" << endl;
	else cout << "5" << endl;
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cstdlib>
#include<vector>
using namespace std;
long long gcd(long long a, long long b){
  if(a % b == 0)    return b;

  return gcd(b , a % b);
}

int main(void){
  int N;  cin >> N;
  long long X;  cin >> X;
  vector<long long> dif_x(N);

  for(int i = 0 ; i < N ; i++){
    long long input;  cin >> input;
    dif_x[i] = llabs(X - input);
  }

  long long ans = dif_x[0];
  for(int i = 1 ; i < N ; i++)
    ans = gcd(ans , dif_x[i]);

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

Measured memory_bytes: 1024
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <iomanip>
#include <tuple>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;

P target[200];
P stars[1000];
int n;
int m;
void exec()
{
	cin >> m;
	if(m==0)exit(0);
	//cout << m << endl;
	for(int i=0;i<m;i++){
		cin >> target[i].first >> target[i].second;
	}
	sort(target,target+m);
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> stars[i].first >> stars[i].second;
	}
	sort(stars,stars+n);
	for(int i=0;i<n;i++){
		int x=stars[i].first-target[0].first;
		int y=stars[i].second-target[0].second;
		int p=i+1;
		int q=1;
		while(p<n&&q<m){
			P t=P(target[q].first+x,target[q].second+y);
			if(stars[p]<t){
				p++;
			}
			else if (stars[p]>t)
			{
				break;
			}
			else
			{
				p++;
				q++;
			}
		}
		if(q==m){
			cout << x << " " << y << endl;
			return;
		}
	}
}
int main() {
	while(1)exec();
}

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

long long int euklid(long long int a, long long int b) {
	long long int x = max(a, b), y = min(a, b);
	long long int re = x % y;
	while (re > 0) {
		x = y;
		y = re;
		re = x % y;
	}
	return y;
}

int main(void)
{
	int N; cin >> N;
	vector<long long int> A(N);
	for (int i = 0; i < N; i++)cin >> A[i];
	long long int ans = A[0];
	for (int i = 1; i < N; i++)ans = euklid(ans, A[i]);
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<=int(b);++i)
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for(int j=0;j<N;++j) {

int main(void) {
  int s,w;cin>>s>>w;
  if(s>w) {
    pr("safe");
  } else {
    pr("unsafe");
  }
  return 0;
}


Measured memory_bytes: 3636
package main

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

// const abcd = "abcdefghijklnmopqrstuvwxyz"
// const ABCD = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

// var dy = [...]int{1, 1, 0, -1, -1, -1, 0, 1}
// var dx = [...]int{0, 1, 1, 1, 0, -1, -1, -1}

// var dx = [...]int{0, 1, 0, -1}
// var dy = [...]int{1, 0, -1, 0}

var inf int = 1e13
var mod = 1000000007

// ---------------------------------------------------------
func main() {
	log.SetFlags(log.Lshortfile)
	next := newScanner()
	H := next.Int()
	W := next.Int()
	h := next.Int()
	w := next.Int()
	if H%h == 0 && W%w == 0 {
		fmt.Println("No")
		return
	}

	fmt.Println("Yes")

	for i := 1; i <= H; i++ {
		for j := 1; j <= W; j++ {
			if i%h == 0 && j%w == 0 {
				fmt.Print(-(4000*(h*w-1))-1, " ")
			} else {
				fmt.Print("4000 ")
			}
		}
		fmt.Println()
	}
}

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

// Pair is liked C++ pair
type Pair struct {
	a, b int
}

// Pairs is sorted by []Pair struct
type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a < p[j].a {
		return true
	} else if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return false
}

// -------------------------------
func in(c, a, z int) bool {
	return c >= a && c < z
}

func btoi(b bool) int {
	if b {
		return 1
	}
	return 0
}

func itob(a int) bool {
	if a == 0 {
		return false
	}
	return true
}

func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}

func sum(a ...int) int {
	r := a[0]
	if len(a) > 1 {
		for i := 1; i < len(a); i++ {
			r += a[i]
		}
	}
	return r
}

func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}

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

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

// ---------- buffered scanner -----------------------------------------
type scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func newScanner() *scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 10000)
	return &scanner{r: rdr}
}
func (s *scanner) next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *scanner) Line() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *scanner) Int() int {
	v, _ := strconv.Atoi(s.next())
	return v
}
func (s *scanner) Int64() int64 {
	v, _ := strconv.ParseInt(s.next(), 10, 64)
	return v
}
func (s *scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 6784
# -*- coding: utf-8 -*-

# Low Elements

### TESTCASE
test = ""
#test = \
"""
5
4 2 5 1 3
ans
3
"""

"""
4
4 3 2 1
ans
4
"""

"""
6
1 2 3 4 5 6
ans
1
"""

"""
8
5 7 4 2 6 8 1 3
ans
4
"""

"""
1
1
ans
1
"""
############
test = list(reversed(test.strip().splitlines()))
if test:
    def input2():
        return test.pop()
else:
    def input2():
        return input()
####### MAIN

n = int(input2())
p = tuple(map(int, input2().split()))

x = [0] * n

ans = 1
x[0] = p[0]

for i in range(1, n):
    if x[i-1] >= p[i]:
        ans += 1
        
    x[i] = min(x[i-1], p[i])
    
print(ans)








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

using namespace std;

int main()
{
    int m1, d1, m2, d2;
    scanf("%d %d %d %d", &m1, &d1, &m2, &d2);
    if(m2 == m1+1) cout << 1 << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        var abhm = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var a = abhm[0];
        var b = abhm[1];
        var h = abhm[2];
        var m = abhm[3];
        var tandeg = (PI * 2 / 12) * h + (PI * 2 / 12 / 60) * m;
        var choudeg = (PI * 2 / 60) * m;
        var deg = Abs(tandeg - choudeg);
        var cos = Cos(deg) * a;
        var sin = Sin(deg) * a;
        Console.WriteLine(Sqrt(Pow(b - cos, 2) + Pow(Abs(sin), 2)));
    }
}

Measured memory_bytes: 28696
#include <iostream>
#include <vector>

using namespace std;

const long long INF = (1LL << 60);

int main(){
	int N;
	while(cin >> N){
		vector<int> A(N), sign(N);
		cin >> A[0];
		sign[0] = 1;
		for(int i=1;i<N;i++){
			char c;
			cin >> c >> A[i];
			sign[i] = (c == '+' ? 1 : -1);
		}
		long long dp[2][3];
		for(int i=0;i<3;i++) dp[0][i] = dp[1][i] = -INF;
		dp[0][0] = 0;
		long long m[3] = {1, -1, 1};
		for(int i=0;i<N;i++){
			long long* cur = dp[i%2];
			long long* next = dp[1-i%2];
			for(int j=0;j<3;j++) next[j] = -INF;
			for(int j=0;j<3;j++){
				for(int k=0;k<=j;k++){
					next[k] = max(next[k], cur[j] + m[k] * sign[i] * A[i]);
					if(sign[i] == -1 && k+1 <= 2){
						next[k+1] = max(next[k+1], cur[j] + m[k] * sign[i] * A[i]);
					}
				}
			}
		}
		long long res = 0;
		for(int i=0;i<3;i++) res = max(res, dp[N%2][i]);
		cout << res << endl;
	}
}



Measured memory_bytes: 1024
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Util{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
        int[] ABC = ria();
        int K = ri();

        int[][] patternArrayArray = Combination.Enumerate(new int[]{0, 1, 2}, K, withRepetition: true).ToArray();

        foreach(int[] patternArray in patternArrayArray) {
            int[] ABC_copy = ABC.Clone() as int[];
            // ABC.Clone Array.CopyTo(ABC, ABC_copy, ABC.Length);

            foreach(int pattern in patternArray) {
                ABC_copy[pattern] *= 2;

                if(ABC_copy[0] < ABC_copy[1] && ABC_copy[1] < ABC_copy[2]){
                    Console.WriteLine("Yes");
		            Console.ReadLine();
                    return;
                }
            }
        }

		Console.WriteLine("No");
		Console.ReadLine();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
    static int[] generateNums(int num, int N){return Enumerable.Repeat(num, N).ToArray();}
    static int[] generateSuretsu(int N){return Enumerable.Range(0, N).ToArray();}
}

public static class Combination {
	//使い方:int[][] Is = Combination.Enumerate(nums, k, withRepetition:false).ToArray();
    public static IEnumerable<T[]> Enumerate<T>(IEnumerable<T> items, int k, bool withRepetition) {
        if (k == 1) {
            foreach (var item in items)
                yield return new T[] { item };
            yield break;
        }
        foreach (var item in items) {
            var leftside = new T[] { item };

            // item よりも前のものを除く （順列と組み合わせの違い)
            // 重複を許さないので、unusedから item そのものも取り除く
            var unused = withRepetition ? items : items.SkipWhile(e => !e.Equals(item)).Skip(1).ToList();

            foreach (var rightside in Enumerate(unused, k - 1, withRepetition)) {
                yield return leftside.Concat(rightside).ToArray();
            }
        }
    }
}


Measured memory_bytes: 30600
s=input()
f=0
for i in range(len(s)):
  if i%2==0:
    if s[i]=='R' or s[i]=='U' or s[i]=='D':
      pass
    else:
      f=1
      break
  else:
    if s[i]=='L' or s[i]=='U' or s[i]=='D':
      pass
    else:
      f=1
      break
if f==0:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include<stdio.h>

int main(void)
{
    int a,b;
    scanf("%d %d",&a,&b);
    if(a<b){
        printf("a < b\n");
    }
    if(a>b){
        printf("a > b\n");
    }
    if(a == b){
        printf("a == b\n");
    }
    return 0;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);++i)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int gcd(int a,int b) { return b ? gcd(b,a%b) : a;}
int lcm(int a,int b) { return a/gcd(a,b)*b;}
void printb(unsigned int v) {
  unsigned int mask = (int)1 << (sizeof(v) * CHAR_BIT - 1);
  do putchar(mask & v ? '1' : '0');
  while (mask >>= 1);
}
void putb(unsigned int v) {putchar('0'), putchar('b'), printb(v), putchar('\n');}
#define ALL(W) (W).begin(),(W).end()

signed main(){
  int N,K,h,ans=0;
  cin >> N >> K;
  rep(i,N){
    cin >> h;
    if(h>=K) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

ll N,M,S,T;
vector<vector<P>> X;
vector<vector<P>> Y;
ll INF = 1e18;

int main(){
    cin >> N >> M >> S >> T;
    S--, T--;
    X.resize(N);
    Y.resize(N);
    for(int i=0;i<M;i++){
        ll u,v,a,b;
        cin >> u >> v >> a >> b;
        X[u-1].push_back({v-1,a});
        X[v-1].push_back({u-1,a});
        Y[u-1].push_back({v-1,b});
        Y[v-1].push_back({u-1,b});
    }
    vector<ll> x(N,INF);
    vector<ll> y(N,INF);
    priority_queue<P,vector<P>,greater<P>> pq;
    pq.push({0,S});
    while(!pq.empty()){
        auto t = pq.top();
        ll c = t.first;
        ll n = t.second;
        pq.pop();
        if(x[n] != INF) continue;
        x[n] = c;
        for(auto &e : X[n]){
            if(x[e.first] != INF) continue;
            pq.push({e.second + c, e.first});
        }
    }
    pq.push({0,T});
    while(!pq.empty()){
        auto t = pq.top();
        ll c = t.first;
        ll n = t.second;
        pq.pop();
        if(y[n] != INF) continue;
        y[n] = c;
        for(auto &e : Y[n]){
            if(y[e.first] != INF) continue;
            pq.push({e.second + c, e.first});
        }
    }
    vector<ll> ans;
    ans.push_back(-1);
    for(int i=0;i<N;i++){
        ll tmp = 1e15 - x[N-i-1] - y[N-i-1];
        ans.push_back(max(ans.back(),tmp));
    }
    for(int i=0;i<N;i++){
        cout << ans[N-i] << endl;
    }
    return 0;
}

Measured memory_bytes: 21624
while(True):
    val = input().split(" ")
    a = int(val[0])
    op = val[1]
    b = int(val[2])

    if op=="+":
        print(a+b)
    elif op =="-":
        print(a-b)
    elif op =="*":
        print(a*b)
    elif op =="/":
        print(a//b)
    elif op =="?":
        break



Measured memory_bytes: 5596
#include<iostream>
#include<queue>

using namespace std;

int main(){
    int N;
    char tab[2][52];
    const long long mod = 1000000007;
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>tab[0][i];
    }
    for(int i=0;i<N;i++){
        cin>>tab[1][i];
    }
    queue<int> q;
    for(int i=0;i<N;i++){
        if(i<N-1 && tab[0][i]==tab[0][i+1]){
            q.push(1);
            i++;
        }else{
            q.push(0);
        }
    }
    long long ans;
    int now=q.front(); q.pop();
    if(now==0){
        ans=3;
    }else{
        ans=6;
    }
    while(!q.empty()){
        int next=q.front(); q.pop();
        if(now==next){
            if(now==0){
                ans = (ans * 2)%mod;
            }else{
                ans = (ans * 3)%mod;
            }
        }else{
            if(now==0){
                ans = (ans * 2)%mod;
            }
            now=next;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int price = 700;
        if(s.charAt(0)=='o'){
            price +=100;
        }
        if(s.charAt(1)=='o') {
            price += 100;
        }
        if(s.charAt(2)=='o'){
            price+=100;
        }
        System.out.println(price);
    }
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
int main()
{
    string s; cin >> s;
    cout << ((s == "ABC")?"ARC":"ABC") << endl;
    return 0;
}

Measured memory_bytes: 3624
from itertools import accumulate
from bisect import bisect_right

N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a = [0] + list(accumulate(A))
b = [0] + list(accumulate(B))

result = 0
for i in range(N + 1):
    if a[i] > K:
        break
    j = bisect_right(b, K - a[i])
    result = max(result, i + j - 1)
print(result)

Measured memory_bytes: 50760
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define f first
#define s second
using namespace std;
int dp[15000001];
int d, g;
int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> d >> g;
    for(int i = 0; i <= 15000000; i++)dp[i] = 1e9;
    dp[0] = 0;
    for(int i = 1; i <= d; i++){
        int p, c; cin >> p >> c; int foo = i*100;
        for(int j = 10000000; j >= 0; j--){
            if(dp[j] == 1e9)continue;
            for(int k = p; k >= 1; k--){
                if(k == p){
                    if(dp[j]+k < dp[j+foo*k+c])dp[j+foo*k+c] = dp[j]+k;
                    continue;
                }
                if(dp[j]+k < dp[j+foo*k])dp[j+foo*k] = dp[j]+k;
            }
        }
        /*
        for(int i = 0; i <= 20000000; i++){
            if(dp[i] == 1e9)continue;
            cout << i << " " << dp[i] << endl;
        }
        cout << endl;
        */
    }

    int res = 1e9;
    for(int i = g; i <= 15000000; i++)res = min(res, dp[i]);
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 62228
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
using namespace std;
#define ll long long

int main(){
    int N,M;cin>>N>>M;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    vector<pair<int,int> > card(M);
    int b,c;
    for(int i=0;i<M;i++){
        cin>>b>>c;
        card[i]=make_pair(c,b);
    }
    sort(A.begin(),A.end());
    sort(card.begin(),card.end(),greater<pair<int,int> >());
    int i=0;
    for(int j=0;j<M;){
        c=card[j].first;
        b=card[j].second;
        int cnt=0;
        bool end=false;
        while(cnt<b){
            if(c<A[i]||i>=N||j>=M){
                end=true;
                break;
            }            
            A[i]=c;
            i++;
            cnt++;
        }
        if(end) break;
        j++;
    }
    ll sum=0;
    for(int i=0;i<N;i++){
        sum+=A[i];
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

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

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 1e4 + 10;

int dp[N][2][100];

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

	string k;
	int d;
	cin >> k >> d;
	int n = k.length();
	dp[0][1][0] = 1;
	for(int i = 1; i <= n; i++) {
		int cur = k[i - 1] - '0';
		for(int j = 0; j <= 9; j++) {
			for(int rem = 0; rem < d; rem++) {
				dp[i][0][(rem + j) % d] = (dp[i][0][(rem + j) % d] + dp[i - 1][0][rem]) % mod;
				if(j < cur) {
					dp[i][0][(rem + j) % d] = (dp[i][0][(rem + j) % d] + dp[i - 1][1][rem]) % mod;
				}
				if(j == cur) {
					dp[i][1][(rem + j) % d] = (dp[i][1][(rem + j) % d] + dp[i - 1][1][rem]) % mod;
				}
			}
		}
	}
	cout << (dp[n][0][0] + dp[n][1][0] - 1 + mod) % mod;

	return 0;
}

Measured memory_bytes: 19256
n = int(input())
m_num = 0
r_num = 0
c_num = 0
a_num = 0
h_num = 0
for i in range(n):
    tmp = input()
    if tmp[0] == 'C':
        c_num += 1
        
    elif tmp[0] == 'R':
        r_num += 1
    
    elif tmp[0] == 'M':
        m_num += 1
        
    elif tmp[0] == 'A':
        a_num += 1
    
    elif tmp[0] == 'H':
        h_num += 1
        
print(m_num*c_num*r_num + a_num*c_num*r_num + h_num*c_num*r_num + m_num*r_num*a_num 
      + m_num*r_num*h_num + m_num*c_num*a_num +  m_num*c_num*h_num + a_num*h_num*m_num + a_num*h_num*r_num + a_num*h_num*c_num )

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

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

  int ans;
  for(ans=n;;ans*=2){
    if(ans % 2 == 0){
      if(ans % n == 0){
	break;
      }
    }
  }

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


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

typedef long long ll;
typedef long double ld; //
typedef double db; //
typedef string str; //
//
typedef pair<int, int> pi;
typedef pair<ll,ll> pl; //
typedef pair<ld,ld> pd; //
#define mp make_pair
#define f first
#define s second

typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<ll> vll; //
typedef vector<ld> vd; //
typedef vector<str> vs; //
typedef vector<pi> vpi; //
typedef vector<pl> vpl; //
typedef vector<pd> vpd; //
typedef vector<vi> vvi;
typedef vector<vll> vvll;

//
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend() //
#define rsz resize
#define ins insert //
#define ft front() //
#define bk back() //
#define pf push_front //
#define pb push_back
#define eb emplace_back //
#define lb lower_bound //
#define ub upper_bound //

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

const int MOD = 1e9+7; // 998244353; // = (119<<23)+1
const int MX = 2e5+5; //
const ll INF = 1e18; //
const ld PI = 4*atan((ld)1); 
const int xd[4] = {0,1,0,-1}, yd[4] = {1,0,-1,0}; //

template<class T> bool ckmin(T& a, const T& b) { 
    return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { 
    return a < b ? a = b, 1 : 0; }
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

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

    string S;
    cin >> S;

    int best = 1000;
    for (int i=0;i<26;i++) {
        char c = i + 'a';

        int maxblock = 0;
        int curblock = 0;
        for (int i=0;i<S.length();i++) {
            if (S[i] == c) {
                maxblock = max(maxblock, curblock);
                curblock = 0;
            } else {
                curblock++;
            }
        }
        maxblock = max(maxblock, curblock);
        best = min(maxblock, best);
    }
    cout << best << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, l;
    cin >> n >> l;
    int p = 0;
    for (int i = 0; i < n; ++i)
        p += l + i;
    
    int sol = 1e9, sd = -1;
    for (int i = 0; i < n; ++i)
    {
        int q = 0;
        for (int j = 0; j < n; ++j)
            if (i != j)
                q += l + j;

        if (abs(p - q) < sol)
            sol = abs(p - q), sd = q;
    }
    cout << sd;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
using namespace std;
#define INF 0x3f3f3f3f
//#define INF 1100000000000000000LL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=40050;
//int arr[SIZE]={};
//ここまでテンプレ
int main(){
	cout<<setprecision(20);
	int N;
	cin>>N;
	vint t,v;
	int time=1;
	float ans=0.;
	int maxV[SIZE]={},limitV[SIZE]={};
	maxV[0]=0;
	for(int i=0;i<N;i++){
		int a;
		scanf("%d",&a);
		t.pb(a);
	}
	for(int i=0;i<N;i++){
		int b;
		scanf("%d",&b);
		v.pb(b);
		for(int j=time;j<time+t[i]*2;j++){
			maxV[j]=b;
		}
		time+=t[i]*2;
	}
	maxV[time+1]=0;
	float now=0;
	for(int i=1;i<=time;i++){
		float prev=now;
		int limit1=INF,limit2=INF;
		for(int j=i;j<=time+1;j++){
			limit1=min(limit1,maxV[j]+(int)(j-i)/2);
			limit2=min(limit2,maxV[j]+(int)(j-i-1)/2);
		}
		if(now<limit1)
			now+=0.5;
		else if(now>limit2)
			now-=0.5;
		ans+=1.*(float)(now+prev)/4.;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[] ans = new int[3];
        ans[0] = 1;
        ans[1] = 2;
        ans[2] = 3;
        int A = sc.nextInt();
        int B = sc.nextInt();
        ans[A - 1] = 0;
        ans[B - 1] = 0;
        for(int i = 0; i < 3; i++){
            if(ans[i] != 0){
                System.out.println(ans[i]);
            }
        }
    }
}


Measured memory_bytes: 22356
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <numeric>
#include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 10007;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
#define ALL(x)   (x).begin(),(x).end()
#define mp       make_pair
#define eb       emplace_back

int dp[1010][8];

int main() {
	int n; cin >> n; n++;
	string pat = "JOI", s;
	cin >> s; 
	s = "J" + s;

	dp[0][1] = 1;
	for (int i = 1; i < n; i++) {
		int key = pat.find(s[i]);
		for (int j = 0; j < 8; j++) {
			if (!(j >> key & 1)) continue;
			for (int k = 0; k < 8; k++) {
				int prev = pat.find(s[i - 1]);
				if ((k >> prev & 1) && (j & k)) {
					(dp[i][j] += dp[i - 1][k]) %= MOD;
				}
			}
		}
	}

	int ans = 0;
	for (int i = 0; i < 8; i++) (ans += dp[n - 1][i]) %= MOD;
	cout << ans << endl;
}

Measured memory_bytes: 3224
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int a, b; cin >> a >> b;
	cout << (a + b) / 2 << endl;
	return 0;
}


Measured memory_bytes: 3200
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String kaibun = sc.next();
        int len = kaibun.length();
        String kaibun1 = kaibun.substring(0,(len - 1)/2);
        String kaibun2 = kaibun.substring((len + 3)/2 - 1,len);

        StringBuffer kaibun4 = new StringBuffer(kaibun1);
        String kaibun3 = kaibun4.reverse().toString();

        StringBuffer kaibun5 = new StringBuffer(kaibun2);
        String kaibun6 = kaibun5.reverse().toString();

        StringBuffer kaibun7 = new StringBuffer(kaibun);
        String kaibun8 = kaibun7.reverse().toString();

        if(kaibun3.equals(kaibun1) && kaibun6.equals(kaibun2) && kaibun8.equals(kaibun)){
            System.out.println("Yes");
} else{
            System.out.println("No");
}
}
}

Measured memory_bytes: 23508
#include "bits//stdc++.h"
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
typedef pair<ll, int> P;

int main() {
	int W, H;
	cin >> W >> H;
	vector<P> E;
	rep(i, W) {
		ll p;
		cin >> p;
		E.emplace_back(p, 0);
	}
	rep(i, H) {
		ll q;
		cin >> q;
		E.emplace_back(q, 1);
	}
	sort(E.begin(), E.end());
	int cntH = 0, cntW = 0;
	ll ans = 0;
	for (P &e : E) {
		if (e.second) {
			ans += e.first*(W + 1 - cntW);
			cntH++;
		}
		else {
			ans += e.first*(H + 1 - cntH);
			cntW++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 6384
n, m, x = map(int,input().split())
ca = [list(map(int,input().split())) for _ in range(n)]

costs = []
for i in range(2 ** n):
    flag = True
    cost = 0
    algos = [0] * m
    op = [False] * n
    for j in range(n):
        if ((i >> j) & 1):
            op[n - j - 1] = True
    #print(op)
    for j in range(n):
        if op[j]:
            for k, u in enumerate(ca[j][1:]):
                algos[k] += u
            cost += ca[j][0]
    for j in algos:
        if j < x:
            flag = False
    if flag:
        costs.append(cost)

if len(costs) == 0:
    print(-1)
else:
    print(min(costs))

Measured memory_bytes: 9120
N = gets.to_i
A = gets.chomp.split.map(&:to_i)

h = {}
A.each do |a|
  if h[a].nil? then
    h[a] = 1
  else
    h[a] += 1
  end
end

(1..N).each do |n|
  if h[n] then
    puts h[n]
  else
    puts 0
  end
end

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define l_l pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

ll dp[100010];

int main() {
  fill_n(dp, 100005, INF);
  dp[0] = 0;

  ll N, K;
  scanf("%lld %lld", &N, &K);

  vector<ll> list;
  for (ll i = 0; i < N; i++) {
    ll v;
    scanf("%lld", &v);
    list.emplace_back(v);
  }

  for (ll n = 0; n < N - 1; n++) {
    for (ll j = 1; j <= K; j++) {
      ll nn = n + j;
      if (nn >= N) {
        continue;
      }
      ll s = abs(list[n] - list[nn]);
      dp[nn] = min(dp[nn], dp[n] + s);
    }
  }

  cout << (dp[N - 1]) << endl;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int gcd(int a,int b){
    return b?gcd(b,a%b):a;
}

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

int N,M;
string S,T;

signed main(){
    cin>>N>>M;
    cin>>S>>T;
    bool flag=true;

    for(int i=0;i<N;i++){
        if((i*M)%N==0){
            int j=i*M/N;
            if(S[i]!=T[j])flag=false;
        }
    }

    if(!flag)cout<<-1<<endl;
    else cout<<lcm(N,M)<<endl;
    return 0;
}


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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).begin(),(x).rend()

typedef long long ll;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;

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

	pair<pair<string,int>,int> p[110];
	for (int i = 0; i < n; ++i){
		int t;
		cin>>p[i].first.first>>t;
		p[i].first.second=-t;
		p[i].second=i;
	}
	sort(p,p+n);

	for (int i = 0; i < n; ++i){
		cout<<p[i].second+1<<endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define vpll vector <pll>
#define pb push_back

int main()
{
   int n;
   string x;
   set<string> words;
   cin>>n;
   for(int i=0;i<n;i++){
        cin>>x;
    words.insert(x);
   }
   cout<<words.size();

  return 0;

}


Measured memory_bytes: 19220
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<bool> vec){
    ll n = vec.size();
    rep(i,n) cout << i << " " << vec.at(i) << "\n";
}

void pr2d(vector<vector<ll>> vvec){
    ll h = vvec.size();
    ll w = vvec.at(0).size();
    rep(i,h){
        rep(j,w){
            cout << vvec.at(i).at(j) << " ";
        }
        cout << "\n";
    }
}

int main(){
    ll d; cin >> d;
    vector<ll> c(26);
    rep(i,26) cin >> c.at(i);
    vector<vector<ll>> s(d,vector<ll>(26));
    rep(i,d) rep(j,26) cin >> s.at(i).at(j);
    vector<ll> last(26,0);

    ll sat = 0;

    ll initial_satis=0;
    rep(i,26){
        initial_satis -= c.at(i)*d*(d+1)/2;
    }
    //initial_satis =　何もコンテストを開催していない状態の満足度

    ll satis = initial_satis;

    vector<ll> cont_order(d);

    //与えられたtだけコンテストを開催することを考える
    vector<vector<ll>> contlis(26,{0,d+1});
    for(int i=1;i<=d;i++){
        ll t ; cin >> t; t--;
        cont_order.at(i-1) = t;
        auto it = lower_bound(contlis.at(t).begin(),contlis.at(t).end(),i);
        ll x = it - contlis.at(t).begin();
        ll a = i - contlis.at(t).at(x-1) - 1;
        ll b = contlis.at(t).at(x) - i - 1;
        ll z = contlis.at(t).at(x) - contlis.at(t).at(x-1) - 1;
        satis += c.at(t)*z*(z+1)/2 - c.at(t)*a*(a+1)/2 - c.at(t)*b*(b+1)/2;
        satis += s.at(i-1).at(t);
        contlis.at(t).insert(it,i);
    }

    //satis = 与えられたtに対する満足度

    ll m ; cin >> m;
    rep(i,m){
        ll d,q; cin >> d >> q; //d日目の開催コンテストをq番目のものにする
        d--; q--;
        //現状d日目に開催されているコンテストは？
        ll cur_cont_d = cont_order.at(d);
        //cur_cont_dの開催をやめる
        satis -= s.at(d).at(cur_cont_d);
        //d日目の開催コンテストをqに変更する
        cont_order.at(d) = q;

        //q番目コンテストの分のsatisを増やす
        satis += s.at(d).at(q);

        //cur_cont_d開催中止による飽きの影響
        auto it = lower_bound(contlis.at(cur_cont_d).begin(),contlis.at(cur_cont_d).end(),d+1);
        ll x = it - contlis.at(cur_cont_d).begin();
        ll a = d+1 - contlis.at(cur_cont_d).at(x-1) - 1;
        ll b = contlis.at(cur_cont_d).at(x+1) - (d+1) - 1;
        ll z = contlis.at(cur_cont_d).at(x+1) - contlis.at(cur_cont_d).at(x-1) - 1;

        satis = satis - c.at(cur_cont_d)*z*(z+1)/2 + c.at(cur_cont_d)*a*(a+1)/2 + c.at(cur_cont_d)*b*(b+1)/2;
        contlis.at(cur_cont_d).erase(it);

        //q追加による飽きへの影響
        it = lower_bound(contlis.at(q).begin(),contlis.at(q).end(),d+1);
        x = it - contlis.at(q).begin();
        a = (d+1) - contlis.at(q).at(x-1) - 1;
        b = contlis.at(q).at(x) - (d+1) - 1;
        z = contlis.at(q).at(x) - contlis.at(q).at(x-1) - 1;
        satis += c.at(q)*z*(z+1)/2 - c.at(q)*a*(a+1)/2 - c.at(q)*b*(b+1)/2;
        contlis.at(q).insert(it,d+1);
        
        cout << satis << endl;
    }

    return 0;
}


Measured memory_bytes: 3716
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define mod 1000000007LL
#define eps 0.0001

#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    // ---------------------
    // コーディング開始
    // ---------------------
    
    int a,b;
    cin >> a >> b;

    int i,j; 

    string c="";
    string h ="";

    rep(i,a){
        c="";
        cin >> c;
        h+=(c);
        h+="\n";
        h+=(c);
        h+="\n";
    }

    pri(h);

    return 0;
}



Measured memory_bytes: 384
import collections
from functools import lru_cache
from math import floor, ceil


def read():
    return input().strip()


def readInt():
    return int(input().strip())


def readList():
    return list(map(int, input().strip().split()))


def solve(l, r, d):
    return floor(r/d) - ceil(l/d) + 1


[L, R, d] = readList()
print(solve(L, R, d))


Measured memory_bytes: 67480