akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> p;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, n) for(int i = 1; i <= (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define srep(i, from, to) for(int i = from; i < (int)(to); i++)
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
template <class T> bool chmax(T &a, const T &b) {
  if(a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if(b < a) {
    a = b;
    return 1;
  }
  return 0;
}

int main() {
  string s;
  cin >> s;
  vector<int> count(s.size());
  vector<int> c(2, 0);

  rep(i, s.size()) {
    if(s[i] == 'R')
      c[i % 2]++;
    else {
      count[i] += c[i % 2];
      count[i - 1] += c[(i - 1) % 2];
      c[0] = 0;
      c[1] = 0;
    }
  }

  rrep(i, s.size()) {
    if(s[i] == 'L')
      c[i % 2]++;
    else {
      count[i] += c[i % 2];
      count[i + 1] += c[(i + 1) % 2];
      c[0] = 0;
      c[1] = 0;
    }
  }

  rep(i, count.size()) cout << count[i] << endl;

  return 0;
}


Measured memory_bytes: 1024
s=list(input())
t=list(input())

s.sort()
t.sort(reverse=True)

for i in range(min(len(s),len(t))):
    if(s[i]<t[i]):
        print("Yes")
        exit()
    if(s[i]>t[i]):
        print("No")
        exit()

if(len(s)<len(t)):
    print("Yes")
else:
    print("No")


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

using namespace std;

int main(){

  long long int x, k, d;
  cin>>x>>k>>d;

  long long int aboutK=abs(x)/abs(d);

  if(aboutK>k){
    cout<<abs(abs(x)-abs(k*d))<<endl;
  }else if(aboutK<=k){
    long long int ans=abs(abs(x)-abs(k*d));
    for(int i=-2; i<3; i++){
      if(i+aboutK<=k and i+aboutK>=0){
        if((k-i-aboutK)%2==0){
          long long int value = abs(x)-abs((i+aboutK)*d);
          ans=min(ans, abs(value));
        }
      }
    }
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int f[4][4];
int main()
{
    int a;
    scanf("%d%d%d",&f[1][1],&f[1][2],&f[2][2]);
    a=f[2][2]*3;
    f[1][3]=a-f[1][1]-f[1][2];
    f[3][1]=a-f[1][3]-f[2][2];
    f[3][3]=a-f[1][1]-f[2][2];
    f[2][1]=a-f[1][1]-f[3][1];
    f[2][3]=a-f[2][1]-f[2][2];
    f[3][2]=a-f[1][2]-f[2][2];
    for(int i=1;i<=3;i++)
    {
        for(int j=1;j<=3;j++)
        {
            printf("%d ",f[i][j]);
        }
        printf("\n");
    }
    return 0;
}

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

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

using namespace std;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
const int INF = 1 << 29;

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    int sy, sx, gy, gx;
    cin >> sy >> sx >> gy >> gx;
    sy--;
    sx--;
    gy--;
    gx--;
    vector<string> B(h);
    rep(i, h) cin >> B[i];

    vector d(h, vector(w, INF));
    d[sy][sx] = 0;
    queue<pair<int, int>> Q;
    Q.emplace(sy, sx);
    while (!Q.empty()) {
        int y, x;
        tie(y, x) = Q.front();
        Q.pop();
        rep(dir, 4) {
            int y2 = y, x2 = x;
            rep(_, k) {
                y2 += dy[dir];
                x2 += dx[dir];
                if (y2 < 0 || h <= y2 || x2 < 0 || w <= x2 || B[y2][x2] == '@' || d[y2][x2] <= d[y][x]) break;
                if (d[y2][x2] == INF) {
                    assert(d[y2][x2] == INF);
                    d[y2][x2] = d[y][x] + 1;
                    Q.emplace(y2, x2);
                }
            }
        }
    }

    printf("%d\n", d[gy][gx] < INF ? d[gy][gx] : -1);

    return 0;
} // test


Measured memory_bytes: 12080
from itertools import permutations
N = int(input())
P = tuple(map(int,input().split()))
Q = tuple(map(int,input().split()))
for i,p in enumerate(permutations(range(1,N+1))):
    if p == P:
        pi = i
    if p == Q:
        qi = i

print(abs(pi-qi))

Measured memory_bytes: 73240
#include<bits/stdc++.h>
#define MAX 100000
using namespace std;
int n,q;
int data[MAX+1];
void add(int i,int v){
  while(i<=n){
    data[i]+=v;
    i+=i&-i;
  }
}
int sum(int i){
  int res=0;
  while(i>0){
    res+=data[i];
    i-=i&-i;
  }
  return res;
}
int main(){
  int c,x,y;
  cin>>n>>q;
  for(int i=0;i<q;i++){
    scanf("%d%d%d",&c,&x,&y);
    if(c)printf("%d\n",sum(y)-sum(x-1));
    else add(x,y);
  }
}

Measured memory_bytes: 3588
s = input()
l = len(s)
dp = [[0, 0] for _ in range(l + 1)]
dp[1][0] = 1
for i in range(2, l + 1):
    if s[i - 1] != s[i - 2]:
        dp[i][0] = dp[i - 1][0] + 1
    dp[i][0] = max(dp[i][0], dp[i - 1][1] + 1)
    dp[i][1] = dp[i - 2][0] + 1
print(max(dp[-1]))


Measured memory_bytes: 36384
// https://atcoder.jp/contests/abc151/tasks/abc151_a

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  string C;
  cin >> C;

  char res = C[0] + 1;
  cout << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

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

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

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

static class P
{
    static void Main()
    {
        var nq = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var stxs = Enumerable.Repeat(0, nq[0]).Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();
        var queries = Enumerable.Repeat(0, nq[1]).Select(_ => int.Parse(Console.ReadLine())).ToList();

        var dict = new Dictionary<int, int>();
        for (int i = 0; i < queries.Count; i++) dict.Add(queries[i], i);
        

        SegmentTree<int> segTree = new SegmentTree<int>(queries.Count, int.MaxValue, Min);
        foreach (var stx in stxs.OrderByDescending(x => x[2]))
        {
            var start = queries.BinarySearch(stx[0] - stx[2]);
            var end = queries.BinarySearch(stx[1] - stx[2]);
            if (start < 0) start = ~start;
            if (end < 0) end = ~end;
            segTree.Operate(start, end, stx[2]);
        }

        StringBuilder builder = new StringBuilder();
        foreach (var q in queries)
        {
            var query = segTree.Query(dict[q]);
            builder.AppendLine((query == int.MaxValue ? -1 : query).ToString());
        }
        Console.WriteLine(builder.ToString());
    }
}


class SegmentTree<T>
{
    public int Size { get; private set; }
    T IdentityElement;
    T[] Operators;
    Func<T, T, T> Merge;
    int LeafCount;

    public SegmentTree(int size, T identityElement, Func<T, T, T> merge)
    {
        Size = size;
        Merge = merge;
        IdentityElement = identityElement;
        LeafCount = 1;
        while (LeafCount < size) LeafCount <<= 1;

        Operators = Enumerable.Repeat(identityElement, LeafCount * 2).ToArray();
    }

    public T this[int index]
    {
        get { return Query(index); }
        set { Operate(index, index + 1, value); }
    }

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public void Operate(int l, int r, T x)
    {
        l += LeafCount;
        r += LeafCount - 1;
        while (l <= r)
        {
            if (l % 2 == 1) Operators[l] = Merge(x, Operators[l]);
            if (r % 2 == 0) Operators[r] = Merge(x, Operators[r]);
            l = (l + 1) / 2;
            r = (r - 1) / 2;
        }
    }

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public T Query(int i)
    {
        i += LeafCount;
        T res = Operators[i];
        while (0 < (i >>= 1)) res = Merge(res, Operators[i]);
        return res;
    }
}

Measured memory_bytes: 50240
#include <limits.h>
#include <string>
#include <iostream>

using namespace std;
#define pi 3.14159265

int main()
{
	long long ans = LLONG_MAX, i = 0, j = 0, N, T, c[100], t[100];
	cin >> N >> T;
	for (i; i < N; i++) {
		cin >> c[i] >> t[i];
	}

	for (i = 0; i < N; i++) {
		if (t[i] <= T) {
			if (ans > c[i])
				ans = c[i];
			j++;
		}
	}

	if (j)
		cout << ans << endl;
	else
		cout << "TLE" << endl;
	return 0;
}

Measured memory_bytes: 256
import itertools
n = int(input())
p = input().replace(' ', '')
q = input().replace(' ', '')
s = itertools.permutations(list(range(1, n+1)), n)
pi = 0
qi = 0
for i, sb in enumerate(s):
    sb = ''.join(map(str, sb))
    if sb == p:
        pi = i
    if sb == q:
        qi = i

print(abs(pi-qi))


Measured memory_bytes: 9052
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;


int main(){
  int x,y;
  cin >> x >> y;
  
  int ans=0;
  for(int i=x; i<=y; i++){
    if((i%10 == i/10000) && (i%100/10 == i%10000/1000)){ans++;}
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/abc135/tasks/abc135_c
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ans = 0
tmp = 0
for i in range(n):
    #print(i,tmp)
    #print(a)
    #print(b)
    if tmp > 0:
        if a[i] <= tmp:
            ans += a[i]
            a[i] = 0
            tmp = b[i]
        else:
            ans += tmp
            a[i] -= tmp
            tmp = 0
    if a[i] > 0:
        if a[i] <= b[i]:
            ans += a[i]
            tmp = b[i] - a[i]
            a[i] = 0
            b[i] = tmp
        else:
            ans += b[i]
            a[i] -= b[i]
            b[i] = 0
            tmp = 0
tmp = min(tmp,a[-1])
#print(a)
#print(b)
#print(tmp)
print(ans+tmp)

Measured memory_bytes: 24188
#include<bits/stdc++.h>
using namespace std;
const int MAXN=2e5+5;
long long a[MAXN];//这两个数组都是要用longlong的
long long b[MAXN];//同上
long long ans=0;//答案也是long long类型的
int main()
{
    int n;
    cin >>n;    
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];//读入a数组
        b[i]=b[i-1]+a[i];//b数组用来存上一个数加上当前a数组的数
        ans+=a[i];//再把读入的a数组累加起来
    }
    long long cmin=INT_MAX;//存最小的数就要先赋值最大进去
    for(int i=1;i<n;i++)
    {
        if(cmin>abs(2*b[i]-ans))//如果新得到的数的两倍和总数的差比cmin来的小的话，那么久更新cmin的值
            cmin=abs(2*b[i]-ans);//赋值进去
    }
    cout<<cmin<<endl;//最后输出就完事了
    return 0;//结束程序
}

Measured memory_bytes: 3328
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
#include<functional>
#include<deque>
#include<list>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int n,a[200010],i,b[200010];
  cin >> n;
  for(i=0;i<n;i++){
    cin >> a[i];
    b[i]=a[i];
  }
  sort(b,b+n,greater<int>() );
  for(i=0;i<n;i++){
    if(a[i]!=b[0]){
      cout << b[0] << endl;
    }
    else{
      cout << b[1] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 5112
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] cost = new int[m];
        int sum = 0;
        for(int i = 0;i < m;i++){
            sum += sc.nextInt();
        }

        System.out.println(sum <= n?n-sum:-1);
    }
}

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

int main() {
  int N;
  string color;
  string Out;
  Out = "Three";
  
  cin >> N;
  int i = 0;
  
  while (i < N) {
    cin >> color;
    if (color == "Y"){
      Out = "Four";
      break;
         }
    i++;
  }
  cout << Out << endl;
  
 
}


Measured memory_bytes: 256
#include <cstdio>
int n;
int main(){
    scanf("%d", &n);
    int a, b, ans = 0;
    for(int i = 0; i < n; i++){
        scanf("%d %d", &a, &b);
        ans += b - a + 1;
    }
    printf("%d\n", ans);
    return 0;
}

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

#define mp make_pair
#define pb push_back

#define ll long long

const int MOD = 1e9+7;

int n,m;
const int N=1e5+5;
vector<int> adj[N];
int dp[N];
int maxans=0;
vector<int> vis(N,0);

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

    int n;
    cin>>n;
    double arr[n+1];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i+1];
    }

    double dp[n+1][n+1];
    dp[0][0]=1;
    dp[1][1]=arr[1];
    dp[1][0]=1-arr[1];

    for(int i=2;i<=n;i++)
    {
        for(int j=0;j<=i;j++)
        {
            if(j==0)
                dp[i][j]=dp[i-1][0]*(1-arr[i]);
            else if(i==j)
                dp[i][j]=dp[i-1][j-1]*arr[i];
            else
            {
                dp[i][j]=dp[i-1][j]*(1-arr[i])+dp[i-1][j-1]*arr[i];
            }
        }
    }

    double ans=0;
    for(int i=n/2+1;i<=n;i++)
        ans+=dp[n][i];

    cout<<setprecision(10)<<ans;

    return 0;
}

