akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::{i32, i64, u32, u64, usize, f64};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::io::{stdout, Write, BufWriter};
use std::mem::{swap};

fn main() {
    input! {
        s: String,
    }
    let mut map = HashMap::new();
    for c in s.chars() { *map.entry(c).or_insert(0usize) += 1; }
    let m = map.values().min().unwrap();
    let mut buf = Vec::new();
    for c in map.values() { buf.push(c - m); }
    buf.sort();
    let (k, n) = (buf.len(), s.len());
    if k <= 2 && k < n {
        println!("NO");
        return;
    }
    if k == n {
        println!("YES");
        return;
    }
    let mut counter = Vec::new();
    for c in buf { if c > 0 { counter.push(c); } }
    if counter.is_empty() {
        println!("YES");
        return;
    }
    let (k, n) = (counter.len(), counter.iter().sum::<usize>());
    if k < n {
        println!("NO");
        return;
    }
    println!("YES");
}


Measured memory_bytes: 4352
#include<stdio.h>

int main(void){
	int n;
	double o;
	int i;

	scanf("%d",&n);

	o = 0;

	for(i=1;i<=n;i++){
		if(i%2 == 1){
			o++;
		}
	}

	printf("%lf\n",o/n);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<long long>a(n);
    rep(i,n) cin>>a.at(i);
    if(n<=2) cout<<'0';
    else{
    sort(a.begin(),a.end());
    long long ans=0;
    rep(i,n-2){
        for(int j=i+1;j<n-1;j++){
            for(int k=j+1;k<n;k++){
                if(a.at(i)!=a.at(j) && a.at(i)!=a.at(k) && a.at(j)!=a.at(k) && a.at(i)+a.at(j)>a.at(k)){
                    ans++;
                }
            }
        }
    }
    
    cout<<ans;
    }
    
    
}

Measured memory_bytes: 3628
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

bool operator<(const pair<int,int> &a, const pair<int,int> &b){
    if(a.first == b.first){
        a.second < b.second;
    } else {
        a.first < b.first;
    }
}

int main(){
    int n;
    vector<pair<int,int>> viiValue(n);
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        int Ai;
        scanf("%d", &Ai);
        viiValue.push_back(make_pair(i + 1 - Ai,0));
        viiValue.push_back(make_pair(i + 1 + Ai,1));
    }    
    sort(viiValue.begin(),viiValue.end());
  
    long int nCount = 0;
    int i = 0;
    while(i < viiValue.size()){
        if(viiValue[i].second == 1){
            i++;
            continue;
        }
        int a = viiValue[i].first;
        long int nCount0 = 0;
        long int nCount1 = 0;
        while(viiValue[i].first == a && viiValue[i].second == 0){
            i++;
            nCount0++;
        }
        while(viiValue[i].first == a && viiValue[i].second == 1){
            i++;
            nCount1++;
        }
        nCount += nCount0 * nCount1;
    }
    printf("%ld", nCount);
    return 0;
}


Measured memory_bytes: 7072
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")
#include<bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;

#define F first
#define S second
#define int long long
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()


void accell() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
}

const int N = 2e5;
vector<int>g[3];

signed main() {
    accell();
    int n, k;
    cin >> n >> k;
    vector<int>a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    sort(all(a));
    for (int i = 0; i < n; ++i) {
        if (a[i] < 0)
            g[0].push_back(-a[i]);
        if (a[i] == 0)
            g[1].push_back(a[i]);
        if (a[i] > 0)
            g[2].push_back(a[i]);
    }
    for (int i = 0; i < 3; ++i)
        sort(all(g[i]));
    int x = (int)g[0].size();
    int y = g[1].size();
    int z = g[2].size();
    int s1 = x * z;
    int s2 = x * y + z * y + y * (y - 1) / 2;
    if (k <= s1) {
        int l = 0;
        int r = 2e18;
        while (r - l > 1) {
            int m = l + r >> 1;
            int cur = 0;
            for (int i = 0; i < g[0].size(); ++i) {
                int t = g[0][i];
                int id = upper_bound(all(g[2]), (m - 1) / t) - g[2].begin();
                cur += (int)g[2].size() - id;
            }
            if (cur >= k)
                l = m;
            else
                r = m;
        }
        cout << -l;
        return 0;
    }
    if (k <= s1 + s2) {
        cout << 0;
        return 0;
    }
    k -= s1;
    k -= s2;
    int l = 0;
    int r = 2e18;
    while (r - l > 1) {
        int m = l + r >> 1;
        int cur = 0;
        for (int i = 0; i < g[2].size(); ++i) {
            int t = g[2][i];
            int id = upper_bound(all(g[2]), m / t) - g[2].begin();
            cur += id;
            if (g[2][i] * g[2][i] <= m)
                --cur;
        }
        for (int i = 0; i < g[0].size(); ++i) {
            int t = g[0][i];
            int id = upper_bound(all(g[0]), m / t) - g[0].begin();
            cur += id;
            if (g[0][i] * g[0][i] <= m)
                --cur;
        }
        cur /= 2;
        // cout << cur << ' ' << m <<  endl;
        if (cur >= k)
            r = m;
        else
            l = m;
    }
    cout << r << endl;

    return 0;
}


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

