akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin >> s;
	int x,y;
	cin >> x >> y;
	int n = s.size();
	int st = -1;
	bool tfound = false;
	for (int q = 0; q < n; q++)
	{
		if (s[q] == 'T')
		{
			tfound = true;
			st = q;
			break;
		}
	}
	if (!tfound)
	{
		x -= n;
		if (x == 0 && y == 0)
		{
			cout << "Yes\n";
		}
		else
		{
			cout << "No\n";
		}
		return 0;
	}
	else
	{
		x -= st;
	}
	vector<vector<int>> blocks(2);
	int cur = 0;
	int len = 0;
	for (int q = st; q < n; q++)
	{
		if (s[q] == 'T')
		{
			if (len > 0)
			{
				blocks[cur].push_back(len);
				len = 0;
			}
			cur^=1;
		}
		else
		{
			len++;
		}
	}
	if (s[n-1] == 'F' && tfound)
	{
		blocks[cur].push_back(len);
	}
	int xtot = 0, ytot = 0;
	int xsz = blocks[0].size();
	int ysz = blocks[1].size();
	for (int q = 0; q < xsz; q++)
	{
		xtot += -blocks[0][q];
		blocks[0][q] *= 2;
	}
	for (int q = 0; q < ysz; q++)
	{
		ytot += -blocks[1][q];
		blocks[1][q] *= 2;
	}
	int xneed = x - xtot;
	int yneed = y - ytot;
	if (xneed < 0 || yneed < 0)
	{
		cout << "No\n";
		return 0;
	}
	vector<vector<bool>> xdp (xneed+1, vector<bool>(xsz+1));
	vector<vector<bool>> ydp (yneed+1, vector<bool>(ysz+1));
	xdp[0][0] = true;
	ydp[0][0] = true;
	for (int q = 1; q <= xsz; q++)
	{
		for (int w = 0; w <= xneed; w++)
		{
			xdp[w][q] = xdp[w][q-1];
		}
		for (int w = 0; blocks[0][q-1]+w<=xneed; w++)
		{
			if (xdp[w][q-1])
			{
				xdp[w+blocks[0][q-1]][q] = true;
			}
		}
	}
	for (int q = 1; q <= ysz; q++)
	{
		for (int w = 0; w <= yneed; w++)
		{
			ydp[w][q] = ydp[w][q-1];
		}
		for (int w = 0; blocks[1][q-1]+w<=yneed; w++)
		{
			if (ydp[w][q-1])
			{
				ydp[w+blocks[1][q-1]][q] = true;
			}
		}
	}
	if (xdp[xneed][xsz] && ydp[yneed][ysz])
	{
		cout << "Yes\n";
	}
	else
	{
		cout << "No\n";
	}
	return 0;
}


Measured memory_bytes: 5536
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String[] n = scan.next().split("");
        scan.close();

        long sum = 0;
        for (int i = 0; i < n.length; i++) {
            sum += Long.parseLong(n[i]);
        }

        if (sum % 9 == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }
}


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

namespace ABC117
{
    class B
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            List<int> L = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
            L.Sort();
            int lmax = L[N - 1];
            int sum = L.Sum() - lmax;
            string r = "No";
            if (sum > lmax) r = "Yes";
            
            Console.WriteLine(r);

        }

    }
}


Measured memory_bytes: 13396
<?php
 
fscanf(STDIN, "%d %d", $N, $M);
$A = trim(fgets(STDIN));

$arrayA = explode(" ", $A);
$answer = "Yes";
$totalVotes = array_sum($arrayA);
$lowerLimit = $totalVotes / (4 * $M);

$result =array_filter($arrayA, function($a) use($lowerLimit) {
  return $a >= $lowerLimit;
});

if (count($result) < $M) {
  $answer = "No";
}

echo $answer;

Measured memory_bytes: 16280
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#include <iomanip>
#include <queue>
#include <stack>

using namespace std;

typedef long long ll;

int main() {
    ll a, b, c, d;  cin >> a >> b >> c >> d;
    cout << max(max(a*c, a*d), max(b*c, b*d)) << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll a, b, c;
    cin >> a >> b >> c;

    ll res = max(0LL, c - (a - b));
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] line = br.readLine().split(" ");
		int a = Integer.parseInt(line[0]);
		int b = Integer.parseInt(line[1]);
		ArrayList<String> array = new ArrayList<String>();

		for (int i = 0; i < a; i++) {
			array.add(br.readLine());
		}

		for (int i = 0; i < b + 2; i++) {
			System.out.print("#");
		}

		System.out.println("");

		for (int i = 0; i < a; i++) {
			System.out.println("#" + array.get(i) + "#");
		}

		for (int i = 0; i < b + 2; i++) {
			System.out.print("#");
		}
		System.out.println("");
	}
}

Measured memory_bytes: 21972
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;



signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, K; cin >> N >> K;
	VI F(N, 0);
	REP(i, K) {
		int d; cin >> d;
		REP(j, d) {
			int a; cin >> a; a--;
			F[a]++;
		}
	}
	int ans = 0;
	REP(i, N)if (F[i] == 0)ans++;
	cout << ans << endl;
	return 0;
}



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

void solve() {
    int n;
    cin>>n;
    int ba = 0,a = 0,b = 0;
    int ret = 0;
    for(int i=0;i<n;++i) {
        string s;
        cin>>s;
        for(int j = 0;j<s.size();++j) {
            if(j+1<s.size() && s[j]=='A' && s[j+1]=='B') {
                ++ret;
            }
        }
        if(s[0]=='B' && s.back()=='A') {
            ++ba;
        } else if(s[0]=='B') {
            ++b;
        } else if(s.back()=='A'){
            ++a;
        }
    }
    if(ba>1) {
        ret += ba-1;
    }
    if(ba>0) {
        if(b>0) {
            ++ret;
            --b;
        }
        if(a>0) {
            ++ret;
            --a;
        }
    }
    ret += min(a,b);
    printf("%d\n", ret);
}

