akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define mp(a,b) make_pair(a,b)
#define ff first
#define setp(a) setprecision(a)<<fixed
#define ss second
#define fori(v) for(ll i=0; i<v; i++)
#define forj(v) for(ll j=0; j<v; j++)
#define fork(v) for(ll k=0; k<v; k++)
#define forl(v) for(ll l=0; l<v; l++)
#define fort(v) for(ll t=0; t<v; t++)
#define forz(v) for(ll z=0; z<v; z++)
#define forx(v) for(ll x=0; x<v; x++)
#define fory(v) for(ll y=0; y<v; y++)
#define ll long long 
#define MAX (int)(pow(10,6)+ 10)
#define pb(a) push_back(a)
#define ld long double
const ll INF = 0x3f3f3f3f;
const ll inf =  pow(10,18);
ll modulo = pow(10,9) + 7;

ifstream in;
ofstream out;

// #define cin in
// #define cout out



ll sum(ll i){
	return i*(i+1)/2;
}

void deal(){
	ll n , k;
	cin>>n>>k;
	vector<ll> arr(n);
	fori(n)	
		cin>>arr[i];
	vector<vector<ll> > sy(n, vector<ll>(2));
	fori(n){
		forj(n){
			if(arr[i] > arr[j])
				sy[i][0]++;
			if(j > i && arr[i] > arr[j])
				sy[i][1]++;
		}
	}
	ll ans = 0;
	fori(n){
		ans += (k*sy[i][1] + sum(k-1)%modulo * sy[i][0]) % modulo;
		ans %= modulo;
	}
	cout<<ans;
}





int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	deal();
}



























































Measured memory_bytes: 384
def resolve():
	s = input()
	s = s[::-1]
	t = [0]*2019
	t[0] = 1
	d = 1
	cur = 0
	m = 2019
	for i in range(len(s)):
		cur = (cur + (int(s[i]) * d % m)) % m
		t[cur] += 1
		d *= 10
		d %= m
	ans = 0
	for v in t:
		ans += v*(v-1)//2
	print(ans)
resolve()

Measured memory_bytes: 68748
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;
#define show2(a, n, m) rep(i, n) { rep(j, m) {cout << a[i][j] << ' ';} cout << endl;} 

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int solve(vi& w) {
	int n = w.size();
	vector<vi> dp(n, vi(n));
	for(int d = 1; d <= n - 1; d++) {
		for(int l = 0; l + d < n; l++) {
			int r = l + d;
			if(d % 2 == 1 && dp[l + 1][r - 1] == d - 1 && abs(w[l] - w[r]) <= 1) {
				dp[l][r] = d + 1;
				continue;
			}
			for(int k = l; k + 1 <= r; k++) {
				dp[l][r] = max(dp[l][k] + dp[k + 1][r], dp[l][r]);
			}
		}
	}
//	show2(dp, n, n);
	return dp[0][n - 1];
}

int main() {
//	cout << fixed << setprecision(15);
	vi ans;
	while(true) {
		int n;
		cin >> n;
		if(n == 0) break;
		vi w(n);
		rep(i, n) cin >> w[i];
		ans.push_back(solve(w));
	}
	for(auto i : ans) cout << i << endl;
}



Measured memory_bytes: 3232
#include <bits/stdc++.h>
#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,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
using pll=pair<ll,ll>;
const ll inf=1e+9;
int main(void){
    ll d,g;cin>>d>>g;
    vector<pair<ll,ll>> p(d);
    ll tot=0;
    rep(i,d){
        cin>>p[i].first>>p[i].second;
        tot+=(i+1)*100*p[i].first+p[i].second;
    }
    //vector<vector<ll>> dp(n,vector<ll>(tot+1,inf));
    vector<ll> dp(tot+1,inf);
    priority_queue<pair<int,pll>, vector<pair<int,pll>>, greater<pair<int,pll>>> que; //score,time
    que.push(make_pair(0,pll(0,0)));
    while(que.size()){
        auto x=que.top();que.pop();
        int i=x.first;
        ll s=x.second.first,t=x.second.second;
        ll pt=(i+1)*100;
        auto P=p[i];
        ll pp=P.first,c=P.second;
        for(ll j=1;j<=pp;j++){
            ll ns=s+pt*j;
            if(j==pp)ns+=c;
            if(chmin(dp[ns],t+j)){
                if(i!=d-1)que.push(make_pair(i+1,pll(ns,t+j)));
                //cout<<ns<<" "<<t+j<<endl;
            }
        }
        if(i!=d-1)que.push(make_pair(i+1,pll(s,t)));
    }
    //cout<<tot<<endl;
    ll res=inf;
    for(ll i=g;i<=tot;i++) chmin(res,dp[i]);
    cout<<res<<endl;
}

Measured memory_bytes: 86772
#include <iostream>
#include <string>
#include <vector>

using namespace std;