using namespace std;
int main() {
    deque<int>d, dd;
    int n;
    int x;
    cin >> n;
    for(int i = 0; i < n; ++i){
        cin >> x;
        if(i % 2 == 1){
            d.push_front(x);
            dd.push_back(x);
        }
        else {
            d.push_back(x);
            dd.push_front(x);
        }
    }
    if(n % 2 == 0){
    for(int i = 0; i < n - 1; ++i){
        cout << d[i] << " ";
    }
    cout << d[n - 1] <<endl;
    }
    else{
        for(int i = 0; i < n - 1; ++i){
        cout << dd[i] << " ";
        }
        cout << dd[n - 1] <<endl;
    }
    return 0;
}


Measured memory_bytes: 3840
//============================================================================
// Name        : Hello5.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <vector>
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using p = pair<int,int>;//<key,value>


int main() {
int x,y,z;

cin>>x>>y>>z;
cout<<z<<" "<<x<<" "<<y;
return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define ll long long
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);


int main() {
  long long n,a,b;
  cin >> n >> a >> b;
  
  cout << (n/(a+b))*a+min(a,n%(a+b));
  
}


Measured memory_bytes: 256
var
  n,m:int64; 
begin
  readln(n,m);
  if(n<0)and(m>0)then writeln('Zero')else
  if(n>0)and(m>0)then writeln('Positive')else
  if(n<0)and(n<0)then
  begin
    if(m-n+1)mod 2=0 then
      writeln('Positive')else
      writeln('Negative');
  end;
end.


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdint>
using namespace std;

int main() {
    int ans;
    string S;
    long long K;

    cin >> S;
    cin >> K;

    long long cnt = 0;
    for(size_t i = 0; i < S.length(); i++) {
        if(S[i] != '1') {
            ans = S[i] - '0';
            break;
        }
        else {
            cnt += 1;
            if(K == cnt) {
                ans = 1;
                break;
            }
        }
    }
    
    cout << ans << endl;
    return 0;
}


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

#define check(val) std::cout << "\033[31m" << #val << ": " << val << "\033[m" << std::endl
#define check_v(vec) \
  std::cout << "\033[31m" << #vec << ": [ ";\
  for(auto it=vec.begin(); it!=vec.end(); it++){cout << *it << " ";}\
  cout << "]"<< "\033[m" << endl;

int main() {
  int x, z, y;
  cin >> x >> y >> z;
  cout <<  z << " " << x <<" " <<  y<< endl;
  return 0;
}


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

int main() {
	// your code goes here
//	int t;cin>>t;
//	while(t--){
//	    
//	    
//	}
	int n;cin>>n;
	int a[n];
	for(int i=0; i<n; ++i){
		cin>>a[i];
	}
	int cnt=0;
	bool flag=false;
	for(int i=0; i<n; ++i){
		if(a[i]==cnt+1){
			cnt++; flag=true;
		}
	}
	if(cnt==0 && flag==false){
		cout<<"-1";return 0;
	}
	else if(cnt==0){
		cout<<cnt;return 0;
	}else
	cout<<n-cnt;
	
	return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>

using namespace std;

const long long mod=1000000007;

const int MX=250250;

long long fact[MX];
long long invFact[MX];

long long ex(long long a,long long e){
	if(e==0) return 1;
	long long tmp=ex(a,e/2);
	tmp*=tmp;
	tmp%=mod;
	if(e%2==1) tmp*=a;
	tmp%=mod;
	return tmp;
}

long long inv(long long a){
	return ex(a,mod-2);
}

long long C(long long N,long long K){
	if(K<0||K>N) return 0;
	long long ans=fact[N];
	ans*=invFact[K];
	ans%=mod;
	ans*=invFact[N-K];
	ans%=mod;
	return ans;
}

long long solve(long long a,long long b){
	return (C(a+b,b)-C(a+b,b-1))%mod;
}

long long get(int N,int M,int k1,int k2){
	long long tmp1=solve(N+k1,k1);
	long long tmp2=solve(M+k2,k2);
	long long tmp3=C(N+M+2*k1+2*k2,N+2*k1);
	return (((tmp1*tmp2)%mod)*tmp3)%mod;
}

int main(){
	int N,M,K;
	scanf("%d%d%d",&N,&M,&K);
	fact[0]=1;
	invFact[0]=1;
	for(int i=1;i<MX;i++){
		fact[i]=(fact[i-1]*i)%mod;
		invFact[i]=inv(fact[i]);
	}
	long long ans=0;
	for(int k=0;k<=K;k++){
		ans+=get(N,M,k,K-k);
		ans%=mod;
	}
	ans+=mod;
	ans%=mod;
	printf("%d\n",(int)ans);
	return 0;
}

Measured memory_bytes: 4936
#include <stdio.h>
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <bitset>
using namespace std;

/*
typedef long long ll;
bool Finish_read;
template<class T>
inline void read(T &x) {
	Finish_read=0;x=0;int f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;if(ch==EOF)return;ch=getchar();}
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	x*=f;Finish_read=1;
}
template<class T>
inline void print(T x) {
	if(x/10!=0)
		print(x/10);
	putchar(x%10+'0');
}
template<class T>
inline void writeln(T x) {
	if(x<0)
		putchar('-');
	x=abs(x);
	print(x);
	putchar('\n');
}
template<class T>
inline void write(T x) {
	if(x<0)
		putchar('-');
	x=abs(x);
	print(x);
}
/*================Header Template==============*/
const int mx=(1<<26);
int pos[mx],f[200010];
char s[200010];
bitset<26> x[200010];
int main() {
	scanf("%s",s+1);
	int n=strlen(s+1);
	f[0]=0;
	memset(pos,-1,sizeof pos);
	pos[0]=0;
	for(int i=1;i<=n;i++) {
		x[i]^=x[i-1];
		x[i][s[i]-'a']=1-x[i][s[i]-'a'];
		f[i]=2e9;
		int t=x[i].to_ulong(),ind=i;
		for(int j=0;j<26;j++) {
			int tmp=(1<<j)^t;
			if(pos[tmp]!=-1&&f[ind]>f[pos[tmp]])
				ind=pos[tmp];
		}
		if(pos[t]!=-1&&f[ind]>f[pos[t]])
			ind=pos[t];
		f[i]=f[ind]+1;
		if(pos[t]==-1||f[i]<f[pos[t]])
			pos[t]=i;
	}
	printf("%d\n",f[n]);
	return 0;
}

Measured memory_bytes: 264960
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  int cnt = 0;
  if (s[0] == '1') cnt++;
  if (s[1] == '1') cnt++;
  if (s[2] == '1') cnt++;
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
  string S;
  bool flag = false;
  cin >> S;
  int N = S.size();
  string tag = "keyence";
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      string T = S.substr(0,i) + S.substr(j);
      if(T == tag) {
        flag = true;
      }
    }
  }
  if(flag){
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ri register
#define int long long
using namespace std;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
int n,m;
string s[210],t[210];
map<string,int> Q;
int res;
signed main()
{
    cin>>n;
    for(ri int i=1;i<=n;i++) cin>>s[i], Q[s[i]]++;
    m=read();
    for(ri int i=1;i<=m;i++) cin>>t[i], Q[t[i]]--;
    for(ri int i=1;i<=n;i++) res=max(res,Q[s[i]]);
    printf("%lld\n",res);
    return 0;
}

Measured memory_bytes: 3692
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) throws Exception {
		while (true) {
			int N = sc.nextInt();
			int H = sc.nextInt();
			if (N == 0 && H == 0) break;
			HashSet<Integer> set = new HashSet<Integer>();
			for (int i = 0; i < H; ++i) {
				String surface = sc.next();
				int v1 = sc.nextInt() - 1;
				int v2 = sc.nextInt() - 1;
				if (surface.equals("xy")) {
					for (int j = 0; j < N; ++j) {
						set.add((v1 << 18) + (v2 << 9) + j);
					}
				} else if (surface.equals("yz")) {
					for (int j = 0; j < N; ++j) {
						set.add((j << 18) + (v1 << 9) + v2);
					}
				} else {
					for (int j = 0; j < N; ++j) {
						set.add((v1 << 18) + (j << 9) + v2);
					}
				}
			}
			System.out.println(N * N * N - set.size());
		}
	}

}

