akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;


signed main() {

    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    int a, b;

    cin >> a >> b;

    for(int i = 0; i <= 30; i++) {
        if(i * a + 1 - i >= b) {
            cout << i << endl;
            return 0;
        }
    }    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#define MOD 1000000007
#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810MEM
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

 
signed main(void){
    int N,M,Q;
    const int MEM=114514;
    int A[MEM],B[MEM];
    int v[MEM],d[MEM],c[MEM];
    cin >> N >> M;
    REP(i,M){
        cin >> A[i] >> B[i];
        A[i]--;B[i]--;
    }
    cin >> Q;
    REP(i,Q){
        cin >> v[i] >> d[i] >> c[i];
        v[i]--;
    }
    
    vector<int> G[MEM];
    REP(i,M){
        G[A[i]].push_back(B[i]);
        G[B[i]].push_back(A[i]);
    }
    
    int dp[MEM][11]={};
    REP(i,MEM){
        REP(j,11){
            dp[i][j]=-1;
        }
    }
    REP(i,Q){
        dp[v[i]][d[i]]=i;
    }
    RREP(j,11){
        if(j==0)continue;
        REP(i,N){
            REP(k,G[i].size()){
                dp[G[i][k]][j-1]=max(dp[G[i][k]][j-1],dp[i][j]);
            }
        }
    }
    
    /*
    REP(i,11){
        REP(j,N){
            //cout << (dp[j][i]!=0?c[dp[j][i]-1]:0) << " ";
            cout << dp[j][i] << " ";
        }cout << endl;
    }cout << endl;*/
    
    REP(i,N){
        int mx=-INF;
        REP(j,11){
            mx=max(mx,dp[i][j]);
        }
        if(mx<0){
            cout << 0 << endl;
        }else{
            cout << c[mx] << endl;
        }
    }
    
    return 0;
}



Measured memory_bytes: 21492
a,b,h,m = gets.chomp.split(' ').map(&:to_i)

h_ceta = (2*(h*60+m)*Math::PI)/720.to_f
m_ceta = (2*m*Math::PI)/60.to_f

ceta = h_ceta - m_ceta
ans = (a**2+b**2-2*a*b*Math.cos(ceta))**0.5
puts ans

Measured memory_bytes: 14880
#include<iostream>
using namespace std;
int main()
{
  	string s;
    int h,n,a,ans;
	cin >> h >> n;
  	for (int i = 0; i < n; i++) {
  		cin >> a;
    	ans += a;
      	if(ans >= h){
  		break;
	}
    	}
	if(ans >= h){
  		s = "Yes";
	}
  	else{
      	s = "No";
    }
      cout << s  << endl;
}


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

map< ll, int > prime_factor(ll n) {
  map< ll, int > res;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if(n != 1) res[n] = 1;
  return res;
}

int main(){
  int n;
  cin >> n;
  map<ll,int> p_sum;
  for (int i = 1; i <= n; i++) {
    auto f = prime_factor(i);
    for (auto e : f) {
      p_sum[e.first] += e.second;
    }
  }

  vector<int> dp(80,0);
  dp[1] = 1;
  for (auto e : p_sum) {
    vector<int> next(76);
    for (int i = 1; i < 76; i++) {
      for (int j = 0; j <= e.second; j++) {
        next[min(76, i * (j + 1))] += dp[i];
      }
    }
    dp = next;
  }
  cout << dp[75] << endl;
  return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >>N;
  
  vector<int> bot(N);
  
  for(int i=0;i<N;i++)
    cin>>bot.at(i);
  
  int a=1,count=0;
  
  for(int i=0;i<N;i++){
    a=bot.at(a-1);
    count++;
    if(a==2)
      break;
  }
  
  if(a!=2)
    count=-1;
  
  cout<<count<<endl;
}
    
    

Measured memory_bytes: 640
#define DEBUG 0
#include <bits/stdc++.h>
#define loop(n) for (lint ngtkana_is_a_genius = 0; ngtkana_is_a_genius < lint(n); ngtkana_is_a_genius++)
#define rep(i, begin, end) for (lint i = lint(begin); (i) < lint(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto&& a, auto b){ if (a > b) {a = b; return true;} return false; };
auto cmx = [](auto&& a, auto b){ if (a < b) {a = b; return true;} return false; };
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#if DEBUG
#define debug(...)\
  do {\
    std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_impl(__VA_ARGS__);\
    std::cerr << std::noboolalpha;\
  } while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
 os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}

void err() { std::cout << 0 << std::endl; exit(0); }
#define require(exp) do { if (!(exp)) { err(); } } while(false)

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  lint  n, m; std::cin >> n >> m;
  std::vector<lint> a(n); std::cin>>a;
  for (lint & x : a) x /= 2;
  debug(a);

  std::vector<int> factor(n);
  rep(i,0,n) {
    lint x = a.at(i);
    while (x % 2 == 0) {
      factor.at(i)++;
      x /= 2;
    }
  }
  factor.resize(std::unique(all(factor)) - factor.begin());
  require(factor.size() == 1u);

  lint lcm = 1;
  for (lint x : a) {
    lint g = std::__gcd(lcm, x);
    lcm = (lcm * x) / g;
    require(lcm <= m);
  }
  debug(lcm);

  lint ans = (m + lcm) / (2 * lcm);
  std::cout << ans << std::endl;
  return 0;
}

