akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
#define CONTAINS_SET(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }

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

	int ans = 0;
	int ma = 0;
	for (int i = 0; i < S.length(); i++)
	{
		if (S[i] == 'R') ans++;
		else ans = 0;
		ma = max(ans, ma);
	}
	cout << ma << endl;
}



Measured memory_bytes: 3196
#include<stdio.h>

int main(){
	int A[3];
	int X,Y,Z;
	scanf("%d %d %d",A,A+1,A+2);
	for(X=0;X<2;X++)
		for(Y=0;Y<2;Y++)
			if(A[Y]>A[Y+1]){
				Z=A[Y];
				A[Y]=A[Y+1];
				A[Y+1]=Z;
			}
	printf("%d %d %d\n",A[0],A[1],A[2]);
	return 0;
}

Measured memory_bytes: 596
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <queue>

using namespace std;



int main(){

	int d,s;

	scanf("%d",&d);

	for(int i=0; i < d; i++){
		scanf("%d",&s);

		printf("Case %d:\n",i+1);
		for(int k=0; k < 10; k++){
			s = s*s;
			s /= 100;
			s %= 10000;
			printf("%d\n",s);
		}

	}

    return 0;
}



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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define COUT(x) cout<<(x)<<"\n"

int main(){
    int n;
    cin >> n;
    vector<int> vec(100010,0);
    int t;
    ll ans = 0;
    REP(i,n){
        cin >> t;
        vec[t]++;
        ans += t;
    }
    int q; cin >> q;
    REP(i,q){
        int b,c;
        cin >> b >> c;
        ans += (c-b)*vec[b];
        vec[c]+= vec[b];
        vec[b]=0;
        COUT(ans);
    }
    return 0;
}

Measured memory_bytes: 3756
n = int(input())
s = [str(input()) for _ in range(n)]

ba = 0
bo = 0
oa = 0
ans = 0

for i in range(n):
    ans += s[i].count('AB')
    if s[i][0] == 'B' and s[i][-1] == 'A':
        ba += 1
    elif s[i][0] == 'B':
        bo += 1
    elif s[i][-1] == 'A':
        oa += 1
#print(ans, ba, min(bo, oa))

if ba > 0 and bo + oa > 0:
    ans += ba + min(bo, oa)
if ba > 0 and bo + oa == 0:
    ans += ba - 1
if ba == 0 and bo + oa > 0:
    ans += min(bo, oa)

print(ans)

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

int main(void) {
    int N, M;
    cin >> N >> M;
    map<int, int> ma;
    bool flag = false;
    for (int i = 0; i < M; i++) {
        int s, c;
        cin >> s >> c;
        s--;
        if (s == 0 && c == 0 && N != 1) {
            flag = true;
        }
        auto f = ma.find(s);
        if (f == ma.end()) {
            ma[s] = c;
        } else {
            if ((*f).second != c) {
                flag = true;
            }
        }
    }
    if (flag) {
        cout << -1 << endl;
        return 0;
    }

    string ans(N, '0');
    if (N != 1) {
        ans[0] = '1';
    }
    for (auto m : ma) {
        ans[m.first] = m.second + '0';
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

bool doit(int i, int j, vector<string> &A, vector<string> &B)
{
    if (i + B.size() > A.size() || j + B.size() > A.size())
        return false;
    for (int _i = i; _i - i < B.size(); _i++)
        for (int _j = j; _j - j < B.size(); _j++)
            if (B[_i - i][_j - j] != A[_i][_j])
                return false;
    return true;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m;
    cin >> n >> m;
    vector<string> A(n);
    vector<string> B(m);
    for (string &s : A)
        cin >> s;
    for (string &s : B)
        cin >> s;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            if (doit(i, j, A, B))
            {
                cout << "Yes\n";
                return 0;
            }
    cout << "No\n";
    return 0;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int c0 = 0;
		int c1 = 0;
		int c2 = 0;
		int c3 = 0;
		for(int i = 0; i < n; i++) {
			String in = sc.next();
			if(in.equals("AC")){
				c0++;
			} else if(in.equals("WA")) {
				c1++;
			} else if(in.equals("TLE")) {
				c2++;
			} else {
				c3++;
			}
		}
		System.out.println("AC x " + c0);
		System.out.println("WA x " + c1);
		System.out.println("TLE x " + c2);
		System.out.println("RE x " + c3);
	}
}


Measured memory_bytes: 58688
#include <iostream>
#include <string.h>
using namespace std;
int main()
{
	string s,w;
	cin>>s>>w;
	int i;
	if(w.length()==(s.length()+1))
	{
		for(i=0;i<s.length();i++)
		{
			if(s.at(i)!=w.at(i))
			break;
		}
		if(i==s.length())
		cout<<"Yes\n";
		else
		cout<<"No\n";
	}
	else
	cout<<"No\n";
	return 0;
}

Measured memory_bytes: 3600
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_C
{
    class C080
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            List<bool[]> Flist = new List<bool[]>();
            List<int[]> Plist = new List<int[]>();
            for (int i = 0; i < N; i++)
            {
                bool[] F = Console.ReadLine().Split(' ').Select(x => x == "1").ToArray();
                Flist.Add(F);
            }
            for (int i = 0; i < N; i++)
            {
                int[] P = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                Plist.Add(P);
            }

            int pmax = int.MinValue;
            for(int i = 1; i < 1024; i++)
            {                
                int k = i;
                bool[] op = new bool[10];
                for (int j = 0; j < 10; j++)
                {
                    op[j] = k % 2 == 1;
                    k /= 2;
                }

                int pall = 0;
                for(int j = 0; j < Flist.Count; j++)
                {
                    int c = 0;
                    bool[] F = Flist[j];
                    for (int m = 0; m < 10; m++)
                    {
                        if (op[m] && F[m]) c++;
                    }
                    int[] P = Plist[j];
                    pall += P[c];
                }

                if (pall > pmax) pmax = pall;
            }
            Console.WriteLine(pmax);
        }
    }
}


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

