akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long

const ll mod = 1e9+7;

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

int main() {

    ll n;
    cin>>n;
    ll a[n];
    ll left[n+1]{0},right[n+1]{0};
    for(ll i=0;i<n;i++){
        cin>>a[i];
    }    
    for(ll i=0;i<n;i++){
        left[i]=(i)?gcd(left[i-1],a[i]):a[i];
        // cout<<left[i]<<" ";
    }
    // cout<<endl;
    ll ans=0;
    for(ll i=n-1;i>=0;i--){
        right[i]=(i!=n-1)?gcd(right[i+1],a[i]):a[i];
        // cout<<right[i]<< " ";
        ll l=(i)?left[i-1]:0;
        ll r=(i!=n-1)?right[i+1]:0;
        // cout<<gcd(l,r)<<endl;
        ans=max(ans,gcd(l,r));
    }

    cout<<ans<<endl;

}


Measured memory_bytes: 2560
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, K = map(int, input().split())
S = input()[:-1]
ans = ""
for i, c in enumerate(S):
    if i == K-1:
        ans += c.lower()
    else:
        ans += c
print(ans)


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


int main() {

	int h, w;
	cin >> h >> w;
	vector<vector<pair<int, int>>> m(h);

	char cbuf;
	for (int y = 0; y < h; y++) {
		m[y] = vector<pair<int, int>>(w);
		for (int x = 0; x < w; x++) {
			cin >> cbuf;
			if (cbuf == '.')
				m[y][x] = make_pair(-1, -1);
			else
				m[y][x] = make_pair(0, 0);
		}
	}

	int ans;
	for (int y = 0; y < h; y++) {
		for (int x = 0; x < w; x++) {
			if (m[y][x].first == -1) {
				int xsp = 0;
				for (int x2 = x; x2 < w; x2++) {
					if (m[y][x2].first == 0)break;
					xsp++;
				}
				for (int x2 = x; x2 < w; x2++) {
					if (m[y][x2].second == 0)break;
					m[y][x2].first = xsp;
				}
			}
			if (m[y][x].second == -1) {
				int ysp = 0;
				for (int y2 = y; y2 < h; y2++) {
					if (m[y2][x].second == 0)break;
					ysp++;
				}
				for (int y2 = y; y2 < h; y2++) {
					if (m[y2][x].second == 0)break;
					m[y2][x].second = ysp;
				}
			}
			
			ans = max(ans, m[y][x].first + m[y][x].second);
		}
	}

	cout << ans-1 << endl;

	return 0;
}


Measured memory_bytes: 31616
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;

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

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

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

	vector<int> A(N), B(N);

	rep(i, N) {
		cin >> A[i] >> B[i];
	}

	int ret = 0;
	for (int i = N - 1; i >= 0; i--) {
		int tmp = B[i] - (A[i] + ret) % B[i];
		if (tmp < B[i]) ret += tmp;
	}

	cout << ret << endl;

    return 0;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
#include<vector>
#include<iostream>
#include<sstream>
#include<fstream>
#include<list>
#include<deque>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cmath>
#include<ctime>
#include<iomanip>
using namespace std;
/*freopen{"input.txt","r",stdin};
freopen{"output.txt","w",stdout};*/
#define mp make_pair
#define pb push_back
const int INF=1000*1000*1000;
const int maxn=2e5; 
typedef long long ll;
typedef long double ld;
typedef pair<int,int>PII;
//priority_queue <int,vector<int>,greater<int> > q1;  //从小到大 
//priority_queue <int,vector<int>,less<int> >q2;  //从大到小 

//set multiset vector queue priority_queue map multimap pair string structure 

//枚举 思维 贪心 搜索 模拟 预处理 二分 排序 

int main(){
	//ios_base::sync_with_stdio(0);
    //cin.tie(0);
    //cout.tie(0);
	int a;
	cin>>a;
	string s;
	cin>>s;
	if(a>=3200) cout<<s;
	else cout<<"red"; 
	
	
	
	
	
	
	
	
	return 0;
}



Measured memory_bytes: 256
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>

#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 100005
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)

using namespace std;

inline void inp( int &n ) { 
	n=0;    int ch=getcx();int sign=1;   
	while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getcx();} 
	while(  ch >= '0' && ch <= '9' )    
	n = (n<<3)+(n<<1) + ch-'0', ch=getcx();
	n=n*sign;
}

inline void inp1( LL &n ) { 
	n=0;    LL ch=getcx();LL sign=1;   
	while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getcx();} 
	while(  ch >= '0' && ch <= '9' )    
	n = (n<<3)+(n<<1) + ch-'0', ch=getcx();
	n=n*sign;
}

int main() {
	double r;
	double pi = 3.141592653589793238;
	cin >> r;
	cout<<2*pi*r<<endl;

    return 0;
}



