akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	Scanner in = new Scanner(System.in);

	int N, M;
	int[][] edge;
	
	int INF = 100000000;
	
	class Island implements Comparable<Island> {
		int sink, id;
		Island(int id, int sink) {
			this.id = id;
			this.sink = sink;
		}
		
		public int compareTo(Island island) {
			int c1 = sink, c2 = island.sink;
			return c2 - c1;
		}
	}
	
	class Edge implements Comparable<Edge> {
		int x, y;
		Edge(int x, int y) {
			this.x = x;
			this.y = y;
		}
		
		public int compareTo(Edge e) {
			int c1 = edge[x][y], c2 = edge[e.x][e.y];
			return c1 - c2;
		}
	}
	
	UnionFindTree uft;
	ArrayList<Integer> iList = new ArrayList<Integer>();
	long res = 0;
	
	void prim() {
		PriorityQueue<Edge> pq = new PriorityQueue<Edge>();
		for (int i = 0; i < iList.size(); i++) {
			for (int j = i+1; j < iList.size(); j++) {
				int x = iList.get(i), y = iList.get(j);
				pq.add(new Edge(x, y));
			}
		}
		
		while (!pq.isEmpty()) {
			Edge e = pq.poll();
			if (edge[e.x][e.y] != INF && !uft.same(e.x, e.y)) {
				uft.unite(e.x, e.y);
				res += edge[e.x][e.y];
			}
		}
	}

	class UnionFindTree {
		int[] parent;
		
		public UnionFindTree(int n) {
			parent = new int[n];
			init();
		}
		
		void init() {
			for (int i = 0; i < parent.length; i++)
				parent[i] = i;	
		}
		
		public int find(int x) {
			if (parent[x] == x) return x;
			return parent[x] = find(parent[x]);
		}
		
		public boolean same(int x, int y) {
			return find(x) == find(y);
		}
		
		public void unite(int x, int y) {
			int xx = find(x), yy = find(y);
			if (xx == yy) return;
			parent[xx] = yy;
		}
	}
	
	public void run() {
		while (true) {
			iList.clear();
			N = in.nextInt(); M = in.nextInt();
			if (N == 0) break;
			
			Island[] islands = new Island[N];
			for (int i = 0; i < N; i++) {
				int sink = in.nextInt();
				islands[i] = new Island(i, sink);
			}
			
			edge = new int[N][N];
			for (int i = 0; i < N; i++) Arrays.fill(edge[i], INF);
			
			for (int i = 0; i < M; i++) {
				int a = in.nextInt() - 1, b = in.nextInt() - 1, c = in.nextInt();
				edge[a][b] = edge[b][a] = c;
			}
			
			Arrays.sort(islands);
			
			int idx = 0, sink = -1;
			res = 0;
			uft = new UnionFindTree(N);
			
			while (idx < N) {
				Island il = islands[idx++];
				if (sink != -1 && sink != il.sink) {
					prim();
					for (int i = 1; i < iList.size(); i++) {
						int z = iList.get(0);
						if (!uft.same(z, iList.get(i))) {
							res = 0;
							uft.init();
							break;
						}
					}
				}
				sink = il.sink; iList.add(il.id);
			}
			prim();
			for (int i = 1; i < iList.size(); i++) {
				int z = iList.get(0);
				if (!uft.same(z, iList.get(i))) {
					res = 0;
					uft.init();
					break;
				}
			}
			
			System.out.println(res);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 171632
n=int(input())
c=[0]*100000
count=0

a=list(map(int,input().split()))
for i in range(n):
    c[a[i]-1]+=1
    if c[a[i]-1]>1:
        count+=1

if count%2==1:
    print(n-count-1)
else:
    print(n-count)



Measured memory_bytes: 15164
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

      //整数の入力
      int A = sc.nextInt();

      int B = sc.nextInt();

      //平均を表示
      System.out.print ((A + B + 1) / 2);
    }
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll H, A;

int main(){
    scanf("%lld%lld", &H, &A);
    printf("%lld", (H - 1) / A + 1);
    return 0;
}

Measured memory_bytes: 764
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
r = 0
for i, j in enumerate(a):
    r += b[j - 1]
    if a[i - 1] == a[i] - 1 and i > 0:
        r += c[j - 2]
print(r)


Measured memory_bytes: 3060
#include <stdio.h>


int main(void)
{
  int m, f, r;
  
  while( scanf("%d %d %d", &m, &f, &r), (m+1||f+1||r+1)){
    int num = m + f;
    if( m+1 && f+1 ){
      if( num >= 80 ) puts("A");
      else if( num >= 65 ) puts("B");
      else if( num >= 50 ) puts("C");
      else if( num >= 30 ){
        if( r >= 50 ) puts("C");
        else{         puts("D");}
      }
      else{           puts("F");}
    
    }  
    else{
      puts("F");
    }
  
  
  }
  return 0;

 
}       

Measured memory_bytes: 584
#include<iostream>
using namespace std;
int main(){
	int n,x;

while(true){

	cin>>n>>x;
	if(n==0&&x==0)break;
		int count=0;
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			for(int l=j+1;l<=n;l++){
		//	cout<<i<<" "<<j<<" " <<l<<endl;
				int s=i+j+l;
				if(s==x)count++;
				else if(s>x)break;
			}
		
		}
	
	}
	cout<<count<<endl;
}
 return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>