int gcd(int n, int m) {
    if (n < m)
        return gcd(m, n);
    else
        return m == 0 ? n : gcd(m, n % m);
}

long long lcm(int n, int m) {
    return 1ll * n * m / gcd(n, m);
}

int main() {
    
    string s, t;
    int n, m;
    long long l;
    int dn, dm, e;
    
    cin >> n >> m >> s >> t;
    l = lcm(n, m);
    dn = l / m;
    dm = l / n;
    
    for (int i = 0, j = 0; i < n; i += dn, j += dm) {
        if (s[i] != t[j]) {
            cout << -1 << endl;
            return 0;
        }
    }
    
    cout << l << endl;
    
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
using namespace std;
 
int main () {
  string x;
  int sum;
  while (1) {
    cin >> x;
    if (x == "0") break;
    sum = 0;
    for (int i = 0; i< x.size(); i++) {
      sum += x[i] - '0';
    }
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 3104
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  int n, m;
  cin >> n >> m;
  int ma, mi;
  ma = INF;
  mi = 0;
  rep (i, m) {
    int l, r;
    cin >> l >> r;
    mi = max(mi, l);
    ma = min(ma, r);
  }
  // cout << ma << " " << mi << endl;
  if (ma - mi + 1 > 0) P(ma - mi + 1);
  else P(0);
  return 0;

}

Measured memory_bytes: 256
# coding: utf-8
def get_ln_inputs():
    return input().split()


def get_ln_int_inputs():
    return list(map(int, get_ln_inputs()))


def main():
    N = get_ln_int_inputs()[0]
    A = list()
    for _ in range(N):
        A.append(get_ln_int_inputs()[0])

    res = {}
    for a in A:
        if not a in res:
            res[a] = 1
        else:
            del res[a]
    print(len(res))
    return


main()

Measured memory_bytes: 16292
N,K = map(int,input().split())
k = []
s = []
sum = 0
ans = 0
for i in range(10**5):
    k.append(0)
for i in range(N):
    s.append(list(map(int,input().split())))
for i in range(N):
    k[(s[i][0]-1)] += s[i][1]
for i in range(10**5):
    sum += k[i]
    ans += 1
    if sum >= K:
        print(ans)
        break
    else:
        continue

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

/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
*/

using namespace std;

#if DEBUG && !ONLINE_JUDGE
    #include "debug.h"
#else
    #define debug(...)
#endif

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

#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define fill(a,x) memset(a,x,sizeof(a))
#define ff first
#define ss second
#define trav(a, x) for(auto& a : x) 
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
const ll INF = 1e18;
const int mod =  1e9 + 7;
const int N = 1e6;
ll gcd(ll a,ll b){if (a==0) return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return a*(b/gcd(a,b));}
ll Abs(ll a){if(a>0)return a;return -a;}
ll Ceil(ll a,ll b){if(a%b==0)return a/b;else return a/b+1;}
double Abs(double a){if(a>0)return a;return -a;}

//*X.find_by_order(2) element at index=2
//X.order_of_key(1) how many elements strictly less than 1

/*
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;
*/

inline int pow_(ll x, ll y,ll p){
  int r = 1; while(y){if(y & 1) r = r * x % p; y >>= 1; x = x * x % p;} return r;
}
inline int inv_(int x){return pow_(x, mod - 2, mod);}
inline int add(int a, int b){a += b; if(a >= mod) a -= mod; return a;}
inline int mul(int a, int b){return a * 1LL * b % mod;}
inline int sub(int a, int b){a -= b; if(a < 0) a += mod; return a;}


ll n;
ll a[305] = {0};
double dp[305][305][305]  = {0};

double rec(int x,int y,int z)
{
	if(x==0 && y==0 && z==0)
	{
		return 0;
	}

	if(dp[x][y][z]!=0)return dp[x][y][z];
	double t = (x+y+z)*1.0;
	dp[x][y][z] = 0;
	dp[x][y][z] += n/t;
	if(x>0)dp[x][y][z] += (x/t)*rec(x-1,y,z);
	if(y>0)dp[x][y][z] += (y/t)*rec(x+1,y-1,z);
	if(z>0)dp[x][y][z] += (z/t)*rec(x,y+1,z-1);

	return dp[x][y][z];
}

int main()
{
	#ifdef LOCAL_TEST
    freopen("in.txt","r",stdin);
    //freopen("out.txt", "w", stdout);
    #else
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    #endif
	cin>>n;
	ll x,y,z;
	x = 0;
	y = 0;
	z = 0;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]==1)x++;
		else if(a[i]==2)y++;
		else z++;
	}

	double ans = rec(x,y,z);
	printf("%0.12f\n",ans);
    return 0;
}

Measured memory_bytes: 219392
# https://atcoder.jp/contests/abc085/tasks/abc085_c
# スペース区切りの整数の入力
n,y=gets.chomp.split(" ").map(&:to_i);

flag = false
for yukichi in 0..n
    for higuchi in 0..n
        noguchi = n - yukichi - higuchi
        if (yukichi * 10000 + higuchi * 5000 + noguchi * 1000 == y) && (yukichi + higuchi + noguchi == n) && noguchi >=0
            print("#{yukichi} #{higuchi} #{noguchi}")
            flag = true
            exit
        end
    end
end

if flag == false
   print("-1 -1 -1")
end

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