Measured memory_bytes: 73088
import numpy as np

def main():
    N = int(input())
    dp = [[[[0 for _ in range(4)]for _ in range(4)]for _ in range(4)]for _ in range(N+1)]
    #ndp = np.array(dp)
    #print(ndp.shape)
    dp[0][3][3][3] = 1

    for len in range(N):
        for c1 in range(4):
            for c2 in range(4):
                for c3 in range(4):
                    if dp[len][c1][c2][c3] == 0:
                        continue
                    for a in range(4):#次に最後尾につく数
                        if a == 2 and c1 == 1 and c2 == 0:
                            continue
                        if a == 2 and c1 == 0 and c2 == 1:
                            continue
                        if a == 1 and c1 == 2 and c2 == 0:
                            continue
                        if a == 2 and c1 == 1 and c3 == 0:
                            continue
                        if a == 2 and c2 == 1 and c3 == 0:
                            continue

                        #ダメな条件を超えたので足してよい
                        dp[len+1][a][c1][c2] += dp[len][c1][c2][c3]
                        dp[len+1][a][c1][c2] %= 1000000007
    ans = 0
    for c1 in range(4):
        for c2 in range(4):
            for c3 in range(4):
                ans += dp[N][c1][c2][c3]
                ans %= 1000000007

    print(ans)