Measured memory_bytes: 17000
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout << (w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define RFOR(i, a, n) for (int i = (n)-1; i >= (a); --i)
#define REP(i, n) for (int i = 0; i < int(n); ++i)
#define RREP(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define IN(a, x, b) (a <= x && x < b)
#define OUT(a, x, b) (x < a || b <= x)
template <class T> inline T chmax(T &a, const T b) {
  return a = (a < b) ? b : a;
}
template <class T> inline T chmin(T &a, const T b) {
  return a = (a > b) ? b : a;
}

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT {
  INIT() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  }
} INIT;

int N;
vector<int> A(N);
int f(){
  int ret = 0;
  if(N%2 == 0){
    REP(i, N){
      if(i < N/2) ret -= A[i]*2;
      else ret += A[i]*2;
    }
    ret += A[N/2-1];
    ret -= A[N/2];
  }else{
    REP(i, N){
      if(i <= N/2) ret -= A[i]*2;
      else ret += A[i]*2;
    }
    ret += A[N/2];
    ret += A[N/2-1];
  }
  return abs(ret);
}

signed main() {
  cin >> N;

  A.resize(N);
  REP(i, N) cin >> A[i];

  sort(ALL(A), greater<>());

  int ans = f();

  sort(ALL(A));

  chmax(ans, f());;

  cout << ans << "\n";


  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <unordered_map>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

int N;
map<string,int> m;

int main(){
    cin>>N;
    rep(i,N){
        string s;
        cin>>s;
        m[s]++;
    }

    int ans=m.size();
    cout<<ans<<endl;
}

Measured memory_bytes: 19224
def Ii():return int(input())
def Mi():return map(int,input().split())
def Li():return list(map(int,input().split()))
 
n = Ii()%10
if n == 3:
  print('bon')
elif n==2 or n == 4 or n == 5 or n==7 or n == 9:
  print('hon')
else:
  print('pon')

Measured memory_bytes: 9116
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; ++i)
#define RREP(i, n) for (int i = n; 0 <= i; --i)
#define FOR(i, start, end) for (int i = start; i < end; ++i)
#define RFOR(i, start, end) for (int i = start; end <= i; --i)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }


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

    ll N; cin >> N;
    cout << pow(N, 3) << '\n';
}



Measured memory_bytes: 256
import sys
import collections

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())
    S = input().strip()

    c = collections.Counter(S)
    ans = c["R"] * c["G"] * c["B"]

    for i in range(N):
        for j in range(i + 1, N):
            if j + j - i > N - 1:
                break
            if S[i] != S[j] and S[j] != S[j + j - i] and S[i] != S[j + j - i]:
                ans -= 1
    print(ans)