/*
すべて2で割っておきます。
するとどの項の奇数倍になっているのが条件です。
よって、2で割れる回数の異なるものがあるとアウトです。
すると答えは floor((M + lcm) / 2*lcm) です。
*/

Measured memory_bytes: 1408
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var N = ReadInt();
            var W = ReadSplitInt();

            var min = int.MaxValue;
            for (int i = 0; i < N; i++)
            {
                var c = 0;
                var d = 0;
                for (int a = 0; a <= i; a++)
                {
                    c += W[a];
                }

                for (int b = i + 1; b < N; b++)
                {
                    d += W[b];
                }

                min = Min(min, Abs(c - d));
            }

            Println(min);
        }


        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static int Gcd(int a, int b) => b == 0 ? a : Gcd(b, a % b);

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}


Measured memory_bytes: 11348
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    const int N = 10;
    int h, w;
    cin >> h >> w;
    vector<vector<int>> g(N,vector<int>(N));
    REP(i,N) REP(j,N) cin >> g[i][j];

    REP(k,N) REP(i,N) REP(j,N) g[i][j] = min(g[i][j],g[i][k] + g[k][j]);

    ll ans = 0;
    REP(i,h) REP(j,w) {
        int a; cin >> a;
        if (a != -1) ans += g[a][1];
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 256
N,D=list(map(int,input().strip().split(' ')))
points=[]
for _ in range(N):
    P=list(map(int,input().strip().split(' ')))
    points+=[P]

count=0
for i in range(len(points)):
    for j in range(i+1,len(points)):
        temp=sum([(points[i][k]-points[j][k])**2 for k in range(D)])
        root=int(temp**0.5)
        if (root-1)**2==temp or root**2==temp or (root+1)**2==temp:
            count+=1
print(count)

Measured memory_bytes: 38384
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string>
 
using namespace std;
 
char c, t;
int a[26] = {0};
 
int main(){
    while (cin >> c){
        if (isalpha(c)) {
            if (isupper(c)) c = tolower(c);
            a[c - 'a']++;
        }
    }
    for (int i = 'a'; i <= 'z'; i++) cout << static_cast<char>(i) << " : " << a[i - 'a'] << endl;
    }

Measured memory_bytes: 1140
#include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#define EPS 1e-9
#define INF MOD
#define MOD 1000000007LL
#define fir first
#define iss istringstream
#define sst stringstream
#define ite iterator
#define ll long long
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define sec second
#define sh(i) (1LL<<i)
#define sz size()
#define vi vector<int>
#define vc vector
#define vl vector<ll>
#define vs vector<string>

int dp[2][2][4][4];
char c[100010];

int main(){
	while(cin>>c){
		if(c[0]=='#')break;
		memset(dp,0,sizeof(dp));
		int n=strlen(c);
		rep2(i,1,n+1){
			int cur=i%2,pre=1-cur,a=(c[i-1]-'0')%3;
			if(!a)a=3;
			rep(j,2)rep(k,4)rep(l,4)dp[cur][j][k][l]=INF;
			rep(j,2)rep2(k,1,4)rep2(l,max(k,a),4){
				dp[cur][0][a][l]=min(dp[cur][0][a][l],dp[pre][j][k][l]+(j<1));
			}
			rep(j,2)rep2(k,1,a+1)rep2(l,k,4){
				dp[cur][1][k][a]=min(dp[cur][1][k][a],dp[pre][j][k][l]+(j>0));
			}
		}
		int a=INF;
		rep(i,2)rep(j,4)rep(k,4)a=min(a,dp[n%2][i][j][k]);
		cout<<a<<endl;
	}
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define FOR(NAME, START, NUM) for (int NAME = START; NAME < (NUM); NAME++)
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); NAME++)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; NAME--)
#define ALL(NAME) (NAME).begin(), (NAME).end()
const ll INF =1000000000000000;

int main(){
  string s;cin >> s;
  int n=s.size();
  s+="ATCODER";
  REP(i,n){
    if(s.at(i) == s.at(i+1)){
      cout << i+1 << " " << i+2 << endl;
      return 0;
    }
    else if(s.at(i) == s.at(i+2)){
      cout << i+1 << " " << i+3 << endl;
      return 0;
    }
  }
  
  cout << "-1 -1" << endl; 
}

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

