akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

// vectorの重複削除
// std::sort(test.begin(), test.end());
// test.erase(std::unique(test.begin(), test.end()), test.end());

using namespace std;
using ll = long long;
using P = pair<int, int>; // vector<P> ba(n); みたいな感じですぐ使える ba[i] = P(a, b); make_pairをしなくてもいい
// typedef vector<int> v;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define rep(i, c) for(int i = 0; i < int(c); i++)
#define ALL(x) (x).begin(), (x).end() //sort(ALL(obj))みたいな
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値
#define pb push_back //
// const int MOD = 1000000007;
// string alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  int n,cnt=0;
  cin >> n;
  std::vector<int> v(n);
  rep(i,n) cin >> v[i];
  int num = n*(n-1)/2;
  for (int i=0; i<n-1; i++){
    for (int j=i+1; j<n; j++){
      cnt += v[i] * v[j];
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.TreeMap;



 class Main{
	 
	 
	 
	

	public static void main(String[] args) throws IOException {
		
		
		FastScanner sc=new FastScanner();
		int n = sc.nextInt();
		long arr[][] = new long[n+1][3];
		for(int i=1; i<=n; i++) {
			arr[i][0] = sc.nextLong();
			arr[i][1] = sc.nextLong();
			arr[i][2] = sc.nextLong();
		}
		long dp[][] = new long[n+1][3];
		
		dp[1][0] = arr[1][0];
		dp[1][1] = arr[1][1];
		dp[1][2] = arr[1][2];
		
		for(int i=2; i<=n; i++) {
//			System.out.println(arr[i][0]+" "+arr[i][1]+" "+arr[i][2]);
			dp[i][0] = Math.max(dp[i-1][1], dp[i-1][2]) + arr[i][0];
			dp[i][1] = Math.max(dp[i-1][0], dp[i-1][2]) + arr[i][1];
			dp[i][2] = Math.max(dp[i-1][0], dp[i-1][1]) + arr[i][2];
			
		}
		System.out.println(Math.max(dp[n][2],Math.max(dp[n][0], dp[n][1])));
		
				
	}
	
	
	
	
 
	static void sort(int[] a) {
		ArrayList<Integer> l=new ArrayList<>();
		for (int i:a) l.add(i);
		Collections.sort(l);
		for (int i=0; i<a.length; i++) a[i]=l.get(i);
	}
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long[] readArrayLong(int n) {
        	long[] a=new long[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
        }
		long nextLong() {
			return Long.parseLong(next());
		}
		String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
	}
}


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

using namespace std;

int main(){
	long long int v[30],n;
	memset(v,0,sizeof v);
	string a;
	
	cin>>a;
	for(long long i=0;i<(long long)a.length();i++)
		v[a[i]-'a']++;
	

	unsigned long long ans = ((long long)a.length()*((long long)a.length()-1)/2);
	for(int i=0;i<26;i++){
		if(v[i]>1)
			ans -=v[i]*(v[i]-1)/2;
	}
	printf("%llu\n",ans+1);
}

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

using namespace std;
using ll = long long;

#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define REP(i,n) FOR(i, 0, n)
#define FORD(i,a,n) for(int i=(a); i>=(n); i--)
#define REPD(i,n) FOR(i, n, 0)

#define ALL(o) (o).begin(), (o).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T, vector<T>, greater<T> >;

// Union Find
// ref: Atcoder ABC 157解説(https://www.youtube.com/watch?v=TdR816rqc3s&feature=youtu.be)
// ref: https://www.slideshare.net/iwiwi/ss-3578491
// 各ノードには親のid(番号)をもたせる
// rootノードには負の数にして木のサイズをもたせる
// 2つの木を結合するときは木のサイズが小さい方を大きい方にくっつける

struct UnionFind {
	vector<int> d;
	UnionFind(int n=0): d(n,-1) {}
	int find(int x) {
		if(d[x] < 0) return x;
		return d[x] = find(d[x]);
	}
	bool unite(int x, int y) {
		x = find(x); y = find(y);
		if(x == y) return false;
		if(d[x] > d[y]) swap(x,y);
		d[x] += d[y];
		d[y] = x;
		return true;
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
	int size(int x) {
		return -d[find(x)];
	}
};

int deg[100005];
V<int> to[100005];

int main() {
	int n,m,k;
	cin >> n >> m >> k;
	UnionFind uf(n);
	REP(i,m) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		deg[a]++;
		deg[b]++;
		uf.unite(a,b);
	}
	REP(i,k) {
		int a,b;
		cin >> a >> b;
		--a; --b;
		to[a].push_back(b);
		to[b].push_back(a);
	}
	REP(i,n) {
		int ans = uf.size(i)-1-deg[i];
		for(int u: to[i]) {
			if(uf.same(i,u)) --ans;
		}
		printf("%d%c", ans, i==n-1?'\n':' ');
	}
	return 0;
}



Measured memory_bytes: 6784
#!/usr/bin/env python

import random

class Dice:
    def __init__(self, top, s, e, w, n, bottom):
        self.top    = top
        self.s      = s
        self.e      = e
        self.w      = w
        self.n      = n
        self.bottom = bottom

    def rotate(self, dist):
        if dist == 'N':
            self.top, self.s, self.n, self.bottom = self.s, self.bottom, self.top, self.n 
        elif dist == 'S':
            self.s, self.bottom, self.top, self.n = self.top, self.s, self.n, self.bottom 
        elif dist == 'E':
            self.top, self.e, self.w, self.bottom = self.w, self.top, self.bottom, self.e 
        elif dist == 'W':
            self.w, self.top, self.bottom, self.e = self.top, self.e, self.w, self.bottom 

if __name__ == '__main__':
    random.seed(0)

    n = input()
    dice = [Dice(*map(int, raw_input().split())) for _ in range(n)]
    ref  = [set() for _ in range(n)]

    for _ in range(1000):
        if len(ref[0]) > 23:
            break

        dist = 'NEWS'[random.randint(0,3)]
        for i in range(n):
            ref[i].add((dice[i].top, dice[i].s, dice[i].e))
            dice[i].rotate(dist)
    
    print 'Yes' if len(set(map(str, ref))) == n else 'No'



Measured memory_bytes: 7100
#include <bits/stdc++.h>
using namespace std;
 //答え見た
int main() {
  int n;
  cin >> n;
  int price;
  for(int i=0;i<=n/4;i++){
    for(int j=0;j<=n/7;j++){
      if( n == 4*i + 7*j){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
      
	
  return 0;
  
}

Measured memory_bytes: 256
#define LOCAL
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos((ld)-1.0))
#define MAXN (300006)
#define ll long long int 
#define ld long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = ss; ii < (ll)ee; ++ii)
#define space " "
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define ph push
#define btinpct(x) __builtin_popcountll((x))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
string to_string(char c) {string s(1,c);return s;}string to_string(bool b){return (b ? "true" : "false");}template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}template <typename A>string to_string(A v) {bool first = true;string res = "{";for (const auto &x : v) {if (!first) {res += ", ";}first = false;res += to_string(x);}res += "}";return res;}void degug_out() { cerr << endl; }template <typename Head, typename... Tail>void degug_out(Head H, Tail... T) {cerr << " " << to_string(H);degug_out(T...);}inline ll gcd(ll a,ll b){if(a>b)swap(a,b);if(a==0)return b;return gcd(b%a,a);}
#ifdef LOCAL
#define degug(...) cerr << "[" << #__VA_ARGS__ << "]:", degug_out(__VA_ARGS__)
#else
#define degug(...) 42
#define cerr if(0)cout
#endif
ll n,A[MAXN],sign[MAXN];
vector<ll>P,N;
int main()
{
	FAST
	cin>>n;
	FOR(i,0,n)cin>>A[i];
	sort(A,A+n);
	ll pos=0,neg=0;
	FOR(i,0,n)sign[i]=(A[i]<0?-1:1);
	FOR(i,0,n)pos+=(A[i]>=0);
	FOR(i,0,n)neg+=(A[i]<0);
	if(neg==n){
		sign[n-1]*=-1;
		--neg,++pos;
	} else if(pos==n){
		sign[0]*=-1;
		++neg,--pos;
	}
	FOR(i,0,n)if(sign[i]==-1)N.pb(A[i]);else P.pb(A[i]);
	ll ans=0;
	FOR(i,0,n)ans+=(sign[i]*A[i]);
	cout<<ans<<'\n';
	if(pos==1){
		ll sum=0;
		cout<<P[0]<<' '<<N.back()<<'\n';
		sum=P[0]-N.back();N.pop_back();
		while(N.size()){
			cout<<sum<<' '<<N.back()<<'\n';
			sum-=N.back();N.pop_back();
		}
		assert(sum==ans);
	}else{
		ll sum=0; 
		cout<<N.back()<<' '<<P.back()<<'\n';
		sum=N.back()-P.back();N.pop_back();P.pop_back();
		while(P.size()>1){
			cout<<sum<<' '<<P.back()<<'\n';
			sum-=P.back();
			P.pop_back();
		}
		cout<<P.back()<<' '<<sum<<'\n';
		sum=P.back()-sum;P.pop_back();
		while(N.size()){
			cout<<sum<<' '<<N.back()<<'\n';
			sum-=N.back();
			N.pop_back();
		}
		assert(sum==ans);
	}
}


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

int main(){
    int n,t,a,ans,i;
    long double q=1000000000000;
    cin >> n;
    cin >> t >> a;
    vector< pair<double,double> > h(n);
    for(i=0;i<n;i++){
        cin >> h.at(i).second;
        h.at(i).first=abs(t-0.006*h.at(i).second-a);
    }
    for(i=0;i<n;i++){
        if(q>h.at(i).first){
            q=h.at(i).first;
            ans=i;
        }
    }
    cout << ans+1 << endl;
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/abc094/tasks/abc094_b

n,m,x=map(int,input().split())
a=list(map(int,input().split()))
left=0
for i in range(m):
    if a[i]<x:left+=1
    else:break
right=m-left
print(min(left,right))

Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    cout << a * b / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))
a_sorted = sorted(a, reverse = True)

A, B = 0, 0

for i in range(N):
    if i % 2 == 0:
        A += a_sorted[i]
    else:
        B += a_sorted[i]

print(A-B)

Measured memory_bytes: 9064
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define base 31
#define MOD 1e9+7
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define FORs(i, a, b) for(int i = a; i >= b; i--)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define __FOR(i, a, b, k) for(int i = a; i <= b; i+= k)
#define __REP(i, a, b, k) for(int i = a; i < b; i+= k)
#define pb push_back
#define _io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;

typedef pair <int, int> ii;
typedef vector <ii> vii;
#define fi first
#define se second
#define mp make_pair
int m,d,res;
int main(){
	
	cin>>m>>d;
	res=0;
	FOR(i,1,d){
		if  ((i/10>=2) && (i%10>=2) &&  ((i/10) *(i%10)<=m)) ++res;
	}
	cout<< res;
}


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

using namespace std;

typedef long long ll;

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;
}

class RollingHash {
    const int base = 9973;
    const int mod = 1000000007;
    string S;
    vector<ll> hash, power;

    public:
        RollingHash(const string &cs) {
            S = cs;
            int n = (int) S.size();
            hash.assign(n + 1, 0);
            power.assign(n + 1, 1);
            for (int i = 0; i < n; i++) {
                hash[i + 1] = (hash[i] * base + S[i]) % mod;
                power[i + 1] = power[i] * base % mod;
            }
        }

        // Get hash of S[left:right] (left: inclusive, right: exclusive)
        // if S = aabaaa, rh.get(0, 2) calculates hash of 'aa' {S[0], S[1]}.
        inline ll get(int l, int r) const {
            ll res = hash[r] - hash[l] * power[r - l] % mod;
            if (res < 0) res += mod;
            return res;
        }
};

/*
 * ref. http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_14_B&lang=jp
 * ref. http://drken1215.hatenablog.com/entry/2019/03/19/015700
 */
int main(void) {
    string T, P;
    cin >> T >> P;

    int lenT = (int) T.size();
    int lenP = (int) P.size();

    if (lenT < lenP) {
        return 0;
    }

    RollingHash rhT(T);
    RollingHash rhP(P);

    ll hash = rhP.get(0, lenP);

    for (int i = 0; i < lenT - lenP + 1; i++) {
        if (hash == rhT.get(i, i + lenP)) {
            if (T.substr(i, lenP) == P) {
                cout << i << "\n"; // avoid endl (it flush buffers each time) when there are many outputs
            }
        }
    }

    return 0;
}



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

#define ll long long
#define ld long double

using namespace std;

const ll inf = (ll)1e9;
const ll MOD = (ll)1e9 + 7;
const ld pi = atan2(0, -1);
const ll N = 1000000;

void print(vector<int> &a)
{
    for (int i : a)
        cout << i << " ";
    cout << endl;
}

const int B = 16;
int pref[(1 << B) + 1];

void sort_n(vector<int> &a)
{
    int n = a.size(), x = (1 << B) - 1;
    vector<int> a1(n);
    fill(pref, pref + (1 << B) + 1, 0);
    for (int i : a)
        pref[(i & x) + 1]++;
    for (int i = 1; i <= (1 << B); i++)
        pref[i] += pref[i - 1];
    for (int i : a)
        a1[pref[(i & x)]++] = i;
    fill(pref, pref + (1 << B) + 1, 0);
    for (int i : a1)
        pref[(i >> B) + 1]++;
    for (int i = 1; i <= (1 << B); i++)
        pref[i] += pref[i - 1];
    for (int i : a1)
        a[pref[(i >> B)]++] = i;
}

int main()
{
    //freopen("makesaw.in", "r", stdin);
    //freopen("makesaw.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 1; i < s.size(); i++)
        if (s[i] != s[i - 1])
            ans++;
    cout << ans;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
const lli MAX=1e5+2;
const lli MOD=1e9+2;

int main(){
		int N,M;
	cin>>N>>M;
	lli PY[MAX];
  	int ord[MAX];
	map<lli,int> pr;
	rep1(i,M){
		int p,y;
		cin>>p>>y;
		PY[i]=(lli)p*MOD+y;
      	pair<lli,int> x=make_pair(PY[i],i);
		pr.insert(x);
	}
  	int j=0;
  	lli nowp=(lli)0;
	lli nowy=(lli)0;
	while(!pr.empty()){
		map<lli,int>::iterator it;
		it=pr.begin();
		lli py=it->first;
		lli ind=it->second;
		lli p=py/MOD;
		lli y=py%MOD;
		pr.erase(it);
      	//cout<<p<<endl;
		if(nowp==p){
			j++;
			ord[ind]=j;			
		}
		else{
          	nowp=p;
			ord[ind]=1;
			j=1;
		}
	}
	rep1(i,M){
		int p=PY[i]/MOD;
		printf("%06d", p);
		printf("%06d\n", ord[i]);
		
	}
}

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

using namespace std;

const int N = 1e5 + 10;

vector<int> v[N];
int f[N];
int DP(int x) {
    int &ans = f[x];
    if (ans != -1) return ans;
    ans = 0;
    for(auto y : v[x]) ans = max(ans, DP(y) + 1);
    return ans;
}
int main() {
    int n, m;
    cin >> n >> m;
    while (m--) {
        int x, y;
        cin >> x >> y;
        v[x].push_back(y);
    }
    memset(f, -1, sizeof(f));
    int ans = 0;
    for(int i = 1; i <= n; i++) ans = max(ans, DP(i));
    cout << ans;
}


Measured memory_bytes: 7424
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1 << 30;

using namespace std;

using ll = long long;
using P = tuple<int, int>;
using iarr = valarray<int>;

int main()
{
  int a,b,c;
  cin >> a >> b >> c;
  if (a + b + c >= 22){
    cout << "bust" << endl;
  }else {
    cout << "win" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;
ll inf = 100000000;
typedef pair<ll, ll> P;
int main() {
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		for (int j = 0; j < s.size() - i; j++) {
			string a = s;
			
			a.erase(i,j);
			
			if (a == "keyence") {
				cout << "YES" << endl;
				return 0;
			}
		}
	}
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
<?php
$input = STDIN;

while (true) {
    $cards = trim(fgets($input));
    if ($cards == '-')
        break;
    
    $m = intval(trim(fgets($input)));
    for ($i = 0; $i < $m; $i++) {
        $h = intval(trim(fgets($input)));
        $cards = substr($cards, $h) . substr($cards, 0, $h);
    }
    print $cards . "\n";
}


Measured memory_bytes: 9212
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

template<class T> 
inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> 
inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};


void solve(){
    ll n;
    cin>>n;
    string s[100010];
    rep(i,n){
        cin>>s[i];
    }
    ll cnt[10]={};
    rep(i,n){
        if(s[i][0]=='M') cnt[0]++;
        else if(s[i][0]=='A') cnt[1]++;
        else if(s[i][0]=='R') cnt[2]++;
        else if(s[i][0]=='C') cnt[3]++;
        else if(s[i][0]=='H') cnt[4]++;
    }
    ll ans=0;
    rep(i,5){
        rep2(j,i+1,5){
            rep2(k,j+1,5){
                ans+=cnt[i]*cnt[j]*cnt[k];
            }
        }
    }
    cout<<ans<<endl;
}




signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
    
    solve();

    return 0;
}


Measured memory_bytes: 5760
<?php
$div = 1000000000+7;
fscanf(STDIN, "%d %d", $n, $m);

if(abs($n-$m) > 1){
  echo "0\n";
  return;
}else if(abs($n-$m) == 1){
  echo factorial($n) * factorial($m) % $div;
  echo "\n";
}else{
  echo factorial($n) * factorial($m) * 2 % $div;
  echo "\n";
}

function factorial($x){
  $div = 1000000000+7;
  $a = 1;
  for($i = 1; $i <= $x; $i++){
    $a *= $i;
    $a %= $div;
  }
  return $a;
}
?>


Measured memory_bytes: 4728
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main() {
    fastio
    
	ll n,i,j,x,t,k,m,y;
	cin>>n>>k;
	
	ll a[n];
	vector<ll> dp(n,1e10);
	
	for(j=0;j<n;j++)
	cin>>a[j];
	
	dp[0]=0;
	
	for(i=0;i<n;i++){
	    for(j=i+1;j<=min(i+k,n-1);j++)
	    dp[j]=min(dp[j],dp[i]+abs(a[j]-a[i]));
	}
	
	cout<<dp[n-1];
	
	return 0;
}



Measured memory_bytes: 4776
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<PII> ab(N), cd(N);
    bool useda[205] = {};
    bool usedb[205] = {};
    REP(i,N)
    {
        int tmpa,tmpb; cin >> tmpa >> tmpb;
        ab[i] = make_pair(tmpa,tmpb);

    }
    REP(i,N)
    {
        int tmpa,tmpb; cin >> tmpa >> tmpb;
        cd[i] = make_pair(tmpa,tmpb);
    }
    sort(ab.begin(), ab.end());
    sort(cd.begin(), cd.end());
    int ans = 0;

    for(auto p : cd)
    {
        dump(p.first)
        dump(p.second)
        int wanta;
        int wantb = -1;
        for(auto q : ab)
        {
            dump(q.first)
            dump(q.second)
            if(q.first >= p.first) break;
            if(useda[q.first] == true)
            {
                dump("used!")
                continue;
            }

            if(q.second <= p.second && q.second > wantb)
            {
                wantb = q.second;
                wanta = q.first;
            }
        }
        if(wantb != -1)
        {
            dump("friend!")
            useda[wanta] = true;
            ans++;
        }
    }
    cout << ans << endl;




}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var xy = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
            long ans = 1;
            while (xy[0]*2 <= xy[1])
            {
                ans++;
                xy[0] *= 2;
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13140
#include<iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<vector>

using namespace std;

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

int main(){
    int n;
    cin >> n;
    int a[2][n];
    rep(i, 2)rep(j, n) cin >> a[i][j];
    int ans = 0;
    for (int i = 0; i < n; i++){
        int num = 0;
        for (int j = 0; j <= i; j++){
            num += a[0][j];
        }
        for (int j = i; j < n; j++){
            num += a[1][j];
        }
        ans = max(ans, num);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
const int inf = 1<<30;

int main() {
  int A, B, M; cin >> A >> B >> M;
  vector<int> a(A), b(B);
  int mina = inf, minb = inf;
  for(int i = 0; i < A; i++) cin >> a[i], mina = min(mina, a[i]);
  for(int i = 0; i < B; i++) cin >> b[i], minb = min(minb, b[i]);
  int ans = mina+minb;
  for(int i = 0; i < M; i++) {
    int x, y, c; cin >> x >> y >> c; x--, y--;
    ans = min(ans, a[x]+b[y]-c);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
using namespace std;
const int mod=1e9+7;
const int r=(mod+1)>>1;
inline int add(int x)
{
	return x>=mod?x-mod:x;
}
int n,Q;
int a[3050];
int f[3050][3050]; 
int t[3050][3050];
int main()
{
	scanf("%d%d",&n,&Q);
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&a[i]);
	}
	for(int i=1;i<=n;++i)
	{
		for(int j=1;j<=n;++j)
		{
			if(a[i]>a[j]) f[i][j]=1;
		}
	} 
	for(int i=1;i<=Q;++i)
	{
		int x,y; scanf("%d%d",&x,&y);
		for(int j=1;j<=n;++j) if(j!=x)
		{
			t[j][x]=1ll*(f[j][x]+f[j][y])*r%mod;
			t[x][j]=1ll*(f[x][j]+f[y][j])*r%mod;
		}
		for(int j=1;j<=n;++j) if(j!=y)
		{
			t[j][y]=1ll*(f[j][y]+f[j][x])*r%mod;
			t[y][j]=1ll*(f[y][j]+f[x][j])*r%mod;
		}
		t[x][y]=1ll*(f[x][y]+f[y][x])*r%mod;
		t[y][x]=1ll*(f[y][x]+f[x][y])*r%mod;
		for(int j=1;j<=n;++j) if(j!=x)
		{
			f[j][x]=t[j][x];
			f[x][j]=t[x][j];
		}
		for(int j=1;j<=n;++j) if(j!=y)
		{
			f[j][y]=t[j][y];
			f[y][j]=t[y][j];
		}
		f[x][y]=t[x][y];
		f[y][x]=t[y][x];
	}
	int an=0;
	for(int i=1;i<=n;++i)
	{
		for(int j=i+1;j<=n;++j)
		{
			an=add(an+f[i][j]);
		}
	}
	for(int i=1;i<=Q;++i)
	{
		an=add(an<<1);
	}
	printf("%d\n",an);
	return 0;
}

Measured memory_bytes: 72320
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl

int main() {
    string s; cin >> s;

    string res = s.at(0) + to_string(s.size()-2) + s.at(s.size()-1);
    cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool comp(pair<long long int,long long int>a,pair<long long int,long long int>b)
{
    if(a.first==b.first)
    {
        if(a.second<=b.second)
        return true;
        else
        return false;
    }
    if(a.first>b.first)
    return true;
    else return false;
}
long long int gcd(long long int bdda,long long int chota)
{
    if(chota==0)
        return bdda;
    return gcd(chota,bdda%chota);
}
void solve()
{
    long long int n;
    cin>>n;
    long long int ans=0,p=1;
    while(n>0)
    {
        if(n==1)
        {
            n=0;
            ans+=1*p;
            continue;
        }
        n=n/2;
        ans+=p;
        p*=2;
    }
    cout<<ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;    
    t=1;

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


Measured memory_bytes: 3652
N, M = map(int, input().split())
X = list(map(int, input().split()))

X.sort(reverse=True)
num = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
dp = [-1] * (N + 1)
dp[0] = 0

for a in X:
    for i in range(N + 1):
        if dp[i] == -1 or i + num[a] > N:
            continue
        dp[i + num[a]] = max(dp[i + num[a]], dp[i] * 10 + a)

print(dp[-1])


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

int a[10];
int b[10];

int score(int x[10]){
  int a=0,b=0,c=0,tmp;

  for(int i=0;i<10;i++){
    if(a < x[i]){
      tmp = a;
      a = x[i];
      x[i] = tmp;
    }
    if(b < x[i]){
      tmp = b;
      b = x[i];
      x[i] = tmp;
    }
    if(c < x[i]){
      tmp = c;
      c = x[i];
      x[i] = tmp;
    }
  }
  return a + b + c;
}
int main(){
  for(int i=0;i<10;i++)cin >> a[i];
  for(int i=0;i<10;i++)cin >> b[i];

  int sa = score(a);
  int sb = score(b);
  
  cout << sa << " " << sb << endl;

  return 0;
}

Measured memory_bytes: 0
import java.io.*;
import java.util.*;

public class Main{
    public static void main(String [] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        // int test = Integer.parseInt(br.readLine());

        // while(test-->0) {
            
            String temp[] = br.readLine().split(" ");
            int a=  Integer.parseInt(temp[0]);
            int b = Integer.parseInt(temp[1]);
            System.out.println(a*b);

        // }

    }
}


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

struct Job {
	int delay;
	int reward;
	friend istream& operator>>(istream& in, Job& x) { return in >> x.delay >> x.reward; }
};

template <typename T> T load() { T r; cin >> r; return r; }
template <typename T> vector<T> loadMany(int n) { vector<T> rs(n); generate(rs.begin(), rs.end(), &load<T>); return rs; }

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	auto n = load<int>();
	auto m = load<int>();
	auto jobs = loadMany<Job>(n);
	sort(jobs.begin(), jobs.end(), [&](const Job& j1, const Job& j2){
		return j1.delay < j2.delay;
	});
	auto ij = 0;
	auto sack = multiset<int>();
	auto answer = 0;
	for (auto i=m-1; i>=0; --i) {
		while (ij < n and i + jobs[ij].delay <= m)
			sack.insert(jobs[ij++].reward);
		if (not sack.empty()) {
			answer += *prev(sack.end());
			sack.erase(prev(sack.end()));
		}
	}
	cout << answer << '\n';
}


Measured memory_bytes: 5632
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {
	private static final long MOD = 1000000007;
	
	public Main() {
		FastScanner scanner = new FastScanner();
		int S = scanner.nextInt();
		
		long DP[][] = new long[670][S+1];
		DP[0][0] = 1;
		
		for (int i = 0; i < 669; i++) {
			for (int s = 0; s < S-2; s++) {
				DP[i+1][s+3] = (DP[i+1][s+3] + DP[i][s]) % MOD;
			}
			
			long SUM = 0;
			for (int s = 0; s <= S; s++) {
				SUM = (SUM + DP[i+1][s])%MOD;
				DP[i+1][s] = SUM;
			}
		}
		
		long Ans = 0;
		for (int i = 1; i < 670; i++) {
			Ans = (Ans + DP[i][S])%MOD;
		}
		
		System.out.println(Ans);
	}
	
	public static void main(String[] args) {
		new Main();
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	
	private int readByte() {
		if (hasNextByte()) return buffer[ptr++];
		else return -1;
	}
	
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
		return hasNextByte();
	}
	
	public String next() {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	
	public long nextLong() {
		if (!hasNext()) throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) nl;
	}
	
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 44308
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int a, b;
    cin >> a >> b;
    int cnt = 0;
    int x = b;
    while(x > 0){
        cnt++;
        x /= 10;
    }
    int n = a*pow(10, cnt) + b;
    if((int)sqrt(n) * (int)sqrt(n) == n) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// #define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
int main(){
    int a,b;
    cin >>a>>b;
    int total=a+b;
    if(total%2==0) {
        cout<<total/2<<endl;
        return 0;
    }else{
        cout << "IMPOSSIBLE"<<endl;
        return 0;
    }
}

Measured memory_bytes: 256
import numpy as np

def cal(output_lst, b_lst):
    for i in range(N):
        t = -1
        for j in range(N-i):
            if b_lst[j] == j+1:
                t = j
        if t == -1:
            return False
        output_lst.append(b_lst.pop(t))
    return True


N = int(input())

output_lst = []


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

judge = cal(output_lst, b_lst)
output_lst.reverse()

if judge:
    for low in output_lst:
        print(low)
else:
    print(-1)
            

print()

Measured memory_bytes: 12500
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) throws Exception{
		
		Scanner sc = new Scanner(System.in);
		

		int N = sc.nextInt();
		int L = sc.nextInt();
		
		String[] S = new String[N];
		for(int i=0; i<N; i++){
			S[i] = sc.next();
		}
		
		Arrays.sort(S);
		
		for(int i=0; i<N; i++){
			System.out.print(S[i]);
		}
		System.out.println();

		sc.close();
	}
}


Measured memory_bytes: 10196
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ll n,i,j,k,l;
	cin >> n >> k;
	ll h[n+1];
	ll dp[n+1];
	for(i=0;i<n;i++)
	{
		cin >> h[i];
	}
	dp[0]=0;
	dp[1]=abs(h[1]-h[0]);
	for(i=2;i<n;i++)
	{
		dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
		for(j=2;j<=k;j++)
		{
			if(i-j<0)
			{
				continue;
			}
			dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
		}
	}
	cout << dp[n-1] << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <functional>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <cmath>

using namespace std;

inline int solution(istream &cin, ostream &cout) {
  int n, t, a;
  cin >> n >> t >> a;
  int ans = 10000000;
  double diff = 10000000;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    double d = double(t) -double(x) * 0.006;
    if (diff > fabs(double(a) - d)) {
      ans = i + 1;
      diff = fabs(double(a) - d);
    }
  }
  cout << ans << endl;
  return 0;
}

#if defined(LOCAL_TEST_RUN)

#include "gtest/gtest.h"
#include "gmock/gmock-matchers.h"
#include "gmock/gmock-more-matchers.h"
#include <sstream>

typedef pair<string, string> TestParam;
class ATest : public ::testing::TestWithParam<TestParam> {};

TEST_P(ATest, ExampleTest) {
  string input, expected_output;
  tie(input, expected_output) = GetParam();

  stringstream ss(input);
  stringstream out;
  solution(ss, out);
  EXPECT_THAT(out.str(), ::testing::StartsWith(expected_output));
}

INSTANTIATE_TEST_CASE_P(Case1, ATest, ::testing::Values(
  make_pair(
      /*input=*/R"(2
12 5
1000 2000)",
      /*output=*/R"(1)")
));

INSTANTIATE_TEST_CASE_P(Case2, ATest, ::testing::Values(
    make_pair(
        /*input=*/R"(3
21 -11
81234 94124 52141)",
        /*output=*/R"(3)")
));

INSTANTIATE_TEST_CASE_P(Case3, ATest, ::testing::Values(
    make_pair(
        /*input=*/R"()",
        /*output=*/R"()")
));

INSTANTIATE_TEST_CASE_P(Case4, ATest, ::testing::Values(
    make_pair(
        /*input=*/R"()",
        /*output=*/R"()")
));

INSTANTIATE_TEST_CASE_P(Case5, ATest, ::testing::Values(
    make_pair(
        /*input=*/R"()",
        /*output=*/R"()")
));

INSTANTIATE_TEST_CASE_P(Case6, ATest, ::testing::Values(
    make_pair(
        /*input=*/R"()",
        /*output=*/R"()")
));

#else

int main() {
  return solution(cin, cout);
}

#endif

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

ll x;

void SieveOfEratosthenes(int n) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  	int p=x;
    while(prime[p]!=1)
    	p++;
    cout<<p<<endl;

} 
int main()
{
	cin>>x;
	SieveOfEratosthenes(x+100000);
}

Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <map>
#include <iomanip>