if __name__ == '__main__':
    main()


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

#define F first
#define S second
#define pb push_back
#define mp make_pair

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

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

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

	ll n,i,j,cnt = 0;

	cin >> n;

	ll a[n];

	for(i=0;i<n;i++)
		cin >> a[i];

	sort(a,a+n);

	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
			for(ll k = j+1;k<n;k++)
			{
				if(a[i] != a[j] && a[i] != a[k] && a[j] != a[k])
				{
					if(a[i] + a[j] > a[k])
						cnt++;
				}
			}
		}
	}

	cout << cnt << endl;
}

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

using namespace std;

const int INF=100000008;

struct Drag
{
	int a,b,c;
	Drag(int a,int b,int c):a(a),b(b),c(c){}
};

int main()
{
	int n,ma,mb;
	cin >> n >> ma >> mb;
	
	vector<Drag> drags;

	for(int i=0;i<n;i++)
	{
		int a,b,c;
		cin >> a >> b >> c;
		drags.push_back(Drag(a,b,c));	
	}

	int ans=INF;

	int table[405][405][2];
	for(int i=0;i<405;i++)
		for(int j=0;j<405;j++)
			for(int k=0;k<2;k++)
				table[i][j][k]=INF;
		
	table[0][0][0]=0;
	table[0][0][1]=0;

	for(int i=0;i<n;i++)
	{
		int x=i%2;
		int y=(i+1)%2;
		for(int j=0;j<405;j++)
			for(int k=0;k<405;k++)
			{
				int x=i%2;
				int y=(i+1)%2;
				if(table[j][k][y]!=INF)
				{
					table[j+drags[i].a][k+drags[i].b][x]=min(table[j][k][y]+drags[i].c,table[j+drags[i].a][k+drags[i].b][y]);
				}
			}
		for(int j=0;j<405;j++)
			for(int k=0;k<405;k++)
				table[j][k][y]=table[j][k][x];
	}

	for(int i=1;i<405/max(ma,mb);i++)
	{
		ans=min(ans,table[ma*i][mb*i][0]);
	}

	cout << (ans==INF ? -1:ans) << endl;


}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char c;
	string s,t;
	cin >> s >> t;
	for(int i=0;i<s.size()-1;i++)
		for(int j=0;j<s.size()-i-1;j++)
			if(s[j]+'0'>s[j+1]+'0')    
			{	
				c=s[j];
				s[j]=s[j+1];
				s[j+1]=c;
			} 
	for(int i=0;i<t.size()-1;i++)
		for(int j=0;j<t.size()-i-1;j++)
			if(t[j]+'0'<t[j+1]+'0')
			{	
				c=t[j];
				t[j]=t[j+1];
				t[j+1]=c;
			} 	
	for(int i=0;i<s.size();i++)
	{
		if(s[i]+'0' < t[i]+'0')
		{
			puts("Yes");
			return 0;
		}
		else
		if(s[i]+'0' > t[i]+'0')
		{
			puts("No");
			return 0;
		}
	} 
	if(s.size() >= t.size())
		puts("No");
	else
		puts("Yes"); 
	return 0; 	 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll X, Y;
  cin >> X >> Y;

  if(Y % 2 == 1){
    cout << "No\n";
    return 0;
  }

  if((2*X - Y/2 < 0) || (-X + Y/2 < 0)){
    cout << "No\n";
    return 0;
  }

  cout << "Yes\n";
  
  return 0;
}


Measured memory_bytes: 3608
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;

int a, b, c, d, e, f;
int answ, ansk;
bool g[3010];

int main() {
	//freopen("C.in", "r", stdin);
	//freopen("C.out", "w", stdout);
	int i, j, k;
	scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &f);
	for(i = 0; i * c*100 <= f*e; i++)
		for(j = 0; i*c*100+j*d*100 <= f*e; j++) 
			g[i*c+j*d] = true;
	for(i = 0; i * a * 100 <= f; i++)
		for(j = 0; i*a*100+j*b*100 <= f; j++) {
			int w = i*a*100+j*b*100;
			if(w == 0) continue;
			for(k = floor(w*1.0/100*e); k; k--) {
				//printf(":(%d, %d)", k, g[k]);
				if(k+w <= f && g[k]) break;
			}
			//printf("\n");
			//printf("%d %d\n", w, k);
			if(answ == 0 && ansk == 0 || k*(answ+ansk) >= ansk*(w+k)) 
				ansk = k, answ = w;
		}
	printf("%d %d\n", answ+ansk, ansk);
	return 0;
}


Measured memory_bytes: 128
// abc168_c
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

template <typename A, typename B> bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B> bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
int inf = sizeof(int) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  double radianM = (double)m / 60.0 * 2 * PI;
  double radianH = (double)(h / 12.0 + m / 720.0) * 2 * PI;
  double ans = (double)(a * a) + (double)(b * b) -
               2.0 * (double)a * (double)b * cos(abs(radianH - radianM));
  cout << fixed << setprecision(9);
  cout << sqrt(ans) << endl;
  return 0;
}


Measured memory_bytes: 4280
n, k = map(int,input().split())
D = list(map(int,input().split()))

f = [0]*10
for d in D:
    f[d] = 1

while True:
    check = str(n)
    for c in check:
        if f[int(c)]:
            n += 1
            break
    else:
        print(check)
        break

