akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

using namespace std;

typedef long double ld;
typedef long long ll;

#define sz(x) (int)(x).size()
#define pb push_back
#define mp make_pair
#define f first
#define s second

template<typename T, typename U> bool ckmin(T &a, U b){ return b < a ? a = b, true : false; }
template<typename T, typename U> bool ckmax(T &a, U b){ return b > a ? a = b, true : false; }

int n, res = 0, a;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    for(int i = 0; i < n; ++i){
        cin >> a;
        if(i%2 == 0) res += (a&1);
    }
    cout << res;
    return 0;
}

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

using namespace std;
typedef long long ll;
#define REP(i,n) for (int i = 0; i < n; ++i)
#define ALL(x) x.begin(), x.end()

const int MAX = 2e4+10;
struct block {
    int w, s, v;

    bool operator<( const block& right ) const {
        return s+w > right.s+right.w;
    }
};
vector<block> B;
ll dp[MAX];

int N;

int main () {
	cin >> N;
    B = vector<block>(N);
    REP (i, N) cin >> B[i].w >> B[i].s >> B[i].v;
    sort(ALL(B));

    ll ans = 0;
    REP (i, N) {
        REP (j, B[i].s+1)
            dp[j] = max(dp[j], dp[j+B[i].w]+B[i].v);
    }
    REP (i, MAX) ans = max(ans, dp[i]);
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>

typedef struct {
	int parent, rank;
} Node;
typedef struct {
	int from, to, w;
} Edge;

Node node[100];
Edge edge[10000];
int e;

int compare(const void *a, const void *b) {
	return ((Edge *)a)->w - ((Edge *)b)->w;
}

void init(int n) {
	int i;
	for (i = 0; i < n; i++) {
		node[i].parent = i;
		node[i].rank = 0;
	}
}

int find(int x) {
	return node[x].parent != x ? node[x].parent = find(node[x].parent) : x;
}

void unite(int x, int y) {
	int xr = find(x), yr = find(y);

	if (node[xr].rank < node[yr].rank)
		node[xr].parent = yr;
	else {
		node[yr].parent = xr;
		if (node[xr].rank == node[yr].rank)
			node[xr].rank++;
	}
}

int kruskal(int v, int e) {
	int i;
	int sum;

	qsort(edge, e, sizeof(Edge), &compare);

	init(v);

	sum = 0;
	for (i = 0; i < e; i++)
		if (find(edge[i].from) != find(edge[i].to)) {
			unite(edge[i].from, edge[i].to);
			sum += edge[i].w;
		}

	return sum;
}

int main(void) {
	int i, j;
	int n;

	scanf("%d", &n);

	for (i = 0; i < n; i++)
		for (j = 0; j < n; j++) {
			int a;
			scanf("%d", &a);
			if (a != -1)
				edge[e++] = (Edge){i, j, a};
		}

	printf("%d\n", kruskal(n, e));

	return 0;
}

Measured memory_bytes: 820
/*
 *
 * Author : fcbruce <fcbruce8964@gmail.com>
 *
 * Time : Sun 21 Aug 2016 20:11:28
 *
 */
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cstdlib>
#include <algorithm>
#include <ctime>
#include <cctype>
#include <cmath>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <map>
#include <set>
#define sqr(x) ((x)*(x))
#ifdef _WIN32
#define lld "%I64d"
#else
#define lld "%lld"
#endif

const int INF = 0x3f3f3f3f;
const long long INFLL = 0x3f3f3f3f3f3f3f3fll;
const double PI = acos(-1.0);
const double eps = 1e-10;

typedef long long LL;
typedef int itn;

const int maxn = 0;
const int maxm = 0;

int main()
{
#ifdef FCBRUCE
  //freopen("/home/fcbruce/code/t", "r", stdin);
#endif // FCBRUCE

  int n;
  scanf("%d", &n);

  LL res = 0, r = 0, a;
  
  for (int i = 0; i < n; i++)
  {
    scanf(lld, &a);
    if (r && a)
    {
      res++;
      a--;
    }

    res += a >> 1;
    r = a & 1;
  }

  printf(lld "\n", res);



  return 0;
}


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

bool inc(int n){
    while (n != 0){
        if (n % 10 == 3) return true;
        n /= 10;
    }
    return false;
}

int main(){
    int n;
    cin >> n;
    int i;
    for (i = 3; i <= n; i++) if (i % 3 == 0 || inc(i)) cout << " " << i;
    cout << endl;
}

Measured memory_bytes: 3072
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int result = 0;
    switch(sc.next()){
      case "SUN":
        result++;
      case "MON":
        result++;
      case "TUE":
        result++;
      case "WED":
        result++;
      case "THU":
        result++;
      case "FRI":
        result++;
      case "SAT":
        result++;
    }
    System.out.println(result);
  }
}

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

