akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)

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

int main()
{
    ll A, B; cin >> A >> B;
    ll C = gcd(A, B);

    int n = 2;
    bool flag;
    
    ll ans = 1;
    while (n <= 1000000)
    {
        flag = true;
        while (C % n == 0)
        {   
            if (flag)
            {
                flag = false;
                ans++;
            }
            
            C /= n;
        }
        n++;
    }
    
    if (C != 1) ans++;
   
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
 
#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
 
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
 
#define FOREACH(x,a) for(auto& (x) : (a) )
 
#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])
 
#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl
 
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl
 
#define ALL(obj) (obj).begin(),(obj).end()
 
#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
 
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision; // cpp_int
 
#define P pair<int,int>
#define V vector<ll>
#define M map<int,int>
#define S set<int>
#define L list<int>
 
#define pb(a) push_back(a)
#define mp make_pair


int main(){
  CIN(n,h);
  V a(n);V b(n);
  VECIN2(a,b);
  priority_queue<P> que;
  REP(i,n)que.push(mp(a[i],0));
  REP(i,n)que.push(mp(b[i],1));
  ll ans=0;
  while(h>0){
    if(que.top().second==1){
      h-=que.top().first;
      ans++;
    }else{
      ans+=(h+que.top().first-1)/que.top().first;
      h=0;
    }
    que.pop();
  }
  COUT(ans);
  return 0;
}


Measured memory_bytes: 3956
N, x = map(int, input().split())
if x == 2 and N == 2:
	print("Yes")
	print(1)
	print(2)
	print(3)
elif x == 1 or x >= 2*N-1:
	print("No")
else:
	print("Yes")
	if x == 2:
		for i in range(5,N+2):
			print(i)
		p = [4,2,1,3]
		for i in p:
			print(i)
		for i in range(N+2,2*N):
			print(i)
	else:
		a = [i for i in range(1,2*N)]
		for i in range(N-3):
			print(a[x-4-i])
		p = [x-1,x,x+1,x-2]
		for i in p:
			print(i)
		for i in range(N-2):
			print(a[(x+1+i)%(2*N-1)])



Measured memory_bytes: 12568
#include<bits/stdc++.h>
#define pii pair<int,int> 
#define mp make_pair
using namespace std;
const int mxn=2e4+4;
int X[mxn],n,cnt;
int ord[mxn],scc[mxn],mid;
set<pii>s;
bool used[mxn];
inline void dfs(int a,int x){
	int tx,po;
	if(a<=n)tx=X[a+n],po=a+n;
	else tx=X[a-n],po=a-n;
	used[a]=1;
	s.erase(mp(tx,po));
	for(;s.size();){
		set<pii>::iterator it=s.lower_bound(mp(x-mid+1,-1));
		if(it==s.end() or it->first>x+mid-1)break;
		int y=it->second;
		if(y==a){
			it++;
			if(it==s.end() or it->first>x+mid-1)break;
			y=it->second;
		}
		if(y>n)dfs(y-n,X[y-n]);
		else dfs(y+n,X[y+n]);
	}
	ord[++cnt]=a;
}
inline void dfs2(int a,int x){
	scc[a]=cnt;
	s.erase(mp(x,a));
	int tx;
	if(a<=n)tx=X[a+n];
	else tx=X[a-n];
	for(;s.size();){
		set<pii>::iterator it2=s.lower_bound(mp(tx-mid+1,-1));
		if(it2==s.end() or it2->first>tx+mid-1)break;
		int y=it2->second;
		if(y==a-n or y==a+n){
			it2++;
			if(it2==s.end() or it2->first>tx+mid-1)break;
			y=it2->second;
		}
		dfs2(y,X[y]);
	}
}
inline bool check(int md){
	mid=md,s.clear();
	memset(used,0,sizeof(used));
	memset(scc,0,sizeof(scc));
	for(int i=1;i<=n*2;++i)s.insert(mp(X[i],i));
	cnt=0;
	for(int i=1;i<=n*2;++i)if(!used[i])dfs(i,X[i]);
	cnt=0;
	for(int i=1;i<=n*2;++i)s.insert(mp(X[i],i));
	for(int i=n*2;i;--i){
		if(!scc[ord[i]]){
			++cnt;
			dfs2(ord[i],X[ord[i]]);
		}
	}
	for(int i=1;i<=n;++i)if(scc[i]==scc[i+n])return 0;
	return 1;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;++i){
		int x,y;cin>>x>>y;
		X[i]=x,X[i+n]=y;
	}
	int lo=0,hi=1000000009,md;
	for(;lo<hi-1;){
		int md=lo+hi>>1;
		if(check(md))lo=md;
		else hi=md; 
	}
	cout<<lo<<endl;
	return 0;
}

Measured memory_bytes: 2816
import java.util.*;

public class Main {
	public static void main(String[] args) {  
  		Scanner sc = new Scanner(System.in);
  		int a = sc.nextInt();
      	int b = sc.nextInt();
      	int c = sc.nextInt();
      	int d = sc.nextInt();
      	
  		if(Math.abs(a - b) <= d && Math.abs(b - c) <= d || Math.abs(a - c) <= d) {
        	System.out.println("Yes"); 
        } else {
        	System.out.println("No");  
        }
    }
}

