akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

const int N=18;

vector<int> vt;
int x,y;
int n,m;
LL cnt[55];

LL check(int bit,vector<int>& v1){
	if(v1.empty())return 0;
	LL s=0;
	if(bit==N){
		int a=v1.size();
		if(a<=m)return ((LL)1<<a)-1;
		else return cnt[a];
	}
	s=check(bit+1,v1);
	vector<int> v2,v3;
	for(auto num:v1){
		if(num&(1<<bit))v3.push_back(num);
		else v2.push_back(num);
	}
	if(y&(1<<bit))s-=check(bit+1,v2);
	if(~x&(1<<bit))s-=check(bit+1,v3);
	return s;
}

int main(){
	int i,j,k;
	LL a,b,c;
	cin>>n>>m>>x>>y;
	for(i=0;i<n;i++){
		cin>>a;
		if((a&x)!=x || (a|y)!=y)continue;
		vt.push_back(a);
	}
	for(i=m+1;i<=n;i++){
		a=0,b=1;
		for(j=0;j<m;j++){
			b*=i-j;
			b/=j+1;
			a+=b;
		}
		cnt[i]=a;
	}
	cout<<check(0,vt)<<endl;
}

Measured memory_bytes: 3600
#include <cstdio>
#include <cstring>
using namespace std;
static const int M = 244140625;

int T[M];

int getChar(char ch) {
    if (ch == 'A') return 1;
    else if (ch == 'C') return 2;
    else if (ch == 'G') return 3;
    else if (ch == 'T') return 4;
    else return 0;
}

int getKey(char str[]) {
    int sum = 0, p = 1;
    for (int i = 0; i < strlen(str); i++) {
        sum += p * getChar(str[i]);
        p *= 5;
    }
    return sum;
}

int main() {
    // When this line was added, memory limit exceeded.
    // for (int i = 0; i < M; i++) T[i] = 0;

    int n;
    scanf("%d", &n);
    char cmd[6], str[12];
    int key;
    for (int i = 0; i < n; i++) {
        scanf("%s %s", cmd, str);
        key = getKey(str);
        if (cmd[0] == 'i') {
            T[key] = 1;
        } else if (cmd[0] == 'f') {
            if (T[key]) {
                printf("yes\n");
            } else {
                printf("no\n");
            }
        }
    }

    return 0;
}


Measured memory_bytes: 19460
import java.util.*;

class Main{
  
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int m = sc.nextInt();
      int[][] matrix = new int[n][m];
      int[] retu = new int[m];
      int[] ans = new int[n];
      for (int i=0; i<n; i++) {
        for (int j=0; j<m; j++) {
          matrix[i][j] = sc.nextInt();
        }
      }
      for(int i = 0; i<m; i++){
        retu[i] = sc.nextInt();   
      }
      for(int i = 0; i<n; i++) {
        for(int j =0; j<m; j++) {
          ans[i] += matrix[i][j] * retu[j];
        }
      }
      for (int i = 0; i<n; i++) {
        System.out.println(ans[i]);
    }
  }
}


Measured memory_bytes: 40836
#include<iostream>
#include<vector>
#include<queue>

using namespace std;

bool check(vector<int> v){
	int sum = 0;
	for (int i = 0; i < v.size(); i++){
		if (v[i] != 0) sum++;
	}
	if (sum == 1){
		return true;
	}else{
		return false;
	}
}


int main(){
	while(1){
		int n; cin >> n;
		int p; cin >> p;
		if (n == 0 and p == 0) break;
		int wan = p;
		vector<int> player_have(n);
		int player = 0;
		int idx = 0;
		while(wan != 0 or !check(player_have) ){
			player = idx%n;
			//cout << "wan = " << wan <<  endl;
			if (wan > 0){
				player_have[player] += 1;
				wan -= 1;
			}else if (wan == 0){
				wan = player_have[player];
				player_have[player] = 0;
			}
			idx++;;
		}
		cout << player << endl;
		player_have.clear();
	
	}

return 0;
}

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

int main()
{
  string s;
  cin >> s;
  ll n=(ll)s.length();

  ll a = 0, b = n-1;

  ll tmp = 0;

  while(a<b)
  {
    if(s[a]!=s[b])
    {
      tmp++;
    }
    a++,b--;
  }

  cout << tmp << endl;

  return 0;
}


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

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

  int ans = p[0] / 2;
  for (int i = 1; i < p.size(); i++)
    ans += p[i];
  cout << ans << endl;
}