Measured memory_bytes: 67236
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)

template<typename T>
void remove(vector<T>& vector, unsigned int index){
vector.erase(vector.begin() + index);
}

typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
vector<int> arr(10000000);
void Eratosthenes(int N){
	for(int i = 0; i < N; i++){
		arr[i] = 1;
	}
	for(int i = 2; i < sqrt(N); i++){
		if(arr[i]){
			for(int j = 0; i * (j + 2) < N; j++){
				arr[i *(j + 2)] = 0;
			}
		}
	}
}
bool judge(int i){
	if(arr[i] == arr[i-2] && arr[i-6] == arr[i-8] && arr[i] == arr[i-8]){
		return true;
	}else{
		return false;
	}
}

int main(void){
	clock_t s,e;
	Eratosthenes(10000000);
	int n;
	
	while(cin >> n, n){
		for(int i = n; i >= 2; i--){
			if(arr[i]){
				if(judge(i)){
					cout << i << endl;
					break;
				}
			}
		}
	}

	return 0;
}



int StrToInt(string s){
	stringstream ss;
	ss << s;
	int val;
	ss >> val;
	return val;
}
string IntToStr(int i){
	stringstream ss;
	ss << i;
	return ss.str();
}

Measured memory_bytes: 40180
def inpl(): return [int(i) for i in input().split()]

N, T = inpl()
A = inpl()
minA = [0 for _ in range(N)]
minA[0] = A[0]
for i in range(N-1):
    minA[i+1] = min(minA[i], A[i+1]) 
ans = 1
maxpro = 0
for i in range(N-1):
    if A[i+1]-minA[i] == maxpro:
        ans += 1
    if A[i+1]-minA[i] > maxpro:
        ans = 1
        maxpro = A[i+1]-minA[i]

print(ans)

Measured memory_bytes: 14252
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
using namespace std;


int main()
{

	int a;
	int h[10] = { 0 };

	for (int i = 1; i <= 9; i++) {
		cin >> h[i];
	}
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a;
		for (int j = 1; j <= 9; j++) {
			if (h[j] == a)h[j] = 0;
		}
	}

	if (h[1] + h[2] + h[3] == 0 || h[4] + h[5] + h[6] == 0 || h[7] + h[8] + h[9] == 0)cout << "Yes" << endl;
	else if (h[1] + h[4] + h[7] == 0 || h[2] + h[5] + h[8] == 0 || h[3] + h[6] + h[9] == 0)cout << "Yes" << endl;
	else if (h[3] + h[5] + h[7] == 0 || h[1] + h[5] + h[9] == 0)cout << "Yes" << endl;
	else cout << "No" << endl;
}


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

int main () {
  string s ;
  cin >> s;
  bool ans = true;
  for (int i = 0; i < 3; i++){
    if (s.at(i) == s.at(i+1)) ans = false;
  }
  if (ans) cout << "Good" << endl;
  else cout << "Bad" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N;
int d[1000000];
string checkprev(){
	int canhop=1;
	for(int i = N-1;i>0;i--){
		canhop--;
		canhop = max(canhop,d[i]/10);
		if(canhop ==0)
			return "no";
	}
	return "yes";
}
string checkfront(){
	int canhop=1;
	for(int i = 0;i<N;i++){
	canhop--;
	canhop = max(canhop,d[i]/10);
	if(canhop ==0)
		return "no";
	}
	return checkprev();
}
int main(){
	cin >> N;
	for(int i = 0;i<N;i++){
		cin >> d[i];
	}
	cout << checkfront()<<endl;
	return 0;
}


Measured memory_bytes: 4344
#include <bits/stdc++.h>
#define PI 3.14159265359
using namespace std;

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

    vector<int> v(N);
    int sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> v.at(i);
        sum += v.at(i);
    }

    cin >> M;
    for (int i = 0; i < M; i++) {
        int P, X;
        cin >> P >> X;

        int n = sum - (v.at(P - 1) - X);
        cout << n << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
using namespace std;
#define INF 100000000
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define rep(i, n) for(int (i)=1; (i)<=(n); (i)++)
typedef pair<int, int> P;
typedef long long ll;
int main(){
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int dx, dy;
    dx = x2-x1;
    dy = y2-y1;
    int x3, y3, x4, y4;
    x3 = x2 - dy;
    y3 = y2 + dx;
    x4 = x1 - dy;
    y4 = y1 + dx;
    cout << x3 <<" "<< y3 <<" "<< x4 <<" "<< y4 << endl;
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  switch(N%10){
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      cout << "hon" << endl;
      break;
    case 0:
    case 1:
    case 6:
    case 8:
      cout << "pon" << endl;
      break;
    case 3:
      cout << "bon" << endl;
      break;
  }
}
 

Measured memory_bytes: 3632
#include<stdio.h>

int main(void){
    long K,N,max;
    long index[200020];
    int i,j;

    scanf("%ld %ld",&K,&N);

    for(i=0;i<N;i++){
        scanf("%ld",&index[i]);
    }

    max = 0;
    for(i=0;i<N-1;i++){
        if(index[i+1]-index[i]>max){
            max = index[i+1]-index[i];
        }
    }

    if(K-index[i]+index[0] > max){
        max = K-index[i]+index[0];
    }

    printf("%ld",K-max);
    return 0;

}

Measured memory_bytes: 1664
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] d = new int[N];
        for(int n=0; n<N; n++) d[n]=sc.nextInt();
        Arrays.sort(d);
        int ABCmax = d[N/2-1];
        int ARCmin = d[N/2];
        System.out.println(Math.max(0, ARCmin - ABCmax));
    }
}

