akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#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++)
using namespace std;


int main(){
  int a, b;
  cin >> a >> b;
  int c = min(a, b) + '0';
  int d = max(a, b);
  char S[d];
  rep(i, 10) S[i] = 0;
  rep(i, d) S[i] = c;
  cout << S << endl;
}


Measured memory_bytes: 3560
def main():
    mod = 10**9+7
    inv_n = [0]*1001
    nCr = [[1]*(i+1) for i in range(1001)]
    for i in range(1001):
        inv_n[i] = pow(i, mod-2, mod)
    for i in range(2, 1001):
        for j in range(1, i):
            nCr[i][j] = (nCr[i-1][j-1]+nCr[i-1][j]) % mod
    n, a, b, c, d = map(int, input().split())
    dp = [0]*(n+1)
    dp[0] = 1

    for A in range(b, a-1, -1):
        dp2 = [i for i in dp]
        for N in range(n-c*A, -1, -1):
            e = dp[N]
            if e:
                temp = 1
                for C in range(1, c):
                    temp = temp*nCr[n-N-(C-1)*A][A]*inv_n[C] % mod
                for C in range(c, min(d, (n-N)//A)+1):
                    temp = temp*nCr[n-N-(C-1)*A][A]*inv_n[C] % mod
                    dp2[N+C*A] = (dp2[N+C*A]+temp*e) % mod
        dp = dp2
    print(dp[-1])


main()


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

typedef long long int ll;

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

    ll ans = 0;
    ans = x / 500;
    ans *= 1000;
    x = x % 500;
    ans += x / 5 * 5;

    cout << ans;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int N;
int a[271728];

char mikisinn[271828];

int main(void) {
	int i, j;
	int guririba = 0;
	int yukana = 0;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 1; i <= N; i++) {
		if (scanf("%d", &a[i]) != 1) return 1;
	}
	for (i = N; i >= 1; i--) {
		int koyasu = 0;
		for (j = i + i; j <= N; j += i) koyasu += mikisinn[j];
		if (koyasu % 2 != a[i]) {
			mikisinn[i] = 1;
			guririba++;
		}
	}
	printf("%d\n", guririba);
	for (i = 1; i <= N; i++) {
		if (mikisinn[i]) {
			if (yukana) putchar(' ');
			printf("%d", i);
			yukana = 1;
		}
	}
	putchar('\n');
	return 0;
}


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

using P = pair<int, int>;
int H, W;
vector<vector<char>> maze;  // 迷路の内容を保存する配列
vector<vector<int>> dist;   // 距離を記録しておく配列

// 幅優先探索
void bfs(vector<P> s) {
    const int INF = 1e8;
    dist.assign(H, vector<int>(W, INF));  // 初期化

    queue<pair<int, int>> que;
    for (auto p : s) {
        que.emplace(p);
        dist[p.first][p.second] = 0;
    }
    while (que.size() != 0) {
        pair<int, int> now = que.front();
        que.pop();
        int dy[4] = {0, 0, 1, -1};  // dx,dy は次の探索場所への距離を表す（４方向分）
        int dx[4] = {1, -1, 0, 0};
        for (int i = 0; i < 4; i++) {
            int ny = now.first + dy[i];
            int nx = now.second + dx[i];
            if (ny < 0 || H <= ny || nx < 0 || W <= nx) continue;
            if (maze[ny][nx] == '#') continue;  // 障害物があればスルー
            if (dist[ny][nx] != INF) continue;
            que.push(make_pair(ny, nx));
            dist[ny][nx] = dist[now.first][now.second] + 1;
        }
    }
}

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

    cin >> H >> W;
    vector<P> s;
    maze.assign(H, vector<char>(W, '.'));  // 初期化
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> maze[i][j];
            if (maze[i][j] == '#') { s.push_back(make_pair(i, j)); }
        }
    }

    bfs(s);
    int ans = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            ans = max(dist[i][j], ans);
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 29032
#include "bits/stdc++.h"
using namespace std;
int main() {
  	int N,ans;
  	cin >> N;
  	
  	if  (N<10){
    cout << N <<endl;
  	    }
	 else  if(10 <=N && N<100){   
  	cout << 9 <<endl;
  	 }
	else  if (100<=N && N<1000){
  	 cout << N-99+9 <<endl;
  	 }
  	 else if (1000<=N && N <10000){
  	 cout << 909 <<endl;
  	 }
  	 else if (10000<=N && N<10e4){
  	 cout <<N-9999+909 << endl;
  	 }
  	 else if (10e4 <= N && N<10e5){
  	     cout << 90909 << endl;
  	 }
  	 else if ( N ==10e5){
  	 cout <<90910 <<endl;
  	 }
  	}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair < int, int >;

vector < vector < int > > g;
vector < bool > visited;
vector < int > d;

void dfs (int u) {
	visited[u] = true;
	d[u] = 0;
	for (int v : g[u]) {
		if (!visited[v]) {
			dfs (v);
		}
		d[u] = max (d[u], 1 + d[v]);
	}
}