Measured memory_bytes: 256
// in the name if Allah
// YA Ali!
#include <bits/stdc++.h>
using namespace std;
typedef long long ll ;
const ll INF = 1<<30 ;
const ll N= 1e6 ;
#define f first
#define s second
#pragma GCC optimize("O1")
#pragma GCC optimize("O2")
#pragma GCC optimize("O3")
#pragma GCC optimize("O4")
#pragma GCC optimize("O5")
#pragma GCC optimize("O6")
#pragma GCC optimize("O7")
#pragma GCC optimize("O8")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
ll n , d ;
deque<ll> v ;
map<ll,ll> m , ans ;
int main()
{
std::ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n ;
for(int i = 1 ; i <= n ; i ++ ){
    ll x ;
    cin >> x ;
    m[i] = x ;
}
ans[n] = m[n] ;
for(int  i = n-1 ; i > 0 ; i --){
  ll sum = 0 ;
  for(int j = (2*i) ; j <= n ; j += i){
     sum += ans[j] ;
  }
  if(sum%2 != m[i])ans[i] = 1 ;
}
for(int i = 1 ; i <= n ; i ++){
    if(ans[i] == 1)v.push_back(i) ;
}
cout << v.size() << endl ;
for(int i = 0 ; i < v.size() ; i ++)cout << v[i] << " " ;
    return 0;
}
 /*
              _     _   __
        /_\  (_    (_)  __)
       /   \  _) . (_) (__
 */


Measured memory_bytes: 26752
#include <bits/stdc++.h>
using namespace std;
const int INF=999999999;
int main() {
 int64_t Q,H,S,D,N;
 cin>>Q>>H>>S>>D>>N;
 cout<<min(min({4*Q,2*H,S})*N , D*(N/2)+min({4*Q,2*H,S})*(N%2))<<endl;
 return 0;}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <list>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <vector>
#include <iomanip>
using namespace std;
using ll = long long;

int main(){
    // input
    int A, B; cin >> A >> B;

    // compute
    if((A+B)%2 == 0){
        cout << (A+B)/2 << endl;
    }
    else cout << "IMPOSSIBLE" << endl;

    // output
    

}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    unordered_map<std::string, int64> hashT(100);
    uint N; cin >> N;
    for(uint i=0; i<N; ++i){
        string s; cin >> s;
        auto itr = hashT.find(s);
        if(itr==hashT.end()){ hashT[s]=1; continue; }
        ++(itr->second);
    }
    uint M; cin >> M;
    for(uint i=0; i<M; ++i){
        string s; cin >> s;
        auto itr = hashT.find(s);
        if(itr==hashT.end()){ hashT[s]=-1; continue; }
        --(itr->second);
    }
    
    int64 max=0;
    for(auto itr=hashT.begin(); itr!=hashT.end(); ++itr){
        if(max < itr->second){ max=itr->second; }
    }
    
    cout << max << endl;
    
    return 0;
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  map<char, int> mp;
  for (char c : s) mp[c]++;
  for (char c = 'a'; c <= 'z'; c++)
    if (mp[c] == 0) {
      cout << c << endl;
      return 0;
    }
  cout << "None" << endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int solve(const std::vector<int>& a) {
	int ret = 0;
	const int n = a.size() - 1;
	for(int i = 0; i < a.size(); i++) ret += a[i] * ((n & i) == i);
	return ret & 1;
}

int main() {
	int n; scanf("%d", &n);
	std::string s; cin >> s;

	std::vector<int> a(n);
	for(int i = 0; i < n; i++) a[i] = s[i] - '0';
	{
		std::vector<int> b(n - 1);
		for(int i = 0; i < n; i++) b[i] = std::abs(a[i + 1] - a[i]);
		a = std::move(b);
		n = n - 1;
	}

	int g = solve(a);
	if(g == 1) {
		printf("1\n");
		return 0;
	}

	bool one = false;
	for(auto v: a) one |= (v == 1);
	if(one) {
		printf("0\n");
		return 0;
	}
	for(auto& v: a) v >>= 1;

	printf("%d\n", solve(a) * 2);
	return 0;
}


Measured memory_bytes: 9220
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1e9
#define LINF 1e18
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
#define int long long
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
struct edge{int to,cost;};
typedef pair<int,int> P;

bool isupper(char c){if('A'<=c&&c<='Z')return 1;return 0;}
bool islower(char c){if('a'<=c&&c<='z')return 1;return 0;}
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;}
bool iskaibun(string s){for(int i=0;i<s.size()/2;i++)if(s[i]!=s[s.size()-i-1])return 0;return 1;}

signed main (){
    int a,b,c;
    cin>>a>>b>>c;
    cout<<a*b/2<<endl;

}
/*
*/


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

int main()
{
    int n,time,i,j,h=0;
    cin>>n>>time;
    int c[n+1];
    int t[n+1];
    for(i=0; i<n; i++)
    {
        cin>>c[i];
        cin>>t[i];
    }
    j=0;
    for(i=0; i<n; i++)
    {
        if(c[i]<=c[j] && t[i]<=time)
        {
            j=i;
            h=1;
        }
    }
    if(h==0)
        cout<<"TLE"<<endl;
    else
        cout<<c[j]<<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)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define dbg(x) cout<<#x" = "<<(x)<<ln

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

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