Measured memory_bytes: 50624
#include<stdio.h>
#include<math.h>
#define N 
int isprime(int);
int main(){

  int n,i,kazu=0,x;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&x);
    if(isprime(x)==1) kazu++;
  }
  printf("%d\n",kazu);

  return 0;
}
int isprime(int x){
  int i;

  if(x==2) return 1;
  if(x<2||x%2==0) return 0;

  i=3;
  while(i<=sqrt(x)){
    if(x%i==0) return 0;
    i=i+2;
  }
    return 1;
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int N,X,L,D=0;
      cin >> N >> X;
      
      for(int i=0;i<N;i++){
        cin >> L;
        D += L;
        if(D>X){
          cout << i+1 <<endl;
          break;
        } 
        if(i == N-1){
          cout << N+1 <<endl;
        }
      }
    }
          

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

ll gcd(ll a,ll b){
  while(b!=0){
    a%=b;
    swap(a,b);
  }
  return a;
}

int main(){
  int X;
  cin >> X;
  int ans=0;
  if(X==2){
    cout << 2 << endl;
    return 0;
  }
  if(X%2==0){
    X+=1;
  }
  for(int i=X;i<1e9;i+=2){
    bool ok=true;
    for(int j=2;j<i-1;j++){
      if(i%j==0){
        ok=false;
        break;
      }
    }
    if(ok){
      cout << i << endl;
      return 0;
    }
  }
        
    
}
      
  
  
  

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int flag = 1, i;
    char input[5];
    scanf("%s", input);
    for(i=0;i < 3;i++){
        if(input[i]==input[i+1])
            flag = 0;
    }
    if(flag==1){
        printf("Good");
    }else{
        printf("Bad");
    }
    return 0;
}

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

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

#define For(i, a, b) for(int i = (a); i < (b); i++)
#define Rep(i, n) For(i, 0, (n))
#define Rrep(i, n) for(int i = (n - 1); i >= 0; i--)
#define Itr(i, c) for(typeof(c.begin()) i = c.begin(); i != c.end(); i++)
#define pb push_back

const int inf = 999999999;
const int mod = 1000000007;

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

int main(){
	ll n, x; cin >> n >> x;
	ll a[n], b[n];
	Rep(i, n){
		cin >> a[i];
		b[i] = abs(x-a[i]);
	}
	ll ans = b[0];
	For(i, 1, n){
		ans = gcd(ans, b[i]);
	}
	cout << ans << endl;
	return 0;
}

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

#define rep3(i, s, n ,a) for (int i = (s); i < (int)(n); i+=a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

int main(){
    int n;
    cin >> n;
    vector<int> a;
    vector<long> sum;
    //set<long> sum_list;
    rep(i, n){
        int num;
        cin >> num;
        a.push_back(num);
    }
    sum.push_back(0);
    //sum_list.insert(0);
    long total=0;
    long minim=0, maxim=0;
    rep(i, n){
        total += a[i];
        sum.push_back(total);
        //sum_list.insert(total);
        minim = min(minim, total);
        maxim = max(maxim, total);
    }
    sort(sum.begin(), sum.end());
    long cnt=0, set=sum[0], seq=1;
    rep2(i, 1, n+1){
        if(set==sum[i]){
            seq++;
        }else{
            cnt += seq * (seq - 1) / 2;
            set = sum[i];
            seq = 1;
        }
    }
    cnt += seq * (seq - 1) / 2;
    // for(set<long>::iterator it=sum_list.begin();it!=sum_list.end();it++){
    //     int tmpcnt=0;
    //     rep(j, n+1){
    //         if(sum[j]==*it){
    //             tmpcnt++;
    //         }
    //     }
    //     cnt += tmpcnt * (tmpcnt - 1) / 2;
    // }
    // // rep2(i, sum_list.begin(), list_size){
    //     int tmpcnt=0;
    //     rep(j, n+1){
    //         if(sum[j]==sum_list[i]){
    //             tmpcnt++;
    //         }
    //     }
    //     cnt += tmpcnt * (tmpcnt - 1) / 2;
    // }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
#define pb(n,m) n.push_back(m)
#define fix(n) cout<<fixed<<setprecision(n);
using namespace std;
//using bint=boost::multiprecision::cpp_int;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  string s; int n;
  cin>>s>>n;
  rep(i,0,n){
    string t; cin>>t;
    if(t=="replace"){
      int a,b; string u; cin>>a>>b>>u;
      rep(i,a,a+u.size()) s[i]=u[i-a];
    }
    else if(t=="reverse"){
      int a,b; cin>>a>>b;
      string u="";
      rep(i,a,b+1) u+=s[i];
      reverse(all(u));
      rep(i,a,b+1) s[i]=u[i-a];
    }
    else{
      int a,b; cin>>a>>b;
      string u="";
      rep(i,a,b+1) u+=s[i];
      co(u);
    }
  }
  
  return 0;
}


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

int main(){
	int n;
  	cin >> n;
  	
  	bool ans = false;
  	for(int i = 1; i < 10; i++){
    	if(n % i == 0){
			if(n / i < 10) ans = true; 	
        }
    }
  
  	if(ans) cout << "Yes" << endl;
  	else cout << "No" << endl;
}

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