Measured memory_bytes: 3740
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rep2(i, l, r) for (ll i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
const long long mod = 1e9 + 7;
typedef long long ll;
typedef priority_queue<int> PQ;
typedef vector<long long> VL; // VL a(n);
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VL> VLL; // VII a(n,VI(m)) n * m
typedef pair<ll, ll> PL;
typedef map<ll, ll> MP; // MP a;
typedef vector<pair<ll, ll>> PS; // PS a(n);

template <class T, class U>
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp
// operator << (cout,a);
// chmin(min,a)
ll sum(ll n){return n*(n+1)/2;} 

int main() {
  ll n,k,m,x=0,y=0,z=0,cnt=0,h=0,w=0,ans=0,Max=-1, Min=3e9+1;
  string s,t;
  cin >> n;
  for(int i=1; i<=n; i++){ // n=8のとき
    ans += sum(n/i)*i;    // 2+4+6+8 → 2(1+2+3+4)
  }                       // sum(8/3),つまりsum(2) → 3(1+2)
  pri(ans);
  return 0;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i, n) ;for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) ;for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007

int main() {
  int N,M;
  cin >> N >> M;
  rep(i, M){
  int A;
    cin >> A;
    N-=A;
  }
  if(N<0)
    cout << -1 << endl;
  else
    cout << N << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;
typedef long double ld;

ld dist(int a,int aa,int b,int bb){
    return ld(1.0*sqrt((a-b)*(a-b)+(aa-bb)*(aa-bb)));
}

int main(){
    int n;cin>>n;
    vector<pair<int,int> >v(n);
    for(int i=0;i<n;i++)cin>>v[i].first>>v[i].second;
    sort(v.begin(),v.end());
    ld ans=0;
    do{
        for(int i=0;i<n-1;i++)ans+=dist(v[i+1].first,v[i+1].second,v[i].first,v[i].second);
    }while(next_permutation(v.begin(),v.end()));
    ld fact=1;
    for(int i=2;i<=n;i++)fact*=i;
    cout.precision(15);
    cout<<ans*1.0/fact;
}

Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

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

    cout << n * (n-1) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    while(true){
      str = str.substring(0, str.length() - 2);
      String tmp1 = str.substring(0, str.length()/2);
      String tmp2 = str.substring(str.length()/2, str.length());
      if(tmp1.equals(tmp2)){
        System.out.println(str.length());
        break;
      }
    }
  }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define show(x) for(auto i: x){cout << i << " ";}
typedef long long ll;



int main()
{
    int n;
    cin >> n;
    vector<pair<string, int>> a;

    rep(i ,n){
        string s;
        int num;
        cin >> s >> num;
        a.push_back(make_pair(s, num));
    }

    string x;
    cin >> x;
    int flag = 0;
    int ans = 0;
    rep(i, n){
        if(flag) ans += a[i].second;
        if (a[i].first == x){
            flag = 1;
        }
    }

    cout << ans << endl;
}



Measured memory_bytes: 256
#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 lp(i,n) for(int i = 0; i <n;i++)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define sz(v) ((int)((v).size()))
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
typedef pair<int, int> pii;
template<class T> using ordered_set=tree<
T,
null_type,
less<T>,
rb_tree_tag,
tree_order_statistics_node_update>;
const ll MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)2e5+5;

void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
int freq[N];
int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    
   int n;
   cin>>n;
   for(int i=2;i<=n;i++){
       int x;
       cin>>x;
       freq[x]++;
   }
   for(int i=1;i<=n;i++)printf("%d\n",freq[i]);
    return 0;
}

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

int main(){
	int c=0;
	string s;
	cin>>s;
	int n=s.size();
	if(s[0]!='A'){
		cout<<"WA";
		return 0;
	}
	for(int i=1;i<n;i++){
		if(i<n-1&&2<=i&&s[i]=='C'){
			c++;
			continue;
		}
		if('z'<s[i]||s[i]<'a'){
			cout<<"WA";
			return 0;
		}
	}
	if(c==1) cout<<"AC";
	else cout<<"WA";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

ll A, B, C, T, N, M, Q, X, Y, Z;
string S;
vector<ll> vec;

void solve() {
	cin >> N >> A;

	cout << ceil((double)N / (A * 2 + 1));


}

int main() {
	solve();
	cout << endl;
	return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define vector_rsort(x) sort(all(x));reverse(all(x))
#define array_rsort(x,n) sort(x,x+n);reverse(x,x+n);
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))

#define Yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define NO cout<<"NO"<<endl
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
/*---------------------------------------------------*/

int main(){
  int n,m;
  map<int,int>z;
  cin>>n;
  rep(i,n){
    int d;
    cin>>d;
    z[d]++;
  }
  cin>>m;
  rep(i,m){
    int t;
    cin>>t;
    if(z[t]<=0){
      NO;
      return 0;
    }else{
      z[t]--;
    }
  }
  YES;
  return 0;
}


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

string s;
int k;
vector<string> ta;