Measured memory_bytes: 21588
#include <iostream>
#include <stack>
using namespace std;
int main()
{
	long long n;
	cin >> n;
	if (n <= 26)
	{
		cout << char(n + 'a' - 1) << endl;
		return 0;
	}
	stack<int> st;
	for (long long i = 1; n > 0; i *= 26)
	{
		n--;
		st.push(n % 26);
		n /= 26;
	}
	while (!st.empty())
	{
		cout << char(st.top() + 'a');
		st.pop();
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3568
#include <iostream>
#include <vector>
#include <set>
using namespace std;
int main(){
	for(int w,h;cin>>h>>w;){
		if(w==0&&h==0)break;
		vector<string> v;
		set<int> visited;
		for(int i=0;i<h;++i){
			string s;
			cin>>s;
			v.push_back(s);
		}
		for(int x=0,y=0;;){
			if(visited.find(y*w+x)!=visited.end()){
				cout<<"LOOP\n";
				break;
			}
			visited.insert(y*w+x);
			if(v[y][x]=='.'){
				cout<<x<<" "<<y<<"\n";
				break;
			}else if(v[y][x]=='>')++x;
			else if(v[y][x]=='<')--x;
			else if(v[y][x]=='v')++y;
			else if(v[y][x]=='^')--y;
		}
	}
}

Measured memory_bytes: 0
n = input()
l = len(n)
n = int(n)
data = [['0']*l for i in range(4**l)]
for i in range(4**l):
  k = i
  for j in range(l):
    a = k//4**(l-1-j)
    if a==1:
      data[i][j]='3'
    if a==2:
      data[i][j]='5'
    if a==3:
      data[i][j]='7'
    k%=4**(l-1-j)
ans = 0
for u in data:
  num = int(''.join(u))
  if num<=n:
    num = str(num)
    if '0' not in num and '3' in num and '5' in num and '7' in num:
      ans += 1
print(ans)

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

#define ll long long
#define pb push_back
#define vi vector<int>
#define sz(a) (int((a).size()))
#define mp make_pair
#define f first
#define s second
#define pii pair<int, int>

using namespace std;

const int N = 100100;
int n, x;
int a[N];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n >> x;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	int ans = 0;
	sort(a + 1, a + n + 1);
	for (int i = 1; i <= n; i++) {
		if (i == n) {
			if (a[i] == x) ans++;
		} else {
			if (a[i] <= x) {
				ans++;
				x -= a[i];
			}
		}	
	}
	
	cout << ans << "\n";
	
	return 0;
}

Measured memory_bytes: 256
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use std::cmp::*;
use std::collections::*;
use std::mem::*;

fn main() {
    let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    assert_eq!(!0usize, std::usize::MAX); //🙊
    assert!(0 == 0); //😇

    let (n, m) = (io.read::<usize>(), io.read::<usize>());
    let ab = (0..n)
        .map(|_| (io.read::<i64>(), io.read::<i64>()))
        .collect::<Vec<_>>();
    let cd = (0..m)
        .map(|_| (io.read::<i64>(), io.read::<i64>()))
        .collect::<Vec<_>>();

    for &(a, b) in &ab {
        let mut mini = INF;
        let mut minii = 0;
        for (i, &(c, d)) in cd.iter().enumerate() {
            if (a - c).abs() + (b - d).abs() < mini {
                mini = (a - c).abs() + (b - d).abs();
                minii = i + 1;
            }
        }
        io.writeln(minii);
    }
}

static MX: usize = 1010101;
static MOD: i64 = 1000000007;
static INF: i64 = std::i64::MAX >> 1;
// IO
use std::io::*;
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn chari(&mut self) -> Vec<i64> {
        self.chars()
            .iter()
            .map(|&c| (c as u8 - b'0') as i64)
            .collect::<Vec<i64>>()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
    fn debug3<S: std::fmt::Debug, T: std::fmt::Debug, U: std::fmt::Debug>(
        &mut self,
        val1: S,
        val2: T,
        val3: U,
    ) {
        writeln!(
            self.Error,
            "(debug3) {:?} -> {:?} -> {:?}",
            val1, val2, val3
        );
    }
}


Measured memory_bytes: 4352
# ソート

n = gets.to_i
a = gets.chomp.split(' ').map(&:to_i)

alice = 0
bob = 0

a.sort!.reverse!

for i in 0..n-1
    if i.even?
        alice += a[i]
    else
        bob += a[i]
    end
end

p alice - bob

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

#define lli long long int
#define endl "\n"
#define debug(n) cout<<n<<endl
#define debug2(a, b) cout<<a<<" "<<b<<endl;
#define forn(i, in, fin) for(int i = in; i<fin; i++)
#define all(v) v.begin(), v.end()
#define fastIO(); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;

lli n;
vector<lli> cola;
lli dp[3010][3010][2];


lli f(lli l, lli r, lli estado) //estado 0-> max, 1-> min
{
    //debug2(l,r);
    if(l>r) return 0;

    if(dp[l][r][estado] != -1) return dp[l][r][estado];

    lli uno = cola[l] - f(l+1, r, !estado) ;
    lli dos = cola[r] - f(l, r-1, !estado) ;
    //return max(uno, dos);
    return dp[l][r][estado] = max(uno,dos);
    
}

int main()
{
    fastIO();
    memset(dp, -1, sizeof(dp));
    cin>>n;
    cola.resize(n);
    for(auto &x: cola)
    {
        cin>>x;
    }
    cout<<f(0,n-1,0)<<endl;

    return 0;
}


Measured memory_bytes: 142080
#include<bits/stdc++.h>
#define INF (1e17)
#define N 100005
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

ll n,m,x,h[N];
vector<P> G[N];
priority_queue<P,vector<P>,greater<P> > q;
ll d[N];

ll dijkstra(){

  for(int i=0;i<n;i++)d[i]=INF;
  q.push(P(0,0));
  d[0]=0;
  
  while(!q.empty()){
    P t=q.top(); q.pop();
    ll cost=t.first,node=t.second;

    if(node==n-1)return cost+max(h[n-1]-(x-cost),0LL);
    if(d[node]<cost)continue;
    
    for(int i=0;i<G[node].size();i++){
      ll nnode=G[node][i].first;
      ll ncost=cost+G[node][i].second;
      
      if(x-ncost>=h[nnode])
	ncost+=x-ncost-h[nnode];
      if(d[nnode]>ncost){
	d[nnode]=ncost;
	q.push(P(ncost,nnode));
      }
    }
  }
  
  return INF;
}

int main(){
  
  cin>>n>>m>>x;
  
  for(int i=0;i<n;i++)scanf("%lld",&h[i]);

  ll a,b,c;
  for(int i=0;i<m;i++){
    scanf("%lld%lld%lld",&a,&b,&c);
    a--,b--;
    if(h[a]-c>=0)G[a].push_back(P(b,c));
    if(h[b]-c>=0)G[b].push_back(P(a,c));
  }

  ll ans=dijkstra();
  if(ans==INF)cout<<-1<<endl;
  else cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 22560
#include <bits/stdc++.h>
 
using namespace std;
 
#define BOOST        std::ios::sync_with_stdio(false);  cin.tie(NULL); cout.tie(NULL);
#define sp           <<" "<<
#define ll           long long
#define ld           long double
#define For(i,k,n)   for(ll i=k;i<n;i++)
#define Ford(i,n)    for(ll i=n-1;i>=0;i--)
#define AZI(i,x)     for(auto i=x.begin();i!=x.end();i++)
#define AZ(x)        x.begin(),x.end()
#define P(x,y)       pair < x,y >
#define V(x)         vector < x >
#define fi           first
#define se           second
#define pb           push_back
#define mp           make_pair
#define PI           3.14159265358979323846264338327950288419716939937510
 
const ll mod=1e9+7,N=1e6+5;

int h,w;
ll dp[1005][1005]={};
char grid[1005][1005]={};

int main() 
{ 
    BOOST

    cin>>h>>w;

    // memset(dp,-1,sizeof(dp));

    for(int i=1; i<=h; i++)
        for(int j=1; j<=w; j++)
            cin>>grid[i][j];

    dp[h][w] = 1;

    for(int i=h; i>0; i--)
    {
        for(int j=w; j>0; j--)
        {
            if(i==h && j==w)
                continue;

            else if(grid[i][j]=='#')
                dp[i][j] = 0;

            else
                dp[i][j] = (dp[i+1][j]%mod + dp[i][j+1]%mod)%mod;
        }
    }
    
    cout<<dp[1][1]<<"\n";
    
    return 0; 
} 

Measured memory_bytes: 9088
a,b=map(int,input().split())


c=a/0.08
if c==c//1:
    c=int(c)
else:
    c=int(c)+1
d=(a+1)/0.08
if d==d//1:
    d=int(d)
else:
    d=int(d)+1
x=set([i for i in range(c,d)])

e=int(b/0.1)
f=int((b+1)/0.1)
y=set([i for i in range(e,f)])

l=x&y

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


Measured memory_bytes: 38384
#include<iostream>
#include<string>
#include<vector>
#include<unordered_map>
#include<algorithm>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)

int main() {
	int n, d;
	cin >> n >> d;
	cout << (n + (d * 2 + 1) - 1) / (d * 2 + 1) << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main {
	public static void main(String[] args){
		Scanner cin = new Scanner(System.in);
		int a, b, c;
		a = cin.nextInt();
		b = cin.nextInt();
		c = cin.nextInt();
		
		int res = serch_divisor_number(a, b, c);
		
		System.out.println(res);
	}
	private static int serch_divisor_number(int a, int b, int c){
		int count = 0;
		for (int i = a; i <= b; i++){
			if (c % i == 0){
				count++;
			}
		}
		return (count);
	}
}

Measured memory_bytes: 26376
/**
 *    Author:   Jay Sabale
 *	       
**/

#include<bits/stdc++.h>

using namespace std;
 
// Competetive Template:
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;
typedef vector <lli> vl;
typedef vector <string> vs;
typedef vector < pair <long, long> > vll;

// Debugging :
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ba  back
#define si size()
#define be begin()
#define en end()
#define le length()
#define mp make_pair 
#define mt make_tuple
#define fi first
#define se second
#define gcd __gcd
#define maxe *max_element
#define mine *min_element
#define deb debug
 
#define forz(i,n) for(lli i=0; i<n; i++)
#define rep(i,k,n) for (lli i = k; i < n; i++)
#define deci(n)  fixed<<setprecision(n)
#define high(n) __builtin_popcount(n)
#define parity(n) __builtin_parity(n)
#define ctz(n)  __builtin_ctz(n)
#define mod 1000000007
#define mod2 998244353
#define kira ios::sync_with_stdio(0), cin.tie(0),cout.tie(0)

// Printing Data :
#define pvec(v) forz(i,v.si) cout<<v[i]<<" "; cout<<endl;
#define parr(arr, n) forz(i,n) cout<<arr[i]<<" "; cout<<endl;
#define p1(i) cout<<i<<endl;
#define p2(i, j) cout<<i<<" "<<j<<endl;
#define p3(i, j, k) cout<<i<<" "<<j<<" "<<k<<endl;
#define p4(i, j, k, l) cout<<i<<" "<<j<<" "<<k<<" "<<l<<endl;

typedef pair <lli,lli> pll;
 
// CODE BEGINS :

int main()
{
    kira;

    lli R; cin>>R;

    cout<<deci(10)<<(2*3.141592653589793238*R)<<endl;

    return 0;
}




















































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

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

	if (n % 2 == 0) {
		ans = n / 2;
	}
	else {
		ans = n / 2 + 1;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

  
N,M=map(int,input().split())
uf = UnionFind(N+1)

for i in range(M):
    a,b=map(int,input().split())
    uf.union(a,b)

ans=0

for j in range(N):
    ans=max(ans,uf.size(j))

print(ans)

Measured memory_bytes: 14540
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
// mt19937 gen_rand_int(chrono::steady_clock::now().time_since_epoch().count());
// mt19937_64 gen_rand_ll(chrono::steady_clock::now().time_since_epoch().count());
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
long long power(long long a, long long b,long long m) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a %m;
        a = a * a %m;
        b >>= 1;
    }
    return res;
}
 
 
signed main()
{
 
ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   
 
#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif      
    
    string a;
    cin>>a;
    int n=a.length();
    if(n<4)
    {
        cout<<"No\n";
    }
    else
    {
        if(a.substr(0,4)=="YAKI")
            cout<<"Yes";
        else
            cout<<"No";
    }
    
 
} 

Measured memory_bytes: 3584
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<vector>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define ALL(C)     (C).begin(),(C).end()
#define FOR(it,o)  for(__typeof((o).begin()) it =(o).begin();it != (o).end();it++)
#define pb         push_back
#define mp         make_pair


typedef unsigned long long           ull;
typedef pair<string,string> pss;
typedef vector<pss>         vpss;

const ull tmp = 10007;

ull calchash(string &in){
  ull ret= 0;
  rep(i,in.size()){
    ret=ret*tmp + in[i];
  }
  return ret;
}


bool isok[200][200];
void ed1(vector<string>&in,set<ull> *S){
  rep(i,in.size()){
    REP(j,i+1,in.size()){
      if (S[j].find(calchash(in[i])) != S[j].end()){
	isok[i][j] = true;
      }
    }    
  }
}
	 
void ed2(vector<string> &in,set<ull> *S){
  rep(i,in.size()){
    REP(j,i+1,in.size()){
      if (isok[i][j])continue;
      FOR(it,S[i]){
	if (S[j].find(*it) != S[j].end()){
	  isok[i][j]=true;
	  break;
	}
      }
    }
  }
}

void del_string(string &in,set<ull>&S){
  rep(i,in.size()){
    string tmp = in;
    tmp.erase(tmp.begin()+i);
    S.insert(calchash(tmp));
  }
}

void insert_string(string &in,set<ull>&S){
  rep(i,in.size()+1){
    rep(j,26){
      string tmp=in.substr(0,i);
      tmp+=string(1,'a'+j);
      tmp+=in.substr(i);
      S.insert(calchash(tmp));
    }
  }
}

void replace_string(string &in,set<ull>&S){
  rep(i,in.size()){
    char tmp = in[i];
    rep(j,26){
      in[i]='a'+j;
      S.insert(calchash(in));
    }
    in[i]=tmp;
  }
}

void swap_string(string&in,set<ull>&S){
  rep(i,(int)in.size()-1){
    swap(in[i],in[i+1]);
    S.insert(calchash(in));
    swap(in[i],in[i+1]);
  }
}

void make_string(vector<string>& in,set<ull> *S){
  rep(i,in.size()){
    del_string(in[i],S[i]);
    insert_string(in[i],S[i]);
    replace_string(in[i],S[i]);
    swap_string(in[i],S[i]);
  }
}

void solve(vector<string>in,set<ull>*S,int d){
  int n=in.size();
  make_string(in,S);
  ed1(in,S);
  if (d==2)ed2(in,S);
  int cnt=0;
  rep(i,n){
    rep(j,n)if (isok[i][j])cnt++,cout<<in[i]<<","<<in[j]<<endl;
  }
  cout << cnt << endl;
}

void test(){
  string in="test";
  set<ull> S;
  insert_string(in,S);
}

main(){
  //test();
  int n,d;
  while(cin>>n>>d && n){
    vector<string> in;
    rep(i,n)rep(j,n)isok[i][j]=false;
    set<ull> S[n];
    rep(i,n){
      string tmp;
      cin>>tmp;
      in.pb(tmp);
    }
    sort(ALL(in));
    rep(i,in.size())S[i].insert(calchash(in[i]));
    solve(in,S,d);
  }
}

Measured memory_bytes: 5572
//#pragma GCC optimize(3,"Ofast","inline")
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <bitset>
#include <set>
#include <utility>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define inf 0x3f3f3f3f
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define lep(i,l,r) for(int i=l;i>=r;i--)
#define ms(arr) memset(arr,0,sizeof(arr))
//priority_queue<int,vector<int> ,greater<int> >q;
const int maxn = (int)1e5 + 5;
const ll mod = 1e9+7;
bool is_prime[1000100];
int prime[1000100];
int cnt=0;
int num[1001000];
int arr[1001000];
void get_prime() {	
	is_prime[0]=true;
	is_prime[1]=true;
	for(int i=2;i<=100000;i++) {
		if(is_prime[i]==false) {
			int j=i+i;
			prime[++cnt]=i;
			while(j<=100000) {
				is_prime[j]=true;
				j+=i;
			}
		}
	}
}
int main() 
{
    /*#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    #endif
    //freopen("out.txt", "w", stdout);
    ios::sync_with_stdio(0),cin.tie(0);*/
    int l,r;
    get_prime();
    cin>>l>>r;
    for(int i=l;i<=r;i++) arr[i-l+1]=i;
    int n=r-l+1;
	for(int i=1;i<=cnt;i++) {
		ll nape=prime[i];
		while(nape<=r) {
			ll t=l/nape;
			if(t*nape!=l) t++;
			while(t*nape<=r) {
				num[t*nape-l+1]++;
				arr[t*nape-l+1]=arr[t*nape-l+1]/prime[i];
				t++;
			}
			nape=nape*(ll)prime[i];
		}
	}
	for(int i=1;i<=n;i++) {
		if(arr[i]>1) {
			num[i]++;
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++) {
		if(is_prime[num[i]]==false) {
			ans++;
		}
	}
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 11076
N,K = list(map(int,input().split()))
S = list(input())

S_zero={}
S_zero_group = 0
s_befor = ''
for s_idx,s in enumerate(S):
    if s != s_befor:
        if s == '0':
            S_zero_group += 1
            S_zero[S_zero_group] = [s_idx-1]
        elif s == '1':
            if S_zero_group in S_zero.keys():
                S_zero[S_zero_group].append(s_idx)
            
    s_befor = s
    
if S[-1] == '0':
    S_zero[S_zero_group].append(N)
    
if S_zero_group <= K:
    ans_ = N
else:   
    ans_=0
    for g_s in range(1,S_zero_group-K+2):
        g_e = g_s + K - 1
#         print('====',g_s,g_e)
        s = 0
        e = N-1

        if g_s != 1:
            s = S_zero[g_s-1][1]
        if g_e != S_zero_group:
            e = S_zero[g_e+1][0]

        ans= e-s+1
        if ans > ans_:
            ans_=ans

print(ans_)

Measured memory_bytes: 22724
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
#define lint long long
#define pii pair<int, int>
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) FOR(i, 0, n)
#define SZ(v) ((int)v.size())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define FILLINF(a) memset(a, 0x3f, sizeof(a))
#define POW(n) (1LL << (n))
#define POPCNT(n) (__builtin_popcount(n))
#define IN(i, a, b) ((a) <= (i) && (i) <= (b))
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a > b) { a = b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a < b) { a = b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(begin(a), end(a)); }
template <typename T> inline void REV(T& a) { reverse(begin(a), end(a)); }
template <typename T> inline void UNI(T& a) { sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end()); }
template <typename S, typename T> inline T LB(S& v, T a) { return *lower_bound(begin(v), end(v), a); }
template <typename S, typename T> inline int LBP(S& v, T a) { return lower_bound(begin(v), end(v), a) - begin(v); }
template <typename S, typename T> inline T UB(S& v, T a) { return *upper_bound(begin(v), end(v), a); }
template <typename S, typename T> inline int UBP(S& v, T a) { return upper_bound(begin(v), end(v), a) - begin(v); }
template <typename S, typename T> ostream& operator << (ostream& os, const pair<S, T>& p) { os << p.first << " " << p.second; return os; }
template <typename S, typename T> istream& operator >> (istream& is, pair<S, T>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator << (ostream& os, const vector<T>& v) { for (int i = 0; i < v.size(); ++i) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator >> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e, v); }
const lint MOD = 1000000007;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const double PI = 3.14159265358979323846;
const double EPS = 1e-10;



void _main() {
    int A, B, K;
    cin >> A >> B >> K;
    if (A >= K) {
        cout << A - K << " " << B << endl;
    } else {
        int rem = K - A;
        cout << 0 << " " << max(0LL, B - rem) << endl;
    }
}

signed main(signed argc, char **argv) {
    if (argc > 1) {
        if (strchr(argv[1], 'i')) freopen("input.txt", "r", stdin);
        if (strchr(argv[1], 'o')) freopen("output.txt", "w", stdout);
    }
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 256
S = input()
n = int(S, 2)
L = len(S)

S2 = ""
for _ in range(L//2+1):
    S2+= "10"
S1 = S2[:L]
S0 = S2[1:L+1]
n1 = int(S1, 2)
n0 = int(S0, 2)

ans1 = str(bin(n^n1)).count("1")
ans2 = str(bin(n^n0)).count("1")

print(min(ans1, ans2))

Measured memory_bytes: 3572
#include <stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s)
{
	int v;
	istringstream sin(s);
	sin >> v;
	return v;
}
template <class T>
inline string toString(T x)
{
	ostringstream sout;
	sout << x;
	return sout.str();
}

//math
//-------------------------------------------
template <class T>
inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

//repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0, sizeof(a))

//debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
					  << " " << __FILE__ << endl;

int main(void)
{
	int cnt = 0;
	int n = 0;
	VI a;
	cin >> n;
	REP(i,n){
		int v = 0;
		cin >> v;
		if(i % 2 ==0){
			a.push_back(v);
		}
		else{
			a.insert(a.begin(), v);
		}
	}
	if(n % 2 == 1)
		reverse(a.begin(), a.end());
	REP(i, n)
	{
		cout << a[i];
		if(i < n){
			cout << " ";
		}
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3188
fun main(args: Array<String>) {
    val (a, b, h, m) = readLine()!!.split(" ").map { it.toLong() }
//    var rad = 2 * Math.PI * Math.abs(h / 12.0 + m / (12.0 * 60.0) - m / 60.0)
    var rad = Math.PI * Math.abs(60 * h - 11 * m) / 360.0
    if (rad > Math.PI) {
        rad = 2 * Math.PI - rad
    }
    System.err.println(rad)
    val a_square = a * a + b * b - 2 * a * b * Math.cos(rad)
    println(Math.sqrt(a_square))
}

Measured memory_bytes: 36596
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    double dp[n+1][n+1];
    double prob[n+1],ans=0;
    prob[0]=0;
    for(int i=1;i<=n;i++)
    {
        cin>>prob[i];
    }
    memset(dp,0,sizeof dp);
    //dp[i][j]--> getting j heads till the ith toss
    dp[0][0]=0;
    dp[1][0]=(1.0-prob[1]);     // getting 0 head int the first throe
    for(int i=2;i<=n;i++)
    {
        dp[i][0]=dp[i-1][0]*(1-prob[i]);
    }
    dp[1][1]=prob[1];      // getting 1 head int the 1st toss is prob of 1
    
    for(int i=2;i<=n;i++)
    {
        dp[i][i]=dp[i-1][i-1]*prob[i];
    }
    //cout<<fixed<<setprecision(2)<<dp[3][3]<<endl;
    // now for the general one in the i th toss there are two possibilities head or tail if there is head then 
    // there will be j-1 heads so total will be j   or j heads till the i-1 th toll so now tail and then total j heads
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<i;j++)
        {
            dp[i][j]=prob[i]*dp[i-1][j-1]+(1-prob[i])*dp[i-1][j];
        }
    }
    for(int i=n/2+1;i<=n;i++)
    {
        ans+=dp[n][i];
    }
    cout<<fixed<<setprecision(10)<<ans;
    return 0;
}

Measured memory_bytes: 74108
// J'aime
// Chemise Blanche

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  int n, m;
  cin >> n >> m;
  cout << (n - 1) * (m - 1) << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3604
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def solve():
    n, k = nm()
    a = nl()
    for i in range(n-k):
        if a[i+k] > a[i]:
            print('Yes')
        else:
            print('No')
    return

solve()


Measured memory_bytes: 31300
#include <algorithm>
#include <cmath>
#include <iostream>

// あまり大きな数字を入れると桁溢れする
template <typename T>
T comb(T n, T r) {
  // 組み合わせ計算時のかぶっている部分を取り除く
  r = std::min(n - r, r);
  T result = 1;
  T div = 1;
  for (T i = 1; i <= r; ++i) {
    result = (result * (n - i + 1));
    // result = result / i;
    div = div * i;
  }
  return result / div;
}

// 値が大きくなる時の対処用のクラス
template <typename T, T MOD>
class mod_int {
 private:
  typedef mod_int<T, MOD> mint;
  T inverse(T x) {
    T pow = MOD - 2;
    T result = 1;
    while (pow) {
      if (pow & 1) result = result * x % MOD;
      pow >>= 1;
      x = x * x % MOD;
    }
    return result;
  }

 public:
  T val;
  // コンストラクタ
  mod_int() : val(0) {}
  mod_int(const mint &o) : val(o.val % MOD) {}
  mod_int(const T &o) : val(o % MOD) {}

  mint &operator+=(const mint &o) {
    val = (val + o.val) % MOD;
    return *this;
  }
  mint &operator-=(const mint &o) {
    val = (val + MOD - o.val) % MOD;
    return *this;
  }
  mint &operator*=(const mint &o) {
    val = (val * o.val) % MOD;
    return *this;
  }
  mint &operator/=(const mint &o) {
    val = (val * inverse(o.val)) % MOD;
    return *this;
  }

  mint &operator++() {
    val = (++val) % MOD;
    return *this;
  }

  mint &operator--() {
    val = (--val) % MOD;
    return *this;
  }

  mint operator+(const mint &o) const { return mint(*this) += o; }
  mint operator-(const mint &o) const { return mint(*this) -= o; }
  mint operator*(const mint &o) const { return mint(*this) *= o; }
  mint operator/(const mint &o) const { return mint(*this) /= o; }

  void operator=(const mint &o) { this->val = o.val; }
  void operator=(const int i) { this->val = i; }
  void operator=(const T i) { this->val = i; }

  bool operator<(const mint &o) const { return val < o.val; }
  bool operator<=(const mint &o) const { return val <= o.val; }
  bool operator==(const mint &o) const { return val == o.val; }
};

// ioのオーバーライド
template <typename T, T MOD>
std::istream &operator>>(std::istream &i, mod_int<T, MOD> &o) {
  i >> o.val;
  return i;
}
template <typename T, T MOD>
std::ostream &operator<<(std::ostream &i, const mod_int<T, MOD> &o) {
  i << o.val;
  return i;
}

// 使うクラスのおまじない
typedef mod_int<uint64_t, 1000 * 1000 * 1000 + 7> muint64_t;

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

  muint64_t xsum = 0;
  muint64_t M2 = M * M;
  for (muint64_t xdiff = 1; xdiff <= N; ++xdiff) {
    xsum = xsum + xdiff * M2 * (N - xdiff);
  }

  muint64_t ysum = 0;
  muint64_t N2 = N * N;
  for (muint64_t ydiff = 1; ydiff <= M; ++ydiff) {
    ysum = ysum + ydiff * N2 * (M - ydiff);
  }

  // uint64_t result = (xsum + ysum) * p / k % (1000 * 1000 * 1000 + 7);
  muint64_t result = (xsum + ysum) * comb(N * M - 2, K - 2);
  std::cout << result << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <cassert>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const ll MOD = 1e9+7;
const double EPS = 1e-9;


int main(int argc, const char * argv[]) {
  int N; cin >> N;
  vector<int> H(N);
  for(int i=0; i<N; i++)
    cin >> H[i];
  int ans, tmp;
  ans = 0;
  tmp = 0;
  for(int i=1; i<N; i++){
    if(H[i-1] >= H[i]) tmp++;
    else {
      ans = max(ans, tmp);
      tmp = 0;
    }
  }
  ans = max(ans, tmp);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

int Q, l, r;
std::vector<bool> flag(112345);
std::vector<int> imos(112345);

bool check(int n) {
	for (int i = 2; i <= sqrt(n); ++i) {
		if (n % i == 0) {
			return false;
		}
	}
	return true;
}

int main() {
	for (int i = 2; i <= 100000; ++i) {
		if (check(i)) {
			flag[i] = true;
		}
	}
	for (int i = 1; i <= 100000; i += 2) {
		if (flag[i] && flag[(i + 1) / 2]) {
			++imos[i];
		}
	}
	rep(i,100000)
	{
		imos[i + 1] += imos[i];
	}
	in>>Q;
	rep(i,Q)
	{
		in>>l>>r;
		out<<imos[r]-imos[l-1]<<std::endl;
	}
	return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define hii cout << "hii" << endl
#define int ll
#define endl '\n'
#define all(s) s.begin(), s.end()
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; } 
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) 
	{ 
		cerr << name << " : " << arg1 << endl;
	}
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) 
    {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#endif
 
 
const int N = 3e5 + 5;
const int MAXN = 1e5 + 5;
const int M = 1e5;
const int mod = 1e9 + 7;
const int MOD = 1e9 + 7;
const ll INF = 1e15;
const int LG = 21;


int arr[120][120];
int n, m, x;

void solve() 
{
	cin >> n >> m >> x;
	for(int i = 0; i < n; i++)
	{
		for(int j = 1; j <= m + 1; j++)
		{
			cin >> arr[i][j];
		}
	}
	int ret = 1e18;
	for(int mask = 0; mask < (1LL << n); mask++)
	{
		int temp = 0;
		vector<int> skills(m + 1, 0);
		for(int i = 0; i < n; i++)
		{
			if((mask >> i) & 1)
			{
				temp += arr[i][1];
				for(int j = 2; j <= m + 1; j++)
				{
					skills[j - 1] += arr[i][j];
				}
			}
		}
		for(int i = 1; i <= m; i++)
		{
			if(skills[i] < x)
			{
				temp = 1e18;
				break;
			}
		}
		ret = min(ret, temp);
	}
	if(ret == 1e18)
	{
		cout << -1 << endl;
		return;
	}
	cout << ret << endl;
}
 
 
int32_t main() 
{	
    ios_base:: sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	    int t = 1;
	    // cin >> t;
	while(t--)solve();
	return 0;
}

Measured memory_bytes: 3668
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

int main() {
  ll N;

  cin >> N;

  ll cs[N];
  ll ss[N];
  ll fs[N];
  for (int i = 1; i <= N - 1; i++) {
    cin >> cs[i] >> ss[i] >> fs[i];
  }

  ll ans[N + 1];
  ans[N] = 0;
  for (int i = 1; i <= N - 1; i++) {
    ll ans_i = ss[i] + cs[i];
    for (int j = i + 1; j <= N - 1; j++) {
      if((ans_i - ss[j]) >= 0){
        if((ans_i - ss[j]) % fs[j] != 0)
          ans_i += fs[j] - ((ans_i - ss[j]) % fs[j]);
      } else {
        ans_i += ss[j] - ans_i;
      }
      ans_i += cs[j];
    }
    ans[i] = ans_i;
  }

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

  return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

const int MAX_N = 112345;

int main2() {
  int N = nextInt();
  int K = nextInt();

  vector<vector<int>> v(N);
  REP(i, N) {
    int t = nextInt() - 1;
    int d = nextInt();
    v[t].push_back(d);
  }
  REP(t, N) {
    sort(ALL(v[t]));
    reverse(ALL(v[t]));
  }

  typedef pair<int,int> P;
  vector<P> ps;
  REP(t, N) {
    REP(i, v[t].size()) {
      ps.push_back( {v[t][i], i == 0} );
    }
  }
  sort(ALL(ps), [](const P&a, const P&b) -> bool {
    return a.first > b.first;
  });
  
  ll X = 0;
  ll Y = 0;
  REP(i, K) {
    X += ps[i].first;
    Y += ps[i].second;
  }
  ll ans = X + Y * Y;

  priority_queue<ll> q0;
  priority_queue<ll> q1;
  for (int i = 0; i < K; i++) { if (ps[i].second == 0) q0.push(-ps[i].first); }
  for (int i = K; i < N; i++) { if (ps[i].second == 1) q1.push(ps[i].first); }

  while (q0.size() > 0 && q1.size() > 0) {
    ll v0 = -q0.top(); q0.pop();
    ll v1 = q1.top(); q1.pop();
    X -= v0;
    X += v1;
    Y++;
    chmax(ans, X + Y * Y);
  }

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

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


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

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  ll ans = 0;
  if(a == 0) ans = 0;
  else if(b == 0) ans = n;
  else if(a + b >= n) {
    if(a >= n) ans = n;
    else ans = a;
  }
  else if(a + b < n) {
    ll rema = n % (a + b);
    ll div = n / (a + b);
    if(a > rema) ans = (div*a) + rema;
    else ans = (div*a) + a;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3548
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0;i<n;i++)
using namespace std;
int main(){
  int N; cin >> N;
  vector<int>A(N);
  rep(i,N) cin >> A[i];
  sort(A.begin(), A.end());
  A.erase(unique(A.begin(), A.end()), A.end());
  if (A.size() == N) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 1024
package main

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

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

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

func readLineNum(bf *bufio.Reader) int {
	line, _ := bf.ReadString('\n')
	line = strings.Trim(line, "\n")
	N, _ := strconv.Atoi(line)
	return N
}

func readLineNums(bf *bufio.Reader) []int {
	line, _ := bf.ReadString('\n')
	line = strings.Trim(line, "\n")
	fields := strings.Split(line, " ")
	nums := []int{}
	for _, field := range fields {
		num, _ := strconv.Atoi(field)
		nums = append(nums, num)
	}
	return nums
}

func readLineFloats(bf *bufio.Reader) []float64 {
	line, _ := bf.ReadString('\n')
	line = strings.Trim(line, "\n")
	fields := strings.Split(line, " ")
	fs := []float64{}
	for _, field := range fields {
		f , _ := strconv.ParseFloat(field, 64)
		fs = append(fs, f)
	}
	return fs
}

func readLineStrs(bf *bufio.Reader) []string {
	line, _ := bf.ReadString('\n')
	line = strings.Trim(line, "\n")
	return strings.Split(line, " ")
}

func main() {
	bf := bufio.NewReader(os.Stdin)
    N := readLineNums(bf)[0]
    A := readLineNums(bf)

	/*
		定义:
			dp[i][j]: 表示i~j之间的差值
		初始值:
			dp[i][i]=A[i]
		转移方程:
			dp[i][j]=max(dp[i+1][j-1]+A[i]-A[j], dp[i+1][j-1]+A[j]-A[i])
	*/
	dp := make([][]int, N)
	for i := range dp {
		dp[i] = make([]int, N)
		dp[i][i] = A[i]
	}

	for l:=2; l<=N; l++ {
		for i:=0; i<=N-l; i++ {
			j:=i+l-1
			dp[i][j] = max(A[i]-dp[i+1][j], A[j]-dp[i][j-1])
		}
	}

	fmt.Println(dp[0][N-1])
}


Measured memory_bytes: 56064
module Main where

import Data.List
import Control.Monad

solve :: Int -> [Int] -> [[Int]] -> Int
solve c bs ass = length $ filter inner ass where
    inner :: [Int] ->Bool
    inner as = (>0) . (+c)  .sum $ zipWith (*) as bs

main = do
    [n, _, c] <-  fmap read . words <$> getLine
    bs <- fmap read . words <$> getLine
    ass <- replicateM n (fmap read . words <$> getLine)
    print $ solve c bs ass




Measured memory_bytes: 1020
#include <stdio.h>

int insertion_sort(int A[], int n, int g){
    int i, j, v, cnt;
    cnt = 0;
    for(i = g; i < n; i++){
        v = A[i];
        j = i - g;
        while(j >= 0 && A[j] > v){
            A[j + g] = A[j];
            j = j - g;
            cnt++;
        }
        A[j + g] = v;
    }
    return cnt;
}

int shell_sort(int A[], int n, int G[], int m){    //mはG[]の要素数
    int i;
    int cnt = 0;
    for(i = 0; i < m; i++){
        cnt = cnt + insertion_sort(A,n,G[i]);
    }
    return cnt;
}

int main( void ){
    int n, i, cnt, temp;
    int G[100];
    scanf("%d", &n);
    int A[n];
    for(i = 0; i < n; i++){
        scanf("%d", &A[i]);
    }
    G[0] = 1;
    for(i = 1; G[i - 1] * 3 + 1 < n; i++){
        G[i] = G[i - 1] * 3 + 1;
    }
    int m = i;
    for(i = 0; i < m / 2; i++){ //G[]を逆順に入れ替える
        temp = G[i];
        G[i] = G[m - 1 - i];
        G[m - 1 - i] = temp;
    }
    cnt = shell_sort(A, n, G, m);

    printf("%d\n", m);
    for(i = 0; i < m; i++){
        printf("%d", G[i]);
        if(i < m - 1){
            printf(" ");
        }
    }
    printf("\n");
    printf("%d\n", cnt);
    for(i = 0; i < n; i++){
        printf("%d\n", A[i]);
    }

    return 0;
}



Measured memory_bytes: 5572
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
int main() {
    int x,z,sum=0;
    cin>>x>>z;
    int arr[x];
    for(int i=0;i<x;i++){
        cin>>arr[i];
    }
    sort(arr,arr+x);
    for(int i=0;i<z;i++){
        sum+=arr[i];
    }
    cout<<sum;
}

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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

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

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	llong a,b;
	cin >> a >> b;

	llong sum = 0;
	for(int i = 1; i <= b-a; i++)
		sum += i;

	cout << sum - b << endl;

	return 0;
}

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

typedef long long int lli;

int main(void)
{
	lli n, k, res = 0;
	scanf("%lld%lld", &n, &k);
	for(lli i = k+1;i <= n;i++)
	{
		for(lli j = i;;j += i)
		{
			if(k+j-i > n) break;
			pair<lli, lli> rng = {max(1ll, k+j-i), min(n, j-1)};
			res += rng.second-rng.first+1;
			if(j > n) break;
		}
	}
	printf("%lld\n", res);
}

Measured memory_bytes: 256