int main(){
    //freopen("input.txt","r",stdin);
    solve();
}


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

priority_queue<int, vector<int >, greater<int > > q;
int ans = 0;

int main() {
	for (int i = 1; i <= 3; ++i) {
		int t;
		scanf("%d", &t);
		q.push(t);
	}
	ans += q.top(); q.pop(); ans += q.top();
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#define maxn 100010
using namespace std;
int e[4][2]={{0,1},{1,0},{-1,0},{0,-1}};
int n,step;
struct node{int t,x,y;}q[maxn];
int abs(int x){
	if(x<0)return -x;
	return x;
}
int main(){
	scanf("%d",&n);
	int x,y,z;
	for(int i=1;i<=n;i++)scanf("%d%d%d",&q[i].t,&q[i].x,&q[i].y);
	for(int i=1;i<=n;i++){
		step=0;
		int dis=abs(q[i].x-q[i-1].x)+abs(q[i].y-q[i-1].y);
		int cha=q[i].t-q[i-1].t;
		if((dis>cha)||((cha-dis)&1)){puts("No");return 0;}
		if((dis==cha)||!((cha-dis)&1))continue;
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 1408
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		if(M % 2 == 1){
			Console.WriteLine(-1);
			return;
		}
		
		List<int>[] E = new List<int>[N];
		for(int i=0;i<N;i++) E[i] = new List<int>();
		for(int i=0;i<M;i++){
			E[A[i]].Add(i);
			E[B[i]].Add(i);
		}
		Func<int,int,int> Nxt = (e, v) => A[e] == v ? B[e] : A[e];
		
		int[] aout = new int[M];
		int[] ain = new int[M];
		for(int i=0;i<M;i++){
			aout[i] = A[i];
			ain[i] = B[i];
		}
		
		int root = 0;
		var q = new Queue<int>();
		int[] min = new int[N];
		for(int i=0;i<N;i++) min[i] = -1;
		
		min[root] = 0;
		q.Enqueue(root);
		while(q.Count > 0){
			var now = q.Dequeue();
			foreach(var e in E[now]){
				var nxt = Nxt(e, now);
				if(min[nxt] == -1){
					min[nxt] = min[now] + 1;
					aout[e] = ain[e] = -1;
					q.Enqueue(nxt);
				}
			}
		}
		
		int[] ord = new int[N];
		for(int i=0;i<N;i++) ord[i] = i;
		Array.Sort(ord, (i, j) => min[i].CompareTo(min[j]) * -1);
		
		foreach(var now in ord){
			int pe = -1;
			int ind = 0;
			int oud = 0;
			foreach(var e in E[now]){
				if(aout[e] == now) oud++;
				if(ain[e] == now) ind++;
				if(aout[e] == -1) pe = e;
			}
			if(pe == -1){
				// root;
				continue;
			}
			if(oud % 2 == 0){
				aout[pe] = Nxt(pe, now);
				ain[pe] = now;
			} else {
				ain[pe] = Nxt(pe, now);
				aout[pe] = now;
			}
		}
		
		for(int i=0;i<M;i++){
			Console.WriteLine("{0} {1}",aout[i] + 1, ain[i] + 1);
		}
		
		
		
	}
	int N,M;
	int[] A,B;
	public Sol(){
		var d = ria();
		N = d[0]; M = d[1];
		A = new int[M];
		B = new int[M];
		for(int i=0;i<M;i++){
			d = ria();
			A[i] = d[0] - 1; B[i] = d[1] - 1;
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

int main() {
    int N;
    cin >> N;
    
    string s;
    int k = 3;
    
    for (int i=0; i<N; i++){
        cin >> s;
        if (s=="Y") k=4;
    }
    if (k==3) cout << "Three" << endl;
    if (k==4) cout << "Four" << endl;
}


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

int main() {
  int n;
  cin >> n;
  if (n % 2 == 0) cout << 1.0 / 2.0 << endl;
  else {
    long double k = n / 2 + 1;
    long double l = k / n;
    cout << fixed << setprecision(7) << l << endl;
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
#include <unordered_map>
unordered_map<ll,ll> dp[51];
int main(){
    int n, k;
    ll s, t;
    cin >> n >> k >> s >> t;
    dp[0][(1<<18)-1] = 1;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        for(int j = k - 1; j >= 0; j--){
            for(auto &y : dp[j]){
                dp[j+1][(((y.first >> 18)|x)<<18 )+ (y.first & x)] += y.second;
            }
        }
    }
    ll ans = 0;
    for(int i = 1; i <= k; i++){
        ans += dp[i][(t<<18) + s];
    }
    cout << ans << endl;
}


Measured memory_bytes: 107424
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;


int main ()
{
    int n,k;
    scanf("%d %d",&n,&k);
    int i;
    if(n>=k)
    {
        int arr[n];
    for(i=0; i<n; ++i)
    {
        scanf("%d",&arr[i]);
    }
    sort(arr,arr+n);
    int s=0;
    for(i=0; i<k; ++i)
    {
        s+=arr[i];
    }
    printf("%d\n",s);
    }
}


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

int main() {
  long n;
  bool bo=true;
  cin >> n;
  vector<long> b(n);
  vector<long> x(n);
  vector<long> ans;
  for(long i=0;i<n;i++) cin >> b[i];

  for(long i=0;i<n;i++) x[i]=i+1;

  while(bo) {
    bo=false;
    for(long i=n-1;i>=0;i--) {
      if(b[i]==x[i]) {
        bo=true;
        ans.push_back(x[i]);
        for(long j=i;j<n;j++) {
          x[j]--;
        }
        break;
      }
    }
  }

  if(ans.size()==n) for(long i=ans.size()-1;i>=0;i--) cout << ans[i] << endl;
  else cout << -1 << endl;
}

Measured memory_bytes: 3564
// Copyright 2017 wu_qing
#include <stdint.h>
#include <cstdio>
#include <algorithm>
const int N = 2e5 + 10;
int n, l[N], r[N], b[N], cnt;
int64_t k, a[N], p[N], tot, pre = 1;
bool cmp(int a, int b) {
    return p[a] < p[b];
}
inline int lowbit(int x) {
    return x & (-x);
}
inline int q(int x) {
    int ans = 0;
    for (; x; x -= lowbit(x)) ans += b[x];
    return ans;
}
inline void c(int x, int delta) {
    for (; x < N; x += lowbit(x)) b[x] += delta;
}
int main() {
    scanf("%d%lld", &n, &k);
    for (int i = 1; i <= n; i++) {
        scanf("%lld", a + i);
        a[i] -= k;
        p[i] = p[i - 1] + a[i];
    }
    for (int i = 0; i <= n; i++)
        l[i] = i;
    std::sort(l, l + n + 1, cmp);
    for (int i = 0; i <= n; i++) {
        if (p[l[i]] == pre) {
            r[l[i]] = cnt;
        } else {
            r[l[i]] = ++cnt;
            pre = p[l[i]];
        }
    }
    for (int i = 0; i <= n; i++) {
        tot += q(r[i]);
        c(r[i], 1);
    }
    printf("%lld\n", tot);
    return 0;
}


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

int main(){
   int n, c=0;
   cin>>n;
   int a[n];
   for(int i=0; i<n; i++) cin>>a[i];
   sort(a, a+n);
   //set<vector<int>> st;
   //vector<int> tmp;
   for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++)
        for(int k=j+1; k<n; k++)
        if(a[i]!=a[k] && a[j]!=a[k] && a[j]!=a[i] && a[i]+a[j]>a[k]  ) c++;
   }
   cout<<c;
}


Measured memory_bytes: 3612
#include <iostream>
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <numeric>
#include <vector>
#include <cmath>
using namespace std;



int main(){
    long long n; cin >> n;
    long long sum = 0;

    for(long long x = 1; x<=n; x++){
        if(x%3==0 && x%5==0){
           continue;
        }else if(x%3== 0 && x%5!=0 ){
            continue;
        }else if(x%3!=0 && x%5==0){
            continue;
        }else{
            sum+=x;
        }
    }

    cout << sum << endl;

}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define ll long long
#define mp make_pair
using namespace std;
int ecnt[334334],wcnt[334334];
int main(){
	int n;
	cin>>n;
	string st;
	cin>> st;
	for(int i=1;i<=n;i++){
		if(st[i-1]=='W'){
			wcnt[i] = wcnt[i-1]+1;
			ecnt[i] = ecnt[i-1];
		}
		else{
			wcnt[i] = wcnt[i-1];
			ecnt[i] = ecnt[i-1]+1;
		}
	}
	int ans = mod;
	for(int i=1;i<=n;i++){
		int cur = wcnt[i-1] + ecnt[n] - ecnt[i];
		if(ans > cur) ans =cur;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3076
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())


N,M = MI()

if N % 2 == 1:
    for i in range(M):
        print(i+1,N-i)
else:
    if N % 4 == 0:
        for i in range(min(M,N//4)):
            print(i+1,N-i)
        if M > N//4:
            for i in range(M-N//4):
                print(N//4+i+1,(3*N)//4-i-1)
    else:
        for i in range(min(M,N//4)):
            print(i+1,N-i)
        if M > N//4:
            for i in range(M-N//4):
                print(N//4+i+1,N-N//4-i-1)


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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<ll> A(n);
	ll a;
	for (int i = 0; i < n; ++i) {
		cin >> a;
		a -= i + 1;
		A[i] = a;
	}

	sort(A.begin(), A.end());
	ll med;
	if (n % 2 == 0) {
		med = (A[n / 2 - 1] + A[n / 2]) / 2;
	}
	else {
		med = A[(n - 1) / 2];
	}
	ll ans = 0;
	for (int i = 0; i < n; ++i) {
		ans += abs(A[i] - med);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  string S , T;
  cin >> S >> T;
  int A ,B ;
  cin >> A >> B;
  string U;
  cin >> U;
    
  if (U.compare(S) == 0) {
     A = A -1; 
  }
  else if (U.compare(T) == 0) {
    B = B -1;
  }
  
  cout << A << " " << B;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <unordered_map>
#include <queue>
// g++ -std=c++11 -o2 -Wall filename.cpp -o filename
#define hell 1000000009
#define bug1(x) cout<<"$ "<<x<<" $"<<endl
#define bug2(x) cout<<"% "<<x<<" %"<<endl
#define bug3(x) cout<<"# "<<x<<" #"<<endl
#define ll long long
#define pb push_back
#define mp make_pair
#define tr(z) for(auto it=z.begin(); it!=z.end(); it++)
#define rloop(i,a,b) for(long long i=a; i>=b;i--)
#define loop(i,a,b) for(long long i=a; i<b; i++)
#define vbool vector< bool >
#define vvbool  vector< vector<bool> >
#define vchar vector<char>
#define vi vector<int>
#define vvi vector< vector<int> >
#define pll pair<long long, long long>
#define vll vector<long long>
#define vvl vector< vector<long long> >
#define ninf numeric_limits<long long>::min()
#define pinf numeric_limits<long long>::max()
#define comp(a,b) (abs(a-b)<1e-9) // to compare doubles
using namespace std;

int N, C;
vll V(N), W(N);
vvl dp;

ll helper(ll i, ll cur_C) {
    if (cur_C <= 0) {
        return 0;
    }
    if (i < 0) return 0;

    if (dp[i][cur_C]) {
        return dp[i][cur_C];
    }
    if (cur_C - W[i] < 0) {
        return dp[i][cur_C] = helper(i - 1, cur_C);
    }
    return dp[i][cur_C] = max(helper(i - 1, cur_C), helper(i - 1, cur_C - W[i]) + V[i]);
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int N, C;
    cin >> N >> C;
    V.resize(N);
    W.resize(N);
    dp = vvl(N+1, vll(C + 1));
    loop(i, 0, N) {
        cin >> W[i] >> V[i];
    }

    //cout << helper(N - 1, C);

    for (int i = 0; i <= N; ++i) {
        for (int j = 0; j <= C; ++j) {
            if (i == 0 || j == 0) {
                dp[i][j] = 0;
            }
            else if (j - W[i - 1] < 0) {
                dp[i][j] = dp[i - 1][j];
            }
            else {
                dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - W[i-1]] + V[i-1]);
            }
        }
    }/*
    loop(i, 0, N + 1) {
        loop(j, 0, C + 1) {
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }
    */
    cout << dp.back().back() << endl;

    //cout << dp[C] << "\n";
    return 0;
}


Measured memory_bytes: 80256
#include <bits/stdc++.h>
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;
 
#define endl '\n'
#define loop(i, m, n) for (lli i = m; i < n; i++)
#define loope(i, m, n) for (lli i = m; i <= n; i++)
#define epool(i, m, n) for (lli i = m; i >= n; i--)
#define pool(i,m,n) for(lli i=m; i>n; i++)
#define maxe *max_element
#define mine *min_element
#define plli pair<lli, lli>
#define mod 1000000007
#define mod2 998244353
#define vt vector<lli>
#define fi first
#define se second
#define pb push_back
#define umap unordered_map
#define mmap multimap
#define mpp make_pair
#define inp1(a) cin >> a
#define inp2(a, b) cin >> a >> b
#define inp3(a, b, c) cin >> a >> b >> c
#define inp4(a, b, c, d) cin >> a >> b >> c >> d
#define inp5(a, b, c, d, e) cin >> a >> b >> c >> d >> e
#define inp6(a, b, c, d, e, f) cin >> a >> b >> c >> d >> e >> f
#define pr0() cout << " "
#define pr1(a) cout << a << " "
#define pr2(a, b) cout << a << " " << b << " "
#define pr3(a, b, c) cout << a << " " << b << " " << c << " "
#define pr4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << " "
#define emp emplace //used to push a pair etc..
#define empf emplace_front
#define empb emplace_back
#define ret(x) return cout << x, 0;
#define all(v) v.begin(),v.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
//especially for deque both sides dynamic
#define pf push_front
//list doubly linked lists can insert at mid. splice fn can be used
#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
using namespace std;
 
lli gcd(lli a, lli b){
    if(a==0) return b;
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
 
lli lcm(lli a, lli b){
    return (a * b) / gcd(a, b);
}
 
lli modi(lli n,lli m=mod){ 
    if(n==0) return 0;
    n%=m;
    n+=m;
    n%=m;
    return n;
}
 
lli mpow(lli base, lli exp){
    base %= mod;
    lli result = 1;
    while (exp > 0){
        if (exp & 1)
            result = ((lli)result * base) % mod;
        base = ((lli)base * base) % mod;
        exp >>= 1;
    }
    return result;
}
const lli INF=1e18;
const lli N=2e5+5;
const ldb pi=4*atan(1);

lli n,m,k,t;
//lli a,b,c,d;
lli p,q,l,r;
lli arr[N];
//lli a[N],b[N],c[N],d[N];
lli a,b,c,d;
lli x[1000005],y[1000005];
map<char,lli> m1,m2;
string s,s1,s2,s3;
vector<lli> v,v1,v2;
lli pre[N],suff[N];
//lli vis[N]={0};
char grid[11][11];
vector<pair<lli,lli>> pl;

bool sortbysec(const pair<lli,lli> &a, pair<lli,lli> &b){
    return (a.se>b.se);
}

int32_t main(){
    fast_io
    lli i = 0,j=0;
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cout << fixed << setprecision(22);
    

    cin >> n;
    cout << 2*pi*n << endl;


}

Measured memory_bytes: 3812
def gcd(x, y):
    m = max(x, y)
    n = min(x, y)
    if m % n == 0:
        return n
    else:
        return gcd(n, m%n)
def lcm(x, y):
    return (x * y) // gcd(x, y)

A , B = tuple(list(map(int, input().split(' '))))
if A == 1 or B == 1:
    print(max(A, B))
else:
    print(lcm(A, B))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int x; cin >> x;
    int ans = 1;
    for(int b = 2; b <= x; ++b){
        int tmp = b*b;
        while(tmp <= x){
            ans = max(ans, tmp);
            tmp *= b;
        }
    }
    cout << ans << endl;
}

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

using namespace std;

int main() {
	int n;
	while (cin >> n) {
		if (n == 0) {
			break;
		}
		vector<int> data(n);
		int a;
		for (int i = 0; i < n; i++) {
			cin >> a;
			if (i % 2 == 0) {
				data[i] = a;
			} else {
				if (data[i-1] == a) {
					data[i] = a;
				} else {
					for (int j = i-1; j >= 0; j--) {
						if (data[j] != a) {
							data[j] = a;
						} else {
							break;
						}
					}
					data[i] = a;
				}
			}
		}
		int counter = 0;
		for (int i = 0; i < n; i++) {
			if (data[i] == 0) {
				counter++;
			}
		}
		cout << counter << endl;
	}
	return 0;
}

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

int main() {

	int D;
	cin >> D;

	switch (D) {
		case 25:	
		cout << "Christmas" << endl;
		break;

		case 24:
		cout << "Christmas Eve" << endl;
		break;

		case 23:
		cout << "Christmas Eve Eve" << endl;
		break;

		case 22:
		cout << "Christmas Eve Eve Eve" << endl;
		break;
	
	
	}


}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#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 ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;

int main(){
    ll k=0,x=0,c=0,d=0,n=1,i=1;
    //VI a(N);
    string s,s1,s2;
    cin >> k >> x; 
    
    while(k-n){
        cout << x - k + n << " ";   
        n++;  
    }
    cout << x << " ";
    n=k-1;
    while(n){
        cout << x + k - n << " ";   
        n--;  
    }

    
    return 0;
}


Measured memory_bytes: 256
points :: [String] -> (Int, Int)
points [s1, s2]
  | s1 > s2   = (3, 0)
  | s1 < s2   = (0, 3)
  | otherwise = (1, 1)

addPoints :: (Int, Int) -> (Int, Int) -> (Int, Int)
addPoints (x, y) (x', y') = (x+x', y+y')

sumPoints :: [[String]] -> (Int, Int)
sumPoints = foldl (\a b -> addPoints a $ points b) (0, 0)

main :: IO ()
main = do
    points <- getLine >> getContents >>= return . sumPoints . map words . lines
    putStrLn $ show (fst points) ++ " " ++ show (snd points)


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

int main() {
  int D; cin >> D;
  int N = 26;
  int C[N]; for (int i = 0; i < N; i++) cin >> C[i];
  int S[D][N];
  for (int d = 0; d < D; d++) {
    for (int i = 0; i < N; i++) {
      cin >> S[d][i];
    }
  }
  int L[N]; for (int i = 0; i < N; i++) L[i] = -1000;
  for (int d = 0; d < D; d++) {
    int max_select = -1, max_num = -1e+9;
    for (int i = 0; i < N; i++) {
      int num = S[d][i];
      if (L[i] >= 0) num += L[i] * C[i];
      if (num > max_num) {
        max_select = i; max_num = num;
      }
    }
    cout << max_select + 1 << endl;
    L[max_select] = 0;
    for (int i = 0; i < N; i++) L[i]++;
  }
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define int int64_t
#define pcnt __builtin_popcount
#define pb push_back
#define ALL(x) (x).begin(),(x).end()
#define vec vector<int>
#define mat vector<vector<int>> //mat データ名(縦,vec(横));
#define F first
#define S second
int INF = 1000000000000000001; //10^18+1
int MOD = 1000000007; //10^9+7
//cout << fixed << setprecision(15); (小数点以下表示)

signed main () {
  int A,B,C,K,ans=0,cnt;
  cin >> A >> B >> C >> K;
  cnt=K;
  ans+=min(A,cnt);
  cnt-=A;
  cnt-=B;
  if(cnt>0)ans-=cnt;
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <numeric>
#include <climits>
#include <math.h>
#include <memory.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;
int N, M;
int cnt = 0;
ll ans = 0LL;
int i_index;
ll tmp;
int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};
string board[64];
int main(){
  int a, b;
  cin >> a >> b;
  cnt += a - 1;
  if(b >= a)
    cnt++;
  cout << cnt << endl;
}



Measured memory_bytes: 256
S = input()
low = int(S) % 100
high = (int(S) - low) / 100

if high == 0:
  if low == 0:
    print('NA')
  elif 1 <= low <= 12:
    print('YYMM')
  else:
    print('NA')
elif 1 <= high <= 12:
  if low == 0:
    print('MMYY')
  elif 1 <= low <= 12:
    print('AMBIGUOUS')
  else:
    print('MMYY')
else:
  if low == 0:
    print('NA')
  elif 1 <= low <= 12:
    print('YYMM')
  else:
    print('NA')

Measured memory_bytes: 3064
package main

import (
        "fmt"
)

func solution(s string) string {
        switch s {
        case "Sunny":
                return "Cloudy"
        case "Cloudy":
                return "Rainy"
        default:
                return "Sunny"
        }
}

func main() {
        var s string
        fmt.Scan(&s)
        fmt.Println(solution(s))
}

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

#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#define endl "\n"
#define all(V) V.begin( ), V.end( )
#define Unique(V) sort( all( V ) ), V.erase( unique( all( V ) ), V.end() )
#define Check( N , p ) ( !( ( N & ( 1LL << p ) ) == 0 ) )
#define ON( N , p ) ( N = N | ( 1LL << p ) )
#define OFF( N , p ) ( N = N & ~( 1LL << p ) )
std::mt19937 rng( chrono::steady_clock::now().time_since_epoch().count() );
#define rnd(a, b) ((((rand() << 15) ^ rand()) % ((b) - (a) + 1)) + (a))
#define ran(a, b) rng() % ( (b) - (a) + 1 ) + (a)
#define trace(...) __f( #__VA_ARGS__ , __VA_ARGS__ )
template < typename Arg1 >
void __f( const char* name , Arg1&& arg1 ) { cerr << name << " : " << arg1 << "\n"; }
template < typename Arg1 , typename... Args >
void __f( const char* names , Arg1&& arg1 , Args&&... args ) {
const char* comma = strchr( names + 1 , ',' );
cerr.write( names , comma - names ) << " : " << arg1 << " , " ; __f( comma + 1 , args... ); }
typedef long long int LL;
typedef pair <int,int> pii;
typedef pair <long long,long long> pll;
const int MOD = 1e9 + 7;
const double EPS = 1e-8;
const int N = 1e5 + 5;
const int inf = 1e9;
const long long INF = 1e18;

int n;
int a[ N ][ 5 ];
int dp[ N ][ 5 ];

int main( int argc , char const *argv[] ) {
        ios_base::sync_with_stdio( false ); cin.tie( nullptr );
        cin >> n;
        for( int i = 1; i <= n; i++ ) {
                for( int j = 1; j <= 3; j++ ) {
                        cin >> a[i][j];
                }
        }
        for( int i = 1; i < N; i++ ) for( int j = 1; j <= 3; j++ ) dp[i][j] = -inf;
        /// dp[i][j] -> max gain in first i days doing task j on i'th day
        dp[0][1] = 0 , dp[0][2] = 0 , dp[0][3] = 0;
        for( int i = 1; i <= n; i++ ) {
                if( i == 1 ) {
                        dp[1][1] = a[1][1];
                        dp[1][2] = a[1][2];
                        dp[1][3] = a[1][3];
                }
                else {
                        dp[i][1] = max( dp[i-1][2] , dp[i-1][3] ) + a[i][1];
                        dp[i][2] = max( dp[i-1][1] , dp[i-1][3] ) + a[i][2];
                        dp[i][3] = max( dp[i-1][2] , dp[i-1][1] ) + a[i][3];
                }
        }
        //trace( dp[n][1] , dp[n][2] , dp[n][3] );
        cout << max( dp[n][1] , max( dp[n][2] , dp[n][3] ) ) << endl;
        return 0;
}













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

	rep(i, k) { ans += p[i]; }
	cout<<ans<<endl;
}

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

//.define
// #define FILE_IN_OUT
#define RET(_x)    return cout << (_x) << '\n', 0;
#define all(_obj)  (_obj).begin(), (_obj).end()
#define loop(_n)   for (int i = 0; i < (_n); ++i)
#define sz(_obj)   static_cast<int>((_obj).size())
#ifdef SHJ_LOCAL
#define debug(_x)  std::cerr << (#_x) << " = " << (_x) << '\n' << std::flush;
#else
#define debug(_x)  {}
#endif
#define endl "\n"
template<typename P, typename Q>
P CeilDiv(P _dividend, Q _divider) {
    return static_cast<P>((_dividend - 1LL + _divider) / _divider);
}
template<typename Tp>
inline void outarr(Tp _begin, Tp _end, const char* _delim = " ") {
    for (Tp current = _begin; current != _end; ++current) {
        std::cout << *current << _delim;
    }
    std::cout << '\n';
}

//.constant
using ll  = long long;
using pii = std::pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr int MOD = static_cast<const int>(1e9 + 7);

//.data
class FenwickTree {
public:
    explicit FenwickTree(int n) : tree(n, 0) {
    }

    void Update(int i, int x) {
        for (; i < sz(tree); i |= i + 1) {
            tree[i] += x;
        }
    }

    int Sum(int r) {
        int res = 0;
        for (; r >= 0; r = (r & (r + 1)) - 1) {
            res += tree[r];
        }
        return res;
    }

    int Sum(int l, int r) {
        return Sum(r) - Sum(l - 1);
    }

private:
    vector<int> tree;
};

struct Query {
    int L;
    int R;
    int ID;

    Query(int l, int r, int id) : L(l), R(r), ID(id) {
    }
};

//.code
int main() {
#ifdef FILE_IN_OUT
    std::ifstream cin ("input.txt",  std::ios::in);
    std::ofstream cout("output.txt", std::ios::out);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif

    int n, q;
    cin >> n >> q;
    vector<int> arr(n);
    loop(n) {
        cin >> arr[i];
        --arr[i];
    }
    vector<int> last(n, -1);
    vector<Query> query;
    loop(q) {
        int l, r;
        cin >> l >> r;
        --l; --r;
        query.emplace_back(l, r, i);
    }
    sort(all(query), [](const Query& lhs, const Query& rhs) {
        return lhs.R < rhs.R;
    });
    vector<int> ans(q);
    FenwickTree ft(n);
    int cur = -1;
    for (auto [l, r, i] : query) {
        while (cur < r) {
            ++cur;
            if (last[arr[cur]] != -1) {
                ft.Update(last[arr[cur]], -1);
            }
            ft.Update(cur, 1);
            last[arr[cur]] = cur;
        }
        ans[i] = ft.Sum(l, r);
    }
    outarr(all(ans), endl);

#ifdef FILE_IN_OUT
    cin.close();
    cout.close();
#endif
    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define pb emplace_back

using namespace std;
using ll = long long;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

int main()
{
    string s;
    cin >> s;
    int ans = INF;
    for(int i = 0; i < s.size()-2; i++){
        int num = (s[i]-'0')*100+(s[i+1]-'0')*10+s[i+2]-'0';
        ans = min(ans,abs(753-num)); 
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define endl "\n"
#define pi 3.14159265358979323846264338327950288
#define MOD 1000000007
#define INF -100000000000000
#define ordered_set tree<pair< ll int ,ll  int>, null_type,less<pair<ll int, ll int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
using namespace std;
#define lld long double
using namespace __gnu_pbds;
int main()
{
    fast;
    ll int n;
    cin>>n;
    string s;
    cin>>s;
    ll int i,r=0,w=0,c=0;
    for(i=0;i<n;i++)
    {
        if(s[i]=='R')
            r++;
        else
            w++;
    }
    for(i=0;i<r;i++)
    {
        if(s[i]!='R')
            c++;
    }
    cout<<c<<endl;
}


Measured memory_bytes: 3732
#include "bits/stdc++.h"
using namespace std;
#define mod 1000000007
#define all(c) begin(c),end(c)
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
using ll = long long;
using vi = vector<int>; using vs = vector<string>;
int dd[] = { 0, 1, 0, -1, 0 }; //→↓←↑

void solve()
{
	int N;
	cin >> N; string S;


	for (int i = 0; i < N; i++)
	{
		cin >> S;
		vector<int> A[10001];
		int p = -1;
		string num = "";
		int stage = -1;
		int M = -1;
		for (int j = 0; j < S.size(); j++)
		{
			if (S[j] == '[')
			{
				p++;
				stage++;
			}
			else if (S[j] == ']')
			{
				
				if (S[j - 1] == ']')
				{
					int sum = 0;
					sort(A[p + 1].begin(), A[p + 1].end());
					for (int k = 0; k < A[p + 1].size() / 2 + 1; k++)
					{
						if(p + 1 == M)sum += A[p + 1][k] / 2 + 1;
						else sum += A[p + 1][k];
					}
					A[p + 1].clear();
					A[p].emplace_back(sum);
					p--;
				}
				else
				{
					A[p].emplace_back(stoi(num));
					p--;
					num = "";
				}
			}
			else
			{
				if (M == -1)M = stage;
				num += S[j];
			}
		}
		if (M == 0)
		{
			cout << A[0][0] / 2 + 1 << endl;
		}
		else cout << A[0][0] << endl;
	}
}

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


Measured memory_bytes: 3468
#include <iostream>
using namespace std;
int main(void){
    int a, b;
    cin >> a >> b;
    if(a>b){
        cout << "a > b" << endl;
    }
    else if(a<b){
        cout << "a < b" << endl;
    }
    else{
        cout << "a == b" << endl;
    }
}



Measured memory_bytes: 3092
#include <stdio.h>
int main(void){
    int H , W;
    int i;
    char col[100][101];
    scanf("%d %d",&H,&W);
    
    for(i=0;i<H;i++){
        scanf("%s",col[i]);
    }
    
    int f=0;
    for(f=0;f<W+2;f++){
        printf("#");
    }
    printf("\n");
    
    int h;
    for(h=0;h<H;h++){
        printf("#%s#\n",col[h]);
    }

    for(f=0;f<W+2;f++){
        printf("#");
    }
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<stack>
#define LL long long
using namespace std;
string f;
int a[100011];
int n;
int ans;
int read()
{
	int _=0,__=1;char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-')__=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){_=_*10+ch-'0';ch=getchar();}
	return _*__;
}
int main()
{
	cin>>f;
	n=f.size();
	ans=f.size();
	for(int i=0;i<n;i++)
	a[i]=f[i]-'0';
	for(int i=1;i<n;i++)
	if(a[i]!=a[i-1])
	ans=min(ans,max(i,n-i));
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  cin >> n;
  int ans = 1e9;
  rep(i, 1, n) {
    int t = i;
    int j = n - i;
    int x = 0;
    while (t) {
      x += t % 10;
      t /= 10;
    }
    while (j) {
      x += j % 10;
      j /= 10;
    }
    chmin(ans, x);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
s = gets.strip.to_s
t = gets.strip.to_s
cnt = 0
m = s.size
if s==t
  puts "Yes"
  exit
end
i = 1
while i < m do
  su= s[(m-i)..(m-1)]+s[0..(m-1)-i]
  if su==t
    cnt += 1
  end
  i += 1
end
if cnt>0
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 14376
n,k=map(int,input().split())
D=[0]*n
for i in range(k):
  d=int(input())
  a=list(map(int,input().split()))
  for j in range(d):
    D[a[j]-1]+=1
res=0
for i in range(n):
  if not D[i]:
    res+=1
print(res)


Measured memory_bytes: 9060
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

long long a, b, r;
char temp[100];
int szTemp;

int main()
{
	scanf("%lld%s", &a, temp);
	szTemp = strlen(temp);
	b = 0;
	
	int p = 0;
	while (p < szTemp) {
		if (temp[p] == '.')
			break;
		b = b * 10 + temp[p] - '0';
		p++;
	}
	
	p++;
	r = 0;
	while (p < szTemp) {
		r = r * 10 + temp[p] - '0';
		p++;
	}
	
	long long ans = a * b;
	ans = ans + a * r / 100;
	
	printf("%lld\n", ans);
		
	return 0;
}


Measured memory_bytes: 1736
#include<iostream>

using namespace std;

int main(void)
{
	int n;
	cin >> n;
	bool a[100000];
	for (int i = 0; i < 100000; i++) {
		a[i] = false;
	}
	while (n--) {
		int l, r;
		cin >> l >> r;
		for (int i = l; i <= r; i++) {
			a[i-1] = true;
		}
	}
	int count = 0;
	for (int i = 0; i < 100000; i++) {
		if (a[i]) count++;
	}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long int n;
    cin>>n;
    double a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    double dp[n+1][n+1];
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            if(i==0 && j==0){
                dp[i][j]=1;
            }
            else if(i==0 && j!=0){
                dp[i][j]=0;
            }
            else if(j==0){
                dp[i][j] = (1-a[i-1])*dp[i-1][j];
            }
            else dp[i][j] = a[i-1]*(dp[i-1][j-1]) + (1-a[i-1])*dp[i-1][j];
        }
    }
    double ans=0;
    for(int i=1;i<=n;i++){
        if(i>n-i){
            ans = ans + dp[n][i];
        }
    }
    cout<<setprecision(9)<<ans<<endl;
}

Measured memory_bytes: 74080
use std::io::stdin;
use std::str::FromStr;


fn main() {
    let n: usize = read_elem();
    let vec: Vec<usize> = read_split_line();
    let mut ans: Vec<i32> = Vec::new();
    ans.resize(n, 0);
    for v in vec {
        if v > 0 { ans[v - 1] += 1; }
    }
    for a in ans {
        println!("{}", a);
    }
}

#[allow(dead_code)]
fn read_elem<T: FromStr>() -> T {
    let mut l = String::new();
    stdin().read_line(&mut l).unwrap();
    l.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_n_elems<T: FromStr>() -> Vec<T> {
    let n = read_elem::<u32>();
    let mut vec: Vec<T> = vec![];
    for _i in 0..n {
        vec.push(read_elem::<T>());
    }
    vec
}

#[allow(dead_code)]
fn read_split_line<T: FromStr>() -> Vec<T> {
    let mut l = String::new();
    stdin().read_line(&mut l).unwrap();
    l.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}


Measured memory_bytes: 5004
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <bitset>
#include <limits>

using ll = long long int;
using ul = unsigned long long int;

namespace lamlib
{
	// EPSITON
	constexpr double epsilon = std::numeric_limits<double>::epsilon();
	// Absolute
	template<class T> inline T abs(const T &a){ return (a>0) ? a : -a; }
	// Digit
	ul inline digit(const ul &num){ return static_cast<ul>(std::log10(num+epsilon))+1; }
	// GCD: a > b
	ul gcd(ul a,ul b) { return (!b) ? a : gcd(b,a%b); }
	
	/* string */
	inline ul same_char_count(const std::string s,const char &ch){ return std::count(std::cbegin(s),std::cend(s),ch); }
}

int main(int argc,char *argv[])
{
	ul n;
	std::cin >> n;

	std::vector<ul> a(n+1,0);
	for(ul i = 0;i < n+1;++i) std::cin >> a[i];
	std::vector<ul> b(n,0);
	for(ul i = 0;i < n;++i) std::cin >> b[i];

	ul ans = 0;
	for(ll i = n-1;i >= 0;--i)
	{
		if(a[i+1] > b[i])
		{
			ans += b[i];
			a[i+1] -= b[i];
			b[i] = 0;
		}
		else
		{
			ans += a[i+1];
			b[i] -= a[i+1];
			a[i+1] = 0;
		}
		if(a[i] > b[i])
		{
			ans += b[i];
			a[i] -= b[i];
			b[i] = 0;
		}
		else
		{
			ans += a[i];
			b[i] -= a[i];
			a[i] = 0;
		}
	}

	std::cout << ans << std::endl;
	
	return 0;
}

Measured memory_bytes: 1792
import sys
a=list(map(int,input().split()))
W=a[0]
H=a[1]
x=a[2]
y=a[3]
print(W*H/2)
f1,f2=0,0
if x==W/2:
    f1=1
if y==H/2:
    f2=1
if x==W or y==H:
    print('0')
    sys.exit()
if f1==1 or f2==1:
    if f1==f2:
        print('1')
        sys.exit()
    else:
        print('0')
        sys.exit()
print('0')

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(void){
  int n;
  cin >> n;
  int a[n];
  int mahou = 0;
  for(int i = 0; n > i; i++){
    cin >> a[i];
    if(a[i] == a[i - 1]){
      mahou++;
      a[i] = 10001;
    }
  }
  cout << mahou << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;
using namespace std;

typedef long long int ll; 
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;

bool ab[9] = {0};

bool yoko(int a){
    if(ab[a]&&ab[a+1]&&ab[a+2])return true;
    return false;
}
bool tate(int a){
    if(ab[a]&&ab[a+3]&&ab[a+6])return true;
    return false;
}
bool naname(){
    if(ab[0]&&ab[4]&&ab[8])return true;
    if(ab[2]&&ab[4]&&ab[6])return true;
    return false;
}

int main(){
    int a[9]={0};
    int tmp;

    for (int  i = 0; i < 9; i++)
    {
        cin >> tmp;
        a[i] = tmp;
    }
    int n;
    cin>>n;
    for (int i = 0; i < n; i++)
    {
        cin>>tmp;
        for ( int j = 0; j < 9;  j++)
            if((a[j])==tmp) {ab[j] = true; break;}
    }

    //yoko
    for (int  i = 0; i < 3; i++)
    {
        if(yoko(i*3))goto YES;
        if(tate(i))goto YES;
    }
    //naname
    if(naname())goto YES;
    goto NO;

    YES: 
    cout<<"Yes";
    return 0;
    NO:
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) ll((a).size())
#define out(a) cout<<(a)<<endl;
const ll inf=1e9;
const int MAX = 510000;
const ll MOD = 998244353;

inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}

int main(){
  ll n,m;cin>>n>>m;
  
  vll num(n,1);vb red(n,false);
  red[0]=true;
  rep(i,0,m){
    ll x,y;cin>>x>>y;
    x--;y--;
    if(red[x])red[y]=true;
    num[x]--;num[y]++;
    if(num[x]==0)red[x]=false;
  }
  ll ans=0;
  rep(i,0,n){
    if(red[i])ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3976