akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define REV(x) reverse(ALL((x)))
#define eb emplace_back

int main()
{
    ll N;
    cin >> N;
    vec A(N);
    REP(i,0,N) cin >> A[i];

    REV(A);

    vec dp;
    REP(i,0,N) {
        ll k = upper_bound(ALL(dp), A[i]) - dp.begin();
        if(k >= SZ(dp)) dp.eb(A[i]);
        else dp[k] = A[i];
    }

    PR(SZ(dp));

    return 0;
}

/*



*/

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

int main() {

  int K, N;
  cin >> K >> N;

  int tmp1, tmp2, first;
  int max = 0;
  cin >> first;
  tmp2 = first;
  for(int i = 1; i < N; i++){
    cin >> tmp1;
    if(tmp1 - tmp2 > max){
      max = tmp1 - tmp2;
    }
    tmp2 = tmp1;
  }
  if(K + first - tmp2 > max){
    max = K + first - tmp2;
  }
  cout << K - max << endl;
}

Measured memory_bytes: 256
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <signal.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")

#define getchar getchar_unlocked
#define putchar putchar_unlocked
int32_t nextint(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); bool s=false; if(c=='-'){s=true;c=getchar();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); int s=0; if(c=='-'){s=1;c=getchar();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar(); while(c==' '||c=='\n') c=getchar(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar(); } *s='\0'; return len; }
void rsorta_d32(void *base, const int count, const int size, const int index){
	typedef int32_t rsort_t;
	rsort_t (*a)[size] = (rsort_t(*)[size])base;
	rsort_t (*b)[size] = (rsort_t(*)[size])malloc(count*size*sizeof(rsort_t));
	int c[0x100];
	for(int k=0; k<4; k++){
		memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i][index]>>(k<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ int to=--c[(a[i][index]>>(k<<3))&0xFF]; for(int j=0; j<size; j++){ b[to][j]=a[i][j]; } }{rsort_t(*t)[size]=a; a=b; b=t;}
	}
	free(b);
}

int m;
int dat[1048510];

void init(int n){
	m=1;
	while(m<n) m*=2;
}

void update(int k, int x){
	k+=m-1;
	int d=x-dat[k];
	dat[k]=x;
	while(k>0){
		k=(k-1)/2;
		dat[k]+=d;
	}
}

// q(a, b, 0, 0, m)
// [a, b)
int query(int a, int b, int k, int l, int r){
	if(r<=a || b<=l) return 0;
	if(a<=l && r<=b) return dat[k];
	int m=(l+r)/2;
	int vl = query(a, b, k*2+1, l, m);
	int vr = query(a, b, k*2+2, m, r);
	return vl+vr;
}

int c[500000];
int k[500000];
int s[500000][4];
int main(void){
	int n=nextint();
	int q=nextint();
	for(int i=0; i<n; i++){
		c[i]=nextint()-1;
		k[i]=-1;
	}
	for(int i=0; i<q; i++){
		s[i][0]=i;
		s[i][2]=nextint()-1;
		s[i][3]=nextint();
	}
	init(n);
	rsorta_d32(s, q, 4, 3);
	int j=0;
	for(int i=0; i<n; i++){
		if(k[c[i]]>=0) update(k[c[i]], 0);
		k[c[i]]=i;
		update(i, 1);
		while(j<q && s[j][3]==i+1){
			s[j][1]=query(s[j][2], s[j][3], 0, 0, m);
			j++;
		}
	}
	rsorta_d32(s, q, 4, 0);
	for(int i=0; i<q; i++){
		printf("%d\n", s[i][1]);
	}
}


Measured memory_bytes: 27012
/**
 *   created: 28 April 2019  23:46:46
**/
#include<bits/stdc++.h>
using namespace std;

typedef vector<int> vi;
typedef pair<int , int> pii;
typedef vector< pair<int , int> > vii;
typedef long long ll;
typedef vector<long long> vl;
typedef pair<long long , long long> pll;
typedef vector< pair<long long , long long> > vll;

#define PB push_back
#define PPB pop_back
#define all(c) (c).begin,(c).end()
#define rep(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
// #define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define INFLL 2000000000000000007
#define INF 2000000007
#define MOD 1000000007


#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif


void optimizeIO()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

//                                        //AUTHOR: Kaushalesh Shukla

//=========================================================================================================

