akhauriyash/Code-Regression huggingface dataset:
//Never stop chasing!-MdSourav.
#include <bits/stdc++.h>

#define yes            cout<<"YES"<<endl
#define no             cout<<"NO"<<endl
#define sz(x)          x.size()
#define ll                    long long int
#define ls             long int
#define start          ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test           int t;cin>>t;while(t--)
#define f(i, a, n)     for(int i=a; i<n;i++)
#define gcd(a,b)7           __gcd(a,b)
#define lcd(a,b)       (a*b)/gcd(a,b)
#define pb             push_back
#define mp(x,y)        make_pair(x,y)
#define rsrt(v)        sort(v.begin(),v.end(),greater<int>())
#define srt(v)         sort(v.begin(),v.end())
#define basrt(a,n)     sort(a,a+n,greater<int>())
#define asrt(a,n)      sort(a,a+n)
#define fact(n)        ll x=1;for(ll i=1;i<=n;i++){x=(x*i);}
#define F              first
#define S              second
#define deb(x)         cout << #x << ": " << x << endl;
#define enter(v,n)     for(ll i=0;i<n;i++){ll x;cin>>x;v.pb(x);}
#define INF 	       1000000007
#define unique(v)      v.erase(unique(v.begin(),v.end()),v.end())
using namespace std;

double pi=3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664 ;
typedef vector<ll> vll ;
typedef vector<int> vii ;

template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v)
{
    os << '{';
    for (const auto &x : v) os << " " << x;
        return os << '}';
}

void solve()
{

    int n;
    cin>>n;
    vector<ll>v;
    enter(v,n);
    rsrt(v);
    ll ans=0;
    ans=ans+v[0];
    int i=1;
    n=n-2;
    while(n>0)
	{
		if(n>=2)
		{
			ans=ans+(v[i]*2);
			n=n-2;
		}
		else
		{
			ans=ans+(v[i]);
			n--;
		}
		i++;

	}
	cout << ans << endl;



}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
    ll test_case=1;
    //cin>>test_case ;
    while(test_case--)
	{
		 solve();
	}

	return 0;
}

Measured memory_bytes: 5284
#pragma GCC optimize ("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> P; typedef pair<Int,Int> Pl;
const int mod = 1e9+7;
const Int Inf = 1e17;
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define mp make_pair
#define Pr(t) priority_queue<t>
#define gPr(t) priority_queue<t,vector<t>,greater<t>>
#define V(t) vector<t>
#define rep(i,n) for(int(i)=0; i<n; i++)
#define rer(i,l,r) for(int i=l; i<=r; i++)
#define gnr(i,l,r) for(int i=r; i>=l; i--)
#define eb emplace_back
#define pri1(a) cout<<(a)<<'\n'
#define pri2(a,n) {rep(pri2i,n-1)cout<<a[pri2i]<<' '; cout<<a[n-1]<<'\n';}
#define prip(p) cout<<p.fi<<' '<<p.se<<'\n'
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }


int n,m,_,x,y,q;
string s,sb;
bool ok;
char cf,cb;

double dp[3001];

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

  int ma=0; double e; cin>>n>>m>>x>>y>>e>>ma; e=e/(100.0+e); n*=100,m*=100;
  V(int)wa,sa;
  rep(i,30)rep(j,30)if(i*n+j*m<=ma)wa.eb(i*n+j*m);
  rep(i,3000)rep(j,3000)if(i*x+j*y<=ma)sa.eb(i*x+j*y);
  double rat=0; P ans=P(min(n,m)<=ma?min(n,m):0,0);
  for(int w:wa)for(int su:sa){
    if(w+su>ma)continue;
    if(!(w+su))continue;
    if(double(su)/(w+su)>e)continue;
    if(double(su)/(w+su)>rat){
      rat=double(su)/(w+su);
      ans=P(w+su,su);
    }
  }
  prip(ans);
}

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

#ifdef __WIN32
#define LLFORMAT "I64"
#else
#define LLFORMAT "ll"
#endif

using namespace std;

struct segment_tree {
	segment_tree() {}
	segment_tree(int _n) {
		n = _n;
		N = 1; while(N - 1 <= n) N <<= 1;
		a = vector<int>(N << 1, 0);
	}

	void M(int i, int x) {
		a[i |= N] = x;
		for (i >>= 1; i; i >>= 1) a[i] = max(a[i << 1], a[(i << 1) | 1]);
		return;
	}

	int Q(int i) {
		int x = 0;
		for (int s = (i | N) - 1, t = (n | N) + 1; s ^ t ^ 1; s >>= 1, t >>= 1) {
			if(~s & 1) x = max(x, a[s ^ 1]);
			if(t & 1) x = max(x, a[t ^ 1]);
		}
		return x;
	}
	private :
	vector<int> a;
	int n, N;
};

int main() {
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<int> a(n), s(n, 0);
	vector<bool> h(n);
	for (int mx = 0, i = 0; i < n; ++i) cin >> a[i], h[i] = (a[i] > mx), mx = max(mx, a[i]);
	for (int i = n - 1; i; --i) s[i - 1] = s[i] + h[i];

	array<segment_tree, 2> seg = {segment_tree(n), segment_tree(n)};
	for (int i = n - 1; ~i; --i) {
		array<int, 2> g = {seg[0].Q(a[i]), seg[1].Q(a[i])};
		if(h[i]) {
			seg[0].M(a[i], g[0] + 2);
			if(g[1] & 1) seg[1].M(a[i], g[1] + 2);
		}
		else {
			seg[1].M(a[i], g[0] + 1);
			if(g[1] & 1) seg[0].M(a[i], g[1] + 1);
		}
	}

	int max0(0), max1(0), cnt0(0), cnt1(0);
	string ans("");
	for (int x, i = 0; i < n; ++i) {
		x = a[i];
		seg[0].M(x, 0); seg[1].M(x, 0);

		auto check = [&](int max0, int cnt0, int max1, int cnt1) {
			static array<int, 2> g;
			g = {seg[0].Q(max0), seg[1].Q(max0)};
			if(cnt0 + cnt1 + s[i] & 1) {
				if(g[1] & 1) {
					if(cnt0 + 1 <= cnt1 + s[i] && cnt0 + g[1] >= cnt1 + s[i]) return true;
				}
			}
			else {
				if(cnt0 <= cnt1 + s[i] && cnt0 + g[0] >= cnt1 + s[i]) return true;
			}
			g = {seg[0].Q(max1), seg[1].Q(max1)};
			if(cnt0 + cnt1 + s[i] & 1) {
				if(g[1] & 1) {
					if(cnt1 + 1 <= cnt0 + s[i] && cnt1 + g[1] >= cnt0 + s[i]) return true;
				}
			}
			else {
				if(cnt1 <= cnt0 + s[i] && cnt1 + g[0] >= cnt0 + s[i]) return true;
			}
			return false;
		};

		if(check(max(max0, x), cnt0 + (x > max0), max1, cnt1)) { ans += "0"; max0 = max(max0, x); cnt0 += (x == max0); }
		else { ans += "1"; max1 = max(max1, x); cnt1 += (x == max1); }
	}
	if(cnt0 == cnt1) cout << ans << endl;
	else cout << "-1\n";
	return 0;
}


