akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		char[] s = sc.next().toCharArray();
		sc.close();
		boolean f=false;
		if(n%2==0) {
			f=true;
			for(i=0;i<n/2;i++) {
				if(s[i]!=s[i+n/2]) {
					f=false;
					break;
				}
			}
		}
		out.println(f?"Yes":"No");
	}
}


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

struct Problem{

    void Solve() {

        LL a, b, c; cin >> a >> b >> c;
        LL k; cin >> k;
        LL ans = 0;
        ans += min(a, k); k -= min(a, k);
        k -= min(b, k);
        ans -= min(c, k); k -= min(c, k);
        cout << ans << endl;
    }
};
int main() {
    unique_ptr<Problem> p(new Problem());
    p->Solve();
    return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

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

int getRand(int l, int r)
{
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
  
#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define precise(x) fixed << setprecision(x) 

const int MOD = 998244353;

int mod_pow(int a,int b,int M = MOD)
{
    int res = 1;
    
    while(b)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }
    
    return res;
}

const int N = 2e5 + 10;
int dp[N];
int pref[N];

void solve()
{
   dp[0] = pref[0] = 1;
    
   int n,k;
    cin >> n  >> k;
    
   pii a[k];
   f(i,k) cin >> a[i].F >> a[i].S;
    
   f(i,k) swap(a[i].F,a[i].S); 
    
   for(int i=1;i<n;i++)
   {
       for(int j=0;j<k;j++)
       {
           // add pref[i - a[j].S]
           if(i - a[j].S >= 0) dp[i] = (dp[i] + pref[i-a[j].S])%MOD;
           
           // remove pref[i - a[j].F - 1]
           if(i - a[j].F - 1 >= 0) dp[i] = (dp[i] + MOD - pref[i-a[j].F-1])%MOD;
       }
       
       pref[i] = (pref[i-1] + dp[i])%MOD;
   }
    
   cout << dp[n-1]; 
}

signed main()
{
    fast;
    
    int t = 1;
    
//    cin >> t;
    
    while(t--)
        
    solve();
}

Measured memory_bytes: 6740
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<int,int> P;
#define fi first
#define se second
#define all(v) (v).begin(),v.end()
set<string> c;
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
bool dpx[8000][17001],dpy[8000][17001];
int main(){
string s;
int x,y;
cin>>s>>x>>y;
int mid=16001/2;
int t=0;
int j=0;
for(int i=0;i<s.size();i++){
    if(t%2==0){
        int cnt=0;
        while(i+cnt<s.size()&&s[i+cnt]!='T'){cnt++;}
        //cout<<cnt<<endl;
        if(j==0){
            dpx[0][mid+cnt]=true;
        }
        else{
            for(int d=0;d<16050;d++){
                if(cnt+d<16050&&dpx[j-1][cnt+d])dpx[j][d]=true;
                else if(d-cnt>=0&&dpx[j-1][d-cnt])dpx[j][d]=true;
            }
        }
        i+=cnt;
        j++;
    }
    if(i<s.size()&&s[i]=='T')t++;
}

int k=0;
dpy[0][mid]=true;
t=0;
for(int i=0;i<s.size();i++){
    if(t%2==1){
        int cnt=0;
        while(i+cnt<s.size()&&s[i+cnt]!='T'){cnt++;}
            for(int d=0;d<16050;d++){
                if(cnt+d<16050&&dpy[k][cnt+d])dpy[k+1][d]=true;
                else if(d-cnt>=0&&dpy[k][d-cnt])dpy[k+1][d]=true;
            }
        i+=cnt;
        k++;
    }
    if(i<s.size()&&s[i]=='T')t++;
}
if(dpx[j-1][mid+x]&&dpy[k][mid+y])cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}


Measured memory_bytes: 135936
implicit none
integer(8) :: i,j,k,n

read(5,*) n
#do i = 1, int(3*n/4)
do i = int(3*n/4),1,-1
  do j = int(3*n/4), 3500
      do k = i, j
          if(4*i*j*k==n*(i*j+j*k+k*i)) then
          goto 100
          endif
enddo
enddo
enddo

100 write(6,"(i0,1x,i0,1x,i0)") i,j,k
end

Measured memory_bytes: 896
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    int N;
    cin >> N;

    string S;
    cin >> S;

    int max_x = 0;
    int x = 0;
    FOR(i, 0, N){
        max_x = max(max_x, x);

        if(S[i]=='I'){
            x++;
        }else{
            x--;
        }

        max_x = max(max_x, x);
    }

    p(max_x);

    return 0;
}

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

typedef long long ll;
typedef long double ld;

int dist[205][205];
int graf[205][205];

const int INF = 100005;

int col[10005];

int n;

bool visited[10005];