int main(){

	int X;
	string ans = "NO";

	cin >> X;

	ans = (X == 3 || X == 5 || X == 7) ? "YES" : ans;

	cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N ;
  int t = 0;
  int x = 0;
  int y = 0;
  int able = 0;
  for (int i = 0; i < N; i ++) {
    int ti, xi, yi;
    cin >> ti >> xi >> yi;
    int p = ti - t ;
    int q = max (xi - x, x - xi);
    int r = max (yi - y, y - yi);//pqrの定義
    int a = p % 2;
    int b = (q + r) % 2;
    if (p < q + r) {
      able = 1;
      break;
    }
    if (a != b) {
      able = 1;
      break;
    }
    if (able) break;
    t = ti;
    x = xi;
    y = yi;
  }
  if (able == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;
int mod = 1e9+7;

int main() {

  string s, t;
  cin >> s >> t;
  for(int i=0; i<s.size(); i++){
    cout << s[i];
    if( i < t.size() ) cout << t[i];
  }
  cout << endl;

  return 0;
}


// EOF


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(v) (int)v.size()
#define v(x) vector<x>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> ans;
    while(n) {
        ans.push_back(n % k);
        n /= k;        
    }
    cout<<sz(ans);
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <stack>
#include <unordered_map>
#define lld long long int
#define dbg1(vari1) cerr<<#vari1<<" = "<<(vari1)<<endl;
#define dbg2(vari1,vari2) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<endl;
#define dbg3(vari1,vari2,vari3) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<" "<<#vari3<<" = "<<(vari3)<<endl;
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	lld l,r;
	cin >> l >> r;
	lld mn=2e18;
	for(lld i=l;i<=l+2020&&i<=r;i++)
	{
		for(lld j=l+1;j<=l+2020&&j<=r;j++)
		{
			if(i==j)
				continue;
			lld t = ((i*j)%2019);
			mn=min(t,mn);
		}
	}
	cout << mn%2019;
}

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

using namespace std;
const long long INF = 1e18;
#define PI 3.141592653589793
#define REP(i, n) for(int i = 0;i < n;++i)
long long N,Y;
int A[1000000];
int main()
{
  string c;
  int count=0,w;
  cin>>c;
  for(int i=0;i<3;i++){
    if(c[i]=='R'){
      count++;
    }else{
      w=max(count,w);
      count=0;
    }
  }
  cout<<max(count,w);
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
  
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}
  
int main()
{
  string S;
  int i;
  int red = 0, blue = 0;
  int ans = 0;

  cin >> S;

  for(i=0;i<(int)S.length();i++){
      if(S[i] == '0'){red++;}
      if(S[i] == '1'){blue++;}
  }

  ans = min(red,blue) * 2;

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


Measured memory_bytes: 512
#include <algorithm>
#include <cctype>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 1> { using type = vector<T>; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

int main() {
  string S;
  while (cin >> S) {
    bool res = true;
    res &= S[0] == 'A';
    res &= (bool)islower(S[1]);
    int C = 0;
    for (int i = 2; i < S.size() - 1; i++) {
      if (S[i] == 'C') {
        ++C;
      } else {
        res &= (bool)islower(S[i]);
      }
    }
    res &= C == 1;
    res &= (bool)islower(S.back());
    cout << (res ? "AC" : "WA") << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
#define ll long long
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
ll dp[20005];
ll a[1005];
ll b[1005];
int main(int argc, char** argv) {
	int h,n;
	scanf("%d%d",&h,&n);
	for(int i=1;i<=n;i++)
	{
		cin>>a[i]>>b[i];
	}
	fill(dp+1,dp+20000+1,1e9);
	dp[0]=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=a[i];j<=20000;j++)
		{
			dp[j]=min(dp[j-a[i]]+b[i],dp[j]);
		//	if(j==h)cout<<dp[j]<<" "<<j-a[i]<<endl;
		}
	}ll ans=1e9;
	for(int i=h;i<=20000;i++)
	ans=min(ans,dp[i]);
	cout<<ans;
	return 0;
}

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

namespace CSharp_practice
{
    class Program
    {
        static void Main(string[] args)
        {
            var r = int.Parse(Console.ReadLine());
            Console.WriteLine(r * r);
        }
    }
}


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

int g[210][210] = {};

int gcd(int x, int y) {
    if (g[x][y] != 0) return g[x][y];
    int res = 0;
    if (x < y) return gcd(y,x);
    if (y == 0) return x;
    res = gcd(y, x % y);
    g[x][y] = res;
    g[y][x] = res;
    return res;
}

int gcd(int x, int y, int z) {
    return gcd(gcd(x,y), z);
}

int main() {
    int k; cin >> k;
    long long res = 0;
    for (int i = 1; i <= k; i++) {
        for (int ii = 1; ii <= k; ii++) {
            for (int iii = 1; iii <= k; iii++) {
                res += gcd(i, ii, iii);
            }
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1e9+7;

int main() {
  string s;
  cin>>s;
  if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3])
    cout<<"Bad"<<endl;
  else cout<<"Good"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int n,p;
	while(1){
		cin>>n>>p;
		if(!n && !p)break;
		int person[n];
		rep(i,n)person[i]=0;
		int cup=p;
		int ans;
		int cnt=0;
		//cout<<"start"<<endl;
		//cout<<"cup="<<cup<<endl;
		while(1){
			if(cup!=0){
				cup--;
				person[cnt]++;
			}else{
				cup=person[cnt];
				person[cnt]=0;
			}
			if(cup==0){
				bool check=true;
				rep(i,n){
					if(i!=cnt){
						if(person[i]!=0){
							check=false;
							break;
						}
					}
				}
				if(check){
					ans=cnt;
					break;
				}
			}
			cnt=(cnt+1)%n;
			//rep(i,n)cout<<person[i]<<" ";
			//cout<<endl;
		//	cout<<"cnt="<<cnt<<endl;
		}
		//cout<<"end"<<endl;
		cout<<ans<<endl;
	}
	return 0;
}

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

int main() {
	int n, out=0, hit=0, point=0;
	string str;
	cin >> n;
	while(cin >> str){
		if(str=="HIT"){
			hit++;
			if(hit==4){
				point++;
				hit = 3;
			}
		}
		if(str=="HOMERUN"){
			point += hit+1;
			hit = 0;
		}
		if(str=="OUT"){
			out++;
			if(out==3){
				cout << point << endl;
				out = 0;
				point = 0;
				hit = 0;
			}
		}
	}
	
	return 0;
}


Measured memory_bytes: 3148
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fi first
#define se second
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
typedef complex<double> com;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	int n, k;
	cin >> n >> k;
	int ans = k;
	rep(_, n - 1) ans *= k - 1;
	cout << ans << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int cnt[100001] = {};
int main() {
	int n, m; cin >> n >> m;
	rep(i, n) {
		int a; cin >> a; cnt[a]++;
	}
	int out = 0;
	rep(i, 100001) {
		if (cnt[i] % 2) {
			bool f = false;
			for (int j = m - i%m; j <= 100000; j += m) {
				if (i == j)continue;
				if (cnt[j] % 2) {
					cnt[j]--; cnt[i]--; out++; f = true; break;
				}
			}
			if (f)continue;
			for (int j = m - i % m; j <= 100000; j += m) {
				if (i == j)continue;
				if (cnt[j]) {
					cnt[j]--; cnt[i]--; out++; break;
				}
			}
		}
	}
	rep(i, 100001) {
		out += cnt[i] / 2;
	}
	cout << out << endl;
	return 0;
}

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


int main(){
    int x, y, z;
    cin >> x >> y >> z;
    vector<int> a(x);
    vector<int> b(y);
    vector<tuple <int, int, int>> M(z);
    int minA = 5000000;
    rep(i, x){
        cin >> a.at(i);
        minA = min(a.at(i), minA);
    }
    int minB = 5000000;
    rep(i, y){
        cin >> b.at(i);
        minB = min(b.at(i), minB);
    }
    int minCost = minA + minB;

    int xm, ym, cm;
    rep(i, z){
        cin >> xm >> ym >> cm;
        M.at(i) = make_tuple(xm, ym, cm);
    }
    for (auto mi: M){
        tie(xm, ym, cm) = mi;
        minCost = min(minCost, a[xm-1] + b[ym-1] - cm);
    }
    cout << minCost << endl; 
}

Measured memory_bytes: 2176
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		Map<Integer, Integer> x = new HashMap<>();
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
			if(x.containsKey(A[i]))
				x.put(A[i], x.get(A[i])+1);
			else
				x.put(A[i], 1);
		}
		long ans = 0;
		for(int i : x.values())
			ans += (long)i*(i-1)/2;
		for(int i = 0; i < N; i++)
			System.out.println(ans - (x.get(A[i])-1));

	}

}


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