int main()
{
  string s;
  cin >> s;
  if(s=="SUN"){cout << "7";}else
  if(s=="MON"){cout << "6";}else
  if(s=="TUE"){cout << "5";}else
  if(s=="WED"){cout << "4";}else
  if(s=="THU"){cout << "3";}else
  if(s=="FRI"){cout << "2";}else
  if(s=="SAT"){cout << "1";}
  return 0;
}

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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

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

  CIN(N, T);
  vector< int > a(N);
  REP(i, N) {
    cin >> a[i];
  }
  int mn = a[0];
  int mx = a[1];
  int dist = 0;
  int ans = 0;
  REP(i, N - 1) {
    if (a[i] < mn) {
      if (dist < mx - mn) {
	ans = 1;
	dist = mx - mn;
      } else if (dist == mx - mn) {
	ans++;
      }
      mn = a[i];
      mx = a[i];
    }
    // mn = min(mn, a[i]);
    if (a[i + 1] > mx) {
      mx = a[i + 1];
    }
    // mx = max(mx, a[i + 1]);
    //  debug(mn);
    // debug(mx);
  }

  if (dist < mx - mn) {
    ans = 1;
    dist = mx - mn;
  } else if (dist == mx - mn) {
    ans++;
  }

  cout << ans << endl;
  

  return 0;
}



Measured memory_bytes: 640
x, n = map(int, input().split())
banned = set()
if n:
    banned |= set(map(int, input().split()))
l = x
r = x
while l in banned and r in banned:
    l -= 1
    r += 1

if l not in banned:
    print(l)
elif r not in banned:
    print(r)


Measured memory_bytes: 61632
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<utility>
#include<map>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<ll, ll> P;

#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define all(x) (x).begin(),(x).end()
#define stop char nyaa; cin>>nyaa;

bool isprime(int x) {
	int k = sqrt(x + 0.01);
	rep1(i, k) {
		if (i == 1 || i == x)continue;
		if (x%i == 0)return false;
	}
	return true;

}
void find_prime() {
	int cur = mod + 39651;
	int tmp = 0;
	while (tmp < 3) {
		if (isprime(cur)) {
			cout << cur << endl; tmp++;
		}
		cur++;
	}
}

ll md[3] = { 1000039679,1000039681,1000039723 };

bool used[1 << 17];
struct edge {
	int to; ll cost; int rev;
};
vector<edge> G[1 << 17];
P val[1 << 17][3];


