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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
#define chmax(x, v)                                                            \
  do {                                                                         \
    x = max(x, v);                                                             \
  } while (0)
#define chmin(x, v)                                                            \
  do {                                                                         \
    x = min(x, v);                                                             \
  } while (0)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

// {{{ Modint
// using mint = modint<1000000007>;
// mint x = 2;
// std::cout << x.a << std::endl;
template <std::int64_t M>
class modint {
 public:
  int64_t a;

  explicit constexpr modint(const int64_t x = 0) noexcept :
    a((x % M + M) % M) {}
  constexpr int64_t &value() noexcept { return a; }
  constexpr const int64_t &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= M) {
      a -= M;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += M;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % M;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    int64_t exp = M - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
  constexpr modint pow(ll t) const {
    if (!t) return modint(1);
    modint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
};
// }}}
const ll M = 1e9+7;
using mint = modint<M>;

mint comb(ll n, ll a) {
  mint upper(1);
  rep(i, a) {
    upper *= mint(n-i);
  }

  mint lower(1);
  rep(i, a) {
    lower *= mint(i+1);
  }

  return upper / lower;
}

signed main() {
  // ans = (nC0 + nC1 + nC2 + nC3 + ... + nCn) - (nCa + nCb + nC0)
  // ans = 2^n - (nCa + nCb + nC0)
  ll n,a,b;
  cin>>n>>a>>b;
  mint ans = mint(2).pow(n);
  ans -= comb(n,a) + comb(n,b) + comb(n,0);
  cout<<ans.value()<<endl;
  return 0;
}


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

int main(){
    int n;
    cin>>n;
    vector<int> num(n);
    rep(i, n){
        cin>>num.at(i);
    }
    sort(num.begin(), num.end());
    cout<<num.at(0)<<" "<<num.at(n-1)<<" ";
    long long sum=0;
    rep(i, n){
        sum+=num.at(i);
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3172
#include<stdio.h>
int main(){
  int i,j,N,A[101],v,a;
  scanf("%d",&N);
  for(i=0;i<N;i++)
    scanf("%d",&A[i]);
  for(i=0;i<N;i++){
    v=A[i];
    j=i-1;
    while(j>=0 && A[j]>=v){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=v;
    for(a=0;a<N;a++){
      printf("%d",A[a]);
      if(a != N-1)
	printf(" ");
    }
    printf("\n");
  }
  return 0;
}



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

int main(){
	vector<int> v;
	int n;
	while(cin>>n,n){
		v.resize(n);
		for(int i=0;i<n;i++)cin>>v[i];
		int ans=n;
		for(int i=0;i<n;i++){
			for(int j=1;j<=3;j++){
				if(v[i]==j)continue;
				int prev=v[i];
				v[i]=j;
				int a=i,b=i+1;
				while(1){
					int c=1;
					while(0<a&&v[a]==v[a-1])a--,c++;
					while(b<n &&v[a]==v[b])b++,c++;
					if(c<4){
						ans=min(ans,n-b+a+c);
						break;
					}
					if(--a==-1){
						ans=min(ans,n-b);
						break;
					}
					if(b==n){
						ans=min(ans,a+1);
						break;
					}
				}
				v[i]=prev;
			}
		}
		cout<<ans<<endl;
	}
}

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

int main(){
  int n;
  cin >> n;
  vector<int> w(n);
  
  for (int i=0;i<n;i++){
    cin >> w[i];
  }
  int ans = 1e9;
  for (int i=1;i<n;i++){
    int l=0;
    int r=0;
    for (int j=0;j<i;j++) l += w[j];
    for (int j=i;j<n;j++) r += w[j];
    
    ans = min(ans,abs(r-l));
  }
  cout << ans << endl;
}
    


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

int main(void){
    int n ;
    cin >> n ;
    char s[n+1] ;
    cin >> s ;
    if (n%2==0){
        for (int i=0; i<n/2; i++){
            if (s[i]!=s[n/2+i]){
                cout << "No" << endl ;
                return 0 ;
            }
        }
        cout << "Yes" << endl ;
    } else {
        cout << "No" << endl ;
    }
}

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

using namespace std;

int main(){
    int n;
    while(cin>>n,n){
        int s;
        int sum=0;
        int ma=-1;
        int mi=10000;
        for(int i=0;i<n;i++){
            cin>>s;
            ma=max(ma,s);
            mi=min(mi,s);
            sum+=s;
        }
        sum-=mi+ma;
        cout<<sum/(n-2)<<endl;

    }


}

Measured memory_bytes: 3080
#include<stdio.h>
#include<string.h>
 
int main(){
  char str[201],tmp[201];
  int i,j,n,h,len;
 
  while(1){
    scanf("%s",str);
    if(str[0] == '-') break;
    len=strlen(str);
    scanf("%d",&n);
    for(i=0;i<n;i++){
      scanf("%d", &h);
      for(j=0;j<len;j++) tmp[j] = str[j];
      for(j=0;j<len-h;j++){
    str[j] = str[j+h];
      }
      for(j=0;j<h;j++){
    str[j+len-h] = tmp[j];
      }
    }
    printf("%s\n",str);
  }
  return 0;
}


Measured memory_bytes: 1920
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

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

  int L, R, d;
  cin >> L >> R >> d;
  cout << (R/d - (L-1)/d) << '\n';
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;
int main(){
    int n,A[200001],ans=0;
    cin>>n;
    rep(i,n) cin>>A[i];
    rep(i,n-1) if(A[i]<A[i+1]) ans++;
    cout<<ans<<"\n";
}


Measured memory_bytes: 3500
import java.util.Scanner;
import java.util.HashSet;
public class Main {
    public static void main(String[] args) {
        Scanner sc= new Scanner(System.in);
        int sunuke = sc.nextInt();
        int kashi = sc.nextInt();
      HashSet set = new HashSet();
      int motteru = 0;
      for(int i = 0; i < kashi; i++){
        motteru = sc.nextInt();
        for(int j = 0; j < motteru;j++) set.add(sc.nextInt());
      }
        
        System.out.println(sunuke - set.size());
    } 
}

Measured memory_bytes: 46528
#include<bits/stdc++.h>
using namespace std;
int n,m;
int a[105],tot,id[105];
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
    {
        scanf("%d",&a[i]);
        if(a[i]&1)tot++,id[tot]=i;
    }
    if(tot>2)return 0*puts("Impossible");
    if(!tot)
    {
        for(int i=1;i<=m;i++)printf("%d ",a[i]);puts("");
        if(m==1)
        {
            printf("2\n%d 1\n",a[1]-1);
        }
        else
        {
            printf("%d\n",m);
            printf("%d ",a[1]-1);
            for(int i=2;i<m;i++)printf("%d ",a[i]);
            printf("%d\n",a[m]+1);
        }
    }
    else if(tot==1)
    {
        swap(a[1],a[id[1]]);

        for(int i=1;i<=m;i++)printf("%d ",a[i]);puts("");
        if(m==1)
        {
            if(a[1]==1)printf("1\n1\n");
            else printf("2\n%d 1\n",a[1]-1);
        }
        else
        {
            printf("%d\n",m-(a[1]==1));
            if(a[1]!=1)printf("%d ",a[1]-1);
            for(int i=2;i<m;i++)printf("%d ",a[i]);
            printf("%d\n",a[m]+1);
        }
    }
    else if(tot==2)
    {
        swap(a[1],a[id[1]]);swap(a[m],a[id[2]]);
        for(int i=1;i<=m;i++)printf("%d ",a[i]);puts("");
        printf("%d\n",m-(a[1]==1));
        if(a[1]!=1)printf("%d ",a[1]-1);
        for(int i=2;i<m;i++)printf("%d ",a[i]);
        printf("%d\n",a[m]+1);
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
 void run() {
  Scanner sc = new Scanner(System.in);
  for(;sc.hasNext();){
   long a = sc.nextLong();
   long b = sc.nextLong();
   System.out.println( gcd(a, b) + " " + lcm(a, b) );
  }
 }
 long gcd(long a, long b){
  if(b==0) return a;
  return gcd(b, a%b);
 }
 long lcm(long a, long b){
  return a/gcd(a, b)*b;
 }
 public static void main(String[] args){
  new Main().run();
 }
}

Measured memory_bytes: 12000
num = int(input())
input_line = input().split()

law = 10 ** 9 + 7
num_list = [int(input_line[i])%law for i in range(num)]

sigma = 0
temp_sum = 0
for j in range(num):
	temp_sum += num_list[j]

for i in range(num):
	num_a = num_list[i]
	temp_sum -= num_a
	sigma += num_a * temp_sum


sigma %= law
print(sigma)

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

int main() {
  int N, a, b, c, d;
  cin >> N;
  a = N/1000;
  b = N%1000/100;
  c = N%100/10;
  d = N%10;
  if ((a == b && b == c) || (b == c && c == d))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL mod=1e9+7;
const int maxn=2e5+10;
const LL inf=1e18;

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    swap(a,b);swap(a,c);
    printf("%d %d %d\n",a,b,c);
    return 0;
}


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

int main(void){
	int H,W;

	while (cin >> H >> W){
		if(H==0&&W==0) break;
		if(H>300||W>300||H<0||W<0) continue;
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				if((i+j)%2==0) cout << "#" ;
				else cout << "." ;
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

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

set<int > r,g,b;

int main(){
   int n;
   scanf("%d",&n);
   string str;
    cin>>str;
    long long ill=0;
    for(int i=0;i<n;i++){
        char temp=str[i];
        if(temp=='R'){
            r.insert(i);
        }else if(temp=='G'){
            g.insert(i);
        }else b.insert(i);
    }
    long long temp=1;
    temp*=r.size();
    temp*=b.size();
    temp*=g.size();
    set<int>::iterator itr=r.begin();
    for(itr;itr!=r.end();itr++){
        set<int>::iterator itg=g.begin();
         for(itg;itg!=g.end();itg++){
            int tempa=*itr;
            int tempb=*itg;

            if(tempa>tempb){
                swap(tempa,tempb);
            }
            int tempc=tempb+(tempb-tempa);
            int revtempc=tempa-(tempb-tempa);
            ill+=b.count(tempc)+b.count(revtempc);
            if((tempa+tempb)%2==0&&str[(tempa+tempb)/2]=='B')
                ill++;
        }
    }
    printf("%lld",temp-ill);
   return 0;
}

Measured memory_bytes: 3936
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
using namespace std;
const int INF = 1001001001;
typedef long long int ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define re0 return 0
#include<string.h>
int npr(int n , int r){//nPr
    r = n - r;
    int sum = 1;
    int i;
    for (i=n;i>=r+1;i--)sum*=i;
    return sum;
}
int gcd(int a, int b) {//最大公約数
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {//最小公倍数
    return a * b / gcd(a, b);
}
int digsum(int n) {//桁和
    int res = 0;
    while(n > 0) {
        //res += n%10;
        //　↑をres++;にすれば桁数
         res++;
        n /= 10;
    }
    return res;
}
bool isPrime(int x){//素数判定
    if(x==1)return 0;
    if(x==2)return 1;
    if(x%2==0)return 0;
    for(int i=3;i*i<=x;i++)if(x%i==0)return 0;
    return 1;
}
/*bit全探索
for (int bit = 0; bit < (1<<N); ++bit) {
}
if (bit & (1 << i)) {
}
*/


signed main(){ 
    char s;
    cin >> s;
    if (isupper(s))
   {
       cout << "A"<<endl;
   }
   else
   {
       cout << "a" << endl;
   }
    return 0;
}


Measured memory_bytes: 3620
// AtCoder165 C

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
#include <assert.h>
#include <string.h>
#include <memory.h>
#include <malloc.h>
#include <stdlib.h>

// qsortで用いる比較用関数．*a<*bならaが先になる．
int compare(const void* a, const void* b) {
    return *(int*)a - *(int*)b;
}

int main() {
    int i,j;
    int x;
    int a, b;
    long long int tmp=0;
    scanf("%d", &x);

    for(a=-118;a<=119;a++){
        for(b=-119;b<=118;b++){
            tmp = pow(a,5) - pow(b,5);
            if(tmp == x){
                printf("%d %d", a, b);
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 2596
def fun_replace(str1,str2,a,b):
    str1_list = list(str1)
    str2_list = list(str2)
    for i in range(b-a+1):
        str1_list[a+i]=str2_list[i]
    str1_changed = "".join(str1_list)
    return str1_changed

def fun_reverse(str1,a,b):
    tmp_str_list=list(str1[a:b+1])
    tmp_str_list.reverse()
    str1_list = list(str1)
    for i in range(b-a+1):
        str1_list[a+i] = tmp_str_list[i]
    str1_changed = "".join(str1_list)
    return str1_changed

def fun_print(str1,a,b):
    for i in range(a,b+1):
        print("%s"%(str1[i]),end="")
    print()


T = str(input())
change_num=int(input())
for order_num in range(change_num):
    order=input().split()

    if str(order[0]) == 'replace':
        T=fun_replace(T,str(order[3]),int(order[1]),int(order[2]))
    elif str(order[0]) == 'reverse':
        T=fun_reverse(T,int(order[1]),int(order[2]))
    else:
        fun_print(T,int(order[1]),int(order[2]))



Measured memory_bytes: 5728
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

using ii = pair<int,int>;
using ll = long long;

const int N = 705;
const int mod = 1e9 + 7;

vector<int>adj[N];
bool mat[N][N];
int n, m;
bool in[N] = {};
int cntParity[2];
bool checkClique(vector<int> v){
	memset(in, 0, sizeof in);
	for(auto x : v)in[x] = 1;
	for(auto x : v){
		int cnt = 0;
		for(auto y : adj[x])cnt += in[y];
		if(cnt != v.size())return false;
	}
	return true;
}
void kill(){cout << -1 << '\n';	exit(0);}
vector<int> g[N];
int col[N];
void dfs(int x, int c){
	if(col[x] != -1){
		if(col[x] != c)
			kill();
		return;
	}
	col[x] = c;
	cntParity[c]++;
	for(auto v : g[x])
		dfs(v,1-c);
}
int calc(int x){return x * (x-1) / 2;}
int main(){
#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#endif // ONLINE_JUDGE

	cin >> n >> m;

	for(int i = 0, u, v; i < m; i++){
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
		mat[u][v] = mat[v][u] = 1;
	}

	vector<int> Candidates;
	for(int i = 1; i <= n; i++)
		Candidates.push_back(i);

	memset(col,-1,sizeof col);

	for(auto x : Candidates)
		for(auto y : Candidates)
			if(!mat[x][y] && x != y){
				g[x].push_back(y);
			}

	vector<pair<int,int>> vp;

	for(auto x : Candidates)
		if(col[x] == -1){

			cntParity[0] = cntParity[1] = 0;
			dfs(x,0);
			vp.push_back({cntParity[0], cntParity[1]});
		}

	vector<int> vals = {0};
	int tot = Candidates.size();

	for(auto x : vp){

		vector<int>nxt;

		for(auto v : vals)
			nxt.push_back(v + x.first),
			nxt.push_back(v + x.second);

		sort(nxt.begin(), nxt.end());
		nxt.resize(unique(nxt.begin(), nxt.end()) - nxt.begin());
		vals = nxt;
	}

	int ans = n * n;

	for(auto v : vals)
		ans = min(ans, calc(v) + calc(tot - v));

	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 3840
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long y = sc.nextLong();
        long count = 0;
        while(y >= x) {
            y /= 2;
            count++;
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 22868
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

    for(;;){
        int n, x;
        cin >> n >> x;
        if(n == 0 && x == 0)    return 0;
        int ans = 0;
        for(int i = 1; i <= n; ++i){
            for(int j = 1; j < i; ++j){
                for(int k = 1; k < j; ++k){
                    if(i + j + k == x)  ++ans;
                }
            }
        }
        cout << ans << '\n';
    }
}


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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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; }

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

ll N,X;
ll patties[100], layers[100];

ll rec(ll n, ll pos){
  if(pos==0) return 0;
  if(n==0) return 1;
  
  if(pos>=2*layers[n-1]+2){
    return patties[n];
  } else if(pos >= layers[n-1]+2){
    ll tmp=pos-(layers[n-1]+2);
    ll res=patties[n-1]+1+rec(n-1,tmp);
    return res;
  } else {
    ll tmp=pos-1;
    return rec(n-1, tmp);
  }
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  cin>>N>>X;
  
  patties[0]=layers[0]=1;
  rep(i,50){
    patties[i+1]=2*patties[i]+1;
    layers[i+1]=2*layers[i]+3;
  }
  cout<<rec(N,X)<<endl;
}


Measured memory_bytes: 256
#include<iostream>

int main() {
	int a, b, x;

	std::cin >> a >> b;
	x=int((a+b) / 2);
	if ((a + b) %2==0) {
		std::cout << x << std::endl;
	}
	else {
		std::cout << x + 1 << std::endl;
	}
	}

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

int rec(int sum, const vector<int> &v, int k) {
  if(v.size() > 21) return 0;
  if(k == v.size()) return sum <= 21 ? sum : 0;
  if(v[k] == 1) return max(rec(sum+1, v, k+1), rec(sum+11, v, k+1));
  else return rec(sum+v[k], v, k+1);
}

int main() {
  string s;
  while(getline(cin,s) && s != "0") {
    stringstream ss(s);
    int a;
    vector<int> v;
    while(ss >> a) {
      v.push_back(min(a,10));
    }
    cout << rec(0, v, 0) << endl;
  }
  return 0;
}

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

vector<vector<int>> g;
vector<int> st[3];

void coloring(int cur, int pre, bool col){
    // col = 0 or 1
    st[col].push_back(cur);
    for(int to : g[cur]) {
        if (to == pre) continue;
        coloring(to, cur, !col);
    }
}

int main(void){
    int n;
    cin >> n;
    g.resize(n);
    rep(i,n-1){
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    coloring(0, -1, true);

    if (st[0].size() < st[1].size()) {
        swap(st[0], st[1]);
    }

    if ((int)st[1].size() < (n+1)/3) {
        swap(st[1], st[2]);
        rep(i,(n+1)/3){
            st[1].push_back(st[0].back());
            st[0].pop_back();
        }
    }
    while((int)st[0].size() > (n+2)/3) {
        st[2].push_back(st[0].back());
        st[0].pop_back();
    }
    while((int)st[1].size() > (n+1)/3) {
        st[2].push_back(st[1].back());
        st[1].pop_back();
    }
    vector<int> p(n);
    rep(col, 3){
        rep(i, st[col].size()){
            p[st[col][i]] = i*3 + col + 1;
        }
    }
    rep(i,n){
        cout << p[i] << (i < n-1 ? " " : "\n");
    }
    return 0;
}


Measured memory_bytes: 20724
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		System.out.println(360 / gcd(x, 360));
	}
	public static int gcd(int num1,int num2) {
        if(num2 == 0) return num1;
        else return gcd(num2 , num1 % num2 );
    }


}



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

int main(void){

    int N;
    cin >> N;
    
    int ans = 0;
    for (int i=1; i<=N; i=i+2) {
        /* iが約数８個か調べる */
        int yakusu_num = 0;
        for (int j=1; j <= i; j++) {
            if (i % j == 0) {
                yakusu_num += 1;
            }
        }
        if (yakusu_num == 8) {
            ans++;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){

  int n,p[5000],now[5000],i,result=10000000,log=0;

  cin>>n;

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

  for(i=0;i<=p[0];i++){
    log=0;
    for(int j=0;j<n;j++) now[j]=p[j];
    now[0]-=i;
    log+=i;
    for(int j=0;j<n-1;j++){
      log+=now[j]*2;
      now[j+1]-=now[j];
      now[j]=0;
      if(now[j+1]<0) now[j+1]=0;
    }
    log+=now[n-1];
    result=min(result,log);
  }

  cout<<result<<endl;

  return 0;

}

Measured memory_bytes: 3140
#include <iostream>
#include <stdio.h>
#include <math.h> 
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <string>
#include <numeric>
#include <bitset>
#include <queue>
#include <map>

using namespace std;


int main() {

	//input
	int n;
	cin >> n;

	vector<int> vec; //全体の値
	vector<int> kisu; //奇数の値(重複削除用)
	vector<int> gusu; //偶数の値(重複削除用)
	vector<int> kisu2; //奇数の値
	vector<int> gusu2; //奇数の値

	for (int i = 0; i < n; ++i) {
		int tmp = 0;
		cin >> tmp;
		vec.push_back(tmp);
		if (i % 2 == 0) {
			gusu.push_back(tmp);
			gusu2.push_back(tmp);
		}
		else if (i % 2 == 1) {
			kisu.push_back(tmp);
			kisu2.push_back(tmp);
		}
	}

	//全部同じ値ならn/2(1,1,1,1 →　2回)
	int tmp = 0;
	for (int i = 0; i < vec.size() - 1; ++i) {
		if (vec[i] == vec[i + 1]) {
			tmp++;
		}
		if (tmp == n - 1) {
			cout << n / 2 << endl;
			return 0;
		}
	}


	//奇数と偶数のvectorから出現頻度の大きい値を取得する
	map<int, int> gusumap; //偶数の各値の出現頻度管理用mapの宣言(出現回数，その値)
	vector<int> gusu_score;
	sort(gusu.begin(), gusu.end());
	sort(gusu2.begin(), gusu2.end());
	gusu.erase(unique(gusu.begin(), gusu.end()), gusu.end()); //gusuから重複を削除

	for (int i = 0; i < gusu.size(); ++i) {
		int same_cnt = 0;
		int num = 0; //最初にgusu[i]が現れた番号
		for (int j = 0; j < gusu2.size(); ++j) {
			if (gusu[i] == gusu2[j]) {
				num = j;
				break;
			}
		}
		for (int j = num; j < gusu2.size(); ++j) {
			if (gusu[i] == gusu2[j]) {
				same_cnt++;
			}
			else {
				break;
			}
		}
		gusumap.insert(make_pair(same_cnt, gusu[i]));
		gusu_score.push_back(same_cnt);
	}
	sort(gusu_score.begin(), gusu_score.end(), greater<int>());

	map<int, int> kisumap; //奇数の各値の出現頻度管理用mapの宣言(出現回数，その値)
	vector<int> kisu_score;
	sort(kisu.begin(), kisu.end());
	sort(kisu2.begin(), kisu2.end());
	kisu.erase(unique(kisu.begin(), kisu.end()), kisu.end()); //kisuから重複を削除

	for (int i = 0; i < kisu.size(); ++i) {
		int same_cnt = 0;
		int num = 0; //最初にkisu[i]が現れた番号
		for (int j = 0; j < kisu2.size(); ++j) {
			if (kisu[i] == kisu2[j]) {
				num = j;
				break;
			}
		}
		for (int j = num; j < kisu2.size(); ++j) {
			if (kisu[i] == kisu2[j]) {
				same_cnt++;
			}
			else {
				break;
			}
		}
		kisumap.insert(make_pair(same_cnt, kisu[i]));
		kisu_score.push_back(same_cnt);
	}
	sort(kisu_score.begin(), kisu_score.end(), greater<int>());

	//奇数と偶数で1，2位の最頻値を有する値を調べる
	int kisu_max_app = 0; //最頻値
	int gusu_max_app = 0; //最頻値
	int kisu_max_app2 = 0; //2最頻値
	int gusu_max_app2 = 0; //2最頻値

	kisu_max_app = kisu_score[0];
	gusu_max_app = gusu_score[0];
	if (kisu_score.size() > 2) {
		kisu_max_app2 = kisu_score[1];
	}
	if (gusu_score.size() > 2) {
		gusu_max_app2 = gusu_score[1];
	}

	int kisu_max_num = 0; //有する値
	int gusu_max_num = 0; //有する値
	kisu_max_num = kisumap[kisu_score[0]];
	gusu_max_num = gusumap[gusu_score[0]];

	if (kisu_max_num != gusu_max_num) {
		cout << n - (gusu_max_app + kisu_max_app) << endl;
		return 0;
	}
	else {
		int adst = max((kisu_max_app + gusu_max_app2), (gusu_max_app + kisu_max_app2));

		cout << n - adst << endl;
		return 0;
	}

	return 0;
}

Measured memory_bytes: 2296
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using PL = pair<ll, ll>;
// Welcome to my source code

int main() {
    int n;
    cin >> n;
    int a[n], b[n], c[n], d[n + 1];
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    for (int i = 0; i < n; i++) cin >> c[i];
    sort(a, a+n);
    sort(c, c+n);
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ll x = lower_bound(a, a+n, b[i]) - a;
        ll y = n - (upper_bound(c, c+n, b[i]) - c);
        ans += x * y;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    veci A(3);
    REP(i,3) cin >> A[i];
    int ans = 1e5;
    REP(i,3) REP(j,3) REP(k,3) {
        if(i == j || j == k || i == k) continue;
        chmin(ans,abs(A[i]-A[j])+abs(A[j]-A[k]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};
use std::collections::HashSet;

fn main() {
    input! {
        n: usize,
        m: usize,
        aabb: [(usize, usize); m]
    };
    let mut first = HashSet::new();
    let mut second = HashSet::new();
    for (a, b) in aabb {
        if a == 1 {
            first.insert(b);
        }
        if b == n {
            second.insert(a);
        }
    }
    println!(
        "{}POSSIBLE",
        ["", "IM"][(first.intersection(&second).count() == 0) as usize]
    );
}


Measured memory_bytes: 10256
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  int N;
  cin >> N;
  long long X;
  cin >> X;
  vector<long long> burger(N + 1);
  burger[0] = 1;
  vector<long long> p(N + 1);
  p[0] = 1;
  for (int i = 1; i <= N; i++) {
    burger[i] = 2 * burger[i - 1] + 3;
    p[i] = 2 * p[i - 1] + 1;
  }
  if(X == burger[N]){
    cout << p[N] <<endl;
    return 0;
  }
  int n = N-1;
  long long ans = 0;
  while(X > 0){
    X--;
    if(X - burger[n] >= 0){
      X -= burger[n]; 
      ans += p[n];
      if(X == 0){
        cout << ans <<endl;
        return 0;
      } else{
        ans ++;
      }
    } else{
      n--;
    }
  }
  cout << ans <<endl;
}

Measured memory_bytes: 3596
//=========================================c++
/* ===========================================
// 20.04.07 AtCoder Beginner Contest 160. A - Coffee 
// 
// 
=========================================== */
/* ===========================================

1 周 KK メートルの円形の湖があり、その周りに N 軒の家があります。
i 番目の家は、湖の北端から時計回りに Ai メートルの位置にあります。
家の間の移動は、湖の周りに沿ってのみ行えます。
いずれかの家から出発して N 軒すべての家を訪ねるための最短移動距離を
求めてください。

::test input
20 3
5 10 15
=========================================== */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int (i)=1;(i)<=(n);i++)
#define rez(i,n) for(int (i)=0;(i)<(n);i++)
#define ET "\n"
#define CLR(arr) memset(&arr, 0, sizeof(arr))
#define PAIR pair<int, int>

static struct GV{
    int K = 0;
    int N = 0;
    vector<int> A;
    int max_interval = 0;
}gv;

void build(){
    cin >> gv.K >> gv.N;
    rez (i, gv.N) {
        int a; cin >> a;
        gv.A.push_back(a);
        if (i > 0) {
            gv.max_interval = max(gv.max_interval, gv.A[i] - gv.A[i-1]);
        }
    }
}

void solve(){
    int ans = 0;
    ans = min(  gv.A[gv.N -1] - gv.A[0], 
                gv.K - gv.max_interval );
    cout << ans;
}

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




Measured memory_bytes: 1400
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
import numpy as np

a,b,h,m = map(int, input().split())

mrad = 2*np.pi/60*m
hrad = 2*np.pi/12*h + 2*np.pi/12/60*m

drad = min(abs(hrad - mrad), 2*np.pi-abs(hrad-mrad) )

tmp = a**2+b**2 - 2*a*b*np.cos(drad)

ans = np.sqrt(tmp)
print(ans)


Measured memory_bytes: 27192
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	string s, t; cin >> s >> t;
	int ans = 0;
	for (int i = 0; i < (int)s.size(); ++i)
		ans += s[i] != t[i];
	cout << ans << '\n';
}

Measured memory_bytes: 3856
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = True

a, b, c, k = MAP()
ab = -1 if k % 2 else 1
ans = ab * a - ab * b
if abs(ans) > 10 ** 18:
    print('Unfair')
else:
    print(ans)

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

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

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

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


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

  int ans = -N;
  REP(i, N){
    int A; cin >> A;
    ans += A;
  }

  cout << ans << "\n";

  return 0;
}

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

// A - Lucky 7
int main() {
    int N;
    cin >> N;
    for (int i = 0; i < 3; i++) {
        if (N % 10 == 7) {
            cout << "Yes";
            return 0;
        }
        N = N / 10;
    }
    cout << "No";
}


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

signed main(void)
{
	int n;
	cin >> n;
	vector<int> a;
	rep(i, 1 << n) 
	{
		int b;
		cin >> b;
		a.push_back(b);
	}
	while(n > 0)
	{
		vector<int> vec;
		for(int i = 0; i < (1 << n); i+=2)
		{
			vec.push_back(abs(a[i] - a[i + 1]));
		}
		swap(a, vec);
		n--;
	}
	cout << a[0] << endl;
	return 0;
}


Measured memory_bytes: 2292
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1ll << 60

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

int main(void) {
	int num, i;
	ll k = 1, ans = 0;
	cin >> num;
	num++;
	vector<ll> d(num), f(num);
	rep(i, num)
		cin >> d[i];
	f = d;
	for (i = num - 2; i >= 0; i--)
		f[i] += f[i + 1];
	rep(i, num) {
		if (k < d[i]) {
			ans = -1;
			break;
		}
		ans += min(k, f[i]);
		k -= d[i];
		k <<= 1;
		if (k > INF)
			k = INF;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 4820
#include "bits/stdc++.h"

using namespace std;

#define ll long long
#define vi  vector<int>
#define vvi vector<vi>
#define pi  pair<int,int>
#define mp  make_pair
#define pb  push_back
#define MOD 1e9 + 7
#define PAI  3.1415
#define all(x) (x).begin(),(x).end()
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define pr(x) cout << x << endl
#define Endl endl
#define rep(i,n) for(int i = 0 ; i < n; i++)

const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int ddx[8] = {-1,0,1,-1,1,-1,0,1};
const int ddy[8] = {-1,-1,-1,0,0,1,1,1};
const int inf = 99999999;
const ll linf = 1LL << 62;

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

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


int main(){

  string s; cin >> s;
  char c[4] = {'A', 'C', 'G', 'T'};
  int ans = 0, cnt = 0;

  for(int i = 0; i < s.length(); i++)
  {
    bool flag = false;

    for(int j = 0; j < 4; j++){
      if(s[i] == c[j])
        flag = true;
    }

    if(flag)
      cnt ++;
    else
      cnt = 0;

    chmax(ans, cnt);

  }
  
  pr(ans);

  return 0;
}


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

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,m,n) for(int i=((int)(m));i<(int)(n);++i)
#define SZ(x) ((int)x.size())

using namespace std;
typedef long long ll;

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

  ll B[M];
  ll A[N][M];

  REP(i,M){
    cin >> B[i];
  }

  REP(i,N){
    REP(j,M){
      cin >> A[i][j];
    }
  }

  ll ret = 0;

  REP(i,N){
    ll tmp = 0;
    REP(j,M){
      tmp += A[i][j] * B[j];
    }
    tmp += C;
    if(tmp > 0) ret++;
  }
  cout << ret << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define c(n) cin>>n
#define c2(n,m) cin>>n>>m
#define c3(n,m,k) cin>>n>>m>>k
#define co(n) cout<<n<<endl
using namespace std;

int main(){
  int a, b;
  c2(a,b);
  char c[a+2][b+2]={};
  int x[a+2][b+2]={};
  rep(i,1,a+1){
    rep(j,1,b+1){
      c(c[i][j]);
    }
  }
  rep(i,1,a+1){
    rep(j,1,b+1){
      if(c[i][j]=='#'){
        x[i][j]+=8;
        rep(k,-1,2){
          rep(l,-1,2){
            x[i+k][j+l]++;
          }
        }
      }
    }
  }
  rep(i,1,a+1){
    rep(j,1,b+1){
      if(x[i][j]>=9) cout << '#';
      else cout << x[i][j];
    }
    cout << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll L[86];
int main(){
    L[0]=2;
    L[1]=1;
    for(int i=2;i<=86;i++)
        L[i]=L[i-1]+L[i-2];
    int N;    
    cin>>N;    
    cout<<L[N]<<"\n";    
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e17;
 
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
 
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;}
 
template<typename T>vector<T>
make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}

int A,B,C,D,E,F,G,H,I,J,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,K;
string s,t;

signed main()
{
	IOS();
	cin>>A>>P;
	P+=A*3;
	cout<<P/2<<endl;
}

Measured memory_bytes: 256
import random
import time

def down_score(d, c, last_d, score):
    sum = 0
    for i in range(26):
        sum = sum + c[i]*(d-last_d[i])
        
    return int(score - sum)


def main():
    D = int(input())

    c = list(map(int, input().split()))

    s = [list(map(int, input().split())) for i in range(D)]

    start = time.time()
    
    last_d = [0 for i in range(26)]
    
    ans = []
    
    score1 = 0
    
    for i in range(D):
        max = 0
        idx = 0
        for j in range(26):
            if max < (s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2) and c[j] != 0:
                max = s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2
                idx = j
            elif max == (s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2) and c[j] * (i-last_d[j])*(i-last_d[j]+1)/2 > c[idx]* (i-last_d[idx])*(i-last_d[idx]+1)/2:
                idx = j
            
        last_d[idx] = i+1
        score1 += s[i][j]
        score1 = down_score(i+1,c,last_d,score1)
        
        ans.append(idx)

    random.seed(20)
    while time.time() - start < 1.9:
        idx = random.randint(0,25)
        d = random.randint(0,D-1)
        if c[idx] == 0 or ans[d-1] == idx:
            continue
        tmp = ans[d]
        ans[d] = idx
        last_d = [0 for i in range(26)]
        score2 = 0    
        for i in range(D):
            score2 += s[i][ans[i]-1]
            last_d[ans[i]-1] = i+1
            score2 = down_score(i+1, c, last_d, score2)
        
        if score1 > score2:
            ans[d] = tmp
    
    for i in range(D):
        print(ans[i]+1)  

if __name__ == "__main__":
    main()


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

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; }

ll nCr(ll n, ll r) {
    if (r > n - r)
        r = n - r; // because C(n, r) == C(n, n - r)
    long long ans = 1;
    int i;

    for (i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }

    return ans;
}

int main() {
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;

    int a, b;

    if (n <= 1)
        a = 0;
    else
        a = nCr(n, 2);
    if (m <= 1)
        b = 0;
    else
        b = nCr(m, 2);
    cout << a + b << endl;
    return 0;
}


Measured memory_bytes: 256
N=int(input())
a=[int(i) for i in input().split(" ")]

count=1
result=0
for i in range(len(a)-1):
    if a[i+1]==a[i]:
        count+=1
    else:
        result+=int(count/2)
        count=1
result+=int(count/2)
print(result)


Measured memory_bytes: 3060
import os
import heapq
import sys,threading
import math
import bisect
import operator
from collections import defaultdict
sys.setrecursionlimit(10**5)
from io import BytesIO, IOBase
def gcd(a,b):
    if b==0:

        return a
    else:
        return gcd(b,a%b)
def power(x, p,m):
    res = 1
    while p:
        if p & 1:
            res = (res * x) % m
        x = (x * x) % m
        p >>= 1
    return res
def inar():
    return [int(k) for k in input().split()]

def lcm(num1,num2):
    return (num1*num2)//gcd(num1,num2)

def main():
    #t=int(input())
    t=1
    for _ in range(t):

        mn=input()
        s=input()
        n=len(s)
        ans=10**10
        for i in range(len(mn)-n+1):
            #print(i)
            temp=0
            for j in range(n):
                if s[j]!=mn[i+j]:
                    temp+=1
            ans=min(ans,temp)
        print(ans)



BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == "__main__":
    main()
    #threadin.Thread(target=main).start()


Measured memory_bytes: 75128
#include <bits/stdc++.h>
using namespace std;
const int MAX = 2e5 + 10;
char s[MAX];
int memo[MAX];
int memo2[MAX];
int nw1[MAX];
int nw2[MAX];
int n, k, c;
int run(int id) {
	if(id >=n)return 0;
	int &res = memo[id];
	if(res != -1)return res;
	int nwork = nw1[id] =  run(id+1);
	if(s[id] == 'x')return res = nwork;
	else return res = max(nwork, 1 + run(id+c+1));
}
int run2(int id) {
	if(id < 0)return 0;
	int &res = memo2[id];
	if(res != -1)return res;
	int nwork = nw2[id] = run2(id-1);
	if(s[id] == 'x')return res = nwork;
	else return res = max(nwork, 1 + run2(id-c-1));
}
int main() {
	
	scanf("%d %d %d", &n, &k, &c);
	scanf(" %s", s);
	memset(memo, -1, sizeof(memo));
	memset(memo2, -1, sizeof(memo2));
	run(0);
	run2(n-1);
	for(int i = 0; s[i]; ++i){
		if(s[i] == 'x')continue;
		if(nw1[i] + nw2[i] < k){
			printf("%d\n", i+1);
		}
	}
	return 0;
}


Measured memory_bytes: 11008
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define reps(i, n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define repi(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
int main(){
    ll n;
    cin>>n;
    vector<ll> a(n+1),b(n);
    rep(i,n+1) cin>>a.at(i);
    rep(i,n) cin>>b.at(i);
    
    ll ans=0;
    rep(i,n){
        ans+=min((a.at(i)+a.at(i+1)),b.at(i));
        ll k=a.at(i+1);
        a.at(i+1)=max((ll)0,a.at(i)+a.at(i+1)-b.at(i));
        a.at(i+1)=min(a.at(i+1),k);
    }
    
    cout<<ans<<endl;
}


Measured memory_bytes: 1792