int main() {
    string S;cin>>S;
    int C0=0,C1=0;
    for(int i = 0; i < S.size(); i++)
    {
        if(S.at(i)=='0'){
        C0++;}
        else
        {
            C1++;
        }
        
    }
    int ans=min(C0,C1);
    cout<<ans*2<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef set<int> si;
typedef set<ld> sd;
typedef set<ll> sl;
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define Plabs     ios_base::sync_with_stdio(false);cin.tie(NULL)
int main()
{
    ll n,k;
    cin>>n>>k;
    ll ar[n];
    ll sum=0;
    for(ll i=0;i<n;i++)
    {
        cin>>ar[i];
    }
    sort(ar,ar+n);
    for(ll j=0;j<k;j++)
    {
        sum=sum+ar[j];
    }
    cout<<sum;
}











Measured memory_bytes: 3644
/* 
我的思路：直接按样例一的方法构造

emm，wa了一发之后发现有反例：1 4 1 3 

我的会输出[1 1 -3 1]


*/
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 10, INF = 1e9 + 10;
inline int read() {
	char c = getchar(); int x = 0, f = 1;
	while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * f;
}
int N, M, h, w;
int ans[501][501];
main() {
	N = read(); M = read(); h = read(); w = read();
	if(N % h == 0 && M % w == 0) {puts("No"); return 0;}

	int sum = 0;
	for(int i = 1; i <= N; i++)
		for(int j = 1; j <= M; j++) {
			if(i % h == 0 && j % w == 0) ans[i][j] =  - h * w * 1000 + 999;
			else ans[i][j] = 1000;			
			sum += ans[i][j];
		}
	if(sum <= 0) {puts("No"); return 0;}
	puts("Yes");
	for(int i = 1; i <= N; i++, puts(""))
		for(int j = 1; j <= M; j++)
			printf("%d ", ans[i][j]);
	return 0;
}
/*

*/


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

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

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

int main(void){

    int n;
    cin >> n;

    map<string, int> mp;

    roop(i, n){
        string s; cin >> s;
        mp[s]++;
    }

    cout << mp.size() << endl;

    return 0;
}


Measured memory_bytes: 19232
import sys
def input():
	return sys.stdin.buffer.readline()[:-1]

n, T = map(int, input().split())

zero = []
non_zero = []

for _ in range(n):
	a, b = map(int, input().split())
	if a == 0:
		zero.append(b)
	else:
		non_zero.append((a, b))

zero.sort()
if not zero:
	z_cum = []
else:
	z_cum = [zero[0] + 1]
	for i in range(1, len(zero)):
		z_cum.append(z_cum[-1] + zero[i] + 1)


non_zero.sort(key=lambda x: (x[1]+1)/x[0])
#print(non_zero)

l = len(non_zero)
k = min(30, l)

INF = 10**10
dp = [[INF for _ in range(k+1)] for _ in range(l+1)]
dp[0][0] = 0
for i in range(l):
	a, b = non_zero[i]
	dp[i+1][0] = 0
	for j in range(1, k+1):
		dp[i+1][j] = min(dp[i][j], dp[i][j-1] + 1 + a * (dp[i][j-1] + 1) + b)
#print(dp)

ans = 0
cur = 0
for i in range(k, -1, -1):
	if dp[l][i] > T:
		continue
	while cur < len(z_cum) and dp[l][i] + z_cum[cur] <= T :
		cur += 1
	ans = max(ans, i + cur)

print(ans)

Measured memory_bytes: 134992
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
const int maxn=1e5+100;
const int mod=1e9+7;
const int inf=123456789;
const int p=1e4;
using namespace std;
ll n,t,k,br[maxn];
char str[maxn];
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);
    char x;
    cin>>x;
    cout<<(char)(x+1)<<'\n';

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