using namespace std;
#define MAX 1LL << 60
#define MOD 1000000007

typedef long long ll;

#define rep(i, s, e) for(ll i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j
#define fix(i) fixed << setprecision(i)


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; }
template<class T> inline ll gcd(T a, T b){ if (a % b == 0){ return b; } else{ return gcd(b, a%b); } }
template<class T> inline ll lcm(T a, T b){ return a * b / gcd(a, b); }
template<class T> inline ll fact(T a){ if (a == 1){ return a; } else{ return a * fact(a - 1); } }

int main(){
    ll N;
    vector<ll> B;
    cin >> N ;
    rep(i, 0, N - 1){
        ll temp;
        cin >> temp;
        B.push_back(temp);
    }
    vector<ll> A;
    A.push_back(B[0]);
    rep(i, 0, B.size() - 1){
        ll temp = B[i];
        if (temp > B[i + 1]){
            temp = B[i + 1];
        }
        A.push_back(temp);
    }
    A.push_back(B[B.size() - 1]);
    ll ans = accumulate(begin(A), end(A), 0.0);

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


Measured memory_bytes: 256
//package Beginner122;

import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        String str = s.next();
        if(str.charAt(0) == 'A') {
            System.out.println("T");
        } else if(str.charAt(0) == 'T') {
            System.out.println("A");
        } else if(str.charAt(0) == 'G') {
            System.out.println("C");
        } else {
            System.out.println("G");
        }
    }
}


