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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
// add_edgeの処理が特殊なので注意(逆辺を張っている)

struct edge { int to; ll cap; ll rev; };
vector<vector<edge>> adj;
vector<bool> used;

void add_edge(int from, int to, int cap) { adj[from].push_back((edge){to,cap,adj[to].size()}); adj[to].push_back((edge){from,0,adj[from].size()-1}); }
ll dfs(int n, int to, ll f) { if (n==to) return f; used[n] = true; for (auto &x: adj[n]) { if (!used[x.to]&&x.cap) { ll d = dfs(x.to, to, min(f,x.cap)); if (d) { x.cap -= d; adj[x.to][x.rev].cap += d; return d; } } } return 0; }
ll FordFulkerson(int from, int to) { int N = adj.size(); used.resize(N,false); ll flow = 0; while (true) { fill(all(used),false); if (ll f = dfs(from,to,LLINF)) flow += f; else return flow; } }

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

int main() {
  int H, W; cin >> H >> W;
  string a[H]; rep(i,H) cin >> a[i];

  adj.resize(H+W+2);
  rep(i,H) rep(j,W) {
    if (a[i][j]=='S') { add_edge(0,i+1,INF); add_edge(0,H+(j+1),INF); }
    if (a[i][j]=='T') { add_edge(i+1,H+W+1,INF); add_edge(H+(j+1),H+W+1,INF); }
    if (a[i][j]=='o') { add_edge(i+1,H+(j+1),1); add_edge(H+(j+1),i+1,1); }
  }
  ll result = FordFulkerson(0,H+W+1);
  if (result>=INF) result = -1;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 1536
_ = input()
A = list(map(int, input().split()))

cnt = 0
while True:
    if len(list(filter(lambda x: x % 2 != 0, A))) != 0 or A.count(0) == len(A):
        break
    for i in range(len(A)):
        A[i] = A[i] // 2
    cnt += 1
print(cnt)


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n-1);
  for(int i=0;i<n-1;++i){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  int j=1;
  int num=0;
  int i=0;
  while(j<=n){
    if(j==a[i] && i<n-1){
      num++;
      i++;
    }else{
      cout << num << endl;
      j++;
      num=0;
    }
  }
  return 0;
}


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

int main() {
  int n, k; cin >> n >> k;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int x; cin >> x;
    ans += min(x, k - x);
  }
  ans *= 2;
  cout << ans << endl;
}

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

int n;
int a[16][16];
long long f[1 << 16];
long long g[1 << 16];

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			scanf("%d", &a[i][j]);
		}
	}
	for (int mask = 0; mask < (1 << n); ++mask) {
		for (int i = 0; i < n; ++i) if (mask & (1 << i)) {
			for (int j = i + 1; j < n; ++j) if (mask & (1 << j)) {
				f[mask] += a[i][j];
			}
		} 
	}
	for (int mask = 0; mask < (1 << n); ++mask) {
		g[mask] = f[mask];
		for (int nmask = mask; nmask > 0; nmask = (nmask - 1) & mask) {
			g[mask] = max(g[mask], g[nmask] + f[mask ^ nmask]);
		} 
	}
	printf("%lld\n", g[(1 << n) - 1]);
}

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

int w, h, black;
char tile[24][24];
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void dfs(int x, int y){
    black++;
    tile[x][y] = '#';
    for(int i = 0; i < 4; i++){
        if( x+dx[i] >= 0 && x+dx[i] < h &&
           y+dy[i] >= 0 && y+dy[i] < w &&
           tile[ x+dx[i] ][ y+dy[i] ] == '.' ){
            dfs( x+dx[i], y+dy[i] );
        }
    }
}

int main(){
    int i, j;
    while( cin >> w >> h){
        if(w==0&&h==0)
            break;
        for(i = 0; i < h; i++){
            for(j=0;j<w;j++){
                cin >> tile[i][j];
            }
        }
        black = 0;
        for(j = 0; j < w && !black; j++){
            for(i = 0; i < h && !black; i++){
                if( tile[i][j] == '@' ){
                    dfs(i, j);
                }
            }
        }
        cout << black << endl;
    }
    return 0;
}

Measured memory_bytes: 1168
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define repi(i, a, b) for (int i = (a); i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ull << (b))

using namespace std;
using i32 = long long;
using u32 = unsigned long long;
using i64 = long long;
using u64 = unsigned long long;
using f64 = double;
using vi32 = vector<i32>;
using vu32 = vector<u32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf64 = vector<f64>;
using vstr = vector<string>;
using vvi32 = vector<vi32>;
using vvu32 = vector<vu32>;
using vvi64 = vector<vi64>;
using vvu64 = vector<vu64>;
using vvf64 = vector<vf64>;