int main(void){
  int H,W,i,j;
  while(H != 0 || W != 0){
    cin >> H >> W;
    for (i=0 ; i<H;i++){
      for(j=0; j<W;j++){
        if (H != 0 || W != 0){
          if( i % 2 ==1){
            if( j % 2 == 1){
              cout << "#";
            }else cout << ".";
          }else{
            if( j % 2 == 1){
              cout << ".";
             }else cout << "#";
          }
        }
//      cout << endl;
    }
    cout << endl;
    }
    if (H != 0 || W != 0) cout << endl;
  }
  return 0; 
    }



Measured memory_bytes: 3108
#include <iostream>
#include <map>
#include<algorithm>
#include <vector>
using namespace std;
int main(){


    int N;
    cin>>N;
    vector<pair<long int,long int> > pairs(N);
    long int X[N],L[N];
    long int Xmin[N],Xmax[N];
    int x,l;
    for(int i=0;i<N;i++){
        cin>>x>>l;
        pairs[i]=make_pair(x+l,x-l);
    }
    sort(pairs.begin(),pairs.end());
    int max_robot=0;
    long int e=-1000000000;
    for(int i=0;i<N;i++){
        if(e<=pairs[i].second){
            e=pairs[i].first;
            max_robot++;
        }
     
    }
    cout<<max_robot<<endl;
    
}

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

int main(void){
  double xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2;
  while(cin >> xa1 >> ya1 >> xa2 >> ya2 >> xb1 >> yb1 >> xb2 >> yb2){
    if(yb2 < ya1 || ya2 < yb1 || xb2 < xa1 || xa2 < xb1) cout << "NO" << endl;
    else cout << "YES" << endl;
  }
  return 0;
}

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