unsigned long long gcd(unsigned long long a, unsigned long long b) {
    unsigned long long c = 1;
    while (c != 0) {
        c = a % b;
        a = b;
        b = c;
    }
    return a;
}
unsigned long long lcm(unsigned long long a, unsigned long long b) {
    unsigned long long c = gcd(a, b);
    return (double)a * (double)b / (double)c;

}

unsigned long long lcm(std::vector<unsigned long long>& c) {
    unsigned long long t = 1;
    for (auto e : c) {
        t = lcm(t, e);
    }
    return t;
}

int main()
{
    int n;
    std::cin >> n;
    std::vector<double> v;

    for (size_t i = 0; i < n; i++)
    {
        double tmp;
        std::cin >> tmp;
        v.push_back(tmp);
    }

    std::sort(v.begin(), v.end());
    double c = v[0];
    for (auto e : v) {
        c = (c + e) / 2.0;
    }
    std::cout << c << std::endl;
}




Measured memory_bytes: 256
def solve():
  N, M = map(int, input().split())

  K = [0] * M
  for i in range(M):
    s = [int(i) for i in input().split()]
    s.pop(0)
    v = 0
    for j in s: v += 2 ** (j - 1)
    K[i] = v

  P = [int(i) for i in input().split()]

  def check(v):
    for i in range(M):
      f = v & K[i]
      count = bin(f).count('1')
      if P[i] != (count % 2): return False
    return True

  ans = 0
  for i in range(2 ** N):
    if check(i): ans += 1

  return ans

print(solve())


Measured memory_bytes: 3064
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**9)
from collections import deque

class Dinic:
    def __init__(self,n,edges):
        self.n=n
        self.edges=[[] for _ in range(n)]
        self.iter=[0]*n
        self.level=None
        self.graph(edges)
    def graph(self,E):
        edges=self.edges
        for fr,to,cap in E:
            edges[fr].append([to,cap,len(edges[to])])
            edges[to].append([fr,0,len(edges[fr])-1])
    def maxflow(self,source,sink):
        max_flow=0
        while True:
            self.bfs(source)
            if self.level[sink]<0:
                return max_flow
            self.iter=[0]*self.n
            flow=self.dfs(source,sink,float('inf'))
            while flow:
                max_flow+=flow
                flow=self.dfs(source,sink,float('inf'))
    def bfs(self,source):
        edges=self.edges
        level=[-1]*self.n
        level[source]=0
        q=deque([source])
        while q:
            fr=q.popleft()
            for to,cap,_ in edges[fr]:
                if cap>0>level[to]:
                    level[to]=level[fr]+1
                    q.append(to)
        self.level=level
    def dfs(self,source,sink,flow):
        if source==sink:
            return flow
        while self.iter[source]<len(self.edges[source]):
            to,cap,rev=self.edges[source][self.iter[source]]
            if cap>0 and self.level[source]<self.level[to]:
                f=self.dfs(to,sink,min(flow,cap))
                if f:
                    self.edges[source][self.iter[source]][1]-=f
                    self.edges[to][rev][1]+=f
                    return f
            self.iter[source]+=1
        return 0

inf=float('inf')
h,w=map(int,input().split())
Edges=[]
delta=(-1,1,-w,w)
for i in range(h):
    S=tuple(input().strip())
    for j,s in enumerate(S):
        v=i*w+j+1
        if s=='.':
            Edges.append((v,v+h*w,1))
        else:
            Edges.append((v,v+h*w,inf))
            Edges.append((0,v,inf))
        for d in delta:
            if v+d<=0 or v+d>=2*h*w+1:
                continue
            Edges.append((v+h*w,v+d,inf))
for i in range(1,w+1):
    Edges.append((i+h*w,2*h*w+1,inf))
    Edges.append((i+(2*h-1)*w,2*h*w+1,inf))
for i in range(1,h-1):
    Edges.append(((i+h)*w+1,2*h*w+1,inf))
    Edges.append(((i+h+1)*w,2*h*w+1,inf))

dinic=Dinic(2*h*w+2,Edges)
mf=dinic.maxflow(0,2*h*w+1)
print(-1 if mf==inf else mf)

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

int main(){
  int m,f,r,i;
  while(1){
    cin>>m>>f>>r;
    if (m==-1&&f==-1&&r==-1)break;
    else if (m==-1||f==-1)cout<<'F'<<endl;
    else if (m+f>=80)cout<<'A'<<endl;
    else if (m+f>=65)cout<<'B'<<endl;
    else if (m+f>=50||r>=50)cout<<'C'<<endl;
    else if (m+f>=30)cout<<'D'<<endl;
    else cout<<'F'<<endl;
  }
}



Measured memory_bytes: 3084
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>
#include<stack>
#include<iomanip>
#include<sstream>
#include<bitset>

using namespace std;

#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPL(i,a,n) for(ll i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define SORTVG(v) sort(v.begin(),v.end(),greater<>())
#define SORTV(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef tuple<int,int,bool> Tb;
typedef pair<int,int> Pii;
typedef vector<int> Vi;