int main() {
  int N, a, b, c, d;
  cin >> N;
  
  a = N / 1000;
  b = (N / 100) - a * 10;
  c = (N / 10) - (a * 100 + b* 10);
  d = N % 10;
  
  if ( a == b){
    if ( b == c ){
      cout << "Yes";
    }
    
    else{
      cout << "No";
    }
  }
  
  else if ( b == c){
    if( c == d ){
      cout << "Yes";
    }
    
    else{
      cout << "No";
    }
  }
  
  else {
    cout << "No";
  }

  
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <math.h>
#include <string>
typedef long long ll;

using namespace std;

int main(){
    ll N;
    cin >> N;
    ll T[1010] = {0}, A[1010] = {0};
    for (int i = 0; i < N; i++){
	cin >> T[i] >> A[i];
    }

    ll t = T[0], a = A[0];
    for (int i = 1; i < N; i++){
	ll ma;
	ll x = 0;
	while (1){
	    if ((a+x)%A[i] == 0){
		ma = (a+x)/A[i];
		break;
	    }
	    x++;
	}

	ll mt;
	x = 0;
	while (1){
	    if ((t+x)%T[i] == 0){
		mt = (t+x)/T[i];
		break;
	    }
	    x++;
	}

	ll m = max(ma, mt);
	t = T[i]*m;
	a = A[i]*m;
    }

    cout << t+a << endl;

    return 0;
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
#define pii pair<int, int>
#define int int64_t
#define re(s) reverse((s).begin(), (s).end())
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
const long long mod = 1e9 + 7;

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

   int n,cnt=0;
   string s;

   cin>>n>>s;

   rep(i,s.size()){
      if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') ++cnt;
   }

   cout<<cnt<<'\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long lli;
lli x,y;
lli ans = 1ll << 62;
int main(){
    cin >> x >> y;
    if(y - x >= 0) ans = min(ans,y-x);
    y *= -1;
    if(y - x >= 0) ans = min(ans,y - x + 1);
    x *= -1;
    if(y - x >= 0) ans = min(ans,y - x + 2);
    y *= -1;
    if(y - x >= 0) ans = min(ans,y - x + 1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int a,b,c = 0;
  scanf("%d%d",&a,&b);
  int i = 0;
  //a:差し込み口の数/タップ
  //b:欲しい差込口の総数
  //c:差込口の数
  //i:タップの数
  //具体的に想像すると4口/タップだとして
  //4:1,7:2,10:3,13:4,,,
  //2タップ目以降差込口-1で増えていく
  //差込口一つだけが必要な時、タップはいらない？
  if (b == 1)
    printf("0\n");
  else if (a >= b)
  {
    printf("1\n");
  }
  else
  {
    while (c < b)
    {
      c = a+i*(a-1);
      i++;
    }
    printf("%d\n",i); 
  }
}

Measured memory_bytes: 128
S = input()
str_dir = {}
for c in list(S):
    if c in str_dir:
        str_dir[c] += 1
    else:
        str_dir[c] = 1

if len(str_dir) == 2 and list(str_dir.values()) == [2, 2]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 2940
#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 cnt=0,ans=0;
    for(int i=1;i<n;i++){
        if(a[i]<=a[i-1])
            cnt++;
        else
            cnt=0;
       ans=max(ans,cnt);;
    }
    cout<<ans;
    return 0;
}


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

int main(){
  int r,g,b;
  int x;
  cin >> r >> g >> b;
  x = 100*r + 10*g + b;
  if (x%4 == 0){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}
  

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>
#include <new>

using namespace std;

#define EPS (1e-9)
#define INF (1e9)
#define MOD (ll)(1e9 + 7)
#define PI (acos(-1))
#define REP(i,a,n) for(int i=a;i<n;i++)
#define rep(i, n) REP(i,0,n)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" ; "IMPOSSIBLE")

using ll = long long int;

ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll beki(ll a, ll b) {
    ll tmp = 1;
    rep(i, b) tmp *= a;
    return tmp;
}

ll modPow(ll x, ll a) {
    if (a == 1) return x;
    if (a % 2) return (x * modPow(x, a - 1)) % MOD;
    ll t = modPow(x, a / 2);
    return ((t % MOD) * (t % MOD)) % MOD;
}

ll modInv(ll x) {
    return modPow(x, MOD - 2);
}

ll X, Y, A, B, C;
vector<ll> p(100010), q(100010), r(100010);
priority_queue<ll, vector<ll>, greater<ll>> p_que, q_que;
ll ans = 0;

int main() {
    cin >> X >> Y >> A >> B >> C;
    rep(i, A) cin >> p[i];
    rep(i, B) cin >> q[i];
    rep(i, C) cin >> r[i];

    sort(p.begin(), p.end(), greater<ll>());
    sort(q.begin(), q.end(), greater<ll>());
    sort(r.begin(), r.end(), greater<ll>());

    rep(i, X) {
        p_que.push(p[i]);
        //cout << p[i] << endl;
    }
    rep(i, Y) {
        q_que.push(q[i]);
        //cout << q[i] << endl;
    }

    for (ll i = 0; min(p_que.top(), q_que.top()) < r[i]; i++) {
        if (p_que.top() <= q_que.top()) {
            p_que.pop();
            p_que.push(r[i]);
        }
        else {
            q_que.pop();
            q_que.push(r[i]);
        }
    }

    rep(i, X) {
        ans += p_que.top();
        p_que.pop();
    }

    rep(i, Y) {
        ans += q_que.top();
        q_que.pop();
    }

    cout << ans << endl;
}

Measured memory_bytes: 7872
//#include <bits/stdc++.h>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <limits>
#include <map>
#include <vector>
#include <queue>
#define LL long long
#define ft first
#define sd second
#define mp(x,y) make_pair(x,y)
//#define int LL
using namespace std;
const int N   = 3e5+233;
//const int mod = ;
const int INF =numeric_limits<int >::max();
#define For(n) for (int i=1;i<=n;++i)
#define rep(i,n) for (int i=1;i<=n;++i)
#define repp(i,x,y) for (int i=x;i<=y;++i)
void read(int &x)
{
	x=0;
	char ch=getchar();
	int f=1;
	while (!isdigit(ch)) (ch=='-'?f=-1:0),ch=getchar();
	while ( isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	x*=f;
}

void write(int x)
{
	if (x<0) putchar('-'),x=-x;
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
int n,a[N],b[N],c[N],d[N];
signed main()
{
	read(n);
	rep(i,n)  read(a[i]),++c[a[i]];
	rep(i,n) read(b[i]),++d[b[i]];
	reverse(b+1,b+1+n);
	rep(i,n ) if (c[i]+d[i]>n) 
	{
		printf("No");
		return 0;
	}
	int l=n,r=1;
	rep(i,n) if (a[i]==b[i])  l=min(l,i),r=max(r,i);
	int pos=l;
	for (int i=1;i<l&&pos<=r;++i) if (b[i]!=a[l]&&a[i]!=a[l]) swap(b[i],b[pos]),++pos;
	for (int i=r+1;i<=n&&pos<=r;++i) if (b[i]!=a[l]&&a[i]!=a[l]) swap(b[i],b[pos]),++pos;

	printf("Yes\n");
	rep(i,n) printf("%d ",b[i]);
	return 0;
}


Measured memory_bytes: 6884
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
#include <sstream>
#include <cstdio>
#include <complex>
#include <cstring>
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)
#define pb(a) push_back(a)
int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

int main(void){
  string o;
  while(cin>>o){
    rep(i,10){
      string s = o;
      int a,b;
      rep(j,s.size()){
	if(s[j] == 'X')s[j] = (char)(i+'0');
	if(s[j] == '+')a=j;
	if(s[j] == '=')b=j;
      }

      vector<string>ss(3);
      ss[0]=s.substr(0,a);
      ss[1]=s.substr(a+1,b-a-1);
      ss[2]=s.substr(b+1);            
      if(ss[0][0]=='0'&&ss[0].size()>1)continue;
      if(ss[1][0]=='0'&&ss[1].size()>1)continue;
      if(ss[2][0]=='0'&&ss[2].size()>1)continue;
      int k = 0;

      rep(j,3){
	int t = ss[j].size();
	k=max(k,t);
      }

      rep(j,3)while(k!=ss[j].size())ss[j]="0"+ss[j];
      for(int j = k-1 ; j >= 0 ; j --){
	ss[0][j]+=ss[1][j]-'0';
	if(ss[0][j]>'9'){ss[0][j]-=10;ss[0][j-1]++;}
      }

      if(ss[0]==ss[2]){cout<<i<<endl;break;}
      if(i==9)cout<<"NA"<<endl;
      //*/
    }
  }
}

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

#define FOR(i,a,b) for(i=(a);i<(b);++i) 
#define FORR(i,a,b) for(i=(a);i>(b);--i)
#define REP(i,n) for(i=0;i<(n);++i)
#define REPR(i,n) for(i=(n);i>0;--i)
#define ll long long
#define INT_MAX 2147483647
#define LL_MAX 9223372036854775807

using namespace std;

long long GCD(long long a, long long b) {
	if (a < b)
		swap(a, b);
	if (b == 0) return a;
	else return GCD(b, a % b);
}
bool sosuu_check(int num) {
	int i;
	for (i = 2; i <= sqrt(num); ++i) {
		if (num%i == 0)
			return false;
	}
	return (num < 2) ? false : true;
}
int main() {
	int N, i, bef, mid, aft;
	vector<int> vec(200000);
	vector<int> aaa(200000);
	cin >> N;
	REP(i, N) {
		cin >> vec[i];
		aaa[i] = vec[i];
	}
	sort(vec.begin(), vec.begin() + N);
	bef = vec[N / 2 - 1];
	mid = vec[N / 2];
	//aft = vec[N / 2 + 1];
	//cout << bef << " " << mid << " " << aft;
	REP(i, N)
		if (aaa[i] < mid)
			cout << mid << endl;
		else
			cout << bef << endl;
}

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

int main(){
	string str;
	cin >> str;
	string tmp = str;
	reverse(tmp.begin(), tmp.end());
	for(int i = 0; i < tmp.length(); i++){
		if(tmp[i] == 'b')tmp[i] = 'd';
		else if(tmp[i] == 'd')tmp[i] = 'b';
		else if(tmp[i] == 'p')tmp[i] = 'q';
		else if(tmp[i] == 'q')tmp[i] = 'p';
	}
	if(str == tmp)cout << "Yes" << endl;
	else cout << "No" << endl;
} 


Measured memory_bytes: 512
#include <iostream>
#include <vector>

using namespace std;

void solve()
{
	int N, A, B, C, X;
	while(cin >> N >> A >> B >> C >> X, N || A || B || C || X)
	{
		vector<int> vec(N);
		for(int i = 0; i < N; ++i)
		{
			cin >> vec[i];
		}
		int count = 0;
		int pos = 0;
		while(true)
		{
			if(vec[pos] == X)
			{
				++pos;
			}
			if(count >= 10001)
			{
				cout << -1 << endl;
				break;
			}
			if(pos >= N)
			{
				cout << count << endl;
				break;
			}
			X = (A * X + B) % C;
			++count;
		}
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
 
template<class T> inline bool chmin(T& a,T b) {if(a>b){a=b;return true;} return false; }
template<class T> inline bool chmax(T& a,T b) {if(a<b){a=b;return true;} return false; }
 
int N;
int h[100010][3];
long long dp[100010][3];
 
int main(){
    cin >> N;
    for(int i=0;i<N;++i) cin >> h[i][0] >> h[i][1] >> h[i][2];
 
    for(int i=0;i<N;++i){
        for(int j=0;j<3;++j){
            for(int k=0;k<3;++k){
                if(j==k) continue;
                chmax(dp[i+1][j],dp[i][k] + h[i][j]);
            }
        }
    }
 
    long long ans = 0;
    for(int i=0;i<3;++i){
        chmax(ans,dp[N][i]);
    }
    cout << ans << endl;
    
    return 0;
 
}

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

int main() {
    int A, B, C;
    std::cin >> A >> B >> C;
    if ((A == 7 && B == 5 && C == 5) ||
        (A == 5 && B == 7 && C == 5) ||
        (A == 5 && B == 5 && C == 7)) 
    {
        std::cout << "YES\n";
    } else {
        std::cout << "NO\n";
    }

    return 0;
}


Measured memory_bytes: 256
n, h = map(int, input().split())


an = [0]*n
bn = [0]*n

for i in range(n):
    an[i],bn[i] = map(int, input().split())
    

an.sort(reverse = True)
bn.sort(reverse = True)

ans = 0
for b in bn:
    if b>an[0] and h>0:
        h -= b
        ans += 1


ans += 0 if h<=0 else h//an[0] + (1 if h%an[0]>0 else 0) 

print(ans)



Measured memory_bytes: 11312
#include <bits/stdc++.h>
#define REP(i, a, b) for (long long i = a; i <= b; ++i)
#define PER(i, a, b) for (long long i = a; i >= b; --i)
#define ll long long
#define N 110
using namespace std;

ll n, a[N], b[N], ans;

inline ll read(){									//快读 
	ll s = 0, w = 1;
	char ch = getchar();
	while (ch < '0' || ch > '9'){
		if (ch == '-') w *= -1;
		ch = getchar();
	}
	while (ch >= '0' && ch <= '9'){
		s = s * 10 + ch - '0';
		ch = getchar();
	}
	return s * w;
}

inline void work(){
	n = read();										//长度为n的数列a 
	REP(i, 1, n - 1) b[i] = read();					//长度为n-1的数列b 
	b[n] = b[n - 1], a[1] = b[1];					//初始化 
	PER(i, n, 2) a[i] = min(b[i - 1], b[i]);		//逆推，取b[i]和b[i-1]的最小值 
	REP(i, 1, n) ans += a[i];						//求和 
	printf("%lld\n", ans);							//输出答案 
}

int main(){
	work();
	return 0;
}

Measured memory_bytes: 256
I = input().split()
for i in[0, 1, 2]:
    I[i] = int(I[i])
for i in[0, 1, 2]:
    j = i + 1
    while j <= 2:
        if I[i] > I[j]:
            w = I[i]
            I[i] = I[j]
            I[j] = w
        j += 1
print(str(I[0]) + ' ' + str(I[1]) + ' ' + str(I[2]))

Measured memory_bytes: 7704
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

const int MAX_N = 100005;

class Edge {
public:
  int nxt, to;
} e[MAX_N << 3];

int head[MAX_N << 1], cnt;
void addedge(int u, int v) {
  e[++cnt] = (Edge){head[u], v}, head[u] = cnt;
  e[++cnt] = (Edge){head[v], u}, head[v] = cnt;
}

int deg1[MAX_N], deg2[MAX_N];
bool vis[MAX_N << 3];
#define rev(x) (x & 1 ? x + 1 : x - 1)
		
void dfs(int u) {
  for (int &i = head[u]; i; i = e[i].nxt)
    if (!vis[i] && !vis[rev(i)]) {
      vis[i] = 1;
      dfs(e[i].to);
    }
}

int main() {
  int N;
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i) {
    int fa;
    scanf("%d", &fa);
    if (fa != -1) deg1[fa] ^= 1, addedge(fa, i);
    else addedge(i, 2 * N + 1);
  }
  
  for (int i = 1; i <= N; ++i) {
    int fa;
    scanf("%d", &fa);
    if (fa != -1) deg2[fa] ^= 1, addedge(fa + N, i + N);
    else addedge(i + N, 2 * N + 1);
  }

  static int val[MAX_N];
  
  for (int i = 1; i <= N; ++i) {
    if (deg1[i] != deg2[i]) {
      puts("IMPOSSIBLE");
      return 0;
    }
    if (!deg1[i]) addedge(i, i + N), val[i] = cnt;
  }

  puts("POSSIBLE");
  dfs(1);

  for (int i = 1; i <= N; ++i)
    if (!val[i]) printf("0 ");
    else printf("%d ", vis[val[i]] ? 1 : -1);
  puts("");
  return 0;
}


Measured memory_bytes: 13184
#include <iostream>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
typedef complex<double> P;
static const double EPS = 1e-8;

namespace std {
  bool operator<(const P& p, const P& q)
  {
    return abs(p.real() - q.real()) < EPS ? p.imag() < q.imag() : p.real() < q.real();
  }
};

double dot(const P& p, const P& q)
{
  return p.real()*q.real() + p.imag()*q.imag();
}

double cross(const P& a, const P& b)
{
  return imag(conj(a) * b);
}

int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0) {
    return 1; // counter clockwise
  } else if (cross(b, c) < 0) {
    return -1;  // clockwise
  } else if (dot(b, c) < 0) {
    return 2; // c-a-b on line
  } else if (abs(b) < abs(c)) {
    return -2;  // a-b-c on line
  }
  return 0;
}

vector<P> convex(vector<P> ps)
{
  sort(ps.begin(), ps.end());
  const int N = ps.size();
  vector<P> ch(2*N);
  int k = 0;
  // upper
  for (int i = 0; i < N; i++) {
    while (k >= 2 && ccw(ch[k-2], ch[k-1], ps[i]) <= 0) {
      k--;
    }
    ch[k] = ps[i];
    k++;
  }
  // lower
  for (int i = N-2, t = k+1; i >= 0; i--) {
    while (k >= t && ccw(ch[k-2], ch[k-1], ps[i]) <= 0) {
      k--;
    }
    ch[k] = ps[i];
    k++;
  }
  ch.resize(k-1);
  return ch;
}

int main()
{
  int n;
  while (cin >> n && n != 0) {
    vector<P> ps(n);
    for (int i = 0; i < n; i++) {
      char d;
      cin >> ps[i].real() >> d >> ps[i].imag();
    }
    vector<P> c = convex(ps);
    cout << n - c.size() << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define FOR(i,a,b) for (int i=(a),for_##i##_max=(b);i<=(for_##i##_max);++i)
#define RFOR(i,a,b) for (int i=(a),rfor_##i##_min=(b);i>=(rfor_##i##_min);--i)
#define REP(i,n) for (int i=0,rep_##i##_len=(n);i<(rep_##i##_len);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

namespace { // Basics

template<typename T>
void chmin(T &x, T y) {
  x = std::min(x, y);
}

template<typename T>
void chmax(T &x, T y) {
  x = std::max(x, y);
}

template<typename T>
__attribute__((unused))
const auto minimum = static_cast<T const &(*)(T const &, T const &)>(std::min);

template<typename T>
__attribute__((unused))
const auto maximum = static_cast<T const &(*)(T const &, T const &)>(std::max);

template<typename T>
int cmp3(T lhs, T rhs) { return (lhs == rhs) ? 0 : (lhs > rhs) ? 1 : -1; }

template<typename T>
__attribute__((unused))
T constexpr infty = std::numeric_limits<T>::max / 3;
template<>
__attribute__((unused))
auto constexpr infty<int> = 1'100'100'100;
template<>
__attribute__((unused))
auto constexpr infty<long long int> = 100'500'400'300'200'100LL;

using lli = long long int;
using ld = long double;

} // namespace

using namespace std;

int score(vector<int> const &seq, vector<tuple<int,int,int,int>> const &table) {
  int pt = 0;
  for (auto &&row : table) {
    int a, b, c, d; tie(a,b,c,d) = row;
    if (seq[b] - seq[a] == c) {
      pt += d;
    }
  }
  return pt;
}

int main() {
  int N, M, Q;
  cin >> N >> M >> Q;

  vector<tuple<int,int,int,int>> tab;
  REP(i, Q) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    tab.emplace_back(--a, --b, c, d);
  }

  int ans = 0;

  int const F = N + M - 1;
  vector<int> Box(F, 0);
  fill(begin(Box) + M - 1, end(Box), 1);
  do {
    vector<int> a(N);
    for(int i = 0, t = 0, k = 0; i < F; ++i) {
      (Box[i] ? a[t++] : k) = k + 1;
    }
    chmax(ans, score(a, tab));
  } while (next_permutation(begin(Box), end(Box)));

  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3636
def resolve():
    N=int(input())
    A=list(map(int,input().split()))
    A=[0]+A+[0]
    total=sum([abs(A[i+1]-A[i]) for i in range(N+ 1)])

    for i in range(N):
        print(total-(abs(A[i+1]-A[i])+abs(A[i+2]-A[i+1]))+abs(A[i+2]-A[i]))



resolve()

Measured memory_bytes: 14048
sub f{map{push@$_,$_[--$|]for@_=glob}<>;$Y[$_]=$d++;$Y[$_]//&f for@$_;$d--}
@X=@Y,@Y=(),f for(glob<>)[1,2];
$X[$j++]<$_&&\$@[$_]for@Y;
print@@-2

Measured memory_bytes: 166656
#include <stdio.h>
#include <algorithm>
#include <math.h>
using namespace std;
int main()
{
int a[3];
scanf("%d %d %d",&a[0],&a[1],&a[2]);
int x=0;
int y=0;
for(int i=0;i<3;i++)
{
if(a[i]==5){x++;}
if(a[i]==7){y++;}
}
if(x==2&&y==1){printf("YES\n");}
else{printf("NO\n");}
}

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

int main(){
    int N,M,k,ans=0;
    int n;
    int flag=0;
    int i,j;
    int ok=0;
    cin >> N >> M;
    int data[M][N]={};
    int p[M]={};


    for (i = 0; i < M; i++){
        cin >>k;
        for (int j = 0; j < n; j++)data[i][j]=0;
        
        for (j = 0; j < k; j++){
            cin >>data[i][j];
            //data[i][j] -= 1;
        }
        
    }
    for (i = 0; i < M; i++){
        cin >> p[i];
    }

    for(n = 0; n < (1<<N); n++){
        ok=0;
        for (i = 0; i < M; i++){
            flag=0;
            j=0;
            while (data[i][j]>0 && j<N){
                flag += (n>>(data[i][j]-1))%2;
                j++;
            }
            if((flag%2) == p[i])ok++;
        }
        if(ok == M)ans++;
    }
    cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 256
import numpy as np
N = input()
N = int(N)
A = input()
A = A.split()
for i in range(len(A)):
    A[i] = int(A[i])
A = np.array(A)
while True:
    min = np.min(A)
    A = A%min
    B = np.where(A==0)
    C = np.delete(A,B)
    C = np.unique(C)
    A = np.append(C,[min])
    if len(A) == 1:
        break
print(A[0])

Measured memory_bytes: 20152
#include<bits/stdc++.h>
#define rg register
#define il inline
#define vd void
#define ll long long
il int gi(){
    int x=0,f=0;char ch=getchar();
    while(!isdigit(ch))f^=ch=='-',ch=getchar();
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
    return f?-x:x;
}
int f[100010];
int fir[100010],dis[200010],nxt[200010],id;
il vd link(int a,int b){nxt[++id]=fir[a],fir[a]=id,dis[id]=b;}
int ans=0;
il vd dfs(int x,int fa=-1,int fa2=-1){
    f[x]=1;
    for(int i=fir[x];i;i=nxt[i]){
        if(fa==dis[i])continue;
        if(fa2==dis[i])continue;
        dfs(dis[i],x);
        f[x]-=f[dis[i]];
    }
}
int stk[100010],tp;int ins[100010];
int cir[200010],p;
il vd pre_dfs(int x,int lst=-1){
    stk[++tp]=x;ins[x]=tp;
    for(int i=fir[x];i;i=nxt[i]){
        if(lst==dis[i])continue;
        if(ins[dis[i]]){
            for(int j=ins[dis[i]];j<=ins[x];++j)cir[++p]=stk[j];
            return;
        }
        pre_dfs(dis[i],x);
        if(p)return;
    }
    --tp;ins[x]=0;
}
int g[100010];
il vd DFS(int x,int fa=-1,int _f=1){
    f[x]=_f;
    if(x==cir[1])g[x]=1;
    else if(x==cir[2])g[x]=-1;
    for(int i=fir[x];i;i=nxt[i]){
        if(x==cir[1]&&dis[i]==cir[2])continue;
        if(x==cir[2]&&dis[i]==cir[1])continue;
        if(dis[i]==fa)continue;
        DFS(dis[i],x,-_f);
        f[x]+=f[dis[i]];
        g[x]+=g[dis[i]];
    }
}
int s[100010];
int main(){
#ifdef xzz
    freopen("in.in","r",stdin);
    freopen("out.out","w",stdout);
#endif
    int n=gi(),m=gi(),a,b;
    for(int i=1;i<=m;++i)a=gi(),b=gi(),link(a,b),link(b,a);
    if(m==n-1){
        dfs(1);
        for(int i=1;i<=n;++i)ans+=abs(f[i]);
        if(f[1])ans=-1;
        printf("%d\n",ans);
    }else{
        pre_dfs(1);
        for(int i=1;i<=p;++i)cir[i+p]=cir[i];
        cir[0]=cir[p];
        if(p%2==0){
            DFS(1);
			if(f[1])return puts("-1"),0;
			int o=0;
			for(int i=1;i<=n;++i)
				if(g[i]==0)ans+=abs(f[i]);
				else if(g[i]>0)s[++o]=f[i];
				else s[++o]=-f[i];
			s[++o]=0;
			std::sort(s+1,s+o+1);
			for(int i=1;i<=o;++i)ans+=abs(s[(1+o)/2]-s[i]);
        }else{
			for(int i=1;i<=p;++i)dfs(cir[i],cir[i-1],cir[i+1]);
			for(int i=1;i<=n;++i)ans+=abs(f[i]);
			for(int i=1;i<=p;++i)ans-=abs(f[cir[i]]);
            for(int i=1,t=-1;i<p;++i,t=-t)f[cir[p]]+=t*f[cir[i]];
            if(f[cir[p]]%2)return puts("-1"),0;
            f[cir[p]]/=2;
            for(int i=p-1;i;--i)f[cir[i]]-=f[cir[i+1]];
            for(int i=1;i<=p;++i)ans+=abs(f[cir[i]]);
        }
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 7424
from queue import Queue


def main():
    H, W = map(int, input().split())

    white = 0

    grid = [[-1 for _ in range(W + 2)]]
    for _ in range(H):
        line = input()
        white += line.count(".")
        grid.append([-1] + [-1 if char == "#" else -2 for char in line] + [-1])
    grid.append([-1 for _ in range(W + 2)])

    grid[1][1] = 0

    tosearch = Queue()
    tosearch.put((1, 1))

    movement = [(-1, 0), (1, 0), (0, -1), (0, 1)]

    while not tosearch.empty():
        y, x = tosearch.get()

        if (y, x) == (H, W):
            print(white - (grid[H][W] + 1))
            break

        for move in movement:
            ny, nx = y + move[0], x + move[1]

            if grid[ny][nx] == -2:
                grid[ny][nx] = grid[y][x] + 1
                tosearch.put((ny, nx))
    else:
        print(-1)



if __name__ == '__main__':
    main()


Measured memory_bytes: 42728
import java.util.Scanner;
import java.util.Arrays;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int[] A;

        A = new int[3];

        A[0] = sc.nextInt();
        A[1] = sc.nextInt();
        A[2] = sc.nextInt();

        Arrays.sort(A);

        System.out.println(A[0]+" "+A[1]+" "+A[2]);
    }

}



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

int main() {

  int N, K;
  cin >> N >> K;

  int answer = 1;

  for (int i = 0; i < N; i++) {
    if (answer < K) {
      answer *= 2;
    } else {
      answer += K;
    }
  }

  cout << answer << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define pr pair<int,int>
#define mod 1000000007
#define endl "\n"

int power(int a,int b,int m=mod)
{
	if(b==0)	return 1;
	if(b==1)	return a;
	int res=power(a,b/2,m);
	res=(res*res)%m;
	if(b&1)	res=(res*a)%m;
	return res;
}
int modinv(int a,int m=mod){ return power(a,m-2,m);}
int add(int a,int b,int m=mod){	return (a+b)%m;}
int sub(int a,int b,int m=mod){	return (a-b+m)%m;}
int mul(int a,int b,int m=mod){	return (a*b)%m;}



void solve()
{
	string s;
	cin>>s;
	if(s=="ARC")	cout<<"ABC"<<endl;
	else			cout<<"ARC"<<endl;
}

int32_t main()
{
	ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
	int t=1;//cin>>t;
	while(t--)	solve();
	return 0;
}

Measured memory_bytes: 3612
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;


using ll = long long;

#define int ll

using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;



const int N = 2e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 6e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


//template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, a[N], q, sum, cnt[N];
main() {
  file("lala");
  ios;
  cin >> n;
  fo(i, 1, n, 1) cin >> a[i], ++cnt[a[i]], sum += a[i];
  cin >> q;
  while (q--) {
    int b, c;
    cin >> b >> c;
    sum -= cnt[b] * b;
    sum += cnt[b] * c;
    cnt[c] += cnt[b];
    cnt[b] = 0;
    cout << sum << "\n";
  }
  return 0;
}
/**

*/


Measured memory_bytes: 5192
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>

using namespace std;

int main(){

    int A;
    int B;
    int C;
    int D;

    cin >> A >> B >> C >> D;

    if(A*B > C*D){
    	cout << A*B;
    }else if(A*B < C*D){
    	cout << C*D;
    }else{
    	cout << A*B;
    }



	return 0;

}


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

using ListItr_t = std::vector<int>::const_iterator;

bool _isAbleMake(ListItr_t begin, ListItr_t end, int sum, int value) {
    for (auto itr = begin; itr != end; ++itr) {
        if (!_isAbleMake(begin, itr, sum + *itr, value)) { continue; }

        return true;
    }

    return sum == value;
}

bool isAbleMake(const std::vector<int> & list, int value) {
    return _isAbleMake(list.cbegin(), list.cend(), 0, value);
}

void vectorInit(std::vector<int> & vector, int count) {
    vector.reserve(count);
    while (count--) {
        int t;
        std::cin >> t;
        vector.emplace_back(t);
    }
}

int main() {

    int n, q;
    std::vector<int> A, m;

    std::cin >> n;
    vectorInit(A, n);

    std::cin >> q;
    vectorInit(m, q);

    for (auto value : m) {
        if (isAbleMake(A, value)) {
            std::cout << "yes" << std::endl;
        } else {
            std::cout << "no" << std::endl;
        }
    }

    return 0;

}

Measured memory_bytes: 3084
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;

ll n,m;
ll k[15],s[15][15];
ll p[15];
ll ans=0;

void solve(){
   for(int i=0;i<(1<<n);i++){
      bool ok=true;
      for(int j=0;j<m;j++){
         ll cnt=0;
         for(int l=0;l<k[j];l++){
            if(i>>s[j][l]&1) cnt++;
         }
         if(cnt%2!=p[j]) ok=false;
      }
      if(ok) ans++;
   }
   cout<<ans<<endl;
}

int main(){
   cin>>n>>m;
   rep(i,m){
      cin>>k[i];
      rep(j,k[i]){
         cin>>s[i][j];
         s[i][j]--;
      }
   }
   rep(i,m) cin>>p[i];
   solve();
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(pi c, pi d){
	return c.S < d.S;
}

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	string ans = "NO";
	
	REP(i, 1, b+1){
		if(i*a %b == c) ans = "YES";
	}
	cout << ans;

}


Measured memory_bytes: 256
import java.awt.geom.Line2D;
import java.util.*;
public class Main {

	public void doIt(){
		Scanner sc = new Scanner(System.in);
		sc.useDelimiter("[,\\r\\n]+");
		while(sc.hasNext()){
			double [] data = new double[8];
			for(int i=0; i < 8; i++)
				data[i] = sc.nextDouble();
			Line2D.Double ac = new Line2D.Double(data[0], data[1], data[4], data[5]);
			Line2D.Double bd = new Line2D.Double(data[2], data[3], data[6], data[7]);
			if(ac.intersectsLine(bd))
				System.out.println("YES");
			else
				System.out.println("NO");
		}

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

	}

}

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

int main(){
    int a,b;
    cin >> a;
    rep(i,100){
        1000*i;
        int ans;
        ans=a-1000*i;
        if(ans<=0){
            b=i;
            break;
        }
    }
    cout << b*1000-a << endl;;

    return 0;
}

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

db dp[301][301][301];

db fun(int x,int y,int z,int &n)
{
    if(x==0 && y==0 && z==0)return 0;
    if (x<0 || y<0 ||z<0)return 0;
    if(dp[x][y][z]>-0.9)return dp[x][y][z];
    db exp=n+x*fun(x-1,y,z,n)+y*fun(x+1,y-1,z,n)+z*fun(x,y+1,z-1,n);
    return dp[x][y][z]=exp/(x+y+z);
}
void solve()
{
    int n;
    cin>>n;
    int cnt[3]={0,0,0};
    for(int i=0; i<n; i++){
        int s;cin>>s;
        cnt[s-1]+=1;
    }
    memset(dp,-1,sizeof dp);
    fun(cnt[0],cnt[1],cnt[2],n);
    cout<<fixed<<setprecision(10)<<dp[cnt[0]][cnt[1]][cnt[2]];
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t=1;
    while(t--){
        solve();
        cout<<endl;
    }
}


Measured memory_bytes: 216868
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>

using namespace std;
using ll = long long;
using P = pair<int, int>;

const int MOD = 1e9 + 7;
const int MAX = 1e9;
const ll LLMAX = 1e18;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

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

int main() {
    int A, B; cin >> A >> B;
    int ans = A + B;
    if (ans >= 24) ans -= 24;
    cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 3632
module bbb;import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;


void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto M = s[1];
    auto G = new int[][](N);
    foreach (i; 0..M) {
        s = readln.split.map!(to!int);
        G[s[0]-1] ~= s[1]-1;
    }
    s = readln.split.map!(to!int);
    auto S = s[0] - 1;
    auto T = s[1] - 1;

    auto dist = new int[][](N, 3);
    foreach (i; 0..N) dist[i][] = 1 << 29;

    auto q = new BinaryHeap!(Array!(Tuple!(int, int, int)), "a[1] > b[1]");
    q.insert(tuple(S, 0, 0));

    while (!q.empty) {
        auto u = q.front[0];
        auto m = q.front[1];
        auto d = q.front[2];
        q.removeFront;
        if (dist[u][m] <= d) continue;
        dist[u][m] = d;
        foreach (v; G[u]) {
            int nm = (m + 1) % 3;
            int nd = d + (nm == 0);
            if (dist[v][nm] <= nd) continue;
            q.insert(tuple(v, nm, nd));
        }
    }

    writeln (dist[T][0] == 1 << 29 ? -1 : dist[T][0]);
}



Measured memory_bytes: 14120
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(S: str):
    N = len(S)
    ptn1 = [1 if i & 1 else 0 for i in range(N)]
    # print(*ptn1, sep="")
    ans1 = 0
    for i, c in enumerate(S):
        if int(c) != ptn1[i]:
            ans1 += 1
    # print(ans1)
    ptn2 = [0 if i & 1 else 1 for i in range(N)]
    # print(*ptn2, sep="")
    ans2 = 0
    for i, c in enumerate(S):
        if int(c) != ptn2[i]:
            ans2 += 1
    # print(ans2)

    print(min(ans1, ans2))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = str(next(tokens))  # type: int
    solve(S)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4972
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int N, K;
  cin >> N >> K;
  VEC<int> a(N);
  REP(i, 0, N) cin >> a[i];

  int ans = INT32_MAX;
  REPC(rn, 0, K) {
    int ln = K - rn;
    auto rp = lower_bound(ALL(a), 0);
    auto rstart = distance(a.begin(), rp);
    if (rstart + rn -1< N && rstart - ln >= 0) {
      int rdist = rn==0?0:a[rstart + rn-1];
      int ldist = ln==0?0:abs(a[rstart - ln]);
      ans = min({ans, rdist * 2 + ldist, rdist + ldist * 2});
      // DUMP("  ",rdist, ldist);
    }
    // DUMP(rn,ans,rstart);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
n, c = map(int,input().split())

xvl = []
for _ in range(n):
    x,v = map(int,input().split())
    xvl.append((x,v))

get_l = []
sum_v = 0
for x, v in xvl:
    sum_v += v
    get_l.append(sum_v - x)

import itertools
get_l_ac = list(itertools.accumulate(get_l, max))
get_r = []
sum_v = 0
for x, v in xvl[::-1]:
    sum_v += v
    get_r.append(sum_v - (c - x))


ans = 0
x = 0
for i in range(n):
    tmp = 0
    if i > 0:
        x = c - xvl[-i][0]
        tmp += get_r[i-1]
    ans = max(tmp, tmp - x + get_l_ac[n - i - 1], ans)

get_r_ac = list(itertools.accumulate(get_r, max))
x = 0
for i in range(n):
    tmp = 0
    if i > 0:
        x = xvl[i-1][0]
        tmp += get_l[i-1]
    ans = max(tmp, tmp - x + get_r_ac[n - i - 1], ans)

print(ans)

Measured memory_bytes: 28068
#include<bits/stdc++.h>
using namespace std;
const long mod=1e9+7;
long N,memo[111][6][6][6][6];
long rec(int now,int c1,int c2,int c3,int c4){
  // printf("%d %d %d %d %d\n",now,c1,c2,c3,c4);
  if(memo[now][c1][c2][c3][c4]!=-1)return memo[now][c1][c2][c3][c4];
  if(c1==0&&c2==1&&c4==2)return 0;
  if(c1==0&&c3==1&&c4==2)return 0;
  if(c2==0&&c3==1&&c4==2)return 0;
  if(c2==0&&c3==2&&c4==1)return 0;
  if(c2==1&&c3==0&&c4==2)return 0;
  if(now==N)return 1;
  long ans=0;
  for(int i=0;i<4;i++)ans+=rec(now+1,c2,c3,c4,i);
  return memo[now][c1][c2][c3][c4]=ans%mod;
}
int main(){
  cin>>N;
  memset(memo,-1,sizeof(memo));
  cout<<rec(0,4,4,4,4)<<endl;
}


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

int a, b, c, d, e, f;
int dp[3005], dp2[3005];
void go(int now, int arr[]) {
	if (now > f || arr[now])return;
	arr[now] = 1;
	go(now + 100*a, arr); go(now + 100*b, arr);
}
void go2(int now, int arr[]) {
	if (now > f || arr[now])return;
	arr[now] = 1;
	go2(now + c, arr); go2(now + d, arr);
}
int main() {
	scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f);
	go(0, dp); 
	go2(0, dp2);
	double mx = -1;
	int ans = 0, ans2 = 0;
	for (int i = 1; i <= f; i++) {
		if (!dp[i])continue;
		for (int j = 0; i + j <= f; j++) {
			if (!dp2[j])continue;
			double t = 100 * j / (double)(i + j);
			if (mx<t &&  j<= (double)(i/100) * e) {
				mx = t, ans = i, ans2 = j;
			}
		}
	}
	printf("%d %d\n", ans + ans2, ans2);

}

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

int main() {
        int n;
        scanf("%d", &n);
        vector<long long> cur(3);
        rep(i, n) {
                int a, b, c;
                scanf("%d%d%d", &a, &b, &c);
                vector<long long> next(3);
                next[0] = max(cur[1] + a, cur[2] + a);
                next[1] = max(cur[0] + b, cur[2] + b);
                next[2] = max(cur[0] + c, cur[1] + c);
                rep(i, 3) swap(cur[i], next[i]);
        }
        printf("%lld\n", max({cur[0], cur[1], cur[2]}));
        return 0;
}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)

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

struct edge {
	int to,cost;
	edge(int t,ll c):to(t),cost(c) {}
};

int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
int ddx[]={1,1,1,0,-1,-1,-1,0},ddy[]={1,0,-1,-1,-1,0,1,1};

ll mypow(ll x,ll n,ll m) {
	if(n==0) return 1;
	if(n%2==0) return mypow(x*x%m,n/2,m);
	else return x*mypow(x,n-1,m)%m;
}

//-----------------------------------------------------------------------------

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

	int a,b; cin>>a>>b;
	if(a%3==0||b%3==0||(a+b)%3==0) cout<<"Possible"<<endl;
	else cout<<"Impossible"<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
#define fst first
#define snd second
using ll = long long;
using I = pair<int, int>;

int main() {
  int N;
  while (cin >> N) {
    ll x = 1, y = 1;
    for (int i = 0; i < N; i++) {
      ll A, B;
      cin >> A >> B;
      ll k = max((x + A - 1) / A, (y + B - 1) / B);
      x = A * k;
      y = B * k;
    }
    cout << (x + y) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

ll mod(ll a){
  return (a % 1000000007);
}

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


int main(){
  ll n,x; cin >> n >> x; ll cnt = 1; ll sum = 0;
  
  rep(i,n){
    ll d; cin >> d;
    
    sum += d;
    
    if(x >= sum) cnt++;
    else break;
  }
  
  cout << cnt << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Linq;
using static System.Math;

class Program
{
    static void Main()
    {
        char[] s = Console.ReadLine().ToCharArray();
        int ans = 0;
        foreach (var c in s) ans += (int)Char.GetNumericValue(c);
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long n;
  cin >> n;
  long long sq = sqrt(n);
  long long ans = 1e12+7;
  if(sq<2 ) {
  	cout << n-1<<endl;
  	return 0;
  }
  bool flag=false;
  for(long long i=2; i<=sq; ++i) {
  	if(n%i!=0) continue;
	long long r = i;
  	long long c = n/i;
	flag=true;
  	ans = min(ans, r-1+c-1);
  }
  if(flag) cout << ans <<endl;
  else cout << n-1<<endl;
  return 0;
}

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

int main(){
    int n; cin >> n;
    vector<ll> a;
    for(int i=0; i<n; i++){
        ll tmp = 0; cin >> tmp;
        a.push_back(tmp);
    }
    sort(a.rbegin(), a.rend());
    ll max_1=0, max_2=0;
    for(int i=1; i<a.size(); i++){
        if(a[i]==a[i-1]){
            if(max_1==0) max_1 = a[i];
            else if(max_2==0) max_2 = a[i];
            i++;
        }
        if(max_1!=0 && max_2!=0) break;
    }
    cout << max_1*max_2 << endl;
    return 0;
}

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

int main(){
    
    int value = 700;
    string S;

    cin >> S;

    if(S[0] == 'o') value += 100;
    if(S[1] == 'o') value += 100;
    if(S[2] == 'o') value += 100;

    cout << value << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    static Scanner scanner = new  Scanner(System.in);
    static long mod = 1000000007;

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int[] before = new int[n];
        Map<Integer, List<Integer>> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            int c = scanner.nextInt();
            map.computeIfAbsent(c, key -> new ArrayList<>()).add(i);
        }
        for (List<Integer> list : map.values()) {
            Collections.sort(list);
            before[list.get(0)] = -1;
            for (int i = 1; i < list.size(); i++) {
                before[list.get(i)] = list.get(i - 1);
            }
        }
        long[] dp = new long[n + 1];
        dp[0] = 1;
        for (int i = 1; i <= n; i++) {
            dp[i] = dp[i - 1];
            if (before[i - 1] != -1 && before[i - 1] + 1 < i - 1) {
                dp[i] = (dp[i] + dp[before[i - 1] + 1]) % mod;
            }
        }
        System.out.println(dp[n]);
    }
}

Measured memory_bytes: 118692