long max(long x,long y){
  if(x>y)
    return x;
  return y;
}

int main(){
  int n,i;
  long t[1000],a[1000],ansx=0,ansy=0,x,y,z;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%ld %ld",&t[i],&a[i]);
  ansx=t[0];
  ansy=a[0];
  for(i=1;i<n;i++){
    x=t[i];
    y=a[i];
    z=max(ansx/x,ansy/y);
    if(ansx<=x*z&&ansy<=y*z){
      ansx=x*z;
      ansy=y*z;
    }
    else{
      z+=1;
      ansx=x*z;
      ansy=y*z;
    }
  }
  printf("%ld\n",ansx+ansy);
}

Measured memory_bytes: 128
#include <iostream>
#include <string.h>
#include <vector>
#include <cstdio>

#define W 1010
#define N 1010

using namespace std;

int main(void)
{
	int w,n;
	int i1,i2;
	int dp[N][W];
	int v[N];
	int ww[N];
	int c=0;
	int maxx;
	int i;

	while(1)
	{
		cin>>w;
		if(w==0) break;
		cin>>n;

		for(i1=0;i1<n;i1++){
			scanf("%d,%d",v+i1,ww+i1);
		}
		memset(dp,0,sizeof(dp));

		for(i1=n-1;i1>=0;i1--){
			for(i2=0;i2<=w;i2++){

				if(ww[i1]>i2) dp[i1][i2]=dp[i1+1][i2];
				else {
					dp[i1][i2]=max(dp[i1+1][i2],dp[i1+1][i2-ww[i1]]+v[i1]);
				}
			}
		}
		c++;
		cout<<"Case "<<c<<":"<<endl;
		cout<<dp[0][w]<<endl;
		
		maxx=dp[0][0];
		for(i1=0;i1<=w;i1++){
			if(maxx<dp[0][i1]) {
				i=i1;
				maxx=dp[0][i1];
			}
		}

		cout<<i<<endl;
	}

	return 0;
}

Measured memory_bytes: 5244
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<queue>
#include<list>
#include<stdio.h>
#include<stdlib.h>
#include<map>
#include<cstdio>
#include <iomanip>

#define rep(i,b) for(int i=0;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

using namespace std;
typedef long long ll;

int main() {

	int n;
	cin >> n;

	int o = n / 2;
	int e = n - o;

	int ans = o*e;

	cout << ans << endl;

	return 0;
}


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


public class Main {
    static long samin = 1000000000;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        search(h, w);
        search(w, h);
        System.out.println(samin);
    }
    static void search(long h, long w) {
        for (int i = 1; i < h; i++) {
            long a = w * i;
            long b = (h - i) * (w / 2);
            long c = w * h - a - b;
            long sa = Math.max(a, Math.max(b, c)) - Math.min(a, Math.min(b, c));
            samin = Math.min(samin, sa);
            b = (h - i) / 2 * w;
            c = w * h - a - b;
            sa = Math.max(a, Math.max(b, c)) - Math.min(a, Math.min(b, c));
            samin = Math.min(samin, sa);
        }
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
#define SHOWA(x,n) for( int yui = 0; yui < n; yui++ ){ cout << x[yui] << " "; } cout << endl

#define pb emplace_back
#define fi first
#define se second

using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
     
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-12;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }

ll in(){ long long int x; scanf( "%lld" , &x ); return x; }
char yuyushiki[1000010]; string stin(){ scanf( "%s" , yuyushiki ); return yuyushiki; }

// head

ll n, m;

vi G[100010];

int used[100010];

ll sz;
bool nibu;