int main() {
	int n, m, x, y;
	scanf ("%d %d", &n, &m);
	g.resize (n);
	visited.assign (n, false);
	d.assign (n, 0);
	for (int i = 0; i < m; i++) {
		scanf ("%d%d", &x, &y);
		x--, y--;
		g[x].push_back (y);
	}
	for (int i = 0; i < n; i++) {
		if (!visited[i]) {
			dfs (i);
		}
	}
	int answer = 0;
	for (int i = 0; i < n; i++) {
		answer = max (answer, d[i]);
	}
	printf ("%d\n", answer);
	return 0;
}


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

#define pb push_back
#define mp make_pair

#define fi first
#define se second

typedef long long ll;

using namespace std;
string s;
ll cnt[27];

int main(){
cin >> s;
for(int i=0;i<s.size();i++){
    cnt[s[i] - 'a']++;
}
ll n = s.size();
ll res = (n * 1ll * (n - 1ll)) * 1ll / 2;
for(int i=0;i<26;i++){
    res -= (cnt[i] * 1ll * (cnt[i] - 1ll)) * 1ll / 2;
}
cout << res + 1;
return 0;
}


Measured memory_bytes: 640
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;
import java.lang.Math.*;
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        int r = in.nextInt();
        int c = in.nextInt();
        int mod = 1000000007;
        String [] paht = new String[r];
        for(int i=0;i<r;i++)
            paht[i]= in.next();
        int [][]mark = new int[r][c];
        mark[0][0]=1;
        for(int i=0;i<r;i++){
            for(int j=0;j<c;j++){
                if(i!=0 || j!=0){
                    if (paht[i].charAt(j)!='#'){
                        int v = 0;
                        if(i>0)
                            v= mark[i-1][j];
                        if(j>0)
                            v+=mark[i][j-1];
                        mark[i][j]= v%mod;
                    }
                }

            }
        }
        System.out.println(mark[r-1][c-1]);

    }


}


Measured memory_bytes: 33096
#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(){
 string s;
      int c = 0;
  cin >> s;
  string t = s;
  int a = s.size();
  rep(i,a){
    t[s.size() - i-1] = s[i];
  }
  int counts =0;
  rep(i,a){
   if(s[i] == t[i]) counts++;    
  }
  if(counts != a) cout << "No" << endl;
  else{
    int b = (a-1)/2;

    rep(i,b){
    if(s[i] == t[i+b+1] && s[i+b+1] == t[i]) c++;
    }
  if(c == b) cout << "Yes" << endl;
  else cout << "No" << endl;
  }
}

Measured memory_bytes: 3532
N,X,M=map(int,input().split())
lst=[]
n,s=X,0
for i in range(N):
  if n in lst:break
  lst.append(n)
  n=(n*n)%M