int main(){
	int r, g, b;
  	int sum = 0;
  
  	cin >> r >> g >> b;
  	sum = r*100 + g*10 + b;
  
  	if(sum % 4 == 0){
      cout << "YES";
    }
  else{
        cout << "NO";
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int A;
	int B;
	int C;
	cin >> A;
	cin >> B;
	cin >> C;
	if (A*C <= B){
		cout << C << "\n";
	}else if (A*C >= B){
		cout << B/A << "\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9 + 7
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main(){
    int n, x, t;
    
    cin >> n >> x >> t;
    int a = 0;
    if (n % x == 0) {
        a = n /  x;
    }
    else {
        a = n / x + 1;
    }
    cout <<  a * t << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define int long long 
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)

using namespace std ;

int n , m , a ,b ;

int32_t main(){IOS;

        cin >> n >> m >> a >> b ; 
        cout << (n-a)*m - (n-a)*b  << endl; 

        return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#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 pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

ll a[100][100], b[100][100], c[100][100];

int main() {
    int n, m, l;
    cin >> n >> m >> l;
    REP(i,n) REP(j,m) cin >> a[i][j];
    REP(i,m) REP(j,l) cin >> b[i][j];
    REP(i,n) REP(j,l) REP(k,m) c[i][j] += a[i][k] * b[k][j];
    REP(i,n){
        REP(j,l){
            cout << c[i][j];
            if (j < l-1) cout << " ";
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3308
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define eps 1e-9
#define maxp 1004
#define mod 998244353
#define sin(s) scanf("%lld",&s);
#define sout(s) printf("%lld\n",s);
#define in(s) cin>>s
#define in2(a,b) cin>>a>>b
#define in3(a,b,c) cin>>a>>b>>c
#define vll vector<ll>
#define out(s) cout<<s
#define outs(s,a) cout<<s<<a
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define gear_change ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define nfl(i,n) for(i=0;i<n;i++)
#define sfl(i,s,e) for(i=s;i<e;i++)
#define ufl(i,n) for(i=n-1;i>=0;i--)
void solve(){
    ld n,m,i,c=0,s=0;
    in2(n,m);
    vector<ll>vec(n);
    nfl(i,n){
        in(vec[i]);
        s+=vec[i];
    }
    ld den=4*m;
    ld fra=s/den;
    nfl(i,n){
        if(vec[i]>=fra){
            c++;
        }
    }
    if(c>=m){
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }
}
int main(){
    clock_t t1=clock();
    gear_change;
    ll test=1;
    // in(test);
    while(test--){
        solve();
    }
    clock_t t2=clock();
    cerr<<"Time elapsed:- "<<(double)(t2-t1)/CLOCKS_PER_SEC<<'\n';
}    

Measured memory_bytes: 256
#pragma GCC optimize "trapv"
#include<bits/stdc++.h>
#define faster ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
int MOD=1e9+7;
 
signed main()
{
   faster;
     {
          int n,k;
          cin>>n>>k;
          int a[n+1];
          for (int i=1;i<=n;i++)
               cin>>a[i];
          long long  dp[n+1][k+1];
          long long pre[n+1][k+1];
          for (int i=0;i<=n;i++)
               for (int j=0;j<=k;j++)
                    dp[i][j]=0;
          for (int i=0;i<=a[1];i++)
               dp[1][i]=1;
          pre[1][0]=dp[1][0];
          for (int i=1;i<=k;i++)
                pre[1][i]=(pre[1][i-1]+dp[1][i])%MOD;
          for (int i=2;i<=n;i++)
          {
               for (int j=0;j<=k;j++)
               {
                    int x=max(j-a[i],0);
                    if (x>0)
                      dp[i][j]=(pre[i-1][j]-pre[i-1][x-1])%MOD;
                    else
                      dp[i][j]=(pre[i-1][j])%MOD;
               }
               pre[i][0]=dp[i][0];
               for (int j=1;j<=k;j++)
                  pre[i][j]=(pre[i][j-1]+dp[i][j]);
          }
          cout<<(dp[n][k])%MOD;
     }
}

Measured memory_bytes: 157312
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
using namespace std;
int n,m,i,j,f[200005][19],g[200005][19],a[200005],l[200005],lg[200005],t,ans,ys;
int qrymi(int x,int y)
{
	int k=lg[y-x+1];
	return min(f[x][k],f[y-(1<<k)+1][k]);
}
int qrymx(int x,int y)
{
	int k=lg[y-x+1];
	return max(g[x][k],g[y-(1<<k)+1][k]);
}
int main()
{
	fz(i,2,200000){
		lg[i]=lg[i/2]+1;
	}
	scanf("%d%d",&n,&m);
	fz1(i,n){
		scanf("%d",&a[i]);
		g[i][0]=f[i][0]=a[i];
	}
	fz1(j,18)fz1(i,n-(1<<j)+1){
		f[i][j]=min(f[i][j-1],f[i+(1<<(j-1))][j-1]);
		g[i][j]=max(g[i][j-1],g[i+(1<<(j-1))][j-1]);
	}
	fz1(i,n){
		if(i>1&&a[i-1]<a[i]) l[i]=l[i-1]+1; else l[i]=1;
	}
	if(l[m]>=m) ys=1; else ans=1;
	fz(i,m+1,n){
		if(l[i]>=m){
			ys=1;
			continue;
		}
		if(qrymi(i-m,i)==a[i-m]&&qrymx(i-m,i)==a[i]){
			continue;
		}
		else{
			ans++;
		}
	}
	cout<<ans+ys<<endl;
	return 0;
}

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

int N,M;

bool visited[8];
vector<int> G[8];

int dfs(int s){
  bool all = true;
  for(int i=0;i<N;i++){
    if(!visited[i])
      all = false;
  }
  if(all) return 1;

  int ret = 0;
  for(int i=0;i<G[s].size();i++){
    int nx = G[s][i];
    if(visited[nx]) continue;
    visited[nx] = true;
    ret += dfs(nx);
    visited[nx] = false;
  }
  return ret;
}

int main(){
  cin>>N>>M;
  for(int i=0;i<M;i++){
    int a,b;
    cin>>a>>b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  visited[0] = true;
  cout<<dfs(0)<<endl;
  return 0;
}


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

typedef long long ll;

struct Card {
  int b;
  ll c;
};

int main() {
  int n, m;
  cin >> n >> m;
  vector<ll> la(n);
  for (ll &a: la) cin >> a;
  sort(la.begin(), la.end());
  vector<Card> cards(m);
  for (int i = 0; i < m; ++i) { 
    int b;
    ll c;
    cin >> b >> c;
    cards.push_back((Card){b, c});
  }
  sort(cards.begin(), cards.end(), [](const Card& lhs, const Card& rhs){
    return lhs.c > rhs.c;
  });
  int cnt = 0;
  ll ans = 0;
  for (Card& card: cards) { 
    for (int i = 0; i < card.b; ++i) { 
      if (cnt >= n) {
        cout << ans << endl;
        return 0;
      }
      ans += max(card.c, la[cnt++]);
    }
  }
  for (int i = cnt; i < n; ++i) {
    ans += la[i];
  }
  cout << ans << endl;
}



Measured memory_bytes: 5504
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

template<typename T>T& max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T& min(T&a,T&b){if(a<b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T get(){T a;cin>>a;return a;}
template<typename T>T rev(T a){reverse(all(a));return a;}
template<typename T>vector<T>&sort(vector<T>&a){sort(all(a));return a;}

const int inf = 1e9;
const ll linf = 3e18;
const double eps = 1e-9;

struct edge { int to, cost; edge(int to, int cost) : to(to), cost(cost) {} };
typedef vector<edge> edges;

edges G[3010];
int d[100010];

void dijkstra(int s)
{
    priority_queue<pii, vpii, greater<pii> > pq;
    d[s] = 0;
    pq.push(pii(0, s));
    
    while (pq.size()) {
        pii p = pq.top(); pq.pop();

        int v = p.scd;

        if (d[v] < p.fst) continue;

        for (edge &e : G[v]) {
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                pq.push(pii(d[e.to], e.to));
            }
        }
    }
}

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

    fill_n(d, N + 1, inf);

    rep(i, M) {
        int a, b, l; cin >> a >> b >> l;
        a--, b--;

        G[a].PB(edge(b, l));
        G[b].PB(edge(a, l));
    }

    rep(i, K) {
        int s; cin >> s;
        s--;
        dijkstra(s);
    }

    int ma = -1;

    rep(i, N) {
        for (edge &e : G[i]) {
            ma = max(ma, d[i]);
            if (d[i] <= d[e.to]) {
                ma = max(ma, (int)(d[i] + round(1. * (d[e.to] - d[i] + e.cost) / 2)));
            }
        }
    }

    cout << ma << endl;
}

Measured memory_bytes: 6012