if __name__ == '__main__':
    main()


Measured memory_bytes: 12516
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, S, E) for (int(X) = (S); (X) < (E); ++(X))
#define rrep(X, S, E) for (int(X) = (E)-1; (X) >= (S); --(X))
#define itrep(X, Y) for (auto(X) = (Y).begin(); (X) != (Y).end(); (X)++)
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

const string YES = "YES";
const string NO = "NO";

void solve(long long N, std::vector<long long> A) {
  if (N == 1) {
    print(YES);
    return;
  }

  ll sum = 0;
  rep(i, 0, N) { sum += A[i]; }

  vl diff(N);
  rep(i, 0, N - 1) { diff[i] = A[i + 1] - A[i]; }
  diff[N - 1] = A[0] - A[N - 1];

  ll maxN = 0;
  rep(i, 0, N) { maxN = max(maxN, diff[i]); }
  rep(i, 0, N) { diff[i] -= maxN; }

  ll cnt = 0;
  rep(i, 0, N) {
    if (abs(diff[i]) % N != 0) {
      print(NO);
      return;
    } else {
      cnt += abs(diff[i]) / N;
    }
  }

  if (maxN == cnt && sum - cnt * (N + 1) * N / 2 == 0) {
    print(YES);
  } else {
    print(NO);
  }
}

int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
  solve(N, std::move(A));
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <map>
#include <numeric>
using namespace std;

#define FOR(i,a,b) for(long long int i=(a);i<(b);i++)
#define REP(i,n) for(long long int i=0;i<(n);i++)
#define ALL(s) (s).begin(),(s).end()

#define PI 3.14159265358479