void rotation_N(int* dise){
   int tmp[6];

   tmp[0] = dise[1];
   tmp[1] = dise[5];
   tmp[2] = dise[2];
   tmp[3] = dise[3];
   tmp[4] = dise[0];
   tmp[5] = dise[4];

   for(int i = 0; i < 6; i++){
      dise[i] = tmp[i];
   }
}
void rotation_E(int* dise){
   int tmp[6];

   tmp[0] = dise[3];
   tmp[1] = dise[1];
   tmp[2] = dise[0];
   tmp[3] = dise[5];
   tmp[4] = dise[4];
   tmp[5] = dise[2];

   for(int i = 0; i < 6; i++){
      dise[i] = tmp[i];
   }
}
void rotation_S(int* dise){
   int tmp[6];

   tmp[0] = dise[4];
   tmp[1] = dise[0];
   tmp[2] = dise[2];
   tmp[3] = dise[3];
   tmp[4] = dise[5];
   tmp[5] = dise[1];

   for(int i = 0; i < 6; i++){
      dise[i] = tmp[i];
   }
}
void rotation_W(int* dise){
   int tmp[6];

   tmp[0] = dise[2];
   tmp[1] = dise[1];
   tmp[2] = dise[5];
   tmp[3] = dise[0];
   tmp[4] = dise[4];
   tmp[5] = dise[3];

   for(int i = 0; i < 6; i++){
      dise[i] = tmp[i];
   }
}

void rotation_spin(int* dise){
   int tmp[6];

   tmp[0] = dise[0];
   tmp[1] = dise[2];
   tmp[2] = dise[4];
   tmp[3] = dise[1];
   tmp[4] = dise[3];
   tmp[5] = dise[5];

   for(int i = 0; i < 6; i++){
      dise[i] = tmp[i];
   }
}

int diff_check(int* dise_a, int* dise_b){
   int f_diff = 0;

   int cnt_cmd = 0;

   if(dise_a[0] == dise_b[1]){
      rotation_N(dise_b);
   }
   else if(dise_a[0] == dise_b[4]){
      rotation_S(dise_b);
   }

   while(dise_a[0] != dise_b[0]){
      rotation_E(dise_b);

      if(cnt_cmd > 4){
         return 1;
      }

      cnt_cmd++;
   }

   cnt_cmd = 0;

   while(dise_a[1] != dise_b[1]){
      rotation_spin(dise_b);

      if(cnt_cmd > 4){
         return 1;
      }

      cnt_cmd++;
   }

   for(int i = 0; i < 6; i++){
      if(dise_a[i] != dise_b[i]){
         return 1;
      }
   }

   return 0;

}

int main(){
   int dise[100][6];
   int n;

   cin >> n;

   for(int i = 0; i < n; i++){
      for(int j = 0; j < 6; j++){
      cin >> dise[i][j];
      }
   }

   for(int i = 0; i < n - 1; i++){
      for(int j = i + 1; j < n; j++){
         if(!diff_check(dise[i], dise[j])){
            cout << "No" << endl;
            return 0;
         }
      }
   }

   cout << "Yes" << endl;

   return 0;
}


Measured memory_bytes: 3096
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;


int main()
{
    ll A, B;
    cin >> A >> B;
    ll ans = 0;
    if (A >= 13) ans = B;
    else if  (A >= 6) ans = B / 2;
    print(ans);
    return 0;
}

Measured memory_bytes: 764
#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;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define srt(a) sort(a.begin(),a.end())
#define rsrt(a) sort(a.rbegin(),a.rend())
#define lb(a,b) lower_bound(a.begin(),a.end(),b)
#define ub(a,b) upper_bound(a.begin(),a.end(),b)
#define MOD ((int)(1e9+7))
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define float long double
#define sqrt sqrtl
#define cbrt cbrtl
typedef vector<int> vi;
typedef vector<float> vf;
typedef pair<float,int> fi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<fi> vfi;
typedef vector<vi> vvi;
typedef vector<vf> vvf;
typedef vector<vii> vvii;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef priority_queue<int> pqi;
typedef priority_queue<ii> pqii;
typedef priority_queue<fi> pqfi;
typedef priority_queue <int, vector<int>, greater<int> > rpqi; 
typedef priority_queue <ii, vector<ii>, greater<ii> > rpqii; 
typedef priority_queue <fi, vector<fi>, greater<fi> > rpqfi; 
		

int32_t main()
{
    IOS
    int n,d,ans=0;cin>>n>>d;
    vvi p(n,vi(d));
    for(int i=0;i<n;i++)
    for(int j=0;j<d;j++)
    cin>>p[i][j];
    
    for(int i=0;i<n;i++)
    for(int j=i+1;j<n;j++)
    {
		int dx=0;
		for(int k=0;k<d;k++)
		{
			dx+=(p[i][k]-p[j][k])*(p[i][k]-p[j][k]);
		}
		int dy=sqrt(dx);
		if( dx==dy*dy)ans++;
	}
	cout<<ans<<endl;
			
  
}
			
  
	
   	
			
				


            


Measured memory_bytes: 256
N, M = map(int, input().split())
if M == 0:
    if N == 1:
        print(0)
    elif N == 2:
        print(10)
    else:
        print(100)
    exit()

rule = dict()
for _ in range(M):
    s, c = map(int, input().split())
    if s == 1 and c == 0 and N != 1:
        print(-1)
        exit()
    if rule.get(s, None) is not None:
        if rule.get(s) == c:
            continue
        else:
            print(-1)
            exit()
    else:
        rule[s] = c
# print(rule)

v = []
for i in range(1, N + 1):
    if rule.get(i) is not None:
        v.append(str(rule.get(i)))
    else:
        if i == 1:
            v.append('1')
        else:
            v.append('0')
print(''.join(v))


Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
using namespace std;