Measured memory_bytes: 6532
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    string s;cin>>s;
    char ans = 'a';
    for(;;){
        if(s.find(ans)==s.npos){
            cout<<ans<<endl;
            return 0;
        } else if(ans=='z'){
            cout<<"None"<<endl;
            return 0;
        }
        ans++;
    }
}

Measured memory_bytes: 512
#include <cstdio>
#include <algorithm>
#include <queue>
#include <climits>
#include <vector>
#include <cstring>

using namespace std;

vector<int> G[5000];
priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > pq;

int N;
int cost[5000], rep[5000], tot[5000], vis[5000];
bool done[5000], looked[5000];

void visit(int v, int left, int needed)
{
	tot[v] = min(tot[v], needed);
	if (!done[v]) pq.push(make_pair(tot[v], -v));
	
	if (!left) return;
	for (int i = 0; i < G[v].size(); i++)
		vis[G[v][i]] = max(vis[G[v][i]], left - 1);
	
	for (int i = 0; i < G[v].size(); i++)
		if (vis[G[v][i]] == left - 1)
			visit(G[v][i], left - 1, needed);
}

int main()
{
	int M;
	
	scanf("%d %d", &N, &M);
	
	for (int i = 0; i < N; i++){
		scanf("%d %d", cost + i, rep + i);
	}
	
	for (int i = 0; i < M; i++){
		int x, y;
		scanf("%d %d", &x, &y);
		G[--x].push_back(--y);
		G[y].push_back(x);
	}
	
	for (int i = 0; i < N; i++) tot[i] = INT_MAX;
	
	tot[0] = 0;
	pq.push(make_pair(0, 0));
	while (pq.size()){
		pair<int, int> x = pq.top(); pq.pop();
		if (done[-x.second]) continue;
		done[-x.second] = true;
		memset(vis, -1, sizeof(vis));
		memset(looked, 0, sizeof(looked));
		if (-x.second == N - 1) return (!printf("%d\n", x.first));
		vis[-x.second] = rep[-x.second];
		visit(-x.second, rep[-x.second], x.first + cost[-x.second]);
	}
	return (0);
}

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

int N;
int X[110];
int Y[110];
int H[110];

int main(){
  cin >> N;
  rep(i, N) cin >> X[i] >> Y[i] >> H[i];

  int init;
  rep(i, N){
    if (H[i] > 0){
      init = i;
      break;
    }
  }

  int h;
  int ans_x, ans_y, ans_h;
  rep(x, 101){
    rep(y, 101){
      // initは高度が0より大きい地点を表す
      h = H[init] + abs(X[init] - x) + abs(Y[init] - y);

      // 条件式を満たしているかどうかのチェック
      bool check = true;
      rep(i, N){
        // maxを消去する
        if (H[i] > 0){
          if (h - abs(X[i] - x) - abs(Y[i] - y) != H[i]) check = false;
        }
        else {
          if (h - abs(X[i] - x) - abs(Y[i] - y) > 0) check = false;
        }
      }

      // 答えは一意に定まる
      if (check){
        ans_x = x;
        ans_y = y;
        ans_h = h;
      }
    }
  }

  cout << ans_x << " " << ans_y << " " << ans_h << endl;
}


Measured memory_bytes: 3644
#include <stdio.h> 

int main() {
  int a, i, min = 2000, max = 0, c, t;
    
    scanf("%d", &a);
    
    for(i = 0; i < a; i++) {
      scanf("%d", &c);
        
        if (min > c) {
            min = c;
        }
        if (max < c) {
            max =c;
        }
    }
    
    t = max - min;
    if (t % 2 == 1) t = t + 1;
    t = t / 2;

    printf("%d\n", t);

}



Measured memory_bytes: 2092
def main():
    a=input()
    b=set(a)
    if(len(b)<=2):
        if(a.count(a[1],0,3)!=3 and a.count(a[2],1,4)!=3):
            print('No')
        else:
            print('Yes')
    else:
        print('No')

main()


Measured memory_bytes: 9076
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[] for _ in range(num)]
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

S = str(input())

print('x'*len(S))

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