if len(lst)<N:
  k=lst.index(n)
  s1=sum(lst[:k])
  s2=sum(lst[k:])*((N-k)//(len(lst)-k))
  s3=sum(lst[k:k+(N-k)%(len(lst)-k)])
  s=s1+s2+s3
else:s=sum(lst)
print(s)

Measured memory_bytes: 68084
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_lr(i,l,r) for(int i=(l);i<(r);i++)
#define rep_sn(i,s,n) for(int i=(s);i<(s)+(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr int INF = INT_MAX >> 1;
constexpr ll LINF = 5000000000000000LL;
constexpr int MOD = 1000000007;

int main() {
	
	int x, a;
	cin >> x >> a;
	cout << (x < a ? 0 : 10) << endl;

}

Measured memory_bytes: 256
from itertools import product, groupby

N = int(input())

testimony = []
for n in range(1, N + 1):
    a = int(input())
    for _ in range(a):
        x, y = map(int, input().split())
        testimony.append((n, x, y))

ans = []
for pattern in product((1, 0), repeat=N):
    choice_index = tuple(idx + 1 for idx, value in enumerate(pattern) if value == 1)
    choice_answers = [t for t in testimony if t[0] in choice_index]
    groups = []
    for choice_answer in choice_answers:
        person, target, honest_or_kind = choice_answer
        if pattern[target-1] != honest_or_kind:
            break
    else:

        data = sorted(choice_answers, key=lambda z: z[1])
        for k, g in groupby(data, lambda z: z[1]):
            groups.append(list(g))

        for group in groups:
            all_ans = set(tuple(ans[2] for ans in group))
            if len(all_ans) == 2:
                break
        else:
            ans.append(sum(pattern))
print(max(ans))


Measured memory_bytes: 4980
#include<iostream>
using namespace std;
bool run(int n){


  while(n!=0){
  if(n%10==7){
    return true;
  break;}
  n=n/10;
   
  }
  return false;
};
  
  int main(){
   int n;
   cin>>n;
    if(run(n)==true){
      cout<<"Yes";
    }
    else
      cout<<"No";
    return 0;
  }

Measured memory_bytes: 3592
n,x = map(int,input().split())
l = list(map(int,input().split()))
count = 0
d = [0]

for i in range(1,len(l)+1):
    d.append(l[i-1]+d[i-1])

for i in range(len(d)):
    if d[i] <= x:
        count += 1

print(count)


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

int main()
{
	int H, W;
	std::cin >> H >> W;
	std::vector<std::string> result;
	std::vector<int> erase_rows;
	std::string row;
	for (int i = 0; i < H; ++i) {
		std::cin >> row;
		if (row[0] == '.' && std::all_of(row.begin(), row.end(), [&](char c) { return c == row[0]; })) {
			erase_rows.push_back(i);
		}
		result.push_back(row);
	}
	int w = W;
	for (int i = 0; i < w; ) {
		char c = result[0][i];
		bool b = true;
		if (c == '.') {
			for (int j = 1; j < H; ++j) {
				if (c != result[j][i]) {
					b = false;
					break;
				}
			}
		}
		else {
			b = false;
		}
		if (b) {
			for (int j = 0; j < H; ++j) {
				result[j].erase(i, 1);
			}
			--w;
		}
		else {
			++i;
		}
	}
	for (int i = 0; i < H; ++i) {
		if (std::find(erase_rows.begin(), erase_rows.end(), i) != erase_rows.end()) {
			continue;
		}
		auto& row = result[i];
		std::cout << row << std::endl;
	}
	return 0;
}

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

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

typedef long long ll;

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

  int cnt = 0;

  for(int i=0; i<3; i++){
    if(s[i] == t[i]) cnt++;
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>  
using namespace std;  
int main()  
{  
    long long int x,t;  
    cin>>x>>t;  
    if(x-t==0)  
    {  
        cout<<0<<endl;  
    }  
    if(x-t>0)  
    {  
        cout<<x-t<<endl;  
    }  
    if(x-t<0)  
    {  
        cout<<0<<endl;  
    }  
    return 0;  
}  

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
	long long int x;
	long long int num = 0;
	cin >> x;
	num = (x / 11) * 2;
	x = x % 11;
	for(int i = 6; i > 0; i--){
		if(x >= i){
			x -= i;
			num++;
		}
	}
	cout << num << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstring>
#include <map>
#include <set>
#define int long long int
using namespace std;
const int cons = 1000000007;




signed main() {
 
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    #ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    //  freopen("output.txt", "w", stdout);
    #endif
    
    int n, i;
    cin>>n;
    int h[n];
    for(i=0;i<n;i++){
        cin>>h[i];
    }
    int dp[n];
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for(i=2;i<n;i++){
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1792
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)

using ll = long long;

const int INF = 1073741823;
const int MINF = -1073741823;
const ll LINF = ll(4661686018427387903);
const ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

double acot(double x) {
	return PI / 2 - atan(x);
}



/*-----------------------------------------ここからコード-----------------------------------------*/

int main() {

	int n;
	scanf("%d", &n);
	int a;
	ll dp = 0;
	rep(i, n) {
		scanf("%d", &a);
		rep(j, 32) {
			if (a & (1 << j)) {
				dp += j;
				break;
			}
		}
	}
	printf("%lld\n", dp);

	return 0;
}


Measured memory_bytes: 256
a,b,c = map(int, input().split())
A = [a,b,c]
A.sort()

if (((A[2]-A[1])%2==0) and ((A[2]-A[0])%2==0)) or (((A[2]-A[1])%2==1) and ((A[2]-A[0])%2==1)):
    print(int(A[2]-(A[0]+A[1])/2))
else:
    print(int(A[2]-(A[0]+A[1])/2+3/2))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pii pair <int,int>
#define pll pair <ll,ll>
#define testcase() int t; cin>>t; while(t--)
#define forn(i,n) for(int i=0;i<n;i++)

ll M = 1e9 + 7;
ll powerm(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x)%M; y=y>>1; x=(x*x)%M;} return res%M; }
ll power(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x); y=y>>1; x=(x*x);} return res; }
ll max3(ll a,ll b,ll c){ return max( max(a,b),c ); }
ll gcd(ll a,ll b){if(b>a)return gcd(b,a); if(b==0)return a; return gcd(b,a%b);}

int main() {
	
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	double pi = acos(-1.0);
	double a,b,h,m; cin>>a>>b>>h>>m;
	double theta = 30.0*h - 5.5*m;
	if(theta < 0.0) theta = -theta;
	theta = theta*pi/180.0;
	double ans = a*a + b*b - 2*a*b*cos(theta);
	ans = sqrt(ans);
	cout<<fixed<<setprecision(15)<<ans;
	
	
	return 0;
}


Measured memory_bytes: 4264
s = input()
for_l = [0] * (len(s) + 1)
for_r = [0] * (len(s) + 1)
l = [0] * (len(s) + 1)
for i in range(1, len(for_l)):
    if s[i - 1] == "<":
        for_l[i] = for_l[i - 1] + 1
for i in range(1, len(for_l)):
    if s[-i] == ">":
        for_r[-i-1] = for_r[-i] + 1
for i in range(len(for_l)):
    l[i] = max(for_l[i], for_r[i])
print(sum(l))

Measured memory_bytes: 31156
#include <stdio.h>
#include <string.h>
char* myfgets(char *buf,int n,FILE *fp){ //accepts LF/CRLF
	char *ret=fgets(buf,n,fp);
	if(!ret)return NULL;
	if(strlen(buf)&&buf[strlen(buf)-1]=='\n')buf[strlen(buf)-1]=0;
	if(strlen(buf)&&buf[strlen(buf)-1]=='\r')buf[strlen(buf)-1]=0;
	return ret;
}