void dfs( int x , int d = 0 ){
  used[x] = d;
  sz++;
  YYS( w , G[x] ){
    if( used[w] == -1 ){
      dfs( w, 1 - d );
    } else if( used[w] == d ){
      nibu = false;
    }
  }
}

int main(){

  n = in();
  m = in();
  REP( i , m ){
    int a = in() - 1;
    int b = in() - 1;
    G[a].pb( b );
    G[b].pb( a );
  }

  REP( i , n ){
    used[i] = -1;
  }


  ll x = 0;
  ll y = 0;
  ll z = 0;
  
  REP( i , n ){
    if( used[i] == -1 ){
      sz = 0;
      nibu = true;
      dfs( i );
      if( sz >= 2 ){
        x++;
        z += sz;
        if( nibu ){
          y++;
        }
      }
    }
  }

  ll ans = n * n - z * z + x * x + y * y;

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


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

int main() {
    
    int N, A, B;
    cin >> N >> A >> B;
    vector<char> v;
    int counter = 0;
    int total = A+B;
    int brank = 0;
    for (int i = 0; i < N; i++) {
        char c;
        cin >> c;

        if (counter < total and c != 'c') {
            if (c == 'a') {
                cout << "Yes" << endl;
                counter++;
            } else if (brank < B) {
                cout << "Yes" << endl;
                counter++;
                brank++;
            } else {
                cout << "No" << endl;
            }
        } else {
            cout << "No" << endl;
        }
    }
    

    return 0;
}

Measured memory_bytes: 3520
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

void cal_score(vector<ll> &c, vector<vector<ll>> &s, ll &score, vector<ll> v, vector<ll> &mai) {
	ll n = v.size() - 1;
	score += s[n][v.back()];
	REP(i, 26)mai[i]++;
	mai[v.back()] = 0;
	REP(i, 26)score -= c[i] * mai[i];
}

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

	ll d;cin >> d;
	vector<ll> c(26);REP(i, 26)cin >> c[i];
	vector<vector<ll>> s(d, vector<ll>(26));
	REP(i, d)REP(j, 26)cin >> s[i][j];

	vector<pair<ll, pair<vector<ll>, vector<ll>>>> lis;
	REP(i, 26){
		vector<ll> v(1, i);
		vector<ll> mai(26, 0);
		ll score = 0;
		cal_score(c, s, score, v, mai);
		lis.EB(score, MP(v, mai));
	}

	REP(i, d-1){
		sort(ALL(lis), greater<pair<ll, pair<vector<ll>, vector<ll>>>>());
		lis.resize(min((ll)lis.size(), 50LL));
		vector<pair<ll, pair<vector<ll>, vector<ll>>>> now;

		for(auto seica: lis){
			REP(i, 26){
				vector<ll> v = seica.SE.FI;v.PB(i);
				vector<ll> mai = seica.SE.SE;
				ll score = seica.FI;
				cal_score(c, s, score, v, mai);
				now.EB(score, MP(v, mai));
			}
		}

		lis = now;
	}

	sort(ALL(lis), greater<pair<ll, pair<vector<ll>, vector<ll>>>>());
	REP(i, d){
		cout << (lis[0].SE.FI[i]+1) << endl;
	}


	return 0;
}


Measured memory_bytes: 12088
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
    int i ,o,t,j,l,s,z,q;
    cin >> i>>o>>t>>j>>l>>s>>z;
    if(i>0&&j>0&&l>0)q=2*((i-1)/2+(j-1)/2+(l-1)/2)+o+3;
    else q=0;
  
     cout<<max(2*(i/2 + j/2 + l/2)+o,q);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
 
 
using namespace std;
 
 
void white_cells()
{
  int H, W, h, w;
  cin >> H >> W >> h >> w;
 
  cout << (H * W) - (h * W) - (H * w) + (h * w) << "\n";
}
 
 
void double_helix()
{
  char b;
  cin >> b;
 
  if (b == 'A') cout << "T\n";
  else if (b == 'T') cout << "A\n";
  else if (b == 'C') cout << "G\n";
  else  cout << "C\n";
 
}
 
 
void five_antennas()
{
  vector<int> a(5);
  for (int i = 0; i < 5; ++i) cin >> a[i];
  int k;
  cin >> k;
 
  if (a[4] - a[0] > k)
  {
    cout << ":(\n";
    return;
  }
  cout << "Yay!\n";
 
}
 
