akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pi> vpi;
typedef vector<vi> vii;
typedef map<int, int> mp;
typedef multiset<int> mset;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
typedef vector<int64> vi64;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define form(i,j,k,l) for(int i=j;i<int(k);i+=l)
#define rform(i,j,k,l) for(int i=int(j);i>int(l);i-=l)
#define rep(i, j) for(int i=0;i<int(j);i++)
#define rrep(i, j) for(int i=int(j);i>=0;i--)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define forc(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define INF (int)1e9
#define INF64 (int64)1e18
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define F first
#define S  second
const double pie = acos(-1.0);
template <typename T>
T Max(T x, T y)
{
  return (x > y) ? x : y;
}
template <typename T>
T Min(T x, T y)
{
  return (x > y) ? y : x;
}
int gcd(int n1, int n2)
{
  if (n2 != 0) return gcd(n2, n1 % n2);
  else return n1;
}
#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define trace(...)
#endif
clock_t time_p = clock();
void rtime() { time_p = clock() - time_p; cerr << "Time Taken : " << (float)1000 * (time_p) / CLOCKS_PER_SEC << "\n";}
int main()
{ fast;
  int n;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++)
    cin >> arr[i];
  int cnt = 0;
  for (int i = 0; i < n; i++)
  { for (int j = i + 1; j < n; j++)
    { if (arr[i] == arr[j])
        continue;
      for (int k = j + 1; k < n; k++)
      { if (arr[k] == arr[i] || arr[k] == arr[j])
          continue;
        int t1 = arr[i] + arr[j];
        int t2 = arr[j] + arr[k];
        int t3 = arr[k] + arr[i];
        if (t1 > arr[k] && t2 > arr[i] && t3 > arr[j])
        { cnt++;
        }

      }

    }

  }
  cout << cnt;
}




Measured memory_bytes: 3640
n = int(input())
ans = 0
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
div = make_divisors(n)
for i in div[1:]:
    if n//(i-1)==n%(i-1):
        ans += i-1

print(ans)

Measured memory_bytes: 39024
a= str(input())
if a=='abc':
	print("Yes")
elif a=='acb':
	print("Yes")
elif a=='bac':
	print("Yes")
elif a=='bca':
	print("Yes")
elif a== 'cab':
	print("Yes")
elif a=='cba':
	print("Yes")
else:
	print("No")


Measured memory_bytes: 2940
#include <stdio.h>