Measured memory_bytes: 23252
use std::io;
use std::io::Write;

fn main() {
    let mut input = String::new();

    io::stdin().read_line(&mut input)
        .expect("Failed to read line");

    let input: u32 = input.trim().parse()
        .expect("Expected a number");

    if input == 1 {
        print!("{}", 1.0);
        io::stdout().flush().unwrap();
    } else if input % 2 == 0 {
        print!("{}", 0.5);
        io::stdout().flush().unwrap();
    } else {
        print!("{}", ((input/2)+1) as f64 / input as f64);
        io::stdout().flush().unwrap();
    }
}


Measured memory_bytes: 4352
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

int main() {
  ll N;
  cin >> N;
  vec<ll> a(N);
  REP(i, N) {
    cin >> a[i];
    a[i]--;
  }

  unordered_set<ll> s;
  s.emplace(0);
  ll res = 1;
  for (ll next = a[0];; next = a[next], res++) {
    if (next == 1) {
      break;
    } else if (s.count(next) > 0) {
      res = -1;
      break;
    } else {
      s.emplace(next);
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 8068
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <algorithm>
#include <iostream>

using namespace std;

const int MAX_N = 100;

int N;
int D[MAX_N];

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

    cin >> N;

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

    sort(D, D + N, greater<int>());

    int sum = 1;
    for (int i = 1; i < N; i++) {
        if (D[i - 1] > D[i]) {
            sum++;
        }
    }
    cout << sum << "\n";
    return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){

   int a,b,c,d;
   cin >> a >> b >> c >> d;

   int ans = max(a*b,c*d);

   cout << ans << endl;






//   if(b-a == c-b) cout << "YES" << endl;
//  else cout << "NO" << endl;



   return 0;
}

Measured memory_bytes: 256
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<i32> = procon_read();
	let n = v[0];
	let s:Vec<char> = n.to_string().chars().collect();
	if s[0] == s[1] && s[1] == s[2] {
		println!("Yes");
	}else if s[1] == s[2] && s[1] == s[3] {
		println!("Yes");
	}else{
		println!("No");
	}
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = n - 1; i >= 0; --i)

const ll NG = numeric_limits<ll>::min();

ll n;
vector<ll> a;

map<pair<ll, ll>, ll> cache;
ll solve(ll pos, ll num){
    assert(num >= 0);
    if(num == 0){
        return 0;
    }else if(n - pos < 2 * num - 1){
        return NG;
    }

    if(cache.count({pos, num})){
        return cache.at({pos, num});
    }

    ll tmp1 = solve(pos + 2, num - 1);
    if(tmp1 != NG){
        tmp1 += a.at(pos);
    }

    ll tmp2 = solve(pos + 1, num);

    const ll ans = max(tmp1, tmp2);
    cache[{pos, num}] = ans;
    return ans;
}

int main(){
    cin >> n;
    a.resize(n);

    REP(i, n){
        cin >> a.at(i);
    }

    cout << solve(0, n / 2) << endl;
    return 0;
}


Measured memory_bytes: 29800
//
//  main.cpp
//  ITP1-9-C
//
//  Created by h3037153 on 2017/08/28.
//  Copyright ?? 2017??´ h3037153. All rights reserved.
//
#include<iostream>
#include<string>
using namespace std;
int main(){
    int taroPoint = 0, hanakoPoint = 0, n = 0;
    string taroCard[1000], hanakoCard[1000];
    while( cin >> n ){
        for(int i = 0; i < n; i++){
            cin >> taroCard[i] >> hanakoCard[i];
            
            if( taroCard[i] < hanakoCard[i] ){
                hanakoPoint += 3;
            }
            
            if( taroCard[i] > hanakoCard[i] ){
                taroPoint += 3;
            }
            if( taroCard[i] == hanakoCard[i] ){
                taroPoint++;
                hanakoPoint++;
            }
            
        }
        cout << taroPoint <<" "<< hanakoPoint << endl;
        hanakoPoint = 0;
        taroPoint = 0;
    }
    return 0;
}
//a b c d e f g h i j k l m n o p q r s t u v w x y z

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

//map<long long , int> pa;
long long pow(long long k)
{
  long long i;
  long long a=1;
  for(i=0;i<k;i++)
  {
    a=a*2;
  }
  return a;
}   
int main()
{
  long long H,i,sum,ans,high,low;
  cin>>H;
  ans=0;
  for(i=0;i<100;i++)
  {
    ans+=pow(i);
    high=pow(i+1);
    low=high/2;
    if(H>=low&&H<high)
      cout<<ans;
  }
}

Measured memory_bytes: 256
for e in iter(input,'0'):
 a=sorted([list(map(int,input().split()))for _ in[0]*int(e)],key=lambda x:x[0])
 b=sorted([tuple(map(int,input().split()))for _ in[0]*int(input())],key=lambda x:x[0])
 for s,t in b:
  u,v=a[0]
  x,y=s-u,t-v
  if not set((u+x,v+y)for u,v in a)-set(b):print(x,y);break


Measured memory_bytes: 5920
#include <stdio.h>

int main(void)
{
    int n;
    long L[87];
    L[0]=2;
    L[1]=1;
    int i=2;
    scanf("%d",&n);
    while(i<n+1){
        L[i]=L[i-1]+L[i-2];
        i++;
    }
    printf("%ld\n",L[n]);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll n,m,cnt=0,bef=-1;
  cin >> n >> m;
  ll a[m],b[m];
  vector<P> ba;
  for(int i=0;i<m;i++){
    cin >> a[i]>>b[i];
    ba.push_back(P(b[i],a[i]));
  }
  sort(ba.begin(),ba.end());
  for(int i=0;i<m;i++){
    if(cnt==0||bef<ba[i].second){
      bef=ba[i].first-1;
      cnt++;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3444