ll n, k, a[111111], s[111111], b[111111], t, r;

int main() {
	cin >> n >> k;
	repst(i,1,n) {
		cin >> a[i];
		b[i] = b[i-1] + max(0ll, a[i]);
		s[i] = s[i-1] + a[i];
	}
	repst(i,1,n-k+1) {
		if (s[i+k-1]-s[i-1]>0) t = b[n] - b[i+k-1] + b[i-1] + s[i+k-1] - s[i-1];
		else t = b[n] - b[i+k-1] + b[i-1];
		chmax(r, t);
	}
	cout << r << ln;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define N 100000
using namespace std;
int a[N];
int cdiv(int a, int b)
{
	return a/b + (a%b > 0);
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n, k; cin >> n >> k;
	int x;
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
		if(a[i]==1)
			x = i;
	}

	int ans = n;
	for(int i = max(0,x-k+1); i+k-1 < n; i++)
		ans = min(ans, cdiv(i,k-1)+cdiv(n-1-(i+k-1),k-1) );
	cout<<ans+1<<endl;

	return 0;
}

Measured memory_bytes: 640
//  sosu.cpp(2014/10/12-)


#include <cstdio>
#define MAX_N 50000000

bool s[MAX_N]={false};

int main(){
    int k=0,d,n;
    
    for(int i=3;i<10000;i+=2){
        if(!s[(i-1)/2]){
            for(int j=i;i*j<=MAX_N*2;j+=2) s[(i*j-1)/2]=true;
        }
    }
    
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&d);
        if(d%2==1 || d==2)
            if(!s[(d-1)/2]) k++;
    }
    
    printf("%d\n",k);
    
    
    return 0;
}

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

/*
  REMEMBER:
  1.Think TWICE, code ONCE!
  Are there any counterexamples to your algo?
	
  2.Be careful about the BOUNDARIES in your algo!
  N=1? P=1? Is P a prime? Something about 0?
	
  3.Never make STUPID MISTAKES!
  Integer overflow? Array size? Time complexity? Memory usage? Precition error?
*/

int arr[100003] , N , lsh[100003];

int main(){
	cin >> N; for(int i = 1 ; i <= N ; ++i){cin >> arr[i]; lsh[i] = arr[i];}
	sort(lsh + 1 , lsh + N + 1); for(int i = 1 ; i <= N ; ++i) arr[i] = lower_bound(lsh + 1 , lsh + N + 1 , arr[i]) - lsh;
	int cnt = 0; for(int i = 1 ; i <= N ; ++i) cnt += (arr[i] ^ i) & 1;
	cout << cnt / 2; return 0;
}


Measured memory_bytes: 1024
from bisect import bisect_right
n = int(input())
a_list = []
for i in range(n):
    a = int(input())
    a_list.append(a)
a_list.reverse()
l_list = [a_list[0]]
for i in range(1, n):
    a = a_list[i]
    if l_list[-1] <= a:
        l_list.append(a)
    else:
        index = bisect_right(l_list, a)
        l_list[index] = a
print(len(l_list))

Measured memory_bytes: 7844
#include<cstdio>
#include<cstring>
#include<map>
#include<algorithm>
#include<iostream>
#include<queue>
using namespace std;
int l;
int a[205];
int main(){
	char s[205];
	scanf("%s",s+1);
	l = strlen(s+1);
	for(int i = 1;i <= l;i++){
		a[i]=s[i]-'0';
	}
	for(int i = 1; ;i++){
		l=l-1;
		if(l%2==1){
			l=l-1;
		}
		int p=0;
		for(int j = 1;j <= l/2;j++){
			if(a[j]==a[j+(l/2)]){
				p++;
			}
		}
		if(p==l/2){
			printf("%d\n",l);
			break;
		}
	}
}

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