int main() {
    ll n,a,b,c,d,e;
    cin>>n>>a>>b>>c>>d>>e;
    cout<<max({(n-1)/a,(n-1)/b,(n-1)/c,(n-1)/d,(n-1)/e})+5<<endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define PI 3.141592653589L

int main(){
  int A,B,H,M;
  cin >> A >> B >> H >> M;
  long double w1 = (PI/30)*((long double)H*60+(long double)M);
  long double w2 = (PI/360)*((long double)H*60+(long double)M);
  long double x;
  x = (long double)A*(long double)A + (long double)B*(long double)B -2*A*B*cos(w1-w2);
  long double y = sqrt(x);
 printf("%20.20Lf",y);
  return 0;
}




Measured memory_bytes: 4160
n, m = map(int, input().split())
s = input()
dp = [-1 for _i in range(n+1)]
dp[0] = 0
f = 0
from collections import deque
q = deque([0])
c = 0
for i in range(1, n+1):
    if s[i]=="0":
        c = 0
        while i-f > m:
            f = q.popleft()
        dp[i] = f
        q.append(i)
    elif c < m-1:
        c += 1
    else:
        break

if dp[n] >= 0:
    r = []
    p = n
    while p > 0:
        nex = dp[p]
        r.append(p-nex)
        p = nex
    print(*r[::-1])
else:
    print(-1)

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

#define IOS cin.tie(0);ios_base::sync_with_stdio(false)

#define ll      long long
#define Fi      first
#define Se      second
#define Pb      push_back
#define vi      vector<int>
#define vp      vector<pair<int,int>>
#define vvi     vector<vector<int>>
#define vvp     vector<vector<pair<int,int>>>
using Graph  =  vector<vector<int>>;

#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define output_s(s) printf("%s\n",(s).c_str())
#define END cout<<"\n"

#define rep(i,n)        for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m)      for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m)     for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m)    for(int i=(int)(n);i>=(int)(m);i--)
#define SRepS(i,n,m)    for(int i=(int)(n);i*i<=(int)(m);i++)
#define RepA(x)         for(auto &item:(x))

void CINT(){} //@shibh308's template
template<class Head,class... Tail> void CINT(Head&& head,Tail&&... tail){cin>>head; CINT(move(tail)...);}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
#define VCIN(x) for(auto &item:x) cin>>item

void OUT(){}
template<class Head,class...Tail> void OUT(Head&& head,Tail&&...tail){cout<<head<<(sizeof...(tail)?" ":"\n"); OUT(move(tail)...);}
#define COUT(...) OUT(__VA_ARGS__)

template<typename TypeInt>TypeInt GCD(TypeInt a,TypeInt b){return a%b==0?b:GCD(b,a%b);} //最大公約数
template<typename TypeInt>TypeInt LCM(TypeInt a,TypeInt b){return a*b/GCD(a,b);} //最小公倍数
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
template<class T>bool comp(T a,T b){return abs(a)<abs(b);} //比較関数

void YES(bool f){printf(f?"YES\n":"NO\n");}
void Yes(bool f){printf(f?"Yes\n":"No\n");}
void Possible(bool f){printf(f?"Possible\n":"Impossible\n");}
void POSSIBLE(bool f){printf(f?"POSSIBLE\n":"IMPOSSIBLE\n");}

//----------------------library------------------------//

//const int dx[4]={1,0,-1,0};
//const int dy[4]={0,1,0,-1};
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int NMAX = 200;
const int INF = 1e9;
const int MOD = 1e9+7;
bool flag;

//----------------------Global-------------------------//

ll f(ll x){
    if(x==1)return 1;
    else return 2*f(x/2)+1;
}

signed main(){
    IOS;
    LCIN(H);
    COUT(f(H));

    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
from collections import Counter
S = input()
if len(S) == 1:
    print("YES")
    exit()
cv = []
for alp in ["a", "b", "c"]:
    cv.append(S.count(alp))
cv.sort()
l = []
for i in range(2):
    for j in range(i+1, 3):
        l.append(abs(cv[i] - cv[j]))
for i in range(len(l)):
    if l[i] > 1:
        print("NO")
        exit()
print("YES")

Measured memory_bytes: 3444
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<map>
#include<random>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include <queue>
#include<boost/multiprecision/cpp_int.hpp>


using namespace std;
using namespace boost::multiprecision;

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldb = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney, tree, chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun

#define REP(i,a,b) for(ll i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIF(v, n) printf("%."#n"f\n", v)
#define PRIY PRI("Yes")
#define PRIN PRI("No")
template<typename A, typename B>
void mins(A & a, const B & b) { a = min(a, (A)b); };
template<typename A, typename B>
void maxs(A & a, const B & b) { a = max(a, (A)b); };

ll N, K;
vector<ll> P, C;

void f(int ind, unordered_set<int>& buf, vector<ll>& pass, vector<ll>& sum) {
	if (pass.empty()) sum.push_back(0);
	else sum.push_back(sum.back() + C[pass.back()]);
	pass.push_back(ind);
	if (buf.count(ind) == 0) {
		buf.insert(ind);
		f(P[ind], buf, pass, sum);
	}
}

ll query(int ind) {
	unordered_set<int> buf;
	vector<ll> pass, sum;
	f(ind, buf, pass, sum);
	int loopstart;
	REP(i, 0, pass.size() - 1) {
		if (pass[i] == pass.back()) {
			loopstart = i;
			break;
		}
	}
	ll noloop_mx = -1e18;
	for (int i = 1; i <= K && i < sum.size(); ++i)maxs(noloop_mx, sum[i]);
	if (K <= sum.size() - 1) return noloop_mx;

	ll loop_score = sum.back() - sum[loopstart];
	if (loop_score <= 0) return noloop_mx;
	ll loop_length = sum.size() - loopstart-1;
	ll loop_n = (K - loopstart) / loop_length;
	ll amari = (K - loopstart) % loop_length;
	ll i0 = sum.size() + amari - loop_length;
	ll tmp = sum[loopstart] + loop_n * loop_score - (sum.back() - sum[i0]);
	ll ans = tmp;
	for (int i = 1; i < loop_length; ++i) {
		int ind = i0 + i;
		if (ind >= sum.size()) ind -= loop_length;
		tmp += sum[ind] - sum[ind - 1];
		maxs(ans, tmp);
	}
	return max(ans, noloop_mx);
}

int main() {
	cin >> N >> K;
	P.resize(N);
	C.resize(N);
	REP(i, 0, N) {
		cin >> P[i];
		--P[i];
	}
	REP(i, 0, N) cin >> C[i];
	ll ans = -1e18;
	REP(i, 0, N) maxs(ans, query(i));
	PRI(ans);
	return 0;
}

Measured memory_bytes: 4464
#include <iostream>
#include <stdexcept>
#include <cassert>
#include <vector>
using namespace std;


const int N = 26;


int decide(int d, int D, vector<vector<int>>& s, vector<int>& c, vector<int>& last) {
  int ans = 0;
  int tmpV, maxV = -10000000;
  int E = min(D-d, N);
  for (int t = 0; t < N; t++) {
    tmpV = s[d][t];
    for (int i = 0; i < N; i++) {
      if (i == t) {
        tmpV -= c[i] * E * (E-1) / 2;
      } else {
        tmpV -= c[i] * E * (d + E/2 - last[i]);
      }
    }
    if (tmpV > maxV) {
      maxV = tmpV;
      ans = t;
    }
  }
  return ans;
}


int main() {
  int D;
  cin >> D;

  vector<int> c(N, 0);
  for (int i = 0; i < N; i++) cin >> c[i];

  vector<vector<int>> s(D, vector<int> (N, 0));
  for (int d = 0; d < D; d++) {
    for (int i = 0; i < N; i++) {
      cin >> s[d][i];
    }
  }

  vector<int> t(D, 0);
  // Choose t[] greedily ans calc score
  vector<int> last(N, -1);
  vector<int> v(D, 0);
  for (int d = 0; d < D; d++) {
    t[d] = decide(d, D, s, c, last);
    last[t[d]] = d;
  }

  for (int x : t) cout << x + 1 << endl;

  return 0;
}


Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
 
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int a, b, c, d;
cin >> a >> b >> c >> d;
(a * b >= c*d) ? cout << a*b << "\n" : cout << c*d << "\n";
return 0;
}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

char f[101][101];
Int d[101][101];

int main() {
    Int h, w;
    cin >> h >> w;
    for (Int i = 0; i < h; i++) {
        for (Int j = 0; j < w; j++) {
            cin >> f[i][j];
            d[i][j] = INF;
        }
    } 
    d[0][0] = (f[0][0] == '#');
    deque<pair<Int, Int>> q;
    q.push_front({0, 0});
    while (not q.empty()) {
        pair<Int, Int> p = q.front();
        q.pop_front();
        Int dy[] = {0, 1};
        Int dx[] = {1, 0};
        for (Int i = 0; i < 2; i++) {
            Int ny = dy[i] + p.fi;
            Int nx = dx[i] + p.se;
            if (ny == h or nx == w) continue;
            if (f[p.fi][p.se] == '.' and f[ny][nx] == '#') {
                if (d[ny][nx] > d[p.fi][p.se] + 1) {
                    d[ny][nx] = d[p.fi][p.se] + 1;
                    q.push_back({ny, nx});
                }
            } else {
                if (d[ny][nx] > d[p.fi][p.se]) {
                    d[ny][nx] = d[p.fi][p.se];
                    q.push_front({ny, nx});
                }
            }
        }
    }
    dump(d[h - 1][w - 1]);
    return 0;
}


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

int main(void) {
    char c;
    map<char, char> m;
    m['A'] = 'T';
    m['T'] = 'A';
    m['G'] = 'C';
    m['C'] = 'G';

    cin >> c;
    cout << m[c] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
template <class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
int main() {
    int N; cin >> N;
    vector<vector<int>> a(N, vector<int>(3, 0));
    for (int i = 0; i < N; i++) for (int j = 0; j < 3; j++) cin >> a[i][j];
    vector<vector<long long int>> dp(N + 1, vector<long long int>(3, 0));

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (j == k) continue;
                chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
            }
        }
    }

    long long int ans = 0;
    for (int i = 0; i < 3; i++) chmax(ans, dp[N][i]);
    cout << ans << endl;
}