bool same(P a, P b,int id) {
	return (a.first*b.second%md[id] == a.second*b.first%md[id]);
}
void solve() {
	int n, m; cin >> n >> m;

	rep(i, m) {
		int a, b, x; cin >> a >> b >> x;
		a--; b--;
		G[a].push_back({ b,x,0 });
		G[b].push_back({ a,x,1 });
	}
	queue<int> q;
	rep(i, n) {
		if (used[i])continue;
		rep(j, 3) {
			val[i][j] = { 1,1 };
		}
		q.push(i); used[i] = true;
		while (!q.empty()) {
			int id = q.front(); q.pop();
			rep(j, G[id].size()) {
				edge &e = G[id][j];
				P nex[3];
				rep(j, 3) {
					nex[j] = val[id][j];
				}
				if (e.rev) {
					rep(j, 3) {
						nex[j].second = (nex[j].second*e.cost%md[j]);
					}
				}
				else {
					rep(j, 3) {
						nex[j].first = nex[j].first*e.cost%md[j];
					}
				}

				if (used[e.to]) {
					rep(j, 3) {
						if (!same(val[e.to][j], nex[j],j)) {
							cout << "No" << endl; return;
						}
					}
				}
				else {
					used[e.to] = true;
					q.push(e.to);
					rep(j, 3) {
						val[e.to][j] = nex[j];
					}
				}
			}
		}
	}
	cout << "Yes" << endl;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//find_prime();
	solve();
	//stop
		return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int A[101010];
vector<int> R;
set<int> S;
int C[101010];
set<pair<int,int>> cnt;

void dfs(int ng) {
	int x,y;
	if(S.empty()) {
		FORR(r,R) cout<<r+1<<" ";
		cout<<endl;
		exit(0);
	}
	
	if(S.size()==2) {
		x=*S.begin();
		y=*S.rbegin();
		if(A[x]==y && A[y]==x) return;
	}
	
	if(cnt.rbegin()->first==S.size()-1) {
		y=cnt.rbegin()->second;
		if(y!=ng) {
			S.erase(y);
			R.push_back(y);
			cnt.erase({C[y],y});
			if(S.count(A[y])) {
				cnt.erase({C[A[y]],A[y]});
				C[A[y]]--;
				cnt.insert({C[A[y]],A[y]});
			}
			dfs(A[y]);
			if(S.count(A[y])) {
				cnt.erase({C[A[y]],A[y]});
				C[A[y]]++;
				cnt.insert({C[A[y]],A[y]});
			}
			cnt.insert({C[y],y});
			R.pop_back();
			S.insert(y);
		}
	}
	else {
		x=0;
		while(1) {
			auto it=S.lower_bound(x);
			int y=*it;
			if(it==S.end()) return;
			
			if(y!=ng) {
				S.erase(it);
				R.push_back(y);
				cnt.erase({C[y],y});
				if(S.count(A[y])) {
					cnt.erase({C[A[y]],A[y]});
					C[A[y]]--;
					cnt.insert({C[A[y]],A[y]});
				}
				dfs(A[y]);
				if(S.count(A[y])) {
					cnt.erase({C[A[y]],A[y]});
					C[A[y]]++;
					cnt.insert({C[A[y]],A[y]});
				}
				cnt.insert({C[y],y});
				R.pop_back();
				S.insert(y);
			}
			x=y+1;
		}
	}
	
	
	
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	
	FOR(i,N) {
		cin>>A[i];
		A[i]--;
		C[A[i]]++;
		S.insert(i);
	}
	
	FOR(i,N) cnt.insert({C[i],i});
	
	dfs(-1);
	_P("-1\n");
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 17280
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
char x[200];
int main(){
	while( ~ scanf("%s", x + 1) ){
		int n = strlen(x + 1);
		for(int i = 1; i < n; i ++ )
			if(x[i] == 'C') for(int j = i + 1; j <= n; j ++)
				if(x[j] == 'F') { printf("Yes\n"); goto dis1; }
		printf("No\n"); dis1:;
	}
	return 0;
}


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

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

  string s;
  cin >> s;
  int n = s.size();
  bool flag = false;
  if (s[0] != 'A') flag = true;
  else {
    int cnt = 0;
    for (char &c : s) {
      if (c != 'C' && c != 'A') {
        if ('a' <= c && c <= 'z') continue;
        flag = true;
        break;
      }
    }
    if (!flag) {
      for (char &c : s.substr(2, n - 3)) {
        cnt += c == 'C';
      }
      if (cnt != 1) flag = true;
    }
  }
  string ans = flag ? "WA" : "AC";
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int sfc[6];
    int wkSfc[2];
    int cnt;
    
    for(int i=0; i<6; i++){
        cin >> sfc[i];
    }
    
    cin >> cnt;
    
    for(int j=0; j<cnt; j++){
        for(int k=0; k<2; k++){
            cin >> wkSfc[k];
        }
        
        if((wkSfc[0]==sfc[3] && wkSfc[1]==sfc[1])||
           (wkSfc[0]==sfc[4] && wkSfc[1]==sfc[3])||
           (wkSfc[0]==sfc[2] && wkSfc[1]==sfc[4])||
           (wkSfc[0]==sfc[1] && wkSfc[1]==sfc[2])){
    
            cout << sfc[0] << endl;
        
        }else if((wkSfc[0]==sfc[2] && wkSfc[1]==sfc[0])||
           (wkSfc[0]==sfc[5] && wkSfc[1]==sfc[2])||
           (wkSfc[0]==sfc[3] && wkSfc[1]==sfc[5])||
           (wkSfc[0]==sfc[0] && wkSfc[1]==sfc[3])){
        
           cout << sfc[1] << endl;
            
        }else if((wkSfc[0]==sfc[0] && wkSfc[1]==sfc[1])||
           (wkSfc[0]==sfc[1] && wkSfc[1]==sfc[5])||
           (wkSfc[0]==sfc[5] && wkSfc[1]==sfc[4])||
           (wkSfc[0]==sfc[4] && wkSfc[1]==sfc[0])
           ){
        
            cout << sfc[2] << endl;
        
        }else if((wkSfc[0]==sfc[1] && wkSfc[1]==sfc[0])||
           (wkSfc[0]==sfc[5] && wkSfc[1]==sfc[1])||
           (wkSfc[0]==sfc[4] && wkSfc[1]==sfc[5])||
           (wkSfc[0]==sfc[0] && wkSfc[1]==sfc[4])
           ){
        
            cout << sfc[3] << endl;
        
        }else if((wkSfc[0]==sfc[0] && wkSfc[1]==sfc[2])||
           (wkSfc[0]==sfc[2] && wkSfc[1]==sfc[5])||
           (wkSfc[0]==sfc[5] && wkSfc[1]==sfc[3])||
           (wkSfc[0]==sfc[3] && wkSfc[1]==sfc[0])
           ){
        
            cout << sfc[4] << endl;
        
        }else if((wkSfc[0]==sfc[1] && wkSfc[1]==sfc[3])||
           (wkSfc[0]==sfc[3] && wkSfc[1]==sfc[4])||
           (wkSfc[0]==sfc[4] && wkSfc[1]==sfc[2])||
           (wkSfc[0]==sfc[2] && wkSfc[1]==sfc[1])
           ){
        
            cout << sfc[5] << endl;
        
        }
           
    }

}



Measured memory_bytes: 3088
N,K=map(int,input().split())
def Base_10_to_n(N,K):
    X_dumy = N
    out = ''
    while X_dumy>0:
        out = str(X_dumy%K)+out
        X_dumy = int(X_dumy/K)
    return out
print(len(str(Base_10_to_n(N,K))))

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), (ll)0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)

const ll INF = 1e18;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
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; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
#define COUT(x) cout<<x<<"\n"