void buttons()
{
  int a, b;
  cin >> a >> b;
 
  int v_max = 0;
  for (int i = 0; i < 2; ++i) {
    if (a > b) {
      v_max += a;
      --a;
    }
    else
    {
      v_max += b;
      --b;
    }
  }
  cout << v_max << "\n";
}
 
 
void biscuit_generator()
{
  int a, b, t;
  cin >> a >> b >> t;
 
  cout << t / a * b << "\n";
}
 
 
void changing_a_character()
{
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
 
  s[k - 1] += 32;
  cout << s <<"\n";
}
 
 
void ferris_wheel()
{
  int a, b;
  cin >> a >> b;
 
  if (a >= 13) cout << b << "\n";
  else if(a >= 6) cout << b / 2 << "\n";
  else cout << 0 << "\n";
}
 
 
void apple_pie()
{
  int a, p;
  cin >> a >> p;
 
  p += 3 * a;
 
  cout << p / 2 << "\n";
}
 
 
void airplane()
{
  vector<int> a(3);
  for (int i = 0; i < 3; ++i) cin >> a[i];
 
  sort(a.begin(), a.end());
 
  cout << a[0] + a[1] << "\n";
}
 
 
void rounding()
{
  int x, a;
  cin >> x >> a;
 
  if (x < a) cout << 0 << "\n";
  else cout << 10 << "\n";
}
 
 
int main()
{
  //white_cells();
  //double_helix();
  //five_antennas();
  //buttons();
  //biscuit_generator();
  //changing_a_character();
  //ferris_wheel();
  //apple_pie();
  //airplane();
  rounding();
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	static int mod=1000000007;
	static Scanner scan=new Scanner(System.in);
	static long gcd (long a, long b) {return b>0?gcd(b,a%b):a;}
	static long lcm (long a, long b) {return a*b/gcd(a,b);}
	static int max(int a,int b) {return a>b?a:b;}
	static int min(int a,int b) {return a<b?a:b;}
	static long factorial(int i) {return i==1?1:i*factorial(i-1);}
	static int lower_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<=key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static int upper_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2)if(n%i==0){return false;}
		return true;
	}
	static int upper_division(int a,int b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lupper_division(long a,long b) {
		if(a%b==0) {
			return a/b;
			}
		else {
			return a/b+1;
		}
	}
	static long lmax(long a,long b) {return Math.max(a, b);}
	static long lmin(long a,long b) {return Math.min(a, b);}
	static int[] setArray(int a) {
		int b[]=new int[a];
		for(int i=0;i<a;i++) {
			b[i]=scan.nextInt();
		}
		return b;
	}
	static String reverce(String str) {
		String strr="";
		for(int i=str.length()-1;i>=0;i--) {
			strr+=str.charAt(i);
		}
		return strr;
	}
	static long modpow(long a,long n) {
		if(n==0) return 1;
		else if(n==1)return a;
		long tmp=modpow(a,n/2);
		tmp%=mod;
		tmp*=tmp;
		tmp%=mod;
		if(n%2==0)return tmp;
		else return (tmp*a)%mod;
	}
	public static void main(String[] args){
		String str=scan.next();
		int one=0;
		int zero=0;
		for(int i=0;i<str.length();i++) {
			if(str.charAt(i)=='1')one++;
			else zero++;
		}
		System.out.println(min(one,zero)*2);
	}
}


Measured memory_bytes: 25684
// Template by [thunder_blade]
// IIIT ALLAHABAD
// includes :)

#include<bits/stdc++.h>
using namespace std;
#define TEST  int test_case; cin>>test_case; while(test_case--)
#define all(v) (v).begin(),(v).end()
#define fi  first
#define se  second
#define pb push_back
#define mp make_pair
#define ll long long int
#define SPEED ios_base::sync_with_stdio(false);  cin.tie(0);  cout.tie(0);
#define pi(x) printf("%d\n",x)
#define pl(x) printf("%lld\n",x)
#define pf(x) printf("%f\n",x)
#define ps(x) printf("%s\n",x)
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define sf(x) scanf("%f",&x)
#define ss(x) scanf("%s",x)
#define pis(x) printf("%d ",x)
#define pls(x) printf("%lld ",x)
#define pfs(x) printf("%f ",x)
#define pss(x) printf("%s ",x)
#define FOR(i,a,b) for(i=a;i<b;i++)
#define mod 1000000007

int arr[5000005];

int main()
{
	int i,j;
	int n;
	si(n);
	n*=2;
	FOR(i,0,n){
		si(arr[i]);
	}
	int sum=0;
	sort(arr, arr+n);
	FOR(i,0,n){
		sum+=arr[i];
		i++;
	}
	pi(sum);
	return 0;
}

Measured memory_bytes: 256
n = int(input())
l = list(list(input().split()) for i in range(n))
a = sorted(l)
for i in range(n):
  l[i][1]= -int(l[i][1])
a = sorted(l)
for i in range(n):
  l[i][1]= -int(l[i][1])
for q in a:
  print(l.index(q)+1)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<cstdio>

using namespace std;