typedef long long LL;

namespace INPUT{
	const int L=1<<15;
	char _buf[L],*S,*T,c;
	char _gc(){
		if(S==T){
			T=(S=_buf)+fread(_buf,1,L,stdin);
			if(S==T) return EOF;
		}
		return *S++;
	}
	void readc(char &c){
		for(c=_gc();c<'a'||c>'z';c=_gc());
	}
	void readi(int &X){
		for(c=_gc();c<'0'||c>'9';c=_gc());X=c&15;
		for(c=_gc();c>='0'&&c<='9';X=X*10+(c&15),c=_gc());
	}
}
#define readc INPUT::readc
#define readi INPUT::readi

const int Maxn=1E6+5;

int N;
char S[Maxn];
char T[Maxn];
int a[Maxn],b[Maxn];

int tap[Maxn];
/*int P[Maxn];
int lnk[Maxn];
int f[Maxn];
*/


bool Check(int X){
	for(int i=1;i+X<=tap[N];++i)
		if(a[i+X]-X<b[i]) return false;
	return true;
}

int main(){
	readi(N); bool flag=true;
	for(int i=1;i<=N;++i) readc(S[i]);
	for(int i=1;i<=N;++i) readc(T[i]);
	for(int i=1;i<=N;++i) flag&=(S[i]==T[i]);
	if(flag){puts("0"); return 0;}
	
	tap[1]=1;
	for(int i=2;i<=N;++i)
		if(T[i]==T[i-1]) tap[i]=tap[i-1],b[tap[i]]=i;
		else tap[i]=tap[i-1]+1;
	/*for(int i=N,j=N;i>=1;--i){
		j=min(j,i);
		while(S[j]!=T[i]&&j>0) --j;
		if(j==0){puts("-1"); return 0;}
		lnk[j]=tap[i];
	}*/
	for(int i=N,j=N;i>=1;--i){
		j=min(j,i);
		while(S[j]!=T[i]&&j>0) --j;
		if(j==0){printf("-1");return 0;}
		a[tap[i]]=j;
	}
	
	int stt,mid,lst;
	stt=0,lst=N+1;
	while(stt+1<lst){
		mid=(stt+lst)>>1;
		if(Check(mid)) lst=mid;
		else stt=mid;
	}
	cout<<lst;
	
	return 0;
}


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

int main(){
  string t;
  cin >> t;
  
  int l = t.size();
  for(int i = 0; i < l; i++){
    if(t.at(i) == '?') t.at(i) = 'D';
  }
  
  cout << t << endl;
}

Measured memory_bytes: 3752
#include <iostream>

#include <vector>

#include <cassert>

#include <algorithm>

#include <functional>

#include <cmath>

#include <iomanip>

