akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

long long b[401][401];
long long suma[401];
int a[401];

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    suma[0] = a[0];
    for (int i = 1; i < n; i++) {
        suma[i] = suma[i - 1] + a[i];
    }
    for (int i = 0; i < n; i++)
        for (int j = 0; j + i < n; j++) {
            if (i == 0) {
                b[j][j] = 0;
                continue;
            }
            long long min1 = 9223372036854775807LL;
            for (int k = 0; k < i; k++) {
                long long x = b[j][j + k] + b[j + k + 1][j + i] + suma[j + i] - (j == 0? 0:suma[j - 1]);
                if (x < min1)
                    min1 = x;
            }
            b[j][j + i] = min1;
        }
    cout << b[0][n - 1];
    return 0;
}


Measured memory_bytes: 1536
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long LL;
const int Mod=1000000007;
LL quick(LL x,LL y)
{
	LL res=1;
	while(y)
	{
		if(y&1)
		res=(x*res)%Mod;
		x=(x*x)%Mod;
		y>>=1;
	}
	return res;
}
int main()
{
	LL n,a[100010];
	while(scanf("%lld",&n)!=EOF)
	{
		int flag=1;
		for(int i=1; i<=n; i++)
		scanf("%lld",&a[i]);
		sort(a+1,a+1+n);
		if(n%2==0)
		{
			for(int i=1; i<=n-1; i+=2)
			{
				if(a[i]!=a[i+1])
				flag=0;
			}
		}
		else
		{
			if(a[1]!=0)
			flag=0;
			for(int i=2; i<=n-1; i+=2)
			{
				if(a[i]!=a[i+1])
				flag=0;
			}
		}
		if(flag==0)
		printf("0\n");
		else
		{
			if(n%2==0)
			printf("%lld\n",quick(2,(n/2)));
			else
			printf("%lld\n",quick(2,((n-1)/2)));
		}
	}
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

ll gcd(ll a, ll b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}

vector<ll> enum_div(ll n){//nの約数を列挙
  vector<ll> ret;
  for(ll i=1 ; i*i<=n ; ++i){
    if(n%i == 0){
      ret.push_back(i);
      if(i!=1 && i*i!=n){
        ret.push_back(n/i);
      }
    }
  }
  sort(ret.begin(),ret.end());
  return ret;
}

bool is_prime(ll num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

const int INF = 1<<30;
int main(){
  int n,m; cin >> n >> m; 
  vector<pair<int,int>> key; //鍵の情報
  rep(i,m){
    int a, b;
    cin >> a >> b;
    int s = 0; //空集合を作る
    rep(j,b){
      int c;
      cin >> c; //開けられる宝箱の番号を入力
      c--; //1-indexedなのでdecrimentする。
      s |= 1<<c; //ORでbitを立てていく
    }
    key.emplace_back(s,a); //firstに開けられる鍵の集合。secondに価格。
  }
  
  vector<int> dp(1<<n,INF); //キーを集合を取る配列を用意。
  dp[0] = 0; //何も開いていない状態（空集合）の最低コストはもちろん0
  rep(s,1<<n){ //全部の宝箱の状態をdpする。最大で2^12=4,096
    rep(i,m){ //全部の鍵を試す。最大で10^3
      int t = s | key[i].first; //sの集合にkey[i]で開けられる宝箱をORで追加しtとする。
      int cost = dp[s] + key[i].second; //dp[s]に入っているコストにkey[i]のコストを追加
      dp[t] = min(dp[t],cost); //コストが安ければ更新
    }
  }
  int ans = dp.back(); //一番後ろ、つまり全部の宝箱が開いている場合の集合を取る。
  if (ans == INF) ans = -1; //更新されていなければ全部の宝箱を開けられる集合はなかったとして-1を出力。
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
from sys import stdin
def main():
	readline=stdin.readline
	S=readline().strip()
	hflag=False
	iflag=True
	for i in range(len(S)):
		if S[i]=="h" and iflag:
			hflag=True
			iflag=False
		elif S[i]=="i" and hflag:
			iflag=True
			hflag=False
		else:
			print("No")
			break
	else:
		if hflag==False and iflag:
			print("Yes")
		else:
			print("No")
if __name__=="__main__":
	main()

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

bool isPrime(int x); 
int gcd(int a, int b); 
vector<int> primeFactorization(int x); 
void printVector(vector<long> list, string str); 
void setPrecision(int n);

void exec(int hoge) {
  cout << hoge << endl;
}

int main() {
  map<int, int> nums;
  int n;
  cin >> n;
  for (int i =0; i < n; i++) {
    int a;
    cin >> a;
    nums[a]++;
  }

  int count =0;
  for (pair<int, int> value : nums) {
    if (value.second % 2 == 1) count++;
  }
  cout << count << endl;

}

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

bool isPrime(int x) {
  if (x < 2) return false;
  if (x == 2) return true;
  if (x % 2 == 0) return false;

  double num = sqrt(x);
  for (int i = 3; i <= num; i+=2) {
    if (x % i == 0) {
      return false;
    }
  }
  return true;
}

// 素因数分解
// example: primeFactorization(12) = vector<int>{2, 2, 3}
vector<int> primeFactorization(int x) {
  vector<int> ans;
  int i = 2;
  while (i*i <= x) {
    if (x % i == 0) {
      ans.push_back(i);
      x /= i;
    } else {
      i++;
    }
  }
  ans.push_back(x);
  return ans;
}

void printVector(vector<long> list, string str) {
  for (int i = 0; i < list.size(); i++) {
    cout << str << ": " << list[i] << endl;
  }
}

void setPrecision(int n) {
  cout << fixed << setprecision(n);
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

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

    vec<int> x(N), y(N);
    rep(i, N) cin >> x[i] >> y[i];

    auto distance = [](long double x1, long double x2, long double y1,
                       long double y2) {
        long double dx = x2 - x1;
        long double dy = y2 - y1;
        return sqrt(dx * dx + dy * dy);
    };

    double sm = 0;
    ll cnt    = 0;

    function<void(vec<int>)> dfs = [&](vec<int> d) {
        if (d.size() == N) {
            rep(i, N - 1) {
                int a = d[i];
                int b = d[i + 1];

                sm += distance(x[a], x[b], y[a], y[b]);
            }
            ++cnt;
        }
        rep(i, N) {
            if (find(all(d), i) != d.end()) continue;
            d.push_back(i);
            dfs(d);
            d.pop_back();
        }
    };

    dfs(vec<int>(0));

    cout << fixed << setprecision(15);
    cout << sm/cnt << endl;
}


Measured memory_bytes: 3848
#include<bits/stdc++.h>
using namespace std;
int N,K;
int memo[100001];
int arr[100001];
int main()
{
	scanf("%d %d",&N,&K);
	for(int i=0;i<N;i++)
	{
		scanf("%d",&arr[i]);
		memo[i]=1000000000;
	}
	memo[0]=0;
	for(int i=0;i<N;i++)
		for(int j=1;j<=K && i+j<N;j++)
			memo[i+j]=min(memo[i+j],memo[i]+abs(arr[i]-arr[i+j]));
	printf("%d\n",memo[N-1]);
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	int a, b,c;
	cin >> a >> b >> c;
	int ans = 0;
	if (a > b && a > c)
		ans = b + c;
	else if (b > a && b > c)
		ans = a + c;
	else
		ans = a + b;
	cout << ans << endl;

} 

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

S = input()

s1 = int(S[0:2])
s2 = int(S[2:4])

mm_s1 = False
mm_s2 = False
output = ''

if s1 > 0 and s1 <= 12:
    mm_s1 = True
if s2 > 0 and s2 <= 12:
    mm_s2 = True

if mm_s1 == True and mm_s2 == True:
    output = 'AMBIGUOUS'
elif mm_s1 == True and mm_s2 == False:
    output = 'MMYY'
elif mm_s1 == False and mm_s2 == True:
    output = 'YYMM'
else:
    output = 'NA'

print (output)

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

using namespace std;

/**
 * AOJの過去問を参考にしました。
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_3_B&lang=jp
 *
 * うしさんのコード(AOJのコード)をパクッてしまった。
 * パクッたうしさんのコード
 * http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=2397653#1
 */

struct UnionFind
{
	vector< int > data;

	UnionFind(int sz)
	{
		data.assign(sz, -1);
	}

	bool unite(int x, int y)
	{
		x = find(x), y = find(y);
		if (x == y) return (false);
		if (data[x] > data[y]) swap(x, y);
		data[x] += data[y];
		data[y] = x;
		return (true);
	}

	int find(int k)
	{
		if (data[k] < 0) return (k);
		return (data[k] = find(data[k]));
	}

	int size(int k)
	{
		return (-data[find(k)]);
	}
};

struct LowLink
{
	UnionFind uf;
	vector< vector< int > > g;
	vector< int > used, ord, low, parent;

	LowLink(size_t v) : g(v), used(v, 0), ord(v), low(v), uf(v), parent(v, -1) {}

	virtual void add_edge(int x, int y)
	{
		g[x].push_back(y);
		g[y].push_back(x);
	}

	void dfs(int idx, int &k, int par = -1)
	{
		used[idx] = true;
		ord[idx] = k++;
		low[idx] = ord[idx];

		for (auto &to : g[idx]) {
			if (!used[to]) {
				dfs(to, k, idx);
				low[idx] = min(low[idx], low[to]);
				parent[to] = idx;
				if (ord[idx] >= low[to]) uf.unite(idx, to);
			}
			else if (to != par) {
				low[idx] = min(low[idx], ord[to]);
			}
		}
	}

	void dfs()
	{
		int k = 0;
		dfs(0, k);
	}
};

struct ArticulationPoints : LowLink
{
	ArticulationPoints(size_t v) : LowLink(v) {}

	vector< int > build()
	{
		LowLink::dfs();
		vector< int > vs;
		int sum = 0;
		for (int i = g.size() - 1; i >= 1; i--) {
			if (parent[i] == 0) ++sum;
			else if (ord[parent[i]] <= low[i]) vs.push_back(parent[i]);
		}
		if (sum > 1)vs.push_back(0);
		sort(begin(vs), end(vs));
		vs.erase(unique(begin(vs), end(vs)), end(vs));
		return (vs);
	}
};

struct BiConnectedComponents : LowLink
{
	vector< pair< int, int > > edges;
	vector< int > comp;

	BiConnectedComponents(size_t v) : LowLink(v), comp(v) {}

	void add_edge(int x, int y)
	{
		LowLink::add_edge(x, y);
		edges.push_back(minmax(x, y));
	}

	int operator[](int k)
	{
		return (comp[k]);
	}

	vector< pair< int, int > > build(vector< vector< int > > &t)
	{
		LowLink::dfs();
		int ptr = 0;
		vector< int > cc(g.size());
		for (int i = 0; i < g.size(); i++) {
			if (i == uf.find(i)) cc[i] = ptr++;
		}

		t.resize(ptr);
		for (int i = 0; i < g.size(); i++) {
			comp[i] = cc[uf.find(i)];
		}
		vector< pair< int, int > > vs;
		for (auto &e : edges) {
			int x = comp[e.first], y = comp[e.second];
			if (x == y) continue;
			vs.emplace_back(e.first, e.second);
			t[x].push_back(y);
			t[y].push_back(x);
		}
		sort(begin(vs), end(vs));
		return (vs);
	}
};

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

	int n, m;
	cin >> n >> m;
	BiConnectedComponents graph(n);

	// うしさん許して
	vector< vector< int > > ei1333;
	for (int i = 0; i < m; i++) {
		int s, t;
		cin >> s >> t;
		s--; t--;
		graph.add_edge(s, t);
	}

	int res = 0;
	for (auto &p : graph.build(ei1333)) {
		res++;
	}

	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;
long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; }

int main(){
    ll K;
    cin >> K;
    ll sev = 7;
    rep(i, K){
        if(sev%K==0){
            cout << i+1 << endl;
            return 0;
        }
        sev = sev*10+7;
        sev%=K;
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 3616
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const ll INF=1e18;

ll s[200005],t[200005];

ll mod_pow(ll x,ll n,ll m){
    if(n==0) return 1;
    ll res=mod_pow(x*x%m,n/2,m);
    if(n&1) res=res*x%m;
    return res;
}

int main(){
    ll n,m,k;
    cin>>n>>m>>k;
    ll A=n*m;
    ll B=A-2;
    ll ans=0;
    ll cnt=1;
    ll c;
    ll ma=n+m-2;
    s[0]=t[0]=0;
    for(ll i=1;i<=ma+2;i++){
        s[i]=i*(i+1)/2;
        t[i]=i*(i+1)*(i+2)/6;
    }
    for(ll i=0;A-2-i>A-k;i++) cnt=(cnt*(A-2-i))%mod;
    for(ll i=2;i<=k-2;i++) cnt=(cnt*mod_pow(i,mod-2,mod))%mod;
    c=cnt;
    ll i=1,j=1;
    while(true){
        ll now=0;
        now=(now+s[m-j])%mod;
        if(j==1){
            now=(now+(t[m-j+n-i]-t[m-j]-t[n-i-1])%mod)%mod;
        }else if(j==m){
            now=(now+(t[j+n-i-1]-t[j-1]-t[n-i-1])%mod)%mod;
        }else{
            now=(now+(t[m-j+n-i]-t[m-j]-t[n-i-1])%mod)%mod;
            now=(now+(t[j+n-i-1]-t[j-1]-t[n-i-1])%mod)%mod;
            now-=s[n-i];
            while(now<0) now=now+mod;
        }
        ans=(ans+(now*cnt)%mod)%mod;
        if(j==m){
            i++;j=1;
        }else{
            j++;
        }
        if(i==n&&j==m) break;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3328
import java.util.Scanner;

class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力

		
		int n = sc.nextInt();
		int k = sc.nextInt();
		double ans = 0;
		
		for(int i = 1;i <= n;i++){
			double sub = ((double)1/n);

			int two = 0;
			int sum = i;
			while(sum < k){
				two++;				//1,2,3,4
				sum *= 2;			//2,4,8,16
			}
			sub *= (double)(1/Math.pow(2, two));
		//	System.out.println("sub " + sub);

			ans += sub;
		}
		System.out.print(ans);
		
	}
	
	
	static int gcd(int a,int b){				//最大公約数を返す
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}
	




static String deletestr(String base,String remove){
	boolean flag = true;
	for(int i = 0;i < remove.length();i++){
		if(i == base.length()){
			flag = false;
			break;
		}
		if(base.charAt(i) - remove.charAt(i) != 0 && base.charAt(i) - remove.charAt(i) != 32 &&remove.charAt(i) - base.charAt(i)  != 32){
			flag = false;
			break;
		}
	}

	if(flag){
		base = base.substring(remove.length());
	}

	return base;

}



}


class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return from - otherpair.from;
	}
}




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

namespace ITP2_4_D
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int n = ReadInt();
            Console.WriteLine(WriteAr(ReadIntAr().Distinct().ToArray()));
        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }
        static string WriteAr(int[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(double[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(long[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }

    }

}



Measured memory_bytes: 39868
import sys
from collections import defaultdict
from collections import deque
def load(vtype=int):
    return vtype(input().strip())
def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]
def exit():
    import sys
    sys.exit(0)
def perm_sub(li, used):
    if len(li) == len(used):
        return [deque()]
    k = []
    for i in range(len(li)):
        if i in used:
            continue
        used.add(i)
        sub_list = perm_sub(li, used)
        for sub in sub_list:
            sub.appendleft(li[i])
        k.extend(sub_list)
        used.discard(i)
    return k
def perm_li(li):
    return perm_sub(li, set())
def perm_n(n):
    return perm_sub(list(range(n)), set())
def join_i(li, sep=""):
    return sep.join([str(e) for e in li])
def li2n(li):
    n, base = 0, 1
    for i in range(len(li)-1, -1, -1):
        n += li[i] * base
        base *= 10
    return n
def sli2ili(li):
    return [int(s) for s in li] 

import math
from decimal import *

a, b, c = load_list()
if (Decimal(a).sqrt() + Decimal(b).sqrt()).compare(Decimal(c).sqrt()) == Decimal(-1):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 5068
from collections import deque

class Graph(): #directed
    def __init__(self, n, edge, indexed=1):
        self.n = n
        self.graph = [[] for _ in range(n)]
        for e in edge:
            self.graph[e[0] - indexed].append(e[1] - indexed)

INF = 10**18

N, M = map(int, input().split())
edge = [tuple(map(int, input().split())) for _ in range(M)]

g = Graph(N, edge)

loopsize = INF

for i in range(N):
    root = i
    stack = [root]
    visited = [0 for _ in range(N)]
    visited[root] = 1
    while stack:
        node = stack.pop()
        for adj in g.graph[node]:
            if adj == root: #閉路を検出
                break
            if visited[adj]:
                continue
            visited[adj] = 1
            stack.append(adj)
        else:
            continue
        break
    else:
        continue
    #閉路があるとき
    queue = deque([root])
    dist = [INF for _ in range(N)]
    dist[root] = 0
    prev = [None for _ in range(N)]
    while queue:
        node = queue.popleft()
        for adj in g.graph[node]:
            if adj == root:
                dist[root] = dist[node] + 1
                prev[root] = node
                break
            if dist[adj] != INF:
                continue
            dist[adj] = dist[node] + 1
            prev[adj] = node
            queue.append(adj)
        else:
            continue
        break
    #最小サイズの閉路なら条件を満たす
    if loopsize > dist[root]:
        loopsize = dist[root]
        path = [root]
        node = root
        while prev[node] != root:
            node = prev[node]
            path.append(node)
        res = path

if loopsize != INF:
    print(loopsize)
    for node in res:
        print(node + 1)
else:
    print(-1)

Measured memory_bytes: 76844
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <cstring>
#include <string>
#include <bitset>
#include <stdlib.h>
#include <time.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef unsigned long long ull;
typedef set<int>::iterator SI;

#define st first
#define sd second
#define mkp make_pair
#define pb push_back
void wenjian(){freopen("concatenation.in","r",stdin);freopen("concatenation.out","w",stdout);}
void tempwj(){freopen("hash.in","r",stdin);freopen("hash.out","w",stdout);}
ll gcd(ll a,ll b){return b == 0 ? a : gcd(b,a % b);}
ll qpow(ll a,ll b,ll mod){a %= mod;ll ans = 1;while(b){if(b & 1)ans = ans * a % mod;a = a * a % mod;b >>= 1;}return ans;}
struct cmp{bool operator()(const pii & a, const pii & b){return a.second > b.second;}};
int lb(int x){return  x & -x;}

const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll mod = 9901;
 
const int M = 10000007;
const int maxn = 1e6+5;


int main()
{
	int T;
	scanf("%d",&T);
	printf("%d\n",T + T * T  + T * T*T);
}

Measured memory_bytes: 3228
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <algorithm>
#include <tuple>

int main()
{
	int N, K;
	std::cin >> N >> K;

	if (N > (K - 1) * 2)
		std::cout << "YES\n";
	else
		std::cout << "NO\n";
}


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

using namespace std;

const int N = 101;
const int K = 100001;
int a[N], dp[K], n, k;

int g(int pile) {
    int& ans = dp[pile];
    if (ans != -1) {
        return ans;
    }
    set<int> s;
    for (int i = 1; i <= n; i++) {
        if (pile - a[i] >= 0) {
            s.insert(g(pile - a[i]));
        }
    }
    int mex = 0;
    while (s.count(mex)) {
        mex++;
    }
    return ans = mex;
}

int main() {
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    memset(dp, -1, sizeof dp);
    if (g(k) != 0) {
        cout << "First\n";
    } else {
        cout << "Second\n";
    }
    return 0;
}


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

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}

signed main() {
	double w,h,x,y;
	cin>>w>>h>>x>>y;
	printf("%.9lf",w*h/2);
	cout<<" ";
	if(x*2==w&&y*2==h){
		cout<<1<<endl;
	}
	else{
		cout<<0<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int n,m,a[100000],c[100000],d[100000];
vector<int>b[100000];
int main(){
	cin>>n>>m;
	for(int i=0;i<n;i++){cin>>a[i];b[a[i]%m].push_back(a[i]);}
	for(int i=0;i<m;i++){
		sort(b[i].begin(),b[i].end());int v=1;
		for(int j=1;j<b[i].size();j++){
			if(b[i][j]!=b[i][j-1]){if(v%2==1)c[i]++;d[i]+=v/2;v=1;}
			else v++;
		}
		if(b[i].size()>=1){if(v%2==1)c[i]++;d[i]+=v/2;}
	}
	int cnt=0;
	for(int i=0;i<=m/2;i++){
		int t=(m-i)%m;
		if(i!=t){
			int F1=min(b[i].size(),b[t].size());
			int F2=F1;cnt+=F1;
			int G1=min(c[i],F1);F1-=G1;c[i]-=G1;if(F1>=1)d[i]-=(F1+1)/2;
			int G2=min(c[t],F2);F2-=G2;c[t]-=G2;if(F2>=1)d[t]-=(F2+1)/2;
		}
		if(i==t){cnt+=b[i].size()/2;c[i]=b[i].size()%2;d[i]=0;}
	}
	for(int i=0;i<m;i++)cnt+=d[i];
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 6912
n, k = gets.split.map(&:to_i)
r, s, p = gets.split.map(&:to_i)
$points = { "r" => p, "s" => r, "p" => s }
t = gets.chomp.each_char.to_a

m = n.fdiv(k).ceil * k
t[m - 1] = t[m - 1]
ts = t.each_slice(k).to_a.transpose.each(&:compact!)

def f(t)
  sum = 0
  t.join.scan(/(.)(\1*)/) do |x, y|
    num = y.length / 2 + 1
    sum += $points[x] * num
  end
  sum
end

puts ts.inject(0) { |sum, t| sum + f(t) }


Measured memory_bytes: 26364
#include"bits/stdc++.h"
// #include "prettyprint.hpp"

using namespace std;

#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, n) for(ll i=n; i>=0; i--)
#define reps(i, s, e) for(ll i=s; i<e; i++)
#define all(x) x.begin(),x.end()


int main(){
	int A, B;
	cin >> A >> B;

	if(A >= 1&& A <= 9 && B >= 1&& B <= 9 ){
		cout << A*B << endl;
	}

	else cout << -1 << endl;

	return 0;
}

Measured memory_bytes: 256
import copy

n = int(input())
A = list(map(int,input().split()))
sums = [0 for _ in range(n)]

sums[0] = A[0]

for i in range(1,n):
    sums[i] = A[i] + sums[i-1]
sums2 = copy.copy(sums)
tyousei = 0
ans1 = 0
for i in range(n):
    if i%2 ==0:
        if sums[i]+tyousei <=0:
            ans1 += abs(sums[i]+tyousei) +1
            tyousei += abs(sums[i]+tyousei) +1
    if i%2 ==1:
        if sums[i]+tyousei >=0:
            ans1 += abs(sums[i]+tyousei) +1
            tyousei -= sums[i]+tyousei +1

ans2 = 0
tyousei =0
for i in range(n):
    if i%2 ==1:
        if sums[i]+tyousei <=0:
            ans2 += abs(sums[i]+tyousei) +1
            tyousei += abs(sums[i]+tyousei) +1
    if i%2 ==0:
        if sums[i]+tyousei >=0:
            ans2 += sums[i]+tyousei +1
            tyousei -= sums[i]+tyousei +1

print(min(ans1,ans2))

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

typedef long long ll;

struct item {
  int v;
  int w;
  char t;
  ll d;
  string s;
};

bool comp(const item &a, const item &b){
  if(a.v == b.v){
    if(a.w == b.w){
      if(a.t == b.t){
        if(a.d == b.d){
          return a.s < b.s;
        }
        return a.d < b.d;
      }
      return a.t < b.t;
    }
    return a.w < b.w;
  }
  return a.v < b.v;
}

int main() {
  int n; cin >> n;
  vector<item> p(n);
  for(int i=0; i<n; i++){
    cin >> p[i].v >> p[i].w >> p[i].t >> p[i].d >> p[i].s;
  }

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

  for(int i=0; i<n; i++){
    cout << p[i].v <<" "<< p[i].w <<" "<< p[i].t <<" "<< p[i].d <<" "<< p[i].s << endl;
  }


}


Measured memory_bytes: 12132
use std::collections::BinaryHeap;

fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b' ');
    let m: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let mut av = vec![0usize; n];
    for i in 0..n - 1 {
        av[i] = read(&mut stdin_lock, &mut buf, b' ');
    }
    av[n - 1] = read(&mut stdin_lock, &mut buf, b'\n');

    let mut heap = BinaryHeap::new();
    for i in 0..n {
        heap.push(av[i]);
    }

    for _ in 0..m {
        let a = heap.pop().unwrap();
        heap.push(a / 2);
    }

    let mut ans = 0;
    while !heap.is_empty() {
        ans += heap.pop().unwrap();
    }
    println!("{}", ans);
}


Measured memory_bytes: 6396
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k,ans=0;
    cin >> n >> k;
    int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a,a+n);
    reverse(a,a+n);
    for(int i=0;i<k;i++){
        ans+=a[i];
    }
    cout << ans << endl;
    return 0;
}


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


void trace(int A[], int N)
{
  int i;
  for(i = 0; i < N-1; i++) cout << A[i] << " ";
  cout << A[i];
  cout << endl;
}

/*
@param int A : 配列
@param int N : 配列の要素数
*/
void insertionSort(int A[], int N)
{
  //for(int i = 1; i < N-1; i++)
  for(int i = 1; i < N; i++)
  {
    trace(A, N);

    int v = A[i];
    int j = i - 1;
    while( j >= 0 && A[j] > v)
    {
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
  }
  trace(A, N);
}


int main(int argc, char const *argv[]) {
  int array[1000];

  int N;
  cin >> N;
  for(int i = 0; i < N; i++) cin >> array[i];
  insertionSort(array, N);


  return 0;
}


Measured memory_bytes: 3136
import java.util.*;
import java.util.stream.Collectors;

public class Main {

    static int N;
    static int M;
    static List<long[]> list;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        M = sc.nextInt();

        list = new ArrayList<>();

        for (int i = 0; i < N; i++) {
            long x = sc.nextLong();
            long y = sc.nextLong();
            long z = sc.nextLong();

            list.add(new long[]{x, y, z});
        }

        solve();
    }

    static void solve() {
        List<int[]> signs = new ArrayList<>();
        signs.add(new int[]{ 1,  1,  1});
        signs.add(new int[]{ 1,  1, -1});
        signs.add(new int[]{ 1, -1,  1});
        signs.add(new int[]{ 1, -1, -1});
        signs.add(new int[]{-1,  1,  1});
        signs.add(new int[]{-1,  1, -1});
        signs.add(new int[]{-1, -1,  1});
        signs.add(new int[]{-1, -1, -1});

        long max = 0;
        for (int[] sign : signs) {
            max = Math.max(
                    max,
                    list.stream()
                        .map(xyz -> xyz[0] * sign[0] + xyz[1] * sign[1] + xyz[2] * sign[2])
                        .sorted(Comparator.reverseOrder())
                        .limit(M)
                        .mapToLong(Long::longValue)
                        .sum()
            );
        }

        System.out.println(max);
    }
}

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

int main(){
int a,b;
cin>>a>>b;
if(a<=b){
    for(int i=0;i<b;i++){
        cout<<a;
    }
}
else{
    for(int i=0;i<a;i++){
        cout<<b;
    }
}

return 0;
}



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

struct UnionFind {
  int num;
  vector<int> data;
  vector<int> rank;

  UnionFind(int N) : num(N), data(N, -1), rank(N, 0) {}

  int root(int x) {
    if (data[x] < 0) return x;
    return data[x] = root(data[x]);
  }

  bool unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x != y) {
      if (rank[x] < rank[y]) swap(x, y);
      if (rank[x] == rank[y]) rank[x]++;
      data[x] += data[y];
      data[y] = x;
      num--;
    }
    return x != y;
  }

  bool same(int x, int y) { return root(x) == root(y); }
  int size(int x) { return -data[root(x)]; }
};