template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}
template<class T> void YesNo(T& a) {if(a){cout << "Yes" << ENT;}else{cout << "No" << ENT;}}
template<class T> void YESNO(T& a) {if(a){cout << "YES" << ENT;}else{cout << "NO" << ENT;}}

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int atcoder(){
    ll n;
    cin>>n;
    vector<ll> x(n+1),y;
    map<ll,ll> mp;
    REP(i,0,n+1){
        cin>>x[i];
        mp[x[i]]++;
    }
    
    COMinit();
    
    ll check;
    for(auto x : mp){
        if(x.second==2) check=x.first;
    }
    
    REP(i,0,n+1) if(x[i]==check) y.push_back(i);
    ll r=n+y[0]-y[1];
    
    REP(i,0,n+1){
        if(i>r) cout<<COM(n+1,i+1)<<ENT;
        else{
            if(COM(n+1,i+1)-COM(r,i)<0) cout<< COM(n+1,i+1)-COM(r,i)+MOD <<ENT;
            else cout<< COM(n+1,i+1)-COM(r,i) <<ENT;
        }
    }
    
    return 0;
}


signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    atcoder();
    return 0;
}



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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
using ll = long long;

/*
 string -> int : stoi(S);
 int -> string : to_string(N);
 Sのn文字以降をm文字取り出す : S.substr(n,m)

 int: -2,147,483,648 ～ 2,147,483,647 (2×10^9)
 ll: -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 (9×10^18)

*/

int main() {

 ll n,m, count=0, ans=0;

 cin >> n;
 cin >> m ;
 vector<ll> a(m);
 rep(i,m){
   cin >> a[i];
 }

 vector<ll> s(n+1);
 s[0]=1;
 int l=0;
 rep2(i,n){
   if(m!=0&&a[l]==i) {
     s[i]=0;
     l++;
   }
   else if(i==1) s[1]=1;
   else s[i] = (s[i-1]+s[i-2])%1000000007;
 }

 cout << s[n] << endl;
}

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