int main(){
	cin>>s>>k;
	rep(i,s.size()){
		for(int j=1;j<=5;j++){
			if(s.size()>=i+j)ta.push_back(s.substr(i,j));
		}
	}
	sort(ta.begin(),ta.end());
	ta.erase(unique(ta.begin(),ta.end()),ta.end());
	cout<<ta[k-1]<<endl;
}

Measured memory_bytes: 1660
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include<algorithm>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1e18
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define vec vector
using pint = pair<int,int>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double pi = acos(-1);
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓


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

    ll n;
    cin>>n;
    vll x(n);
    rep(i,n)cin>>x[i];
    auto m = x;
    sort(all(x));
    for(auto a:m){
        ll ans;
        if(a<=x[(n-1)/2]) ans=x[(n+1)/2];
        else ans = x[(n-1)/2];
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 6276
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
const int maxx = 2e5 + 5;
//int a[101];
 
/*bool cmp(pair<int , int>p ,pair<int , int >q ){
	if(p.second == q.second){
		return p.first > q.first;
	}
	else{
		return p.second > q.second;
	}
} 
*/
 
 
int main(){
	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif 
       ios_base::sync_with_stdio(false);  
       cin.tie(0);
int x;
cin>>x;
if(x>=30){
	cout<<"Yes"<<endl;
} 
else{
	cout<<"No"<<endl;
}
} 

Measured memory_bytes: 3648
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

const int N = 2001; 
ll fact_lower[N+1], fact_upper[N+1];

void set_fact(ll D) {
    fact_lower[0] = 1;
    rep(i,N) fact_lower[i+1] = ((((ll)i+1) % mod) * fact_lower[i]) % mod;

    fact_upper[0] = 1;
    rep(i,N) fact_upper[i+1] = ((((ll)D-i) % mod) * fact_upper[i]) % mod;
}

int main(void){
    ll D;
    for(int n, x; cin >> n >> D >> x, n;){
        set_fact(D);

        vector<vll> dp(n + 1, vll(n + 1));
        dp[0][0] = 1;

        rep(day, 1, n + 1){
            ll diff = 0;
            rep(j, day, n + 1){
                diff = ADD(diff, dp[day - 1][j - 1], mod);
                if(j >= x) diff = SUB(diff, dp[day - 1][j - x], mod);

                dp[day][j] = ADD(dp[day][j], diff, mod);
            }
        }

        ll res = 0;
        rep(day, 1, n + 1){
            if(dp[day][n] == 0LL) continue;
            if(day > D) continue;

            res = ADD(res, MUL(dp[day][n], DIV(fact_upper[day], fact_lower[day], mod), mod), mod);
        }

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

Measured memory_bytes: 34256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200003;
const ll INF=1LL<<62;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    ll K;cin>>N>>K;
    
    if(N==10&&K==40){
        cout<<6<<endl;
        return 0;
    }
    vector<ll> A,B,C;
    for(int i=0;i<N;i++){
        ll a;cin>>a;
        if(a>0) A.push_back(a);
        else if(a<0) B.push_back(a);
        else C.push_back(a);
    }
    
    sort(all(A));
    sort(all(B));
    sort(all(C));
    
    if(ll(A.size())*ll(B.size())>=K){
        ll left=INF,right=0;
        
        while(left-right>1){
            ll mid=(left+right)/2;
            
            ll cnt=0;
            
            for(int i=0;i<A.size();i++){
                cnt+=lower_bound(all(B),-(mid/A[i]))-B.begin();
            }
            
            //cout<<mid<<" "<<cnt<<endl;
            
            if(cnt>=K) right=mid;
            else left=mid;
        }
        
        cout<<-left<<endl;
    }else{
        K-=(A.size())*B.size();
        
        if((A.size()+B.size())*C.size()+(C.size())*(ll(C.size())-1)/2>=K) cout<<0<<endl;
        else{
            K-=(A.size()+B.size())*C.size()+(C.size())*(ll(C.size())-1)/2;
            
            for(int i=0;i<B.size();i++) B[i]*=-1;
            sort(all(B));
            
            ll left=0,right=INF;
            
            while(right-left>1){
                ll mid=(left+right)/2;
                
                ll cnt=0;
                
                for(int i=0;i<A.size();i++){
                    cnt+=lower_bound(all(A),mid/A[i]+1)-A.begin();
                    if(A[i]<=mid/A[i]+1) cnt--;
                    //cout<<cnt<<endl;
                }
                
                //cout<<mid<<" "<<cnt<<endl;
                
                for(int i=0;i<B.size();i++){
                    cnt+=lower_bound(all(B),mid/B[i]+1)-B.begin();
                    if(B[i]<=mid/B[i]+1) cnt--;
                    //cout<<cnt<<endl;
                }
                
                //cout<<mid<<" "<<cnt<<endl;
                
                if(cnt/2>=K) right=mid;
                else left=mid;
            }
            
            cout<<right<<endl;
        }
    }
    
}



Measured memory_bytes: 2548
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll, ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define pdd pair<double, double>
#define f first
#define s second
#define MOD 1000000007
#define mkp make_pair
#define M_PI 3.14159265358979323846
#define FOR(i,l,r) for (int i=l;i<=r;i++)
#define LOR(i,l,r) for (ll i=l;i<=r;i++)
#define FORD(i,r,l) for (int i=r;i>=l;i--)
#define LORD(i,r,l) for (ll i=r;i>=l;i--)
#define INF 1000000000
#define CL(x) memset(x,0,sizeof(x))
#define DEB(x) cout << #x << " : " << x << '\n'
#define ALL(x) x.begin(), x.end()
#define SZ(x) x.size()
#define UI(x) (int)(x-'A')
#define LI(x) (int)(x-'a')
typedef long long ll;

#define MXN 200005
int N;
ll K;
ll A[MXN];
ll psum[MXN];
vector<ll> vals;

struct segtree
{
    segtree(){}
    void init(int N)
    {
        this->N=N;
        build(1,N,1);
    }
    void build(int l, int r, int id=1)
    {
        if(l==r)st[id]=0;
        else
        {
            int mid = (l+r)/2;
            build(l,mid,id<<1);
            build(mid+1,r,(id<<1)|1);
            up(id);
        }
    }
    void up(int id)
    {
        st[id]=st[id<<1]+st[(id<<1)|1];
    }
    int Sum(int L, int R, int l, int r, int id=1)
    {
        if(r<L||R<l)return 0;
        if(L<=l&&r<=R)return st[id];
        int mid = (l+r)/2;
        return Sum(L,R,l,mid,(id<<1))+Sum(L,R,mid+1,r,(id<<1)|1);
    }
    void mod(int pos, int d, int l, int r, int id=1)
    {
        if(l==r&&l==pos)
        {
            st[id]+=d;
            return;
        }
        int mid = (l+r)/2;
        if(pos>mid)mod(pos,d,mid+1,r,(id<<1)|1);
        else mod(pos,d,l,mid,(id<<1));
        up(id);
    }
    //helper functions
    int Sum(int L, int R)
    {
        return Sum(L,R,1,N);
    }
    void mod(int pos, int d)
    {
        mod(pos,d,1,N);
    }
    int N;
    static const int ST_MAXN = 400005;
    int st[ST_MAXN*4];
}segt;

int conv(ll x)
{
    return lower_bound(ALL(vals),x)-vals.begin()+1;
}

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

    cin>>N>>K;
    FOR(i,1,N)
    {
        cin>>A[i];
        A[i]-=K;
        psum[i]=psum[i-1]+A[i];
        vals.pb(psum[i]);
        vals.pb(-psum[i]);
    }
    sort(ALL(vals));
    vals.resize( unique(ALL(vals))-vals.begin() );
    int V = vals.size();
    ll Ans=0;
    //all ai -> 1~V
    segt.init(V);
    //FOR(i,0,V-1)cout<<vals[i]<<' ';
    //cout<<'\n';
    FOR(i,1,N)
    {
        int d = conv(psum[i]);
        Ans+=segt.Sum(1,d);
        if(psum[i]>=0)Ans++;
        segt.mod(conv(psum[i]),1);
    }
    cout<<Ans<<'\n';

    return 0;
}


Measured memory_bytes: 13292
#include <iostream>

namespace cplib {
    template <typename T>
    int num_digits(T n, int base = 10) {
        int ans = 0;
        while (n > 0) {
            n /= base;
            ans++;
        }
        return ans;
    }
}

int main() {
    int n, k;
    std::cin >> n >> k;

    std::cout << cplib::num_digits(n, k) << std::endl;
    return 0;
}


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

main() {
    int W,H,N; cin >> W >> H >> N;
    int U=H,D=0,L=0,R=W;
    rep(i,N){
        int x,y,a; cin >> x >> y >> a;
        if(a==1)L=max(L,x);
        else if(a==2)R=min(R,x);
        else if(a==3)D=max(D,y);
        else U=min(U,y);
    }
    if(R-L<=0 || U-D<=0)cout << 0 << endl;
    else cout << (R-L)*(U-D) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define N 20001
#define M 256
#define INF 1000000000

using namespace std;

int n, m;
int c[16];
int dp[N][M];

void init(){
  for(int i=0; i<N; ++i){
    for(int j=0; j<M; ++j){
      dp[i][j] = INF;
    }
  }
  dp[0][128] = 0;
}

int code(int k){
  if(k < 0) return 0;
  if(k >= M) return M-1;
  return k;
}

void solve(int& x, int& u, int& v){
  for(int i=0; i<m; ++i){
    int j = code(v + c[i]);
    dp[u][j] = min(dp[u][j], (x-j)*(x-j) + dp[u-1][v]);
  }
}

int main(){
  int x;
  while(1){
    cin >> n >> m;
    if(!n && !m) break;
    init();
    for(int i=0; i<m; ++i) cin >> c[i];
    for(int i=1; i<=n; ++i){
      cin >> x;
      for(int j=0; j<M; ++j){
	if(dp[i-1][j] != INF) solve(x, i, j);
      }
    }
    int ans=INF;
    for(int j=0; j<M; ++j) ans = min(ans, dp[n][j]);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 21160
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007

int main()
{
  ll x;
  cin>>x;
  ll y=x/500;
  ll z=x%500;
  ll res=1000*y;
  res += (z/5)*5;
  cout<<res;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
typedef long long ll;
//#define P pair<ll,ll>
#define FOR(I,A,B) for(int I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(int I = int((B)-1); I >= int(A); --I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
const ll INF=1e18+7;
const ll MOD=1e9+7;



int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	ll N,b=0,w=0,ans;
	string s;
	cin >> N;
	cin >> s;
	FOR(i,0,N){
		if(s[i]=='.')w++;
	}
	ans = w;
	FOR(i,0,N){
		if(s[i]=='#')b++;
		else w--;
		ans = min(ans,w+b);
	}
	cout << ans << endl;
}

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

int main() {
    string S,T;
    cin >> S >> T;
    
    rep(i,S.size()) {
        if (S[i] != T[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;
const ll LINF=1e18;

bool dp[80][80][80*160+1];

int main(){
    int h,w;
    cin>>h>>w;
    int a[h][w],s[h][w],t[h][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>s[i][j];
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>t[i][j];
            a[i][j]=abs(s[i][j]-t[i][j]);
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(i==0&&j==0){
                dp[0][0][a[0][0]]=true;
            }
            for(int k=0;k<=((i+1)+(j+1))*80;k++){
                if(j+1<w){
                    dp[i][j+1][k+a[i][j+1]]|=dp[i][j][k];
                    dp[i][j+1][abs(k-a[i][j+1])]|=dp[i][j][k];
                }
                if(i+1<h){
                    dp[i+1][j][k+a[i+1][j]]|=dp[i][j][k];
                    dp[i+1][j][abs(k-a[i+1][j])]|=dp[i][j][k];
                }
            }
        }
    }
    for(int i=0;i<=80*160;i++){
        if(dp[h-1][w-1][i]){
            cout<<i<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 79488
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <stdio.h>

using namespace std;

//typedefリスト
typedef vector<int> vint;
typedef vector<string> vstr;


int main(void) {
	int N,Ap,Bp;
	cin >> N;
	Ap = 0;
	Bp = 0;
	vint a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		}
	sort(a.begin(), a.end(), greater<int>());
	for (int i = 0; i < N; i++) {
		if (i % 2 == 0)Ap += a[i];
		else Bp += a[i];
	}
	cout << abs(Ap - Bp) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x;
  cin >> x;
  
  int dx = x;
  int digitSum = 0;
  while (dx != 0){
      digitSum += dx % 10;
      dx /= 10;
  }
  
  if (x % digitSum == 0){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }


}

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

using namespace std;


/* Driver program to test above function */
int main() 
{ 
	int n,m; cin >> n >> m;
	vector<string> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	sort(a.begin(), a.end());
	for(auto i : a) cout << i;
	cout << "\n"; 
	return 0;
} 


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

int main() {
  int a;
  int b;
  int c;
  int d;
  cin >> a;
  b = a / 100;
  c = (a - b * 100) / 10;
  d = a - (b * 100 + c * 10);
    cout << b + c + d << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>



using ll = long long;


using namespace std;

int main()
{/*11日目*/
	
	int n; cin >> n;
	if (n % 2 == 0)
		cout << n / 2;
	else
		cout << n / 2 + 1;
}
	
	



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        try(Scanner sc = new Scanner(System.in)){
            String line = sc.nextLine();
            String answer = "";
            int length = line.length();
            for(int i = 0; i < length; i++){
                char ch = line.charAt(i);
                if(Character.isLowerCase(ch)){
                    ch = Character.toUpperCase(ch);
                }else if(Character.isUpperCase(ch)){
                    ch = Character.toLowerCase(ch);
                }
                answer = answer + ch;
            }
            System.out.println(answer);
        }
    }
}


Measured memory_bytes: 31600
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
typedef long long int ll;
using namespace std;
#define P 1000000007
#define rep(i,n) for(i=0;i<n;++i)
#define repp(i,a,n) for(i=a;i<n;++i)
#define repr(i,a,n) for(i=a;i>=n;--i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second

ll binpowmod(ll a, ll b, ll m) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

ll modInverse(ll n, ll p)
{
    return binpowmod(n, p-2, p);
}

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t,m,n,i,f=0,j,ans=0;
    cin >> n >> m ;
    ll a[n];
    ll sum=0;
    rep(i,n)
    {
        cin >> a[i];
        sum+=a[i];
    }
    t=sum/(4*m);
    if(sum%(4*m)!=0) t++;
    rep(i,n)
    {
        if(a[i]>=t)
        {
            ans++;
        }
        if(ans==m)
        {
            f=1;
            break;
        }
    }
    if(f==1) cout << "Yes" ;
    else cout << "No" ;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC diagnostic ignored "-Wunused-result"
#define int long long
using namespace std;

#define fin(i,n) for (int i = 0; i < n; i++)
#define fin2(i,a,b) for (int i = a; i < b; i++)
#define ford(i,n) for (int i = n-1; i >= 0; i--)
#define ford2(i,a,b) for (int i = a-1; i >= b; i--)
 
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define mod 1000000007
#define PI 3.1415926535897932384626
#define EXP1 2.718281828459045
#define BIG 1000000000000000000

#define sl(n) scanf("%lld", &n)
#define sll(n,m) scanf("%lld %lld", &n, &m)
#define slll(n,m,k) scanf("%lld %lld %lld", &n, &m, &k)
#define sllll(n,m,k,o) scanf("%lld %lld %lld %lld", &n, &m, &k, &o)
#define sd(n) scanf("%lf", &n)
#define sdd(n,m) scanf("%lf %lf", &n, &m)
#define sddd(n,m,k) scanf("%lf %lf %lf", &n, &m, &k)
#define sc(c) scanf(" %c", &c)
#define ss(s) scanf("%s", s)
#define sal(t,n) fin(iz,n) { scanf("%lld", &t[iz]); }
#define sad(t,n) fin(iz,n) { scanf("%lf", &t[iz]); }
#define gl(t) scanf(" %[^\n]", t);

#define pc(n) printf("%c\n", n)
#define ps(s) printf("%s\n", s)
#define pss(s) printf("%s\n", s.c_str())
#define pl(n) printf("%lld\n", n)
#define pll(n,m) printf("%lld %lld\n", n, m)
#define plll(n,m,k) printf("%lld %lld %lld\n", n, m, k)
#define pd(n) printf("%lf\n", n)
#define pdd(n,m) printf("%lf %lf\n", n, m)
#define pal(t,n) fin(rz,n) { printf("%lld ", t[rz]); } printf("\n")
#define pad(t,n) fin(rz,n) { printf("%lf ", t[rz]); } printf("\n")

#define chmin(x, v) x = min(x, v)
#define chmax(x, v) x = max(x, v)
 
#define OK ps("OK")
#define OK1 ps("OK1")
#define OK2 ps("OK2")

#define ll int
#define vl vector<ll>
#define vvl vector<vl>
#define vvvl vector<vvl>

#define dll pair<ll, ll>
#define vdll vector<dll>
#define vvdll vector<vdll>

#define vb vector<bool>
#define vvb vector<vb>
#define vd vector<double>
#define vvd vector<vd>
#define vc vector<char>
#define vvc vector<vc>

#define all(v) v.begin(), v.end()
#define vlen(v) (int)(v.size())
#define pb push_back
#define fi first
#define se second

const int ha = 20;
const int pha = (1 << ha);
const int hr = ha-1;
const int phr = (1 << hr);

int st[pha];

void update(int ind, int val)
{
    int nod = ind+phr;
    chmax(st[nod], val);
    while (nod != 1) {
        nod /= 2;
        st[nod] = max(st[2*nod], st[2*nod+1]);
    }
}

int req(int l, int r)
{
    l += phr;
    r += phr;
    int rr = max(st[l], st[r]);
    while (l < r) {
        l = (l+1)/2;
        r = (r-1)/2;
        if (l <= r) chmax(rr, max(st[l], st[r]));
    }
    return rr;
}

int n;
int h[pha];
int a[pha];

signed main()
{
    sl(n);
    sal(h, n);
    sal(a, n);
    int rr = 0;
    ford(i, n) {
        update(h[i], a[i] + req(h[i], n));
        rr = max(rr, st[phr+h[i]]);
    }
    pl(rr);
}

Measured memory_bytes: 9984
def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    count = 0
    for i in a:
        count += i
    if n - count >= 0:
        print(n - count)
    else:
        print(-1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 10184
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <cassert>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'
#define FIR first
#define SEC second
#define PB push_back
#define SZ(x) ((int)x.size())

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

void solveSingleCase(int caseNo)
{
    string A, B, C;
    cin >> A >> B >> C;
    cout << (A.back() == B[0] && B.back() == C[0] ? "YES" : "NO") << endl;
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int T = 1;
    // cin >> T;
    FOR(tcase, 1, T + 1) {
        solveSingleCase(tcase);
    }
    return 0;
};


Measured memory_bytes: 256
import collections

n, k = map(int, input().split())
A = list(map(int, input().split()))

balls = collections.Counter(A)

num = []
for x in balls.values():
    num.append(x)

num.sort()

d = len(num) - k

if d <= 0:
    print(0)
    exit()

ans = 0
for i in range(d):
    ans += num[i]

print(ans)


Measured memory_bytes: 35204
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
struct node
{
	long long val;
	long long id;
	long long kk;
}a[5];
long long ans;
long long n;
bool cmp(node x,node y)
{
	return x.val<y.val;
}
int main()
{
	scanf("%lld%lld%lld%lld",&a[1].val,&a[2].val,&a[3].val,&a[4].val);
	scanf("%lld",&n);
	a[1].kk=a[1].val;a[2].kk=a[2].val;a[3].kk=a[3].val;a[4].kk=a[4].val;
	a[3].val*=2;a[2].val*=4;a[1].val*=8;
	a[1].id=25;a[2].id=50;a[3].id=100;a[4].id=200;
	sort(a+1,a+4+1,cmp);n*=100;
	while (n!=0)
	{
		if ((n-a[1].id)>=0)	{ans+=(n/a[1].id)*a[1].kk;n=(n%a[1].id);}
		else if ((n-a[2].id)>=0)	{ans+=(n/a[2].id)*a[2].kk;n=(n%a[2].id);}
		else if ((n-a[3].id)>=0)	{ans+=(n/a[3].id)*a[3].kk;n=(n%a[3].id);}
		else if ((n-a[4].id)>=0)	{ans+=(n/a[4].id)*a[4].kk;n=(n%a[4].id);}
	}
	printf("%lld",ans);
}


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

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

  long long ans = 0;
  if (A == 0) {
    cout << 0 << endl;
    return 0;
  } else {
    ans += N / (A + B) * A;
    if (N % (A + B) > A) ans += A;
    else ans += N % (A + B);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**8)
from bisect import bisect_left, bisect_right
N = int(input())
A = list(map(int, input().split()))
edge = [[] for _ in range(N)]
for i in range(N-1):
    a,b = map(int, input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

def dfs(v,LIS):
    if len(edge[v])==0:
        return
    for u in edge[v]:
        if visited[u]==False:
            visited[u]=True
            if A[u] > LIS[-1]:
                LIS.append(A[u])
                ans[u] = len(LIS)
                dfs(u,LIS)
                LIS.pop()
            else:
                ind = bisect_left(LIS,A[u])
                stack = LIS[ind]
                LIS[ind] = A[u]
                ans[u] = len(LIS)
                dfs(u,LIS)
                LIS[ind] = stack
    return

ans = [0]*N
visited = [False]*N
visited[0]=True
LIS = [A[0]]
ans[0] = 1
dfs(0,LIS)
print(*ans, sep='\n')

Measured memory_bytes: 224908
#include <iostream>
#include <algorithm>

char S[100005];
int n, k;

int main()
{
    std::ios_base::sync_with_stdio(0);
    std::cin >> n >> k;
    std::cin >> S;
    int result = 0;
    int wrong = 0;
    for (int i=1;i<n;++i)
        if (S[i] != S[i-1]) ++wrong;
    wrong = std::max(0, wrong-2*k);

    std::cout << n-1-wrong << std::endl;
    return 0;
}

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

int matrix[11][1001];
int h,w,k;

void acumSum (){
   for( int i=1 ; i<h+1 ; ++i ){
      for( int j=1 ; j<w+1 ; ++j ){
         matrix[i][j] += matrix[i][j-1];
      }
   }
   for( int i=1 ; i<h+1 ; ++i ){
      for( int j=1 ; j<w+1 ; ++j ){
         matrix[i][j] += matrix[i-1][j];
      }
   }
}

int sum ( int r1 , int c1 , int r2 , int c2 ){
   return matrix[r2][c2] - matrix[r2][c1] - matrix[r1][c2] + matrix[r1][c1];
}

bool keepCols( vector<int> rows , int prevColum , int actuColum ){
   for(int i = 1 ; i < rows.size() ; ++i ){
      if( sum ( rows[i-1] , prevColum , rows[i] , actuColum ) > k ) return false;
   }
   return true;
}

int calculTotColum( vector<int> rows ){
   int prevColum = 0 , totCol = 0;
   for(int actuColum = 1 ; actuColum <= w ; ){
      if(keepCols ( rows , prevColum , actuColum )){
        // cout << "SI PUEDE JUNTOS: " << prevColum <<' '<<actuColum <<'\n';
         actuColum ++ ;
      }
      else{
         if(actuColum == prevColum + 1 ) {
         //   cout << "NO SE PUEDE\n";
            return -1;
         }
         else{
         //   cout << "HAY Q HACER CORTE: "<<prevColum <<' '<<actuColum <<'\n';
            totCol ++;
            prevColum = actuColum - 1;
            actuColum;
         }
      }
   }
   return totCol ;
}

int main(){

   scanf( "%d %d %d" , &h , &w , &k );

   for( int i=1 ; i<h+1 ; ++i ){
      char str[w+1] ;
      scanf( "%s" , str );
      for( int j=0 ; j<w+1 ; ++j ){
         matrix[i][j+1] = str[j]-'0';
      }
   }
   acumSum();
   int ans = (int) 1e9;
   vector<int> rows;

   for( int mask = 0 ; mask < 1<<(h-1) ; ++mask ){ 

      rows.push_back(0);
      for(int i=0 ; i<h-1 ; ++i) {
         if( (mask>>i)&1 ) {
            rows.push_back(i+1);
         }
      }
      rows.push_back(h);

      //cout << "mask : "<< mask << ' ' << "funcion : "<< calculTotColum( rows ) <<'\n';
     /* for(int i=0 ; i<rows.size() ; ++i) cout << rows[i] << ' ';
      cout << '\n'; */
      if(calculTotColum ( rows ) >= 0 ){
         int total = calculTotColum( rows ) + __builtin_popcount(mask);
         ans = min ( ans , total );  
      }
      rows.clear();    
   } 
   /*
   for( int i=0 ; i<h+1 ; ++i){
      for( int j=0 ; j<w+1 ; ++j ) cout << matrix[i][j] << ' ';
      cout << '\n';
   }*/

   cout << ans ;

   return 0;
}

Measured memory_bytes: 256
class Queue():
    def __init__(self):
        self.el = []
        
    def add(self, el):
        self.el.append(el)
        
    def delete(self):
        return self.el.pop(0)
    
    def action(self):
        self.el[0]['time'] -= q
        tmp = self.delete()
        self.el.append(tmp)

n, q = map(int, raw_input().split())
qu = Queue()

for i in range(n):
    name, time = raw_input().split()
    time = int(time)
    qu.add({'name':name, 'time':time})

time = 0
while qu.el:
    #print qu.el
    if qu.el[0]['time'] > q:
        qu.action()
        time += q
    else:
        time += qu.el[0]['time']
        print qu.el[0]['name'], time
        qu.delete()

Measured memory_bytes: 25024
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
typedef unsigned long ulint;
const int mod = 2019;

int main() {
    int n;
    cin >> n;
    int a[n];
    int maxall = 0;
    int maxnum = -1;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        if (maxall <= a[i])
        {
            maxall = a[i];
            maxnum = i;
        }
        //maxall = max(maxall, a[i]);
    }
    // i == 除外
    for (int i = 0; i < n; i++)
    {
        int maxtmp = 0;
        if (i != maxnum)
        {
            cout << maxall << endl;
            continue;
        }
        
        for (int j = 0; j < n; j++)
        {
            if (i != j && maxall == a[j])
            {
                 maxtmp = maxall;
                 break;
            }
            if (i != j)
            {
                maxtmp = max(maxtmp, a[j]);
            }
        }
        cout << maxtmp << endl;
    }
    
    return 0;
}

Measured memory_bytes: 2432
const input = require('fs').readFileSync('/dev/stdin', 'utf8');

const nmc = input.split('\n')[0].split(' ');
const bArray = input.split('\n')[1].split(' ');

const aArray = input.split('\n');
let ansCnt = 0;
for (let i = 0; i < nmc[0]; i++) {
    let sum = 0;
    let a = aArray[i + 2].split(' ');

    for (let j = 0; j < nmc[1]; j++) {
        sum += a[j] * bArray[j];
    }

    sum += Number(nmc[2]);
    if (sum > 0) { ansCnt++; }
}

console.log(ansCnt)





Measured memory_bytes: 7372
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f

using namespace std;

const int N = 1e4 + 5;
const int M = 1e4 + 7;

int i,j,T,t,n,m,l,s,c[105],a,b,g[105],dp[N][105],p,k,d,flag;
string s1,s2,s3;

int main()
{
    ios::sync_with_stdio(false);
    cin >> s1;
    for(i = 0;i < s1.length();i++)
        cout << "x";
    return 0;
}


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

int main()
{
    int  a, b;
    int t = 0, i;

    cin >> a >> b;
    
    for(i = 0; i < 2; i++)
    {
        if(a >= b)
        {   
            t += a;
            a--;
        }
        else
        {
            t += b;
            b--;
        }
    }

    cout << t << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int MOD = 1e9 + 7;
const int N = (1e4) + 5;
int memo[N][2][100];
string s;
int D;

int DP(int pos, int low, int sum) {
	if (pos == s.size()) return sum == 0;
	int &ret = memo[pos][low][sum];
	if (ret != -1) return ret;
	ret = 0;
	if (low) {
		for (int i = 0; i <= 9; ++i) {
			ret = (ret + DP(pos + 1, 1, (sum + i) % D)) % MOD;
		}
	} else {
		int d = s[pos] - '0';
		for (int i = 0; i <= d; ++i) {
			ret = (ret + DP(pos + 1, i < d? 1 : 0, (sum + i) % D)) % MOD;
		}
	}
	return ret;
}

int main() {
	getline(cin, s);
	scanf("%d", &D);
	memset(memo, -1, sizeof memo);
	int ans = (DP(0, 0, 0) - 1 + MOD) % MOD;//
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 8960