int main(){
  int N,K;
  cin >> N >> K;
  int c = 0;
  vector<long long>a;
  for(int i=1;i<K+1;i++){
    if((2*i)%K==0){
      //cout << i << endl;
      for(int j=0;j<N/K+1;j++){
        if( (2*i+(j*K))%K==0 && i+(j*K)<N+1 ){
          c++;
        }
      }
      //cout << c << endl;
      a.push_back(c);
      c=0;
    }
  }
  long long ans = 0;
  for(int i=0;i<a.size();i++){
    ans += a[i]*a[i]*a[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <cmath>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
using ull =unsigned long long;
const ll INF =1001001001;

//10億7。　　　100000007

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}


int main(){
cout<<fixed<<setprecision(10);
//cin.tie(0); ios::sync_with_stdio(false);

  int X,N;
  cin>>X>>N;
 /* if(N==100){
    if(X<=50){cout<<"-1"<<endl;
             }else{
      cout<<"101"<<endl;
    }
    return 0;
  }*/
  
  vector<int> vec(100);
  for(int i=0;i<100;i++){
    
    cin>>vec[i];
  }
  
vsort(vec);
vector<int> vecN(102);
  for(int i=0;i<102;i++){
    vecN[i]=i;
  }
  for(int i=0;i<101;i++){
    for(int j=0;j<101;j++){
      if(vecN[i]==vec[j]){
        vecN[i]=0;
      }
    }
  }
  vsort(vecN);
int ans=1000;
  for(int i=0;i<102;i++){
    int a=abs(X-vecN[i]);

    ans=min(a,ans);
  }
  for(int i=0;i<102;i++){
    if(vecN[i]==X-ans){
      cout<<X-ans<<endl;
      return 0;
    }
  }
  cout<<ans+X<<endl;
}



Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
using ll = long long;
int MOD = 1e9 + 7;
using namespace std;
ll GCD(ll x,ll y){
    if(y==0){
        return x;
    }else{
        return GCD(y, x % y);
    }
}
ll LCM(ll x,ll y){
    return x / GCD(x, y) * y;
}
struct UnionFind
{
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

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

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

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

    bool same(int x, int y)
    { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
int main()
{
    int n, m;
    cin >> n >> m;
    UnionFind tree(n+1);

    vector<int> vec(n);
    for (int i = 0; i<n;i++){
        cin >> vec[i];
    }
    for (int i = 0;i<m;i++){
        int x,y;
        cin>>x>>y;
        tree.unite(x, y);
    }
    int sum = 0;
    for(int i = 0; i < n;i++){
        if(vec[i]==i+1){
            sum++;
            continue;
        }
        if(tree.same(vec[i],i+1)){
            sum++;
            continue;
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define IO ios::sync_with_stdio(false), cin.tie(0)
#define endl '\n'
#define main() int main()
#define ff1(i,n) for(int i=1;i<=n;++i)
#define ff0(i,n) for(int i=0;i<n;++i)
#define pi acos(-1.0)
#define ms(a, x) memset(a, x, sizeof(a))
#define lowbit(x) ((x)&(-(x)))
#define pb push_back
#define binarycount __builtin_popcount(x)
#define tr t[root]
#define lson t[root << 1]
#define rson t[root << 1 | 1]
#define fir first
#define sec second
#define debug(x) cout<<x<<'\n'
#define sa(a) scanf("%d", &a)
#define sab(a, b) scanf("%d%d", &a, &b)
#define pa(a) printf("%d",a)
#define pab(a,b) printf("%d%d",a,b)
#define pii pair<string,int>
using namespace std;

#define maxn 100010
const int inf = 0x3f3f3f3f;
const int mod = 9973;
const double eps = 1e-8;
ll gcd(ll a, ll b) {return b==0?a:gcd(b, a%b);}
ll lcm(ll a, ll b) {return a/gcd(a, b)*b;}
int max(int x,int y){if(x>y) return x;return y;}
ll powmod(ll a,ll b){
    ull ans = 1, pow = a%mod;
    while(b) { if(b&1) ans = (ans*pow)%mod; pow = (pow*pow)%mod; b >>= 1; }
    return ans%mod;
}
main(){
	IO;
    int n,k;
	cin>>n;
	int a[n+1][3]={0};
	for(int i=1;i<=n;i++) {
		cin>>a[i][0]>>a[i][1]>>a[i][2];
	}
	int dp[n+1][3];
	ms(dp,0);
	dp[1][0]=a[1][0];dp[1][1]=a[1][1];dp[1][2]=a[1][2];
	for(int i=2;i<=n;i++){
		for(int j=0;j<=2;j++){
			dp[i][j]=dp[i-1][j];
			dp[i][j]=max(dp[i][j],dp[i-1][(j+1)%3]+a[i][j]);
			dp[i][j]=max(dp[i][j],dp[i-1][(j+2)%3]+a[i][j]);
		}
	}
	cout<<max(dp[n][0],max(dp[n][1],dp[n][2]))<<endl;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,m,c,b[25],a[25],sum,count=0;
  cin>>n>>m>>c;
  for(int i=0; i<m;i++){
    cin>>b[i];
  }
  for(int i=0; i<n; i++){
    sum=0;
    for(int j=0; j<m; j++){
      cin>>a[j];
      sum+=a[j]*b[j];
    }
    if(sum+c>0){
      count++;
    }
  }
  cout<<count<<'\n';
  return 0;
}


Measured memory_bytes: 256
/*
 * Talk is cheap, show me the code.
 * Author:  JiangDingyuan
 * Created Time:  2017/9/9 21:09:22
 * File Name: 123456.cpp
 */
#include <time.h>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#define PI acos(-1.0)
#define LL long long
#define bug printf("bug!\n");
#define RD freopen("in.txt", "r", stdin);
#define LD freopen("out.txt", "w", stdout);

using namespace std;
int s[100005];
int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> s[i];
    sort(s,s+n);
    int ans = 0, t = 1;
    for (int i = 1; i < n; i++) {
        if(s[i-1]==s[i]) t++;
        if(s[i-1]!=s[i]) {
            if(t&1) ans++;
            t = 1;
        }
    }
    if(t&1) ans++;
    cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 640