akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int a[11][11]= {0};
int num[11]= {0};
int yu[12]={0};
int fun(int n,int m)
{
    int ans=0,flag=1;
    //int yu[11]= {0};
    int sum=1;
    for(int i=0; i<n; ++i)
    {
        sum=2*sum;
    }
    //cout << sum <<endl;
    int cnt[11]={0};
    for(int i=0; i<sum; ++i)
    {
        flag=1;

        int t=i;
        for(int j=0; j<n; ++j)
        {
            num[j]=t%2;
            t=t/2;
        }
        for(int j=1;j<=m;++j){
            cnt[j]=0;
        }
        for(int j=0;j<n;++j){

            if(num[j])
            for(int k=1;k<=m;++k){
                if(a[k][j])
                    cnt[k]^=1;
            }
        }
        for(int j=1;j<=m;++j){
            if(cnt[j]!=yu[j]){
                flag=0;
                break;
            }
        }
        if(flag==1){
            ans++;
        }

    }
    return ans;
}
int main()
{
    std::ios::sync_with_stdio(false);
    int n,m,num,t;
    cin  >> n >> m;
    for(int i=1; i<=m; i++)
    {
        cin >> num;
        for(int j=0; j<num; ++j)
        {
            cin >> t;
            a[i][t-1]=1;
        }
    }
    for(int i=1;i<=m;i++){
        cin >> yu[i];
        yu[i]=yu[i]%2;
    }
    int t1=fun(n,m);
    cout << t1 << endl;
    return 0;
}


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

