akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void) {
	int l[2],d[2],s[2],n,h,m,t,i;
	while(scanf("%d",&n) , n != 0){
		l[0] = 0;l[1] = 0;d[0] = 0;d[1] = 0;s[0] = 0;s[1] = 0;
		for(i = 1;i <= n;i++){
			scanf("%d:%d%d",&h,&m,&t);
			if(m > t){
				t+=60;
			}
			if(11 <= h && h < 15){
				l[1]++;
				if(t - m <= 8){
					l[0]++;
				}
			}
			if(18 <= h && h < 21){
				d[1]++;
				if(t - m <= 8){
					d[0]++;
				}
			}
			if(21 <= h || h < 2){
				s[1]++;
				if(t - m <= 8){
					s[0]++;
				}
			}
		}
		if(l[1]){
			printf("lunch %d\n",l[0] * 100 / l[1]);
		}
		else{
			printf("lunch no guest\n");
		}
		if(d[1]){
			printf("dinner %d\n",d[0] * 100 / d[1]);
		}
		else{
			printf("dinner no guest\n");
		}
		if(s[1]){
			printf("midnight %d\n",s[0] * 100 / s[1]);
		}
		else{
			printf("midnight no guest\n");
		}
	}
	return 0;
}

Measured memory_bytes: 608
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    int n;
    cin >> n;
    set<int> s;
    for(int i=0; i<n; ++i){
        int a;
        cin >> a;
        s.insert(a);
    }
    cout << s.size() << endl;

    return 0;
}


Measured memory_bytes: 256
package main

import(
    "fmt"
    "sort"
    "strings"
)



func main() {
    var a,b,c,d int
    fmt.Scan(&a,&b,&c,&d)
    ans := "No"
    if abs32(a-c)<=d || (abs32(a-b)<=d && abs32(b-c)<=d){
        ans = "Yes"
    }
    fmt.Println(ans)
}





func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func SortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}


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

  
int main(){
  int n,m;
  cin >> n >> m;
  int N,M;
  if(n>=2) N=n*(n-1)/2;
  else if(n<=1) N=0;
   if(m>=2) M=m*(m-1)/2;
  else if(m<=1) M=0;
  cout << N+M <<endl;
         
  
 }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define pll pair<ll,ll>
#define forA(i,a,n,x) for(auto i=a;i<n;i+=x)
#define forD(i,a,n,x) for(auto i=n-1;i>=0;i-=x)
#define ranit(it,n) for(auto it:n)
#define testCases ll t;cin>>t;while(t--)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007

 vll stone(100003,0); vll dp(100003,-1);

ll calc(ll n)
{
	if(n==0 || n==1)return dp[n];
	ll x,y; 
	if(dp[n-1]!=-1)x=dp[n-1];
	else {x=calc(n-1);}
	if(dp[n-2]!=-1)y=dp[n-2];
	else {y=calc(n-2);}

	dp[n]=min(x+abs(stone[n]-stone[n-1]),y+abs(stone[n]-stone[n-2]));
	return dp[n];
}

int main()
{
	ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
	ll n; cin>>n;forA(i,0,n,1)cin>>stone[i];
	dp[0]=0; dp[1]=abs(stone[1]-stone[0]);
	cout<<calc(n-1)<<"\n";
	//forA(i,0,n,1)cout<<dp[i]<<" ";
	return 0;
}

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