class Dijkstra{
 private:
  struct edge{
	ll to;
	ll cost;
  };
  vector<vector<edge>> G;
  vector<ll> d;
  ll siz;
 public:
  Dijkstra(ll n){
	  G.resize(n);
	  siz = n;
  }
  void add_edge(ll from,ll to,ll cost){
	  G[from].push_back(edge{to,cost});
  }
  vector<ll> dijkstra(ll s){
	  priority_queue<PLL,vector<PLL>,greater<PLL>> pq;
	  d.assign(siz,INF);
	  d[s] = 0;
	  pq.push(PLL(0,s));
	  while(!pq.empty()){
		  PLL p = pq.top();pq.pop();
		  ll v = p.second;
		  if (d[v] < p.first) continue;
		  for(edge &e:G[v]){
			  if (chmin(d[e.to],d[v]+e.cost)){
				  pq.push(PLL(d[e.to],e.to));
			  }
		  }
	  }
	  return d;
  }
};
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
void Main()
{
  ll n,m,s;
  cin >> n >> m >> s;
  Dijkstra g(2501*n); // u:2500*u+money
  ll u,v,a,b,c,d;
  REP(i,m){
    cin >> u >> v >> a >> b;
    --u;
    --v;
    rep(i,a,2501){
      g.add_edge(2501*u+i,2501*v+i-a,b);
      g.add_edge(2501*v+i,2501*u+i-a,b);
    }
  }
  rep(i,n){
    cin >> c >> d;
    rep(j,2500){
      g.add_edge(2501*i+j,2501*i+min(j+c,(ll)2500),d);
    }
  }
  vector<ll> dist = g.dijkstra(min(s,(ll)2500));
  rep(i,1,n){
    ll ans = INF;
    rep(j,2501){
      chmin(ans,dist[2501*i+j]);
    }
    COUT(ans);
  }

	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 23824
//#include <cstdio>
#include <iostream>

#include <cstring>

#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
//#include <queue>
//#include <stack>
#include <cassert>

using namespace std;

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

#define DEBUG(x) cerr << #x << ": " << x << endl

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;

int N;
string S;

const int INF = 1e9;
int memo[2][10000004];
int go(int n, int flip) {
   assert(n < SZ(S));

   int& res = memo[flip][n];

   if (res < 0) {
      res = INF;

      int d = S[n]-'0';
      if (n == N-1) {
         if (flip)
            d = 10-d;

         // pay exact
         int cur1 = d;

         // pay one denomination up
         int cur2 = 1 + (10-d);

         res = min(cur1, cur2);
      }
      else {
         if (flip)
            d = 9-d;

         // pay exact
         int cur1 = go(n+1, flip) + d;

         // pay one denomination up
         int cur2 = go(n+1, flip^1) + 1 + (9-d);

         // pay one more in current denomination
         int cur3 = go(n+1, flip^1) + (d+1);

         //if (n == 0)
         //   cerr << "cur1:" << cur1 << "  cur2:" << cur2 << "  cur3:" << cur3 << endl;

         res = min(min(cur1, cur2), cur3);
      }
   }

   return res;
}

int main(int argc, char* argv[]) {
   ios_base::sync_with_stdio(false); 
   cin.tie(nullptr);

   cin >> S;
   N = SZ(S);
   
   memset(memo, -1, sizeof(memo));
   int res = go(0, 0);
   cout << res << '\n';

   return 0;
}


Measured memory_bytes: 157596
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define watch(x); cout<<#x<<"="<<x<<endl;
#define watch2(x,y); cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define endl "\n"
#define int long long
using namespace std;        
 
int n,k;
vector<int>adj[200005];
vector<char> color;
vector<int> parent;
int cycle_start, cycle_end;

bool dfs(int v) {
    color[v] = 1;
    for (int u : adj[v]) {
        if (color[u] == 0) {
            parent[u] = v;
            if (dfs(u))
                return true;
        } else if (color[u] == 1) {
            cycle_end = v;
            cycle_start = u;
            return true;
        }
    }
    color[v] = 2;
    return false;
}
vector<int>arr;
void find_cycle() {
    color.assign(n+1, 0);
    parent.assign(n+1, -1);
    cycle_start = -1;

    for (int v = 0; v < n; v++) {
        if (color[v] == 0 && dfs(v))
            break;
    }

    if (cycle_start == -1) {
        cout << "Acyclic" << endl;
    } else {
        vector<int> cycle;
        //cycle.push_back(cycle_start);
        for (int v = cycle_end; v != cycle_start; v = parent[v])
            cycle.push_back(v);
        cycle.push_back(cycle_start);

        reverse(cycle.begin(), cycle.end());
        int cnt=0;
        int i=1;
        int start=cycle[0];
        vector<int>path;
        while(i!=start){
            i=arr[i];
            path.push_back(i);
            cnt++;
        }
        // for(auto it:path)cout<<it<<" ";
        // cout<<endl;
        // watch(cnt);
        // cout << "Cycle found: ";
        // for (int v : cycle)
        //     cout << v << " ";
        // cout << endl;


        if(k<=cnt){
            cout<<path[k-1];
        }
        else{
            k-=cnt;
            int cyclesize=cycle.size();
            //watch(cyclesize);
            //cout<<k<<endl;
            k=(k%cyclesize);
            //cout<<k<<endl;
            cout<<cycle[k];
        }
    }
}

int32_t main(){

    fast
    //int n,k;
    cin>>n>>k;
    arr.resize(n+1);
  

    for(int i=1;i<=n;i++){
        cin>>arr[i];
        adj[i].push_back(arr[i]);
    }
    find_cycle();

    return 0;
}



Measured memory_bytes: 25708
#include<algorithm>
#include<iostream>
#include<cstring>
#include<iomanip>
#include<sstream>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#define rep(i,x,n) for(int i=x;i<=n;i++)
#define per(i,n,x) for(int i=n;i>=x;i--)
#define sz(a) int(a.size())
#define rson mid+1,r,p<<1|1
#define pii pair<int,int>
#define lson l,mid,p<<1
#define ll long long
#define pb push_back
#define mp make_pair
#define se second
#define fi first
using namespace std;
const double eps=1e-8;
const int mod=1e9+7;
const int N=1e5+10;
const int inf=1e9;
string s;
int main(){
	//ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	cin>>s;
	if(s=="ABC") puts("ARC");
	else puts("ABC");
	return 0;
}

Measured memory_bytes: 3588
h,w=map(int,input().split())
m=[]
for i in range(h):
  m.append(list(map(int,input().split())))

ans=[]
for i in range(h-1):
  for j in range(w):
    if m[i][j]%2:
      ans.append(" ".join(map(str,(i+1,j+1,i+2,j+1))))
      m[i+1][j]+=1
for j in range(w-1):
  if m[h-1][j]%2:
    ans.append(" ".join(map(str,(h,j+1,h,j+2))))
    m[h-1][j+1]+=1

print(len(ans))
print("\n".join(ans))

Measured memory_bytes: 91748
INF = 1 << 60

n, m ,p = gets.split.map(&:to_i)
g = []
to = Array.new(n + 1) {[]}
ot = Array.new(n + 1) {[]}
m.times do
  a, b, c = gets.split.map(&:to_i)
  g << [a, b, -(c - p)]
  to[a] << b
  ot[b] << a
end

toflag = [0] * (n + 1)
toflag[1] = 1
iki = ->(v) {
  to[v].each do |u|
    if toflag[u].zero?
      toflag[u] = 1
      iki.(u)
    end
  end
}
iki.(1)

otflag = [0] * (n + 1)
otflag[n] = 1
kaeri = ->(v) {
  ot[v].each do |u|
    if otflag[u].zero?
      otflag[u] = 1
      kaeri.(u)
    end
  end
}
kaeri.(n)

cand = toflag.zip(otflag).map {|a, b| a * b}
max_count = cand.count(1)
g.select! {|a, b, _| cand[a] == 1 && cand[b] == 1}

bellman_ford = ->{
  inf = INF
  d = Array.new(n + 1, inf)
  d[1] = 0
  max_count.times do
    update = false
    g.each do |v, u, cost|
      if d[v] != inf && d[u] > (a = d[v] + cost)
        d[u] = a
        update = true
      end
    end
    return -d[n] unless update
  end
  inf
}
ans = bellman_ford.()

ans = (ans == INF) ? -1 : [ans, 0].max
puts ans

Measured memory_bytes: 14460
#define _USE_MATH_DEFINES
#define INF 100000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;

static const double eps = 1e-8;

bool check(const vector<int>& blocks){
	for(int i=0;i+1<blocks.size();i++){
		if(blocks[i] < blocks[i+1]) return false;
	}
	return true;
}

void dfs(vector<int>& blocks,int n,int remnants){
	if(!check(blocks)) return;
	if(remnants==0){
		for(int i=0;i<blocks.size();i++){
			printf("%s%d",i==0 ? "" : " ",blocks[i]);
		}
		printf("\n");
		return;
	}

	for(int i=remnants;i>=1;i--){
		vector<int> next = blocks;
		next.push_back(i);
		dfs(next,n,remnants-i);
	}
}

int main(){
	int n;
	while(~scanf("%d",&n)){
		vector<int> blocks;
		if(n==0) break;
		dfs(blocks,n,n);
	}
}

Measured memory_bytes: 0
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <iostream>
using namespace std;
int a, b, i, j, k,  n, m;
int str[100005];
int main() {
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &str[i]);
	}
	j = 0; 
	int maxn = 0;
	for (i = 1; i < n; i++) {
		if (str[i] <= str[i - 1]) {
			j++;
		}
		else {
			maxn = maxn > j ? maxn : j;
			j = 0;
		}
	}
	maxn = maxn > j ? maxn : j;
	printf("%d\n", maxn);
	return 0;
}