Measured memory_bytes: 14004
from collections import*
h,w=map(int,input().split())
c=eval('list(input()),'*h)
q=deque()
e=q.append
for i in range(h):
 for j in range(w):
  if'.'>c[i][j]:e((i,j,0))
a=0
while q:
 y,x,v=q.popleft();a=max(a,v)
 for i,j in((y,x-1),(y,x+1),(y-1,x),(y+1,x)):
  if h>i>=0and w>j>=0and'#'<c[i][j]:c[i][j]='#';e((i,j,v+1))
print(a)

Measured memory_bytes: 161884
fn main() {
    let mut buf = String::new();
    let handle = std::io::stdin();

    let n: isize = {
        handle.read_line(&mut buf).unwrap();
        let tmp = buf.trim().parse().unwrap();
        buf.clear();
        tmp
    };
    let h: isize = {
        handle.read_line(&mut buf).unwrap();
        let tmp = buf.trim().parse().unwrap();
        buf.clear();
        tmp
    };
    let w: isize = {
        handle.read_line(&mut buf).unwrap();
        let tmp = buf.trim().parse().unwrap();
        buf.clear();
        tmp
    };
    println!("{}", (n - h + 1) * (n - w + 1));
}


Measured memory_bytes: 4352
N, K = map(int, input().split())
A = list(map(int, input().split()))
# dp[i] := when i stones are remaining can the player win?
dp = [False] * (K+1)
for i in range(1, K+1):
    for j in range(N):
        if i - A[j] >= 0 and not dp[i - A[j]]:
            dp[i] = True
            break
if dp[K]:
    print('First')
else:
    print('Second')


Measured memory_bytes: 42220
#include<stdio.h>
#define MAX 10000
#define NIL -1
 
void setDepth(int,int);
int setHeight(int);
int getSibling(int u);
void print(int u);

typedef struct{
  int parent;
  int left;
  int right;
} Node;
 
Node T[MAX];
int n, D[MAX], A[MAX];
 
int main(){
   
  int i, v, l, r, root=0;
  scanf("%d",&n);
 
  for(i=0;i<n;i++) T[i].parent=NIL;
 
  for(i=0;i<n;i++){
    scanf("%d%d%d",&v,&l,&r);
    T[v].left = l;
    T[v].right = r;
    if(l != NIL) T[l].parent=v;
    if(r != NIL) T[r].parent=v;
     
  }
 
  for(i=0;i<n;i++){
    if(T[i].parent==NIL) root=i;
  }
   
    setDepth(root,0);
    setHeight(root);
 
    for(i=0;i<n;i++) print(i);
 
    return 0;
     
  }
 
 