int main()
{
    int N;
    cin >> N;
    vector<vector<int>> kuku(9,vector<int>(9));
    repi(i,1,10) {
        repi(j,1,10) {
            kuku.at(i-1).at(j-1) = i * j;
        }
    }

    int flag = 0;
    repi(i,0,9){
        repi(j,0,9){
            if (N == kuku.at(i).at(j)) {
                flag = 1;
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    if (flag == 0){
        cout << "No" << endl;
    }

    return 0;
}

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

int main()
{
	long long int a,b,k,c,d;
	cin>>a>>b>>k;
	if(a>=k)
		{
			c=a-k;
			d=b;
		}
	else
		{
			c=0;
			if(a+b>=k)
				d=a+b-k;
			else
				d=0;
		}
		cout<<c<<" "<<d<<endl;
}

Measured memory_bytes: 3612
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const double pi = acos(-1);

int main() {
    ll a, b;
    cin >> a >> b;
    out(a*b);
    re0;
}

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

int main() {
  vector<long long> A(3);
  cin >> A.at(0) >> A.at(1) >> A.at(2);
  
  sort(A.begin(),A.end());
  
  if(A.at(0)%2==0||A.at(1)%2==0||A.at(2)%2==0){cout << 0 << endl;}
  else {cout << A.at(0)*A.at(1) << endl;}
    
}

Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
#include <cstdio>

using namespace std;

typedef pair<int, int> PII;

const int MAX_X = 4;
const int MAX_Y = 50;
const int MAX_MONEY = 5000;

PII eve[MAX_Y+1];
int num[MAX_X];
double prob[MAX_MONEY+1][MAX_Y+1];

int main ( void )
{
	int x, y, z;

	while (cin >> x >> y >> z, x | y | z) {
		for (int i = 0; i < x; ++i) {
			cin >> num[i];
		}
		fill (eve, eve+y+1, PII(0, 0));
		for (int i = 0; i < z; ++i) {
			int mass;
			cin >> mass;
			cin >> eve[mass].first >> eve[mass].second;
		}

		for (int i = 0; i <= MAX_MONEY; ++i) {
			fill(prob[i], prob[i]+MAX_Y+1, 0);
		}

		prob[0][0] = 1;
		for (int i = 0; i < y; ++i) {
			for (int j = 0; j < MAX_MONEY; ++j) {
				if (prob[j][i] == 0) { continue; }
				for (int k = 0; k < x; ++k) {
					int mass = min(i + num[k], y);
					PII e = eve[mass];
					switch (e.first) {
					case 1:
						prob[j][min(mass+e.second, y)] += prob[j][i] / x ;
						break;
					case 2:
						prob[j+e.second][mass] += prob[j][i] / x;
						break;
					case 3:
						prob[max(0, j-e.second)][mass] += prob[j][i] / x;
						break;
					default:
						prob[j][mass] += prob[j][i] / x;
						break;
					}
				}
			}
		}

	double d_ans = 0;
	for (int i = 0; i <= MAX_MONEY; ++i) {
		d_ans += prob[i][y] * i;
	}

	int ans = d_ans;
	printf("%d\n", ans);

	}
	return 0;
}

Measured memory_bytes: 3136
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <string.h>
using namespace std;

#define ISEQ(c) (c).begin(), (c).end()
typedef long long ll;

int main() {
  int n;
  scanf("%d", &n);
  ll res = 1LL;
  for (int i = 1; i <= n; i++)
    res *= i;
  printf("%ld\n", res);
}

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

using namespace std;

#define INF 1e9
#define MAXN 200005
#define MAXM 100005
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

ll ans;
int N, a[MAXN];
vi Xs;

void solve(){
    sort(Xs.begin(), Xs.end());

    rep(i, N){
        if(a[i] < Xs[(N+1)/2])
            cout << Xs[(N+1)/2] << endl;
        else
            cout << Xs[(N-1)/2] << endl;
    }
}

int main(){
    cin >> N;

    Xs.resize(N);

    rep(i, N) {
        cin >> Xs[i];
        a[i] = Xs[i];
    }
    solve();
}


Measured memory_bytes: 3712
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  
																								   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
																													   
const int INF = 1000000001;																						   
const float PI = 3.14;																								   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra	   
																													   																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////

LL n, m;

///////////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    
    cin >> n >> m;
    vector<LL> dp(m + 1);
    for(int i = 0; i < n; i++){
		LL waga, wartosc;
		cin >> waga >> wartosc;
		
		for(int j = m - waga; j >= 0; j--){
			dp[j + waga] = max(dp[j + waga], dp[j] + wartosc); 
		}
		//cout << "current dp: " << endl;
		//for(int i = 0;i <= m;i++){
			//cout << dp[i] << " ";
		//}
		//cout << endl << endl;
	}
	
	//cout << "tablica dp: " << endl;
	//for(int i = 0; i < n;i++){
		//cout << dp[i] << " ";
	//} 
   
   LL ans = 0;
   for(int i = 0; i <= m; i++){
	   ans = max(ans, dp[i]);
   }
	
	cout << ans << endl;
    
    
    
    
    
    
    

	
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

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
#include<cstdio>
const static int MAX_N = 100;
unsigned A[2][MAX_N];

int main(){
    unsigned N;
    scanf("%u", &N);
    for (size_t i = 0; i < N; i++) scanf("%u", &A[0][i]);
    unsigned answer = A[0][0];
    for (size_t i = 0; i < N; i++){
        scanf("%u", &A[1][i]);
        answer += A[1][i];
    }
    unsigned last = answer;
    for (size_t i = 1; i < N; i++){
        last = last + A[0][i] - A[1][i-1];
        if(answer < last)answer = last;
    }
    printf("%u\n", answer);
	return 0;
}

Measured memory_bytes: 1704
#pragma region Macros

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define int ll
using vi = vector<int>;
using vvi = vector<vi>;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

#pragma endregion

void Main() {
    int N, K;
    cin >> N >> K;
    vi p(N);
    REP(i, N) {
        cin >> p[i];
    }

    sort(ALL(p));
    int kSum = 0;
    REP(i, K) {
        kSum += p[i];
    }

    cout << kSum;
}

#pragma region main
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    Main();
    cout << flush;
}
#pragma endregion


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

#define mod 1000000007
#define INF 1000000000

#define mp make_pair
#define pb push_back
#define mt make_tuple
#define eb emplace_back
#define all(x) begin(x), end(x)
#define len(x) ((int)(x).size())
#define contains(a, x) (a.find(x) != end(a))
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define F(i,a,b) for(int i = (int)(a); i < (int)(b); ++i)
#define RF(i,a,b)for(int i = (int)(a); i >= (int)(b); --i)

using dbl = double;
using ll = long long;
using ull = unsigned ll;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pi = pair<int,int>;

#define log(x) cout << (x) << endl;
#define fast() {ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}




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

	vi a(n);
	rep (i,n) cin>>a[i];

	int sm = 0;
	rep(i,n) sm+=a[i];

	if (sm%10)
		log(sm)
	else {
		sort(all(a));
		rep (i, n) if(a[i]%10){
			sm -= a[i];
			break;
		}
		if (sm%10) log(sm)
		else log(0);
	}

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
using namespace std;

int main(void){
    int n;
    cin>>n;
    long long ans=1,s[10010]={};
    for(int i=1;i<=n;i++){
        int a=i;
        for(int j=2;j<=n;j++){
            int t=0;
            while(a%j==0){
                t++;
                a/=j;
            }
            s[j]+=t;
        }
    }
    for(int i=0;i<=n;i++){
        ans*=s[i]+1;
        if(ans>1000000007)ans%=1000000007;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
pair<int, int>x[8000000]; int n, m, s;
int main() {
	while (true) {
		for (int i = 0; i < 8000000; i++) { x[i].first = 1000000; }
		cin >> n >> m;
		if (!n) { break; }
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				cin >> s;
				x[j].first -= s;
				x[j].second = j;
			}
		}
		sort(x, x + m);
		for (int i = 0; i < m; i++) {
			if (i) { cout << ' '; } cout << x[i].second + 1;
		}
		cout << endl;
	}
}

Measured memory_bytes: 63664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int N;
  cin >> N;
  int H[N];
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }
  int ans = 0;
  int v = 0;
  for (int i = 0; i < N - 1; i++) {
    if (H[i] >= H[i + 1]) v++;
    else v = 0;
    ans = max(ans, v);
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 4020
#include <iostream>
#include <string>
#include <vector>
#include<algorithm>

using namespace std;

#define M 2005
bool d[3][3][M];

int max(int a, int b){
    if (a > b) return a;
    return b;
}
int ans = M * 3;
void check(string a, string b, string c){
    vector <string> s;
    s.push_back(a);
    s.push_back(b);
    s.push_back(c);
    
    int i, j, k;
    for (i=0;i<3;i++)
        for(j=0;j<3;j++)
            for(k=0;k<s[i].size();k++){
                if (i>= j) continue;
                bool ok = true;
                for (int ni =k; ni<s[i].size();ni++){
                    int nj = ni - k;
                    if (nj >= s[j].size()) break;
                    if (s[i][ni]=='?' || s[j][nj]=='?') continue;
                    if (s[i][ni] != s[j][nj]) ok = false;
                }
                d[i][j][k] = ok;
            }
    for (i=0;i<M;i++)
        for (j=0;j < M;j++){
            if (i < s[0].size() && !d[0][1][i]) continue;
            if (j < s[1].size() && !d[1][2][j]) continue;
            if (i+j < s[0].size() && !d[0][2][i+j]) continue;
            int now = 0;
            now = max(now, (int)s[0].size());
            now = max(now, i + (int)s[1].size());
            now = max(now, i + j + (int)s[2].size());
            ans = min(ans, now);
        }
}


int main()
{
    int i;
    vector<string> s(3);
    for (i=0;i<3;i++)
        cin >> s[i];
    
    sort(s.begin(), s.end());
    
    check(s[0], s[1], s[2]);
    check(s[0], s[2], s[1]);
    check(s[1], s[0], s[2]);
    check(s[1], s[2], s[0]);
    check(s[2], s[0], s[1]);
    check(s[2], s[1], s[0]);
    
    cout << ans<<endl;
    return 0;
}


Measured memory_bytes: 256
using System;
class Program
{
    static void Main()
    {
        int[] input = new int[10];
        for (int i = 0; i < input.Length; i++)
        {
            input[i] = int.Parse(Console.ReadLine());
        }
        Array.Sort(input);
        Array.Reverse(input);
        for (int i = 0; i < 3; i++)
        {
            Console.WriteLine(input[i]);
        }
        Console.ReadLine();
    }
}

Measured memory_bytes: 9352
b = gets.chomp

D = ["A", "T", "G", "C"]

max = 0
count = 0

for i in 0..(b.length-1) do
  for j in 0..3 do
    if b[i] == D[j]
      count += 1
      if max < count
        max = count
      end
      break
    end

    if j == 3
      count = 0
    end
  end
end

puts max


Measured memory_bytes: 1788
import numpy as np

N,T = map(int, input().split())
ct = [list(map(int, input().split())) for i in range(N)]
c = np.array([ct[i][0] for i in range(N)])
t = np.array([ct[i][1] for i in range(N)])
c_ = list(c[t<T])
if len(c_)==0:
    print("TLE")
else:
    print(np.min(c[t<=T]))


Measured memory_bytes: 21576
#include <stdio.h>
#include <iostream>

using namespace std;

int main(void){
	long long int w;
	long long int a;
	long long int wa;
	long long int b;
	long long int wb;

	long long int ans;

	scanf("%lld %lld %lld",&w, &a, &b);

	wa = a + w;
	wb = b + w;

	if(wb - wa > 0){
		if(b - wa < 0){ans = 0;}
		else{ans = b - wa;}
	}else{
		if(a - wb < 0){ans = 0;}
		else{ans = a - wb;}
	}

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

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9,MOD = 1e9+7,ohara = 1e6;
const ll LINF = 1e18;
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrrep(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt=0,ans=LINF,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);
      
    cin>>n;
    pair<ll,ll> p[ohara];
    rep(i,n){
        cin>>a;
        p[i]=make_pair(a,i);
    }
    sort(p,p+n);
    rep(i,n-1){
        if(p[i].second<p[i+1].second)cnt++;
        else{
            ans=min(ans,n-cnt-1);
            cnt=0;
        }
    }
    ans=min(ans,n-cnt-1);
    Cout(ans);
    return 0;
}


Measured memory_bytes: 15872
#include<iostream>
#include<climits>

using namespace std;

int main()
{
	int n;
	cin >> n;
	long int max, min, sum;
	max = LONG_MIN; min = LONG_MAX; sum = 0;
	long int num;

	for (int i = 0; i < n; i++)
	{
		cin >> num;
		
		if (max < num)
			max = num;

		if (min > num)
			min = num;

		sum += num;
	}

	cout << min << " " << max << " " << sum << endl;

}

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

int main(){

int N,A,B,C,D;
cin >> N >> D;
C = 0;
//cin >> K >> A >> B;
//vector<int> X(N);
for(int i = 0; i < N;i++){
	cin >> A >> B;
	if(sqrt(pow(A,2)+pow(B,2))<=D) C++;
}
cout << C << endl;
}

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

const int MOD=1e9+7;

int main(){
    string s; cin>>s;
    int dp[100010][4]={0};
    dp[0][0]=1;
    for(int i=1;i<=s.size();i++){
        for(int j=0;j<=3;j++){
            (dp[i][j]+=dp[i-1][j])%=MOD;
            if(s[i-1]=='?'){
                (dp[i][j]+=(2*dp[i-1][j])%MOD)%=MOD;
            }
            if(!j)continue;
            if(s[i-1]-'A'+1==j||s[i-1]=='?'){
                (dp[i][j]+=dp[i-1][j-1])%=MOD;
            }
        }
    }
    cout<<dp[s.size()][3]<<endl;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define INF 1000000000
typedef pair<int,int>P;
int dx[]={0,1,0,-1};
int dy[]={-1,0,1,0};
char mp[109][109];
int d[109][109];

int main(){
  int h,w;
  int ans=0;
  cin>>h>>w;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>mp[i][j];
      if(mp[i][j]=='.')ans++;
      d[i][j]=INF;
    }
  }

  queue<P>que;
  que.push(P(0,0));
  d[0][0]=0;
  while(!que.empty()){
    P now=que.front();que.pop();
    int x=now.fi;
    int y=now.se;
    for(int i=0;i<4;i++){
      int nx=x+dx[i];
      int ny=y+dy[i];
      if(0<=nx&&nx<w&&0<=ny&&ny<h&&mp[ny][nx]!='#'&&d[ny][nx]==INF){
	que.push(P(nx,ny));
	d[ny][nx]=d[y][x]+1;
      }
    }
  }

  if(d[h-1][w-1]==INF){
    cout<<-1<<endl;
  }
  else{
    cout<<ans-d[h-1][w-1]-1<<endl;
  }
  return(0);
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <iterator>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(v) reverse((v).begin(),(v).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)

struct MyStruct {
	int idx, a, b, pl;
};

bool comp(const MyStruct& s, const MyStruct& t) {
	if (s.pl != t.pl)
		return s.pl > t.pl; // 降順
	return s.idx < t.idx;
}


int main() {
	int n;
	cin >> n;
	VI v(n);
	REP(i, n) {
		cin >> v[i];
	}

	SORT(v);
	int m = v[n - 1];

	int sum = 0;
	REP(i, n - 1) {
		sum += v[i];
	}

	if (m < sum) {
		ANS("Yes");
	}
	else {
		ANS("No");
	}

	return 0;
}


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

#define itos(x) to_string(x)
#define stoi(x) stoi(x)
#define ctoi(x) (x-'0')

#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) (int)(x).size()

#define ll long long
#define ld long double
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ld pi = acos((ld)-1);
const ld e = exp(1);

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s, t; cin >> s >> t;
  int count = 0;
  for (int i = 0; i < sz(s); i++) {
    if (s[i] != t[i]) {
      count++;
    }
  }
  cout << count << "\n";
  return 0;
}


Measured memory_bytes: 3868
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

    static long mod=1000000007;
    static long[][] dp;
    public static void main(String[] args)throws Exception{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        String[] s=br.readLine().split(" ");
        int n=Integer.parseInt(s[0].trim());
        int m=Integer.parseInt(s[1].trim());
        char[][] a=new char[n][m];
        for(int i=0;i<n;i++){
            String s1=br.readLine().trim();
            for(int j=0;j<m;j++){
                a[i][j]=s1.charAt(j);
            }
        }
        dp=new long[n][m];
        for(int i=0;i<n;i++){
            Arrays.fill(dp[i],-1);
        }
        dp[0][0]=1;
        for(int i=1;i<n;i++){
            for(int j=1;j<m;j++){
                long res=0;
                if(i-1>=0 && a[i-1][j]!='#'){
                    res=(grid(a,i-1,j)%mod);
                }
                long res2=0;
                if(j-1>=0 && a[i][j-1]!='#'){
                    res2=(grid(a,i,j-1)%mod);
                }
                long r=((res%mod)+(res2%mod))%mod;
                dp[i][j]=r;
            }
        }

        System.out.println(dp[n-1][m-1]);






    }

    public static long grid(char[][] a,int i,int j){
        if(dp[i][j]!=-1){
            return dp[i][j];
        }

        if(i==0 && j==0){
            dp[i][j]=1;
            return 1;
        }
        long res=0;
        if(i-1>=0 && a[i-1][j]!='#'){
            res=((dp[i-1][j])%mod);
        }
        long res2=0;
        if(j-1>=0 && a[i][j-1]!='#'){
            res2=((dp[i][j-1])%mod);
        }
        long r=((res%mod)+(res2%mod))%mod;
        dp[i][j]=r;
        return r;
    }






}