Measured memory_bytes: 640
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		List<Integer> hitArray = new ArrayList<>(),
					  blowArray = new ArrayList<>();
		
		int hit = 0, blow = 0;
		int[] a = new int[4], b = new int[4];
		while(sc.hasNext()) {
			for(int i = 0; i < 4; i++) {
				a[i] = sc.nextInt();
			}
			for(int i = 0; i < 4; i++) {
				b[i] = sc.nextInt();
			}
			for(int i = 0; i < 4; i++) {
				for(int j = 0; j < 4; j++) {
					if(a[i] == b[j] && i == j)	hit++;
					else if(a[i] == b[j])	blow++;
				}
			}
			
			hitArray.add(hit);
			blowArray.add(blow);
			
			hit = 0;
			blow = 0;
		}
		
		for(int i = 0; i < hitArray.size(); i++) {
			System.out.println(hitArray.get(i) + " " + blowArray.get(i));
		}
	}
}

Measured memory_bytes: 26052
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define write(x) cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N, K;
    cin >> N >> K;
    vector<pair<int, ll>> AB(N);
    rep(i, N) cin >> AB[i].first >> AB[i].second;

    int msb = 0;
    {
        int k = K;
        while (k) {
            k /= 2;
            msb++;
        }
        msb--;
    }

    ll ans = 0;
    rep(i, N) if ((AB[i].first | K) == K) ans += AB[i].second;

    int mask = 0;
    for (int b = 30; b > msb; --b) mask |= 1 << b;
    for (int b = msb; b >= 0; --b) {
        int m = 1 << b;

        if (K & m) {
            ll tmp = 0;
            rep(i, N) {
                if (((AB[i].first | K) & mask) == (K & mask) && (AB[i].first & m) == 0) {
                    tmp += AB[i].second;
                }
            }

            ans = max(ans, tmp);
        }

        mask |= m;
    }

    write(ans);
}

Measured memory_bytes: 1792
class UnionFind():
    def __init__(self, n):
        self.parents = [-1]*n
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    def size(self, x):
        return -self.parents[self.find(x)]

N,M = map(int, input().split())
AB = []
for i in range(M):
    AB.append(list(map(int, input().split())))
S = []
uf = UnionFind(N)
for a,b in AB[::-1]:
    if a < b:
        a,b = b,a
    x = uf.size(a-1)
    y = uf.size(b-1)
    uf.union(a-1,b-1)
    z = uf.size(a-1)
    t = z*(z-1)//2 - x*(x-1)//2 - y*(y-1)//2
    if t < 0:
        S.append(0)
    else:
        S.append(t)