void setDepth(int u, int d){
   
  if(u==NIL) return;
  D[u] = d;
  setDepth(T[u].left,d+1);
  setDepth(T[u].right,d+1);
   
}
 
 
int setHeight(int u){
 
  int h1=0, h2=0;
  if(T[u].left != NIL){
    h1 = setHeight(T[u].left)+1;
  }
  if(T[u].right != NIL){
    h2 = setHeight(T[u].right)+1;
  }
    return A[u] = (h1>h2 ? h1:h2);
 
}
 
 
int getSibling(int u){
   
  if(T[u].parent==NIL) return NIL;
  if(T[T[u].parent].left!=u && T[T[u].parent].left!=NIL) return T[T[u].parent].left;
  if(T[T[u].parent].right!=u && T[T[u].parent].right!=NIL) return T[T[u].parent].right;
  return NIL;
 
}
 
 
void print(int u){
   
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("sibling = %d, ",getSibling(u));
 
  int deg=0;
 
  if(T[u].left != NIL) deg++;
  if(T[u].right != NIL) deg++;
   
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",A[u]);
 
  if(T[u].parent == NIL){
    printf("root\n");
  }else if(T[u].left == NIL && T[u].right == NIL){
    printf("leaf\n");
  }else{
    printf("internal node\n");
  }
 
}

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

int main()
{
   long long int n;
   cin>>n;

   vector<long long int>v(200002,0);
   long long int a[n],maxi=LONG_MIN,sum=0;
   long long b[200002]={0};

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

   for(int i=1;i<=maxi;i++)
   {
       b[i]=(v[i]*(v[i]-1))/2;
       sum+=b[i];
   }
   long long int d;
   for(int i=0;i<n;i++)
    {
        d=v[a[i]]-1;
        cout<<sum-b[a[i]]+(d*(d-1))/2<<"\n";
    }
   return 0;
}


Measured memory_bytes: 7296
#include <cstdio>

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

    int ans = 0;
    int chain = 0;
    for (int i = 0; i < n; i++) {
        int p;
        scanf("%d", &p);
        if (p == i + 1) {
            chain++;
        } else {
            ans += (chain + 1) / 2;
            chain = 0;
        }
    }
    ans += (chain + 1) / 2;
    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 128
#! /usr/bin/env python
# -*- coding: utf-8 -*-

(N, Q) = map(int, raw_input().split())
while N!=0 and Q!=0:
    H=[0]*101
    for i in range(N):
        q = map(int, raw_input().split())
        for j in range(1, len(q)):
            H[q[j]] += 1
    if Q <= max(H):
        print H.index(max(H))
    else:
        print 0

    (N, Q) = map(int, raw_input().split())

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

int H,W;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};
char t[500][500];
ll A[500][500],B[500][500];
ll INF=(1LL<<50);

void bfs(char ch,ll d[500][500]){
  fill(d[0],d[500], INF );
  queue<int> qy,qx;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(ch==t[i][j]){
        d[i][j]=0;
        qy.push(i);
        qx.push(j);
      }
    }
  }
  while(!qy.empty()){
    int y=qy.front();qy.pop();
    int x=qx.front();qx.pop();
    for(int dir=0;dir<4;dir++){
      int ny=y+dy[dir];
      int nx=x+dx[dir];
      if(t[ny][nx]=='#')continue;
      if(t[ny][nx]=='*')continue;
      if(d[ny][nx]>d[y][x]+1){
        d[ny][nx]=d[y][x]+1;
        qy.push(ny);
        qx.push(nx);
      }
    }
  }
}

int main(){
  cin>>W>>H;
  for(int i=0;i<H;i++)
    for(int j=0;j<W;j++)
      cin>>t[i][j];
  
  bfs('*',A);
  bfs('g',B);

  vector<ll> v;
  ll sum=0,cnt=0,K=0;
  double base=1e100;
  double ans=1e100;

  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(t[i][j]=='#')continue;
      if(t[i][j]=='*')continue;
      if(t[i][j]=='g')continue;
      
      cnt++;
      if(t[i][j]=='s'){
        if(A[i][j]==INF)base=1e100;
        else base=A[i][j];
        if(B[i][j]!=INF)ans=B[i][j];
      }
      if(A[i][j]==INF){
        sum+=B[i][j];
      }else if(B[i][j]==INF){
        sum+=A[i][j];
        K++;
      }else{
        sum+=B[i][j];
        v.push_back(A[i][j]-B[i][j]);
      }

    }
  }
  sort(v.begin(),v.end());
  for(int i=0;i<=(int)v.size();i++){
    double rate=(double)K/(double)cnt;
    double X=(double)sum/(double)cnt;
    X/=(1.0-rate);
    ans=min(ans,(double)base+X);
    K++;
    
    if(i==(int)v.size())break;
    sum+=v[i];
  }
  printf("%.12f\n",ans);
  return 0;
}

Measured memory_bytes: 9244
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	N := getInt()
	L := getInts(N)
	// sort.Ints(L)
	cnt := 0
	for i := 0; i < N; i++ {
		for j := i + 1; j < N; j++ {
			for k := j + 1; k < N; k++ {
				a := L[i]
				b := L[j]
				c := L[k]
				if a == b || a == c || b == c {
					continue
				}
				if a+b > c && b+c > a && c+a > b {
					// out(i+1, j+1, k+1, a, b, c)
					cnt++
				}
			}
		}
	}
	out(cnt)
}


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

int main(){
	int n,q,s[10000],t[500];
	scanf("%d",&n);
	for (int i=0;i<n;i++)
		scanf("%d",s+i);
	scanf("%d",&q);
	for (int i=0;i<q;i++)
		scanf("%d",t+i);
	int count=0;
	for (int i=0;i<q;i++){
		for (int j=0;j<n;j++){
			if (s[j]==t[i]){
				count++;
				break;
			}
		}
	}
	printf("%d\n",count);
}	


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n)  for (int i = 0; i < (int) (n); i++)
#define REP1(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
using ll = long long;
const ll mod  = 1e9 + 7;
const int INF = 2e9;
using pint = pair <int, int>;