int main() {
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    for (int i = 0; i+3 <= n; ++i) {
        if ("ABC" == s.substr(i, 3)) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 764
=begin
N
A1 A2 ... An
=end

n = gets.chomp.to_i
as = gets.chomp.split(" ").map(&:to_i)

b = as.select {|i| i.even? }.all? {|i| (i % 3 == 0) || (i % 5 == 0)}

if b
  puts "APPROVED"
else
  puts "DENIED"
end

Measured memory_bytes: 1788
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <iomanip>

using namespace std;

#define rep(i , n)  for(int i=0 ; i<n ; i++)
#define rep1(i , n) for(int i=1 ; i<=n ; i++)
#define FAST        ios_base :: sync_with_stdio(false); cin.tie(NULL);
typedef long long int ll;

class Pair
{
	public:
	string first;
	int second,third;
};

bool custome(Pair p1 , Pair p2)
{
	if(p1.first == p2.first)
		return p1.second > p2.second;
	return p1.first < p2.first;
}

int main()
{
	FAST;
	int n;
	Pair arr[100];

    cin >> n;
	
	rep(i , n)
	{
		cin >> arr[i].first >> arr[i].second;
		//cout << arr[i].first << " " << arr[i].second << "\n";
		arr[i].third = i+1;
	}

	sort(arr , arr+n , custome);

	rep(i , n)
		cout << arr[i].third << "\n";

	return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        SDigitSum solver = new SDigitSum();
        solver.solve(1, in, out);
        out.close();
    }

    static class SDigitSum {
        static int[] arr;
        static int m;
        static int mod = (int) 1e9 + 7;
        static Integer[][][][] memo;

        public void solve(int testNumber, Scanner sc, PrintWriter pw) {
            String tmp = sc.next();
            arr = new int[tmp.length()];
            for (int i = 0; i < arr.length; i++)
                arr[i] = tmp.charAt(i) - '0';
            m = sc.nextInt();
            memo = new Integer[2][2][m][arr.length];
            int s = dp(0, 0, 0, 0) % mod;
            pw.println(s);
        }

        private int dp(int idx, int s, int rem, int NonZero) {
            if (idx == arr.length)
                return rem == 0 && NonZero == 1 ? 1 : 0;
            boolean small = s == 1;
            int end = small ? 9 : arr[idx];
            int sum = 0;
            if (memo[s][NonZero][rem][idx] != null)
                return memo[s][NonZero][rem][idx];
            for (int i = 0; i <= end; i++) {
                sum += dp(idx + 1, i < arr[idx] ? 1 : s, (rem + i) % m, i != 0 ? 1 : NonZero);
                sum %= mod;
            }
            return memo[s][NonZero][rem][idx] = sum;
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 86476
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;

typedef pair<int, int> P;
int a[100][100];
int m, n;
queue<P> q;
int dx[4] = {0, 0, -1, 1}, dy[4] = {-1, 1, 0, 0};
int ans;

void dfs(int x, int y, int s){
	for(int i=0; i<4; i++){
		if(0<=x+dx[i]&&x+dx[i]<m&&0<=y+dy[i]&&y+dy[i]<n&&a[x+dx[i]][y+dy[i]] == 1){
			a[x][y] = 0;
			dfs(x+dx[i], y+dy[i], s+1);
			a[x][y] = 1;
		}
	}
	ans = max(ans, s);
}

int main(){
	while(1){
		scanf("%d %d", &m, &n);
		if(m == 0 && n == 0) break;

		for(int i=0; i<100; i++)
			for(int j=0; j<100; j++)
				a[i][j] = 0;

		for(int i=0; i<n; i++){
			for(int j=0; j<m; j++){
				scanf("%d", &a[j][i]);
				if(a[j][i] == 1){
					q.push(P(j, i));
				}
			}
		}

		ans = 0;
		while(q.size()){
			P p = q.front();
			q.pop();
			dfs(p.first, p.second, 1);
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1112
#include  <stdio.h>

int main(){
    int a;
    int b;
        scanf ("%d %d",&a,&b);
    int c=a/b;
    if (a%b==0){
         printf ("%d\n",c);
    }
    else {
        printf ("%d\n", c+1);
    }
    
    return 0;
}

Measured memory_bytes: 1728
from collections import deque

N = int(input())
S = [""] * N
for i in range(N):
    S[i] = input()
mostfrequent = deque()
wordcount = {}
frequentoccurence = 0

for s in S:
    if not s in wordcount:
        wordcount[s] = 1
    else:
        wordcount[s] += 1
    if wordcount[s] == frequentoccurence:
        mostfrequent.append(s)
    if wordcount[s] > frequentoccurence:
        frequentoccurence = wordcount[s]
        mostfrequent.clear()
        mostfrequent.append(s)
frequentlist = list(mostfrequent)
frequentlist.sort()
print("\n".join(frequentlist))


Measured memory_bytes: 37612
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define vv(T) vector<vector<T>>
using namespace std;
using ll = long long;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using vll = vector<long long>;
using vvll = vector<vector<long long>>;
using vbool = vector<bool>;
using vvbool = vector<vector<bool>>;
using qint = queue<int>;
using sint = stack<int>;
using pii = pair<int, int>;

const string YES = "Yes";
const string NO = "No";

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

    long long tp = 0;
    for(char x : n){
        int t = x - '0';
        tp += t;
    }

    string ans = YES;
    if(tp % 9 != 0) ans = NO;

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


Measured memory_bytes: 3752
import sys

def kruskal(v_count: int, edges: list) -> int:
    tree = [-1]*v_count

    def get_root(x):
        if tree[x] < 0:
            return x
        tree[x] = get_root(tree[x])
        return tree[x]

    def unite(x, y):
        x, y = get_root(x), get_root(y)
        if x != y:
            big, small = (x, y) if tree[x] < tree[y] else (y, x)
            tree[big] += tree[small]
            tree[small] = big
        return x != y

    cost = 0
    for (w, _s, _t), _ in zip(filter(lambda p: unite(*p[1:]), sorted(edges)),
                              range(v_count-1)):
        cost += w
    return cost

V, E = map(int, input().split())
edges = [(w, s, t) for s, t, w in (map(int, l.split()) for l in sys.stdin)]
print(kruskal(V, edges))


Measured memory_bytes: 24008
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    long long x;
    cin>>x;
    if(x>=400&&x<=599)
    {
        cout<<8<<endl;
    }
    else if(x>=600&&x<=799)
    {
        cout<<7<<endl;
    }
    else if(x>=800&&x<=999)
    {
        cout<<6<<endl;
    }
    else if(x>=1000&&x<=1199)
    {
        cout<<5<<endl;
    }
    else if(x>=1200&&x<=1399)
    {
        cout<<4<<endl;
    }
    else if(x>=1400&&x<=1599)
    {
        cout<<3<<endl;
    }
    else if(x>=1600&&x<=1799)
    {
        cout<<2<<endl;
    }
    else if(x>=1800&&x<=1999)
    {
        cout<<1<<endl;
    }
    return 0;
}

Measured memory_bytes: 3628
import sys
readline = sys.stdin.buffer.readline
MOD = 10**9+7

def main():
    N, M = map(int, readline().split())
    S = set(i for i in range(1,M+1))
    for _ in range(N):
        S &= set(list(map(int, readline().split()))[1:])
    print(len(S))


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
A, B, H, M = map(int, input().split())
import math

pi = math.pi
w_a = pi/360
w_b = pi/30
mins = 60*H + M
rad_a = -w_a * mins
rad_b = -w_b * mins
x_a = A * math.cos(rad_a)
y_a = A * math.sin(rad_a)
x_b = B * math.cos(rad_b)
y_b = B * math.sin(rad_b)
print(math.sqrt((x_a-x_b)**2+(y_a-y_b)**2))


Measured memory_bytes: 9516
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		// 整数の入力
		String val = sc.next().trim();

		int n1 = Integer.parseInt(String.valueOf(val.charAt(0)));
		int n2 = Integer.parseInt(String.valueOf(val.charAt(1)));
		int n3 = Integer.parseInt(String.valueOf(val.charAt(2)));
		int n4 = Integer.parseInt(String.valueOf(val.charAt(3)));

		if (n1 + n2 + n3 + n4 == 7){
			System.out.println(n1 + "+" + n2 + "+" + n3 + "+" + n4 + "=7");
		}else if(n1 - n2 + n3 + n4 == 7){
			System.out.println(n1 + "-" + n2 + "+" + n3 + "+" + n4 + "=7");
		}else if(n1 + n2 - n3 + n4 == 7){
			System.out.println(n1 + "+" + n2 + "-" + n3 + "+" + n4 + "=7");
		}else if(n1 + n2 + n3 - n4 == 7){
			System.out.println(n1 + "+" + n2 + "+" + n3 + "-" + n4 + "=7");
		}else if(n1 + n2 - n3 - n4 == 7){
			System.out.println(n1 + "+" + n2 + "-" + n3 + "-" + n4 + "=7");
		}else if(n1 - n2 + n3 - n4 == 7){
			System.out.println(n1 + "-" + n2 + "+" + n3 + "-" + n4 + "=7");
		}else if(n1 - n2 - n3 + n4 == 7){
			System.out.println(n1 + "-" + n2 + "-" + n3 + "+" + n4 + "=7");
		}else if(n1 - n2 - n3 - n4 == 7){
			System.out.println(n1 + "-" + n2 + "-" + n3 + "-" + n4 + "=7");
		}

		sc.close();
	}

}

Measured memory_bytes: 23636
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define cl clear() ;
#define vl vector<ll>
#define sz size()
#define len length()
#define el endl;cout.flush()
#define be begin()
#define fi first
#define se second
#define br break
#define en end()
#define ro return 0
#define br break
#define mod %
#define eb emplace_back
#define con continue
#define ms(x) memset(x , 0, so x)
#define all(x) (x).be , (x).en
#define rall(x) (x).rbegin() , (x).rend()
#define acc(x) accumulate((x).be , (x).en , 0ll)
#define forn(i,a,b) for(ll i=a;i<=b;++i)
#define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
#define trace2(a,b) cerr <<"a is " << a << " b is " << b << el;
#define trace3(a,b,c) cerr <<"a is " << a << " b is " << b << " c is " << c << el;
#define trace4(a,b,c,d) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << el ;
#define trace5(a,b,c,d,e) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << el;
#define trace6(a,b,c,d,e,f) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << " f is " << f << el ;

int main()
{
    ios;
    multiset<ll> s1 , s2 , s3 ;
    s1.insert(4);
    s1.insert(6);
    s1.insert(9);
    s1.insert(11);
    s2.insert(2);
    s3.insert(1);
    s3.insert(3);
    s3.insert(5);
    s3.insert(7);
    s3.insert(8);
    s3.insert(10);
    s3.insert(12);
    ll x, y;
    cin >> x >> y ;
    if(s1.find(x)!=s1.end() and s1.find(y)!=s1.end()){
        cout << "Yes\n";
        ro;
    }
    if(s2.find(x)!=s2.end() and s2.find(y)!=s2.end()){
        cout << "Yes\n";
        ro;
    }
    if(s3.find(x)!=s3.end() and s3.find(y)!=s3.end()){
        cout << "Yes\n";
        ro;
    }
    cout << "No\n" ;
    ro ;


}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

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

    int A, B;
    cin >> A >> B;
    if(A > B) { swap(A, B); }
    int ans = 1;
    if(A == 1 && B == 2) {
        ans = 3;
    }
    else if(A == 1 && B == 3) {
        ans = 2;
    }

    printf("%lld\n", ans);

    return 0;
}


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

using namespace std;

#define sz(v)           ((int)((v).size()))
#define clr(v, d)       memset(v, d, sizeof(v))
#define rep(i, v)       for(int i=0; i<sz(v); ++i)
#define lp(i, n)        for(int i=0; i<(int)(n); ++i)
#define lpi(i, j, n)    for(int i=(j); i<(int)(n); ++i)
#define lpd(i, j, n)    for(int i=(j); i>=(int)(n); --i)
#define INF             1000000000

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

void init(){
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

const int N = 10;
struct PT{int x, y;};
struct PT pts[10];

double distPtPt(PT pt1, PT pt2){
	return sqrt((pt1.x - pt2.x) * (pt1.x - pt2.x) + (pt1.y - pt2.y) * (pt1.y - pt2.y));
}

int fact[9];

int main()
{
	init();
	fact[0] = fact[1] = 1;
	lpi(i, 2, 9){
		fact[i] = fact[i-1] * i;
	}
	int  n;
	double ans = 0;
	cin >> n;
	lp(i, n){
		cin >> pts[i].x >> pts[i].y;
		lp(j, i){
			ans += distPtPt(pts[i], pts[j]);
		}
	}
	cout << setprecision(20) << ans*((double)fact[n-1]/fact[n]) * 2;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int d;

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> d;
	cout << "Christmas";
	for(int i = 0; i < 25 - d; i++) cout << " Eve";
	cout << "\n";
	return 0;
}

Measured memory_bytes: 256
//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector") 
#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define int long long

#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) {cout << a; exit(0);}

using namespace std;
                                                                                                      
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

typedef pair < int , int > pii ;
typedef pair < long long  , long long > pll ;

const int N = 2e5 + 123;

int n , m , k , a[N] , d;
int dp[N] , cnt[N] , ls[N];
int ans[N] , inv[N] , f[N];
void D(int &x){
	if(x < 0) x += mod;
	x %= mod;
}
int C(int n , int k){
	if(k > n or k < 0 or n < 0)return 0;
	return f[n] * inv[k] % mod * inv[n - k] % mod;
}
main(){                                                                   	
//	freopen(".out" , "w" , stdout);
	cin >> n;
	//000000100000001000000000
	//000000[1]00000001000000000
	//00000010000000[1]000000000 
	f[0] = 1;
	inv[0] = 1;
	for(int i = 1 ; i <= 2e5 ; i++)
		f[i] = f[i - 1] * i % mod ,	inv[i] = powmod(f[i] , mod - 2 , mod);;
	n++;
	for(int i = 1; i <= n ; i++){
		cin >> a[i];

	}
	int l = 0, r = 0;
	for(int i = 1 ; i <= n + 1 ; i++){
		cnt[a[i]]++;
		if(cnt[a[i]] == 2){
		 	l = ls[a[i]] , r = i;
		 	break;
		}
		ls[a[i]] = i;
	}
	for(int i = 0 ; i <= n ; i++){
		ans[i] += C(n - 2 , i);
		ans[i + 2] += C(n - 2 , i);
		ans[i] += C(n - 2 , i - 1) * 2 % mod;
		ans[i] -= C(l - 1 + (n - r) , i - 1);
		D(ans[i]);
	}
	for(int i = 1;  i <= n ;i++)
		cout << ans[i] << '\n';






}

Measured memory_bytes: 11392
import java.util.*;

public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        String s = sc.next();
        sc.close();

        Deque<Character> dq = new ArrayDeque<>();
        for(int i = 0; i < s.length(); i++){
            if(s.charAt(i) == 'S'){
                dq.push('S');
            } else {
                if(dq.size() == 0){
                    dq.push('T');
                }
                else if(dq.peek() == 'S'){
                    dq.pop();
                } else {
                    dq.push('T');
                }
            }
        }
        System.out.println(dq.size());
   }
}

Measured memory_bytes: 27748
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<char> c(n);
	for (int i = 0; i < n; i++) cin >> c[i];

	int counter = 0;
	vector<char>::iterator itr;
	int rnum = count(c.begin(), c.end(), 'R');
	itr = find(c.begin(), c.end(), 'R');
	while (itr!=c.end()) {
		if (distance(c.begin(), itr) >= rnum) {
			//iter_swap(c.begin() + counter, itr);
			counter++;
		}
		itr = find(itr+1, c.end(), 'R');
	}
	cout << counter;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>

#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)

#define repv(x, arr) for (auto &x : arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a, b) make_pair(a, b)
#define op(i) cout << (i) << endl;
#define F first
#define S second

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const ll mod = 1e9 + 7;
const ll infl = 1e17;

ll powmod(ll x, ll y, ll mod)
{
    map<ll, ll> Z;
    Z[0] = 1;
    Z[1] = x;
    ll nowy = 1;
    ll nowx = x;
    while (nowy * 2 <= y)
    {
        nowy *= 2;
        nowx = nowx * nowx % mod;
        Z[nowy] = nowx;
    }
    ll nowz = nowy / 2;
    while (nowy < y)
    {
        if (nowz + nowy <= y)
        {
            nowy += nowz;
            nowx = (nowx * Z[nowz]) % mod;
        }
        nowz /= 2;
    }
    return nowx;
}

int main(){
    ll n, a, b, c;
    cin >> n >> a >> b >> c;
    vector<ll> kaijo(2*n+1, 0);
    kaijo[0] = 1;
    repf(i, 1, 2*n+1)
    {
        kaijo[i] = (kaijo[i - 1] * i) % mod;
    }
    vector<ll> gyaku(2 * n + 1, 0);
    gyaku[2 * n] = powmod(kaijo[2 * n], mod - 2, mod);
    rep(i,2*n){
        gyaku[2 * n - 1 - i] = gyaku[2 * n - i] * (2 * n - i) % mod;
    }
    ll x = 100 * powmod(100 - c, mod - 2, mod) % mod;
    ll revab = powmod(a + b, mod - 2, mod);
    ll pa = (a *  revab) % mod;
    ll pb = (b * revab) % mod;
    ll xa = powmod(pa, n, mod);
    ll xb = powmod(pb, n, mod);
    ll ans = 0;
    repf(m,n,2*n){
        ll c = ((kaijo[m - 1] * gyaku[n - 1]) % mod * gyaku[m - n]) % mod;
        c=c*((xa+xb)%mod)%mod;
        c = (c * m) % mod * x % mod;
        ans = (ans + c) % mod;
        xa = (xa * pb) % mod;
        xb = (xb * pa) % mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "a", long, "b");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    auto n = lread();
    auto a = aryread();
    auto q = lread();
    auto l = new long[](MAX);
    foreach (e; a)
        l[e]++;
    long s = a.sum();

    foreach (_; iota(q))
    {
        long b, c;
        scan(b, c);
        s -= b * l[b];
        s += c * l[b];
        l[c] += l[b];
        l[b] = 0;
        s.writeln();
    }
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 9624
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.valueOf(scanner.nextLine());
        String[] hAry = scanner.nextLine().split(" ");
        int ans = 0;
        int counter = 0;
        int prev = 0;
        for (int i = 0; i < n; i++) {
            int h = Integer.valueOf(hAry[i]);
            if (h <= prev) {
                counter++;
                if (counter > ans) ans = counter;
            } else {
                if (counter > ans) ans = counter;
                counter = 0;
            }
            prev = h;
        }
        System.out.println(ans);
    }
}

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

int main() {

  double PI = 3.14159265358979323846264338327950L;

  double A, B, H, M;
  cin >> A >> B >> H >> M;

  double angleH = 360 * H / 12;
  double angleM = 360 * M / 60;

  angleH += 30 * M / 60;

  double angle = angleH - angleM;

  double radian = angle * PI / 180.0;
  double answer = A * A + B * B - (2 * A * B * cosl(radian));

  printf("%.20f\n", sqrt(answer));

  return 0;

}

Measured memory_bytes: 4148
#include <stdio.h>
using namespace std;
int N;
int i = 2;
int num;
int main()
{

  scanf("%d", &N);
  long long ans = (long long)N * (N + 1) - 1;

  while (i * i <= N)
  {
    num = N / i;
    ans += (long long)(num - i + 1) * i * (i + num) - i * i;
    i += 1;
  }
  printf("%lld", ans);
}


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

namespace program
{
    class Program
    {
        static void Main()
        {
          Console.WriteLine(Input.ScanInt()/3);
        }
    }

    static class Input
    {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray(); }
        static public double[] ScanDoubleArray() { return Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(' '); }
    }

    static class MyMath
    {
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


Measured memory_bytes: 11092
read S
BB=`echo $S | sed -e 's/WB//g'`
CC=`echo $S | sed -e 's/BW//g'`
ans1=$((${#S} - ${#BB}))
ans2=$((${#S} - ${#CC}))

if [ $ans1 -ne 0 ]
then
	ans1=$((ans1 / 2))
fi
if [ $ans2 -ne 0 ]
then
	ans2=$((ans2 / 2))
fi
echo $((ans1 + ans2))


Measured memory_bytes: 1976
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

int main() {
  int A, B; cin>>A>>B;
  cout << ((A > 8 || B >	8)  ? ":(" : "Yay!") <<	endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
    int x;
    scanf("%d", &x);
    if (x == 2)
    {
        printf("%d", x);
    }
    else
    {
        x += 1 - x % 2;
        int c;
        int rc;
        int f = 1;
        int j;
        for (int i = 0; f; i += 2)
        {
            c = x + i;
            rc = (int)sqrt((double)c);
            f = 0;
            for (j = 3; j < rc; j += 2)
            {
                if (c % j == 0)
                {
                    f = 1;
                    break;
                }
            }
        }
        printf("%d", c);
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
using namespace std;
int main() {
    // INPUT
    int N = 0;
    cin >> N;
    string S;
    cin >> S;

    // SOURCE
    int count = 0;
    for(int i=0; i < N-2; i++) {
        if( S[i] == 'A' ) {
            if( S.substr(i, 3) == "ABC" ) {
                count++;
                i += 2;
            }
        }
    }

    // OUTPUT
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k;cin>>n>>k;
    vector<ll> a(n);rep(i,n)cin>>a[i];
    vector<ll> p, q, r;
    int zero = 0;
    for(ll A: a){
        if(A>0)p.push_back(A);
        if(A<0)q.push_back(A);
        if(A==0){p.push_back(A);zero++;}
    }
    int MAX = min(k,(int)q.size()), MIN = max(k-(int)p.size(),0);
    if(MAX!=MIN||MIN%2==0){//ans is non-negative
        mint ans = 1;
        sort(rALL(p));sort(ALL(q));
        int ip = 0, iq = 0;
        while(k){
            if(k>=2&&(int)q.size()-iq>=2&&(int)p.size()-ip>=2&&p[ip]*p[ip+1]<q[iq]*q[iq+1]){
                k-=2;
                ans*=q[iq];ans*=q[iq+1];
                iq+=2;
            }else if(k>=2&&(int)q.size()-iq>=2&&(int)p.size()-ip<2){
                k-=2;
                ans*=q[iq];ans*=q[iq+1];
                iq+=2;
            }else{
                k-=1;
                ans*=p[ip];
                ip++;
            }
        }
        cout<<ans.x<<endl;
    }else if(zero==0){//ans is negative
        mint ans = 1;
        sort(ALL(p));
        sort(rALL(q));
        rep(i,min(k,(int)q.size())){
            ans*=q[i];
        }
        rep(i,k-(int)q.size()){
            ans*=p[i];
        }
        cout<<ans.x<<endl;
    }else{//ans is zero
        cout<<0<<endl;
    }


    return 0;
}

Measured memory_bytes: 6820
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<ll> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
 
ll rui(ll abc,ll bed){
	//aのb乗を計算する
	if(bed==0){return 1;}
	else{
		ll ced = rui(abc,bed/2);
		ced *= ced;
		ced %= mod;
		if(bed%2==1){ced*=abc; ced%=mod;}
		return ced;
	}
}

ll i,j,k,ii,jj;
ll n,m,sum,num;
ll a,b,c,d,e,ans;
ll x[500005],y[500005],z[500005];
ll ma,mi;
char s[100005],t[100005];
double aa;

int main(){
	cin>>s>>m;
	n=strlen(s);
	for(i=0;i<n;i++){
		if(i%m==0){
			t[num]=s[i];
			num++;
		}
	}
	p(t);
	return 0;
}

Measured memory_bytes: 6656
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 100000;
int N;
ll S[MAX_N];
int used[MAX_N];

int main() {
  cin >> N;
  rep(i, N) cin >> S[i];

  ll ans = 0;
  for (int C = 1; C <= N; ++C) {
    ll tmp = 0;
    int lb = C, ub = N-1-C;
    while (lb < N-1-C) {
      tmp += S[ub] + S[lb];
      if (used[lb] == C) break; used[lb] = C;
      if (used[ub] == C) break; used[ub] = C;
      ans = max(ans, tmp);
      lb += C; ub -= C;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1408