int main(){
  int N, M, K; cin >> N >> M >> K;
  vector<int> ff(N, 0);
  UnionFind uf(N);
  rep(i, M) {
    int A, B; cin >> A >> B;
    A--; B--;
    ff[A]++; ff[B]++;
    uf.unite(A, B);
  }

  vector<int> ans(N);
  rep(i, N) ans[i] = uf.size(i) - ff[i] - 1;
  
  rep(i, K) {
    int C, D; cin >> C >> D;
    C--; D--;
    if (uf.same(C, D)) {
      ans[C]--; ans[D]--;
    }
  }

  rep(i, N) cout << ans[i] << " ";
}


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

int main() {
	string a,b;
	cin>>a>>b;
	if(a[1]!=b[1])
	{
		cout<<"NO";
		return 0;
	}
	if(a[0]!=b[2])
	{
		cout<<"NO";
		return 0;
	}
	if(a[2]!=b[0])
	{
		cout<<"NO";
		return 0;
	}
	cout<<"YES";
	return 0;
}

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

m=int(input())
q=list(map(int,input().split()))

sum=[0]
for i in range(n):
    for j in range(len(sum)):
        sum.append(A[i]+sum[j])

for i in range(m):
    if q[i] in sum:
        print("yes")
    else:
        print("no")