int main() {
  string s;
  cin >> s;
  if (s == "AAA" || s == "BBB") {
	  cout << "No" << endl;
	} else {
	  cout << "Yes" << endl;
	}
  return 0;
}


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

#define MAX_NUM (1000000000 + 7)

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

bool Sec_compare(pair<uint64_t, uint64_t> a, pair<uint64_t, uint64_t> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

u64 dec_dig(u64 num) {
  u64 res = 0;
  while (num > 0) {
    num /= 10;
    ++res;
  }
  return res;
}

u64 gcd(u64 a, u64 b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }

  return b ? gcd(b, a % b) : a;
}

int main() {
  cout << setprecision(15);
  u64 N, A, B;
  cin >> N >> A >> B;
  u64 d, m;
  d = N / (A + B);
  m = N % (A + B);
  u64 res = d * A;
  if (m > A)
    res += A;
  else
    res += m;
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i=0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll N,M;
int main(void){
    cin >> N >> M;
    ll cnt=0,ans=1;
    for(ll i=1;i*i<=M;i++)if(M%i==0){
        if(i>=N)ans = max(ans,M/i);
        if(M/i>=N)ans=max(ans,i);
    }
    cout << ans << endl;
}


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

int main(){
	int N, L, Q, a, b, i, j, l, h, r, tmp;
	scanf("%d", &N);
	int *x = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		scanf("%d", &x[i]);
	}
	scanf("%d", &L);
	int **dab = (int **)malloc(sizeof(int *) * N);
	for(i = N - 1; i >= 0; i--){
		dab[i] = (int *)malloc(sizeof(int) * 20);
		l = -1;
		r = N;
		while(r - l > 1){
			h = (l + r) / 2;
			if(x[i] + L < x[h]){
				r = h;
			}
			else{
				l = h;
			}
		}
		dab[i][0] = l;
		for(j = 0; j < 19; j++){
			dab[i][j + 1] = dab[dab[i][j]][j];
		}
	}
	scanf("%d", &Q);
	int *ans = (int *)malloc(sizeof(int) * Q);
	for(i = 0; i < Q; i++){
		scanf("%d%d", &a, &b);
		a--;
		b--;
		if(a > b){
			tmp = a;
			a = b;
			b = tmp;
		}
		ans[i] = 1;
		for(j = 19; j >= 0; j--){
			if(dab[a][j] < b){
				a = dab[a][j];
				ans[i] += (1 << j);
			}
		}
	}
	for(i = 0; i < Q; i++){
		printf("%d\n", ans[i]);
	}
	return 0;
}

Measured memory_bytes: 11648
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>

#define rep(i,j,k) for(int i=j;i<k;i++)
#define drep(n,m) for(int i=0;i<n;i++)for(int j=0;j<m;j++)
#define Sort(x) sort((x).begin(),(x).end())
#define fi first
#define se second
#define vi vector<int>
#define INF 1000000000
#define MOD 1000000009
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef unsigned long long ull;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

ll gcd(ll a,ll b){
    if(a<b){
        int t=a;a=b;b=t;
    }
    int c=a%b;
    while(c!=0){
        a=b;
        b=c;
        c=a%b;
    }
    return b;
}

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

bool isPrime(int x){
    if(x==1)return false;
    if(x==2)return true;
    if(x%2==0)return false;
    for(int i=3;i<=sqrt(x);i+=2){
        if(x%i==0)return false;
    }
    return true;
}

typedef struct Point{
    int x;
    int y;
} P;

int main() {
    set<int> st;
    int n;
    cin>>n;
    rep(i,0,n){
        int x;cin>>x;
        st.insert(x);
    }
    cout<<st.size()<<endl;
    return 0;
}




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

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

	cout << max({ a*10 + b + c,a + b*10 + c,a+b+c*10 }) << endl;


	return 0;
}

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

const int MIN = 1;
const int MAX = 1000000000;

bool isRange(int v)
{
    if ((MIN <= v) && (v <= MAX))
    {
        return true;
    }
    return false;
}

int main()
{
    int a, b;
    int d, r;
    double f;
    while (cin >> a >> b)
    {
        d = a / b;
        r = a % b;
        f = (double)a / (double)b;
        cout << d << " "<< r << " "<< fixed << std::setprecision(5) << f <<endl;
    }

    return (0);
}

Measured memory_bytes: 3228
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define fr(i, n) for (int i = 0; i < n; i++)
#define frf(i, j, n) for (int i = j; i <= n; i++)
#define frd(i, n) for (int i = n; i >= 0; i--)
#define mp(i, j) make_pair(i, j)
#define pb(x) push_back(x)
using namespace std;
// typedef vector<vector<ll> > matrix;
// const ll S = 3e5 + 20;
// const ll N = 1e6 + 1;
// const ll PRIME = 1e9 + 7;
const ll MAX = 1e6;

void solve()
{
    int n, x;
    cin >> x >> n;
    int b[102];
    memset(b, 0, sizeof(b));
    b[0] = 0;
    int a[n];
    fr(i, n)
    {
        cin >> a[i];
        b[a[i]] = 1;
    }
    if (n == 0)
    {
        cout << x;
        return;
    }
    vector<int> ans(102);
    frf(i, 0, 101)
    {
        if (b[i] == 0)
        {
            ans.pb(i);
        }
    }

    int pos = lower_bound(ans.begin(), ans.end(), x) - ans.begin();
    if (ans[pos] == x)
    {
        cout << x;
        return;
    }
    if ((abs(ans[pos - 1] - x)) <= (abs(ans[pos] - x)))
    {
        cout << ans[pos - 1];
        return;
    }
    cout << ans[pos];
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

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


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

int main ()
{
    int n;
    cin >> n;
    while (n--)
    {
        char c;
        cin >> c;
        if (c=='Y')
        {
            cout << "Four" << endl;
            return 0;
        }
    }
    cout << "Three" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
/* #include <atcoder/all> */
#include <iostream>
using namespace std;
/* using namespace atcoder; */
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) \
    for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) \
    for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(), v.end()