typedef long long ll;
typedef vector<long long int> vi;
typedef vector<long long int>::iterator vit;

int main(){
	int n, c = 0;
	double l, m;
	vector<ll> vi;
	while (scanf("%d,%lf,%lf", &n, &l, &m) != EOF){
		if (l / powl(m, 2) >= 25){
			vi.push_back(n);
			c++;
		}
	}
	if (c == 0){
		cout << "????????????\n";
	}
	else{
		REP(i, c){
			cout << vi[i] << "\n";
		}
	}
	return 0;
}

Measured memory_bytes: 1244
N, K, C = gets.split.map(&:to_i)
S = gets.strip

s = S.chars.each.with_index(1).map{|c, i| i if c == 'o'}.compact
ls = s.drop(1).each_with_object([s.first]){|i, o| o << i if i > o.last + C}.take(K)
rs = s.reverse.drop(1).each_with_object([s.last]){|i, o| o << i if i < o.last - C}.take(K).reverse
puts ls.zip(rs).map{|l, r| l if l == r}.compact

Measured memory_bytes: 41056
#include <iostream>

using namespace std;

int main()
{
    int m, n_min, n_max;
    while (cin >> m >> n_min >> n_max, m)
    {
        int a[m] = {0};
        int gap[m] = {0};
        int MAX = 0;
        int MAX_n = 0;
        for (int i = 0; i < m; i++)
        {
            cin >> a[i];
            if (i > 0)
            {
                gap[i] = a[i - 1] - a[i];
            }
        }
        for (int i = n_min; i < n_max + 1; i++)
        {
            if (gap[i] >= MAX)
            {
                MAX = gap[i];
                MAX_n = i;
            }
        }
        cout << MAX_n << endl;
    }
}


Measured memory_bytes: 3080
# AOJ 0008 Sum of 4 Integers
# Python3 2018.6.9 bal4u

ans = [0 for i in range(51)]
for i in range(10):
	for j in range(10):
		for k in range(10):
			for l in range(10):
				ans[i+j+k+l] += 1
#for i in range(50+1):
#	print(i, ans[i])
	
while True:
    try:
        print(ans[int(input())])
    except EOFError:
        break


Measured memory_bytes: 5604
#include<stdio.h>

int main()
{
    int a,b,c,d;

    scanf("%d %d %d",&a,&b,&c);

    if (a>b){
        d=a;
        a=b;
        b=d;
    }
    if (b>c){
        d=b;
        b=c;
        c=d;
    }
    if (a>b){
        d=a;
        a=b;
        b=d;
    }
    printf("%d %d %d\n",a,b,c);
    return 0;
}

Measured memory_bytes: 596
import sys
import itertools
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, M, X = map(int, input().split(' '))
C = []
A = []
for i in range(N):
    c, *a = map(int, input().split(' '))
    C.append(c)
    A.append(np.array(a))

ans = np.inf

for i in range(2**N):
    point = np.zeros(M)
    cost = 0

    for j in range(N):
        if ((i >> j) & 1):
            point += A[j]
            cost += C[j]

    if np.all(point >= X):
        ans = min(ans, cost)

if ans != np.inf:
    print(ans)
else:
    print('-1')


Measured memory_bytes: 27236
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int gcd(int x, int y) {
    if (x < y) swap(x, y);
    int r = x%y;
    if (r == 0) {
        return y;
    }
    return gcd(y, r);
}

int main(){
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> C(N);
    vector<vector<int>> A(N, vector<int>(M));
    for (int i=0; i<N; i++) {
        cin >> C[i];
        for (int j=0; j<M; j++) {
            cin >> A[i][j];
        }
    }
    ll minSumC = 1e9;
    bool bigFlag = false;
    for (int tmp=0; tmp<(1<<N); tmp++) {
        bitset<12> book(tmp);
        vector<ll> know(M);
        ll sumC = 0;
        bool flag = true;
        for (int i=0; i<N; i++) {
            if (book.test(i)) {
                sumC += C[i];
                for (int j=0; j<M; j++) {
                    know[j] += A[i][j];
                }
            }
        }
        for (int j=0; j<M; j++) {
            if (know[j] < X) {
                flag = false;
                break;
            }
        }
        if (flag) {
            minSumC = min(minSumC, sumC);
            bigFlag = true;
        }
    }
    if (bigFlag) {
        cout << minSumC << endl;
    }
    else {
        cout << -1 << endl;
    }
}

Measured memory_bytes: 3644
N = int(input())
abc = [list(map(int, input().split())) for _ in range(N - 1)]
Q, K = list(map(int, input().split()))
xy = [list(map(int, input().split())) for _ in range(Q)]

class Tree:
  def __init__(s, N):
    s.D = [-1] * (N + 1)
    s.R = {}
  def setR(s, a, b, c):
    if a in s.R:
      s.R[a].append([b, c])
    else:
      s.R[a] = [[b, c]]
    if b in s.R:
      s.R[b].append([a, c])
    else:
      s.R[b] = [[a, c]]
  def setD(s, x):
    S = [[x, s.R[x]]]
    s.D[x] = 0
    while S:
      y, t = S.pop()
      k = s.D[y]
      for a, d in t:
        if s.D[a] == -1:
          s.D[a] = k + d
          S.append([a, s.R[a]])
  def getD(s, x):
    return s.D[x]