int main() {

	int A, B;

	scanf("%d %d",&A,&B);

	if (A == 1) { A = 14; }
	if (B == 1) { B = 14; }

	if (A == B) { printf("Draw\n"); }
	else if (A > B) { printf("Alice\n"); }
	else { printf("Bob\n"); }

	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(){
    int i;
    int X;
    scanf("%d", &X);
    if (X == 3 || X == 5 || X == 7){
        printf("YES\n");
    }
    else{
        printf("NO\n");
    }


    return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
	public static void main(final String[] args) {
        final Scanner sc = new Scanner(System.in);
        
        Integer N = sc.nextInt(); // 数列
        Integer Q = sc.nextInt(); // クエリ

        sc.nextLine();

        sc.close();

        Integer ans = N*Q;

        System.out.println(ans);

    }
}

Measured memory_bytes: 35784
S = gets.strip
SIGNS = [ '+', '-' ]

SIGNS.each do |a|
	SIGNS.each do |b|
		SIGNS.each do |c|
			s = S.dup.insert( 3, a ).insert( 2, b ).insert( 1, c )
			if eval( s ) == 7 then
				puts s + "=7"
				exit 0
			end
		end
	end
end

exit 1


Measured memory_bytes: 1788
package main

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

func solve() {
	_ = getInt()
	a, b := getInt(), getInt()

	ans := "Alice"
	if (b-a)%2 == 1 {
		ans = "Borys"
	}
	fmt.Fprintln(wr, ans)
}

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

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

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

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

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


Measured memory_bytes: 640
#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;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}

int main(){
  int n; cin >> n;
  vector<int> v(n);
  rep(i,n) cin >> v[i];
  sort(v.begin(),v.end());
  
  int ans = 0;
  
  rep(i,n){
    for(int j = i+1; j < n; j++){
      int k = lower_bound(v.begin(),v.end(), v[i]+v[j]) - v.begin();
      ans += max(k - (j+1),0);
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<cmath>
#include<limits>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
#define pno cout << "no" << endl
#define pyes cout << "yes" << endl
#define pYes cout << "Yes" << endl
#define pNo cout << "No" << endl
using namespace std;
#define int ll
bool validate(vi vec, int flag_even) {
	if (flag_even) {
		for (auto e : vec) {
			if (e != 2) {
				return false;
			}
		}
	}
	else {
		for (int i = 0; i < vec.size(); i++) {
			if (vec[0] != 1) {
				return false;
			}
			if (i != 0 && vec[i] != 2) {
				return false;
			}
		}
	}

	return true;
}

ll mpow(ll x, ll n) { //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % MOD;
		x = x * x % MOD;
		n = n >> 1;
	}
	return ans;
}

inline int ctoi(char c) {
	return c - '0';
}

ll acc(vi v) {
	ll res = 0;
	for (auto e : v) {
		res += e;
	}
	return res;
}
signed main() {
	string s; cin >> s;
	int N = s.size();
	ll ans = 0;
	for (int i = 0; i < (1 << N); i += 2) {
		bitset<10> bs = i;
		int cnt = 0;
		int u = 0;
		vector<int> vec(10);

		for (int j = s.size() - 1; j  >= 0; j--) {
			vec[u] += mpow(10, cnt) * ctoi(s[j]);
			if (bs[j] == true) {
				u++;
				cnt = 0;
			}
			else {
				cnt++;
			}
		}

		ans += acc(vec);
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 3620
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;
vector <int> edges[1000];
vector <int> cycle;
bool in_stack[1000];
bool done[1000];
set <pair <int, int> > edge_set;
int cycle_begin;
bool dfs_cycle(int cur){
  in_stack[cur] = true;
  cycle.push_back(cur);
  done[cur] = true;
  for(int i = 0; i < edges[cur].size(); i++){
    int next = edges[cur][i];
    if(in_stack[next]){
      cycle_begin = next;
      return true;
    } else {
      if(!done[next] && dfs_cycle(next)){
        return true;
      }
    }
  }
  cycle.pop_back();
  in_stack[cur] = false;
  return false;
}

int main(void){
  int N;
  int M;
  cin >> N >> M;
  for(int i = 0; i < M; i++){
    int a;
    int b;
    cin >> a >> b;
    edges[a - 1].push_back(b - 1);
    edge_set.insert(make_pair(a - 1, b - 1));
  }
  for(int i = 0; i < N; i++){
    if(!done[i]){
      if(dfs_cycle(i)){
        break;
      }
    }
  }

  if(cycle.size() == 0){
    cout << -1 << endl;
    return 0;
  }

  vector <int> new_cycle;
  for(int i = 0; i < cycle.size(); i++){
    if(cycle[i] == cycle_begin){
      for(int j = i; j < cycle.size(); j++){
        new_cycle.push_back(cycle[j]);
      }
      break;
    }
  }
  cycle = new_cycle;
  while(true){
    map <int, int> cycle_map;
    for(int i = 0; i < cycle.size(); i++){
      cycle_map[cycle[i]] = i;
      //cout << cycle[i] << " ";
    }
    //cout << endl;
    bool updated = false;
    for(int u = 0; u < N; u++){
      for(int j = 0; j < edges[u].size(); j++){
        int v = edges[u][j];
        if(cycle_map.find(u) != cycle_map.end() 
          && cycle_map.find(v) != cycle_map.end() 
          && (cycle_map[u] + 1) % cycle.size() != cycle_map[v]){
          vector <int> next_cycle;
          if(cycle_map[u] > cycle_map[v]){
            for(int k = cycle_map[v]; k <= cycle_map[u]; k++){
              next_cycle.push_back(cycle[k]);
            }
          } else {
            for(int k = cycle_map[v]; k < cycle.size(); k++){
              next_cycle.push_back(cycle[k]);
            }
            for(int k = 0; k <= cycle_map[u]; k++){
              next_cycle.push_back(cycle[k]);
            }
          }
          cycle = next_cycle;
          updated = true;
          break;
        }
      }
      if(updated){
        break;
      }
    }
    if(!updated){
      break;
    }
  }

  cout << cycle.size() << endl;
  for(int i = 0; i < cycle.size(); i++){
    cout << cycle[i] + 1 << endl;
  }

  for(int i = 0; i < cycle.size(); i++){
    if(edge_set.find(make_pair(cycle[i], cycle[(i + 1) % cycle.size()])) == edge_set.end()){
      cout << "shit no edge!" << endl;
    }
    for(int j = 0; j < cycle.size(); j++){
      if(i == j || (i + 1) % cycle.size() == j){
        continue;
      }
      if(edge_set.find(make_pair(cycle[i], cycle[j])) != edge_set.end()){
        cout << "shit" << endl;
      }
    }
  }

  return 0;
}


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

using namespace std;

string s;
set<char> st;

int main(void) {
	cin>>s;
	int n = s.size();
	for(int i = 0; i < n; ++i) {
		st.insert(s[i]);
	}
	if((st.find('S') != st.end()) && (st.find('N') == st.end())) {
		cout<<"No";
	}
	else
	if((st.find('N') != st.end()) && (st.find('S') == st.end())) {
		cout<<"No";
	}
	else
	if((st.find('E') != st.end()) && (st.find('W') == st.end())) {
		cout<<"No";
	}
	else
	if((st.find('W') != st.end()) && (st.find('E') == st.end())) {
		cout<<"No";
	}
	else {
		cout<<"Yes";
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define all(v) v.begin(), v.end()
#define vl vector<ll>
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define ff first
#define ss second
ll INF = 1e9;
const int N=100005;
void solve()
{
    ll n,k=1,m=0,i=1,j,x,y,l,r,z;
    ll ans=0,sum;
    cin>>n;
    ll dp[3]{},newDp[3]{},a[3];
    for(i=1;i<=n;i++)
    {
        for(j=0;j<3;j++)
            cin>>a[j];
        for(j=0;j<3;j++)
        {
            for(k=0;k<3;k++)
            {
                if(k!=j)
                newDp[j]=max(newDp[j],a[j]+dp[k]);
            }
        }
        for(j=0;j<3;j++)dp[j]=newDp[j],newDp[j]=0;
    }
    cout<<max({dp[0],dp[1],dp[2]});
}
int main()
{
    ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
     #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin) ;
    freopen("output.txt", "w", stdout) ;
    #endif 
    int t=1;
    //cin>>t;
    while(t--)solve();
    return 0;
}

Measured memory_bytes: 3656
#include<iostream>
#include <iomanip>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<string.h>
#include<math.h>
#include<unordered_map>
#include <deque>
using namespace std;


typedef long long ll;
typedef long long ll;

int n;
ll sum = 0;

int dif[100001] = {};


int main()
{
	int bef = 0, bb = 0;


	cin >> n;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		sum += abs(a - bef);
		if (i == n - 1)sum += abs(a);

		if (i >= 1) 
			dif[i - 1] = abs(a - bb) - (abs(a - bef) + abs(bef - bb));

		if(i==n-1)
			dif[i] = abs(bef - 0) - (abs(a - 0) + abs(bef - a));
		
		bb = bef;
		bef = a;
	}

	for (int i = 0; i < n; i++) {
		cout << sum + dif[i] << endl;
	}

	return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <LL,LL>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

LL n,m,x,y,dp[60][1100000];
vector <pii> g[60];
vector <LL> contr[60],pass;

bool dfs(LL pos,LL no)
{
	if(pos==y) return true;
	rep(i,g[pos].size())
	{
		if(g[pos][i].fi==no) continue;
		pass.pb(g[pos][i].se);
		if(dfs(g[pos][i].fi,pos)) return true;
		pass.pop_back();
	}
	return false;
}

int main()
{
	cin>>n;
	rep(i,n-1)
	{
		cin>>x>>y;
		g[x].pb(mpr(y,i));
		g[y].pb(mpr(x,i));
	}
	cin>>m;
	rep(i,m)
	{
		cin>>x>>y;
		pass.clear();
		dfs(x,0);
		rep(j,pass.size()) contr[pass[j]].pb(i);
	}
	dp[0][0]=1;
	rep(i,n-1)
	{
		rep(j,1<<m)
		{
			if(dp[i][j]==0) continue;
			dp[i+1][j]+=dp[i][j];
			int tmp=j;
			rep(k,contr[i].size()) tmp|=(1<<contr[i][k]);
			dp[i+1][tmp]+=dp[i][j];
		}
	}
	cout<<dp[n-1][(1<<m)-1]<<endl;
	return 0;
}

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

using namespace std;

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

  int h,w;
  cin >> h>>w;
  vector<string> a;
  for (int i = 0; i < h; ++i) {
    string s;
    cin >> s;
    if (find(s.begin(), s.end(), '#') != s.end()) {
      a.push_back(s);
    }
  }
  vector<int> crash(w, 0);
  for (auto& e : a) {
    for (int i = 0; i < w; ++i) {
      crash[i] |= e[i] == '#';
    }
  }

  for (auto& e : a) {
    string row;
    for (size_t i = 0; i < e.size(); ++i) {
      if (crash[i] != 0) {
        row.push_back(e[i]);
      }
    }
    cout << row << "\n";
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int[] P = new int[N];
    for (int i = 0; i < N; i++) P[i] = scanner.nextInt();
    int min = P[0];
    int count = 1;
    for (int i = 1; i < N; i++) {
      if (P[i] < min) count++;
      min = Math.min(min, P[i]);
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 65452
N,M=map(int,input().split())
mises=[]
for i in range(N):
    mises.append(list(map(int,input().split())))

mises.sort()
pay=0
for i in mises:
    if i[1]<M:
        pay+=i[0]*i[1]
        M-=i[1]
    else:
        pay+=i[0]*M
        break
print(pay)


Measured memory_bytes: 27756
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

int main(){
  int n, m;
  cin >> n >> m;
  vector<pair<ll, ll>> ab(n);
  rep(i,n){
   int a, b;
   cin >> a >> b;
    ab[i].first = a;
    ab[i].second = b;
  }
  sort(ab.begin(),ab.end());
  ll ans = 0;
  int hon = 0;
  int i=0;
  while(hon < m){
    hon++;
    ans += ab[i].first;
    ab[i].second --;
    if(ab[i].second == 0) i++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 4844
var e:array[1..100000] of boolean;
    ans,i,a,n:longint;

begin
  readln(n);
  for i:=1 to n do begin
    read(a);
    e[a]:=true
  end;
  ans:=0;
  for i:=1 to 100000 do if e[i] then ans:=ans+1;
  if ans mod 2 = 0 then ans:=ans-1;
  writeln(ans)
end.

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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    bool beg = true;
    int digit[] = {10, 50, 100, 500};
    while(true){
        int res[4] = {};
        int dec = -mod;
        int N; cin >> N;
        if(N == 0) break;
        if(!beg){
            cout << endl;
        }
        beg = false;
        int ten, fif, hun, fiv_hun;
        cin >> ten >> fif >> hun >> fiv_hun;
        rep(i, ten+1){
            rep(j, fif+1){
                rep(k, hun+1){
                    rep(l, fiv_hun+1){
                        int pay = i*10 + j*50 + k*100 + l*500;
                        int num_coin = i+j+k+l;
                        if(pay >= N){
                            int charge = pay - N;
                            int ch_500 = charge / 500;
                            charge -= ch_500*500;
                            int ch_100 = charge / 100;
                            charge -= ch_100*100;
                            int ch_50 = charge / 50;
                            charge -= ch_50*50;
                            int ch_10 = charge / 10;
                            charge -= ch_10*10;
                            if(!((l > 0 && ch_500 > 0) || (k > 0 && ch_100 > 0) || (j > 0 && ch_50 > 0) || (i > 0 && ch_10 > 0))){
                                if(dec < num_coin - ch_10 - ch_50 - ch_100 - ch_500){
                                    dec = num_coin - ch_10 - ch_50 - ch_100 - ch_500;
                                    res[0] = i;
                                    res[1] = j;
                                    res[2] = k;
                                    res[3] = l;
                                }
                            }
                        }
                    }
                }
            }
        }
        rep(i, 4){
            if(res[i] > 0){
                cout << digit[i] << " " << res[i] << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3016
#include <bits/stdc++.h>
using namespace std;
#define pb                push_back
#define int               long long
#define M                 1000000007
#define MM                998244353
#define fr                first
#define sc                second
#define vc                vector
#define pii               pair<int,int>
#define msi               map<string,int>
#define mii               map<int,int>
#define psi               pair<string,int>
#define pis               pair<int,string>
#define piii              pair<int,pii>

	signed main() {
	
		   int t=1;
		  //cin>>t;
		   while(t--)
		   {
		   		
		   	int n,k,w,mx=0,sum=0,xx=0;
		             string s;

		        cin>>n;
		        int a[n];
		        map<int,int>m;
		        for(int i=1;i<n;i++){
		        	cin>>a[i];
		        	m[a[i]]++;}
		        	for(int i=1;i<=n;i++)
		        		cout<<m[i]<<endl;
}
 
	} 

Measured memory_bytes: 17688
#include <cstdio>
#include <queue>
#include <cstdlib> 
using namespace std;
struct nn{
//	nn(){}
	int m,val;
	nn(int a,int b):m(a),val(b){}
};
deque <nn> node;
int k;
const int maxn=1e5+10;
bool vis[maxn];
int main(){
	scanf("%d",&k);
	//nn x;
	//x.m=1;
	//x.val=1;
	for(int i=0;i<k;i++){
		vis[i]=1;
	}
	node.push_back(nn(1,1));
	while(node.front().m){
		int mm1,mm2;
		vis[node.front().m]=0;
		mm1=(node.front().m*(10%k))%k;
		mm2=(node.front().m+1)%k;
		int vall=node.front().val;
		node.pop_front();
		if(vis[mm1]){
			node.push_front(nn(mm1,vall));
			//vis[node.front().m]=0;
		}
		if(vis[mm2]){
			node.push_back(nn(mm2,vall+1));
			//vis[node.front().m]=0;
		}
	}
	printf("%d",node.front().val);
	return 0;
}

Measured memory_bytes: 3708
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

char ans[100][100];

void AddWhite(int A)
{
    if (A == 0) return;
    for (int i = 99; i > 50; i -= 2)
    {
        if (A == 0) return;
        for (int j = 0; j < 100; j += 2)
        {
            if (A == 0) return;
            ans[i][j] = '.';
            --A;
        }
    }
}

void AddBlack(int B)
{
    if (B == 0) return;
    for (int i = 0; i < 50; i += 2)
    {
        if (B == 0) return;
        for (int j = 0; j < 100; j += 2)
        {
            if (B == 0) return;
            ans[i][j] = '#';
            --B;
        }
    }
}

int main()
{
    int A, B; cin >> A >> B;
    for (int i = 0; i < 50; ++i)
    {
        for (int j = 0; j < 100; ++j) ans[i][j] = '.';
    }
    for (int i = 50; i < 100; ++i)
    {
        for (int j = 0; j < 100; ++j) ans[i][j] = '#';
    }
    --A; --B;
    AddWhite(A);
    AddBlack(B);
    cout << 100 << ' ' << 100 << endl;
    for (int i = 0; i < 100; ++i)
    {
        for (int j = 0; j < 100; ++j)
        {
            cout << ans[i][j];
        }
        cout << endl;
    }
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, x, n) for(int i = x; i < (int)(n); i++)
#define ALL(n) begin(n), end(n)
//struct cww{cww(){ios::sync_with_stdio(false);cin.tie(nullptr);}}star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;

int main() {
  int n, m, k;
  scanf("%d", &n);
  scanf("%d", &m);
  scanf("%d", &k);

  vector<int> a(n);
  REP(i, n) scanf("%d", &a[i]);
  vector<int> b(m);
  REP(i, m) scanf("%d", &b[i]);

  int max = 0;        // 答えとなる最高記録
  int curr_num = 0;   // 現在読んでいる冊数
  int curr_time = 0;  // 現在の合計時間
  int x = -1;          // 現在机Aから読んでいる冊数-1（上から）
  int y = -1;          // 現在机Bから～

  while (x + 1 < n) {
    if (curr_time + a[x + 1] <= k) {
      x++;
      curr_time += a[x];
      curr_num++;
    } else {
      break;
    }
  }
  max = curr_num;

  while(y + 1 < m) {
    if (curr_time + b[y + 1] <= k) {
      y++;
      curr_time += b[y];
      curr_num++;
      max = (curr_num > max) ? curr_num : max;
      continue;
    } else {
      if (x >= 0) {
        curr_time -= a[x];
        curr_num--;
        x--;
        continue;
      } else {
        break;
      }
    }
  }

  printf("%d\n", max);
  return 0;
}


Measured memory_bytes: 4868
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = INT64_MAX;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i=0;i<N;i++)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll w,h,x,y;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>w>>h>>x>>y;
    double ans = (double)w*h;
    if(x*2==w && y*2 == h){
        cout<<ans/2.0<<" "<<1<<endl;
    }else{
        cout<<ans/2.0<<" "<<0<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define SIZE 501

int main(){
  char s1[SIZE], s2[SIZE];
  scanf("%s", s1);
  scanf("%s", s2);

  char s[SIZE];
  int len1,len2;
  for(int i=0; ; i++){
    s[2*i] = s1[i];
    len1 = i;
    if(s1[i] == '\0') break;
  }

  for(int i=0; ; i++){
    s[2*i+1] = s2[i];
    len2 = i;
    if(s2[i] == '\0') break;
  }

  s[len1+len2] = '\0';

  printf("%s\n", s);
  

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
long long a[100000 * 2];
long long n, A, B;
inline bool check(long long mid) {
	long long need = 0;
	for (int i = 1; i <= n; i++) {
		if ((a[i] + B - 1ll) / B <= mid) {
			continue;
		} else {
			//A * c + (mid - c) * B >= x
			//A * c + mid * B - Bc >= x
			//A * c - B * c >= x - mid * B
			//c * (A - B) >= x - mid * B
			//c >= x * mid * B / (A - B);
			long long x = a[i];
			long long c = (x - mid * B + (A - B) - 1ll) / (A - B);
			need += c;
			if (need > mid) {
				return false;
			}
		}
	}
	return need <= mid;
}
int main() {
	scanf("%lld%lld%lld", &n, &A, &B);
	for (int i = 1; i <= n; i++) {
		scanf("%lld", &a[i]);
	}
	sort(a + 1, a + 1 + n);
	reverse(a + 1, a + 1  +n);
	long long l = -1;
	long long r = 1e16;
	while (r - l > 1ll) {
		long long mid = (r + l )/ 2;
		if (check(mid)) {
			r = mid;
		} else {
			l = mid;
		}
	}
	cout << r;
	return 0;
}


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

int main() {
	while(true){
		int n,r;
		cin>>n>>r;
		if(n==0&&r==0) return 0;
		vector<int>v(n+5);
		for(int i=0;i<n;i++) v[i]=n-i;
		for(int i=0;i<r;i++){
			int p,c;
			cin>>p>>c;
			vector<int>u(p-1);
			vector<int>l(c);
			for(int i=0;i<p-1;i++) u[i]=v[i];
			for(int i=p-1;i<p-1+c;i++) l[i-(p-1)]=v[i];
			for(int i=0;i<c;i++) v[i]=l[i];
			for(int i=c;i<c+p-1;i++) v[i]=u[i-c];
		}
		cout<<v[0]<<endl;
	}
	return 0;
}


Measured memory_bytes: 3064
import java.util.*;

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

		ArrayList<Integer> array = new ArrayList<>();
		
		for (int i=0; i<n; i++) {
			int query = scan.nextInt();
			if (query == 0) {
				array.add(scan.nextInt());
			}
			else if (query == 1) {
				System.out.println(array.get(scan.nextInt()));
			}
			else if (query == 2) {
				array.remove(array.size()-1);
			}
		}
		
	}
}


Measured memory_bytes: 141324
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        int n;
        cin >> n;
        int a[n];
        for(int i = 0; i < n; i++){
            cin >> a[i];
        }
        int ans = 0;
        for(int i = 1; i < n - 1; i++){
            vector<int> v = {a[i - 1], a[i], a[i + 1]};
            sort(all(v));
            if(v[1] == a[i]){
                ans++;
            }
        }
        cout << ans << '\n';
    }
}

Measured memory_bytes: 31488
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		String s = sc.next();
		if (a<3200) {
			System.out.println("red");
		} else {
			System.out.println(s);
		}
	}
}

Measured memory_bytes: 22100
n = gets.to_i
l = gets.split.map(&:to_i)

l.sort!

ans = 0
for a in 0...n-2
    for b in a+1...n-1
        t = l[a] + l[b]
        c = l.bsearch_index{|x| x >= t}

        left = b+1
        right = c
        ans += (c ? c : n) - (b + 1)
    end
end

puts ans

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

int main() {
    int N;
    int a = 0, un = 0;
    cin >> N;
    string S;
    for(int i = 0; i < N; i++) {
        cin >> S;
        if(S == "A") {
            a++;
        }
        else if(S == "Un") {
            un++;
        }
        if(a < un) {
            cout << "NO" << endl;
            return 0;
        }
    }
    if(a == un) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 3140
#include <stdio.h>
#include <math.h>
int main() {int N;scanf("%d",&N);while (N--) {double x1,x2,x3,y1,y2,y3,a1,a2,b1,b2,c1,c2;scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3);a1=(x2-x1)*2,b1=(y2-y1)*2,a2=(x3-x1)*2,b2=(y3-y1)*2,c1=x1*x1-x2*x2+y1*y1-y2*y2,c2=x1*x1-x3*x3+y1*y1-y3*y3,x3=(b1*c2-b2*c1)/(a1*b2-a2*b1),y3=(c1*a2-c2*a1)/(a1*b2-a2*b1);a1=sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3));printf("%.3lf %.3lf %.3lf\n",x3,y3,a1);} return 0;}

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

int main(){
    while(true){
        int a,b;
        scanf("%d %d",&a,&b);
        if(a==0&&b==0)return 0;
        for(int i=0;i<a;i++){
            for(int j=0;j<b;j++){
            printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main()
{
	int n;
	cin >> n;
	vector<int> d(n);
	for (int i = 0; i < n; i++)
	{
		cin >> d[i];
	}
	int m;
	cin >> m;
	vector<int> t(m);
	for (int i = 0; i < m; i++)
	{
		cin >> t[i];
	}
	map<int, int> a;
	for (int x : d)
	{
		a[x]++;
	}
	bool ans = true;
	for (int x : t)
	{
		if (a[x] == 0)
		{
			ans = false;
			break;
		}
		else
		{
			a[x]--;
		}
	}
	if (ans == true)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 11136
#include <iostream>
typedef long long ll;
using namespace std;

int main() {
    ll n, x, a, b, cnt=0;
    cin >> n >> x >> a;
    if(a>x) {
        cnt = a-x;
        a = x;
    }
    for(int i=1; i<n; i++) {
        cin >> b;
        if(a+b>x) {
            cnt+=a+b-x;
            b = x-a;
        }
        a = b;
    }

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
//ITP1_2_B
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int a = 0;
  int b = 0;
  int c = 0;
while(cin >> a >> b >> c){
if(a < b && b < c){

	printf("Yes\n");
}else	
	printf("No\n");


}


    return 0;
}


Measured memory_bytes: 3036
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{

    public static void Main()
    {
        int N = intRead();
        string S = Console.ReadLine();
        int[] E = new int[300001];
        int[] W = new int[300001];
        E[0] = 0; W[0] = 0;
        for (int i = 1; i <= N; i++)
        {
            if (S[i - 1] == 'W')
            {
                E[i] = E[i - 1];
                W[i] = W[i - 1] + 1;
            }
            else
            {
                E[i] = E[i - 1] + 1;
                W[i] = W[i - 1];
            }
        }
        int min = 3000001;
        for (int i = 1; i <= N; i++)
        {
            min = Math.Min(min, (W[i - 1] + (E[N] - E[i])));
        }
        Console.WriteLine(min);
    }
}


public class Atcoder
{
    static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static int LCM(int a, int b)
    {
        int c = a * b;
        if (a < b) Swap(ref a, ref b);
        int d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string strReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int intRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }

}


Measured memory_bytes: 14432
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main(){
  int n;
  cin>>n;
  int a[n],cnt=0,fl=0;
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
  }
  int j=1;
  for(int i=0;i<n;i++)
  {
    if(a[i]==j){
       fl=1;
      cnt++;
      j++;
              }
  }
  if(fl==0){cout<<-1;return 0;}
  cout<<n-cnt;
}

Measured memory_bytes: 1024
#include <stdio.h>
int A[100];
 

void printSequence(int len, int num){
    int i;
    for(i = 0; i<len; i++){
        if(i != 0)printf(" ");
        printf("%d",A[i]);
    }
 
    printf("\n");
    printf("%d\n",num);
 
}
 
int main(){
    int key = 0, num = 0, len, i, j, minj;
 
    scanf("%d", &len);
    for(i = 0; i<len; i++){
        scanf("%d",&A[i]);
    }
 

    for(i = 0;i <= len - 1;i++){
        minj = i;
        for(j = i; j <= len - 1;j++){
            if(A[j] < A[minj]){
                minj = j;
            }
        }
 
        if(minj != i){
            key = A[i];
            A[i] = A[minj];
            A[minj] = key;
            num++;
        }
    }
 
    printSequence(len, num);
 
    return 0;
}

Measured memory_bytes: 604
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
#define LL long long
#define mod 1000000007
#define G() Cr=getchar()
int Xr;char Cr;
inline int rd(){   //ｶﾁﾈ・ﾅｻｯ
    Xr=0,G();
    while(Cr<'0'||Cr>'9')G();
    while(Cr>='0'&&Cr<='9')Xr=(Xr<<3)+(Xr<<1)+Cr-'0',G();
    return Xr;
}
int n,ans;
struct node{
	int va,pos;
}e[100005];
bool comp(node x,node y){
	return x.va<y.va;
}
int main(){
    n=rd();
    for(int i=1;i<=n;i++)e[i].va=rd(),e[i].pos=i;
    sort(e+1,e+1+n,comp);
    for(int i=1;i<=n;i++)ans+= (e[i].pos&1)^(i&1);
    cout<<ans/2<<endl;
}

Measured memory_bytes: 1024
N, M = map(int, input().split())

inter, goalable = set(), set()
for i in range(M):
  a, b = map(int, input().split())
  if a == 1:
    inter.add(b)
    
  if b == N: 
    goalable.add(a)
      
flag = inter & goalable
print("POSSIBLE" if flag else "IMPOSSIBLE")

Measured memory_bytes: 18892
fn main() {
    let n ={
        let mut inputline = String::new();
        std::io::stdin().read_line(&mut inputline).ok();
        inputline.trim().parse::<usize>().unwrap()
    };
    let p:Vec<usize> = {
        let mut inputline = String::new();
        std::io::stdin().read_line(&mut inputline).ok();
        inputline.split_whitespace().map(|x|x.parse::<usize>().unwrap()).collect()
    };
    let count ={ 
        let mut count = 0;
        for i in 1..n-1{
            if (p[i-1]<p[i] && p[i]<p[i+1]) || (p[i+1]<p[i] && p[i]<p[i-1]){
                count = count +1;
            }
        }
        count
    };
    println!("{}",count);
}


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

int main() {
  int L, R, d;
  cin >> L >> R >> d;

  int res = 0;
  for (L; L <= R; L++){
    if (L % d == 0) {
      res++;
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 3592
N,T=map(int, input().split())
A=[[0]*2 for _ in range(N)]
for i in range(N):
    A[i][1], A[i][0] = map(int,input().split())
A.sort()

import bisect
idx = bisect.bisect_right(A,[T,1001])

if idx==0:
    print('TLE')
else:
    print(min(A[:idx],key=lambda l:l[1])[1])

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <stddef.h>
#include <stack>
#include <queue>

using namespace std;

int main() {
	int x;
	int i=1;
	while (1) {
		cin >> x;
		if (x == 0) break;
		cout << "Case " << i <<": " << x << endl;
		i++;
	}
}

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

int main(){
	int n;
	cin>>n;
	while(n--){
		deque<char> deq;	
		string s;
		cin>>s;
		int p=0;
		deq.push_front(s[0]);
		for(int i=1;i<s.size();i+=3){
			if(s[i]=='<'){
				if(p==0)deq.push_front(s[i+2]);
				else p--;
			}else{
				if(p+1==deq.size())deq.push_back(s[i+2]);
				p++;
			}
		}
		for(int i=0;i<deq.size();i++)cout<<deq[i];
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1200
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 14;
const int MAXBITS = 1 << MAX_N;
const double DINF = 1e70;

/* typedef */

/* global variables */

int n;
double xs[MAX_N][2], ys[MAX_N][2], ds[MAX_N];
double dp[MAXBITS][MAX_N][2];

/* subroutines */

/* main */

int main() {
  for (int cn = 1;; cn++) {
    cin >> n;
    if (n == 0) break;

    for (int i = 0; i < n; i++) {
      cin >> xs[i][0] >> ys[i][0] >> xs[i][1] >> ys[i][1];
      double dx = xs[i][1] - xs[i][0];
      double dy = ys[i][1] - ys[i][0];
      ds[i] = sqrt(dx * dx + dy * dy);
    }

    for (int b = 0; b < MAXBITS; b++)
      for (int i = 0; i < n; i++)
	for (int k = 0; k < 2; k++) dp[b][i][k] = DINF;

    for (int i = 0; i < n; i++)
	for (int k = 0; k < 2; k++) dp[1 << i][i][k] = ds[i];
    
    for (int bits0 = 1; bits0 < MAXBITS; bits0++) {
      for (int i0 = 0; i0 < n; i0++) {
	int bi0 = 1 << i0;
	if (! (bits0 & bi0)) continue;

	for (int k0 = 0; k0 < 2; k0++) {
	  double dp0 = dp[bits0][i0][k0];
	  double x0 =xs[i0][k0], y0 = ys[i0][k0];

	  for (int i1 = 0; i1 < n; i1++) {
	    int bi1 = 1 << i1;
	    if (bits0 & bi1) continue;
	    int bits1 = bits0 | bi1;
	    
	    for (int k1 = 0; k1 < 2; k1++) {
	      double dx =xs[i1][k1 ^ 1] - x0, dy = ys[i1][k1 ^ 1] - y0;
	      double dp1 = dp0 + sqrt(dx * dx + dy * dy) + ds[i1];
	      if (dp[bits1][i1][k1] > dp1) dp[bits1][i1][k1] = dp1;
	    }
	  }
	}
      }
    }

    double min_d = DINF;
    int allbits = (1 << n) - 1;

    for (int i = 0; i < n; i++)
      for (int k = 0; k < 2; k++)
	if (min_d > dp[allbits][i][k]) min_d = dp[allbits][i][k];

    printf("Case %d: %.5lf\n", cn, min_d);
  }

  return 0;
}

Measured memory_bytes: 4832
import math
import fractions
#import sys
#input = sys.stdin.readline

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def ValueToBits(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

def BitsToValue(arr):
    n = len(arr)
    ans = 0
    for i in range(n):
        ans+= arr[i] * 2**i
    return ans

def ZipArray(a):
    aa = [[a[i],i]for i in range(n)]

    aa.sort(key = lambda x : x[0])
    for i in range(n):
        aa[i][0]=i+1
    aa.sort(key = lambda x : x[1])
    b=[aa[i][0] for i in range(len(a))]
    return b

def ValueToArray10(x, digit):
    ans = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        ans[digit-i-1] = now%10
        now = now //10
    return ans

def Zeros(a,b):
    if(b<=-1):
        return [0 for i in range(a)]
    else:
        return [[0 for i in range(b)] for i in range(a)]

class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
            
'''
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 2
N = 10 ** 6 + 2
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

'''

#a = list(map(int, input().split()))

#################################################
#################################################
#################################################
#################################################



n,m,x = list(map(int, input().split()))
costlist = []
info = []
for i in range(n):
    temp = list(map(int, input().split()))
    costlist.append(temp[0])
    info.append(temp[1:])

ans = 10**9
for i in range(2**n):
    bits = ValueToBits(i,n)
    sums = [0 for j in range(m)]
    costs = 0
    for j in range(n):
        if (bits[j]==1):
            costs+= costlist[j]
            for l in range(m):
                sums[l] += info[j][l]
    ok = 1
    for l in range(m):
        if(sums[l] < x):
            ok = 0
    if(ok == 1):
        ans = min(ans, costs)


if(ans>=10**9-1):
    print(-1)
else:
    print(ans)













Measured memory_bytes: 73988
n = gets.to_i
s = gets.chomp

cnt = 0
('0'..'9').each do |c|
  i = s.index c
  next unless i
  ('0'..'9').each do |d|
    j = s.index d, i+1
    next unless j
    ('0'..'9').each do |e|
      k = s.index e, j+1
      next unless k
      #STDERR.puts c+d+e
      cnt += 1
    end
  end
end

p cnt

Measured memory_bytes: 14360
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>
#include <random>
#include <functional>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

ll min(ll a, ll b) {return a < b ? a : b;}
ll min(int a, ll b) {return a < b ? a : b;}
ll min(ll a, int b) {return a < b ? a : b;}
ll min(int a, int b) {return a < b ? a : b;}

ll max(ll a, ll b) {return a > b ? a : b;}
ll max(int a, ll b) {return a > b ? a : b;}
ll max(ll a, int b) {return a > b ? a : b;}
ll max(int a, int b) {return a > b ? a : b;}

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()
#define int long long

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, h, w;
    cin >> h >> w >> n;
    int ans = 0;
    int c = 0;
    while (c < n)
    {
        ans++;
        c += max(h, w);
    }
    cout << ans;
}


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

int main() {
  long long n;
  cin >> n;
  vector<long long> v(5);
  for (int i = 0; i < 5; i++) {
    cin >> v[i];
  }

  sort(v.begin(), v.end());
  long long ans = 0;
  long long r = n % v[0];
  long long s;
  if (r == 0) {
    s = n / v[0];
  } else {
    s = (n / v[0]) + 1;
  }
  ans += (s + 4);
  cout << ans << endl;
};


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;

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

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

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main()
{
	ll n,c,k;
	cin>>n>>c>>k;
	vector<ll> t(n);
	for (int i = 0; i < n; i++){
		cin>>t[i];
	}
	sort(all(t));
	ll start = t[0];
	int ans = 0;
	int num = 0;
	for (int i = 0; i < n; i++){
		if(num<c && t[i] <= start + k) num++;
		else{
			ans++;
			start = t[i];
			num = 1;
		}
	}
	cout<<ans+1<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
	unsigned long n = 0;
	unsigned long a = 0;
	unsigned long b = 0;
	char d;

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

	if (a == 0) {
		printf("%ld\n", a);
	}
	else if (b == 0) {
		printf("%ld\n", n);
	}
	else if ((n % (a + b)) == 0) {
		printf("%ld\n", a * (n / (a + b)));
	}
	else {
		if (n % (a + b) < a) {
			printf("%ld\n", a * (n / (a + b)) + n % (a + b));
		}
		else {
			printf("%ld\n", a * (n / (a + b)) + a);
		}
	}

	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int c,m;
int main(){
    cin>>c;
    int a[c],b[c];
    for(int i=0;i<c;i++) cin>>a[i];
    for(int i=0;i<c;i++) cin>>b[i];
    for(int i=0;i<c;i++){
        if(a[i]-b[i]>0) m+=a[i]-b[i];
    }
    cout<<m;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define REP(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1<<x)-1)
#define DUP(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const double eps = 1e-9;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;

  vi water, sugar;
  REP(i,f+1) {
    REP(j,f+1) {
      int x = 100*a*i + 100*b*j;
      int y = c*i + d*j;
      if (x <= f) water.push_back(x);
      if (y <= f) sugar.push_back(y);
    }
  }

  SORT(water);
  SORT(sugar);

  water.erase(unique(ALL(water)),water.end());
  sugar.erase(unique(ALL(sugar)),sugar.end());

  //double cnct_max = -1.0;
  double cnct_max = 0.0;
  int xm, ym;
  for (auto x : water) {
    for (auto y : sugar) {
      //DEBUG(x);
      //DEBUG(y);
      if (x == 0 && y == 0) continue;
      if (y*100 > x*e || x+y > f) {
        continue;
      }
      else {
        double cnct = 100*(double)y/(x+y);
        //DEBUG(cnct);
        if (cnct_max < cnct + eps) {
        //if (cnct_max < cnct) {
          cnct_max = cnct;
          xm = x;
          ym = y;
        }
      }
    }
  }

  cout << xm+ym << " " << ym << endl;
}

Measured memory_bytes: 1400