#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
constexpr ll MOD = 998244353;
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (int i = 0; i < v.size(); ++i) {
        is >> v[i];
    }
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    if (v.size() == 0) return os;
    for (int i = 0; i < v.size() - 1; ++i) {
        os << v[i] << " ";
    }
    os << v[v.size() - 1];
    return os;
}

void solve() {
    int m1,d1,m2,d2;
    cin >> m1 >> m2 >> d1 >> d2;
    if (d2 == 1) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }
}


int main() {
    solve();
    char tmp;
    while (cin >> tmp) {
        cin.putback(tmp);
        solve();
    }
}



Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
template<typename T>
void print(T x) {
    cout << x << endl;
}
ll f(ll x) {
    if(x%2) return 3*x + 1;
    else return x/2;
}
int main(void) {
    ll s; cin >> s;
    map<ll,int> mp;
    mp[s]++;
    rep(i, 1000001) {
        s = f(s);
        if(mp[s]) {
            cout << i+2;
            return 0;
        }
        mp[s]++;
    }
}



Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define Decimal fixed << setprecision(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}
constexpr int INF = 1 << 30 - 1;
constexpr long long LLINF = 1LL << 60;
constexpr long long MOD = 1000000007;

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

ll A[301][301];
int N;
bool check(int i, int j)
{
  for (int k = 0; k < N; k++) {
    if (k == i || k == j) continue;
    if (A[i][k] + A[k][j] == A[i][j]) return false;
  }
  return true;
}
int main()
{
  cin >> N;
  REP(i, N) {
    REP(j, N) {
      cin >> A[i][j];
    }
  }
  REP(k, N) {
    REP(i, N) {
      REP(j, N) {
        if (A[i][j] > A[i][k] + A[k][j]) {
          cout << -1 << endl;
          return 0;
        }
      }
    }
  }

  ll ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      if (check(i, j)) ans += A[i][j];
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define N 10010
vector<int> prime_list;

void seive(){
    int prime[N];
    memset(prime, 1, sizeof(prime));
    prime_list.clear();
    prime[0] = 0;
    prime[1] = 0;
    for(int i = 0; i*i <= N; i++){
        if(prime[i]){
            for(int j = 2*i; j < N; j += i) prime[j] = 0;
        }
    }
    for(int i = 0; i < N; ++i)
        if(prime[i]) prime_list.push_back(i);
}

int check_prime(int num){
    if(num == 2) return 1;
    if(!num&1) return 0;

    int state = 1;
    int size = prime_list.size();
    for(int i = 0; i < size && prime_list[i]*prime_list[i]<=num; ++i){
        if(!(num%prime_list[i])){
            return 0;
        }
    }
    return 1;
}

int main(){
    //FILE *inp = freopen("in.txt", "r", stdin);
    int n, num;
    int prime_cnt = 0;
    seive();
    cin>>n;
    for(int i = 0; i < n; ++i){
        cin>>num;
        if(check_prime(num)){
            prime_cnt++;
        }
    }
    cout << prime_cnt << endl;
    //fclose(inp);
    return 0;
}

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

int main(){
  string s;
  cin >>s;
  int p;
  for(int i=0;i<s.size();i++){
    if(s[i]!=s[s.size()-i-1]) p++;
  }
  cout << p/2 <<endl;
  
}
  

Measured memory_bytes: 3600
#include<stdio.h>
int main(void)
{
	double r,PI=3.141592653589,menseki,ensyu;

	scanf("%lf",&r);

	menseki = PI*r*r;

	ensyu = PI*r*2;

	
	
	printf("%f %f",menseki,ensyu);
	
	return 0;
}

Measured memory_bytes: 648
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
using namespace std;

typedef long long ll;
const int INF = 1e+9;

int main() {
	static int dp[3010][3010];
	string s, t, ans;
	cin >> s >> t;
	for (int i = 0; i < s.length(); ++i) {
		for (int j = 0; j < t.length(); ++j) {
			if (s[i] == t[j]) dp[i + 1][j + 1] = dp[i][j] + 1;
			else if (dp[i + 1][j] > dp[i][j + 1])
				dp[i + 1][j + 1] = dp[i + 1][j];
			else dp[i + 1][j + 1] = dp[i][j + 1];
		}
	}
	int i = s.length(), j = t.length();
	while (i > 0 && j > 0) {
		if (dp[i][j] == dp[i - 1][j]) --i;
		else if (dp[i][j] == dp[i][j - 1]) --j;
		else {
			--i;
			--j;
			ans.push_back(s[i]);
		}
	}
	reverse(ans.begin(), ans.end());
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
const int MOD = 1000000007;
const int INF = 1e9;
typedef long long ll;


int main(){
    int h,w;
    cin >> h >> w;
    
    vector<string> s(h);
    rep(i,h){
        cin >> s[i];
    }

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

    rep(i,h){
        rep(j,w){
            if(s[i][j]=='.') continue;
            int count = 0;
            rep(d,4){
                int x = i + dx[d];
                int y = j + dy[d];
                if(x < 0 || x >= h || y < 0 || y >= w) continue;
                if(s[x][y]=='.') count++;
            }
            if(count==4){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
program sum_of_large_numbers
  implicit none
  integer(8), parameter :: md = 1000000007_8
  integer :: n, k, i
  integer(8) :: x = 0, s(0:200000) = 0
  read(*,*) n, k
  do i = 1, n
    s(i) = mod(s(i-1)+i,md)
  end do
  do i = k, n+1
    x = modulo(x+(s(n)-s(n-i))-(s(i-1)-s(0))+1,md)
  end do
  write(*,'(i0)') x
end program sum_of_large_numbers

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

using namespace std;
using ll = long long;

struct Edge {
  int from, to;
  ll cost;
};

int n, m;
vector<Edge> edge[2010];

void bellmanford() {
  queue<int> q;
  vector<ll> score(n, -1e16);
  vector<set<int>> froms(n);
  q.push(0);
  score[0] = 0;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (auto e: edge[u]) {
      if (froms[e.to].count(e.from)) {
        if (score[e.to] == 1e16) {
          continue;
        }
        if (score[e.to] < score[e.from] + e.cost) {
          score[e.to] = 1e16;
        } else if (score[e.to] > score[e.from] + e.cost) {
          continue;
        } else {
          continue;
        }
      }
      froms[e.to].insert(e.from);
      if (score[e.to] < score[e.from] + e.cost) {
        score[e.to] = score[e.from] + e.cost;
        if (score[e.to] > 1e16) {
          score[e.to] = 1e16;
        }
      }
      q.push(e.to);
    }
  }
  if (score[n - 1] == 1e16) {
    cout << "inf" << endl;
  } else {
    cout << score[n - 1] << endl;
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--; b--;
    edge[a].push_back({a, b, c});
  }
  bellmanford();
  return 0;
}

Measured memory_bytes: 512
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N := ReadInt()
	D := ReadInts(N)

	c := make([]int, Max(D...)+1)
	for _, d := range D {
		c[d]++
	}

	if D[0] != 0 || c[0] != 1 {
		fmt.Println(0)
		return
	}

	ans := 1
	for i := 0; i < len(c)-1; i++ {
		ans = ModMul(ans, ModPow(c[i], c[i+1]))
	}
	fmt.Println(ans)
}

const Mod = 998244353

func ModMul(a, b int) int { return (Mod + a%Mod) * (Mod + b%Mod) % Mod }
func ModPow(a, b int) (x int) {
	for x = 1; b > 0; b >>= 1 {
		if b&1 == 1 {
			x = x * a % Mod
		}
		a = a * a % Mod
	}
	return
}

func Max(xs ...int) int {
	max := xs[0]
	for _, x := range xs[1:] {
		if max < x {
			max = x
		}
	}
	return max
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 4020
import java.util.Scanner;

public class Main {

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

	public void run() {
		Scanner sc = new Scanner(System.in);
		long a=sc.nextLong();
		long b=sc.nextLong();
		long k=sc.nextLong();

		if(a<=k) {
			k-=a;
			a=0;
		} else {
			a-=k;
			k=0;
		}

		if(b<k) {
			k-=b;
			b=0;
		} else {
			b-=k;
			k=0;
		}

		System.out.println(a+" "+b);
		sc.close();
	}
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int A,B,C;
  cin>>A>>B>>C;
  vi X(3);
  X[0]=max(A,B)-min(A,B);
  X[1]=max(A,C)-min(A,C);
  X[2]=max(C,B)-min(C,B);
  sort(ALL(X));
  cout<<X[0]+X[1];
  }


Measured memory_bytes: 256
n=int(input())
a=input()
st=set()
st.add(a)
ans='Yes'
for i in range(n-1):
    s=input()
    st.add(s)
    if a[-1]!=s[0]:
        ans='No'
    a=s
if len(st)<n:
    ans='No'
print(ans)


Measured memory_bytes: 38256
S = input()
T = input()

Sd = {}
Sl = []
for c in S:
    if c not in Sd:
        Sd[c] = len(Sd)
    Sl.append(Sd[c])

Td = {}
Tl = []
for c in T:
    if c not in Td:
        Td[c] = len(Td)
    Tl.append(Td[c])

print('Yes' if Sl == Tl else 'No')


Measured memory_bytes: 6832
from itertools import *
N, C = map(int, input().split())
D = [list(map(int, input().split())) for _ in [0]*C]
tri = [[0]*C for _ in [0]*3]
for i in range(N):
    for j,x in enumerate(map(int, input().split())):
        tri[(i+j)%3][x-1] += 1
res = 1<<30
for p in permutations(range(C), 3):
    tt = sum(D[l][p[m]] * tri[m][l] for l in range(C) for m in range(3))
    if tt < res: res = tt
print(res)

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

int main() {
  int n, k, r, s, p;
  vector<int> ans_r(n + k), ans_s(n + k), ans_p(n + k);
  string t;
  cin >> n >> k >> r >> s >> p >> t;
  for (int i = 0; i < n; i++) {
    if (t.at(i) == 'r') {
      ans_p[i + k] = max(ans_r[i], ans_s[i]) + p;
      ans_r[i + k] = max(ans_s[i], ans_p[i]);
      ans_s[i + k] = max(ans_p[i], ans_r[i]);
    } else if (t.at(i) == 's') {
      ans_r[i + k] = max(ans_s[i], ans_p[i]) + r;
      ans_s[i + k] = max(ans_p[i], ans_r[i]);
      ans_p[i + k] = max(ans_r[i], ans_s[i]);
    } else {
      ans_s[i + k] = max(ans_p[i], ans_r[i]) + s;
      ans_p[i + k] = max(ans_r[i], ans_s[i]);
      ans_r[i + k] = max(ans_s[i], ans_p[i]);
    }
  }
  int ans = 0;
  for (int i = n; i < n + k; i++) {
    ans += max(ans_r[i], max(ans_s[i], ans_p[i]));
  }
  cout << ans << endl;
}


Measured memory_bytes: 74240
#include <stdio.h>

long pow(long x) {
	int i;
	long j = 1;
	if (x == 1) {
		return 1;
	}
	for (i = 1; i < 50; i++) {
		if (x < j) {
			return j-1;
		}
		j = j * 2;
	}
}

int main() {
	long H;
	scanf("%ld", &H);
	printf("%ld", pow(H));
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define esp 1e-6

using namespace std;

long long int n,maxx;

int main()
{
    long long int a,b;
    int cnt=0;
    scanf("%lld",&n);
    for(long long int i=1;i<=sqrt(n)+esp;i++)
    {
        if(!(n%i))
        {
            a=i;
            b=n/i;
            maxx=max(a,b);
        }
    }
    while(maxx)
    {
        maxx/=10;
        cnt++;
    }
    printf("%d\n",cnt);
    return 0;
}

Measured memory_bytes: 128