template<typename T, typename S> void amax(T &x, S y) { if (x < y) x = y; }
template<typename T, typename S> void amin(T &x, S y) { if (y < x) x = y; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  i64 n, k;
  cin >> n >> k;
  vi64 a(n);
  rep(i, n) cin >> a[i];
  vi32 cnt(45, 0);
  rep(i, n) rep(j, 45) {
    if ((a[i] >> j) & 1ull) cnt[j]++;
  }
  bool tight = true;
  i64 x = 0;
  rrep(i, 45) {
    x <<= 1;
    if (tight && ((k >> i) & 1ull) == 0) {
    } else {
      i32 cnt1 = cnt[i];
      i32 cnt0 = n - cnt[i];
      if (cnt1 < cnt0) x |= 1ull;
      else {
        if (tight) tight = false;
      }
    }
  }
  i64 ans = 0;
  rep(i, n) ans += x ^ a[i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
m = input()[::-1]
n = []
for i in range(len(m)):
    n.append(int(m[i]))

dp = [[0, 0] for _ in range(len(n)+1)]

for i in range(len(n)):
    dp[i+1][0] = min((dp[i][0]+n[i]), (dp[i][1]+n[i]+1))
    if i == 0:
        dp[i+1][1] = dp[i][0]+10-n[i]
    else:
        dp[i+1][1] = min((dp[i][0]+10-n[i]), (dp[i][1]+9-n[i]))

s = len(n)
print(min(dp[s][0], (dp[s][1]+1)))

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

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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int dfs(int x,std::vector<int> v[],bool visited[], int n ){
	//visited[x]=true;
	bool s=true;
	int sum=0;
	FOR(i,n) if(visited[i]!=true) s=false;
	if(s) return 1;
	
	FOR(i,v[x].size()){
		if(!visited[v[x][i]]) {
			visited[v[x][i]]=true;
			sum+=dfs(v[x][i],v,visited,n); 
			visited[v[x][i]]=false;
		}
	}
	return sum;
}


int main(){
	int n,m,a,b;
	cin >> n >>m;
	vector<int> v[n];
	FOR(i,m){
		cin >> a >> b;
		v[a-1].PB(b-1);
		v[b-1].PB(a-1);
	}
	bool visited[n];
	FOR(i,n)visited[i]=0;
	visited[0]=true;
	cout << dfs(0,v,visited,n);

	return 0;
}

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

int main() {
  int N;
  cin >> N;
  int a,b,c;
  a = N % 10;
  b = N / 10 % 10;
  c = N / 100;
  if((a == 7)||(b == 7)||(c == 7)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}



Measured memory_bytes: 3632
#include<cstdio>
#define LOOP(i,f,t) for(int i=f;i<t;++i)
inline void swap(short&a,short&b){
  int t=a;a=b;b=t;
}
int main(){
  short h[10];
  LOOP(i,0,10)scanf("%d",h+i);
  LOOP(i,0,3){
    LOOP(j,i+1,10){
      if(h[i]<h[j])swap(h[i],h[j]);
    }
  }
  LOOP(i,0,3)printf("%d\n",h[i]);
}

Measured memory_bytes: 2720
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApplication5
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] strarr = Console.ReadLine().Split(' ');
            int r = int.Parse(strarr[0]);
            int c = int.Parse(strarr[1]);
            List<int[]> inputList = new List<int[]>();

            for (int i = 0; i < r; i++)
            {
                string[] inputarr = Console.ReadLine().Split(' ');
                inputList.Add(Array.ConvertAll(inputarr, new Converter<string, int>(s => int.Parse(s))));
            }

            List<int> tempColumn = new List<int>();
            for (int j = 0; j < r; j++)
            {
                tempColumn = inputList[j].ToList();
                tempColumn.Add(tempColumn.Sum());
                inputList[j] = tempColumn.ToArray();
            }

            List<int> tempRow = new List<int>();
            for (int k = 0; k < c; k++)
            {
                int temp = 0;
                foreach (int[] temparr in inputList)
                {
                    temp += temparr[k];
                }
                tempRow.Add(temp);
            }
            tempRow.Add(tempRow.Sum());
            inputList.Add(tempRow.ToArray());

            foreach(int[] outputInt in inputList)
            {
                string outputRow = string.Join(" ", Array.ConvertAll(outputInt, new Converter<int, string>(s => s.ToString())));
                Console.WriteLine(outputRow);
            }

            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 9736
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
using namespace std;

int main(){
    int x,a,b;cin>>x>>a>>b;
    if (abs(a-x)>abs(b-x)){
        cout << "B" << endl;
    } else {
        cout << "A" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1LL << 60
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const long long MOD=1000000007;

// vector<p> cut(M); vector<vector<ll> > v(4);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()), sort(v.rbegin(), v.rend()); //sort
// char '' str ""
int main(void)
{
    int N;cin>>N; std::vector<int> h;
    int ans=-1; int cnt=0;
    for(int i=0; i<N;i++){
      int bb; cin>>bb; h.push_back(bb);
    }
    int prev = h[0];
    for(int i=1; i<N;i++){
      if(prev >= h[i]){
        cnt++; prev = h[i];
      }else{
        ans = max(ans , cnt);
        cnt = 0;
        prev = h[i];
      }
    }
    ans = max(ans , cnt);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <algorithm>
#include <random>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define alll(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it;}cout<<endl;}

int main(){
    string s;
    ll n,a;
    cin >> n>>a;
    pr(n%500<=a ? "Yes":"No");
    return 0;
}


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

  vector<long> x(n);
  vector<long> y(n);
  int count = 0;
  rep(i, n) {
    cin >> x[i] >> y[i];
    if (sqrt(x[i]*x[i] + y[i]*y[i]) <= d) {
      count++;
    }
  }
  cout << count << endl;
}

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

int main() {
  int x1, x2, x3, x4, x5;
  cin >> x1 >> x2 >> x3 >> x4 >> x5;

  if (x1 == 0) {
    cout << 1 << endl;
  } else if (x2 == 0) {
    cout << 2 << endl;
  } else if (x3 == 0) {
    cout << 3 << endl;
  } else if (x4 == 0) {
    cout << 4 << endl;
  } else {
    cout << 5 << endl;
  }
}

Measured memory_bytes: 3632
# input
str = input()
n,m = str.split(" ")
n = int(n)
m = int(m)
arr = []

for i in range(0,int(n)):
    xyz = input()
    x,y,z = xyz.split(" ")

    arr.append([int(x),int(y),int(z)])
    
# 係数テーブル
pm = [[1,1,1],[1,1,-1],[1,-1,1],[1,-1,-1],[-1,1,1],[-1,1,-1],[-1,-1,1],[-1,-1,-1]]

# sort
mymax = -1
for item in pm:
    sumtmparr = []
    for a in arr:
        sumtmparr.append(item[0]*a[0]+item[1]*a[1]+item[2]*a[2])
            
    sumtmparr.sort(reverse=True)
    sumtmp = sum(sumtmparr[:m])
    #print(sumtmp)
    if sumtmp > mymax:
        mymax = sumtmp
print(mymax)

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

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

int main(){
    int N,W;
    cin >> N >> W;
    vector<int> w(N+1,0),v(N+1,0);
    rep(i,N) cin >> w[i+1] >> v[i+1];

    ll dp[101][100001];//N,value
    //ll dp[101][101];

    rep(i,101){    
        reps(j,1,100001){
            dp[i][j] = 1e15;
        }
    }

    reps(i,1,N+1){
        reps(j,1,1000*N + 1){
        //reps(j,1,101){
            if(j-v[i]>=0){
                if(dp[i-1][j-v[i]] + w[i] <= W)
                    dp[i][j] = min(dp[i-1][j] ,dp[i-1][j-v[i]] + w[i]);
                else{
                    dp[i][j] = dp[i-1][j];
                }
            }else{
                dp[i][j] = dp[i-1][j];
            }
        }
    }

    // rep(i,N+1){
    //     rep(j,80){
    //         if(dp[i][j] < 1e15)
    //             cout << dp[i][j] << " ";
    //         else 
    //             cout << "* ";
    //     }
    //     cout << endl;
    // }

    for(int j=1000*N; j >= 0; j--){
        if(dp[N][j] >= 0 && dp[N][j] < 1e15){
            cout << j << endl;
            break;
        }
    }

    return 0;
}

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

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

ll count_div5(ll n)
{
    ll ans = 0;
    n /= 10;
    while (n != 0) {
        ans += n;
        n /= 5;
    }
    return ans;
}

int main()
{
    ll n;
    cin >> n;
    ll ans;
    ans = n % 2 == 1 ? 0LL : count_div5(n);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    int ans = 0;
    for(int i = 1; i <= N; i++) {
        if(i % 2 == 0) continue;
        int tmp = 0;
        for(int j = 1; j <= i; j++) {
            if(i % j == 0) tmp++;
        }
        if(tmp == 8) {
            ans++;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
while True:
        table = input().split()

        a = int(table[0])
        op = table[1]
        b = int(table[2])

        if op == "?":
                break

        elif op == "+":
                print (a+b)
        elif op == "-":
                print (a-b)
        elif op == "*":
                print (a*b)
        elif op == "/":
                print (int(a/b))


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

std::string S;

bool allSame();

int main()
{
	int64_t K;
	std::cin >> S >> K;
	if (allSame())
	{
		printf("%lld\n", (int)S.size() * K / 2);
		return 0;
	}

	int64_t ans{};
	char prev{S.front()};
	int prev_i{};
	S.push_back('$');
	for (int i{}; i < (int)S.size(); i++)
	{
		if (S[i] == S[prev_i]) continue;
		ans += (i - prev_i) / 2;
		prev_i = i;
	}
	S.pop_back();
	while (S.front() == S.back())
	{
		S.erase(S.begin(), S.begin() + 1);
		S.push_back(S.back());
	}
	prev_i = 0;
	int64_t count{};
	prev = S.front();
	S.push_back('$');
	for (int i{}; i < (int)S.size(); i++)
	{
		if (S[i] == S[prev_i]) continue;
		count += (i - prev_i) / 2;
		prev_i = i;
	}
	S.pop_back();

	ans += (K - 1) * count;

	printf("%lld\n", ans);

	return 0;
}

bool allSame()
{
	for (auto& e: S)
		if (e != S.front())
			return false;
	return true;
}

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

int main() {
  int N;
  cin >> N;
  vector<vector<int>> groups(N, vector<int>(2));
  for (int i = 0; i < N; i++)
    cin >> groups.at(i).at(0) >> groups.at(i).at(1);
  int seats = 0;
  for (vector<int> x : groups)
    seats += x.at(1) - x.at(0) + 1;
  cout << seats;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;
using int32 = __uint32_t;

void solve() {
    int n;
    cin >> n;

    vector<string> v(n);
    vector<string> b, ea, rest, op;

    int ct = 0;
    for (int i = 0; i < n; i++) {
        cin >> v[i];
        if (v[i].front() == 'B' and v[i].back() == 'A')op.push_back(v[i]);
        else if (v[i].front() == 'B')b.push_back(v[i]);
        else if (v[i].back() == 'A')ea.push_back(v[i]);
        else rest.push_back(v[i]);
        for(int j = 0; j + 1 < v[i].size(); j++){
            if(v[i].substr(j, 2) == "AB")ct++;
        }
    }

    if(ea.size() + b.size() == 0 and op.size())ct += op.size() - 1;
    else if(op.size() == 0)ct += min(ea.size(), b.size());
    else if(op.size() and ea.size() + b.size() > 0)ct += op.size() +  min(ea.size(), b.size());
    
    cout << ct;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define REPZ(i, z, n) for(decltype(n) i = (z); i < (n); i++)
#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(all(v)))
#define MIN(v) (*min_element(all(v)))
#define INF 1000000000000 //1E+12
#define MOD 1000000007    //合同式の法

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<

typedef long long ll;
typedef unsigned long long ul;
// 1s間で可能なループ回数2E+8回
// llの最大値2147483647~2E+9
// long longの最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<> push_back
// 連想配列map<key,value> insert,
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 setprecision()
// to_string<->stoi
// stoll(longlong)
// stod(double)
// 大文字65-90(-32)
// 小文字97-122(+32)
using namespace std;
vector<ll> dres;
vector<vector<ll>> a;
vector<ll> c;
ll res=INF;
ll n,m,x;
void dfs(vector<bool> isused, ll d){ 
  if(d>n){
    dres = vector<ll>(m,0);
    ll cost=0;
    REP(i,n){
      if(isused[i+1]){
        REP(j,m){
          dres[j]=dres[j]+a[i][j];
        } 
        cost+=c[i];
      }
    }
    REP(i,m){
      if(dres[i]<x) return;
    }
    res = min(res,cost);
    return;
  }
  isused.push_back(false);
  dfs(isused,d+1);
  isused.back()=true;
  dfs(isused,d+1);
  
  return;
}
int main(){
  // faster
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  cin >> n >> m >> x;
  a = vector<vector<ll>>(n,vector<ll>(m));
  c = vector<ll>(n);
  REP(i,n){
    ll temp2; cin >> temp2;
    c[i]=temp2;
    REP(k,m){
      ll temp; cin >> temp;
      a[i][k] =temp;
    }
  }
  dfs(vector<bool>(1,false), 0);
  if(res==INF){
    cout << -1 << endl;
    return 0;
  }
  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 3660
#include <stdio.h>
#include <string.h>

int main( void ) {
	int n, sum;
	char ch[ 9 ][ 6 ] = { ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz" }, key, tmp;

	scanf( "%d ", &n );
	while ( n-- ) {
		while ( ( key = getchar() ) != '\n' ) {
			if ( key == '0' )
				continue;

			for ( sum = 0; ( tmp = getchar() ) != '0'; sum++ ) ;

			putchar( ch[ key - '1' ][ sum % strlen( ch[ key - '1' ] ) ] );
		}

		putchar( '\n' );
	}

	return 0;
}

Measured memory_bytes: 572
#include <iostream>

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

using namespace std;

long long int k(long long int n){
	if (n==0) return 1;
	return k(n/2)+1;
}

int main(){
	long long int x,y;
	cin >> x >> y;
	
	cout << k(y/x)-1 << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <map>
#include <tuple>
#include <cmath>
#include <cstdio>
#include <cassert>
#include <functional>
#define _LIBCPP_DEBUG 0
using namespace std;


int main(void){
    int  k;
    cin >> k;
    long long  seven=0;
    int r=7;
    for (int i = 0; i < k ;i++)
    {
        if (r%k==0)
        {
            cout << i+1 << endl;
            return  0;
        }
        else
        {
            r*=10;
            r+=7;
            r%=k;
        }
        
    }
    cout << -1 << endl;
}


Measured memory_bytes: 3592
#include<cstdio>
#include<algorithm>
using namespace std;
long long n,a[100002],z=1,zs;
int main()
{
  scanf("%d",&n);
  for(int i=1;i<=n;i++)
    scanf("%d",&a[i]);
  sort(a+1,a+n+1);
  for(int i=2;i<=n;i++)
    if(a[i]==a[i-1])  z=(z+1)%2;
    else  zs+=z,z=1;
  if(z%2)  zs++;
  printf("%d\n",zs);
  return 0;
}

Measured memory_bytes: 896
package main

import (
  "fmt"
  "regexp"
)

func main() {
  var s string
  fmt.Scan(&s)
  r := regexp.MustCompile(`^(hi)+$`)
  if r.MatchString(s) {
    fmt.Println("Yes")
  } else {
    fmt.Println("No")
  }
}

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

using namespace std;
using ll = long long;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount


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

    int d = __gcd(A[0], A[1]);
    for(int i = 0; i < N; i++)
    {
        d = __gcd(d, A[i]);
    }
    
    cout<<d<<endl;

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <set>

using namespace std;

int main(){

    int Q;
    cin >> Q;

    int cnt = 0;
    long long bSum = 0;
    pair<int, int> median;
    long long leftSum = 0;
    long long rightSum = 0;
    set<pair<int, int>> s;
    for(int i = 0; i < Q; i++){
        int type;
        cin >> type;
        if(type == 1){
            int a, b;
            cin >> a >> b;

            cnt++;
            s.insert(make_pair(a, cnt));

            bSum += b;

            if(i == 0){
                median = make_pair(a, cnt);
            }
            else{
                if(make_pair(a, cnt) < median){
                    if(cnt % 2 == 0){
                        // left
                        auto temp = s.find(median);
                        temp--;
                        rightSum += median.first;
                        leftSum += a;
                        median = *temp;
                    }
                    else{
                        // same
                        leftSum += a;
                        leftSum -= median.first;
                    }
                }
                else{
                    if(cnt % 2 == 0){
                        // same
                        rightSum += a;
                        leftSum += median.first;
                    }
                    else{
                        // right
                        auto temp = s.find(median);
                        temp++;
                        rightSum += a;
                        median = *temp;
                        rightSum -= median.first;
                    }
                }
            }
        }
        else{
            long long ans = bSum - leftSum + rightSum;
            cout << median.first << " " << ans << "\n";
        }
    }

    return 0;
}

Measured memory_bytes: 9600
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in=new Scanner(System.in);
		String k=in.next();
		int z=0;
		int flag=0;
		char[] a=new char[k.length()];
		char[] b=new char[k.length()];
		for(int i=0;i<k.length();i++)
		{
			a=k.toCharArray();
		}
		for(int i=0;i<k.length();i++)
		{
			if(a[i]=='C'||a[i]=='F')
			{
				b[z]=a[i];
				z++;
			}
		}
		for(int i=0;i<z;i++)
		{
			for(int j=i+1;j<=z-1;j++)
			{
				if(b[i]=='C'&&b[j]=='F')
					flag=1;
			}
		}
		if(flag==1)
			System.out.println("Yes");
		else
			System.out.println("No");

		
		in.close();
	}

}


Measured memory_bytes: 21204
import java.util.Scanner;
public class Main{

   int[] sequence;

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

   public void solve(){
      long sum = 0;
      String line = new Scanner(System.in).nextLine();
      sequence = new int[line.length()];

      for(int i=0; i<line.length(); i++){
         sequence[i] = Character.getNumericValue(line.charAt(i));
      }

      for(int i=0; i<(int)Math.pow(2.0,line.length()-1); i++){
         sum += addition(i);
      }

      System.out.println(sum);

   }

   public long addition(int pattern){
      boolean isOne = false;
      long temp = sequence[0];
      long sum = 0;
      for(int i=0; i<sequence.length-1; i++){
         if((pattern >> i & 0x1) == 1){
            sum += temp;
            temp = sequence[i+1];
            isOne = true;
         }else{
            isOne = false;
            temp *= 10;
            temp += sequence[i+1];
         }
      }
      sum += temp;
      return sum;
   }

}

Measured memory_bytes: 9684
#include <stdio.h>

int main(){

  int n,p,c[50],i,j,count;

  while(1){
  for(i = 0 ; i < 50 ; i++){
    c[i] = 0;
  }
    scanf("%d%d",&n,&p);
    if(n == 0 && p == 0){
      break;
    }
    i = 0;
    while(1){
      if(p > 0){
	c[i] += 1;
	p -= 1;
	i++;
      }
      else if(p == 0 && c[i] > 0){
	p = c[i];
	c[i] = 0;
	i++;
      }
      else if(p == 0 && c[i] == 0){
	i++;
      }
      count = 0;
      if(p == 0){
	for(j = 0 ; j < n ; j++){
	  if(c[j] > 0){
	    count++;
	  }
	}
      }
      if(count == 1){
	i -= 1;
	break;
      }
      if(i > n - 1){
	i = 0;
      }
    }
    printf("%d\n",i);
  }
  return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

struct UnionFind{
    vint v;
    UnionFind(int n){ v.assign(n,-1); }
    int  find(int x){ return v[x]<0? x:v[x]=find(v[x]); }
    void unite(int x,int y){ 
        x=find(x),y=find(y); if(x==y) return;
        if(v[x]>v[y]) swap(x,y); v[x]+=v[y],v[y]=x;
    }
    int  size(int x){ return -v[find(x)]; }
    bool same(int x,int y){ return find(x)==find(y); }
    bool root(int x){ return v[x]<0; }
};

signed main()
{
    int N,Q; cin>>N>>Q;
    UnionFind uf(N);
    while(Q--){
        int com,x,y; cin>>com>>x>>y;
        if(com==0) uf.unite(x,y);
        else cout<<uf.same(x,y)<<endl;
    }
}



Measured memory_bytes: 3160
#include <stdio.h>
int main(void) {
	int n;
	scanf("%d", &n);
	const char *ans = "No";

	int i, j;
	for (i = 1;i <= 9;i++) {
		for ( j = 1; j <= 9; j++){
			if (i * j == n) {
				ans="Yes";
				break;
			}
		}
	}
	printf("%s", ans);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
	long long s;
	cin>>s;
	cout<<0<<' '<<0<<' '<<int(1e9)<<' '<<1<<' '<<(int(1e9)-s%int(1e9))%int(1e9)<<' '<<(s+int(1e9)-1)/int(1e9)<<endl;
}


Measured memory_bytes: 256
/*
      author : nishi5451
      created: 11.08.2020 00:59:07
*/

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


int main(){
    int n,m;
    cin >> n >> m;
    cout << (n-1)*(m-1) << endl;
    return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>

  int main(){

    int a[100],t,j,i,length,minj,count=0;
    scanf("%d",&length);
    for(i=0;i<length;i++){
      scanf("%d",&a[i]);
    }

    for(i=0;i<length;i++){
      minj = i;

      for(j=i;j<length;j++){

  if(a[j] < a[minj]){
  minj =  j; 
  }
      }

      if(minj != i){
        t=a[i];
        a[i]=a[minj];
        a[minj]=t;

        count++;
      }
    }
    for(j=0;j<length;j++){

      printf("%d",a[j]);
      if(j != length-1)
      printf(" ");
    }
    printf("\n");
    printf("%d\n",count);

    return 0;
  }


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

using namespace std;
int main(){
  int n[3]; 
  cin >> n[0] >> n[1] >> n[2];
  sort(n, n+3, greater<int>());
  //cout << n[0] << n[1] << n[2] << endl;

  int a = n[0], b = n[1], c = n[2];
  int do_count=0;
  do_count += (a - b)/2;
  b += ((a - b)/2)*2;
  //cout << b << endl;

  do_count += (a - c)/2;
  c += ((a - c)/2)*2;
  //cout << c << endl;

  //cout << do_count << endl;
  int ans=0;
  if((a==b)&&(a==c))ans = do_count;
  else if((a!=b)&&(a!=c))ans = do_count+1;
  else if((a!=b)||(a!=c))ans = do_count+2;

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define INF ll(1e18)
#define MOD 998244353
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
#define MAXN 1000000007
 
 
int main() {
	ll a,b,c;
	cin>>a>>b>>c;
	if ((a<b) and (b<c)) {
		cout<<"Yes"<<endl;
	}
	else {
		cout<<"No"<<endl;
	}
}
	



Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define N 4010
using namespace std;

inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}
int n,ps[2][N],F[N][N],tree[N<<2];
int S1[N][N],S2[N][N];
inline void Add(int x)
{
	for(;x<=2*n;x+=x&-x)
		tree[x]++;
}
inline int Ask(int x)
{
	if(!x) return 0;
	int ret=0; for(;x;x-=x&-x)
		ret+=tree[x]; return ret;
}
int main()
{
	n=read();
	for(int i=1;i<=2*n;i++)
	{
		char s[3]; scanf("%s",s);
		int x=read();
		if(s[0]=='B') ps[0][x]=i;
		else ps[1][x]=i;
	}
	memset(tree,0,sizeof tree);
	for(int i=1;i<=n;i++)
	{
		Add(ps[0][i]);
		for(int j=1;j<=2*n;j++)
			S1[i][j]=Ask(j-1);
	}
	memset(tree,0,sizeof tree);
	for(int i=1;i<=n;i++)
	{
		Add(ps[1][i]);
		for(int j=1;j<=2*n;j++)
			S2[i][j]=Ask(j-1);
	}
	memset(F,0x3f,sizeof F); F[0][0]=0;
	for(int i=0;i<=n;i++) for(int j=0;j<=n;j++)
	{
		if(i<n)
		{
			int xm=ps[0][i+1];
			F[i+1][j]=min(F[i+1][j],F[i][j]+(xm-1-S1[i][xm]-S2[j][xm]));
		}
		if(j<n)
		{
			int xm=ps[1][j+1];
			F[i][j+1]=min(F[i][j+1],F[i][j]+(xm-1-S1[i][xm]-S2[j][xm]));
		}
	}
	cout << F[n][n] << endl;
	return 0;
}

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

int main(){
  double x,y,a,b;
  cin>>x>>y>>a>>b;
  double k = x*y/2;
  //double ans = k/2;
  int z;
  if(a+a == x && b+b == y)
    	z=1;
  else
    	z=0;
  cout<<k<<" "<<z;
}

Measured memory_bytes: 256
while 1:
    try:
        word = input()
    except EOFError:
        break

    newword = []
    word = list(word)
    while word != []:
        w = word.pop(0)
        if w == "@":
            count = int(word.pop(0))
            s = word.pop(0)
            for _ in range(count):
                newword.append(s)
        else:
            newword.append(w)

    print(''.join(w for w in newword))



Measured memory_bytes: 5596
import java.util.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    try {
      int n = sc.nextInt();
      Map<Integer, Integer> cnt = new HashMap<Integer, Integer>();
      boolean ans = true;
      for (int i = 0; i < n; i++) {
        int a = sc.nextInt() - 1;
        if (cnt.containsKey(a)) ans = false;
        cnt.put(a, 1);
      }
      System.out.println(ans ? "YES" : "NO");
    } finally {
      sc.close();
    }
  }
}

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

using namespace std;

const int N = int(1e6 + 10);
int a[N];
int b[N];
vector< int > balls;

int main(){
	int n;

	scanf("%d", &n);

	for(int i = 1 ; i <= n ; i++){
		scanf("%d", &a[i]);
	}

	for(int i = n ; i >= 1 ; i--){
		int cnt = 0;

		for(int k = i + i ; k <= n ; k += i){
			if(b[k]){
				cnt++;
			}
		}

		cnt = cnt & 1;

		if(cnt != a[i]){
			balls.push_back(i);
			b[i] = 1;
		}
	}

	printf("%lu\n", balls.size());

	for(int i = balls.size() - 1 ; i >= 0 ; i--){
		printf("%d\n", balls[i]);
	}

	return 0;
}

Measured memory_bytes: 6392
#include <iostream>
#include <map>
using namespace std;
typedef long long ll;

int main()
{
    int n;
    cin >> n;
    ll a[200005];
    map<ll, ll> mp;
    ll now = 0;
    mp[now]++;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        now += a[i];
        mp[now]++;
    }
    ll ans = 0;
    for(auto itr = mp.begin(); itr != mp.end(); itr++){
        ll num = itr->second;
        ans += num * (num - 1) / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 14336
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdio.h>

using namespace std;

//typedefリスト
typedef vector<long long int> vint;
typedef vector<vector<long long int>> vvint;
typedef vector<string> vstr;
typedef long long int llint;

llint gcd(llint x, llint y) {
	while (y != 0) {
		if (x > y) {
			llint r = x % y;
			x = y;
			y = r;
		}
		else {
			llint r = y % x;
			y = r;
		}
	}
	return x;
}

int main(void) {
	int N, M;
	cin >> N;
	vector<pair<int, int>> h(N);
	for (int i = 0; i < N; i++){
		cin >> h[i].first >> h[i].second;
	}
	cin >> M;
	vector<pair<int, int>> k(M + N);
	for (int i = 0; i < N; i++){
		k[i].first = h[i].first;
		k[i].second = h[i].second;

	}
	for (int i = N; i < N + M; i++)cin >> k[i].first >> k[i].second;
	sort(k.begin(), k.end());
	std::cout.fill('0');
	cout << k[0].first << ":" << std::setw(2) << k[0].second;
	for (int i = 1; i < M + N; i++){
		if (k[i].first != k[i - 1].first || k[i].second != k[i - 1].second){
			cout << " " << k[i].first << ":" << std::setw(2) << k[i].second;
		}
	}
cout<<endl;

}




Measured memory_bytes: 3120
#include <iostream>
#include <vector>
#include <map>
#include <math.h>
#include <algorithm>
using namespace std;

int dp(int k, int w, int* a, int* b);

int main(void){
    // Your code here!
    int a;
    std::cin >> a;
    int b;
    std::cin >> b;
    if(a <= 8 && b <= 8){
        std::cout << "Yay!" << std::endl;
    } else {
        std::cout << ":(" << std::endl;
    }
}

int dp(int k, int w, int* a, int* b){
    int result = 0;
    if(k == 1){
        if(a[1] > w){
            result = 0;
        } else {
            result = b[1];
        }
    } else {
        if(a[k] > w){
            result = dp(k-1, w, a, b);
        } else {
            result = max(dp(k-1, w, a, b),dp(k-1, w - a[k], a, b) + b[k]);
        }
    }
    return result;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

// int tr(int X, int N) {
// 	if(X&1) return X/2;
// 	return X/2+(1<<(N-1));
// }

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	// int N;
	// cin >> N;
	// vector<int> ans(1<<N, 0);
	// set<int> opS;
	// for(int X = 0; X < (1<<N); X++) if(ans[X] == 0) {
	// 	vector<int> v = {X};
	// 	int Y = tr(X, N), ops = 1;
	// 	while(Y != X) {
	// 		v.push_back(Y);
	// 		Y = tr(Y, N);
	// 		ops++;
	// 	}
	// 	for(auto x : v) ans[x] = ops;
	// 	opS.insert(ops);
	// }
	// int divs = 0;
	// for(int i = 1; i <= N; i += 2) if(N%i == 0) divs++;
	// cout << opS.size() << " " << divs << "\n";
	// for(auto s : opS) cout << s << "\n";
	int N;
	string X;
	cin >> N >> X;
	cat ans = 0, mod = 998244353;
	vector<cat> cnt(N+1, 0), use(N+1, 0);
	for(int i = 1; i <= N; i += 2) if(N%i == 0) {
		for(int j = 0; j < N/i; j++) cnt[N/i] = (cnt[N/i] * 2 + (X[j]-'0')) % mod;
		bool ok = true;
		for(int j = N/i; j < N; j++) if(X[j] == X[j-N/i]) {
			if(X[j] == '0') ok = false;
			break;
		}
		if(ok) cnt[N/i]++;
		use[N/i] = 1;
	}
	for(int i = 1; i <= N; i++) if(use[i]) {
		cnt[i] %= mod;
		for(int j = 2*i; j <= N; j += i) cnt[j] -= cnt[i];
		ans = (ans + 2LL * i * cnt[i]) % mod;
	}
	if(ans < 0) ans += mod;
	cout << ans << "\n";
	return 0;
}

// look at my code
// my code is amazing


Measured memory_bytes: 3732
import java.io.*;
import java.util.Arrays;
import java.util.Scanner;
import java.util.HashMap;
import java.util.Map;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int x=scan.nextInt();
        int cnt=0;
        while(x!=0){
            System.out.println("Case "+(++cnt)+": "+x);
            x=scan.nextInt();
        }
    }
}


Measured memory_bytes: 41040
#include "bits/stdc++.h"
using namespace std;
#define ll long long
// function to construct new array
void constructXOR(int A[], int n)
{
	// calculate xor of array
	int XOR = 0;
	for (int i = 0; i < n; i++)
		XOR ^= A[i];

	// update array
	for (int i = 0; i < n; i++)
		A[i] = XOR ^ A[i];
}
int main()
{
    int n; cin >> n;
    int A[n+1];
    for(int i = 0; i<n; i++){
        cin >> A[i];
    }
    constructXOR(A,n);
    for(int i = 0; i<n; i++){
        cout<<A[i]<<' ';
    }

return 0;
}





Measured memory_bytes: 4368
#include <iostream>
#include <string>
#include <cstring>

using namespace std;

int main(){
	string S;
  	cin >> S;
  	S.push_back('B');
  	int len = S.length();
  	int max=0, count=0;
  	for(int i=0; i < len; i++){
    	if(S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T'){
        	count++;
        }
      	else{
        	if(max < count)
              	max = count;
          	count = 0;
        }
    }
  	cout << max << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long 
#define rep(i,a,b) for(signed i=a;i<(b);++i)
#define erep(i,a,b) for(signed i=a;i<=(b);++i)
#define per(i,a,b) for(signed i=(a);i>(b);--i)
#define eper(i,a,b) for(signed i=(a);i>=b;--i)
#define fore(i, x, a) for(auto &&x:a) 
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define ALL(x) begin(x),end(x)
#define F first
#define S second
#define debug(x)  cout << #x << ": " << (x) << '\n';
const long long INF=1001001001001001001;
const int MOD=(int)1e9 + 7;
const double EPS=1e-9;
using namespace std;
using Pii = pair<int,int>;
using vii = vector<int>;
template<class T>using  PS_queue = priority_queue<T, vector<T>, greater<T> >;
template<class T>using vv = vector<T>;
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> ostream& operator<<(ostream &os,const vector<vector<T> > &v) {
    ITR(u,begin(v),end(v))ITR(w,begin(*u),end(*u))os<<*w<<(w==end(*u)-1?"\n":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct edge { int from, to, cost; };
int dy[]={0, 1, -1, 0}; int dx[]={1, 0, 0, -1};
// cout << fixed << setprecision(10) << val;

int n, a[100];
signed main() {
 cin.tie(0);
 ios::sync_with_stdio(false);

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

	int swap_cnt = 0;
	for (int i = 0; i < n; i++) {
		int mi = i;
		for (int j = i; j < n; j++) {
			if (a[j] < a[mi]) {
				mi = j;
			}
		}
		if (mi != i) {
			swap(a[i], a[mi]);
			swap_cnt++;
		}
	}
	for (int i = 0; i < n; i++) {
		cout << a[i] << (i != n-1 ? " " : "\n");
	}
	cout << swap_cnt << endl;
  return 0;
}





Measured memory_bytes: 3200
#include <iostream>
#include <math.h>

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long int n, k;
    cin >> n >> k;
    n = n % k;
    n = (n > abs(n - k)) ? abs(n - k) : n;
    cout << n;
    return 0;
}

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

using namespace std;
typedef int long long ill;
typedef long long ll;

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

Measured memory_bytes: 3628
#include <cstdio>
#include <algorithm>
#include <vector>

using std::sort;
using std::vector;

const int MAXN=1e5+5;
int rt,n,A,B;
int he[MAXN],deg[MAXN];
int dp[MAXN];

struct line{int to,nex;}ed[MAXN<<1];

inline void addE(int u,int v){
	static int cnt;
	ed[++cnt]=(line){v,he[u]};
	he[u]=cnt;
}

inline bool cmp_dp(int a,int b){return dp[a]<dp[b];}

inline bool check(vector<int> &vec,int son){
	for(int l=0,r=vec.size()-1;l<r;++l,--r){
		if(l==son) ++l;
		if(r==son) --r;
		if(dp[vec[l]]+dp[vec[r]]>B)
			return false;
	}
	return true;
}

inline int bin_chop_son(vector<int> &vec){
	int l=0,r=vec.size()-1,mid;
	while(l<=r){
		mid=l+r>>1;
		if(check(vec,mid)) r=mid-1;
		else l=mid+1;
	}
	return l;
}

bool treeDP(int u,int fa){
	bool ret=true;
	vector<int> vec;
	for(int i=he[u],v;i;i=ed[i].nex){
		v=ed[i].to;
		if(v!=fa){
			ret&=treeDP(v,u);
			vec.push_back(v);
		}
	}
	if(!ret) return false;
	if(vec.size()==0){
		dp[u]=1;
		return true;
	}
	//度数为奇数，则儿子为偶数个
	if(deg[u]&1) vec.push_back(0);
	sort(vec.begin(),vec.end(),cmp_dp);
	int v=bin_chop_son(vec);
	if(v==vec.size()) return false;
	dp[u]=dp[vec[v]]+1;
	return dp[u]<=B+1;
}

inline void bin_chop_B(){
	int l=0,r=n;
	while(l<=r){
		B=l+r>>1;
		if(treeDP(rt,0)) r=B-1;
		else l=B+1;
	}
	B=l;
}

inline void cal_A(){
	int cnt=0;
	for(int i=1;i<=n;++i)
		cnt+=deg[i]&1;
	A=cnt>>1;
}

int main(){
	scanf("%d",&n);
	for(int i=1,u,v;i<n;++i){
		scanf("%d%d",&u,&v);
		++deg[u],++deg[v];
		addE(u,v),addE(v,u);
	}
	cal_A();
	for(int i=1;i<=n;++i){
		if(deg[i]==1){
			rt=i;
			break;
		}
	}
	bin_chop_B();
	printf("%d %d",A,B);
	return 0;
}

Measured memory_bytes: 12288
n, m = map(int, input().split())
s = []

for i in range(m):
    temp = list(map(int, input().split()))
    s.append(temp[1:])

p = list(map(int, input().split()))

# print(s)

def isAllOn(n):
    # print('\nn:', n)
    for i in range(m):
        # print('Light:', i)
        bitCnt = 0
        for j in range(len(s[i])):
            pos = s[i][j] - 1
            # print('pos:', pos)
            bit = (n >> pos) & 1
            if bit == 1:
                bitCnt += 1
        if bitCnt % 2 != p[i]:
            # print('False!')
            return False

    return True

ans = 0

for i in range(2**n):
    if isAllOn(i):
        ans += 1

print(ans)

Measured memory_bytes: 40432
#include <iostream>
#include <cstdio>
#include <string.h>
#include <algorithm>
#include <queue>
#include <set>
#include <vector>
#include <stack>
using namespace std;
   int n,m,ans=0;
   bool e[50][50],vis[50];
   int a[50],b[50];
void dfs(int x){
       vis[x]=true;
       for(int i=0;i<n;i++){
           if(e[x][i]&&!vis[i])dfs(i);
       }
}
int main(void){

   cin>>n>>m;
   for(int i=0;i<n;i++){
       for(int j=0;j<n;j++)e[i][j]=false;
   }
   for(int i=0;i<m;i++){
      
       cin>>a[i]>>b[i];
       a[i]--;
       b[i]--;
       e[a[i]][b[i]]=true;
       e[b[i]][a[i]]=true;
   }
   
   
   for(int i=0;i<m;i++){
       e[a[i]][b[i]]=e[b[i]][a[i]]=false;
       for(int i=0;i<n;i++)vis[i]=false;
       dfs(0);
       for(int i=0;i<n;i++){
           if(!vis[i]){
               ans++;
               break;
           }
       }
       e[a[i]][b[i]]=e[b[i]][a[i]]=true;
   }
   cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<bits/stdc++.h>
using namespace std;

int main()
{
	
	string w;
	cin>>w;
	
	int count;
	int i,j;
	for(i=0;i<w.size();i++)
	{
		  count=0;
	     for(j=0;j<w.size();j++)
	     {
	     	 
	     	   if(w[i]==w[j])
	     	   {
	     	   	
	     	       count++;	
	     	   	
			   }
	     	
	     		
		 }
		 
		 
		 if(count%2!=0)
		 {
		 	
		 	break;
		 	
		 }
		
		
	
	}
	
	
	
	
	if(i==w.size())
	{
		
		cout<<"Yes"<<endl;
		
	}
	
	
	else
	{
		
		
		cout<<"No"<<endl;
	}
	

	return 0;
	
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << (a + b >= c ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstddef>

int main(){
    std::string buf;
    int n;

    std::cin >> n;
    // now, there is "\n ...." in the stream.
    // then, skip the initial '\n'.
    std::getline(std::cin,buf);

    for (int i=0;i < n;++i) {
        std::getline(std::cin,buf);
        size_t pos = 0; // index where we will start searching.

        while (true) {
            pos = buf.find("Hoshino",pos);
            if (pos == std::string::npos) {    // couldn't find.
                break;
            }else{
                buf.replace(pos,7,"Hoshina");
                pos += 7;
            }
        }
        std::cout << buf << std::endl;
    }

    return 0;
}

Measured memory_bytes: 1208