Measured memory_bytes: 42976
cand = [1]
MAX = 10**5 +1
for c in (6,9):
  coin = 1
  while 1:
    coin *= c
    if coin <= MAX:
      cand.append(coin)
    else:
      break
cand.sort()

dp = [float('inf') for i in range(MAX)]
dp[0] = 0
n = int(input())
for i in range(n):
  for c in cand:
    if i+c < MAX:
      dp[i+c] = min(dp[i+c], dp[i]+1)
print(dp[n])

Measured memory_bytes: 6296
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;

int main(){
	ll N,M;
	cin>>N>>M;
	for(ll i(M/N);i>=1;--i){
		if( M%i == 0 ){
			cout << i << endl;
			return 0;
		}
	}
}

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vvll = vector<vll>;
using vst = vector<st>;
using vchar = vector<char>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
ll mod = 1000000007;

int main(){
  ll n;
  cin >> n;
  vll a(n);
  vin(a);
  ll pointer = 0, ans = 0, check = 0;
  while(pointer < n - 1){
    if(a.at(pointer) < a.at(pointer + 1)){
      if(check == 0){
        check = 1;
        pointer++;
      }
      else if(check == 1) pointer++;
      else {
        check = 0;
        ans++;
        pointer++;
      }
    }
    else if(a.at(pointer) == a.at(pointer + 1)) pointer++;
    else{
      if(check == 0){
        check = 2;
        pointer++;
      }
      else if(check == 2) pointer++;
      else {
        check = 0;
        ans++;
        pointer++;
      }
    }
  }    
  cout << ans + 1 << endl;
}