#include <limits>
#include <bits/stdc++.h>
#include<queue>
#include<type_traits>
#include<cstdint>
using namespace std;
int main(){
   int n;
   cin >> n;
   vector<int> vec(n);
   vector<int> vec1(n);
   for(int i=0;i<n;i++){
       int x;
       cin >> x;
       vec[i]=x;
       vec1[i]=x;
   }
   int count=0;
   sort(vec.begin(),vec.end());
   for(int i=0;i<n;i++){
       if(vec[i]!=vec1[i]){
           count++;
       }
   }
   if(count<=2){
       cout<<"YES"<<endl;
   }else{
       cout<<"NO"<<endl;
   }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;
using P = pair<int,int>;
void Yes() {
    cout << "Yes" << endl;
}
void No() {
    cout << "No" << endl;
}
int main(void) {
    int n, m, a, b, c;
    string s, t;
    cin >> a >> b;
    int ans = a-1;
    if(a <= b) ans++;
    cout << ans;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(v) v.begin(),v.end()
#define UN(v) v.erase(unique(ALL(v)),v.end())
#define EACH(v,it) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define FILL(x,y) memset(x,y,sizeof(x))
#define FIO ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,string> pis;
typedef vector<string> vs;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef unsigned int uint;
int dis[100005],co[100005];
int v[100005],d[100005],c[100005];
int n,m,q;
vi E[100005];
/*-------The Main Code-------*/

void BFS(int x,int d,int c)
{
	if(d<=dis[x])
	{
		return ;
	}
	queue<int> q;
	q.push(x);
	dis[x]=d;
	while(!q.empty())
	{
		int x=q.front();
//		cout<<x<<' ';
		q.pop();
		if(!co[x])
		{
			co[x]=c;
		}
		if(dis[x]<=0)
		{
			continue;
		}
		EACH(E[x],it)
		{
			int nx=*it;
			int nd=dis[x]-1;
			if(nd>dis[nx])
			{
				dis[nx]=nd;
				q.push(nx);
			}
		}
	}
//	cout<<"\n\n";
}

int main(int argv,char *argc[])
{
	FILL(dis,-1);
	FIO;
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int x,y;
		cin>>x>>y;
		E[x].push_back(y);
		E[y].push_back(x);
	}
	cin>>q;
	for(int i=1;i<=q;i++)
	{
		cin>>v[i]>>d[i]>>c[i];
	}
	for(int i=q;i>=1;i--)
	{
		BFS(v[i],d[i],c[i]);
	}
	for(int i=1;i<=n;i++)
	{
		cout<<co[i]<<'\n';
	}
	return 0;
}


Measured memory_bytes: 8824
from collections import Counter
n, k = map(int, input().split())
a = list(map(int, input().split()))
result = 0
cnt = Counter(a)
cnt_set = set(cnt.items())
cnt_sort = sorted(cnt.items(), key=lambda x:x[1])
for i in range(len(cnt_set) - k):
    result += cnt_sort[i][1]

print(result)

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

int main()
{
  string A , B ;
  cin >> A >> B ;
  int a;
  a=A.size();
  int ans=0;
  
  if((A.size()+1)==B.size()){
    for(int i=0;i<a;i++){
      if(!(A.at(i)==B.at(i))){
        ans++;
      }
    }
    if(ans==0){
      cout << "Yes" << endl;
      return 0;
    }
  }
    
    cout << "No" << endl;

return 0;
}

Measured memory_bytes: 3624
def distance_judge(d,x,y):
  dis = 0
  for index in range(d):
    dis = dis + pow(x[index]-y[index],2)
  dis = dis**0.5
  if int(dis)==dis: return True
  else: return False

def main():
  n,d = map(int, input().split())
  whole = []
  count = 0
  for i in range(n):
    coord = list(map(int, input().split()))
    whole.append(coord)

  for i in range(n-1):
    for j in range(i+1,n):
      flag = distance_judge(d,whole[i],whole[j])
      if flag==True: count += 1
  print(count)
  
if __name__=='__main__':
  main()

Measured memory_bytes: 3064
import Foundation

func main() {
    guard let line = readLine() else { return }
    let inputs = line.components(separatedBy: " ").compactMap() { Int($0) }
    let n = inputs[0]
    let d = inputs[1]
    var count = 0
    
    for _ in 0..<n {
        let inputs = readLine()!.components(separatedBy: " ").compactMap() { Int($0) }
        let point = Point(x: inputs[0], y: inputs[1])
        if point.isD(d: d) {
            count += 1
        }
    }
    print(count)
}
struct Point {
    let x: Int
    let y: Int
    func isD(d: Int) -> Bool {
        return sqrt(Double(self.x) * Double(self.x) + Double(self.y) * Double(self.y)) <= Double(d)
    }
}
main()

Measured memory_bytes: 14188
N = int(input())
a = list(map(int,input().split()))
C = [0]*9
for e in a:
    if e < 400:
        C[0] += 1
    elif e < 800:
        C[1] += 1
    elif e < 1200:
        C[2] += 1
    elif e < 1600:
        C[3] += 1
    elif e < 2000:
        C[4] += 1
    elif e < 2400:
        C[5] += 1
    elif e < 2800:
        C[6] += 1
    elif e < 3200:
        C[7] += 1
    else:
        C[8] += 1
ans = 0
for k in range(8):
    if C[k] > 0:
        ans += 1
print(max(1,ans),ans+C[8])


Measured memory_bytes: 3064
#include <iostream>
#include <string>

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

	std::string s, t;
	std::cin >> s >> t;

	for (int i = 0; i < n; ++i)
		std::cout << s[i] << t[i];

	std::cout << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int main() {
  int N;
  string S, T;
  cin >> N >> S >> T;
  rep(i, N) {
    cout << S[i] << T[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long lint;

int main() {
  int n;
  scanf("%d", &n);
  lint total_count = 1, odd_count = 1;
  for (int i = 0; i < n; ++i) {
    int v;
    scanf("%d", &v);
    total_count *= 3LL;
    if (v % 2 == 0) {
      odd_count *= 2LL;
    } else {
      odd_count *= 1LL;
    }
  }
  lint result = total_count - odd_count;
  printf("%lld\n", result);
  return 0;
}


Measured memory_bytes: 256
let () =
    let split s =
        let rec loop i cur flag acc =
            if i = String.length s then (
                if flag then cur :: acc else acc
            ) else (
                match flag, s.[i] with
                | true,  ' ' -> loop (i + 1) 0 false (cur :: acc)
                | false, ' ' -> loop (i + 1) 0 false acc
                | true,  v   -> loop (i + 1) (cur * 10 + int_of_char v - 48) true acc
                | false, v   -> loop (i + 1) (cur * 10 + int_of_char v - 48) true acc
            )
        in
        List.rev (loop 0 0 false [])
    in
    let main () =
        let n, m = Scanf.sscanf (read_line ()) "%d %d" (fun n m -> n, m) in
        let a = Array.of_list (split (read_line ())) in
        Array.sort compare a;
        let bc = Array.init m
            (fun _ -> Scanf.sscanf (read_line ()) "%d %d" (fun b c -> c, b))
        in
        Array.sort (fun a b -> compare b a) bc;
        let cur = ref 0 in
        let rec loop i =
            if i < m && !cur < n then (
                let (c, b) = bc.(i) in
                let rec loop2 j =
                    if j > 0 && !cur < n then (
                        if a.(!cur) < c then (
                            a.(!cur) <- c;
                            cur := !cur + 1;
                            loop2 (j - 1)
                        )
                    ) 
                in
                loop2 b;
                loop (i + 1)
            )
        in
        loop 0;
        Printf.printf "%d\n" (Array.fold_left (+) 0 a)
    in
    main ()

Measured memory_bytes: 11008
l=input()
max=0
c=0
for i in range(len(l)):
    if l[i]=='A' or l[i]=='T' or l[i]=='C' or l[i]=='G':
        c+=1
    else:
        if c>max:
            max=c
        c=0
if c>max:
    max=c
print(max)

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

long long GCD(long long a, long long b) 
{ 
    if(b==0) 
        return a; 
    return GCD(b, a%b);  
      
}

long long LCM(long long a, long long b)
{
    long long gcd=GCD(a,b);
     return (a*b)/gcd;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    long long i, j, k, n, m, t, x, y, z, s=0, c=0, l;
    cin >> n;
    int a[n];
    for(i=0; i<n; i++)
    {
        cin >> a[i];
        s+=a[i];
    }
    sort(a, a+n);
    cout << s-(a[n-1]/2);
}


Measured memory_bytes: 3576
# include <iostream>
# include <stdint.h>
# include <stdio.h>
# include <math.h>
using namespace std;


int main(){
	int sum;
	while(1){
		string str;
		cin >>str;
		if(str =="0") break;
		else{
			 sum =0;
			for(int i =0;i<(int)str.size();i++){
				sum += str[i] -'0';
			}

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



Measured memory_bytes: 3204
N=int(input())
ls=list(map(int,input().split()))
ls.sort()

#定数倍のやつに＋１する
M=max(ls)
A=[0]*(M+1)
for i in range(N):
  a=M//ls[i]
  for j in range(1,a+1):
    if A[j*ls[i]]<=2:
      A[j*ls[i]]+=1
    
ans=0     
for i in range(len(ls)):
  if A[ls[i]]==1:
    ans+=1
print(ans)

Measured memory_bytes: 94440
#include <bits/stdc++.h>    //C++の標準ライブラリのヘッダを全て読み込む
 
int main() {
    using std::cout;
    using std::endl;
    using std::cin;

    int r = 0, g = 0;
    cin >> r >> g;
    cout << g*2 - r << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=200005;
int a[maxn],n;
int b[maxn];
bool check(int mid)
{
    for(int i=1;i<2*n;i++)
        b[i]=a[i]<=mid;
    int l=1,r=2*n-1;
    for(int i=n-1;i;i--)
    {
        if(b[i]==b[i+1]){
            l=i+1;break;
        }
    }
    for(int i=n+1;i<2*n;i++)
    {
        if(b[i]==b[i-1]){
            r=i-1;break;
        }
    }
    if(l==-1&&r==-1) return b[1];
    if(l==-1||r-n<n-l){
        return b[r];
    }
    return b[l];
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<2*n;i++)
        scanf("%d",a+i);
    int l=1,r=2*n-1,ans;
    while(l<=r)
    {
        int mid=(l+r)>>1;
        if(check(mid)){
            ans=mid;r=mid-1;
        }
        else{
            l=mid+1;
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n,k; cin >> n >> k;
    if(n%k > 0) OUT(1);
    else OUT(0);

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  int A[N];
  REP(i,N)cin>>A[i];
  sort(A,A+N);
  cout<<A[N-1]-A[0]<<endl;
  return 0;
}


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

int main() {
  int m=0, M;
  vector<int> V(5);
  int p, t, S=0;
  for (int i=0; i<5; i++) {
    cin >> V[i];
    S+=((V[i]-1)/10+1)*10;
    p=(200-V[i])%10;
    if (m<p) {
      M=i;
      m=p;
    }
  }
  cout << S-m << endl;
}



Measured memory_bytes: 3596
# ARC082C - Together (ABC072C)
def main():
    n = int(input())
    lst = list(map(int, input().rstrip().split()))
    ans = [0] * 100001
    for i in lst:
        ans[i] += 1
    print(max(map(sum, zip(ans, ans[1:], ans[2:]))))


if __name__ == "__main__":
    main()

Measured memory_bytes: 13964
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

const int MX = 200005;

int N;
ll L;

struct Node{
	int t[2];
} node[MX];
int sz = 1;

map<int, int> G;

int dfs(int x, ll lev = L){
	int l = node[x].t[0], r = node[x].t[1];
	if( l && r ) dfs(l, lev-1), dfs(r, lev-1);
	else if( !l && !r ) return 0;
	else{
		dfs(l|r, lev-1);
		G[__builtin_ctzll(lev)] ^= 1;
	}
}

int main()
{
	int root = 1;
	scanf("%d%lld", &N, &L);
	for(int i = 1; i <= N; i++){
		string D;
		cin >> D;
		int cur = root;
		for(char c : D){
			if( !node[cur].t[c-'0'] ) node[cur].t[c-'0'] = ++sz;
			cur = node[cur].t[c-'0'];
		}
	}
	dfs(root);
	int ch = 0;
	for(auto c : G) ch |= c.second;
	printf("%s\n", ch? "Alice":"Bob");
}


Measured memory_bytes: 5788
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let c = read::<String>().chars().nth(0).unwrap();
    if c == 'A' {
        println!("T");
    } else if c == 'T' {
        println!("A");
    } else if c == 'C' {
        println!("G");
    } else {
        println!("C");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long i = 0; i < n; i++)
#define erep(i, n) for(long i = 1; i <= n; i++)
#define all(a) a.begin(), a.end()
#define show(ans)  cout << ans << endl;
const long MOD = 1000000007;


int main() {long N, M;
cin >> N >> M;
long a = 1;
vector<long> vec;
while(a*a <= M){
    if(M % a == 0){
        vec.push_back(a);
        if(a != M/a) vec.push_back(M/a);
    }
    a++;
}
sort(all(vec));
long t = lower_bound(all(vec), N) - vec.begin();
long ans = M / vec[t];

show(ans);



  return 0;
 
}



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

int main() {
  string S;
  cin >> S;
  int cnt=0;
  for(int i = 0; i < S.length(); i++){
    if(i%2==0){
      if(S[i]=='L')cnt++;
    } else {
      if(S[i]=='R')cnt++;
    }
  }
  if(cnt!=0) cout << "No";
  else cout << "Yes";
}

Measured memory_bytes: 256
import math
def lcm(x, y): # 最小公倍数
    return (x * y) // math.gcd(x, y)


a, b, c, d = map(int, input().split())

lcm_cd = lcm(c, d)

under_b = b - b//c - b//d + b//lcm_cd
over_a = (a-1) - (a-1)//c - (a-1)//d + (a-1)//lcm_cd

print(under_b - over_a)

Measured memory_bytes: 9088
#include <iostream>
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n; cin >> n;
    int a = 0, b = 0, cur = 0;
    int t, x, y;
    bool flag = true;
    for (int i = 0; i < n; i++) {
        cin >> t >> x >> y;
        int delta = abs(a - x) + abs(b - y);
        int tmp = t - cur - delta;
        if (tmp < 0 || tmp%2 != 0) {
            flag = false;
            break;
        }
        cur = t; a = x, b = y;
    }
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

struct Point{
  double x,y;
};

void koch(int n,struct Point a,struct Point b){
  if(n==0) return;
  struct Point s,t,u;
  double th=M_PI*60.0/180.0;

  s.x =(2.0*a.x+1.0*b.x)/3.0;
  s.y =(2.0*a.y+1.0*b.y)/3.0;
  t.x =(1.0*a.x+2.0*b.x)/3.0;
  t.y =(1.0*a.y+2.0*b.y)/3.0;
  u.x =(t.x -s.x)*cos(th) - (t.y -s.y)*sin(th) + s.x;
  u.y =(t.x -s.x)*sin(th) + (t.y -s.y)*cos(th) + s.y;

  koch(n-1,a,s);
  printf("%.8f %.8f\n",s.x,s.y);
  koch(n-1,s,u);
  printf("%.8f %.8f\n",u.x,u.y);
  koch(n-1,u,t);
  printf("%.8f %.8f\n",t.x,t.y);
  koch(n-1,t,b);  
}

int main(){
  struct Point a,b;
  int n;

  scanf("%d",&n);

  a.x=0;
  a.y=0;
  b.x=100;
  b.y=0;

  printf("%.8f %.8f\n",a.x,a.y);
  koch(n,a,b);
  printf("%.8f %.8f\n",b.x,b.y);

  return 0;  
}


Measured memory_bytes: 1968
use std::io::Read;

fn main() {
    let mut buf = String::new();

    std::io::stdin().read_to_string(&mut buf).unwrap();

    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let k: isize = iter.next().unwrap().parse().unwrap();
    let q: isize = iter.next().unwrap().parse().unwrap();

    let mut a: Vec<usize> = vec![];
    for _ in 0..q {
        a.push(iter.next().unwrap().parse().unwrap());
    }

    let mut scores: Vec<isize> = vec![(k - q) as isize; n];

    for i in a {
        scores[i - 1] += 1;
    }

    for score in scores {
        if score <= 0 {
            println!("No");
        } else {
            println!("Yes");
        }
    }

    // println!("{}", ans);
}


Measured memory_bytes: 8828
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define pie 3.141592653589793238462643383279
#define int long long
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mood) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mood;
		}
		x = x * x % mood;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int n, d[50];
int ans;

signed main() {
	cin >> n;
	for (int i = 0; i < n; i++)cin >> d[i];
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			ans += d[i] * d[j];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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 ll INF=1e18;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n;
    cin>>n;
    map<string,int> mp;
    rep(i,n){
        string s;
        cin>>s;
        mp[s]++;
    }
    printf("AC x %d\n",mp["AC"]);
    printf("WA x %d\n",mp["WA"]);
    printf("TLE x %d\n",mp["TLE"]);
    printf("RE x %d\n",mp["RE"]);
    
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
//どうしてもわからないときはサンプルで実験　何か見えてくるかも
//頭で考えてダメなら紙におこせ！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
{
    ・全探索できるなら全探索しろ
    ・異常な制約ならそこに注目
}
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'¥n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え('='でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
doubleを扱うときには(abs)ではなく'fabs'!!!
*/

Measured memory_bytes: 3760
#include<iostream>
#include<string>
#include<stack>
using namespace std;
int main(){
  int n,m;
  string str;
  stack<int>st;
  cin>>n>>m;
  cin>>str;
  int pos=n;
  while(pos>0){
    int temp=pos;
    int index=0;
    for(int i=1;i<=m&&pos-i>=0;i++){
      if(str[pos-i]=='0'){
	temp=pos-i;
	index=i;
      }
    }
    if(temp==pos){
      cout<<-1<<endl;
      return(0);
    }
    pos=temp;
    st.push(index);
  }
  cout<<st.top();
  st.pop();
  while(!st.empty()){
    cout<<" "<<st.top();
    st.pop();
  }
  cout<<endl;
  return(0);
}


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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

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;
}
vector<bool> seen;
void dfs(const Graph &G, int v){
    seen[v] = true; // vを訪問済みにする
    
    for(auto next_v: G[v]){
        if(seen[next_v]) continue; // next_vが探索済みならスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

int main(){

    int n;
    cin >> n;

    ll ans = 0;
    for(int i = 1; i <= n; i++){
        if((i%3 == 0) && (i%5 == 0)){
        }
        else if(i%3 == 0){
        }
        else if(i%5 == 0){
        }
        else{
            ans += i;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cctype>



using namespace std;

int main()
{
        string s;
        getline(cin,s);
        
        for(int i=0;i<(int)s.size();i++)
        {
            printf("%c",toupper(s[i]))  ;
        }
        cout << endl;
}

Measured memory_bytes: 1168
n,k=map(int,input().split())
p=list(map(int,input().split()))
q=[0]*n
r=0
for i in range(n):
    t=0
    for j in range(n):
        if p[i]>p[j]:
            t+=1
    q[t]=p[i]
for i in range(n):
    if q[i]==0:
        q[i]=q[i-1]
for i in range(k):
    r+=q[i]
print(r)

Measured memory_bytes: 66080
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main(void){
    // Here your code !
    int n;
    cin >> n;
    int x[n], y[n];
    for(int i=0;i<n;i++) {
        cin >> x[i];
    }
    for(int i=0;i<n;i++) {
        cin >> y[i];
    }
    double d1 = 0, d2 = 0, d3 = 0, d = 0;
    for(int i=0;i<n;i++) {
        d1 = d1 + abs(x[i] - y[i]);
        d2 = d2 + pow(x[i] - y[i], 2);
        d3 = d3 + pow(abs(x[i] - y[i]), 3);
        d = fmax(d, abs(x[i] - y[i]));
    }
    d2 = sqrt(d2);
    d3 = cbrt(d3);
    cout << fixed
         << setprecision(10)
         << d1 << endl
         << d2 << endl
         << d3 << endl
         << d << endl;
}

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

#define      pb    push_back
#define      ff    first
#define      ss    second
#define      ll    long long int
#define      endl  "\n"
#define      FASTIO        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const ll big = 10e12 + 11 ;

bool  isPalindrome( string  s ) {
    string s1 = s ;
    reverse( s.begin( ), s.end( ) ) ;

    if( s == s1 )
        return true ;

    return  false ;
}

int  main (  ) {

    FASTIO ;

    string s, s1, s2 ;
    cin >> s ;

    int flag = 0, n = s.size( ) ;

    if( isPalindrome( s ) )
        flag++ ;

    s1 = s.substr( 0, s.size( ) / 2 ) ;

    if( isPalindrome( s1 ) )
        flag++ ;

    int l = ( ( n + 3 )/ 2 ) - 1 ;

    s2 = s.substr( l, n - l ) ;

    if( isPalindrome( s2 ) )
        flag++ ;

    if( flag == 3)
        cout << "Yes" ;
    else
        cout << "No" ;

    return  0 ;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()
// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

  // vector<vector<vector<int> > > DP =  vector<vector<vector<int> > >(100001,vector<vector<int> >(2,vector<int>(2,0)));
void solve(void)
{
  int ANS = INF;
  int H,W,K;
  cin>>H>>W>>K;
  vector<string> data(H);
  for (int i = 0; i < H; i++)
  {
    cin>>data[i];
  }
  vector<vector<int> > v(W);
  for (int i = 0; i < (1<<(H-1)); i++)
  {
    int count =__builtin_popcount(i);
    for (int j = 0; j < W; j++)
    {
      int s = 0;
      for (int k = 0; k < H; k++)
      {
        s += data[k][j]&1;
        if(i>>k&1)
        {
          v[j].push_back(s);
          s = 0;
        }
      }
      v[j].push_back(s);
      for (int vi:v[j])
      {
        if(vi > K) count = 1e9;
      }
      
      
    }
    vector<int> u (v[0].size());
    for (int j = 0; j < W; j++)
    {
      bool split = 0;
      for (int l = 0; l < u.size(); l++)
        split |= u[l] +v[j][l]>K;
        if(split)
        {
          ++count;
          u = vector<int>(u.size());
        }
        for (int l = 0; l < u.size() ; l++)
        {
          u[l] += v[j][l];

        }
        
               v[j].clear(); 
      
    }
    chmin(ANS,count);
  }
  
  
  cout<<ANS<<endl;
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <bitset>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <string>
#include <algorithm>
#include <cmath>
#include <limits>

using namespace std;
using ll=long long;
using vint=vector<int>;
using pint=pair<int,int>;

const double EPS = 1e-9;
const int inf = numeric_limits<int>::max();

#define rep(i,n) for(int i=0;i<int(n);++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;--i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

bool p[55565]={};

bool is_prime(int n){
  bool ans = true;
  for(int j=2;j<=sqrt(n);j++){
    if(n%j==0){
      ans = false;
      break;
    }
  }

  return ans;
}

void solve(){
  int n;
  vector<int> ans;
  cin >> n;

  for(int i=2;i<55565;i++)
  {
    p[i] = is_prime(i);
  }

  int c=0;

  for(int i = 3; c != n; i++){
    if(p[i] && i % 5 == 1){
      cout << i;
      c++;
      if(c!= n){
        cout << " ";
      }
    }
  }
  cout << endl;
}

int main(){
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 100005;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
vector<bool> IsPrime;

void sieve(int max){
    if(max+1 > IsPrime.size()){     
        IsPrime.resize(max+1,true); 
    } 
    IsPrime[0] = false;
    IsPrime[1] = false;

    for(int i=2; i*i<=max; ++i) 
        if(IsPrime[i])
            for(int j=2; i*j<=max; ++j) 
                IsPrime[i*j] = false;      
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    sieve(MAX);
    vector<ll> cnt(100003,0);
    rep(i,100003){
        if (i%2 && IsPrime[i] && IsPrime[(i+1)/2]) cnt[i]++;
    }
    rep(i,100000){
        cnt[i+1] += cnt[i];
    }
    ll q,l,r;
    cin >> q;
    rep(i,q){
        cin >> l >> r;
        PRINT(cnt[r]-cnt[l-1]);
    }
}




Measured memory_bytes: 1408
N = int(input())
s, t = [0 for _ in range(N)], [0 for _ in range(N)]
for i in range(N):
    s[i], t[i] = input().split()
    t[i] = int(t[i])
X = input()

ind = s.index(X)
print(sum(t[ind+1:]))


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

int main(){
string s;
cin >> s;
  int countC,countLow;
  countC = 0; countLow =0;
for(int i = 0;i < s.size();i++){
  if(i == 0){
    if(s.at(i) != 'A'){
      break;
    }
  }else{
    if(islower(s.at(i))){
      countLow++;
    }
       if(i > 1&& i < s.size() - 1){
         if(s.at(i) == 'C'){
           countC++;
         }
       }
      }
     }
       if(countC == 1 && countLow == s.size() - 2){
         cout << "AC" << endl;
         return 0;
       }
      cout << "WA" << endl;
  
  return 0;
}

Measured memory_bytes: 256
class Problem
  attr_accessor :a, :b, :n, :m, :h, :w

  def initialize
    @a, @b = gets.to_s.split.map { |v| v.to_i }
  end

  def solve
    power(a) <=> power(b)
  end

  def power(a)
    return 14 if a == 1
    a
  end

  def show(ans)
    puts ["Bob", "Draw", "Alice"][ans+1]
  end
end

Problem.new.instance_eval do
  show(solve)
end


Measured memory_bytes: 14232
#include <iostream>
#include <string>
#include <sstream>
using std::cin;
using std::cout;

std::string S;

int main(){
  std::stringstream U;
  cin >> S;
  U << S[ 5 ] << S[ 6 ] << S[ 8 ] << S[ 9 ];
  int C = atoi(U.str().c_str());
  if(C > 430){
  	cout << "TBD\n";
  }else{
   cout << "Heisei\n"; 
  }
  return 0; 
}


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

using namespace std;

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

  stack<int> s;
  for(int i=1;i<=a;i++){if(a%i==0 && b%i==0) s.push(i);}
  for(int i=1;i<k;i++){s.pop();}
  cout<<s.top()<<endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python

line1 = int(input())
line2 = [int(i) for i in input().split()]

dif = []
for idx in range(1,line1):
	sum1 = sum(line2[0:idx])
	sum2 = sum(line2[idx:])
	dif.append(abs(sum1-sum2))
	

print(min(dif))

Measured memory_bytes: 3060
#include<stdio.h>
#include<math.h>
#define PI 3.141592653589793238
int main(){
	double a,b,C;
	scanf("%lf%lf%lf",&a,&b,&C);
	C=C/180*PI;
	printf("%f\n%f\n%f\n",a*b/2*sin(C),a+b+sqrt(a*a+b*b-2*a*b*cos(C)),b*sin(C));
	return 0;
}



Measured memory_bytes: 2104
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <stack>
using namespace std;
#define ll int64_t
const ll mod = 1000000007;


const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}


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


  ll ans = 0;

  ll a1 = a-1;
  ll b1 = b;

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

  ll ans2 = 0;

  if (b1%2 ==0){
    ans2 = (b1/2)%2 ^ b1;
  }else{
    ans2 = (b1+1)/2%2;
  }

  cerr << ans <<"  :  " <<ans2 <<endl;


  ll ans3 = ans^ans2;



  cout << ans3 << endl;

}




















Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  string n;
  cin >> n;

  for (char c : n){
    if (c == '1'){
      cout << 9;
    }else{
      cout << 1;
    }
  }
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
// 287644PV
#define FIXED_FLOAT(x) std::fixed <<std::setprecision(6)<<(x)
const int mod = 1000000007;

void addSelf(int&x, int y)
{
    x+= y;
    if(x >= mod)
        x-=mod;
}
void subSelf(int&x, int y)
{
    x -= y;
    if(x < 0)
        x += mod;
}

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

int64_t power(int base, int expo)
{
    int64_t sol = 1;
    for (int i = 0; i <expo ; ++i) {
        sol *= base;
    }
    return sol;
}

bool compare1(pair<int,int> i,pair<int,int> j) // 1 < i < n
{
    return i.second < j.second;
}

bool compare2(pair<int,int> i, pair<int,int> j) //n > n-i > 1
{
    return i.first > j.first;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,a,b;
    cin >> n >> a >> b;
    cout << min(n*a,b);


return 0;
}

Measured memory_bytes: 256