char Q[99999];
char *q[99];
char L[99999];
int ind[99];
int n;
dfs(depth){
	int cur_ind=0;
	if(!myfgets(L,sizeof(L),stdin)){puts("no such property");exit(0);}
	if(depth){
		for(;L[cur_ind]==' ';cur_ind++);
		if(ind[depth-1]>=cur_ind){puts("no such property");exit(0);}
	}
	char *name=strtok(L+cur_ind,":"),*value=name+strlen(name)+1;
	if(!strcmp(name,q[depth])){
		if(depth==n-1){
			if(*value)
				printf("string \"%s\"\n",value+1),exit(0);
			else
				puts("object"),exit(0);
		}
		ind[depth]=cur_ind;
		dfs(depth+1);
	}
	dfs(depth);
}

main(depth){
	myfgets(Q,sizeof(Q),stdin);
	q[0]=strtok(Q+1,".");
	for(n=1;;n++)if(!(q[n]=strtok(NULL,".")))break;
	dfs(0);
}

Measured memory_bytes: 584
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

	int Q;
	int[] l,r;
	boolean[] primes;

	private void solve(){
		Q = nextInt();

		l = new int[Q];
		r = new int[Q];
		for(int i = 0;i < Q;i++) {
			l[i] = nextInt();
			r[i] = nextInt();
		}

		primes = new boolean[100000 + 10];
		for(int i = 2;i <= 100000;i++) {
			boolean flag = true;
			for(int j = 2;j * j <= i;j++) {
				if (i % j == 0) {
					flag = false;
					break;
				}
			}

			if (flag) {
				primes[i] = true;
			}
		}


		int[] primeSum = new int[100000 + 10];
		for(int i = 0;i < 100000 + 1;i++) {
			if (primes[i] && primes[i + 1 >> 1]) {
				primeSum[i]++;
			}
		}

		for(int i = 0;i < 100000 + 1;i++) {
			primeSum[i + 1] += primeSum[i];
		}

		for(int i = 0;i < Q;i++) {
			out.println(primeSum[r[i]] - primeSum[l[i]-1]);
		}
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	private boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	private String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

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

	private long nextLong() {
		return Long.parseLong(next());
	}

	private double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 44528
#include <bits/stdc++.h>
using namespace std;
typedef pair <int,int> pii;

inline int rd(int x=0) {return cin>>x,x;}
const int N=1e5+50;
int n,a[N];
vector <pii> vec1;
vector <pii> vec2;

int main() {
	n=rd();
	for(int i=1;i<=n;i++) a[i]=rd();
	map <int,int> s; int c=0;
	for(int i=1;i<=n;i+=2) ++s[a[i]], ++c;;
	for(auto it:s) vec1.push_back(pii(c-it.second,it.first));
	s.clear(); c=0;
	for(int i=2;i<=n;i+=2) ++s[a[i]], ++c;
	for(auto it:s) vec2.push_back(pii(c-it.second,it.first));
	sort(vec1.begin(),vec1.end());
	sort(vec2.begin(),vec2.end());
	if(vec1.begin()->second!=vec2.begin()->second) cout<<vec1.begin()->first+vec2.begin()->first;
	else {
		int ans=0x3f3f3f3f;
		int val=(vec1.size()<2) ? (n+1)/2 : vec1[1].first;
		ans=min(ans,val+vec2.begin()->first);
		val=(vec2.size()<2) ? n/2 : vec2[1].first;
		ans=min(ans,val+vec1.begin()->first);
		cout<<ans<<'\n';
	}
}

Measured memory_bytes: 4088
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;
const long double EPS = 0.00000001;

long long int N, M, K, W, H, L, R;
long long int ans;

int main() {
	ios::sync_with_stdio(false);
	string s, t;
	cin >> s;
	for (auto i : s)t = i + t;
	if (s == t)cout << "Yes\n";
	else cout << "No\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
using namespace std;
typedef long long LL;
 
int main() {
	int t, i, j, k;
	int a, b, c ,F=0;
	
	cin >> a >> b;
 
	F = (a - 1)*(b - 1);
 
	cout << F << endl;
	return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

type Graph<T> = Vec<Vec<T>>;

struct Solver {
    visited: Vec<bool>,
    cnt: usize,
}

impl Solver {
    fn dfs(&mut self, i: usize, g: &Graph<usize>) {
        if self.visited[i] {
            return;
        }
        self.visited[i] = true;
        self.cnt += 1;
        for &n in &g[i] {
            self.dfs(n, &g);
        }
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let N: usize = sc.get();
    let M: usize = sc.get();
    let mut adj = vec![Vec::new(); N];
    for _ in 0..M {
        let A: usize = sc.get();
        let B: usize = sc.get();
        adj[A-1].push(B-1);
        adj[B-1].push(A-1);
    }
    let mut s = Solver { visited: vec![false; N], cnt: 0 };
    let mut ans = 1;
    for i in 0..N {
        let before = s.cnt;
        s.dfs(i, &adj);
        let after = s.cnt;
        ans = max(ans, after-before);
    }
    println!("{}", ans);
}


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

ll INF=1000000000000000;
ll mod=1000000007;

ll i,j,k;

int main(){
    ll x,ans=0;cin>>x;
    ll num=100;
    while(num<x){
        num=(ll)(num*1.01);
        ans++;
    }
    
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3632
fn main() {
    proconio::input! {
        n: usize,
        k: usize,
        mut a_s: [i64; n],
    }
    const M: i64 = 1_000_000_007;
    a_s.sort();
    a_s.reverse();
    let negs = a_s
        .iter()
        .filter(|a| **a < 0)
        .map(|a| *a)
        .collect::<Vec<_>>();
    let poss = a_s
        .iter()
        .filter(|a| **a > 0)
        .map(|a| *a)
        .collect::<Vec<_>>();
    let mut ans = 1;
    if n == k {
        for a in a_s {
            ans *= a;
            ans %= M;
        }
        ans += M;
        ans %= M;
    } else if n == negs.len() && k % 2 == 1 {
        for neg in negs.iter().take(k) {
            ans *= neg;
            ans %= M;
        }
        ans += M;
        ans %= M;
    } else if poss.len() == 0 && k % 2 == 1 {
        ans = 0;
    } else if poss.len() + negs.len() / 2 * 2 < k {
        ans = 0;
    } else {
        let mut negs = negs;
        negs.reverse();
        let mut inegs = 0;
        let mut iposs = 0;
        if k % 2 == 1 {
            ans *= poss[iposs];
            ans %= M;
            iposs += 1;
        }
        while iposs + inegs != k {
            let neg2 = if inegs + 1 < negs.len() {
                negs[inegs] * negs[inegs + 1]
            } else {
                0
            };
            let pos2 = if iposs + 1 < poss.len() {
                poss[iposs] * poss[iposs + 1]
            } else {
                0
            };
            if neg2 >= pos2 {
                assert!(neg2 != 0);
                ans *= negs[inegs];
                ans %= M;
                ans *= negs[inegs + 1];
                ans %= M;
                inegs += 2;
            } else {
                assert!(pos2 != 0);
                ans *= poss[iposs];
                ans %= M;
                ans *= poss[iposs + 1];
                ans %= M;
                iposs += 2;
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 8056
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

a, b = na()

if a <= 5:
    print(0)
elif a <= 12:
    print(b//2)
else:
    print(b)


Measured memory_bytes: 2940
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<set>
#include<map>
#define ll long long 
#define N 1005
using namespace std;
const int maxn =10000000;

typedef pair<int, int> p;   

string str[N];   //表示迷宫的字符出

int h,w,n;
int sx,sy,ex,ey;  //起始和终点坐标 
int dir[4][2]={0,1,1,0,-1,0,0,-1};  //方向 
int d[N][N];  //到达各个点的最短距离的坐标 
struct node
{
	int x,y;
};
vector<node> ve;
int bfs()
{
	queue<p> que;
	int i,j;
	for(i=0;i<h;i++)
	{
		for(j=0;j<w;j++)
		{
			d[i][j]=-1;
		}
	}
	que.push(p(sx,sy));
	d[sx][sy]=0;
	while(que.size())
	{
		p temp=que.front();
		que.pop();
		if(temp.first==ex&&temp.second==ey)
		break;
		for(i=0;i<4;i++)
		{
			int dx=temp.first+dir[i][0];
			int dy=temp.second+dir[i][1];
			if(dx>=0&&dy>=0&&dx<h&&dy<w&&str[dx][dy]!='X'&&d[dx][dy]==-1)
			{
				que.push(p(dx,dy));
				d[dx][dy]=d[temp.first][temp.second]+1;
				if(dx==ex&&dy==ey)
				return d[dx][dy];
			} 
		}
	}
} 
void find(char x,char y)
{
	int i,j;
	for(i=0;i<h;i++)
	{
		for(j=0;j<w;j++)
		{
			if(str[i][j]==x)
			{
				sx=i;
				sy=j;
			}
			if(str[i][j]==y)
			{
				ex=i;
				ey=j;
			}
		}
	}
}
int main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);//让cin，cout变得快一点
	cin>>h>>w>>n;
	int i,j;
	int ans=0;
	for(i=0;i<h;i++)
	{
		cin>>str[i];
	}
	for(i=0;i<n;i++)
	{
		if(i==0)
		{
			find('S','1');
			ans+=bfs();
		}
		else
		{
			char x='0'+i;
			char y='0'+i+1;
			find(x,y);
			ans+=bfs();
		}
	}
	cout<<ans<<endl;
	return 0;   
}


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

const int N = (int)  1e5 + 5;

int n, k, q;
int a[N];

int main() {
	cin >> n >> k >> q;
	for (int i = 1; i <= n; i++) a[i] = k, a[i] -= q;
	for (int i = 1; i <= q; i++) {
		int idx; cin >> idx;
		a[idx]++;
	}
	for (int i = 1; i <= n; i++)
		if (a[i] >= 1) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{

    int k,l,c=0,x,s=0,t,m,n;
    cin>>m>>n>>k;
    int a[k+10];
    //memset(a,0,sizeof(a));
    map<int,int>s1;

    for(int i = 0; i < k; i++)
    {
        cin>>x;
        s1[x-1]++;
    }
    for(int i = 0; i < m; i++)
    {
        t = s1[i]+n-k;

        if(t <= 0)
        {
            cout<<"No\n";
        }
        else{
            cout<<"Yes\n";
        }
    }

}





Measured memory_bytes: 5376
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
template<class Type> void line(const Type &a){int cnt=0;for(auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	int yen[]={0,300000,200000,100000};
	
	int x,y;
	cin>>x>>y;
	if(x>3) x=0;
	if(y>3) y=0;
	
	int ans=yen[x]+yen[y];
	if(x==1 and y==1) ans+=400000;
	
	cout<<ans<<endl;
}


Measured memory_bytes: 256
import itertools

N, x = map(int, input().split())
a = list(map(int, input().split()))

a.sort()
a = list(itertools.accumulate(a))

cnt = 0

for i in range(len(a)):
    if x > a[i]:
        if i == len(a)-1:
            break
        cnt += 1
    elif x == a[i]:
        cnt += 1
        break
    else:
        break

print(cnt)

Measured memory_bytes: 9148
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] sa = br.readLine().split(" ");
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sa[i]);
		}
		br.close();

		int x = 0;
		for (int i = 0; i < n; i++) {
			x ^= a[i];
		}

		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < n; i++) {
			sb.append(x ^ a[i]).append(' ');
		}
		sb.deleteCharAt(sb.length() - 1);
		System.out.println(sb.toString());
	}
}


Measured memory_bytes: 61308
import java.util.*;

class Main {
        public static void main(String args[]) {
                Scanner sc = new Scanner(System.in);
                int N = sc.nextInt(), L = sc.nextInt();
                int[] A = new int[N];
                boolean possibleflag = false;
                int idx = 0;
                for (int i = 0; i < N; i++) {
                        A[i] = Integer.parseInt(sc.next());
                        if (i != 0) {
                                if (A[i] + A[i-1] >= L) {
                                        possibleflag = true;
                                        idx = i - 1;
                                        break;
                                }
                        }
                }
                if (!possibleflag) {
                        System.out.println("Impossible");
                        return;
                }
                StringBuilder str = new StringBuilder();
                str.append("Possible\n");
                for (int i = 0; i < idx; i++) {
                        str.append(i + 1 + "\n");
                }
                for (int i = N - 2; i >= idx; i--) {
                        str.append(i + 1 + "\n");
                }
                System.out.print(str);
        }
}

Measured memory_bytes: 25688
N,K = map(int,input().split())
h = list(map(int,input().split()))
INF = 10**10

dp = [INF]*N
dp[0] = 0

for i,hi in enumerate(h):
    if i == 0:
        continue
    s = i-K if i-K >= 0 else 0
    dp[i] = min([dpk + abs(hi-hk) for dpk,hk in zip(dp[s:i],h[s:i])])

print(dp[-1])

Measured memory_bytes: 13976
#include<stdio.h>

int a[105];

int main()
{
    int K,n,i,p=0,mx,mp;
    scanf("%d %d", &K, &n);
    for(i=1;i<=n;i++){
        scanf("%d", &a[i]);
    }
    while(K--){
        mx=0;
        for(i=1;i<=n;i++){
            if(i==p)continue;
            if(a[i])break;
        }
        if(i==n+1)break;
        for(i=1;i<=n;i++){
            if(i==p)continue;
            if(a[i]>mx)mx=a[i],mp=i;
        }
        a[mp]--;
        p=mp;
    }
    printf("%d", a[p]);
    return 0;
}


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

using namespace std;

const int MAXN=100000+100;
int dp[MAXN][8],joy[MAXN][8]; 
int n;

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=3;j++){
			scanf("%d",&joy[i][j]);
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=3;j++){
			for(int k=1;k<=3;k++){
				if(k==j) continue;
				dp[i][j]=max(dp[i][j],dp[i-1][k]+joy[i][j]);
			}
		}
	}
	printf("%d\n",max(dp[n][1],max(dp[n][2],dp[n][3])));
	return 0;
}
 

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
int i,ls,j;
char s[101];
int main()
{
	cin>>s;
	ls=strlen(s);
	for(i=0;i<ls;i++)
		if(s[i]=='C')
			for(j=i+1;j<ls;j++)
				if(s[j]=='F')
				{
					cout<<"Yes"<<endl;
					return 0;
				}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define ARR(array) for(int i=0;i<array.size();i++)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 100000007
#define SIZE 10005
#define PI 	3.14159265358979323846

unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

char input(){
  char a;
  cin >> a;
  return a;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin >> n >> m;
    ll ans=0,roop=0;
    ll a0=0;
    FOR(i,1,n+1){
      ll a1;
      cin >> a1;
      if(a1-a0<=m){
        roop+=a1-a0;
        if(i==n)ans += roop;
      }
      else {
        ans += roop+m;
        roop=0;
      }
      a0 = a1;
    }
    cout << ans+m << endl;
}

Measured memory_bytes: 256
/********************************
*MAHBUBCSEJU                    *
*CSE 22                         *
*JAHANGIRNAGAR UNIVERSITY       *
*TIMUS:164273FU                 *
*UVA>>LIGHTOJ>>HUST:mahbubcseju */
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d\n",a)
#define PL(a) printf("%lld\n",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())
//#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M) {
    ll ret = 1;
    for(; e > 0; e >>= 1) {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b) {
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M) {
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e) {
    ll ret = 1;
    for(; e > 0; e >>= 1) {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
template <class T>string NTS ( T Number ) {
    stringstream ss;
    ss << Number;
    return ss.str();
}
template <class T>T stringtonumber ( const string &Text ) {
    istringstream ss(Text);
    T result;
    return ss >> result ? result : 0;
}
template <class T>bool ISLEFT ( T a,T b,T c) {
    if(((a.xx-b.xx)*(b.yy-c.yy)-(b.xx-c.xx)*(a.yy-b.yy))<0.0)return 1;//Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
#define mx 10000
#define md 1000000007
#define maxp 2050180000

typedef pair<int ,int > P;

////////define value/////
int main()
{

  ll n,m;
  L2(n,m);
  ll res=0;
  ll x=n-m;
  res+=x;
  res+=m;
  n=x;

  while(n&&m)
  {

     // if(n>m)swap(n,m);
    res+=(m/n)*n*2;
      m=m%n;
    swap(n,m);
   // cout<<n<<m<<endl;
   // res+=n;

  }
  if(n)res-=n;
  if(m)res-=m;
  PL(res);


    return 0;
}


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

int main(){
  int s, a=0;
  cin >> s;
  a += s % 10;
  s = s / 10;
  a += s % 10;
  s = s / 10;
  a += s % 10;
  s = s / 10;
  cout << a << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <chrono>
#include <random>
#include <time.h>
#include <cstdio>
#include <list>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define vec vector<int>
#define vecll vector<ll>
#define vecstr vector<string>
#define vecch vector<char>
#define vecpii vector<pii>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
string strin(){string s;cin>>s;return s;}
char chin(){char c;cin>>c;return c;}
ll lin() {ll x;scanf("%lld",&x);return x;}


int main(){
    string s=strin();
    int n=s.length();
    int cnt1=0,cnt2=0;
    rep(i,n){
        if(i%2==0){
            if(s.at(i)=='0'){
                cnt1++;
            }else{
                cnt2++;
            }
        }else{
            if(s.at(i)=='1'){
                cnt1++;
            }else{
                cnt2++;
            }
        }
    }
    cout<<min(cnt1,cnt2)<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <set>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cstring>
#include <cstdio>
#include <map>
  
using namespace std; 
  
int main() 
{ 
    int n;

    scanf("%d", &n);
    
    int odd = n / 2;

    if(n % 2 == 1)
	 odd++;

    cout << fixed << (double)odd/n << endl;
    return 0; 
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    int N, cnt;
    int[] A;
    boolean[] S;

    long gcd(long x, long y){
        long r, t;
        if ( x < y ) { t = x; x = y; y = t; }
        while( y > 0 ){
            r = x % y;
            x = y;
            y = r;
        }
        return x;
    }
    long lcm(long x, long y){
        return x/gcd(x, y)*y;
    }

    void rec(int p, long LCM, int sum){
        boolean ok;
        if ( p == N ){
            ok = (sum > 0);
            for ( int i = 0; i < N; i++ ){
                if ( LCM >= A[i] && LCM % A[i] == 0 ){
                    if ( S[i] == false ) ok = false;
                }
            }
            if ( ok ) cnt++;
            return;
        }
        S[p] = true;
        rec(p+1, lcm(LCM, A[p]), sum+1);
        S[p] = false;
        rec(p+1, LCM, sum);
    }

    void solve(){
        Scanner sc = new Scanner(System.in);
        A = new int[20];
        S = new boolean[20];
        N = sc.nextInt();
        for ( int i = 0; i < N; i++ ) A[i] = sc.nextInt();
        cnt = 0;
        rec(0, 1, 0);
        System.out.println(cnt);
    }

    public static void main(String[] args){
        new Main().solve();
    }
}




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

#define INF INT_MAX/2;
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long ;

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

   int N;
   cin>>N;
   vector<ll>A(N),B(N),C(N);
   for(int i=0;i<N;i++)cin>>A[i];
   for(int i=0;i<N;i++)cin>>B[i];
   for(int i=0;i<N;i++)cin>>C[i];
   vector<ll>ans(N,0);
   sort(A.begin(),A.end());
   sort(B.begin(),B.end());
   sort(C.begin(),C.end());
   for(int i=0;i<N;i++){
      ans[i] = lower_bound(A.begin(),A.end(),B[i])-A.begin();
   }
   for(int i=0;i<N;i++){
      int a =  N-(upper_bound(C.begin(),C.end(),B[i])-C.begin());
      a = max(a,0);
      ans[i] *= a;
   }
   ll res = 0;
   for(int i=0;i<N;i++)res+=ans[i];
   cout<<res<<endl;
   return 0; 
}


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

// 
int main() {
    int N;
    cin >> N;
    int A[N];
    for (int i = 0; i < N; i++) cin >> A[i];

    // 最初の購入ポイントを確認
    int firstBuyPoint = N;
    int nextUp = A[N - 1];
    for (int i = N - 1; i >= 0; i--) {
        if (A[i] < nextUp) {
            firstBuyPoint = i;
            nextUp = A[i];
        } else if (A[i] > nextUp) {
            nextUp = A[i];
        }
    }

    // cout << firstBuyPoint << endl;  // debug
    // cout << nextUp << endl;  // debug

    // 購入ポイントがないなら終了
    if (firstBuyPoint == N) {
        cout << 1000;
        return 0;
    }

    long long haveSuryo = 1000 / A[firstBuyPoint];
    long long haveMoney = 1000 - A[firstBuyPoint] * haveSuryo;
    int havePrice = A[firstBuyPoint];  // 購入単価
    int nextBuyPoint = 0;
    for (int i = firstBuyPoint + 1; i < N; i++) {
        if (i <= nextBuyPoint) {
            continue;
        }

        // 売るタイミング調整
        if (havePrice < A[i]) {
            haveMoney += A[i] * haveSuryo;
            haveSuryo = 0;
            havePrice = 0;
        }

        // 買うタイミング調整
        if (haveSuryo == 0) {
            int nowPrice = A[i];
            int nowPoint = i;
            for (int j = i + 1; j < N; j++) {
                if (nowPrice < A[j]) {
                    nextBuyPoint = nowPoint;

                    //　購入処理
                    haveSuryo = haveMoney / A[nowPoint];
                    haveMoney -= A[nowPoint] * haveSuryo;
                    havePrice = A[nowPoint];
                    break;
                }

                if (A[j] < nowPrice) {
                    nowPrice = A[j];
                    nowPoint = j;
                }
            }
        }
    }
    cout << haveMoney;
 }


Measured memory_bytes: 3652
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    double L; cin >> L;
    cout << setprecision(12) << pow(L / 3.0, 3.0) << endl;
}


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

int main(void) {
	int N; cin >> N;
	string S; cin >> S;
	bool Ans = true;
	if (N %2 != 0) {
		Ans = false;
	}
	for (int i = 0; i < N / 2; i++) {
		if (S[i] != S[i + (N / 2)]) {
			Ans = false;
		}
	}
	if (Ans == true) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include <string.h>
#include <algorithm>
using namespace std;

int main()
{
    int a[4]= {},b[4]={},c,d;
    for(int i = 0; i < 4; i++)
    {
        cin >> a[i];
        if(a[i] == 1)
        {
            b[0]++;
        }
        else if (a[i] == 4)
        {
            b[1]++;
        }
        else if (a[i] == 7)
        {
            b[2]++;
        }
        else if (a[i] == 9)
        {
            b[3]++;
        }        
    }
    
    for(int i = 0; i < 4; i++)
    {
        if(b[i] != 1)
        {
            cout << "NO" << endl;
            break;
        }
        if(i == 3)
        {
            cout << "YES" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var N, W int
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d %d", &N, &W)

	ws := make([]int, N+1)
	vs := make([]int, N+1)
	for i := 1; i < N+1; i++ {
		scanner.Scan()
		fmt.Sscanf(scanner.Text(), "%d %d", &ws[i], &vs[i])
	}

	vlim := 0
	for _, v := range vs {
		vlim = vlim + v
	}

	var dp [][]int
	dp = make([][]int, N+1)
	for i := 0; i < len(dp); i++ {
		dp[i] = make([]int, vlim+1)
	}

	for v := 0; v < vlim+1; v++ {
		dp[1][v] = math.MaxInt64 / 2
	}
	dp[1][0] = 0
	dp[1][vs[1]] = ws[1]

	for i := 2; i < N+1; i++ {
		for v := 0; v < vlim+1; v++ {
			if v >= vs[i] {
				dp[i][v] = min(
					dp[i-1][v],
					dp[i-1][v-vs[i]]+ws[i],
				)
			} else {
				dp[i][v] = dp[i-1][v]
			}
		}
	}

	/*
		for i := 1; i < N+1; i++ {
			for v := 0; v < vlim+1; v++ {
				if dp[i][v] != math.MaxInt64/2 {
					fmt.Print(dp[i][v], "\t")
				} else {
					fmt.Print("_\t")
				}

			}
			fmt.Println()
		}
	*/

	for v := vlim; v >= 0; v-- {
		if dp[N][v] <= W {
			fmt.Println(v)
			break
		}
	}
}

func min(ns ...int) int {
	ret := math.MaxInt64
	for _, n := range ns {
		if n < ret {
			ret = n
		}
	}
	return ret
}


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

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


Measured memory_bytes: 256
n=int(input())
s=[str(x) for x in input()]

error=0
for i in range(n-2):
    for j in range(i+1,(n+i+1)//2):
        k=2*j-i
        if s[i]!=s[j] and s[j]!=s[k] and s[k]!=s[i]:
            error += 1
r=s.count('R')
g=s.count('G')
b=s.count('B')
print(r*g*b-error)

Measured memory_bytes: 9216