Measured memory_bytes: 1024
def e_hopscotch_addict(N, M, Edges, S, T, INF=float('inf')):
    from collections import deque

    graph = [[] for _ in range(N)]
    for u, v in Edges:
        graph[u - 1].append(v - 1)
    start, target = S - 1, T - 1

    # editorialに従って G' を構成
    graph_prime = [[INF] * N for _ in range(3)]
    graph_prime[0][start] = 0  # S_0を起点とする
    queue = deque([(start, 0)])  # S_0を最初にデックに入れる
    while queue:
        vertex, t = queue.popleft()
        u = (t + 1) % 3
        for to in graph[vertex]:
            if graph_prime[u][to] != INF:
                continue  # もう探索済み
            queue.append((to, u))
            graph_prime[u][to] = graph_prime[t][vertex] + 1
    return graph_prime[0][target] // 3 if graph_prime[0][target] != INF else -1

N, M = [int(i) for i in input().split()]
Edges = [[int(i) for i in input().split()] for j in range(M)]
S, T = [int(i) for i in input().split()]
print(e_hopscotch_addict(N, M, Edges, S, T))

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

#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define rng(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define all(x) (x).begin(),(x).end()
#define cAll(x) (x).cbegin(),(x).cend()
#define COUT(x) cout << x << endl
//#define int long long

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

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