T = Tree(N)
for a, b, c in abc:
  T.setR(a, b, c)
T.setD(K)

for x, y in xy:
  print(T.getD(x) + T.getD(y))

Measured memory_bytes: 93232
#include <bits/stdc++.h>
using namespace std;
#define int long long int
mt19937 rng(std::chrono::duration_cast<std::chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int N=100005;
#define M 1000000007
#define double long double
#define BINF 10000000000000000
#define init(arr,val) memset(arr,val,sizeof(arr))
#define MAXN 15000001
#define deb(x) cout << #x << " " << x << "\n";
const int LG = 22;


#undef int 
int main() {
#define int long long int
ios_base::sync_with_stdio(false); 
cin.tie(0); 
cout.tie(0);


    int a, b;
    cin >> a >> b;
    cout << (a * b) / __gcd(a, b);




return 0;
}




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

using namespace std;

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

class Cube {
public:
    int f[6];

    Cube() {}

    void roll_z() { roll(1, 2, 4, 3); }//
    void roll_y() { roll(0, 2, 5, 3); }//
    void roll_x() { roll(0, 1, 5, 4); }//
    void roll(int i, int j, int k, int l) {
        int t = f[i];
        f[i] = f[j];
        f[j] = f[k];
        f[k] = f[l];
        f[l] = t;
    };

    void move(char ch) {
        if (ch == 'E') REP(i, 3) roll_y();
        if (ch == 'W') roll_y();
        if (ch == 'N') roll_x();
        if (ch == 'S') REP(i, 3) roll_x();
    }
};

bool eq(Cube c1, Cube c2) {
    REP(i, 6) {
        if (c1.f[i] != c2.f[i]) return false;
    }
    return true;
}

bool equal(Cube c1, Cube c2) {
    REP(i, 6) {
        REP(j, 4) {
            if (eq(c1, c2)) return true;
            c1.roll_z();
        }
        if (i % 2 == 0) c1.roll_y();
        else c1.roll_x();
    }
    return false;
}

int main() {
    Cube c1, c2;

    REP(i, 6) cin >> c1.f[i];
    REP(i, 6) cin >> c2.f[i];

    if (equal(c1, c2)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3100
x = int(input())
ans = 0
while ans == 0:
    count = 2
    flg = 0
    while x >= count and flg == 0:
        if x % count == 0:
            flg = 1
            if x == count:
                ans = x
        else:
            count += 1
    x += 1
print(ans)

Measured memory_bytes: 38512
import collections
s = int(input())
a = list(map(str, input().split()))
n = {}
for i in a:
  n.setdefault(i, 0)
for i in a:
  n[i] += 1
x = 0
for i in n.values():
  if x <= i:
    x = i
if x == 1:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 39884
package main

import (
	"fmt"
)

func main() {
	routes := map[int]bool{}
	obs := map[int]int{}
	var n, m int
	fmt.Scan(&n, &m)
	for i := 1; i <= n; i++ {
		var h int
		fmt.Scan(&h)
		obs[i] = h
	}
	for i := 0; i < m; i++ {
		var a, b int
		fmt.Scan(&a, &b)
		if obs[a] > obs[b] {
			routes[b] = false
		} else if obs[a] == obs[b] {
			routes[a] = false
			routes[b] = false
		} else {
			routes[a] = false
		}
	}
	fmt.Println(n - len(routes))
}


Measured memory_bytes: 11300
import sys
from collections import defaultdict, deque, Counter
import math

# import copy
from bisect import bisect_left, bisect_right
import heapq

# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)


def nck(n, k, kaijyo):
    return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD


def npk(n, k, kaijyo):
    if k == 0 or k == n:
        return n % MOD
    return (kaijyo[n] * divide(kaijyo[n-k])) % MOD


def kaijyo(n):
    ret = [1]
    for i in range(1, n + 1):
        ret.append((ret[-1] * i)% MOD)
    return ret


def cut(pt, grid, k, h, w):
    pat = []
    for i in range(h-1):
        if pt % 2 == 1:
            pat.append("1")
        else:
            pat.append("0")
        pt //= 2

    # print("pat", pat)
    slice = Counter(pat)["1"]
    pat = pat + ["0"]
    white = [0] * (slice + 1)
    ret = 0
    for i in range(w):
        tw = [0] * (slice + 1)
        dan = 0
        for j in range(h):
            if grid[j][i] == "1":
                tw[dan] += 1
            if pat[j] == "1":
                dan += 1

        if max(tw) > k:
            return INF
        reset = False
        for w1, w2 in zip(white, tw):
            if w1 + w2 > k:
                ret += 1
                reset = True
                break
        if reset:
            white = tw
        else:
            for up in range(slice + 1):
                white[up] += tw[up]

    return ret + slice

def solve():
    h, w, k = getList()
    grid = []
    for i in range(h):
        grid.append(getS())

    ans = INF
    for i in range(2 ** (h-1)):
        tmp = cut(i, grid, k, h, w)
        # print(tmp)
        ans = min(ans, tmp)
    print(ans)


def main():
    n = getN()
    for _ in range(n):
        solve()


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

Measured memory_bytes: 76164
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

constexpr int dx[] = {-1, 0, 1, 0};
constexpr int dy[] = {0, -1, 0, 1};

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

int main() {
	int a, b;
	cin >> a >>b;
	cout << a * b << endl;
	return 0;
}


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

using namespace std;

int main() {
  int n;
  cin >> n;
  
  vector<int> h(n);
  
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  int ans = 0;
  for (int i = 0; i < 100; i++) {
    bool hh = false;
    for (int j = 0; j < n; j++) {
      if (h[j] > 0) {
        h[j]--;
        hh = true;
      } else {
        if (hh) {
          ans++;
        }
        hh = false;
      }
    }
    if (hh) {
      ans++;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define p pair<int, int>
using namespace std;

int fl[105], h[105];

int main(){
    int n;
    cin >> n;
    int sum = 0;
    for(int i = 0; i < n; i++) cin >> h[i];
    while(1){
        int l, f = 0, c = 1;
        vector<p> v;
        for(int i = 0; i < n; i++){
            if(h[i] != fl[i]) c = 0;
        }
        if(c) break;
        for(int i = 0; i < n; i++){
            if(h[i] != fl[i] && !f){
                l = i;
                f = 1;
            }else if(h[i] == fl[i] && f){
                v.push_back(p(l, i));
                f = 0;
            }
        }
        v.push_back(p(l, n));
        for(int i = 0; i < v.size(); i++){
            int mi = 101;
            for(int k = v[i].first; k < v[i].second; k++){
                mi = min(mi, h[k] - fl[k]);
            }
            for(int k = v[i].first; k < v[i].second; k++){
                fl[k] += mi;
            }
            sum += mi;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
use std::io::stdin;
fn main() {
    let mut st = String::new();
    stdin().read_line(&mut st).unwrap();
    let n:String = st.trim().parse().unwrap();
    let x:Vec<char> = n.chars().collect();
    let y = x.len();
    if x[1..].iter().all(|&x| x as i32 -48 == 9) {
        let r:i32 = x[1..].iter().map(|&x| x as i32 -48).sum();
        println!("{:?}",r+(x[0] as i32 - 48));
    } else {
        println!("{:?}", 9*(y-1)+(x[0] as usize - 48)-1)
    }
}

Measured memory_bytes: 2132
K,A,B = map(int, input().split())
if B - A < 3:
    print(1+K)
else:
    if K - (A-1) < 2:
        print(1+K)
    else:
        K -= A-1
        if K%2 == 0:
            print((B-A)*K//2 + A)
        else:
            print((B-A)*(K-1)//2 + A + 1)

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

int main(){
	int h, m, s;
	cin >> s;
	h = s / 3600;
	m = (s - h * 3600) / 60;
	s = (s - h * 3600 - m * 60);
	cout << h << ":" << m << ":" << s << "\n";
	cin >> s;
	return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cassert>
#include<map>
#include<set>
#include<climits>
#include<cstring>

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

using namespace std;

#define FIR 1
#define SEC 0

short h,w,memo[22][22][22][22];
string s[21];

short dfs(int xL,int yL,int xR,int yR,int phase) {
  if( !( xL < xR && yL < yR ) ) {
    return 0;
  }
  short &grundy = memo[xL][yL][xR][yR];
  if( grundy != -1 ) return grundy;
  set<int> S;
  REP(y,yL,yR) {
    REP(x,xL,xR) {
      if( s[y][x] == 'X') continue;
      int v = 0;
      v ^= dfs(xL,yL,x,y,(phase+1)&1);
      v ^= dfs(x+1,yL,xR,y,(phase+1)&1);
      v ^= dfs(xL,y+1,x,yR,(phase+1)&1);
      v ^= dfs(x+1,y+1,xR,yR,(phase+1)&1);
      S.insert(v);
    }
  }
  rep(i,1000) if( !S.count(i) ) {
    grundy = i;
    break;
  }
  return grundy;
}

void compute() {
  memset(memo,-1,sizeof memo);
  puts(dfs(0,0,w,h,FIR)?"First":"Second");
}

int main() {
  if( 0 ) {
    srand((unsigned int)time(NULL));
    h = 4, w = 4;
    cout << h << " " << w << endl;
    rep(i,h) {
      rep(j,w) {
	cout << ((rand()%2)?'X':'.');
      }puts("");
    }
    return 0;
  }
  cin >> h >> w;
  rep(i,h) cin >> s[i];
  compute();
  return 0;
}

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

int main(){
  long int A,B,K; cin >> A>>B>>K;
  long int r_A = A;
  long int r_B = B;
  if(A>=K){
    r_A -= K;
  }else{
    r_A = 0;
    long int L = K-A;
    r_B = max(B-L,(long int)0 );
  }
  cout << r_A << " " << r_B << "\n";
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> i_i;

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int A[4];
int main() {
    int N;
    cin >> N;
    rep(i, N){
        string S;
        cin >> S;
        if (S == "AC")A[0]++;
        if (S == "WA")A[1]++;
        if (S == "TLE")A[2]++;
        if (S == "RE")A[3]++;
    }
    cout << "AC x " << A[0] << endl;
    cout << "WA x " << A[1] << endl;
    cout << "TLE x " << A[2] << endl;
    cout << "RE x " << A[3] << endl;
    return 0;
}



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

struct Node{
  struct Node* left;
  struct Node* right;
  int key, pri;
};

Node* create(int key, int pri){
  Node* t = new Node;
  t->key = key;
  t->pri = pri;
  t->left = t->right = NULL;
  return t;
}

Node* rightRotate(Node* t){
  Node* s = t->left;
  t->left = s->right;
  s->right = t;
  return s;
}

Node* leftRotate(Node* t){
  Node* s = t->right;
  t->right = s->left;
  s->left = t;
  return s;
}

Node* insert(Node* t, int key, int pri){
  if(t == NULL) return create(key, pri);
  if(key == t->key) return t;

  if(key < t->key){
    t->left = insert(t->left,key,pri);
    if(t->pri < t->left->pri) t = rightRotate(t);
  }
  else{
    t->right = insert(t->right,key,pri);
    if(t->pri < t->right->pri) t = leftRotate(t);
  }
  return t;
}

Node* erase(Node* t, int key){
  if(t == NULL) return NULL;

  if(key == t->key){
    if(t->left == NULL && t->right == NULL) return NULL;
    else if(t->left == NULL) t = leftRotate(t);
    else if(t->right == NULL) t = rightRotate(t);
    else{
      if(t->left->pri > t->right->pri) t = rightRotate(t);
      else t = leftRotate(t);
    }
    return erase(t,key);
  }
  if(key < t->key) t->left = erase(t->left,key);
  else t->right = erase(t->right,key);

  return t;
}

void inorder(Node* t){
  if(t == NULL) return;
  inorder(t->left);
  cout << " " << t->key;
  inorder(t->right);
}

void preorder(Node* t){
  if(t == NULL) return;
  cout << " " << t->key;
  preorder(t->left);
  preorder(t->right);
}

void print(Node* t){
  inorder(t);
  cout << endl;
  preorder(t);
  cout << endl;
}

void find(Node* t, int key){
  if(t == NULL){
    cout << "no" << endl;
    return;
  }
  if(t->key == key){
    cout << "yes" << endl;
    return;
  }
  if(t->key > key) find(t->left,key);
  else find(t->right,key);
}

int main(){
  Node* t = NULL;
  int m, key, pri;
  string str;
  cin >> m;
  for(int i = 0; i < m; i++){
    cin >> str;
    if(str == "insert"){
      cin >> key >> pri;
      t = insert(t,key,pri);
    }
    else if(str == "find"){
      cin >> key;
      find(t,key);
    }
    else if(str == "delete"){
      cin >> key;
      t = erase(t,key);
    }
    else print(t);
  }
  return 0;
}


Measured memory_bytes: 9388
n = int(input())
a = list(map(int, input().split()))

l = r = now = ans = 0
while r < n:
    if now + a[r] == now ^ a[r]:
        now += a[r]
        r += 1
        ans += r - l
    else:
        now -= a[l]
        l += 1

print(ans)

Measured memory_bytes: 23560
//auto 関数名 = [(&:ラムダ外の引数をとる時))](引数の型1 引数名1, 引数の型2, 引数名2, ...) { 関数の処理 }; //inside main() define function. take care of };
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//   bitset<ビット数> s(tmp);
//   // (ビット列sに対する処理)
// }
// sort(配列変数.begin(), 配列変数.end());
// do {
//   // 順列に対する処理
// } while (next_permutation(配列変数.begin(), 配列変数.end()));
//const double PI = acos(-1); M_PI
// cout << fixed << setprecision(10);
#include <bits/stdc++.h>
#include <regex>
using namespace std;
#define _GLIBCXX_DEBUG 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end() //sort(all(vec)); ,reverse(all(vec));etc
int main(){
    int n;
    cin>>n;
    uint64_t ans;
    vector<uint64_t>a(100000);
    ans=1;
    uint64_t k=1;
    rep(i,18){
        k*=10;
    }
    //cout<<k<<endl;
    rep(i,n){
       cin>>a.at(i);
       if(a.at(i)==0){
           cout<<0<<endl;
           return 0;
       }
    }
    rep(i,n){
        if(a.at(i)>k/ans){
            
            cout<<-1<<endl;
            return 0;
        }else{
            ans=ans*a.at(i);
        }
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 4052
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n,p;
    cin>>n>>p;
    ll maki=ll(sqrt(p));
    map<ll,ll> mp;
    for(ll i=2;i<=maki;i++){
        while(p%i==0){
            mp[i]++;
            p/=i;
        }
    }
    if(p>1)mp[p]++;
    ll ans=1;
    for(auto& i:mp){ 
        ans*=pow(i.first,(i.second)/n);
    }
    cout << ans<<endl;
    return 0;
}


Measured memory_bytes: 256
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;

int main(){
  int a,b;
  cin >> a >> b;
  int ans = 0;
  ans = max(a+b,a-b);
  ans = max(ans,a*b);
  printf("%d\n", ans);
  return 0;
}


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

using namespace std;
#define int long long
const int MOD = 1000000007;
int res = 0;
int N, M, Q;
vector<int> A;
vector<int> B;
vector<int> C;
vector<int> D;
vector<int> X;
void dfs(int a, int x) {
	if (a == N) {
		int score = 0;
		for (int i = 0; i < Q; i++) {
			if (X[B[i]] - X[A[i]] == C[i]) {
				score += D[i];
			}
		}
		res = max(res, score);
	} else {
		for (int i = x; i < M; i++) {
			X[a] = i;
			dfs(a + 1, i);
		}
	}
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N >> M >> Q;
	A.resize(Q);
	B.resize(Q);
	C.resize(Q);
	D.resize(Q);
	X.resize(M);
	for (int i = 0; i < Q; i++) {
		cin >> A[i] >> B[i] >> C[i] >> D[i];
		A[i]--;
		B[i]--;
	}
	dfs(0, 0);
	cout << res << endl;
}

Measured memory_bytes: 3620
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


vector<ll> getDivisorsList(ll n)
{
    vector<ll> ret;

    for (ll i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }

    sort(begin(ret), end(ret));
    return ret;
} 

int main()
{
	int N, M;
	cin >> N >> M;

    auto v = getDivisorsList(M);
    auto lower = lower_bound(all(v), N);

    for(auto iter = lower;iter != v.end(); ++iter)
    {
        if (M % *iter == 0)
        {
            cout << M / *iter << endl;
            return 0;
        }
    }

    cout << 1 << endl;

	return 0;
}	

Measured memory_bytes: 256
//raja1999
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
int get(int x){
	int res=0;
	while(x>0){
		res+=x%10;
		x/=10;
	}
	return res;
}
int main(){
	std::ios::sync_with_stdio(false);
	int n,i,val=0,res=inf;
	cin>>n;
	f(i,1,n){
		val=get(i);
		val+=get(n-i);
		res=min(res,val);
	}
	cout<<res<<endl;
} 
	

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
using namespace std;
int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-48;ch=getchar();}
	return x*f;
}

int main(){
	int x=read();
	for(int i=1;i;i++){
		if(i*(i+1)>=(2*x)){
			printf("%d\n",i);
			break;
		}
	}
	return 0;
}

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

a = raw_input()

count = 0

for i in range(26):
    c = a.count(chr(i+97))
    x = c * (c-1) / 2
    count += x

ans = len(a)*(len(a)-1)/2
ans -= count
ans += 1

print ans


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

long long md(pair<long long,long long> x,pair<long long,long long> y){
    return max(x.first,y.first)-min(x.first,y.first)+max(x.second,y.second)-min(x.second,y.second);
}

int main(){
    long long N,ans=1;
    cin >> N;
    for(long long i=1;i<N+1;i++){
        ans*=i;
        ans%=1000000007;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(final String[] args) {

        try (final Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            int[] A = new int[N];
            for (int i = 0; i < N; i++) {
                A[i] = sc.nextInt();
            }
            int[] left = new int[N + 1];
            int[] right = new int[N + 1];
            for (int i = 0; i < N; i++) {
                left[i + 1] = gcd(left[i], A[i]);
            }
            for (int i = N - 1; i >= 0; i--) {
                right[i] = gcd(right[i + 1], A[i]);
            }
            int max = 0;
            for (int i = 0; i < N; i++) {
                max = Math.max(max, gcd(left[i], right[i + 1]));
            }
            System.out.println(max);
        }
    }

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


Measured memory_bytes: 50200
#include <bits/stdc++.h>
using namespace std;
#define INF 2000000000
typedef long long int ll;
typedef pair<ll,ll> ii;
typedef pair<ii,ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
#define getbit(n,i) (((n)&(1<<(i)))!=0)
#define setbit0(n,i) ((n)&(~(1<<(i))))
#define setbit1(n,i) ((n)|(1<<(i)))
#define togglebit(n,i) ((n)^(1<<(i)))
#define lastone(n) ((n)&(-(n)))
#define read freopen("debug\\in.txt","r",stdin)
#define write freopen("debug\\out.txt","w",stdout)
#define fi first
#define se second
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d%d",&a,&b)
#define PI (acos(-1))
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod (1000000007)
#define asz 500005
#define pb push_back
#define ppf pop_front
#define ppb pop_back
#define pf push_front
ll cnt[200005];
vector<ll>v[200005];
int main() {
    fastread;
    ll n,i,j,k,l;
    string s;
    cin>>s;
    ll sz=s.size();
    ll gun=1;
    ll prevsum=0;
    for(i=sz-1;i>=0;i--){
        ll kola=(prevsum+(gun*(s[i]-'0'))%2019)%2019;
        gun=(gun*10)%2019;
        prevsum=kola;
        v[kola].pb(sz-1-i);
    }
    ll sum=0;
    gun=1;
    prevsum=0;
    for(i=sz-1;i>=0;i--){
        ll kola=(prevsum+(gun*(s[i]-'0'))%2019)%2019;
        gun=(gun*10)%2019;
        prevsum=kola;
        ll pos1=upper_bound(v[kola].begin(),v[kola].end(),sz-1-i)-v[kola].begin();
        ll pos2=v[kola].end()-v[kola].begin();
        sum+=(pos2-pos1);
    }
    ll pos1=upper_bound(v[0].begin(),v[0].end(),-1)-v[0].begin();
    ll pos2=v[0].end()-v[0].begin();
    sum+=(pos2-pos1);
    cout<<sum;
}

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

int K[31];
int A[31][31];
int C[31];
int main() {
    int N,M;
    cin >> N >> M;
    for(int i=0;i<M;i++) {
    	C[i]=0;
    }
    for(int i=0;i<N;i++) {
        cin >> K[i];
        for(int j=1;j<=K[i];j++) {
            cin >> A[i][j];
        }
    }

    for(int i=0;i<N;i++) {
        for(int j=1;j<=K[i];j++) {
            C[A[i][j]]++;
        }
    }

    int ans=0;
    for(int i=1;i<=M;i++) {
        if (C[i]==N) ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256