Measured memory_bytes: 47540
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18,MOD = 1e9 + 7;
const int INT_INF = 1e9,INT_MOD=1e9+7;
#define rep(i, N) for(int i = 0; i < N; i++)
typedef pair<int, int> Pi;
typedef pair<double, double> P;
vector<int> r,b,g;
int count=0;
bool isOK(int index, int key) {
    if (g[index] >= key) return true;
    else return false;
}
int nibutan(int key) {
    int ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int ok = (int)g.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
    int mid;
    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
        mid = (ok + ng) / 2;

        if (isOK(mid, key)) ok = mid;
        else ng = mid;
    }
    if(ok<g.size() and ok>=0 and g[ok]==key) return 1;
    else return 0;
}

signed main(){
    int n;cin>>n;
    ll ans=0;
    string str;cin>>str;
    rep(i,str.size()){
        if(str[i]=='R') r.push_back(i);
        else if(str[i]=='G') g.push_back(i);
        else b.push_back(i);
    }
    //cout<<r.size()<<b.size()<<g.size()<<endl;
    if(r.size()==0 or b.size()==0 or g.size()==0){
        cout<<"0"<<endl;
        return 0;
    }
    int count=0;
    int siz=g.size();
    rep(i,r.size())rep(j,b.size()){
        count=0;
        int x=r[i],y=b[j];
        int low,high,middle;
        if(x>y){
            if((x+y)%2==0){
                low=y-(x-y);
                high=x+(x-y);
                middle=(x+y)/2;
                if(nibutan(low)==1) count++;
                if(nibutan(high)==1) count++;
                if(nibutan(middle)==1) count++;
                ans+=siz-count;
            }else{
                low=y-(x-y);
                high=x+(x-y);
                if(nibutan(low)==1) count++;
                if(nibutan(high)==1) count++;
                ans+=siz-count;
            }
        }else{
            if((x+y)%2==0){
                low=x-abs(x-y);
                high=y+abs(x-y);
                middle=(x+y)/2;
                if(nibutan(low)==1) count++;
                if(nibutan(high)==1) count++;
                if(nibutan(middle)==1) count++;
                ans+=siz-count;
            }else{
                low=x-abs(x-y);
                high=y+abs(x-y);
                if(nibutan(low)==1) count++;
                if(nibutan(high)==1) count++;
                ans+=siz-count;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

int A[2001];
int q, n;

bool solve(int i, int m){
    if(m==0) return true;
    if(i>=n) return false;
    bool res = solve(i+1, m) || solve(i+1, m-A[i]);
    return res;
}


int main(){
    scanf("%d",&n);
    for(int i=0;i<n;++i) scanf("%d",&A[i]);
    scanf("%d",&q);
    int m;
    for(int i=0;i<q;++i){
        scanf("%d",&m);
        if(solve(0,m)) printf("yes\n");
        else printf("no\n");
    }

}



Measured memory_bytes: 3160
#include <stdio.h>
#include <math.h>
#include <string.h>

int main(void){
    int i,j,k;
    int N,answer;
    char S[200];
    
    scanf("%s",S);
    N = strlen(S);
    
    for(i = 0;i < N;i += 2){
        if(S[i] == 'R' || S[i] == 'U' || S[i] == 'D'){
            
        }else{
            printf("No\n");
            return 0;
        }
    }
    for(i = 1;i < N;i += 2){
        if(S[i] == 'L' || S[i] == 'U' || S[i] == 'D'){
            
        }else{
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string.h>
#include <cstdio>
#include <string>
#include <math.h>

using namespace std;

void solve(){

}

int main(){
    int N,L;
    int min_index=-1, min_value=1000;
    int A[256];

    scanf("%d %d", &N, &L);

    for (int i = 0; i < N ; i++){
        A[i] = L + i;
        if(min_value > abs(A[i])){
            min_value = abs(A[i]);
            min_index = i;
        }
    }

    A[min_index] = 0;
    int ret=0;

    for (int i = 0; i < N ; i++){
        ret += A[i];
    }
    
    printf("%d\r\n", ret);
    fflush(stdout);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>

using namespace std;

const int maxv = 105;
vector<int> adj [maxv];

typedef long long llong;

int max_deg [maxv];
void calc_max_deg (int vertex, int parent, int lvl) {
  if (parent == 0) {
    max_deg[lvl] = max(max_deg[lvl], (int) adj[vertex].size());
  } else {
    max_deg[lvl] = max(max_deg[lvl], (int) adj[vertex].size() - 1);
  }

  for (int nxt : adj[vertex]) {
    if (nxt != parent) {
      calc_max_deg(nxt, vertex, lvl + 1);
    }
  }
}

pair<int, llong> attempt (int root) {
  for (int i = 0; i < maxv; i++) {
    max_deg[i] = 0;
  }

  calc_max_deg(root, 0, 0);

  pair<int, llong> ans = make_pair(1, 1LL);
  for (int i = 0; i < maxv; i++) {
    if (max_deg[i] != 0) {
      ans.first++;
      ans.second *= max_deg[i];
    }
  }

  return ans;
}

pair<int, llong> attempt (int root, int boot) {
  for (int i = 0; i < maxv; i++) {
    max_deg[i] = 0;
  }

  calc_max_deg(root, boot, 0);
  calc_max_deg(boot, root, 0);

  pair<int, llong> ans = make_pair(1, 2LL);
  for (int i = 0; i < maxv; i++) {
    if (max_deg[i] != 0) {
      ans.first++;
      ans.second *= max_deg[i];
    }
  }

  return ans;
}

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

  for (int i = 0; i < vertexc - 1; i++) {
    int u, v;
    cin >> u >> v;

    adj[u].push_back(v);
    adj[v].push_back(u);
  }

  pair<int, llong> ans = make_pair(maxv, -1);
  for (int i = 1; i <= vertexc; i++) {
    ans = min(ans, attempt(i));
    for (int u : adj[i]) {
      ans = min(ans, attempt(i, u));
    }
  }

  cout << ans.first << " " << ans.second << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll GCD(ll a, ll b){ return a ? GCD(b % a, a) : b; }
int main(){
    int n,k;
    cin>>n>>k;
    vector<int> p(n);
    for(int i=0; i<n; i++) cin>>p[i];
    sort(p.begin(), p.end());
    int sum=0;
    for(int i=0; i<k; i++){
        sum+=p[i];
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include<string.h> 
#include <vector>
#include <cmath>
#include <string>
#include <stack>
#include <algorithm>
using namespace std;
int main (){
	int n, i, p, a, sum=0;
	int arr[100];
	cin >> n;
	for (i=0; i<n; i++){
		cin >> arr[i];
	}
	for (p=0; p<n; p++){
		for (a=p+1; a<n; a++){
			sum+=arr[p]*arr[a];
		}
	}
	cout << sum;
}

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


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

    bool n = false;
    bool s = false;
    bool e = false;
    bool w = false;

    for (int i = 0; i < S.size(); ++i) {
        if (S[i] == 'N') n = true;
        else if (S[i] == 'S') s = true;
        else if (S[i] == 'E') e = true;
        else if (S[i] == 'W') w = true;
    }

    if (((n && s) && (e && w))||((n && s) && (!e && !w))||((!n && !s) && (e && w))) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <typename T> using vec = vector<T>;

int main()
{
    int n;
    cin >> n;
    int f[270000];
    for (int i = 0; i < n; i++)
    {
        f[i] = 0;
    }
    int x;
    int y;
    int z;
    for ( x = 1; x < 150; x++)
    {
        for ( y = 1; y <= x; y++)
        {
            for ( z = 1; z <= y; z++)
            {
                int N = x*x+y*y+z*z+x*y+y*z+z*x;
                if (x==y and y== z)
                {
                    f[N] += 1;
                }
                else if (x!=y and y!=z and z!=x)
                {
                    f[N] += 6;
                }
                else
                {
                    f[N] += 3;
                }
            }
            
        }
        
    }
    for (int i = 1; i <= n; i++)
    {
        cout << f[i] << endl;
    }
    
    
}

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

void main_()
{
    int N, M;
    cin >> N >> M;

    bitset<100007> ac_problems;
    array<int, 100007> wa_counts = {};

    int ac_total = 0;
    for (int m = 0; m < M; ++m) {
        int p;
        string s;
        cin >> p >> s;
        if (!ac_problems[p]) {
            if (s == "AC") {
                ac_total++;
                ac_problems.set(p);
            }
            if (s == "WA") {
                wa_counts[p]++;
            }
        }
    }

    int wa_total = 0;
    for (int n = 1; n <= N; ++n) {
        if (ac_problems[n]) {
            wa_total += wa_counts[n];
        }
    }

    cout << ac_total << " " << wa_total << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 640
# -*- coding: utf-8 -*-
n = int(input())
p = list(map(int,input().split()))
q = list(map(int,input().split()))

from collections import deque
#階乗 kaijo
import math
kaijo_list = [math.factorial(i) for i in range(1,9)]
def calc_dict_order(int_list):
    ret = 0
    int_list=deque(int_list)
    base_dict = [i for i in range(1,n+1)]
    while int_list:
        x = int_list.popleft()
        rank_x = base_dict.index(x)
        del base_dict[rank_x]
        ret+=(rank_x*kaijo_list[len(base_dict)-1])
    return ret
print(abs(calc_dict_order(p)-calc_dict_order(q)))

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n,i;
    cin>>n;
    string str[n];
    string s;
    map<string,ll> m1;
    vector<pair<ll,string> >arr;
    for(ll i=0;i<n;i++){
        cin>>str[i];
        m1[str[i]]+=1;
    }
    map<string,ll>::iterator it;
    ll temp = INT_MIN;
    for(it=m1.begin();it!=m1.end();it++){
        arr.push_back(make_pair(it->second,it->first));
        temp=max(temp,it->second);
    }
    vector<string> ans;
    sort(arr.rbegin(),arr.rend());
    for(i=0;i<arr.size();i++){
        if(arr[i].first==temp)
            ans.push_back(arr[i].second);
    }
    sort(ans.begin(),ans.end());
    for(i=0;i<ans.size();i++)
        cout<<ans[i]<<endl;
    return 0;
}


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

int main() {
    int A ,B, C;
    cin >> A >> B >> C;
    int ans = A;
    int flag = 0;
    for (int i = 0; i < 100; ++i){
        ans = A * i;
        if ( ans >= B ) {
            ans = ans % B;
        }
        if ( ans == C ) {
            flag = 1;
        }
    }
    if (flag == 1 ) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define SORT(v) sort(v.rbegin() , v.rend())
#define si(n) scanf( "%d" , &n)
#define sii(n , m) scanf( "%d %d" , &n , &m)
#define sl(n) scanf( "%lld" , &n)
#define sll(n , m) scanf( "%lld %lld" , &n, &m)
#define ss(cad) scanf( "%s" , cad)
#define sz(x) (int)x.size()
#define PB push_back
#define fst first
#define scn second
#define DBG(x) cerr << #x << " = " << (x) << endl
#define M 11092019
#define N_MAX 1000010
#define EPS 1e-9

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<ll> vll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<pi> vp;

int main(){
	ll d, s, t;
	sll(d, s);
	sl(t);
	if(d > t*s)
		printf("No\n");
	else
		printf("Yes\n");
    return 0;
}

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

int main(){
    ll n,x;cin>>n>>x;
    ll e,ans;
    ans=0;
    vector<ll> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=1;i<n;i++){
        e=max((ll)0,(a[i-1]+a[i])-x);
        ans+=e;
        a[i]=max((ll)0,a[i]-e);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
user = input()
w = int(user)
user = input()
n = int(user)
a = []
b = []
now = 0
for i in range(n):
    user = input()
    users = user.split(",")
    a.append(int(users[0]))
    b.append(int(users[1]))

for j in range(1, w+1):
    now = j
    for k in reversed(range(n)):
        if now == a[k]:
            now = b[k]
        elif now == b[k]:
            now = a[k]
    print(now)

Measured memory_bytes: 7612
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define int long long int
#define double long double
#define inf (int)(1e15)
#define all(x) (x).begin(), (x).end()
#define pair pair<int, int>
typedef vector<int> vi;   // Vector of long long
typedef vector<vi> vvi;   // Vector of vi
typedef vector<pair> vii; // Vector of pairs
typedef vector<vii> vvii; // Vector of Vector of pairs
typedef vector<bool> vb;  // Vector of bool
#define pq priority_queue // Max heap (To convert to min heap, use negative sign before every value)
#define ff first          // For pairs
#define ss second
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, -1, 0, 1};
const int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}, dy8[] = {1, -1, 1, 0, -1, 1, -0, -1};
#define testcases(t) \
    int(t);          \
    cin >> (t);      \
    while ((t)--)
signed main()
{
    int a, b;
    cin >> a >> b;
    vi primesa, primesb;
    int cnt = 1;
    for (int i = 2; i * i <= a; i++)
    {
        if (a % i == 0)
        {
            primesa.pb(i);
            while (a % i == 0)
            {
                a /= i;
            }
        }
    }
    for (int i = 2; i * i <= b; i++)
    {
        if (b % i == 0)
        {
            primesb.pb(i);
            while (b % i == 0)
            {
                b /= i;
            }
        }
    }
    if (a > 2)
        primesa.pb(a);
    if (b > 2)
        primesb.pb(b);
    for (int i = 0; i < primesa.size(); i++)
    {
        for (int j = 0; j < primesb.size(); j++)
            if (primesb[j] == primesa[i])
                cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

int main(void) {
  int n; cin >> n;
  if (n == 0) cout << 1 << endl;
  else if (n == 1) cout << 2 << endl;
  else if (n == 2) cout << 1 << endl;
  else cout << 0 << endl;
}


Measured memory_bytes: 3104
S=input()
c=0
for m in range(len(S)):
    if m%2==0:
        if S[m]=="L":
            print("No")
            break
    elif m%2==1:
        if S[m]=="R":
            print("No")
            break
    c+=1
if c==len(S):
    print("Yes")

Measured memory_bytes: 3060
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


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

    ll maxNum = 0;
    ll maxA = -1;
    ll secondA = -2;
    ll A[N];
    rep(i, N){
        cin >> A[i];
        if(A[i] > maxA){
            secondA = maxA;
            maxA = A[i];
            maxNum = 1;
        }else if(A[i] == maxA){
            maxNum++;
        }else if(A[i] > secondA){
            secondA = A[i];
        }
    }

    rep(i, N){
        if(A[i] == maxA){
            if(maxNum > 1){
                cout << maxA << endl;
            }else{
                cout << secondA << endl;
            }
        }else{
            cout << maxA << endl;
        }
    }

    return 0;
}

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

int main()
{
    int n, m, c;
    cin >> n >> m >> c;
    vector<int> b(m);
    rep(i, m) cin >> b.at(i);
    vector<vector<int>> a(n, vector<int>(m));
    rep(i, n)
    {
        rep(j, m)
        {
            cin >> a.at(i).at(j);
        }
    }

    int answer = 0;
    rep(i, n)
    {
        int if_sum = c;
        rep(j, m)
        {
            if_sum += a.at(i).at(j) * b.at(j);
        }
        if (if_sum > 0)
            answer++;
    }
    cout << answer << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        sb.append(br.readLine());
        for(int i=0;i<sb.length();i++){
            if(Character.isUpperCase(sb.charAt(i))){
                sb.replace(i,i+1,sb.substring(i,i+1).toLowerCase());
            }else{
                sb.replace(i,i+1,sb.substring(i,i+1).toUpperCase());
            }
        }
        sb.append("\n");
        System.out.print(sb);
    }
}

Measured memory_bytes: 24456
#include <bits/stdc++.h>
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define repi(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define SIZE_OF_ARRAY(array)    (sizeof(array)/sizeof(array[0]))
typedef long long ll;
using namespace std;
int main(){
  int n;
  string s;
  int ans=0;
  cin >> n >> s;
  for(int i=0;i<n-2;i++){
    string str = s.substr(i,3);
    if(str == "ABC"){
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <map>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "Yes" : "No";
}

int n;

int main(){
    string s; cin >> s;
    
    s[5] = s[13] = ' ';
    
    cout << s << endl;
        
}







Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define f first
#define s second
using namespace std;

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    set<string> st;
    int n; cin >> n;
    bool ok = 1;
    vector<string> vec;
    for(int i = 0; i< n; i++){
        string t; cin >> t;
        if(i == 0){
            vec.pb(t); st.insert(t); continue;
        }
        if(st.find(t) == st.end() && vec[i-1][vec[i-1].length()-1] == t[0]){
            vec.pb(t); st.insert(t);
        }
        else{
            vec.pb(t); st.insert(t);
            ok = false;
        }
    }
    cout << (ok ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 3660
import java.io.*;
import java.util.*;

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

		int n = in.nextInt();
		int[] a = new int[n];

		int target = 1;
		int breakCount = 0;
		for (int i=0; i<n; i++) {
			int x = in.nextInt();
			if (x != target)
				breakCount++;
			else
				target++;
		}
		if (breakCount == n)
			System.out.println(-1);
		else
			System.out.println(breakCount);
	}
}



Measured memory_bytes: 84880
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int arr[1000001];
    pair<int*,int*>result;
    for (int i = 0; i < n; i++)
        cin >> arr[i];
    int q;
    cin >> q;
    while (q--) {
        int val;
        cin >> val;
        result = equal_range(arr, arr + n, val);
        cout << result.first-arr << " " << result.second-arr << endl;
    }
}


Measured memory_bytes: 3492