const int MOD = 1000000007;
const int INF = INT_MAX;

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

	VP AB(N);

	for (auto& ab : AB) {
		cin >> ab.first >> ab.second;
	}

	ULL money = 0;
	int idx = 0;
	priority_queue<int> b;

	sort(all(AB));

	rng(m, AB[0].first, M + 1) {
		if (idx < N) {
			while (AB[idx].first <= m) {
				b.push(AB[idx++].second);
				if (idx >= N) break;
			}
		}

		if (!(b.empty())) {
			money += b.top();
			b.pop();
		}
	}

	COUT(money);

	return 0;
}


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

class D
{
	static int[] Read() => Console.ReadLine().Split().Select(int.Parse).ToArray();
	static void Main()
	{
		var h = Read();
		int n = h[0], k = h[1];
		var p = Read();

		int t = p.Take(k).Sum(), M = t;
		for (int i = 0; i < n - k; i++)
			M = Math.Max(M, t += p[i + k] - p[i]);
		Console.WriteLine((M + k) / 2.0);
	}
}


Measured memory_bytes: 34396
@q=1;$#q=$N=<>;
/ /,push@{$`-1},$'-1for<>;
map$q[$_]+=$q[$i]/@$i,@{$i=$_}for 0..--$N;
while($N--){$s=$m=0;$m=($~=$e[$_])>$m?$~:$m,$s+=$~for@$N;$e[$N]=1+$s/@$N;
$a<($t=$q[$N]*=$#$N&&($s-$m)/$#$N-$s/@$N)or$a=$t}
print"@e"+$a

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

using namespace std;
using ll = long long int;
using lc = complex<double>;

int main(void) {
    constexpr ll MOD = 1e9 + 7;
    constexpr double PI = acos(-1);
    cout << fixed << setprecision(32);
    cin.tie(0); ios::sync_with_stdio(false);

    while(1) {
        ll n, m, t, p;
        cin >> n >> m >> t >> p;
        if(!n) break;
        vector<vector<ll>> v(m, vector<ll>(n, 1));

        ll si = 0, sj = 0;
        while(t--) {
            ll d, c;
            cin >> d >> c;
            if(d == 1) {
                if(c > n-sj-c)
                    for(ll i=si; i<m; i++)
                        for(ll j=sj; j<n-1+sj-j; j++)
                            swap(v[i][j], v[i][n-1+sj-j]);

                c = min(c, n-sj-c);
                for(ll i=si; i<m; i++)
                    for(ll j=0; j<c; j++)
                        v[i][sj+c+j] += v[i][sj+c-1-j];
                sj += c;
            } else {
                if(c > m-si-c)
                    for(ll i=si; i<m-1+si-i; i++)
                        for(ll j=sj; j<n; j++)
                            swap(v[i][j], v[m-1+si-i][j]);

                c = min(c, m-si-c);
                for(ll j=sj; j<n; j++)
                    for(ll i=0; i<c; i++)
                        v[si+c+i][j] += v[si+c-1-i][j];
                si += c;
            }
            assert(si < m);
            assert(sj < n);
        }

        while(p--) {
            ll x, y;
            cin >> x >> y;
            cout << v[si+y][sj+x] << endl;
        }
    }
}



Measured memory_bytes: 3132
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
using ll = long long;
int main(){
  int n, a;
  cin >> n;
  map<int, int> b;
  for(int i = 0; i < n; i++){
    cin >> a;
    b[a - 1]++;
    b[a]++;
    b[a + 1]++;
  }
  int maxi = 0;

  for(auto c:b){
    maxi = max(maxi, c.second);
  }
  cout << maxi << "\n";
  return 0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

int digit(ll n){
	if(n==0) return 1;
	int res = 0;
	while(n){
		n /= 10;
		res++;
	}
	return res;
}

int main(void) {
	int k; cin >> k;
	vll lun;
	
	queue<ll> q;
	rep2(i,1,10) q.push(ll(i));
	while(true){
		ll x = q.front(); q.pop();
		if(x) lun.push_back(x);
		if(lun.size()==100000) break;
		int r = x%10;
		for(int i=r-1; i<=r+1; i++){
			if(i<0||i>=10) continue;
			ll add = i;
			ll nxt = x*10+add;
			q.push(nxt);
		}
	}
	SORT(lun);
//	rep(i,k) cout << lun[i] << endl;
	cout << lun[k-1] << endl;
}




Measured memory_bytes: 2548
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using ll = long long;
using namespace std;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int N,K;
int main(){
    cin >> N >> K;
    double ans = 0;
    rep1(i,N){
        double ct = 1,k = i;
        while(k < K) k *= 2, ct /= 2;
        ans += (1/(double)N)*ct;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val H = sc.nextInt()
    val W = sc.nextInt()
    val h = sc.nextInt()
    val w = sc.nextInt()
    if (H % h == 0 && W % w == 0) {
        println("No")
        return
    }
    val a = H / h
    val b = W / w
    val x = H * W - a * b * h * w
    val plus = (a * b) / x + 1
    val minus = (1 - h * w) * plus - 1
    val ans = Array(H) { Array(W) { 0 } }
    for (i in 0 until H) {
        for (j in 0 until W) {
            ans[i][j] = if ((i + 1) % h == 0 && (j + 1) % w == 0) minus else plus
        }
    }
    println("Yes")
    for (i in 0 until H) {
        println(ans[i].joinToString(" "))
    }
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

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

int n, m, x;
vector<int> cs;
vector<vector<int>> as;
int ans = 1000000000;
bool f = false;

void search(vector<int> aSum, int cSum, int idx) {
  if (idx >= n) {
    bool can = true;
    for (int i = 0; i < m; i++) {
      if (aSum[i] < x) {
        can = false;
        break;
      }
    }

    if (can) {
      ans = min(ans, cSum);
      f = true;
    }
  } else {
    search(aSum, cSum, idx+1);

    for (int i = 0; i < m; i++) {
      aSum[i] += as[idx][i];
    }
    search(aSum, cSum+cs[idx], idx+1);
  }
}

void solver() {
  cin >> n >> m >> x;
  for (int i = 0; i < n; i++) {
    int c;
    cin >> c;
    cs.push_back(c);
    vector<int> as_;
    for (int i = 0; i < m; i++) {
      int a;
      cin >> a;
      as_.push_back(a);
    }
    as.push_back(as_);
  }

  vector<int> aSum(m);
  int cSum = 0;
  int idx = 0;
  search(aSum, cSum, idx);

  if (f){
    cout << ans << "\n";
  } else {
    cout << "-1\n";
  }
}

int main() {
  solver();
  return 0;
}


Measured memory_bytes: 3636
import sys
input = sys.stdin.readline

mod = 10**9+7

def cmb(n, r, mod=mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
NN = 4*10**5 # 使うデータによって変える
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, NN + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

N = int(input())
graph = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

Child = [1]*N
Score = [1]*N

def dfs1(s):
    stack = [s]
    Ind = [0]*N
    while stack:
        p = stack[-1]
        #print(p)
        #print(Score)
        #print(Child)
        if Ind[p] == len(graph[p]):
            stack.pop()
            par = -1
            if len(stack) > 0:
                par = stack[-1]
            P = []
            for ch in graph[p]:
                if ch == par: continue
                Child[p] += Child[ch]
                P.append([Score[ch], Child[ch]])
            tmp = Child[p]-1
            for s, c in P:
                Score[p] = (Score[p] * s * cmb(tmp, c)) % mod
                tmp -= c
        elif len(stack) > 1 and stack[-2] == graph[p][Ind[p]]:
            Ind[p] += 1
        else:
            stack.append(graph[p][Ind[p]])
            Ind[p] += 1

ans = [-1]*N

def dfs2(s):
    stack = [s]
    ans[s] = Score[s]
    Ind = [0]*N
    while stack:
        p = stack[-1]
        #print(p)
        #print(Score)
        #print(Child)
        if Ind[p] == len(graph[p]):
            stack.pop()
            if len(stack) > 0:
                par = stack[-1]
                kiyo = Score[par] * cmb(Child[p]-1, Child[par])
                Score[p] = Score[p] * pow(kiyo, mod-2, mod) % mod
                Child[p] -= Child[par]
                Child[par] += Child[p]
                Score[par] = (Score[par] * Score[p] * cmb(Child[par]-1, Child[p])) % mod
        elif len(stack) > 1 and stack[-2] == graph[p][Ind[p]]:
            Ind[p] += 1
        else:
            ch = graph[p][Ind[p]]
            kiyo = Score[ch] * cmb(Child[p]-1, Child[ch])
            Score[p] = Score[p] * pow(kiyo, mod-2, mod) % mod
            Child[p] -= Child[ch]
            Child[ch] += Child[p]
            Score[ch] = (Score[ch] * Score[p] * cmb(Child[ch]-1, Child[p])) % mod
            ans[ch] = Score[ch]
            stack.append(ch)
            Ind[p] += 1

def main():
    dfs1(0)
    dfs2(0)
    print(*ans, sep="\n")

if __name__ == "__main__":
    main()

Measured memory_bytes: 122836
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Stream;
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.nextLine());
    int[] a = new int [n+1];
    for(int i = 0; i < n; i++){
        a[i+1] = sc.nextInt();
    }
    sc.close();
    int[] b = new int [n+1];
    int cnt = 0;
    List<Integer>ans = new ArrayList<Integer>();
    for(int i = n; i > 0; i--){
        int c = 0;
        int j = 2;
        while (i*j <= n) {
            c += b[i*j];
            j++;
        }
        if(a[i] != (c%2)){
            b[i] = 1;
            ans.add(i);
        }
    }
    System.out.println(ans.size());
    Collections.reverse(ans);
    ans.stream().forEach(v -> {System.out.print(v + " ");});
  }
}

Measured memory_bytes: 87108
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

void yes(){
   cout<<"Yes"<<endl;
   //exit (0);
}
void no(){
   cout<<"No"<<endl;
   //exit (0);   
}

int n, a[N];
string s, t;

int32_t main(){_
      
   int n;
   cin >> n;
   long double x = 101 / 100.000;
   long double tmp = x;
   int amt = 100;
   for (int i = 1; ; ++i)
   {
      amt = amt * ((long double)101/(100.00));
      if (amt >= n){
         cout<<i;
         return 0;
      }
   }
   

   return 0;
}

Measured memory_bytes: 3648
/*----------------by syr----------------*/
/*

         iii                  ii
     rBQBBBBBBE       BBR iBBBBQBBL     XBBBBBBQBBBBB
   iBBQJ    7BBB      BBsSBBr   BBQ      i      cBBB
  rBBU       iBBw     BBBQi     HBBi           KBBi
  BBH         BB5    iBBB       isL          wBB5
 GBB         iBBi    6BB                   iBBB
 BBQ         BQB     BBD                  QBBi
 BBB        BQB     iQBi                1BBv
 sBBg     wBBB      QBB               iBBB
  7BBBBBBBBBi       BBR              wBBBBBBBBBBBBB
     irvi           ii               ii    i i iii
                i5U
               BBB
               BB7
              1BB
      iPBBBBBKBBR    JBR1       rQBO   BR  UBQP  iBBQi
    7BBBGs7sXBBBi     QBBr     gBBE   rBB BB2BB7HBZQBB
   QBBi      sBQ       BBB   iBBB     SQBBR  BBBB  cBQ
  gBQ        BBg        BBB KBBi      MBBH   BBB   BBs
 iBBv       iBBi         QBBBL        BBR   pBB   iBB
 pBB        BBB         iBBBB        iBB    BBL   KBB
 MBB       BBBR        BBB JBBi      DBR   iBQ    BBL
 GBB     7BBBB2      PBBH   BBBi     BQr   DBB   iBB
  BQBXwgBBP BB7    1BBB      BBQ7   1BB    BBc   BBB
   2BBBBw   BB    EBBS        QBBi  HBa   iBB    BB7
*/
#include<bits/stdc++.h>

using namespace std;

#define PH push
#define MP make_pair
#define PB push_back
#define fst first
#define snd second
#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define x0 x0123456789
#define y0 y0123456789
#define x1 x1234567890
#define y1 y1234567890
#define x2 x2345678901
#define y2 y2345678901
typedef double db;
typedef long long ll;
typedef long double ldb;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9 + 7;

int n, s, s1, ans = INF;
int a[105];

int main(){
	scanf("%d", &n);
	FOR(i, 0, n)
		scanf("%d", a + i), s += a[i];
	FOR(i, 0, n)
		s1 += a[i], ans = min(ans, abs(s1 - (s - s1)));
	printf("%d\n", ans);
	return 0;
}



Measured memory_bytes: 256