int main(){
  int n;
  cin>>n;
  
  string s;
  cin>>s;
  
  bool ans=false;
  if(n%2==0){
    string substr1=s.substr(0,n/2);
    string substr2=s.substr(n/2,n/2);
    if(substr1==substr2){
      ans=true;
    }
  }
  
  if(ans==true){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <numeric>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 10007;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);

typedef std::pair<int, int> P;
typedef pair<int, P> pp;

const int smax = 100100;

vector<P> edge[smax];
int c, n, m, s, d; // c...??????????????° n...?????? m...??? s...????????? d...?????? 
LL v[15][smax]; //15....max of tickets

int solve() {
	v[c][s] = 0; //?????????
	priority_queue<pp, vector<pp>, greater<pp> > q;
	q.push(pp(0, P(s, c))); //cost,now,ticket(now)
	while (!q.empty()) {
		pp V = q.top();
		q.pop();
		int now_v = V.second.first;
		int now_t = V.second.second;
		if (v[now_t][now_v] < V.first) continue; //v.first(?????????)???v[now_t][now_v]???????????§????????£???????????????????????§?????????

												 //not use tickets
		for (int i = 0; i<edge[now_v].size(); i++) {
			if (v[now_t][edge[now_v][i].first] > v[now_t][now_v] + edge[now_v][i].second) {
				v[now_t][edge[now_v][i].first] = v[now_t][now_v] + edge[now_v][i].second;
				q.push(pp(v[now_t][now_v] + edge[now_v][i].second, P(edge[now_v][i].first, now_t)));
			}
		}

		// use tickets
		if (now_v > 0) {
			for (int i = 0; i<edge[now_v].size(); i++) {
				P p = edge[now_v][i];
				int next_c = p.second / 2;
				if (now_t == 0)continue;
				if (v[now_t - 1][p.first] > v[now_t][now_v] + next_c) {
					v[now_t - 1][p.first] = v[now_t][now_v] + next_c;
					q.push(pp(v[now_t - 1][p.first], P(p.first, now_t - 1)));
				}
			}
		}
	}
	LL ans = INF;
	for (int i = 0; i<c + 1; i++) {
		ans = min(ans, v[i][d]);
	}
	return ans;
}

int main(void) {
	while (cin >> c >> n >> m >> s >> d && c | n | m | s | d) {
		for (int i= 0; i < smax;i++) edge[i].clear();
		fill(v[0], v[0] + 15 * smax, INF);
		for (int i = 0; i < m;i++) {
			int a, b, f;
			cin >> a >> b >> f;
			edge[a].push_back(P(b, f));
			edge[b].push_back(P(a, f));
		}
		cout << solve() << endl;
	}
	return 0;
}

Measured memory_bytes: 17192
(let* ((n (read))
       (m (read))
       (lst (concatenate 'vector (loop :repeat n :collect (1- (read)))))
       (arr (make-array n :initial-element -1 :element-type 'fixnum))
       (st nil)
       (ans 0))
  (setf st (loop :for j :from 0
                 :for k := 0 :then (aref lst k)
                 :if (= -1 (aref arr k)) :do (setf (aref arr k) j)
                   :else :return (list (aref arr k) k)))
  (setf ans (loop :for j :from 1
                  :for k := (aref lst (second st)) :then (aref lst k)
                  :if (= k (second st)) :return j))
  (if (<= (first st) m)
      (loop :for j :from (mod (- m (first st)) ans) :downto 0
            :for k := (second st) :then (aref lst k)
            :finally (princ (1+ k)))
      (loop :for j :from m :downto 0
            :for k := 0 :then (aref lst k)
            :finally (princ (1+ k)))))

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

char field[101][101];
int dx[4] = { 0, -1, 0, 1 };
int dy[4] = { 1, 0, -1, 0 };
int nx, ny;
int h, w;

void dfs( int x, int y, char before );

int main()
{
   int cnt = 0;

   while( 1 )
   {
      cin >> h >> w;
      if( h == 0 && w == 0 ) break;

      for( int i = 0; i < h; ++i )
      {
         for( int j = 0; j < w; ++j )
         {
            cin >> field[i][j];
         }
      }

      for( int i = 0; i < h; ++i )
      {
         for( int j = 0; j < w; ++j )
         {
            if( field[i][j] != '0' )
            {
               dfs( j, i, field[i][j] );
               ++cnt;
            }
         }
      }
      cout << cnt << endl;
      cnt = 0;
   }
}

void dfs( int x, int y, char before)
{
   field[y][x] = '0';
   for( int i = 0; i < 4; ++i )
   {
      nx = x + dx[i];
      ny = y + dy[i];
      if( 0 <= nx && nx < w && 0 <= ny && ny < h && before == field[ny][nx] )
      {
         dfs( nx, ny, before );
      }
   }

   return ;
}

Measured memory_bytes: 1636
n = int(input())
S = input()

A = [0] * n

for i in range(n):
    if S[i] == "R":
        A[i] = 0
    if S[i] == "G":
        A[i] = 1
    if S[i] == "B":
        A[i] = 2
#print(A)

Cnt = [0] * 3
for a in A:
    Cnt[a] += 1

ans = 1
for cnt in Cnt:
    ans *= cnt

# j - i = k -j　
for j in range(n):
    for i in range(j):
        k = 2*j - i
        if k < n:
            if A[i] == A[j]: continue
            if A[i] == A[k]: continue
            if A[k] == A[j]: continue
            ans -= 1
print(ans)
            

Measured memory_bytes: 9224
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main(void) {
	const double PI = acos(-1.0);
	int R;
	cin >> R;
	double ans = 2.0 * PI * R;
	cout << fixed << setprecision(5) << ans << '\n';
	return 0;
}


Measured memory_bytes: 3764
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class DSumOfDivisors {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      ll ans = 0;
      for(int i=1; i<=n; i++) {
        ll k = n/i;
        ans += i*k*(k+1)/2;
      }
      cout << ans << endl;
    }
};

signed main() {
  DSumOfDivisors solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 3672
fun main(args: Array<String>) {
    val k = readInt()
    val (a, b) = readListInt()
    var str = "NG"
    for (i in a..b) {
        if (i % k == 0) {
            str = "OK"
        }
    }
    println(str)
}

private fun read() = readLine()!!

private fun readInt() = read().toInt()

private fun readLong() = read().toLong()

private fun readDouble() = read().toDouble()

private fun readListString() = read().split(" ")

private fun readListInt() = readListString().map { it.toInt() }

private fun readListLong() = readListString().map { it.toLong() }

private fun readListDouble() = readListString().map { it.toDouble() }

private fun readMatrixString(n: Int): List<List<String>> {
    val matrix = mutableListOf<List<String>>()
    for (i in 0 until n) {
        val list = readListString()
        matrix.add(list)
    }
    return matrix
}

private fun readMatrixInt(n: Int): List<List<Int>> {
    val matrix = mutableListOf<List<Int>>()
    for (i in 0 until n) {
        val list = readListInt()
        matrix.add(list)
    }
    return matrix
}

private fun readMatrixDouble(n: Int): List<List<Double>> {
    val matrix = mutableListOf<List<Double>>()
    for (i in 0 until n) {
        val list = readListDouble()
        matrix.add(list)
    }
    return matrix
}

private fun readMatrixLong(n: Int): List<List<Long>> {
    val matrix = mutableListOf<List<Long>>()
    for (i in 0 until n) {
        val list = readListLong()
        matrix.add(list)
    }
    return matrix
}



Measured memory_bytes: 36408
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  if(n==0){
    cout<<0<<endl;
    return 0;
  }
  vector<int>v;
  while(n!=1){
    int a=n/(-2);
    int b=n%(-2);
    if(b==-1){
      b=1;
      a++;
    }
    n=a;
    v.push_back(b);
  }
  v.push_back(1);
  for(int i=0;i<v.size();i++)cout<<v[v.size()-i-1];
}
                                     



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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

#define MAX_V 105

int main(){
    string s;
    cin >> s;
    if((s[2] == s[3]) && s[4] == s[5]){
        cout << "Yes" << endl; 
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
N,M = gets.split.map(&:to_i)
A = N.times.map { gets.chomp }
B = M.times.map { gets.chomp }

(N-M+1).times do |i|
  (N-M+1).times do |j|
    if M.times.all? { |k| B[k] == A[i+k][j..(M-1+j)] }
      puts 'Yes'
      exit
    end
  end
end
# ここまで来たら不一致
puts 'No'

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e18;

int main(){
  string s;
  cin >> s;
  int a,z;
  REP(i,s.size()){
    if(s[i]=='A'){
      a=i;
      break;
    }
  }
  REP(i,s.size()){
    if(s[s.size()-1-i]=='Z'){
      z=s.size()-1-i;
      break;
    }
  }
  cout << z-a+1 << endl;
}



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

typedef long long ll;

vector<int> v(101);

int n, x;

int main(){
    cin >> n >> x;
    v.resize(n);

    for (int i = 0; i < n; i++){
        cin >> v[i];
    }
    sort(v.begin(), v.end());

    int cnt = 0;
    int res = 0;
    for (int i = 0; i < n; i++){
        cnt += v[i];
        res++;
    }

    while(cnt + v[0] <= x){
        cnt += v[0];
        res ++;
    }

    cout << res << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
#define DUMP(x)  cerr<<#x<<" = "<<(x)<<endl;

struct edge { int to, cost; };

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

signed main()
{
   int n; cin >> n;
   V<int> a(n);
   for (int i = 0; i < n; i++) {
      cin >> a[i];
   }

   V<V<int>> dp(n+1, V<int>(n+1));
   for (int i = n-1; i >= 0; i--) {
      for (int j = n-1; j >= 0; j--) {
         if (i + j >= n) continue;

         if ((i + j) % 2 == 0) {
            dp[i][j] = max(dp[i+1][j] + a[i], dp[i][j+1] + a[n-1-j]);
         } else {
            dp[i][j] = min(dp[i+1][j] - a[i], dp[i][j+1] - a[n-1-j]);
         }
      }
   }
   cout << dp[0][0] << endl;

   return 0;
}


Measured memory_bytes: 70784
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  int s;
  cin >> s;
  
  int c = s/100;
  int d = s%100;
  
  if(c >= 1 && c <= 12){
    if(d >= 1 &&  d <= 12){
      cout << "AMBIGUOUS" << endl;
    }
    else{
      cout << "MMYY" << endl;
    }
  }
  else{
    if(d >= 1 && d <= 12){
      cout << "YYMM" << endl;
    }
    else{
      cout << "NA" << endl;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;

int main(){
    double t, x;
    
    cin >> t >> x;
    
    printf("%.9f", t/x);
}


Measured memory_bytes: 256
N = int(input())
S = input()
left= 0
right = S[1:].count('E')
result = left + right
for i in range(1, N):
  if S[i - 1] == "W":
    left += 1
  if S[i] == "E":
    right -= 1
  result = min(result, left + right)
print(result)

Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long int a,b,v,w,t;
	cin>>a>>v>>b>>w>>t;
	long long int i,j,k;
	i=(v-w)*t;j=b-a;
	j=abs(j);
	if(i>=j)cout<<"YES";
	else cout<<"NO";
}

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

using namespace std;

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

	vector<vector<int>> dp(3, vector<int>(n + 1, 0));
	for (int i = 1; i < 3; ++i) {
		for (int j = 1; j < n + 1; ++j)
			cin >> dp[i][j];
	}

	for (int i = 1; i < 3; ++i) {
		for (int j = 1; j < n + 1; ++j)
			dp[i][j] += max(dp[i - 1][j], dp[i][j - 1]);
	}

	cout << dp[2][n];

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N) cin >> A[i];

  ll ans = 0;
  int r = 0;
  int temp = 0;

  rep(l, N) {
    while (r < N && (temp ^ A[r]) == (temp + A[r])) {
      temp += A[r];
      r++;
    }
    ans += r - l;
    if (r == l)
      r++;
    else {
      temp -= A[l];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define watch(x) cout << (#x) << " is " << (x) << endl
#define f(t) for(ll i=0;i<t;i++)
#define ll long long int
#define ld long double
#define umpl unordered_map<ll,ll> 
#define vl vector<ll>
#define vld vector<ld>
#define vvl vector<vl>
#define pb push_back
#define mod 998244353
#define inf 1e18
#define pcout(x,p) cout<<fixed<<setprecision(p)<<x
#define all(a) a.begin(),a.end()
#define endl "\n"

inline ll mul(ll a, ll b){ return (a * 1ll * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c >= mod) c -= mod; return c; }
inline ll max(ll a, ll b){return a>b?a:b;}
inline ll min(ll a, ll b){return a<b?a:b;}
inline ll ceil(ll a,ll b){if(a%b==0)return a/b;else return a/b+1;}
inline ll mo(ll a,ll b){if(b<0){b=abs(b)%mod;b=a-b;return (b<0)?b+mod:b;}else{return (a+b)%mod;}}
inline ll pow(ll a,ll b){if(b==0){return 1;}else{if(b%2==0){ll temp=pow(a,b/2);return temp*temp;}
else{return a*pow(a,b-1);}}}

struct comp { 
    template<class T1,class T2,class T3,class T4>
    bool operator()(const pair<T1,T2> &p1,const pair<T3,T4> &p2){
        if(p1.first!=p2.first)return p1.first<p2.first;
        else return p1.second<p2.second;
    }
}; 

int main(){
    fio;
    ll n;cin>>n;
    map<string,ll> mp;
    f(n){
        string data;cin>>data;
        mp[data]++;
    }
    for(string t:{"AC","WA","TLE","RE"}){
        cout<<t<<" x "<<mp[t]<<endl;
    }
}


Measured memory_bytes: 3660
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split(' ');
        var lakeSize = int.Parse(input[0]);
        var houseCount = int.Parse(input[1]);

        var houseNums = Console.ReadLine().Split(' ');

        var distance = int.MaxValue;


        //iはスタート
        for(var i = 0; i < houseNums.Length; i++)
        {
            if (i == houseNums.Length - 1)
            {
                var dis1 = int.Parse(houseNums[i]) - int.Parse(houseNums[0]);
                var dis2 = int.Parse(houseNums[i - 1]) - int.Parse(houseNums[i]) + lakeSize;
                var dis = (dis1 < dis2 ? dis1 : dis2);
                if (dis < distance)
                {
                    distance = dis;
                }
            }
            else if(i == 0)
            {
                var dis1 = int.Parse(houseNums[houseNums.Length - 1]) - int.Parse(houseNums[0]);
                var dis2 = int.Parse(houseNums[0]) - int.Parse(houseNums[1]) + lakeSize;
                var dis = (dis1 < dis2 ? dis1 : dis2);
                if (dis < distance)
                {
                    distance = dis;
                }

            }
            else
            {
                //反時計回り
                var dis1 = int.Parse(houseNums[i]) - int.Parse(houseNums[i + 1]) + lakeSize;
                //時計回り
                var dis2 = int.Parse(houseNums[i - 1]) - int.Parse(houseNums[i]) + lakeSize;
                var dis = (dis1 < dis2 ? dis1 : dis2);
                if(dis < distance)
                {
                    distance = dis;
                }
            }
            
        }

        Console.WriteLine(distance);
        Console.ReadLine();
    }
}



Measured memory_bytes: 28892
// May this submission get accepted
#pragma GCC optimize ("O3")
#pragma GCC target("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) { if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(DUMPALL_ITR, (q).size()) { cerr << (q)[DUMPALL_ITR] << (DUMPALL_ITR == DUMPALL_ITR_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using  ld = long double;
using namespace std;

// 標準入出力
struct inp {
    size_t sz;
    inp(size_t _sz = 1) : sz(_sz) {}
    template <typename T> operator T () const { T a; cin >> a; return a; }
    template <typename T> operator vector<T> () const { vector<T> a(sz); for (size_t i = 0; i < sz; i++) cin >> a[i]; return a; }
    template <typename T, typename U> operator pair<T, U> () const { T f; U s; cin >> f >> s; return pair<T, U>(f, s); }
};
inp inp1; // input one
template <typename T> void say(T &x, char end = '\n') { cout << x << end; }
template <typename T> void say(vector<T> &x, char sep = ' ', char end = '\n') { for (size_t i = 0, sz = x.size(); i < sz; i++) { cout << x[i] << (i == sz-1 ? end : sep); } }

// モジュール


// 処理内容
int main() {
    
    ios::sync_with_stdio(false); // stdioを使うときはコメントアウトすること
    cin.tie(nullptr);            // インタラクティブ問題ではコメントアウトすること
    
    ll h = inp1;
    ll n = inp1;
    vector<ll> a(n), b(n);
    REP(i, n) {
        cin >> a[i] >> b[i];
    }

    vector<ll> dp(h+1, INF);
    dp[0] = 0;
    REP(i, n) {
        REP(j, h) {
            chmin(dp[min(h, j+a[i])], dp[j]+b[i]);
        }
    }
    say(dp[h]);
    
}

Measured memory_bytes: 384
import sys
import math
def input():
    return sys.stdin.readline().strip()

def main():
    n, d = map(int, input().split())
    X=[]
    count = 0
    sum = 0
    for i in range(n):
        x = list(map(int, input().split()))
        X.append(x)
    for i in range(n-1):
        for v in range(i+1,n):
            for u in range(d):
                sum += (X[i][u] - X[v][u])**2
            len = math.sqrt(sum)
            sum = 0
            if len == int(len):
                count += 1
    print(count)


main()

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

int main()
{
    int r,g,b;
    cin >> r >> g >> b;

    int num = 100 * r + 10 * g + 1 * b;
    if (num % 4 == 0){
        cout << "YES" << endl;
    } else{
        cout << "NO"<< endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
	string s; cin >> s;
    int ssize = s.size();
    for (int i = 0; i < ssize; i++)
    {
        if (i % 2 == 0) cout << s[i];
    }
    cout << endl;
	return 0;
}

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



// ABC128B - Guidebook
// https://atcoder.jp/contests/abc128/tasks/abc128_b
void ABC128B() {

	int N;
	cin >> N;

	vector<pair<pair<string, int>,int>> G(N);

	for (int i = 0; i < N; i++)
	{
		G[i].second = i+1; //レストランの番号は1から始まる
		int tmp;
		cin >> G[i].first.first >> tmp;
		G[i].first.second = -tmp; //スコアは降順にしたいので-をかけておく
	}

	sort(G.begin(), G.end());

	for (int i = 0; i < N; i++)
	{
		cout << G[i].second << endl;
	}
}



int main() {
	ABC128B();

	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func mergeSort(a []int) []int {
//       fmt.Println("Mergesort:",a)
        if len(a) == 1 {
                return a
        }
        n := len(a)
        left := mergeSort(a[:n/2])
        right := mergeSort(a[n/2:])
//       fmt.Println("Left;",left," Right:",right)
        var l,r int
        sorted := make([]int,n)
        for i := 0 ; i < n ; i++ {
                if len(right) == r || (len(left) > l && left[l] <= right[r]){
                        sorted[i] = left[l]
                        l++
                } else {
                        sorted[i] = right[r]
                        r++
                }
//                fmt.Println("Now sorting :",sorted)
        }
        return sorted

}


func main(){
	var n int
	fmt.Scan(&n)
	a := make([]int,n)
	for i := 0 ; i < n ; i++ {
		fmt.Scan(&a[i])
	}
	a = mergeSort(a)
	flag := true
	for i := 0 ; i < n-1 ; i++ {
		if flag && a[i] == a[i+1] {
			flag = false
		}
	}
	if flag {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct Edge{ll from, to, cost;};
struct node{ll cost, to;
  bool friend operator>(node a, node b){
    return a.cost>b.cost;
  }
};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

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

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll A, B, C, K;
  cin >> A >> B >> C >> K;
  ll cur=A;
  ll ans = A;
  if(A>=K){
    cout << K;
  }else if(A+B>=K){
    cout << A;
  }else{
    cout << A -1*(K-A-B);
  }
  return 0;
}


Measured memory_bytes: 3636
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
#sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]





# @lru_cache(None)
s=list(input())
A=[]
for i in range(len(s)):
    if(s[i]=="W"):
        A.append(i)
k=0
i=0
for x in A:
    k+=(x-i)
    i+=1
print(k)

Measured memory_bytes: 14852
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

int main(){
    string a,b,c;
    cin>>a>>b>>c;
    a.at(0)-=0x20;
    b.at(0)-=0x20;
    c.at(0)-=0x20;
    
    cout<<a.at(0)<<b.at(0)<<c.at(0)<<endl;
    
    return 0;
}

Measured memory_bytes: 256
program bridge
  integer :: n, m, i, k
  integer :: a(50), b(50), c(50)
  a = 0
  b = 0
  c = 0
  read(*,*) n, m
  if (n.eq.1) then
    write(*,'(i0)') 1
    stop
  end if
  do i = 1, m
    read(*,*) a(i), b(i)
  end do
  do i = 1, m
    if (is_bridge(n,m,a(1:m),b(1:m),i)) c(i) = 1
  end do
  write(*,'(i0)') sum(c(1:m))
  stop
contains
  function is_bridge(n,m,a,b,i) result(r)
    implicit none
    integer, intent(in) :: n, m, a(m), b(m), i
    integer             :: x(m-1), y(m-1), j, k
    logical             :: r, v(n)
    k = 0
    do j = 1, m-1
      if (j.eq.i) k = 1
      x(j) = a(j+k)
      y(j) = b(j+k)
    end do
    v = .true.
    call dfs(n,m,x,y,v,x(1))
    r = .false.
    do j = 1, n
      r = r.or.v(j)
    end do
    return
  end function is_bridge
  recursive subroutine dfs(n,m,x,y,v,i)
    implicit none
    integer, intent(in)    :: n, m, x(m-1), y(m-1), i
    logical, intent(inout) :: v(n)
    integer                :: j
    v(i) = .false.
    do j = 1, m-1
      if (x(j).eq.i) then
        if (v(y(j))) call dfs(n,m,x,y,v,y(j))
      end if
      if (y(j).eq.i) then
        if (v(x(j))) call dfs(n,m,x,y,v,x(j))
      end if
    end do
    return
  end subroutine dfs
end program bridge

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 250;
int n;
int a[maxn];
int main()
{
    std::ios::sync_with_stdio(false);
    cin >> n;
    int ans = 0;
    for(int i = 0;i < n;i++) cin >> a[i];
    for(int i = 0;i < n;i++){
        for(int j = i + 1;j < n;j++){
            for(int k = j + 1;k < n;k++){
                if(a[i] == a[k] || a[i] == a[j] || a[j] == a[k]) continue;
                if(a[i] + a[j] > a[k] && a[i] + a[k] > a[j] && a[j] + a[k] > a[i] ){
                    ans ++;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

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

    int ans = 0;
    for (int i = 1; i <= N; i++)
    {
        int a = i % 10;
        int b = i / 10 % 10;
        int c = i / 100 % 10;
        int d = i / 1000 % 10;
        int e = i / 10000 % 10;

        int sum = a + b + c + d + e;
        if (A <= sum && sum <= B)
        {
            ans += i;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 384
#include <stdio.h>

void swap(int& a, int& b){
	int c;
	c=a;a=b;b=c;
}

int main(){
	int cup[3] = {1,0,0};
	char s1, s2;

	while( scanf("%c,%c\n", &s1, &s2) != EOF){
		swap( cup[s1-'A'] , cup[s2-'A'] ) ;		
	}
	printf("%c\n", cup[0]*'A' + cup[1]*'B' + cup[2]*'C');	

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,0,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int main(){
  int N,K,Q;
  cin>>N>>K>>Q;
  int A[N+1],ANS[N+1];
  REP(i,N+1){
    A[i]=0;
    ANS[i]=K;
  }
  REP(i,Q){
    int a;
    cin>>a;
    A[a]++;
  }
  
  for(int i=1; i<=N; ++i){
    ANS[i]-=(Q-A[i]);
    if(ANS[i]>0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}

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

int main(){
int a,b,maior,soma;

cin>>a>>b;
soma=a+b;
maior=soma;
soma=a-b;
if (soma>maior){maior=soma;}
soma=a*b;
if (soma>maior){maior=soma;}
cout<<maior<<endl;

return 0;
}


Measured memory_bytes: 888
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int mod = 1e9 + 7;
const int N = 600000;
vector < int > g[N];
map < pair < int, int >, int > m;
vector < int > z;
int sz[N], ans, n;
void dfs(int v, int p = -1){
    int t = 0;
    for (auto u: g[v]){
        if (u == p) continue;
        dfs(u, v);
        t = max(t, sz[u]);
        sz[v] += sz[u];
        ans += 2 * min(sz[u], n - sz[u]) * m[{v, u}];
    }
    sz[v]++;
    t = max(t, n - sz[v]);
    if (2 * t == n){
        z.pb(v);
       // ans -= m[{v, p}];
    } else
    if (2 * t < n){
        int x = 1e9;
        for (auto u: g[v]){
            x = min(x, m[{v, u}]);
        }
        ans -= x;
    }
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    cin >> n;
    for (int i = 1; i < n; i++){
        int u, v, w;
        cin >> u >> v >> w;
        m[{u, v}] = w;
        m[{v, u}] = w;
        g[u].pb(v);
        g[v].pb(u);
    }
    dfs(1);
    if (!z.empty()){
        ans -= m[{z[0], z[1]}];
    }
    cout << ans;
}


Measured memory_bytes: 41984
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
// #include "prettyprint.hpp"

long mod = 1000000007;

int amida[9];
int getAmida(int i) {
  if (i < 0) return 1;
  return amida[i];
}

int main() {
  amida[0] = 1;
  amida[1] = 2;
  for (int i = 2; i <= 8; i++) {
    amida[i] = amida[i - 2] + amida[i - 1];
  }

  int H, W, K;
  cin >> H >> W >> K;

  long dp[H + 1][W];
  for (int i = 0; i < H + 1; i++) {
    for (int j = 0; j < W; j++) {
      dp[i][j] = 0;
    }
  }
  dp[0][0] = 1;

  for (int i = 1; i < H + 1; i++) {
    for (int j = 0; j < W; j++) {
      dp[i][j] += dp[i - 1][j] * getAmida(j - 1) * getAmida(W - j - 2);
      // cout << "i j " << i << " " << j << endl;
      // cout << "dp[i - 1][j] " << dp[i - 1][j] << endl;
      // cout << "getAmida(j - 1) " << getAmida(j - 1) << endl;
      // cout << "getAmida(W - j - 2) " << getAmida(W - j - 2) << endl;
      // cout << "1 " << dp[i][j] << endl;

      if (j - 1 >= 0)
        dp[i][j] += dp[i - 1][j - 1] * getAmida(j - 2) * getAmida(W - j - 2);
      // cout << "dp[i - 1][j-1] " << dp[i - 1][j - 1] << endl;
      // cout << "getAmida(j - 2) " << getAmida(j - 2) << endl;
      // cout << "getAmida(W - j - 1) " << getAmida(W - j - 1) << endl;
      // cout << "2 " << dp[i][j] << endl;

      if (j + 1 < W)
        dp[i][j] += dp[i - 1][j + 1] * getAmida(j - 1) * getAmida(W - j - 3);
      // cout << "3 " << dp[i][j] << endl;

      dp[i][j] = dp[i][j] % mod;
      // cout << "mod " << dp[i][j] << endl;
    }
  }

  cout << (dp[H][K - 1] % mod) << endl;

  return 0;
}

Measured memory_bytes: 256
# sys.stdin.readline
import collections
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N = int(input())
        s = [input() for _ in range(N)]
        M = int(input())
        t = [input() for _ in range(M)]
        s_c = collections.Counter(s)
        t_c = collections.Counter(t)

        ans = 0
        for k, s_v in s_c.items():
            t_v = t_c.get(k)
            if not t_v:
                ans = max(ans, s_v)
            else:
                ans = max(ans, max(0, s_v - t_v))
        print(ans)


# Run main
if __name__ == '__main__':
    AtCoder().main()

Measured memory_bytes: 38256
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 3e3 + 10;
int dp[31][N];
void check(int &up, int &low, int a, int b)
{
	if (up*b < a*low) up = a, low = b;
}
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	vector<pair<int, int>> v(4);
	cin >> v[0].first >> v[1].first;
	cin >> v[2].second >> v[3].second;
	int e, f;
	cin >> e >> f;
	int up = 0, low = 100 * v[0].first;
	dp[0][0] = 1;
	queue<pair<int, int>> q;
	q.emplace(0, 0);
	while (!q.empty())
	{
		int x, y;
		tie(x, y) = q.front();
		q.pop();
		if (y * 100 <= e*x * 100)
		{
			check(up, low, y, x * 100 + y);
		}
		for (auto &p : v)
		{
			int a, b;
			tie(a, b) = p;
			if ((x + a) * 100 + b + y > f) continue;
			if (dp[x + a][b + y]) continue;
			q.emplace(x + a, b + y);
			dp[x + a][b + y] = 1;
		}
	}
	cout << low << ' ' << up << endl;
	return 0;
}


Measured memory_bytes: 384
row,column = map(int,input().split())
S = [list(input()) for i in range(row)]
for i in range(row):
  for j in range(column):
    if S[i][j] == "#":
      continue
    cnt = 0
    for dx in [-1,0,1]:
      for dy in [-1,0,1]:
        if not 0<= i+dy <row or not 0 <= j + dx < column:
          continue
        if S[i + dy][j + dx] ==  "#":
          cnt +=1
    S[i][j]  = str(cnt)
for s in S:
  print("".join(s))

Measured memory_bytes: 3188
#include <stdio.h>

int main(){
    int i, j, k;
    char S[16];
    scanf("%s", &S);
    
    j = k = 0;
    for(i = 0 ; i < 16; i++){
        if(S[i]=='\0') break;
        if(S[i]=='o') j++;
        if(S[i]=='x') k++;
        
    }
    i = j + 15 - (j + k);
    if(i >= 8) printf("YES"); else printf("NO");
    return 0;
}


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

int main() {
  string s;
  cin >> s;

  int ans;
  if (s=="SUN") ans=7;
  else if (s=="MON") ans=6;
  else if (s=="TUE") ans=5;
  else if (s=="WED") ans=4;
  else if (s=="THU") ans=3;
  else if (s=="FRI") ans=2;
  else if (s=="SAT") ans=1;

  cout << ans;
}

Measured memory_bytes: 3572
N=int(input())
A = list(map(int, input().split()))

dic={}
for i in A:
    if i in dic.keys():
        dic[i]+=1
    else:
        dic.setdefault(i,1)

hoge=0
for i in dic.values():
    hoge+=i*(i-1)
hoge =int(hoge/2)

for k in A:
    print(hoge-(dic[k]-1))

Measured memory_bytes: 25644
n = int(input())
weight = list(map(int,input().split()))

mi = abs(sum(weight[:1])-sum(weight[1:]))
for i in range(1,n):
  s1 = sum(weight[:i])
  s2 = sum(weight[i:])
  if abs(s1-s2) < mi:
    mi = abs(s1-s2)
print(mi)

Measured memory_bytes: 3060
n, m = map(int, input().split())
x = [None] * m
y = [None] * m
for i in range(m):
    x[i], y[i] = map(lambda s: int(s) - 1, input().split())

red = [False] * n
balls = [1] * n
red[0] = True
for i in range(m):
    if red[x[i]]:
        red[y[i]] = True
    balls[x[i]] -= 1
    balls[y[i]] += 1
    if balls[x[i]] == 0:
        red[x[i]] = False

ans = sum(1 for v in red if v)
print(ans)

Measured memory_bytes: 12404
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            long iN = long.Parse(sS[0]);

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            long iSum = 0;
            for (long i = 1; i <= iN; i++)
            {
                if (i % 3 == 0 || i % 5 == 0) { }
                else { iSum += i; }
            }

            // 出力
            System.Console.WriteLine("{0}", iSum.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 27444
using System;
using System.Linq;

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Trim();
            var n = s.Length;

            var f1 = s.Equals(string.Join("", s.Reverse()));

            var n2 = ((n - 1) / 2);
            var s2 = s.Substring(0, n2);
            var f2 = s2.Equals(string.Join("", s2.Reverse()));

            var n3 = ((n + 3) / 2) - 1;
            var s3 = s.Substring(n3, n - n3);
            var f3 = s3.Equals(string.Join("", s3.Reverse()));


            Console.WriteLine(f1 && f2 && f3 ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep_3(i, initial, n) for (int i = (int)(initial); i < (int)(n); ++i)
#define repeat(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int i = (int)(n); i > 0; i--)
#define rep_r_3(i, initial, n) for (int i = (int)(initial); i > (int)(n); i--)
#define repeat_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define variable
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;
const double EPS = numeric_limits<double>::epsilon();
// 最大公約数
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; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector< pair<ll, ll> > prime_factorize(ll n) {
	vector< pair<ll, ll> > p;
	for(ll i = 2; i*i <= n; i++) {
		if ((n % i) != 0) continue;
		p.push_back(make_pair(i, 0));
		while((n % i) == 0) {
			n /= i;
			p[i].second += 1;
		}
		p.push_back(make_pair(n, 0));
	}

	if (n != 1) p.push_back(make_pair(n, 1));
	return p;
}

int main() {
	string S;
	cin >> S;

	string s1 = S.substr(0, 1);
	int result = 0;
	repeat(i, 1, S.length()) {
		string s = S.substr(i, 1);

		if (s1 == "0") {
			if (s == "0") result++;
			s1 = "1";
		} else {
			if (s == "1") result++;
			s1 = "0";
		}
	}

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

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x,y,a,b,c;
  cin >> x >> y >> a >> b >> c;
  vector<long> p(a),q(b),r(c);
  long ans = 0;
  for(int i = 0; i < a; i++){
    cin >> p[i];
  }
  for(int i = 0; i < b; i++){
    cin >> q[i];
  }
  for(int i = 0; i < c; i++){
    cin >> r[i];
  }
  sort(p.begin(),p.end(),greater<long>());
  sort(q.begin(),q.end(),greater<long>());
  
  for(int i = 0; i < x; i++){
    r.push_back(p[i]);
  }
  for(int i = 0; i < y; i++){
    r.push_back(q[i]);
  }
  
  sort(r.begin(),r.end(),greater<long>());
  
  for(int i = 0; i < x + y; i++){
    ans += r[i];
  }
  cout << ans << endl;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> s(m);

  for (int i = 0; i < m; ++i) {
    int k;
    cin >> k;
    for (int j = 0; j < k; ++j) {
      int l;
      cin >> l;
      l--;
      s[i].push_back(l);
    }
  }

  vector<int> p(m);
  rep(i, m) cin >> p[i];

  int ans = 0;
  for (int i = 0; i < (1 << n); ++i) {
    bool flg = true;
    for (int j = 0; j < m; ++j) {
      int cnt = 0;
      for (auto ss : s[j]) {
        int k = (1 << ss);
        if (i & k) cnt++;
      }
      if (cnt % 2 != p[j]) flg = false;
    }
    if (flg) ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
from itertools import product

n, m, x = map(int, input().split())
c = [0] * n
a = [0] * n
for i in range(n):
    inp = [int(_) for _ in input().split()]
    c[i] = inp[0]
    a[i] = inp[1:]

INIT = 10**10
ans = INIT
pat = list(product([0, 1], repeat=n))

for p in pat:
    a_val = [0] * m
    c_yen = 0

    for i in range(n):
        if p[i] == 1:
            c_yen += c[i]
            for j in range(m):
                a_val[j] += a[i][j]

    flag = True
    for i in range(m):
        if a_val[i] < x:
            flag = False
            break
    if flag:
        ans = min(ans, c_yen)

if ans == INIT:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 9636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define sim template < class c
#define ris return *this
#define dor > debug & operator <<
#define eni(x) sim > typename \
	enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", ", d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; it++)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int N = 3010;
int n;
ll a[N], dp[N][N][2];
bool vis[N][N][2];

ll solve(int l, int r, int p) {
	if (l > r) {
		return 0;
	}
	if (vis[l][r][p]) {
		return dp[l][r][p];
	}
	vis[l][r][p] = true;
	if (p == 0) {
		dp[l][r][p] = max(a[l] + solve(l + 1, r, 1), a[r] + solve(l, r - 1, 1));
	} else {
		dp[l][r][p] = min(-a[l] + solve(l + 1, r, 0), -a[r] + solve(l, r - 1, 0));
	}
	return dp[l][r][p];
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	memset(dp, -1, sizeof(dp));
	ll ans = solve(0, n - 1, 0);
	cout << ans;
	
	return 0;
}


Measured memory_bytes: 159872
#include <iostream>
#include <algorithm>
#include <vector>
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;


int main()
{
ll n,k;
cin>>n>>k;
vector<int>p(n),c(n);
rep(i,n)cin>>p[i];
rep(i,n)cin>>c[i];
rep(i,n)p[i]--;

ll ans=-1e18;
rep(si,n)
{
ll x=si;
ll tot=0;
vector<int>s;
while(1)
{
x=p[x];
tot+=c[x];
s.push_back(c[x]);
if(x==si)break;
}

ll l=s.size();
ll t=0;
    rep(i,l)
    {
    t+=s[i];
    if(i+1>k)break;
    ll now=t;
        if(tot>0)
        {
        ll e=(k-(i+1))/l;
        now+=e*tot;
        }

    ans=max(ans,now);
    }
}

cout <<ans;
}

Measured memory_bytes: 3696
n = int(input())
a = list(map(int, input().split()))

cnt = 0
flag = True
while flag:
    for x in range(len(a)):
        if a[x]%2 == 1:
            flag = False
            break
        a[x] = a[x]//2
    if flag:
        cnt += 1
print(cnt)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5LL << 60, MOD = 1e9 + 7;

int N, M;
string S;
vi va, vb;

void input() {
  ;
  ;
  cin >> N;
  cin >> S;
}
void solve() {
  ;
  int ans = 0;
  char prv = 'I';
  for (auto x : S) {
    if (x != prv) {
      ans++;
    }
    prv = x;
  }
  cout << ans << endl;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 512