if len(a)%2==1:
    tmp = [0]
    for i in range((len(a)-1)//2):
        tmp.append((i+1)*2)
        tmp.append((i+1)*2)
    if a == tmp:
        ans = (2**((len(a)-1)//2))%(10**9+7)
    else:
        ans = 0
else:
    tmp = []
    for i in range(len(a)//2):
        tmp.append(2*i+1)
        tmp.append(2*i+1)
    if a == tmp:
        ans = (2**(len(a)//2))%(10**9+7)
    else:
        ans = 0
print(ans)

Measured memory_bytes: 20560
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1000000)

	n := scanInt()
	k := scanInt()

	d := make([]bool, 11)
	for i := 0; i < k; i++ {
		d[scanInt()] = true
	}

	for i := n;; i++ {
		val := i
		f := true
		for val != 0 {
			if d[val%10] {
				f = false
			}
			val /= 10
		}

		if f {
			fmt.Println(i)
			return
		}
	}

}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using namespace std;
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; }
#define INF 1e9
#define PI (acos(-1))
#define mod (int)1e9+7
int main() {
    int X,Y;
    cin>>X>>Y;
    ll sum=0;
    if(X==1)sum+=300000;
    if(Y==1)sum+=300000;
    if(X==2)sum+=200000;
    if(Y==2)sum+=200000;
    if(X==3)sum+=100000;
    if(Y==3)sum+=100000;
    if(X==1&&Y==1)sum+=400000;
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
N = gets.to_i
A = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)
C = gets.split.map(&:to_i)

score = 0
A.each_with_index do |a, idx|
  score += B[a - 1]
  if idx > 0
    if a - A[idx - 1] == 1
      score += C[A[idx - 1] - 1]
    end
  end
end
p score


Measured memory_bytes: 1788
def dist(p, X, Y):
    s = 0
    for x, y in zip(X, Y):
        s += abs(x - y)**p
    return s**(1/p)
N = int(input())
*X, = map(int, input().split())
*Y, = map(int, input().split())
print(dist(1, X, Y))
print(dist(2, X, Y))
print(dist(3, X, Y))
print(max(abs(x - y) for x, y in zip(X, Y)))


Measured memory_bytes: 5644
#include <iostream>
#include <string>
using namespace std;
int main(){
	int h,n,a;
	cin>>h>>n;
	for(int i=1;i<=n;i++){
		cin>>a;
		h=h-a;
		if(h<=0){
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int k=0;
	long long int n=0;
	long long int ans=0;
	cin>>k>>n;
	vector<long long int> v(n);
	vector<long long int> s(n);
	for(int i=0;i<n;i++)
	{
		cin>>v[i];
	}
	s[n-1]=k-v[n-1]+v[0];
	for(int i=0;i<n-1;i++)
	{
		s[i]=v[i+1]-v[i];
	}
	sort(s.begin(),s.end());
	for(int i=0;i<n-1;i++)
	{
		ans+=s[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3328
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;
const int INF= 1e9+5;
typedef long long ll;

int main(){
  int A,B;
  cin>>A>>B;
  if(A==B){
    cout<<"Draw"<<endl;
    return 0;
  }
  if(A==1){
    cout<<"Alice"<<endl;
    return 0;
  }
  if(B==1){
    cout<<"Bob"<<endl;
    return 0;
  }
  if(A>B){
    cout<<"Alice"<<endl;
    return 0;
  }
  if(A<B){
    cout<<"Bob"<<endl;
    return 0;
  }
}

Measured memory_bytes: 256
/*
ID: tohoast1
TASK: gymnastics
LANG: C++
*/
#include <bits/stdc++.h>
#define speedup ios_base::sync_with_stdio(NULL)
#define fin freopen("gymnastics.in", "r", stdin)
#define fout freopen("gymnastics.out", "w", stdout)
#define FILENAME
#define PUBG push_back
#define p_b pop_back
#define mp make_pair
#define fi first
#define se second
#define cls clear
#define INF const int ci = 1e6 + 100
#define K_INF 1e9 + 7
#define time cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
#define MIN_INT -999999999
#define MOD 1000000007
#define d109 1000000000
#define basay break
#define bmbr exit(0)

using namespace std;
typedef long long LL;
typedef long L;
typedef unsigned long long ULL;
typedef unsigned long UL;
typedef string STR;
STR s;
int cnt;

int main() {
    #ifdef FILENAMEs
        fin;
        fout;
    #endif // FILENAME
    cin >> s;
    int x = s.size() - 1;
    for (int i = 0 ; i < s.size() / 2 ; ++ i) {
        if (s[i] == s[x]) {
            cnt ++;
        }
        x --;
    }
    int len = s.size() / 2;
    cout << len - cnt;
    ///time;
    return 0;
}


Measured memory_bytes: 256
def dfs(i,sum1):
    global ss
    #print(i,sum1)
    if i == len(s):
        return sum(list(map(int,sum1.split("+"))))
    return dfs(i + 1, sum1 + s[i]) + dfs(i + 1, sum1 + "+" +s[i])


s = input()
ss = 0
print(dfs(1,s[0]))

Measured memory_bytes: 9096
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }
        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var K = cin.ReadInt;
            var Q = cin.ReadInt;
            var A = cin.ReadIntArray(Q);
            var Ansewer = new int[N];
            for(int i = 0; i < N; i++)
            {
                Ansewer[i] = K - Q;
            }
            for(int i = 0; i < Q; i++)
            {
                Ansewer[A[i] - 1]++;
            }
            for(int i = 0; i < N; i++)
            {
                if (Ansewer[i] > 0) WriteLine("Yes");
                if (Ansewer[i] <= 0) WriteLine("No");
            }
        }

        /*public long C(long n, long r)
        {
            if (r == 0 || r == n) return 1L;
            if (n < r) return 0L;
            long[,] Pascal = new long[n + 1, n + 1];
            Pascal[0, 0] = 1;
            for (long i = 1; i <= n; i++)
            {
                Pascal[i, 0] = 1;
                Pascal[i, i] = 1;
                for (long j = 1; j < n; j++)
                {
                    Pascal[i, j] = Pascal[i - 1, j] + Pascal[i - 1, j - 1];
                }
            }
            return Pascal[n, r];
        }*/

        public class ConsoleInput
        {
            private readonly System.IO.TextReader _stream;
            private char _separator = ' ';
            private Queue<string> inputStream;
            public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
            {
                this._separator = separator;
                this._stream = stream;
                inputStream = new Queue<string>();
            }
            public string Read
            {
                get
                {
                    if (inputStream.Count != 0) return inputStream.Dequeue();
                    string[] tmp = _stream.ReadLine().Split(_separator);
                    for (int i = 0; i < tmp.Length; ++i)
                        inputStream.Enqueue(tmp[i]);
                    return inputStream.Dequeue();
                }
            }
            public string ReadLine { get { return _stream.ReadLine(); } }
            public int ReadInt { get { return int.Parse(Read); } }
            public long ReadLong { get { return long.Parse(Read); } }
            public double ReadDouble { get { return double.Parse(Read); } }
            public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
            public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
            public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        }
    }
}



Measured memory_bytes: 16208
#include<bits/stdc++.h>
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define MOD 1000000007
#define INF 1e9
#define F first
#define S second
#define All(x) (x).begin(),(x).end()
using namespace std;
const double PI = acos(-1);
typedef long long ll;

int main(void){
  string S;
  int N;cin>>N>>S;
  if(N%2!=0){
    cout<<"No"<<endl;
    return 0;
  }

  REP(i,N/2){
    if(S[i]!=S[i+N/2]){
      cout<<"No"<<endl;
      return 0;
    }
  }

  cout<<"Yes"<<endl;
}


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

  //mp.reserve(1024);
  //mp.max_load_factor(0.25);
int main() 
{ 
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll n,m;
	cin>>n>>m;
	if(m==n)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
    return 0; 
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i <n; i++)
#define INF 100000000;


using namespace std;
int main(void){
    string s=" ";
    cin >> s;
    int left = (s[0] -'0')*10 + s[1] -'0';
    int right = (s[2]-'0')*10 + s[3]-'0';
    if(1<=left and left<=12){
        if(1<=right and right<=12){
            cout << "AMBIGUOUS";
            return 0;
        }else{
            cout << "MMYY";
            return 0;
        }
    }else{
        if(1<=right and right<=12){
            cout << "YYMM";
            return 0;
        }else{
            cout << "NA";
            return 0;
        }
    }
    
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)

#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define _repis(i,a,b,s) for(int i=a, i##_len(b); i<i##_len; i+=s)
#define REP(...) _overload3(__VA_ARGS__,_repis,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)

#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))

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

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl
#define POSS(n) cout<<((n)?"POSSIBLE":"IMPOSSIBLE")<<endl



int main(){
    string n;
    cin>>n;
    int wa=0;
    bool f=true;
    REPARR(i,n){
        if(i==0){
            if(n[i]!='1')f=false;
        }else{
            if(n[i]!='0')f=false;
        }
        wa+=n[i]-'0';
    }
    if(f)cout<<10<<endl;
    else cout<<wa<<endl;
    return 0;
}

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

vector<int> com;
int ans;
int ABC[3];
int N;
vector<int> l;


void solve(){
    int abc[4] = {0, 0, 0};
    int cnt[4] = {0, 0, 0};
    for(int i=0; i<N; i++){
        abc[com[i]] += l[i];
        cnt[com[i]]++;
    }
    for(int i=0; i<3; i++)
        if(cnt[i] == 0)
            return;

    int ret = 10*(cnt[0]+cnt[1]+cnt[2]-3);
    for(int i=0; i<3; i++){
        ret += abs(abc[i]-ABC[i]);
    }
    ans = min(ans, ret);
}

void dfs(int i, int j){
    if(i == N){
        solve();
        return;
    }

    com[i] = j;
    for(int k=0; k<4; k++)
        dfs(i+1, k);
}

int main(){
    cin >> N >> ABC[0] >> ABC[1] >> ABC[2];
    l.resize(N);
    for(int i=0; i<N; i++)
        cin >> l[i];

    com.resize(N);

    ans = 1<<30;
    for(int i=0; i<4; i++){
        dfs(0, i);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int_fast64_t;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
#define fast() ios::sync_with_stdio(false), cin.tie(nullptr)
#define digit(N) cout << fixed << setprecision((N))
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string &s)
{
    return '"' + s + '"';
}

string to_string(const char *s)
{
    return to_string((string)s);
}

string to_string(bool b)
{
    return (b ? "true" : "false");
}

string to_string(vector<bool> v)
{
    bool first = true;
    string res = "{";
    for (int i = 0; i < static_cast<int>(v.size()); i++)
    {
        if (!first)
        {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v)
{
    string res = "";
    for (size_t i = 0; i < N; i++)
    {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v)
{
    bool first = true;
    string res = "{";
    for (const auto &x : v)
    {
        if (!first)
        {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p)
{
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p)
{
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p)
{
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main()
{
    int N, M, a;
    while (cin >> N >> M >> a)
    {
        if (N == 0 && M == 0 && a == 0)
            return 0;

        vector<pair<int, pair<int, int>>> v(M);
        for (int i = 0; i < M; i++)
        {
            cin >> v[i].first >> v[i].second.first >> v[i].second.second;
        }

        for (int h = 1000; h > 0; h--)
        {
            for (int i = 0; i < M; i++)
            {
                if (v[i].first == h && v[i].second.first == a)
                    a = v[i].second.second;
                else if (v[i].first == h && v[i].second.second == a)
                    a = v[i].second.first;
            }
        }

        cout << a << "\n";
    }
}


Measured memory_bytes: 3028
def main():
    n = int(input())

    s_set = set()
    for i in range(n):
        order = input().split()
        if order[0] == "insert":
            s_set.add(order[1])
        else:
            if order[1] in s_set:
                print("yes")
            else:
                print("no")


if __name__ == '__main__':
    main()



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

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

    int ans = 0;
    if (s[0] == s[1] && s[1] == s[2] && s[2] == s[3]) {
        /* code */
    } else {
        if ( s[0] == s[1] && s[2] == s[3]) {
            ans = 1;
        } else if ( s[0] == s[2] && s[1] == s[3]) {
            ans = 1;
        } else if ( s[0] == s[3] && s[1] == s[2]) {
            ans = 1;
        }
    }

    if ( ans == 1 ) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
def main():
    K, S = map(int, input().strip().split())
    result = 0
    for z in range(0, K+1):
        target = S - z
        k = 0
        while k <= K:
            if 0 <= target - k <= K:
                result += 1
                k += 1
            else:
                k += 1
                continue
    print(result)

if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
)

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//=====main=====

func main() {
	sc.Split(bufio.ScanWords)

	n := scanInt()
	b := scanInts(n-1)
	
	ans := b[0]
	pre := b[0]
	for i := 0; i < n-2; i++ {
		if pre < b[i+1] {
			ans+=pre
		} else {
			ans+=b[i+1]
		}

		pre = b[i+1]
	}

	ans += b[n-2]

	fmt.Println(ans)
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;

int main() {
    int N;
    cin >> N;
    ll X[N];
    for (int i = 0; i < N; ++i) {
        cin >> X[i];
        X[i]--;
    }
    ll m = 1ll << 50;
    for (int P = 0; P < 100; ++P) {
        ll tmp = 0;
        for (int i = 0; i < N; ++i) {
            tmp += (P - X[i]) * (P - X[i]);
        }
        m = min(m,tmp);
    }
    cout << m << endl;

}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define all(a) (a).begin(),(a).end()

int main() {
  int a,b;
  cin >> a >> b;
  if(abs(a-b)%2==1){
    cout << "IMPOSSIBLE" << endl;
  }else{
    cout << (a+b)/2 << endl;
  }
}


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

K = format(K, '040b')
A = [format(a, '040b') for a in A]

max_flg = 0
ans = ''
for index, i in enumerate(list(K)):
    if i == '1':
        num_1 = 0
        for a in A:
            if a[index] == '1':
                num_1 += 1
        if num_1 >= int(N/2) + 1:
            ans += '0'
            max_flg = 1
        else:
            ans += '1'
    else:
        if i == '0' and max_flg == 0:
            ans += '0'
        elif i == '0' and max_flg == 1:
            num_1 = 0
            for a in A:
                if a[index] == '1':
                    num_1 += 1
            if num_1 >= int(N/2) + 1:
                ans += '0'
            else:
                ans += '1'
ans2 = 0
for a in A:
    ans2 += int(ans, 2) ^ int(a, 2)
print(ans2)

Measured memory_bytes: 17820
#include <iostream>
#include <map>
#include <functional>
#include <vector>
#include <cmath>

class Factoriser
{
    std::vector<int> factors;

public:
    using map_type = std::map<int, int>;
    
    Factoriser(int N)
    {
        factors.resize(N+1, 0);
        int sqrN = static_cast<int>(std::sqrt(N));

        for (int i = 2; i <= sqrN; ++i)
        {
            if (factors[i] == 0)
            {
                for (int j = i * 2; j <= N; j += i)
                {
                    if (factors[j] == 0)
                    {
                        factors[j] = i;
                    }
                }
            }
        }
    }

    map_type Factorise(int M) const
    {
        map_type P;
        int mm = M;

        while (factors[mm])
        {
            ++P[factors[mm]];
            mm /= factors[mm];
        }

        if (mm >= 2) ++P[mm];
        return P;
    }
    
    bool IsPrime(int M) const
    {
        return factors[M] == 0;
    }
};


///////////////////////////////////////////////////

using plist_citr_t = Factoriser::map_type::const_iterator;
using vi = std::vector<int>;

bool contains_dfs(int a, std::function<bool(int)> exists, int cur, plist_citr_t it, plist_citr_t last)
{
    if (cur == a) return false;
    if (it == last)  return exists(cur);

    auto [p, m] = *it++;
    for (int i = 0; i <= m; ++i)
    {
        bool r = contains_dfs(a, exists, cur, it, last);
        if (r) return true;
        cur *= p;
    }
    return false;
}

bool contains(int a, std::function<bool(int)> exists, const Factoriser &fac)
{
    auto plist = fac.Factorise(a);
    return contains_dfs(a, exists, 1, plist.begin(), plist.end());
}

int main()
{
    int N;
    std::map<int, int> A;
    std::cin >> N;
    for (int i = 0; i < N; i++)
    {
        int a;
        std::cin >> a;
        ++A[a];
    }

    constexpr int MAX_A = 1000000;
    Factoriser fac(MAX_A);

    int ans = 0;
    if (A.count(1) > 0)
    {
        ans = A[1] == 1 ? 1 : 0;
    }
    else
    {
        for (auto [a, i] : A)
        {
            auto exist = [&A](int a){ return A.count(a) > 0; };
            if (i == 1 && !contains(a, exist, fac)) ++ans;
        }
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 16304
#include <bits/stdc++.h>
#define sp putchar(' ')
#define en putchar('\n')
using namespace std ;
using VI = vector<int64_t> ;
int n, m, T, u, v, a, b ;
string str ;

int main()
{
    ios::sync_with_stdio(false) ;
    while(cin >> str) {
        if(str[str.length() - 1] == 's') {
            str += "es" ;
        } else {
            str += "s" ;
        }
        cout << str << endl ;
    }
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i ++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i ++)
#define MP make_pair

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int MOD = 998244353;

int n, k, cnt;
char hv[25][1048576];
int cdp[1048576][25], ndp[1048576][25];

int main()
{
	scanf("%d%d", &n, &cnt);
	for(int i = 0; i <= n; i ++) scanf("%s", hv[i]);
	
	rep(i, 1 << n) if(hv[n][i] == '1') for(int j = 0; j <= n; j ++) cdp[i][j] = 1;
	rep(i, 1 << n) if(cdp[i][0] >= cnt) {
		for(int j = n - 1; j >= 0; j --) printf("%d", i >> j & 1);
		printf("\n");
		return 0;
	}
	for(int i = n - 1; i >= 0; i --) {
		rep(j, 1 << i) for(int k = 0; k <= i; k ++) ndp[j][k] = 0;
		rep(j, 1 << i) for(int k = i; k >= 0; k --)
		if(k == i) ndp[j][k] = cdp[j][k + 1] + cdp[j | 1 << i][k + 1];
		else {
			int cj = j & (1 << k) - 1;
			cj |= (j ^ cj) << 1;
			cj |= ~j & 1 << k;
			ndp[j][k] = cdp[cj][k + 1] + ndp[j][k + 1];
		}
		rep(j, 1 << i) if(hv[i][j] == '1') for(int k = 0; k <= i; k ++) ndp[j][k] ++;
		
		rep(j, 1 << i) for(int k = 0; k <= i; k ++) cdp[j][k] = ndp[j][k];
		
		rep(j, 1 << i) if(cdp[j][0] >= cnt) {
			for(int k = i - 1; k >= 0; k --) printf("%d", j >> k & 1);
			printf("\n");
			return 0;
		}
	}
	
	return 0;
}

Measured memory_bytes: 178432
#include<stdio.h>
int main()
{
	int i,j,n,c=0,d=0;
	scanf("%d",&n);
	for(i=1;i<=n;i=i+2)
	{
		for(j=1;j<=i;j++)
		{
			if(i%j==0)
				d++;
		}
		if(d==8)
			c++;
		d=0;
	}
	printf("%d\n",c);
}


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

using namespace std;

using ll = long long;

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

#define INF 1e9

int main(void)
{
    int n, s[100005] = {}, q, t[50005] = {}, i, left, right, center, sum = 0;

    cin >> n;
    for(i = 0; i < n; i++){
        cin >> s[i];
    }
    cin >> q;
    for(i = 0; i < q; i++){
        cin >> t[i];
    }

    sort(s, s + n);

    for(i = 0; i < q; i++){
        left = 0;
        right = n - 1;
        center = (left + right) / 2;
        while(s[center] != t[i] && left <= right){
            if(s[center] < t[i]){
                left = center + 1;
                center = (left + right) / 2;
            }
            else{
                right = center - 1;
                center = (left + right) / 2;
            }
        }
        if(s[center] == t[i]){
            sum++;
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
#define inf 1000000000 //1E+9
using namespace std;


int main(){
	string s; cin>>s;
	string t="CODEFESTIVAL2016";
	int ans=0;
	for(int i=0;i<16;i++){
		if(s[i]!=t[i]) ans++;
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll  long long int
#define all(x) (x).begin(), (x).end()
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,t;
    cin>>s>>t;
    int ans=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]!=t[i])ans++;
    }
    cout<<ans<<endl;

    return 0;
}


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

int main(){
  int n, p, sum = 0, pmax = 1;
  cin >> n;
  for ( int i = 0; i < n; i++ ){
    cin >> p;
    sum += p;
    pmax = max(pmax, p);
  }
  
  sum -= pmax / 2;
  cout << sum << endl;
}

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

const ll MOD = 1e9 + 7;

int main()
{
	int n,m; cin>>n>>m;
	vector<int> a;
	for(int i=0;i<m;i++){
		int x; cin>>x; a.push_back(x);
	}
	sort(a.begin(),a.end());
	//for(int i=0;i<m;i++) cout<<a[i]<<" "; cout<<endl;
	vector<int> d;
	for(int i=1;i<m;i++) d.push_back(a[i]-a[i-1]);
	sort(d.begin(), d.end());
	//for(int i=0;i<m-1;i++) cout<<d[i]<<" "; cout<<endl;
	ll ans=0;

	for(int i=0;i<(m-n);i++){
		ans += d[i];
	}

	cout<<ans;	
}

Measured memory_bytes: 1400
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lli;

int main(){
	lli a,b,c,k;
	cin >> a >> b >> c >> k;
	if(k%2 == 0) cout << a-b << endl;
	else cout << b-a << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

const ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
int compare(string a, string b) {
	int i;
	for (i = 0; i < a[i] != '\0'; i++) {
		if (b[i] == '\0')
			return -1;
		else if (a[i] < b[i])
			return 1;
		else if (a[i] > b[i])
			return -1;
	}
	if (b[i] != '\0')
		return 1;
	else
		return 0;
}
int main() {
	ll n, i,j,h, p, dp[5001][5001],ans;
	cin >> n;
	vector<pair<ll, ll>> w(n);
	for (i = 0; i < n; i++) {
		cin >> h >> p;
		w[i] = make_pair(h+p, p);
	}
	sort(w.begin(), w.end());
	for (i = 0; i <= n; i++)
		for (j = 0; j <= i; j++)
			dp[i][j] = 1e+12;
	dp[0][0] = 0;
	for (i = 0; i < n; i++) {
		for (j = 0; j <= i; j++)
			dp[i + 1][j] = dp[i][j];
		for (j = 0; j <= i; j++)
			if (dp[i][j] <= w[i].first-w[i].second)
				dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] +w[i].second);
	}
	for (j = 0; j <= n; j++)
		if (dp[n][j] < 1e+11)
			ans = j;
	cout << ans << endl;
}

Measured memory_bytes: 200320
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    String S = sc.nextLine();
		int odd0 = 0;
		int odd1 = 0;
		int even0 = 0;
		int even1 = 0;
		for(int i=0;i<S.length();i++) {
			char c = S.charAt(i);
			if(i%2==0) {
				if(c=='0') even0++;
				else even1++;
			}else {
				if(c=='0') odd0++;
				else odd1++;
			}
		}
		System.out.println(Math.min(odd0+even1, odd1+even0));
    
  }
}
    

Measured memory_bytes: 40372
#include <bits/stdc++.h>
using namespace std;
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                             \
  cerr << __LINE__ << ": " << #x << " = {";          \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) { \
    cerr << ((hoge) ? "," : "") << x[hoge];          \
  }                                                  \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long N, A, B;
  cin >> N >> A >> B;
  long long ans = N / (A + B) * A + min(A, N % (A + B));
  cout << ans << endl;
  return 0;
}


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

int main(){
	int cnt=0,len;
	string s;
	cin >> s;
	len=s.size();
	for(int i=0;i<s.size();i++){
		if(s[i]=='S'){
			cnt++;
		}
		else{
			if(cnt>0){
				len-=2;
				cnt--;
			}
		}
		
	}
	
	cout << len << endl;
	return 0;
}

Measured memory_bytes: 640
import collections
import sys

p_q = collections.deque(maxlen = 100000)

e_time = 0

n, q = map(int, sys.stdin.readline().split())

for i in range(n):
    p_name, r_time = sys.stdin.readline().split()
    p_q.append([p_name, int(r_time)])

while p_q:
    t_p = p_q.popleft()
    if t_p[1] > q:
        t_p[1] -= q
        e_time += q
        p_q.append(t_p)
    else:
        e_time += t_p[1]
        print(t_p[0], e_time)

Measured memory_bytes: 16052
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let s=read::<String>();
    let mut ss=String::new();
    ss.push_str(&s[..]);
    ss.push_str(&s[..]);
    let t=read::<String>();
    println!("{}",if let Some(_a)=ss.find(&t[..]){"Yes"}else{"No"});
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define ifaxb(a, x, b) if (a < x && x < b)  // 比較は昇順
#define vi vector<int>
#define vii vector<vi>
#define vs vector<string>
#define vss vector<vs>
#define all(x) x.begin(), x.end()
#define pi 3.1415926536
#define ff first
#define ss second
#define pq priority_queue
#define ipair pair<int, int> s
#define lpair pair<LL, LL>
#define MP make_pair
#define INF 2147483647
#define _INF -2147483647
#define MM multimap
#define PB push_back
#define MAXN 100004
using namespace std;
typedef long long ll;

int main() {
    int N, L;
    cin >> N >> L;
    int original = N * L - N + N * (N + 1) / 2;
    if (L + N - 1 < 0)
        cout << original - (L + N - 1);
    else if (L > 0)
        cout << original - L;
    else
        cout << original;
    cout << '\n';
}

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

typedef long long ll;
#define fr(i,n) for(int i = 0;i<n;i++)

#define prin(a) cout << #a << " = " << a << endl

#define eb emplace_back
#define all(v) (v).begin(),(v).end()

typedef pair<int,int> pii;

vector<ll> vans;
ll ans;

const int N = 1e5+10;

vector<int> g[N];

int n, m;

vector<pii> edges;

int pai[N];

int rep(int u){
    return pai[u]<0? u : pai[u] = rep(pai[u]);
}

void merge(int u, int v){
    u = rep(u), v = rep(v);
    if(u!=v){
        if(pai[u]>pai[v]) swap(u,v);
        ans-= (ll)pai[u]*pai[v];
        pai[u]+=pai[v];
        pai[v] = u;
    }
}

int main(){
    memset(pai,-1,sizeof(pai));
    cin >>n >> m;
    
    fr(i,m){
        int a, b;
        scanf("%d%d", &a, &b);
        a--,b--;
        edges.eb(a,b);
    }
    
    ans = (ll)n*(n-1)/2;
    
    reverse(all(edges));
    
    fr(i,edges.size()){
        int a,b;
        tie(a,b) = edges[i];
        vans.eb(ans);
        merge(a,b);
        
    }
    
    reverse(all(vans));
    
    fr(i,vans.size()){
        printf("%lld\n", vans[i]);
    }

}

Measured memory_bytes: 5748
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
using namespace std;
using ll = long long;
const int INF = +100100100;
typedef pair<ll,ll> P;
const ll MO = 1000000007;

int main(){
    int n;
    cin >> n;
    vector<int> h(n),c(n);
    rep(i,n)cin>>h[i];
    c[0] = 0;
    c[1] = abs(h[0]-h[1]);
    for(int i = 2; i<n;++i){
        c[i] = min(c[i-1]+abs(h[i]-h[i-1]),c[i-2]+abs(h[i]-h[i-2]));
    }
    cout << c[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1024
def gcd(a,b):
    a,b=sorted([a,b])
    while a > 0:
        t=a
        a=b%a
        b=t
    return b

def dev(a):
    d=list()
    for i in range(1, a+1):
        if a%i==0:
            d.append(i)
    return d

n=int(input())
while True:
    try:
        x=sorted(list(map(int,input().split())))
        a=x.pop(0)
        b=x.pop(0)
        c=gcd(a,b)
        while len(x) > 0:
            a=c
            b=x.pop(0)
            c=gcd(a,b)
        for i in dev(c):
            print(i)
        quit()
    except ValueError:
        break


Measured memory_bytes: 5600
S = input()
S = S[1:-1]
#print(S)
S = S.split("LR")

ans = ""
for i in range(len(S)):
    tp = "R" + S[i] + "L"
    #print(tp)
    rn = len(tp.split("RL")[0])+1
    ln = len(tp) - rn 
    #print(rn,ln)
    for k in range(rn-1):
        ans += "0 "
    ans += str(-(-rn//2) + ln//2) +" "
    ans += str(-(-ln//2) + rn//2) +" "
    for k in range(ln-1):
        ans += "0 "
    #print()
#print(S)

print(ans)

Measured memory_bytes: 4468
# -*- coding: utf-8 -*-
N = int(input())
while N:
    days = [[] for _ in range(31)]
    roles = [2**i for i in range(N)]
    for i in range(N):
        for j in list(map(int, input().split()))[1:]:
            days[j].append(i)

    for i, day in enumerate(days):
        role = 0
        for d in day:
            role |= roles[d]
        for d in day:
            roles[d] = role
        if role == 2**N - 1:
            print(i)
            break
    else:
        print(-1)
    N = int(input())



Measured memory_bytes: 5620
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
ll INF = 1LL<<60;
int main(void){
    int n,m,r;
    ll d[210][210];
    cin >> n >> m >> r;
    vector<int> v;
    for(int i = 0;i < r;i++){
        int x;
        cin >> x;
        x--;
        v.push_back(x);
    }
    
    for(int i = 0;i < 210;i++){
        for(int j = 0;j < 210;j++) d[i][j] = INF;
        d[i][i] = 0;
    }
    
    for(int i = 0;i < m;i++){
        int a,b,c;
        cin >> a >> b >> c;
        a--,b--;
        d[a][b] = c;
        d[b][a] = c;
    }
    
    for(int k = 0;k < n;k++)for(int i = 0;i < n;i++)for(int j = 0;j < n;j++)
    d[i][j] = min(d[i][j],d[i][k] + d[k][j]);
    
    ll ans = INF;
    sort(v.begin(),v.end());
    do{
        ll tmp = 0;
        for(int i = 0;i < v.size()-1;i++) tmp += d[v[i]][v[i+1]];
        ans = min(ans,tmp);
    }while(next_permutation(v.begin(),v.end()));
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640