void dfs_check(int v, int color){
    visited[v] = 1;
    col[v] = color;
    for(int c=1; c<=n; c++){
        if(!graf[v][c]) continue;
        if(!visited[c]) dfs_check(c, 1-color);
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    cin >> n;
    for(int i=1; i<=n; i++){
        string s;
        cin >> s;
        for(int j=1; j<=n; j++){
            if(s[j-1] == '1') graf[i][j] = 1;
        }
    }
    dfs_check(1, 0);
    for(int i=1; i<=n; i++){
        for(int j=1; j<=n; j++){
            if(graf[i][j] && col[i] == col[j]){
                cout << -1;
                return 0;
            }
        }
    }
    for(int i=1; i<=n; i++){
        for(int j=i+1; j<=n; j++){
            if(!graf[i][j]) dist[i][j] = dist[j][i] = INF;
            else dist[i][j] = dist[j][i] = 1;
        }
    }
    for(int k=1; k<=n; k++){
        for(int i=1; i<=n; i++){
            for(int j=1; j<=n; j++){
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
    int res = 0;
    for(int i=1; i<=n; i++){
        for(int j=i+1; j<=n; j++){
            res = max(res, dist[i][j]);
        }
    }
    cout << 1+res;
    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static Scanner sc = new Scanner(System.in);
	public static void main(String[] args){
		//C
		int N = sc.nextInt();
		int K = sc.nextInt();
		int ans = 999999999;
		int[] x = new int[N];
		for(int i = 0 ; i < N ; i++){
			x[i] = sc.nextInt();
		}
		int a;
		int b;
		int tmp;
		for(int i = 0 ; i <= N-K ; i++){
			a = x[i];
			b = x[i+K-1];
			if(a >= 0){
				tmp = Math.abs(b);
			}else if(b <= 0){
				tmp = Math.abs(a);
			}else{
				tmp = Math.abs(a) + Math.abs(b) + Math.min(Math.abs(a), Math.abs(b));
			}
			ans = Math.min(tmp, ans);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 50180
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353,INF=1e18;



int main() {
    int N;
    cin>>N;
    cout<<(N-2)*180<<endl;
}

Measured memory_bytes: 256
/*
Look at the star
Lokk at the shine for U
*/ 

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e6+5;
const ll mod = 1e9+7;
const ll INF = 0x3f3f3f3f;
int s[N];

int main()
{
	int n,i,j,k;
	scanf("%d",&n);
	for(i = 0;i < n;i++)
	scanf("%d",&s[i]);
	int ans = 0;
	for(i = 1;i < n;i++)
	{
		if(s[i] == s[i-1])
		{
			ans++;
			s[i] = INF;
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 256
n,m = map(int,input().split())
p = []
s = []
ac = [0 for i in range(n)]
wa = [0 for i in range(n)]
for i in range(m):
    p_i,s_i = input().split()
    if ac[int(p_i)-1] == 0:
        if s_i == "WA":
            wa[int(p_i)-1] += 1
        elif s_i == "AC":
            ac[int(p_i)-1] += 1
for i in range(n):
    if ac[i] == 0 and wa[i] > 0:
        wa[i] = 0
print(sum(ac),sum(wa))

Measured memory_bytes: 4760
#include<iostream>
#include<vector>
#include<stdio.h>
#define ll long long
using namespace std;
const ll INF=1e18L+5;

void max_self(ll &a,ll b){
  a=max(a,b);
}

void min_self(ll &a,ll b){
  a=min(a,b);
}

int main()
{
  ll n,W;
  scanf("%lld%lld",&n,&W);
  vector<ll>weight(n),value(n);
  for(ll i=0;i<n;i++)
    scanf("%lld%lld",&weight[i],&value[i]);
  ll sum_value=0;
  for(ll x: value)
   sum_value+=x;
  vector<ll>dp(sum_value+1,INF);
  dp[0]=0;
  for(ll item=0;item<n;item++){
    for(ll value_already=sum_value-value[item];value_already>=0;value_already--)
    {
      min_self(dp[value_already+value[item]],dp[value_already]+weight[item]);
    }
  }
  ll answer=0;
  for(ll i=0;i<=sum_value;i++){
    if(dp[i]<=W){
      answer=max(answer,i);
    }
  }
  printf("%lld\n",answer);
}
  

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#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 << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}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;

/*
0-index
functionの中を書いて使う
segtree<ll> seg(n, [](ll a, ll b){return a + b;}, 0);
*/
template<typename T>
struct segtree{
	int n;
	vector<T> dat;
	T ZERO;
	function<T(T,T)> func;//要素と要素をマージする関数

	segtree(int n_, function<T(T,T)> func_, T zero):func(func_), ZERO(zero){
	  n = 1;
	  while(n < n_)n*=2;
	  dat.resize(2*n);
	  for(int i = 0;i < 2*n;i++)dat[i] = ZERO;
	}

	void update(int k, T a){
	  k += n - 1;dat[k] = a;
	  while(k > 0){
		k = (k-1)/2;
		dat[k] = func(dat[k*2+1],dat[k*2+2]);
	  }
	}

	void set(int k, T a) {
		k += n - 1;dat[k] = a;
	}

	void build(){
		for(int i = n - 2;i >= 0;i--){
			dat[i] = func(dat[2 * i + 1], dat[2 * i + 2]);
		}
	}

	T get(int k){return dat[k+n-1];}

	T que(int a,int b){
		T L = ZERO,R = ZERO;
		int A = a + n - 1;
		int B = b + n - 1;
		while(A < B){
			if((A & 1) == 0)L = func(L,dat[A++]);
            if((B & 1) == 0)R = func(dat[--B],R);
            A = A >> 1;
            B = B >> 1;
		}
		return func(L,R);
	}
};


vector<P> v;
segtree<ll> seg(222222, [](ll a, ll b){return max(a, b);}, -LLINF);
ll num[222222];

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

	ll n;cin >> n;
	num[n] = 1;
	num[n+1] = 1;
	REP(i, n){
		ll x, d;cin >> x >> d;
		d += x;
		v.EB(x, d);
	}
	sort(ALL(v));
	REP(i, n)seg.update(i, v[i].SE);

	REV(i, n){
		int id = lower_bound(ALL(v), MP(v[i].SE, -LLINF)) - v.begin();
		v[i].SE = seg.que(i, id);
		seg.update(i, v[i].SE);
	}

	REV(i, n){
		int id = lower_bound(ALL(v), MP(v[i].SE, -LLINF)) - v.begin();
		num[i] = (num[i+1] + num[id]) % MOD;
	}

	cout << num[0] << endl;

	return 0;
}


Measured memory_bytes: 10352
#枚数の入力
n = gets.chomp.to_i
#カードの入力と大きい順にそーと
nums = gets.chomp.split(" ").map(&:to_i).sort.reverse
#アリスとボブの各合計を計算
alice_sum = 0
bob_sum = 0
(1..n).each do |i|
  (i - 1) % 2 == 0 ? alice_sum += nums[i - 1] : bob_sum += nums[i - 1]
end
#差の出力
puts alice_sum - bob_sum

Measured memory_bytes: 1788
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)

n,m = map(int,input().split())
a = list(map(int,input().split()))
toku = sum(a)
flag = toku*(1/(4*m))
cnt = 0
for i in range(len(a)):
    if a[i]>=flag:
        cnt += 1
if cnt >= m:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 21772
N, M = gets.split.map(&:to_i)

if (N-M).abs > 1
  puts 0
  exit
end

def fact(n)
  fact = Array.new(n)
  fact[0] = 1
  for i in 1..n do
    fact[i] = fact[i-1] * i % (10 **9 + 7)
  end
  fact[n]
end

ans = fact(N) * fact(M) 
if N == M
  ans *= 2
end

puts ans % (10 **9 + 7)

Measured memory_bytes: 3836
# やっぱり全探索で大丈夫． その文字列を作る方法がDFSになっております
# まぁどっちでも同じか？なんかこういうときはDFSを使う決まりでもあんのかなぁ
N,M,Q=map(int,input().split())
A=[] # ミュータブルオブジェクトでこれやっちゃうとあかん
B=[]
C=[]
D=[]
for _ in range(Q):
    a,b,c,d=map(int,input().split())
    A.append(a)
    B.append(b)
    C.append(c)
    D.append(d)

# 再帰で呼び出せばいいらしいんだけど．．．
# 再帰で呼び出して，条件を満たすような文字列を作るように私用．
# 現在作っている文字列のながさがNになった時点でリストにappendするようにする
# dfsで再帰的に文字を返すのではないのがみそか
A_lis=[]
def dfs(s):
    global A_lis
    if len(s)==N:
        A_lis.append(s)
        return None
    last = s[-1]
    for i in range(last,M+1):
        new=s+[i]
        dfs(new)
for a in range(1,M+1):
    dfs([a])
max_score=0
for a in A_lis:
    score=0
    for i in range(Q):
        if a[B[i]-1]-a[A[i]-1]==C[i]:
            score+=D[i]
    max_score=max(max_score,score)
print(max_score)




Measured memory_bytes: 22904
#include<iostream>

using namespace std;

int main(){
  for (int x, y, t = 1; ; t++ ) {
    cin >> x >> y;
   if ( x == 0 && y == 0 ) break;
  if( x < y ) cout << x << " " << y << endl;
  else cout << y << " " << x << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

vector<ll>a[100010];
int main() {
	ll n,m;
	cin>>n>>m;
	for(ll i=0;i<m;i++){
		ll x,y;
		cin>>x>>y;
		x--;y--;
		a[x].push_back(y);
	}
	ll ch[100010][3];
	for(ll i=0;i<n;i++){
		for(ll j=0;j<3;j++){
			ch[i][j]=-1;
		}
	}
	ll s,e;
	cin>>s>>e;
	s--;e--;
	queue<pair<ll,ll>>q;
	ch[s][0]=0;
	q.push(make_pair(s,0));
	while(q.size()!=0){
		pair<ll,ll> now=q.front();
		//cout<< now.first<<now.second;
		q.pop();
		for(ll i=0;i<a[now.first].size();i++){
			ll next=a[now.first][i];
			if(ch[next][(now.second+1)%3]!=-1){
				continue;
			}
			ch[next][(now.second+1)%3]=ch[now.first][now.second]+1;
			q.push(make_pair(next,(now.second+1)%3));
		}
		//cout << "k"<<endl;
		//cout << ch[1][1];
	}
	if(ch[e][0]==-1){
		cout << -1;
	}
	else{
	cout << ch[e][0]/3;
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
 
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector<vvvi> vvvvi;
 
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n, ans = 1e15;
    cin >> n;
    for (ll i = 1; i <= sqrt(n); ++i) {
        if (n%i == 0) {
            ans = min(ans, (i-1) + (n/i - 1));
        }
    }
    cout << ans << "\n";
    return 0;
}

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

int main()
{
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a,a+3);

    cout << (a[0] + a[1] == a[2] ? "Yes" : "No") << endl;
    
    return 0;
}

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

int main(){
    map<char,int> mp;
    string S;
    int ans=0;
    cin >> S;
    for(auto s: S){
        mp[s]++;
    }
    for(auto&p :mp){
        if(p.second==2){
            ans +=1;
        }
    }
    if(ans == 2){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    } 
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;
using Graph = vector<vector<int>>;

typedef long long LL;
static LL INF = (1LL<<62);

LL N;
vector<LL> A;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> N;
	for(int i=0; i<N; i++){
		LL a;
		cin >> a;
		A.push_back(a);
	}
	sort(A.begin(), A.end());

	vector<LL> S;
	for(int i=0; i<A.size(); i++){
		if(i == 0){
			S.push_back(A[0]);
		}
		else{
			S.push_back(S[i-1] + A[i]);
		}
	}

	LL ans = 1;
	for(int i=S.size()-1; i>=1; i--){
		if(S[i-1] * 2 >= A[i]){
			ans++;
		}
		else{
			break;
		}
	}
	printf("%lld\n", ans);
	return 0;
}



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

const int mod = 1e9 + 7;

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

/*-------------------------------------------*/

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

    int n;
    string s;
    map<pair<string, string>, int> mp;
    cin >> n >> s;

    rep(i, 1 << n) {
        string a = {}, b = {};
        rep(j, n)((i >> j) & 1 ? a : b).push_back(s[j]);
        mp[{a, b}]++;
    }

    ll ans = 0;

    rep(i, 1 << n) {
        string a = {}, b = {};
        rep(j, n)((i >> j) & 1 ? a : b).push_back(s[2 * n - 1 - j]);
        ans += mp[{a, b}];
    }

    cout << ans << endl;
}

Measured memory_bytes: 91904
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let v: Vec<char> = get!(String).chars().collect();
    let mut len = 0;
    'outer: for i in 0..v.len() {
        let mut t_len = 0;
        for j in 0..v.len() {
            if j < i {
                continue;
            }
            if v[i] == 'A' || v[i] == 'C' || v[i] == 'G' || v[i] == 'T' {
                if v[j] == 'A' || v[j] == 'C' || v[j] == 'G' || v[j] == 'T' {
                    t_len += 1;
                    if len < t_len {
                        len = t_len;
                    }
                //eprintln!("i: {}, vi: {}", i, v[i]);
                //eprintln!("j: {}, vj: {}", j, v[j]);
                //eprintln!("len: {}, t_len: {}", len, t_len);
                } else {
                    if len < t_len {
                        len = t_len;
                    }
                    //t_len = 0;
                    continue 'outer;
                }
            } else {
                //t_len = 0;
                continue 'outer;
            }
            //koko
        }
    }
    println!("{}", len);
}


Measured memory_bytes: 4352
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// http://dai1741.github.io/maximum-algo-2012/docs/minimum-spanning-tree/
// 素集合データ構造
struct UnionFind
{
 // par[i]：データiが属する木の親の番号。i == par[i]のとき、データiは木の根ノードである
 vector<int> par;
 // sizes[i]：根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる
 vector<int> sizes;

 UnionFind(int n) : par(n), sizes(n, 1) {
   // 最初は全てのデータiがグループiに存在するものとして初期化
   rep(i,n) par[i] = i;
 }

 // データxが属する木の根を得る
 int find(int x) {
   if (x == par[x]) return x;
   return par[x] = find(par[x]);  // 根を張り替えながら再帰的に根ノードを探す
 }

 // 2つのデータx, yが属する木をマージする
 void unite(int x, int y) {
   // データの根ノードを得る
   x = find(x);
   y = find(y);

   // 既に同じ木に属しているならマージしない
   if (x == y) return;

   // xの木がyの木より大きくなるようにする
   if (sizes[x] < sizes[y]) swap(x, y);

   // xがyの親になるように連結する
   par[y] = x;
   sizes[x] += sizes[y];
   // sizes[y] = 0;  // sizes[y]は無意味な値となるので0を入れておいてもよい
 }

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

 // データxが含まれる木の大きさを返す
 int size(int x) {
   return sizes[find(x)];
 }
};

int main() {
    ll n,k,l;
    std::cin >> n>>k>>l;
    UnionFind p(n);
    UnionFind r(n);
    for (int i = 0; i < k; i++) {
        ll a,b;
        std::cin >> a>>b;
        a--;
        b--;
        p.unite(a,b);
    }

    for (int i = 0; i < l; i++) {
        ll a,b;
        std::cin >> a>>b;
        a--;
        b--;
        r.unite(a,b);
    }
    
    std::map<ll, vector<ll>> m;
    for (int i = 0; i < n; i++) {
        m[p.find(i)].push_back(i);
    }
    
    ll result[200010];

    for (auto e : m) {
        unordered_map<ll,vector<ll>> um;
        for (auto ee : e.second) {
            um[r.find(ee)].push_back(ee);
        }
        for (auto ee : e.second) {
            result[ee] = um[r.find(ee)].size();
        }
    }
    
    for (int i = 0; i < n-1; i++) {
        std::cout << result[i]<<" ";
    }
    std::cout << result[n-1] << std::endl;
}


Measured memory_bytes: 25404
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1000000007;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

ll dp[55][2505][55];

int main(){
    ll N,A;
    cin >> N >> A;
    vector<ll> x(N);
    rep(i,N){
        cin >> x[i];
    }
    dp[0][0][0] = 1;
    rep(i,N){//iko tsukatte heikin A,
        rep(j,N*50+1){
            rep(k,i+1){
                if(2500 >= j+x[i]){
                    dp[i+1][j+x[i]][k+1] += dp[i][j][k];
                }
                dp[i+1][j][k] += dp[i][j][k];
            }
        }
    }
    ll ans = 0;
    REP(i,1,N+1){
        ans += dp[N][A*i][i];
    }
    cout << ans << endl;
    /*
    rep(i,(1LL << N)){
        ll sum = 0;
        ll nc = 0;
        rep(j,N){
            if((i >> j)&1LL){
                sum += x[j];
                nc++;
            }
        }
        if(!nc) continue;
        if(sum % nc != 0) continue;
        if(sum/nc == A){
            ans++;
        }
    }
    cout << ans << endl;*/
}

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

int main(){
    string s;cin>>s;
    string target = "CODEFESTIVAL2016";

    int acc = 0;
    for (int i=0;i<s.size();i++){
        if (s[i] != target[i]){
            acc++;
        }
    }
    cout << acc <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

int h, w;
inline bool inside(int y, int x){
    return 0 <= y and y < h and 0 <= x and x < w;
}
inline bool valid(int y, int x){
    return inside(y, x) and inside(y + 2, x + 2);
}

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

    int n; cin >> h >> w >> n;
    vi a_(n), b_(n);
    map<int, map<int, int>> dic;
    rep(i, n) cin >> a_[i] >> b_[i], a_[i]--, b_[i]--, dic[a_[i]][b_[i]] = 1;

    map<int, map<int, bool>> used;
    vll tbl(10); tbl[0] = (h - 2LL) * (w - 2);
    rep(i, n){
        int a = a_[i], b = b_[i];
        rep(da, -2, 1){
            rep(db, -2, 1){
                int na = a + da, nb = b + db;
                if(not valid(na, nb) or used[na][nb]) continue;
                used[na][nb] = true;
                int cnt = 0;
                rep(j, 3){
                    rep(k, 3){
                        cnt += dic[na + j][nb + k];
                    }
                }
                assert(cnt >= 1);
                assert(cnt <= 9);
                tbl[cnt]++;
            }
        }
    }

    rep(i, 1, 10) tbl[0] -= tbl[i];
    for(auto& e : tbl) cout << e << endl;

    return 0;
}


Measured memory_bytes: 235392
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef struct node {
  int key;
  struct node *parent,*left,*right;
}Node;
  
Node *root,*NIL;

void insert(int);
void inorder(Node *);
void preorder(Node *);
Node * find(Node *,int);

void insert(int k){
  Node *y=NIL;
  Node *x=root;
  Node *z;

  z=(Node *)malloc(sizeof(Node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;

  while(x!=NIL){
    y=x;
    if(z->key < x->key){
      x=x->left;
    }else{
      x=x->right;
    }
  }

  z->parent=y;

  if(y==NIL){
    root=z;
  }else{
    if(z->key < y->key){
      y->left=z;
    }else{
      y->right=z;
    }
  }
}

void inorder(Node *u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node *u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

Node * find(Node *u,int k){
  while(u!=NIL&&k!=u->key){
    if(k<u->key){
      u=u->left;
    }else{
      u=u->right;
    }
  }
  return u; 
}

int main(){
  int m,i,x;
  char com[10];
  
  scanf("%d",&m);
  
  for(i=0;i<m;i++){
    scanf("%s",com);
    if(strcmp(com,"find")==0){
      scanf("%d",&x);
      Node *t=find(root,x);
      if(t!=NIL) printf("yes\n");
      else printf("no\n");
    }else if(strcmp(com,"insert")==0){
      scanf("%d",&x);
      insert(x);
    }else if(strcmp(com,"print")==0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  } 
  return 0;
}

Measured memory_bytes: 21340
n, k = map(int, input().split())
a = list(map(int, input().split()))

dist = [-1 for i in range(n)]
dist[0] = 0

now_town = 0
freq = 0
for i in range(k):
    next_town = a[now_town] - 1
    if dist[next_town] != -1:
        freq = (i+1) - dist[next_town]
        const = dist[next_town]
        break
    dist[next_town] = i + 1
    now_town = next_town

if freq == 0:  # ループが発生していない場合
    print(next_town+1)
else:  # ループが発生している場合
    freq_ = (k - const) % freq
    if freq_ == 0:
        print(next_town+1)
    else:
        now_town = next_town
        for i in range(freq_):
            now_town = a[now_town] - 1
        print(now_town+1)


Measured memory_bytes: 32180
# include<iostream>
# include<string.h>
using namespace std;

int main(void)
{
    char s[113];
    int n;
    cin >> n;
    cin >> s;
    int sum = 0;
    int flag1[30], flag2[30];
    for(int i = 0, j; s[i+1] != '\0'; ++i)
    {
        memset(flag1, 0, sizeof(flag1));
         memset(flag2, 0, sizeof(flag2));
        for(j = 0; j <= i; ++j)
        {
            flag1[s[j]-'a'] = 1;
        }
        for(; s[j] != '\0'; ++j)
        {
            flag2[s[j]-'a'] = 1;
        }
        int q = 0;
        for(j = 0;j < 26; ++j)
        {
            if(flag1[j] == 1 && flag2[j] == 1)
                q++;
        }
        if(q > sum)
            sum = q;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    ll N, A, B;
    cin >> N >> A >> B;
    vector<ll> X(N);
    rep(i, N) cin >> X[i];

    ll ans = 0;
    rep(i, N - 1) {
        ll tmp = X[i + 1] - X[i];
        ans += min(tmp * A, B);
    }

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

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

int main(){

  int s;
  cin >> s;
  vector<int> index(1000001, -1);

  int temp = s;
  int cnt = 0;
  while(true){
    cnt++;
    if(index[temp] == -1){
      index[temp] = cnt;
      if(temp % 2 == 0){
	temp /= 2;
      }
      else{
	temp = 3 * temp + 1;
      }
    }
    else{
      cout << cnt << endl;
      break;
    }
  }

  return 0;
}


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

int main(){
    int a,b,c,k;
    cin >> a >> b >> c ;
    cin >> k;

    if(a>b && a>c){
        cout << a*pow(2,k)+b+c;
        return 0;
    }
    if(b>a && b>c){
        cout << b*pow(2,k)+a+c;
        return 0;
    }
    cout << a+b+c*pow(2,k) << endl;

    return 0;
}


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

#define PI 3.141592653589793


int main(){

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false); 

	int n, ac = 0, wa = 0, tle = 0, re = 0;
	cin >> n;
	for (int i = 0; i < n; i++){
		string s;
		cin >> s;
		if (s == "AC"){
			ac++;
		}
		if (s == "TLE"){
			tle++;
		}
		if (s == "WA"){
			wa++;
		}
		if (s == "RE"){
			re++;
		}
	}

	cout << "AC x " << ac << endl;
	cout << "WA x " << wa << endl;
	cout << "TLE x " << tle << endl;
	cout << "RE x " << re << endl;



	


}

Measured memory_bytes: 3660
#include <iostream>
#include <cmath>
#include <string>
#include <numeric>
#include <algorithm>
#include <iomanip>
#include <queue>
using namespace std;
#define INF 1000000007
#define ll long long
#define rep(i, start, end) for(ll i=(ll)start; i<(ll)end; i++)
#define print(a) cout << a << endl;
#define printarray(a, len) rep(ii,0,len) cout << a[ii] << " ";

int main(){
  ll n, k, ans=0;
  cin >> n >> k;
  ll v[51];
  rep(i, 0, n) cin >> v[i];
  
  // 何個取り出すか
  for (ll t = min(k, n); t > 0; t--){
    // そのうち左からいくつ取り出すか
    rep(i, 0, t+1){
      ll result=0;
      priority_queue<ll, vector<ll>, greater<ll>> q;
      // 左から取り出す
      rep(l, 0, i){
        q.push(v[l]);
        result += v[l];
      }
      // 右から取り出す
      rep(r, 0, t-i){
        q.push(v[n-1-r]);
        result += v[n-1-r];
      }
      // 戻す
      rep(b, 0, min(t, k-t)){
        if(q.top() < 0){
          result -= q.top();
          q.pop();
        }
      }
      ans = max(ans, result);
      // cout << t << " " << i << " " << result << endl;
    }
  }
  print(ans);
  
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <time.h>
#pragma warning(disable:4996) 

typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
//const long long MOD = 1000000007;
const long long MOD = 998244353;

using namespace std;


const int max_comb=5000;
vector<ll> fac(max_comb+1); //n! (mod M)
vector<ll> ifac(max_comb+1); //k!^(-1) (mod M)

ll mpow(ll x, ll n){ //x^n(mod M)
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
}

ll minv(ll x){
    return mpow( x, MOD-2 );
}

ll comb(int a, int b){     // C(a,b) = a! * b!^(-1) * (a-b)^(-1)
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % MOD;
    return tmp * fac[a] % MOD;
}

ll perm(int a, int b){     // P(a,b) = a! * (a-b)!^(-1)
    if(b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b] % MOD;
    return tmp * fac[a] % MOD;
}

void pre_comb()
{
    fac[0] = 1;
    ifac[0] = 1;
    for(int i = 0; i<max_comb; i++){
        fac[i+1] = fac[i]*(i+1) % MOD; // n!(mod M)
        ifac[i+1] = ifac[i]*minv(i+1) % MOD; // k!^(-1) (mod M)
    }
    return;
}

void solve()
{
    pre_comb();

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

    int i, j;
    for (i = 2; i <= K * 2; i++) {
        ll ans = 0;
        if (i % 2 == 0) {
            int num = i/2;
            if (K < i / 2) {
                num = 0;
            }
            else if (K < i - 1) {
                num -= (i - 1 - K);
            }

            if (num > 0) {
                for (j = 0; j <= num; j++) {
                    ll ans0 = comb(num-1, j) * comb(n - j * 2 + K - 1, K - 1) % MOD;
                    ll ans1 = (j>0? (comb(num-1, j-1) * comb(n - j* 2+ K - 1, K - 1) % MOD): 0);
                    if (j % 2 == 0) ans = (ans + ans0 + ans1) % MOD;
                    else ans = (ans - ans0 - ans1 + MOD + MOD) % MOD;
                }
            }
        }
        else {
            int num = i/2;
            if (K <= i / 2) {
                num = 0;
            }
            else if (K < i - 1) {
                num -= (i - 1 - K);
            }

            for (j = 0; j <= num; j++) {
                ll ans0 = comb(num, j) * comb(n - j*2 + K - 1, K - 1) % MOD;
                if (j % 2==0) ans = (ans + ans0) % MOD;
                else ans = (ans - ans0 + MOD) % MOD;
            }
        }
        printf("%lld\n", ans);
    }



    return;
}


int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}


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

ll cnt[10][10];

int main(){
	ll n;
	cin>>n;
	for(int i=1;i<=n;i++){
		ll x,y;
		x=i;
		while(x>9)x/=10;
		y=i%10;
		cnt[x][y]++;
	}
	ll ans=0;
	for(int i=1;i<=9;i++)for(int j=1;j<=9;j++)ans+=cnt[i][j]*cnt[j][i];
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep2(i, n, m) for (int i = m; i < (int)(n); i++)
#define rep(i, n) rep2(i, n, 0)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using ll = long long;  //
template <typename T>
T sq(T x) {
  return x * x;
}
signed main() {
  int a, b, c;
  cin >> a;
  cin >> b;
  cin >> c;
  set<int> Set;
  Set.insert(a);
  Set.insert(b);
  Set.insert(c);
  cout << Set.size() << endl;
  return 0;
}



Measured memory_bytes: 256
def isPrime(n):
    if(n == 1):
        return False
    elif(n == 2 or n == 3 or n == 5):
        return True
    flag = 0
    for i in range(2,int(n**0.5)+1):
        if(n%i == 0):
            flag = 1
    if(flag == 0):
        return True
    else:
        return False



N = int(input())
i = 0
temp = 0
List = []
while(i < N):
    judge = temp * 5 + 1
    if(isPrime(judge)):
        List.append(judge)
        i +=1
    temp += 1
print(' '.join(map(str,List)))


Measured memory_bytes: 3064
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int[] sum = new int[10001];
        int number = 1;

        for (int i = 1; i <= 10000; i++) {
            while (!isPrime(++number))
                ;

            sum[i] = number + sum[i - 1];
        }

        String line;
        while (!(line = br.readLine()).equals("0")) {
            System.out.println(sum[Integer.parseInt(line)]);
        }

    }

    static boolean isPrime(int n) {
        for (int i = 2; i <= (int) (Math.sqrt(n)); i++) {
            if (n % i == 0)
                return false;
        }
        return true;
    }
}


Measured memory_bytes: 24888
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>

using lint = long long int;
using Graph = std::vector<std::vector<lint>>;

template<class T>
struct edge
{
	T dist;
	lint to;
	edge(){}
	edge(const T &a_dist,const lint &a_to) : dist(a_dist), to(a_to) {}
	~edge(){}
};

int main(int argc,char *argv[])
{
	int n;
	std::cin >> n;
	
	std::vector<lint> b(n);
	for(int i = 1;i < n;i++) std::cin >> b[i];
	b[0] = b[1];

	lint ans = b[n-1];
	for(int i = 0;i < n-1;i++) ans += ((b[i] < b[i+1]) ? b[i] : b[i+1]);

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 256
//============================================================================
// Name        : test.cpp
// Author      : Qihan
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <bits/stdc++.h>
using namespace std;
typedef long long int LLI;
typedef pair<int,int> PII;
const int maxn = (100000 + 10);

int vis[maxn];
int a[maxn],p = 0;

int main(){
//	freopen("/home/qihan/Documents/in","r",stdin);
	int n;
	scanf("%d",&n);
	for(int i = 1;i <= n;i ++){
		int temp;
		scanf("%d",&temp);
		vis[temp] ++;
	}
	for(int i = 1;i <= 100000;i ++){
		if(vis[i] != 0)	a[p ++] = vis[i];
	}
	int l = 0,r = p - 1;
////	printf("%d\n",p);
//    for(int i = 0;i < p;i ++){
//        printf("%d ",a[i]);
//    }
//    printf("\n");
	while(l < r){
		if(a[l] <= 1)	l ++;
		if(a[r] <= 1)	r --;
		if(a[l] > 1 && a[r] > 1 && l < r){
			int x = min(a[l],a[r]);
			a[l] = a[l] - x + 1;
			a[r] = a[r] - x + 1;
		}
	}
	int ans = p;
//	printf("%d %d %d\n",l,r,a[l]);
	if(a[l] > 1 || a[r] > 1){
		if(a[l] > 1)		ans = ans - (a[l] % 2 == 0 ? 1 : 0);
		else if(a[r] > 1)	ans = ans - (a[r] % 2 == 0 ? 1 : 0);
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1024
n,k = map(int,input().split())
a = [int(i) for i in input().split()]

def gcd(x,y):
    if y == 0: return x
    else: return gcd(y,x%y)

g = a[0]
for i in range(n):
    g = gcd(g,a[i])

if k <= max(a) and k%g == 0:
    ans = "POSSIBLE"
else:
    ans = "IMPOSSIBLE"

print(ans)

Measured memory_bytes: 14224
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  if(N%2==0) cout << N << endl;
  else cout << N*2 << endl;

}


Measured memory_bytes: 256
#include <stdio.h>
void swap(int *a,int *b);
int main(void) {
	int n,i,j,hanten=0;
	scanf("%d",&n);
	int a[n];
	for(i=0;i<n;i++)scanf("%d",&a[i]);
	for(i=0;i<n;i++){
		for(j=0;j<n-i-1;j++){
			if(a[j]>a[j+1]){
				swap(&a[j],&a[j+1]);
				hanten++;
			}
		}
	}
	for(i=0;i<n;i++){
		printf("%d",a[i]);
		if(i!=n-1)printf(" ");
	}
	puts("");
	printf("%d\n",hanten);
	return 0;
}
void swap(int *a,int *b){
	int tmp;
	tmp=*a;
	*a=*b;
	*b=tmp;
}


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

using namespace std;

int main(){
	int n;
	while(cin >> n && n!=0){
		vector<int> v(n);
		for(int i=0;i<n;i++){
			cin >> v[i];
		}
		string s;
		cin >> s;
		int x;
		for(int i=0;i<s.size();i++){
			x = v[i%n];
			while(1){
				if(x==0)break;
				if(s[i]<='z'&&s[i]>='a'){
					if(s[i]-x<'a'){
						x-= (s[i]-'a')+1;
						s[i]='Z';
					}else{
						s[i] = s[i]-x;
						break;
					}
				}else{
					if(s[i]-x<'A'){
						x-= (s[i]-'A')+1;
						s[i]='z';
					}else{
						s[i] = s[i]-x;
						break;
					}
				}
			}
			cout << s[i];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3124
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
	int H,A; cin >> H >> A;
	cout << (H+A-1)/A << endl;
}

Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(_,v.size())cout<<" "<<v[_];cout<<endl;
#define show2d(v) rep(_,v.size()){rep(__,v[_].size())cout<<" "<<v[_][__];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 1e18+10 : 1e9+10;
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,1,-1,1,-1};//RDLU
typedef ll Def;
vi ga;
class DIJ{
	public:
	struct edge{
		Def to,cost;
	};
	vector<vector<edge> >G;
	Def n,L;
	vector<vector<Def> >d;//distance
//	Def d[510][50][2];
	DIJ(Def size,Def l){
		n=size;
		L=l;//??????
		G=vector<vector<edge> >(n);
	}
	void add_edge(Def a,Def b,Def c){
		edge e={b,c},ee={a,c};
		G[a].pb(e);
		G[b].pb(ee);
	}
	void dij(Def s,Def g){
		d=vector<vector<Def> >(n,vector<Def>(L+1,inf));
		d[s][L]=0;
		priority_queue<tp>q;
		q.push(tp(0,s,L));
		while(!q.empty()){
			Def cost,pos,t;
			tie(cost,pos,t)=q.top();
			cost*=-1;
			q.pop();
			if(cost>d[pos][t])continue;
			rep(i,G[pos].size()){
				edge e=G[pos][i];
				Def to=e.to;
				Def ncost=cost+e.cost;//??????
				Def nt=t-e.cost;//??????
				if(nt<0)continue;
				if(ga[to])nt=L;
				if(ncost<d[to][nt]){
					d[to][nt]=ncost;
					q.push(tp(-ncost,to,nt));
				}
			}
		}
		int out=inf;
		rep(i,L+1)out=min(out,d[g][i]);
		if(out==inf)out=-1;
		cout<<out<<endl;
	}
};
signed main(){
	int m,w,cap;
	string st,go;
	while(cin>>m>>w>>cap,m){
		int n=0;
		cin>>st>>go;
		map<string,int>ma;
		vvi in(m);
		rep(i,m){
			string s,t;
			cin>>s>>t;
			int d;
			cin>>d;
			if(ma[s]==0)ma[s]=++n;
			if(ma[t]==0)ma[t]=++n;
			in[i]={ma[s]-1,ma[t]-1,d};
		}
		
		DIJ dij(n,cap*10);
		rep(i,m)dij.add_edge(in[i][0],in[i][1],in[i][2]);
		ga=vi(n);
		rep(i,w){
			string s;
			cin>>s;
			ga[ma[s]-1]=1;
		}
		dij.dij(ma[st]-1,ma[go]-1);
	}
}


Measured memory_bytes: 99868
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

vector<Int> h;
Int N, A, B;

bool isOK(Int x) {//x回の攻撃で全滅するかどうか
	
	Int cnt=0;//(A-B)ダメージの回数
	Int temp;
	for (Int i = 0; i < N; i++) {
		temp = h[i] - x * B;
		if (temp<=0) {
			continue;
		}
		else {
			temp = (temp + (A - B - 1)) / (A - B);
		}
		cnt += temp;
	}

	return x >= cnt;
}

// 汎用的な二分探索のテンプレ
Int binary_search() {
	Int ng = -1; // 0が条件を満たすこともあるので、初期値は -1
	Int ok = 1e9; // 考えられる答えの上限

	/* ok と ng のどちらが大きいかわからないことを考慮 */
	while (abs(ok - ng) > 1) {
		Int mid = (ok + ng) / 2;

		if (isOK(mid)) ok = mid;
		else ng = mid;
	}
	return ok;
}

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	cin >> N >> A >> B;

	h.resize(N);
	for (Int i = 0; i < N; i++) {
		cin >> h[i];
	}

	Int ans = binary_search();

	cout << ans << "\n";

}


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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

//#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>

#define XX              first
#define YY              second
#define PB              push_back
#define MP              make_pair

#define NEWLINE         cerr << "\n";
#define HOISE           cerr << "hoise " << __LINE__ << "\n"
#define PAUSE           system("pause")
#define DEBUG(x)        cerr << #x << " = " << x << "\n"
#define FASTIO          ios_base::sync_with_stdio(false);cin.tie(NULL)

typedef long long ll;
typedef pair<int, int > pii;
typedef pair<ll, ll> pll;

const int INF = 1e9 + 23;
const ll INFL = 2e18 + 23;

int32_t main()
{
    FASTIO;

    char ch;
    cin >> ch;
    if('A'<=ch and ch<='Z') cout << "A";
    else cout << "a";

    return 0;
}

Measured memory_bytes: 3644