int main()
{
	// optimizeIO();
	int tc=1;
	// cin>>tc;
	for(int tt=0;tt<tc;tt++){
		int n,m,c;
		cin>>n>>m>>c;
		int arr[n][m],ar[m];
		rep(i,0,m)
			cin>>ar[i];
		rep(i,0,n){
			rep(j,0,m)
				cin>>arr[i][j];
		}
		int res=0;
		rep(i,0,n){
			int temp=0;
			rep(j,0,m){
				temp += arr[i][j]*ar[j];
			}
			temp += c;
			if(temp>0)
				res++;
		}
		cout<<res;
	}
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(ll)(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  st a,b,c;
  	ci(a>>b>>c);
  ll A=a.sz,B=b.sz;
  if(a[A-1]==b[0]&&b[B-1]==c[0]) co("YES")
    else co("NO")
    }

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

int main(){
	 int h,w,n;
	 cin>>h>>w;
	 vector<vector<int>> grid(h,vector<int>(w));
	 cin>>n;
	 vector<int> colors(n+1);

	 for(int i=1;i<=n;i++) cin>>colors[i];

	 	int row = 0;
	    int col = 0;
	 	for(int c=1;c<=n;c++){
	 		//cout<<"colors:"<<c<<endl;
	 		int curr = 0;
	 		while(row<h){
	 		//cout<<"colors:"<<c<<endl;

	 		//if(c>1) return 0;
	 			   if((row+1)%2){
	 				    while(col<w){
	 				    //	cout<<"row:"<<row<<endl;
	 		//cout<<"curr:"<<curr<<endl;
	 						grid[row][col] = c;
	 						//cout<<row<<" "<<col<<" "<<c<<endl;
	 						curr++;
	 						col++;
	 						if(curr == colors[c]) break;
	 			   		}
	 		    	} else {
	 		    		while(col>=0){
	 						//cout<<row<<" "<<col<<" "<<c<<endl;
	 		    			grid[row][col] = c;
	 		    			curr++;
	 		    			col--;
	 		    			if(curr == colors[c]) break;
	 		    		}
	 		    	} 
	 		    	if(col == w){ row++;col--;}
	 		    	if(col < 0) {row++;col = 0;}
	 		    	if(colors[c] == curr) break;
	 		}
	 	}

	 	for(int i=0;i<h;i++){
	 		for(int j=0;j<w;j++){
	 			cout<<grid[i][j]<<" ";
	 		}
	 		cout<<endl;
	 	}
}

Measured memory_bytes: 384
from heapq import heappush, heappop
 
N,M = map(int,input().split())

allhiyatoi = [[] for j in range(M+1)]
for i in range(N):
    temp = list(map(int,input().split()))
    if temp[0] > M:
        continue
    allhiyatoi[temp[0]].append(temp[1])
 
reward = 0
Q = []
for i in allhiyatoi:
    for j in i:
        heappush(Q,j*-1)
    if len(Q) == 0:
        continue
    reward -= (heappop(Q))

print(reward)

Measured memory_bytes: 23748
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define eps 1e-9
#define inf 0x3f3f3f
#define mod 4999999
using namespace std;
 
int main() {
	speed;
    int n;
    cin >> n;
    cout << (1000 - n % 1000) % 1000;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#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 all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

typedef long long ll;

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 998244353;

const double PI = acos(-1.0);

ll modpow(ll a, ll n, int mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    int N;
    cin>>N;
    vector<ll> D(N),C(N,0);
    rep(i,N){
        cin>>D[i];
        C[D[i]]++;
    }
    if(D[0] != 0){
        cout<<0<<endl;
        return 0;
    }
    rep1(i,N){
        if(D[i] == 0){
            cout<<0<<endl;
            return 0;
        }
    }
    sort(all(D));
    rep(i,N-1){
        if(D[i+1]-D[i]>1){
            cout<<0<<endl;
            return 0;
        }
    }
    ll ans = 1;
    rep(i,N-1){
        ans *= modpow(C[i],C[i+1],MOD);
        ans %= MOD;
    }
    cout<<ans<<endl;
}

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

int main()
{
    int A,B,C,X,Y;
    cin >> A >> B >> C >> X >> Y;

    long long ans = 0;
    if(A + B > 2*C) {
        ans += min(X, Y)*2*C;
        int tmp = min(X, Y);
        X -= tmp; Y -= tmp;
    }
    else {
        ans += min(X, Y)*(A + B);
        int tmp = min(X, Y);
        X -= tmp; Y -= tmp;
    }

    if(X == 0) {
        if( B < 2*C ) ans += Y*B;
        else ans += Y*2*C;
    }
    if(Y == 0) {
        if( A < 2*C ) ans += X*A;
        else ans += X*2*C;
    }

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

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

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

    
    int n;
    cin >> n;
    ll b[n-1];
    rep(i,n-1) cin >> b[i];
    
    ll sum = b[0];
    for(int i=1; i<=n-2; i++){
        sum += min(b[i-1], b[i]);
    }
    sum += b[n-2];
    
    
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
use text_io::*;
use std::collections::*;
use std::process::exit;
use std::cmp::max;

fn main() {
    let mut a:usize = read!();
    let mut b:usize = read!();
    if (a+b)%2==0 {
        println!("{}",(a+b)/2);
    }
    else {
        println!("IMPOSSIBLE");
    }
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N;
  cin>>N;
  int sum=0;
  set<int>s;
  for(int i=1;i<=N;i++){
    s.insert(i);
    sum+=i;
    if(sum>=N){
      int d=sum-N;
      if(d)s.erase(s.find(d));
      for(auto x:s)cout<<x<<endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 512
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N, K;
  string S;
  cin >> N >> K >> S;
  vector<int64_t> A(N);
  vector<int64_t> counts;
  int64_t count = 0;
  int64_t pval = 1;
  for (int64_t i = 0; i < N; ++i) {
    const int64_t cval = static_cast<int64_t>(S[i] - '0');
    if (cval == pval) {
      ++count;
    } else {
      counts.emplace_back(count);
      // cerr << " " << count << endl;
      count = 1;
      pval = cval;
    }
  }
  if (count > 0) {
    counts.emplace_back(count);
  }
  if (S[N - 1] == '0') {
    counts.emplace_back(0);
  }
  int64_t result = 0;
  int64_t sum = 0;
  int64_t right = 0;
  for (int64_t left = 0; left < static_cast<int64_t>(counts.size()); left += 2) {
    // cerr << " " << counts[left] << endl;
    while (right <= min(left + K * 2, static_cast<int64_t>(counts.size()) - 1)) {
      // cerr << "aa " << right << endl;
      sum += counts[right];
      ++right;
    }
    // cerr << "  " << sum << endl;
    result = max(result, sum);
    // cerr << " " << counts[left] << " " << counts[left + 1] << endl;
    sum -= counts[left];
    sum -= counts[left + 1];
  }
  cout << result << endl;
  return 0;
}


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

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

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  int n, g = 0, k = 0;
  cin >> n;
  rep(i, 0, n) {
    int a;
    cin >> a;
    if(a % 2) k++;
    else g++;
  }

  if(k % 2 && g) {
    cout << "NO" << endl;
  }else {
    cout << "YES" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
template <class T>
bool chmax(T &a, const T &b)
{
	if (a < b)
	{
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
	if (a > b)
	{
		a = b;
		return 1;
	}
	return 0;
}

ll M = 1000000007;
/*
set<int> divisor(int n)
{
	set<int> value;
	for( int ite=1; (ll)ite*ite<=n;ite++)
	{
		
			if (n % ite == 0)
			{
				value.insert(ite);
				if (ite * ite != n)
				{
					value.insert(n / ite);
				}
			}
		
	}
	return value;
}
*/
bool IsPrime(ll num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

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

    // 素数である
    return true;
}
set<ll> divisor(ll n)
{
	set<ll> value;
	for( ll i=1; i*i<=n;i++)
	{
		
			if (n % i == 0)
			{
				value.insert(i);
				if (i * i != n)
				{
					value.insert(n / i);
				}
			}
		
	}
	return value;
}

void solve()
{
	ll n;
	cin>>n;
	set<ll>div=divisor(n);
	vector<int>prims;
	for(auto i=div.begin(); i!=div.end();i++){
		if(IsPrime(*i)){
			ll tn=n;
			int cnt=0;
			while(tn%*i==0){
				cnt++;
				tn/=*i;
			}
			prims.push_back(cnt);
			
		}
	}
	vector<int>sums(100);
	rep(i,100){
		sums[i]=(i*(i+1))/2;
	}
	ll ans=0;
	rep(i,size(prims)){
		bool yet=true;
		rep(j,100){
			if(prims[i]<sums[j]&& yet){
				ans+=j-1;
				yet=false;
			}
		}
	}
	cout<<ans<<endl;

}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
	return 0;
}


Measured memory_bytes: 3708
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
lis=LI()
mn=inf
for i in range(-100,100+1):
    sm=0
    for s in lis:
        sm+=(s-i)**2
    if sm<mn:
        mn=sm
print(mn)

Measured memory_bytes: 3316
#!/usr/bin/env python3

def main():
    N = int(input())
    Hs = [int(s) for s in input().split()]
    result = 0
    for i, ryokan in enumerate(Hs):
        for i2, syougai in enumerate(Hs):
            if i2 == i:
                result += 1
                break
            if ryokan < syougai:
                break
    print(result)


if __name__ == "__main__":
    main()


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define contains(v, t) (find(v.begin(), v.end(), t) != v.end())
#define MOD 1000000007
using ll = long long;
using ull = unsigned long long;

int main() {
  string s,t;
  cin>>s>>t;
  rep(i, s.length()) {
    s = s[s.length() - 1] + s.substr(0, s.length() - 1);
    if (s == t) {
      cout << "Yes";
      return 0;
    }
  }
  cout << "No";
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<ctime>
#include<vector>
#include<queue>
#include<map>
#include<deque>
#include<stack>
#include<algorithm>
#define N 405
using namespace std;
const int INF=0x7fffffff;
const double Pi=acos(-1);
const long long Mod=1e9+7;
long long A[N],B[N],P[N][N],Sum[N][N],F[N][N];
int main()
{
	int i,j,k,n,m;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++)scanf("%lld",&A[i]);
	for(i=1;i<=n;i++)scanf("%lld",&B[i]);
	for(i=1;i<=400;i++)
	{
		P[i][0]=1;
		for(j=1;j<=400;j++)//P[i][j]=i^j
		{
			P[i][j]=P[i][j-1]*i%Mod;
		}
	}
	for(j=0;j<=400;j++)
	{
		Sum[0][j]=0;
		for(i=1;i<=400;i++)//Sum[i][j]=1^j+2^j+...+i^j 
		{
			Sum[i][j]=(Sum[i-1][j]+P[i][j])%Mod;
		}
	}
	F[0][0]=1;
	for(i=1;i<=n;i++)
	{
		for(j=0;j<=m;j++)
		{
			for(k=0;k<=j;k++)//Ã¶¾ÙµÚi¸öÈË·Ök¸ö 
			{
				long long Temp=(Sum[B[i]][k]-Sum[A[i]-1][k]+Mod)%Mod;
				F[i][j]=(F[i][j]+F[i-1][j-k]*Temp%Mod)%Mod;
			}
		}
	}
	printf("%lld\n",F[n][m]);
	return 0;
}


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

int main(void){

// Your code here!

string s;

cin>>s;

int count=0;

if(s[0]=='o'){

count++;

}
if(s[1]=='o'){

count++;

}
if(s[2]=='o'){

count++;

}

cout<<700+count*100<<endl;

}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define MOD 1000000007
#define ll long long int
bool brokenSteps[100005];
ll dp[100005];
int N;
ll getWays(int currVertex){
    if(currVertex == N){
        return 1;
    }
    if(currVertex > N || brokenSteps[currVertex]){
        return 0;
    }
    if(dp[currVertex] != -1){
        return dp[currVertex];
    }
    ll opt1 = (getWays(currVertex + 1)) % MOD;
    ll opt2 = getWays(currVertex + 2) % MOD;
    dp[currVertex] = (opt1 + opt2) % MOD;
    return dp[currVertex];
}

int main(){
    int M;
    cin >> N >> M;
    for(int i = 0; i < N; i++){
        brokenSteps[i] = false;
    }
    for(int i = 0; i < N; i++){
        dp[i] = -1;
    }
    for(int i = 0; i < M; i++){
        int x;
        cin >> x;
        brokenSteps[x] = true;
    }
    ll numWays = getWays(0);
    cout << numWays << endl;
}

Measured memory_bytes: 4224
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <queue>
#include <vector>
#include <sstream>

#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(int x=from;x<to;x++)

using namespace std;

typedef pair<int,string> mypair;

int main(void){

int n, k, m, h;
mypair ch[10];
bool kg=false;
	while(cin >>n){
		if(n==0 || cin.eof()) break;
		rep(i,n){
			cin >> ch[i].second;
			cin >> k >> m >> h;
			ch[i].first = (k *3 + h *1) * 100 + 50- i;
		}
		sort(ch, ch+n, greater<mypair>());
		if(kg) cout << endl;
		kg=true;
		rep(i,n) cout << ch[i].second << "," << (int)(ch[i].first/100) << endl;
		
	}
	return 0;
	
}

Measured memory_bytes: 1212
def lcm(a,b):
    return a*b//gcd(a,b)
def gcd(a,b):
    if a<b: a,b = b,a
    if b>0:
        return gcd(b,a%b)
    else:
        return a

n = int(input())
ret = int(input())
for i in range(n-1):
    t = int(input())
    ret = lcm(ret,t)
print(ret)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>

#define REP(i,n) for(int i = 0; i < n; i++)
#define ll long long
#define PI 3.141592653589793

using namespace std;

int main(void){
    int a, b, x;
    double y, z;
    cin >> a >> b >> x;

    if(x <= a * a * b /2){
        printf("%.6f",atan((double)a * pow(b,2) / 2 / x) * 180.0 / PI) ;
    } else{
        printf("%.6f",atan((double)2 * b / a - 2 * x / pow(a,3) ) *180.0 / PI);
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){

  string S;  cin >> S;
  for(int i = 0 ; i < 3 ; i++)  cout << S[i];
  cout << 8;
  for(int i = 4 ; i < S.length() ; i++)  cout << S[i];
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <map>
#include <iostream>

using namespace std;
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

int main() {

	long long n; cin >> n;
	map<long long, long long> freq;
	long long ans = 0;
	for (long long i = 1; i <= n; i++) {
		long long hi; cin >> hi;
		ans += freq[i - hi];
		freq[i + hi]++;
	}

	cout << ans;

	return 0;
}

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

int main() {
  string s, t;
  cin>>s>>t;
  map<char, set<int>> cm;
  for (int i=0; i<s.length(); i++) {
    cm[s[i]].insert(i);
  }
  long long cnt = 0;
  int idx = -1;
  for (char c: t) {
    if (cm[c].size() == 0) {
      cout<<-1<<endl;
      return 0;
    }
    auto it = cm[c].upper_bound(idx);
    if (it == cm[c].end()) {
      ++cnt;
      idx = *cm[c].begin();
    } else {
      idx = *it;
    }
  }
  cout<<cnt * s.length() + idx + 1<<endl;
}

Measured memory_bytes: 5248
object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val x, y = sc.nextLong()

    var num = x
    var count = 0
    while (num <= y) {
      count += 1
      num = num * 2
    }

    println(count)
  }
}


Measured memory_bytes: 27448
// AtCoder template
// sabaより胡蝶しのぶさんの方が可愛いのではないか？
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n; ++i)
ll dp[11][7];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n; int k; cin >> n >> k;
    ll tmp = 0LL;
    dp[0][0] = 0;
    rep(i,11) rep(j,5){
        if( (9*(7*(i+1)+(j+1)+1)%11) == k) tmp++;
        dp[i][j] = tmp;
    }
    if(n <= 2) cout << 0 << endl;
    else if((n-2)%11 != 0){
        cout << ((n-2)/11)*tmp + dp[(n-2)%11 -1][4] << endl;
    }else cout << ((n-2)/11)*tmp << endl;
    
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 62;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n; cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  rep(i, n) {
    if(a[i]%2 == 0) {
      if(a[i] %3 != 0 && a[i] %5 != 0) {
        cout << "DENIED" << endl;
        return 0;
      }
    }
  }
  cout << "APPROVED" << endl;
}


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

int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    a=min(a,b);
    c=min(c,d);
    cout<<c+a<<endl;
}

Measured memory_bytes: 3544
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int N, K;
        Scanner in = new Scanner(System.in);
        N = in.nextInt();
        K = in.nextInt();
        long ans = solve(N, K);
        System.out.println(ans);
        in.close();
    }

    public static long solve(int N, int K) {
        long ans = 0;
        for (int b = 1; b <= N; b++) {
            //s個の数列{1,2,...,b-1}
            //s = (N+1)/b
            //数列ひとつあたりb-1-K+1 = b-K個がK以上
            //s * (b-K) = (N+1)/b * (b-K)
            //最後に1周できなかった数列の断片{1,2,...,r}
            //{1,2,...r}のうちK以上の個数
            //r < Kなら0
            //r >= Kならr-K個
            //Math.max(0, r-K)
            //ans += (N+1)/b * (b-K) + Math.max(0, r-K)
            //a=0からはじめると0,1,2,...,b-1の繰り返しになり計算しやすい
            long s = (N + 1) / b;//[0, N]はN+1個
            long overKinSeq = Math.max(0, b - K);
            long r = (N + 1) % b;
            long overKlast = Math.max(0, r - K);
            long overK = s * overKinSeq + overKlast;
            ans += (overK > 0 ? overK : 0);
        }
        //a>0, b>0なのでa=0の場合は答えに入らない
        //K=0の場合のみa=0の場合がカウントされるので1つのbにつき1引く
        ans -= (K == 0 ? N : 0);
        return ans;
    }
}


Measured memory_bytes: 23508
#include <iostream>

#define MAX_N 100000

using namespace std;

int main(){
    int N;
    int t[MAX_N],x[MAX_N],y[MAX_N];
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>t[i]>>x[i]>>y[i];
    }
    int dist;
    int T;
    bool ok=true;
    for(int i=0;i<N;i++){
        if(i==0) {
            dist=abs(x[0])+abs(y[0]);
            T=t[0];
        }
        else{
            dist=abs(x[i]-x[i-1])+abs(y[i]-y[i-1]);
            T=t[i]-t[i-1];
        }
        if(dist>T+1 || (T-dist)%2!=0){
            ok=false;
            break;
        } 
    }
    if(ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 1408
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int n;
  cin >> n;
  vector<vector<i_i> > v(n);
  rep(i,n){
    int a; cin >> a;
    rep(j,a){
      int x,y; cin >> x >> y; x--;
      v[i].push_back(i_i(x,y));
    }
  }
  int ans=0;
  rep(i,(1<<n)){
    bool f=1;
    rep(j,n){
      if(i&(1<<j)){
        rep(k,v[j].size()){
          if(((i>>v[j][k].first)&1)!=v[j][k].second) f=0;
        }
      }
    }
    if(f){
      chmax(ans,__builtin_popcount(i));
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int A[50];
int n;

int solve(int i,int m){

  int re;

  if(m==0)
    return 1;

  if(i>=n)
    return 0;

  re = solve(i+1,m) || solve(i+1,m-A[i]);

  return re;
}

int main(){

  int i,j;
  int q,m;

  scanf("%d",&n);
  
  if(n<0 ||n >20)
    return 0;
  

  for(i=0;i<n;i++){

    scanf("%d",&A[i]);
    
    if(A[i]<1 || A[i]>2000)
      return 0;
  }
  

  scanf("%d",&q);
  
  if(q<0 ||q >200)
    return 0;


  for(i=0;i<q;i++){

    scanf("%d",&m);

    if(solve(0,m) == 1)
      printf("yes\n");

    else
      printf("no\n");

  }

  return 0;
}



Measured memory_bytes: 2048
#include<bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    int n;
    ll res = 1;
    cin >> n;
    ll a[n];
    for(int i = 0; i < n; ++i)
        cin >> a[i];
    sort(a, a+n);
    if(a[0] == 0) {
        cout << 0 << "\n"; 
        return 0;
    }
    for(int i = 0; i < n; ++i) {
        ll tmp = res;
        res *= a[i];
        // cout << res << "\n";
        if(res > 1000000000000000000 || res < tmp) {
            cout << -1 << "\n";
            return 0;
        }
    }
    cout << res << "\n";

    return 0;
}

Measured memory_bytes: 4456
n = int(input())
s = [input() for s in range(n)]
dic = {}

for i in range(n):
	if not s[i] in dic:
		dic[s[i]] = 1
	else:
		dic[s[i]] += 1

cnt_max = max(dic.values()) 
ans = []
for j in dic.keys():
	if dic[j] == cnt_max:
		ans.append(j)

ans.sort()

for h in range(len(ans)):
	print(ans[h])

Measured memory_bytes: 38348
#include <bits/stdc++.h>
using namespace std;
typedef long long lol;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
#define VL vector<lol>
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define PI 3.1415926535897932385 //pi
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

lol modPow(lol a, lol n, lol p)
{
    if(n == 0) return 1;
    if(n == 1) return a%p;
    if(n%2 == 1) return (a*modPow(a, n-1, p))%p;
    lol t = modPow(a, n/2, p);
    return (t*t)%p;
}

int main()
{
    lol result{1};
    lol n, a, b; cin >> n >> a >> b;
    result = modPow(2, n, MOD)-1;
    lol ac{1}, bc{1}, an{1}, bn{1};
    FORD(i, a, 1)
        ac = (ac*i)%MOD;
    FORD(i, b, 1)
        bc = (bc*i)%MOD;
    FORD(i, n, n-a+1)
        an = (an*i)%MOD;
    FORD(i, n, n-b+1)
        bn = (bn*i)%MOD;
    lol nCa = (an*modPow(ac, MOD-2, MOD))%MOD;
    lol nCb = (bn*modPow(bc, MOD-2, MOD))%MOD;
    result = result - nCa - nCb;
    while(result < 0) result += MOD;

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 3604
#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
    int a, b, c;
    cin >> a >> b >> c;
    
    int left = a - b;
    if(left < 0) left = 0;// 念のためエラー対策
    
    // cから水を移す
    int left2 = c - left;
    if(left2 < 0) left2 = 0;
    
    // 出力
    cout << left2 << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

# In[14]:


N = int(input())


# In[15]:


for h in range(1,3500+1):
    for n in range(h,3500+1):
        tmp = 4*h*n - N*n - N*h
        if tmp > 0 and (N*h*n)%tmp == 0:
            w = (N*h*n)//tmp
            print(h,n,w)
            break
    else:
        continue
    break


# In[ ]:






Measured memory_bytes: 9016
#include <iostream>
#include <algorithm>
#include <iterator>
#include <iomanip>
#include <cmath>
#include <vector>
#include <numeric>

using namespace std;

int main()
{
    int H, W;
    while(cin >> H >> W)
    {
        if (!H && !W)
            break;
        
        int i = 0;
        while (i++ < H)
        {
            int j = 0;
            while (j++ < W)
            {
                //both i and j are even or odd, so their remainders are the same
                if (i%2 == j%2)
                    cout << '#';
                else 
                    cout << '.';
                    
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#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()
{
  string S;
  cin >> S;
  if (S == "ABC") {
    cout << "ARC" << endl;
  } else {
    cout << "ABC" << endl;
  }
}

Measured memory_bytes: 3624
#include<stdio.h>

int main(void){
	int n, b, f, r, v, floor[4][3][10] = {0}, i, j, k, l;
	
	scanf("%d\n", &n);
	for(i = 0; i < n; i++){
		scanf("%d %d %d %d\n", &b, &f, &r, &v);
		b -= 1;
		f -= 1;
		r -= 1;
		floor[b][f][r] += v;
	}
	for(j = 0; j < 4; j++){
		for(k = 0; k < 3; k++){
			for(l = 0; l < 10; l++){
				printf(" %d", floor[j][k][l]);
			}
			printf("\n");
		}
		if(j == 3){
			break;
		}
		printf("####################\n");
	}
	return 0;
}


Measured memory_bytes: 2072
#include <iostream>
#include <vector>
#include <cmath>
#include <queue>
#include <cstdio>
#include <deque>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>
#include <stdlib.h>
#include <stack>

using namespace std;
int n, m;
pair<int, long long> a[100001];
pair<int, long long> b[100001];
map<long long, int> ma;
bool comp(pair<int, long long> x, pair<int, long long> y) {
	if (x.first == y.first) {
		return x.second < y.second;
	}
	else {
		return x.first < y.first;
	}
}
int main() {
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> a[i].first >> a[i].second;
		b[i].first = a[i].first;
		b[i].second = a[i].second;
	}
	sort(b, b + m, comp);
	int s = 1;
	int cmp = b[0].first;
	for (int i = 0; i < m; i++) {
		if (b[i].first != cmp) {
			cmp = b[i].first;
			ma[b[i].second] = 1;
			s = 1;
		}
		else {
			ma[b[i].second] = s;
		}
		s += 1;
	}
	for (int i = 0; i < m; i++) {
		int x = ma[a[i].second];
		printf("%06d", a[i].first);
		printf("%06d\n", x);
	}
}


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


int main(){
  int n, d;
  int x, y;
  cin >> n;
  cin >> d;
  int count = 0;
  for (int i=0; i!=n; ++i){
    cin >> x;
    cin >> y;
    
    if (sqrt(pow(x, 2) + pow(y, 2)) <= d){
      count += 1;
    }
  }
  cout << count << endl;
	return 0;
  
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N;
    cin >> N;
    int a[N];
    int ave=0;
    rep(i,N) {
        cin >> a[i];
        ave+=a[i];
    }
    ave/=N;
    int ans=INF;
    rep(i,2){
        int x=ave+i;
        int sum=0;
        rep(j,N){
            sum+=(a[j]-x)*(a[j]-x);
        }
        ans=min(ans,sum);
    }
    cout << ans << endl;



}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>
#define itn int
#define retrun return
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
using namespace std;
typedef long long llong;
typedef pair<int, int> pii;
llong gcd(llong a, llong b) {
	if (a < b) std::swap(a, b);
	if (a % b == 0)
		return b;
	else
		return gcd(b, a % b);
}
llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}
//ここまで共通
int H, W, K;
char S[100][10000];
int main() {
	cin >> H >> W >> K;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> S[i][j];
		}
	}
	llong ANS = 10000000000;
	for (int i = 0; i < pow(2, H - 1); i++) {
		llong tans = 0;
		vector<vector<int>> A;
		vector<int> tmp, B;
		bool F = false;
		for (int j = 0; j < H - 1; j++) {
			tmp.push_back(j);
			if (i & (1 << j)) {
				A.push_back(tmp);
				tmp.clear();
			}
		}
		tmp.push_back(H - 1);
		A.push_back(tmp);
		tans += A.size() - 1;

		for (int j = 0; j < A.size(); j++) {
			for (int k = 0; k < A[j].size(); k++) {
				B.push_back(j);
			}
		}

		tmp.clear();
		for (int j = 0; j < A.size(); j++) {
			tmp.push_back(0);
		}

		for (int j = 0; j < W; j++) {
			for (int k = 0; k < H; k++) {
				if (S[k][j] == '1') {
					tmp[B[k]]++;
				}
			}

			for (int k = 0; k < tmp.size(); k++) {
				if (tmp[k] > K) {
					tmp.clear();
					for (int l = 0; l < A.size(); l++) {
						tmp.push_back(0);
					}

					for (int l = 0; l < H; l++) {
						if (S[l][j] == '1') {
							tmp[B[l]]++;
						}
					}

					for (int l = 0; l < tmp.size(); l++) {
						if (tmp[l] > K) F = true;
					}

					tans++;
					break;
				}
			}
		}
		if (F) continue;

		ANS = min(ANS, tans);
	}

	cout << ANS;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

use std::collections::HashMap;

fn main() {
    input! {
        n: usize,
        mut s: [chars; n],
    }

    let mut map: HashMap<String, usize> = HashMap::new();

    for i in 0..s.len() {
        s[i].sort();
        let s: String = s[i].iter().cloned().collect::<String>();
        let count = map.entry(s).or_insert(0);
        *count += 1;
    }
    let mut sum: usize = 0;
    for (_, value) in &map {
        sum += (value * (value - 1) / 2) as usize;
    }
    println!("{}", sum);
}


Measured memory_bytes: 25720
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define MAX 110

int n, x;
int a[MAX];

bool cal(int m) {
	int cnt = x;
	for (int i = 0; i < m; i++) {
		cnt -= a[i];
	}
	if (m == n) return cnt == 0;
	return cnt >= 0;
} 

int32_t main() {
	cin >> n >> x;
	for (int i = 0; i < n; i++) cin >> a[i];
	sort(a, a + n);

	for (int i = n; i >= 0; i--) if (cal(i)) {
		cout << i << '\n';
		return 0;
	}
	return 0;
}

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

using namespace std;

#define int long long

int lcm(int a, int b)
{
	int x = __gcd(a, b);
	
	return (a * b) / x;
}

void solve()
{
	int n, m;
	cin >> n >> m;
	
	int p = 0;
	int t = 0;
	
	for(int i = 1; i <= n; i++)
	{
		int x;
		cin >> x;
		
		int nr = 0;
		
		while(x % 2 == 0)
		{
			x /= 2;
			nr++;
		}
		
		if(i == 1)
		{
			p = nr;
			t = x;
		}
		else
		{
			if(nr != p)
			{
				cout << 0;
				return ;
			}
			
			t = lcm(t, x);
		}
	}
	
	p--;
	
	while(p--)
	{
		t *= 2;
		
		if(t > m)
		{
			cout << 0;
			return ;
		}
	}
	
	int res = (m / t + 1) / 2;
	
	cout << res;
}

main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int t = 1;
//	cin >> t;
	
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 256
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	sc.Scan()
	N, _ := strconv.Atoi(sc.Text())

	sc.Scan()
	M, _ := strconv.Atoi(sc.Text())

	edges := make([][]int, M)
	for i := 0; i < M; i++ {
		sc.Scan()
		a, _ := strconv.Atoi(sc.Text())

		sc.Scan()
		b, _ := strconv.Atoi(sc.Text())

		edges[i] = []int{a, b}
	}

	nodes := make([]*unionTree, N)
	for i := 0; i < N; i++ {
		nut := newUnionTree(i + 1)
		nodes[i] = &nut
	}

	results := make([]int, M)
	for i := M - 1; i >= 0; i-- {
		if i == M-1 {
			results[i] = N * (N - 1) / 2
			continue
		}

		results[i] = results[i+1]

		edge := edges[i+1]
		u := nodes[edge[0]-1]
		v := nodes[edge[1]-1]
		uSize := size(u)
		vSize := size(v)
		if unite(u, v) {
			results[i] += uSize*(uSize-1)/2 + vSize*(vSize-1)/2
			unite(u, v)
			newSize := size(u)
			results[i] -= newSize * (newSize - 1) / 2
		}
	}

	writer := bufio.NewWriter(os.Stdout)
	for _, res := range results {
		writer.WriteString(strconv.Itoa(res) + "\n")
	}
	writer.Flush()
}

type unionTree struct {
	el     int
	parent *unionTree
	count  int
}

func newUnionTree(el int) unionTree {
	return unionTree{
		el:     el,
		parent: nil,
		count:  1,
	}
}

func (u *unionTree) root() *unionTree {
	if u.parent == nil {
		return u
	}

	root := u.parent.root()
	if root != u.parent {
		u.parent = root
	}
	return root
}

func same(u *unionTree, v *unionTree) bool {
	return u.root() == v.root()
}

func unite(u *unionTree, v *unionTree) bool {
	uRoot := u.root()
	vRoot := v.root()
	if uRoot == vRoot {
		return false
	}

	if uRoot.el < vRoot.el {
		vRoot.parent = uRoot
		uRoot.count += vRoot.count
	} else {
		uRoot.parent = vRoot
		vRoot.count += uRoot.count
	}
	return true
}

func size(u *unionTree) int {
	return u.root().count
}


Measured memory_bytes: 12288
#include "bits/stdc++.h"
using namespace std;

int n,a,b,c,d;
string s;
bool jump(int A, int B){
	if(A==c && B==d){
		return true;
	}
	if(A+1<=c && s[A]!='#' && A+1!=B){
		return jump(A+1, B);
	}
	if(A+2<=c && s[A+1]!='#' && A+2!=B){
		return jump(A+2, B);
	}
	if(B+1<=d && s[B]!='#' && B+1!=A){
		return jump(A, B+1);
	}
	if(B+2<=d && s[B+1]!='#' && B+2!=A){ 
		return jump(A, B+2);
	}

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

	cin>>n>>a>>b>>c>>d>>s;
	if(jump(a,b))
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.begin(), c.end()
#define Cin(T, x) T x; cin >> x;
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i];
#define Cout(x) cout << (x) << "\n";
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n";
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i];
#define Sort(a) sort(Range(a));
#define DeSort(a) sort(RevRange(a));

using namespace std;
using ll = long long;

int main(void){
    Cin(int, d);
    Cin(int, n);
    Cout((n == 100 ? 101 : n) * (d == 0 ? 1 : d == 1 ? 100 : 10000));
}


Measured memory_bytes: 256