ans = 0
for _ in range(M):
    ans += S.pop()
    print(ans)

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

int main() {
  int d, t, s;
  cin >> d >> t >> s;
  if (d <= t*s) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template <class T, class U>ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >>p.second ;
	return is;
}
template <class T>istream& operator>>(istream& is,  vector<T>& v) {
	rep(i, v.size()) {
		is >> v[i];
	}
	return is;
}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	string s;
	int q=0;
	cin >>s>>q;
	int id;
	char c;
	bool flag = false;
	deque<char> ans;
	rep(i, s.size()) { ans.pb(s[i]); }
	int t;
	rep(i, q) { cin >> id ; 
	if(id==1){
		flag = !flag;
	}else{
		cin >> t>>c;
		if(flag==false xor t==1){
		ans.push_back(c);
		}else{
			ans.push_front(c);
		}
	}
	}
	while(!ans.empty()){
		if(flag==false){
		cout << ans.front();
		ans.pop_front();
		}else{
			cout << ans.back();
			ans.pop_back();
		}
	}
	cout<<endl;
}

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

int main(){
  int n; cin>>n;
  vector<int> even(100001,0),odd(100001,0);
  for(int i=0;i<n;i++){
    int a; cin>>a;
    if(i%2==0){
      even[a]++;
    }else{
      odd[a]++;
    }
  }
  int mi=0,mi2=0,ans=0,ans2=0,f=0;
  for(int i=0;i<100001;i++){
    if(even[mi]<even[i]){
      mi=i;
    }if(odd[mi2]<odd[i]){
      mi2=i;
    }
  }
  if(mi==mi2){
    int si=0,si2=0;
    for(int i=0;i<100001;i++){
      if(even[si]<even[i] && i!=mi){
        si=i;
      }if(odd[si2]<odd[i] && i!=mi2){
        si2=i;
      }
    }
    cout<<n-max(even[mi]+odd[si2],even[si]+odd[mi2])<<endl;
  }else{
    cout<<n-even[mi]-odd[mi2]<<endl;
  }
}


Measured memory_bytes: 1024
N = int(input())

able_flg = False 

for i in range(N) :
    if (N - i * 4) == 0 or ((N - i * 4) > 0 and  (N - i * 4) % 7 == 0) : 
        able_flg = True
        
print("Yes" if able_flg else "No")

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  i64 K;
  cin >> K;

  vvi list_gcd(K+1, vi(K+1,-1));
  rep(i,1,K+1) rep(j,1,K+1){
    list_gcd[i][j] = __gcd(i,j);
  }

  i64 ans = 0;
  rep(i,1,K+1) rep(ii,1,K+1) rep(iii,1,K+1){
    ans += list_gcd[i][list_gcd[ii][iii]];
  }
  cout << ans << endl;
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}

Measured memory_bytes: 3780
a, b ,c= map(int, input().split())
k = int(input())
w = 0
if a >=b:
  while a >=b:
    b = b*2
    w+=1
if b >=c:
  while b >=c:
    c = c*2
    w+=1
if w<=k:
  print('Yes')
else:
  print('No')

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

long long gcd(long x, long y)
{    if (y == 0)
        return x;
    return gcd(y, x % y);}
long long lcm(long x, long y){ return x * y / gcd(x, y);}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}

int count(char b[60][60],int x,int y){
    int ans =0;
    if(b[x-1][y-1]=='#')ans++;
    if(b[x][y-1]=='#')ans++;
    if(b[x+1][y-1]=='#')ans++;
    if(b[x-1][y]=='#')ans++;
    if(b[x+1][y]=='#')ans++;
    if(b[x-1][y+1]=='#')ans++;
    if(b[x][y+1]=='#')ans++;
    if(b[x+1][y+1]=='#')ans++;

    return ans;
}


int main()
{
    int H,W;
    char b[60][60]={},ans[60][60]={};
    cin>>H>>W;

    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            cin>>b[i][j];
        }
    }

    
    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            if(b[i][j]=='#'){
                ans[i][j]='#';
            }else{
                int cnt=count(b,i,j);
                string str = to_string(cnt);
                ans[i][j]=str[0];
            }
        }
    }

    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            cout<<ans[i][j];
        }
        cout<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
//1-indexed
#include<vector>
template<typename T>
struct BIT{
	int n;
	vector<T>bit;
	BIT(int n_=0):n(n_),bit(n_+1){}
	T sum(int i)
	{
		T ans=0;
		for(;i>0;i-=i&-i)ans+=bit[i];
		return ans;
	}
	void add(int i,T a)
	{
		if(i==0)return;
		for(;i<=n;i+=i&-i)bit[i]+=a;
	}
	int lower_bound(T k)//k<=sum(ret)
	{
		if(k<=0)return 0;
		int ret=0,i=1;
		while((i<<1)<=n)i<<=1;
		for(;i;i>>=1)
			if(ret+i<=n&&bit[ret+i]<k)k-=bit[ret+=i];
		return ret+1;
	}
};
string s;
int cnt[26];
bool mov[2<<17];
int now[26];
int idx[26][1<<17],iidx[26];
main()
{
	cin>>s;
	for(int i=0;i<s.size();i++)cnt[s[i]-'a']++;
	int N=s.size();
	string L="",R="",mid="";
	long ans=0;
	if(N%2==0)
	{
		for(int i=0;i<26;i++)
		{
			if(cnt[i]%2)
			{
				cout<<-1<<endl;
				return 0;
			}
		}
		for(int i=0;i<26;i++)now[i]=0;
		for(int i=0;i<N/2;i++)
		{
			mov[i]=++now[s[i]-'a']*2>cnt[s[i]-'a'];
		}
		for(int i=0;i<26;i++)now[i]=0;
		for(int i=N-1;i>=N/2;i--)
		{
			mov[i]=++now[s[i]-'a']*2>cnt[s[i]-'a'];
		}
		string l="",r="";
		for(int i=N/2-1;i>=0;i--)
		{
			if(mov[i])
			{
				l+=s[i];
				ans+=N/2-i-(int)l.size();
			}
		}
		for(int i=0;i<N/2;i++)
		{
			if(!mov[i])L+=s[i];
		}
		for(int i=N/2;i<N;i++)
		{
			if(mov[i])
			{
				r+=s[i];
				ans+=i-N/2-(int)r.size()+1;
			}
		}
		for(int i=N-1;i>=N/2;i--)
		{
			if(!mov[i])R+=s[i];
		}
		ans+=1L*l.size()*r.size();
		L+=r;
		R+=l;
		//cout<<L<<endl<<R<<endl;
	}
	else
	{
		int id=-1;
		for(int i=0;i<26;i++)
		{
			if(cnt[i]%2)
			{
				if(id<0)id=i;
				else
				{
					cout<<-1<<endl;
					return 0;
				}
			}
		}
		mid+=id+'a';
		int I=0,T=(cnt[id]+1)/2;
		while(T>0)
		{
			if(s[I]-'a'==id)T--;
			I++;
		}
		I--;
		cnt[id]--;
		for(int i=0;i<26;i++)now[i]=0;
		for(int i=0;i<I;i++)
		{
			mov[i]=++now[s[i]-'a']*2>cnt[s[i]-'a'];
		}
		for(int i=0;i<26;i++)now[i]=0;
		for(int i=N-1;i>I;i--)
		{
			mov[i]=++now[s[i]-'a']*2>cnt[s[i]-'a'];
		}
		string l="",r="";
		for(int i=I-1;i>=0;i--)
		{
			if(mov[i])
			{
				l+=s[i];
				ans+=I-i-(int)l.size();
			}
		}
		for(int i=0;i<I;i++)
		{
			if(!mov[i])L+=s[i];
		}
		for(int i=I+1;i<N;i++)
		{
			if(mov[i])
			{
				r+=s[i];
				ans+=i-I-(int)r.size();
			}
		}
		for(int i=N-1;i>I;i--)
		{
			if(!mov[i])R+=s[i];
		}
		ans+=1L*l.size()*r.size()+l.size()+r.size();
		L+=r;
		R+=l;
		//cout<<L<<endl<<mid<<endl<<R<<endl;
	}
	BIT<int>P(N/2);
	for(int i=0;i<R.size();i++)
	{
		idx[R[i]-'a'][iidx[R[i]-'a']++]=i;
		P.add(i+1,1);
	}
	for(int i=0;i<26;i++)iidx[i]=0;
	for(int i=0;i<L.size();i++)
	{
		int id=L[i]-'a';
		int t=idx[id][iidx[id]++];
		ans+=P.sum(t);
		P.add(t+1,-1);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 11908
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
int a[maxn], vis[maxn];
int n;
int ans;
int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) 
	{
		scanf("%d", &a[i]);
		++vis[a[i]];
	}
	for(int i = maxn - 1; i >= 1; --i)
		if(vis[i])
		{
			if(vis[i] == 1)
			{
				for(int j = i + i; j < maxn; j += i)
					vis[j] = 0;
			}
			else
				for(int j = i; j < maxn; j += i)
					vis[j] = 0;
		}
	for(int i = 1; i <= n; ++i)
		ans += vis[a[i]];
	cout << ans << endl;
	return 0;
}
		
	 

Measured memory_bytes: 8324
#include<iostream>
#include<map>
#include<algorithm>
using namespace std;
typedef pair < int , int > Pi;
int main(){
  int n;
  Pi a[20];
  cin >> n;
  for(int i = 0 ; i < n ; i++ ){
    cin >> a[i].second >> a[i].first;
  }

  int no = -1, big = -1;
  for(int i = 0 ; i < n ; i++ ){
    if(big < a[i].first) big = a[i].first, no = a[i].second;
    else if(big == a[i].first && no > a[i].second) no = a[i].second;
  }
  cout << no << " " << big << endl;
}

Measured memory_bytes: 1168
N = int(input())
A = list(map(int, input().split()))
B = [0] * N
ans = []
for i in reversed(range(1, N + 1)):
    cnt = 0
    for j in range(i, N + 1, i):
        cnt += B[j - 1]
    if (cnt + A[i - 1]) % 2 == 1:
        B[i - 1] = 1
        ans.append(i)
print(len(ans))
if len(ans) != 0:
    print(*ans)


Measured memory_bytes: 67292
#include "bits/stdc++.h"
#define ed cout<<"\n";
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int

using namespace std;


int main() {
	speed;
	int n, l;
	cin >> n >> l;
	int all = n * (2 * l + n - 1) / 2;
	int lost[200];
	int ans = 10000000;
	int comper = 1000000;
	for (int i = 0; i < n; i++) {
		lost[i] = all - l - i;
		if (comper>abs(l+i)) {
			comper = abs(l + i);
			ans = lost[i];
		}
	}
	cout << ans;
	ed;
	return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long


#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)

const int N=1e5+5;
const int mod=1e9+7;
int32_t main() {
int w,a,b;
cin>>w>>a>>b;
if(a+w==b||b+w==a||(b>=a&&b<=a+w)||(b+w>=a and b+w<=a+w))return cout<<0,0;
cout<<min(abs(b-(a+w)),abs(b+w-a))<<endl;
}

Measured memory_bytes: 256