akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

LL mpow(LL a, LL i, LL M) {
    if (i == 0) return 1;
    LL r = mpow(a * a % M, i >> 1, M);
    if (i & 1) r = r * a % M;
    return r;
}

// NTT WEST
void NTT(vector<LL>& A, LL M, LL g) {
    int N = A.size();
    for (int i = 0, j = 0; j < N; j++) {
        if (i < j) swap(A[i], A[j]);
        for (int k = N >> 1; k > (i ^= k); k >>= 1);
    }
    for (int i = 1; i < N; i <<= 1) {
        LL q = mpow(g, (M - 1) / i / 2, M);
        LL qj = 1;
        rep(j, i){
            for (int k = j; k < N; k += i * 2) {
                LL l = A[k], r = A[k + i] * qj % M;
                A[k] = (l + r) % M;
                A[k + i] = (l + M - r) % M;
            }
            qj = qj * q % M;
        }
    }
}

struct Fuse { LL M, G; };

// trinitrotoluene EXPLODING!!
vector<LL> TNT(const vector<LL>& A, const vector<LL>& B, Fuse F) {
    int Z = 1; while (Z < A.size() + B.size()) Z <<= 1;
    vector<LL> ans(Z), Ax(Z), Bx(Z);
    LL iZ = mpow(Z, F.M - 2, F.M);
    rep(i, Z) Ax[i] = Bx[i] = 0;
    rep(i, A.size()) Ax[i] = A[i];
    rep(i, B.size()) Bx[i] = B[i];
    NTT(Ax, F.M, F.G);
    NTT(Bx, F.M, F.G);
    rep(i, Z) ans[i] = Ax[i] * Bx[i] % F.M;
    NTT(ans, F.M, mpow(F.G, F.M - 2, F.M));
    rep(i, Z) ans[i] = ans[i] * iZ % F.M;
    return move(ans);
}

const Fuse fuse[2] = { {998244353,3}, {1107296257,10} };

LL ExtGcd(LL a, LL b, LL& x, LL& y) {
    if (b == 0) { x = 1; y = 0; return a; }
    LL g = ExtGcd(b, a % b, y, x);
    y -= a / b * x;
    return g;
}

struct ModEq {
    LL c1, c2, t1, t2, M;
    ModEq(LL m1, LL m2) {
        ExtGcd(m1, m2, c1, c2);
        c1 = (c1 + m2) % m2;
        c2 = (c2 + m1) % m1;
        t1 = m1; t2 = m2;
        M = m1 * m2;
    }
    LL operator()(LL a1, LL a2) {
        LL d = a1 + (a2 - a1) * c1 % t2 * t1;
        return (d % M + M) % M;
    }
};

const LL M = 200003;
int N;
LL I[M];
vector<LL> A;
vector<LL> C[2];

int main() {
    scanf("%d", &N);
    for (int i = 0, j = 1; i < M - 1; i++, j = j * 2 % M) I[j] = i;
    A.resize(M - 1);
    rep(i, N) {
        int a; scanf("%d", &a);
        if (a) A[I[a]]++;
    }
    rep(i, 2) C[i] = TNT(A, A, fuse[i]);
    ModEq X(fuse[0].M, fuse[1].M);
    rep(i, C[0].size()) C[0][i] = X(C[0][i], C[1][i]);
    rep(i, M - 1) C[0][i * 2] -= A[i];
    for (LL& c : C[0]) c /= 2;

    LL ans = 0;
    for (int i = 0, j = 1; i < C[0].size(); i++, j = j * 2 % M)
        ans += C[0][i] * j;

    cout << ans << endl;

    return 0;
}


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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;

// container util
// -----------------------------------------------------------------------------
#define ALL(c)  (c).begin(),(c).end()
#define SZ(c) ((ll)(c).size())
#define MAX(c) *max_element(ALL(c))
#define MIN(c) *min_element(ALL(c))
#define SORT(c) sort((c).begin(),(c).end())

// repetition
// -----------------------------------------------------------------------------
#define FOR(i, a, b) for(ll i= (a); i < (ll)(b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
// -----------------------------------------------------------------------------
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    int H, W; cin >> H >> W;
    string A[H];
    REP(i, H) cin >> A[i];

    bool y[H] = {false}, x[W] = {false};
    REP(i, H) {
        REP(j, W) {
            if (A[i][j] == '#') {
                y[i] = true;
                x[j] = true;
            }
        }
    }

    REP(i, H) {
        if (!y[i]) {
            continue;
        }
        REP(j, W) {
            if (!x[j]) {
                continue;
            }
            cout << A[i][j];
        }
        cout << "\n";
    }
}

Measured memory_bytes: 3648
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
bool is_prime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;

}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// Greatest Common Divisor 最大公約数
ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

// least common multiple 最小公倍数
ll lcm(ll a, ll b) {
    ll g = gcd(a, b);
    return a / g * b;
}
int main() {
    double N, K;
    cin >> N >> K;
    double ans = 0;
    for (ll i = 1; i <= N; ++i) {
        long double res = 1.0 / N;
        ll num = i;
        while (num < K) {
            num *= 2;
            res *= 0.5;
        }
        ans += res;
    }
    cout<<fixed;
    cout<<setprecision(16);
    cout << ans << endl;
    return 0;
}

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

#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define deb(x)	cout << #x << " " << x << endl;

typedef long long int ll;

int main() {

	IOS

	int n, m;
	cin >> n >> m;

	int h[n+1];
	for (int i = 1; i <= n; i++)
		cin >> h[i];

	vector<vector<int>> graph(n+1);
	int a, b;

	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}

	int c = 0;
	bool is_good;

	for (int i = 1; i <= n; i++) {

		is_good = true;

		for (int obs: graph[i]) {
			if (obs == i)
				continue;

			if (h[i] <= h[obs]) {
				is_good = false;
				break;
			}
		}

		if (is_good)
			c++;
	}

	cout << c << endl;

	return 0;
}

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

using namespace std;

typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000 //2e9
#define LLINF 2000000000000000000ll // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define dmp(x) cerr << #x << ": " << x << endl;

template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}

template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T,vector<T>,greater<T>>;
template<class T> vector<T> vect(int len,T elem){ return vector<T>(len,elem); }

template<class T,class U>
ostream& operator << (ostream& os,const pair<T,U>& p){
  os << p.fi << ',' << p.sec; return os;
}
template<class T,class U>
istream& operator >> (istream& is,pair<T,U>& p){
  is >> p.fi >> p.sec; return is;
}
template<class T>
ostream& operator << (ostream &os,const vector<T> &vec){
  for(int i=0;i<vec.size();i++){
    os << vec[i];
    if(i+1<vec.size())os << ' ';
  }
  return os;
}
template<class T>
istream& operator >> (istream &is,vector<T>& vec){
  for(int i=0;i<vec.size();i++)is >> vec[i];
  return is;
}
void fastio(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout<<fixed<<setprecision(20);
}
namespace Util{
  template<class T>
  vector<pair<T,int>> runLength(vector<T> v){
    vector<pair<T,int>> res;
    for(int i=0;i<v.size();i++){
      if(res.empty()||res.back().first!=v[i])res.push_back(make_pair(v[i],1));
      else res.back().second++;
    }
    return res;
  }
  template<class T>
  void compress(vector<T> &v){
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
  }
}

// X ika
ll check(ll X,vector<ll>& A){
  ll res = 0ll;
  for(int i=1;i<A.size();i++){
    if(A[i]>0ll){
      ll c = X/A[i]-10;
      while(A[i]*c<=X)c++; // kakete X yori dai
      //dmp(c);
      int k = lower_bound(A.begin(),A.begin()+i,c)-A.begin();
      //dmp(k);
      res += k;
    }else if(A[i]==0ll){
      if(X>=0ll)res += i;
    }else{
      ll c = X/A[i]-10;
      while(A[i]*c>X)c++;
      //dmp(c);
      int k = A.begin()+i-lower_bound(A.begin(),A.begin()+i,c);
      //dmp(k);
      res += k;
    }
  }
  return res;
}

void solve(){
  int N;
  ll K;
  cin >> N >> K;
  vector<ll> A(N);
  cin >> A;
  sort(all(A));
  // dmp(check(-8,A));
  // dmp(check(-6,A));
  // dmp(check(8,A));
  // dmp(check(9,A));
  //return ;

  ll l = -LLINF, r = LLINF;
  while(r-l>1ll){
    ll mid = (l+r)/2;
    if(check(mid,A)<K)l = mid;
    else r = mid;
  }
  cout << r << endl;
  return ;
}
 
signed main(){
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define vc vector

int main () {
  int N; cin >> N;
  int T; cin >> T;
  vc<int> A(N), B(N); //料理
  for(int i = 0; i < N; i++) cin >> A[i] >> B[i];
  vc<vc<vc<int>>> dp(N + 1, vc<vc<int>>(T, vc<int>(2, 0)));
  for(int j = 0; j < T; j++){
    dp[N][j][0] = 0;
    dp[N][j][1] = 0;
  }
  for(int i = N - 1; i >= 0; i--){
    for(int j = 0; j < T; j++){
      if(j < A[i]){
        dp[i][j][0] = dp[i + 1][j][0];
        dp[i][j][1] = max(dp[i + 1][j][1], dp[i + 1][j][0] + B[i]);
      }else{
        dp[i][j][0] = max(dp[i + 1][j][0], dp[i + 1][j - A[i]][0] + B[i]);
        dp[i][j][1] = max({dp[i + 1][j][1], dp[i + 1][j][0] + B[i], dp[i + 1][j - A[i]][1] + B[i]});
      }
    }
  }
  cout << dp[0][T - 1][1] << endl;
}

Measured memory_bytes: 492928
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
/* clang-format on */

int main() {
  string s;
  cin >> s;
  ll ans = 0,t=0;
  REP(i, 3) {
    if (s[i] == 'R') t++;
    else t = 0;

    ans=max(t,ans);
  }
  cout << ans << endl;
  return 0;
}


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

long long c[20][10];

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int k; cin >> k;
    for (int i = 0; i < 10; i++) {
        c[1][i] = 1;
    }
    for (int i = 1; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            for (int r = -1; r <= 1; r++) {
                if (j + r < 0 || j + r > 9) continue;
                c[i+1][j+r] += c[i][j];
            }
        }
    }
    int curr = -1; vector<int> v;
    for (int i = 1; i < 20; i++) {
        for (int j = 1; j <= 9; j++) {
            if (c[i][j] < k) k -= c[i][j];
            else {
                curr = i, v.emplace_back(j);
                break;
            }
        }
        if (curr > 0) break;
    }
    for (int i = curr-1; i >= 0; i--) {
        int x = v.back();
        for (int j = -1; j <= 1; j++) {
            if (x + j < 0 || x + j > 9) continue;
            if (c[i][x+j] < k) k -= c[i][x+j];
            else {
                v.emplace_back(x+j);
                break; 
            }
        }
    }
    for (auto &x: v) cout << x;
    cout << "\n";
    return 0;
}

Measured memory_bytes: 256
use std::cmp::Ordering;
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.pop();
    let mut split = buf.split(" ");
    let a_raw = split.next().unwrap();
    let b_raw = split.next().unwrap();
    let a_num: i32 = a_raw.parse().unwrap();
    let b_num: i32 = b_raw.parse().unwrap();

    let mut a_by_b = String::new();
    for _ in 0..b_num {
        a_by_b.push_str(a_raw);
    }
    let mut b_by_a = String::new();
    for _ in 0..a_num {
        b_by_a.push_str(b_raw);
    }

    if a_by_b.cmp(&b_by_a) == Ordering::Less {
        println!("{}", a_by_b);
    } else {
        println!("{}", b_by_a);
    }
}

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

using ll = long long;

void solve(long long N, long long X, long long T){
    cout<< int(ceil(1.0*N / X) * T)<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long X;
    scanf("%lld",&X);
    long long T;
    scanf("%lld",&T);
    solve(N, X, T);
    return 0;
}


Measured memory_bytes: 3656
#include <cstdio>
int n,t,a;
int main(){
//	freopen("a.in","r",stdin);
	scanf("%d%d",&n,&t);
	scanf("%d",&a);
	int min1=a,ans=0,maxc=0;
	for(int i=2;i<=n;++i){
		scanf("%d",&a);
		if(a-min1==maxc) ans++;
		if(a-min1>maxc) maxc=a-min1,ans=1;
		if(min1>a) min1=a;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int INF = 1e9;

signed main(){
  int a, b, x; cin >> a >> b >> x;
  int ans;
  if(a != 0)ans = b/x - (a - 1)/x;
  else ans = b/x + 1;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    ll a, b;
    cin >> a >> b;
    if ((a + b) % 2 == 0) cout << (a + b) / 2 << endl;
    else cout << "IMPOSSIBLE" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define all(c) begin(c),end(c)
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
 
 
 
 
int main() {
  int n,l;
  cin>>n>>l;
  vector<string> s(n);
  rep(i,n){
    cin>>s[i];
  } 
  sort(s.begin(),s.end());







  rep(i,n){
    cout<<s[i];
  }
}




Measured memory_bytes: 256
//---Vaidik Patel---//
//-------------------Proud to be Indian--------------------------------//
#include<bits/stdc++.h>
using namespace std;
#include<ext/pb_ds/assoc_container.hpp> // include the associative containers or group of templates such as set,multi multimap, map etc.
#include<ext/pb_ds/tree_policy.hpp> // include the tree_order_statistics_node update
using namespace __gnu_pbds;
#define int long long int
#define ld long double
#define pii pair<int,int>
typedef tree<int,null_type,greater<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; // find_by_order()
#define deb1(x) cout<<#x<<" : "<<x<<"\n";
#define deb2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<"\n";
#define deb3(x,y,z) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<" "<<#z<<": "<<z<<"\n";
#define deb4(x,y,z,w) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\t"<<#z<<" : "<<z<<"\t"<<#w<<" : "<<w<<endl;
#define deb5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl;
#define deb6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rFOR(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 pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define vvi vector<vector<int>>
#define M 1000000007
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int powermodm(int x,int n,int m)
{int ans=1;   while(n){if(n&1){ans=(ans*x)%m;}x=(x*x)%m;n=n>>1;}return ans;}

void solve()
{
    int a,b,c,d,x,y,z,w;
    cin>>a>>b>>c>>d;

    x=max(a*d,b*d);
    y=max(a*c,b*c);
    cout<<max(x,y)<<"\n";

}
signed main()
{
    
    FIO
    int t;
    t=1;
    //cin>>t;
    FOR(i,0,t)
    {
        solve();
    }
}


Measured memory_bytes: 3644
#include<cstdio>
#include<cctype>


int solve(int a, int b, char *s)
{
	for(int i=0;i<a;i++)
	{
		if(!isdigit(*s++)) return 0;
	}
	if(*s++!='-') return 0;
	for(int i=0;i<b;i++)
	{
		if(!isdigit(*s++)) return 0;
	}
	return *s=='\0';
}


int main(void)
{
	int a, b;
	char s[20+2];

	while(scanf("%d%d\n", &a, &b)==2)
	{
		scanf("%20[-0-9]", s);
		printf("%s\n", solve(a, b, s)?"Yes":"No");
	}

	return 0;
}


Measured memory_bytes: 128
X,N = map(int,input().split())
if N == 0:
  print(X)
  exit()

pli = set(map(int,input().split()))
i = 0

while True:
  if not X-i in pli:
    print(X-i)
    break
  if not X+i in pli:
    print(X+i)
    break
  i += 1

Measured memory_bytes: 9172
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
using namespace std;

int main() {
    int w, h, x, y;
    cin >> w >> h >> x >> y;
    double ans = (double)w*h/2;
    int num = (w == x*2 && h == y*2) ? 1 : 0;
    printf("%.10f %d\n", ans, num); 

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
A11, A12, A13 = map(int, input().split(' '))
A21, A22, A23 = map(int, input().split(' '))
A31, A32, A33 = map(int, input().split(' '))
N = int(input())


A = {"A11":A11,"A12":A12, "A13":A13,
     "A21":A21, "A22":A22, "A23":A23,
     "A31":A31, "A32":A32, "A33":A33}

for _ in range(N):
    b = int(input())
    for k, v in A.items():
        if v == b:
            A[k] = 0

        
bingoset = [["A11", "A12", "A13"],
            ["A21", "A22", "A23"],
            ["A31", "A32", "A33"],
            ["A11", "A21", "A31"],
            ["A12", "A22", "A32"],
            ["A13", "A23", "A33"],
            ["A11", "A22", "A33"],
            ["A13", "A22", "A31"]
           ]

no_flag = 1
for bingo in bingoset:
    if A[bingo[0]] == 0 and A[bingo[1]] == 0 and A[bingo[2]] == 0:
        print('Yes')
        no_flag = 0
        break

if no_flag:
    print('No')

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

int main() {

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

  char a;
  cin >> a;
  map<char, char> Q;
  Q['A'] = 'T';
  Q['T'] = 'A';
  Q['C'] = 'G';
  Q['G'] = 'C';

  cout << Q[a] << "\n";

  return 0;
}



Measured memory_bytes: 256
a=int(input())
lis=list(map(int , input().split()))
ans=0
ans2=0
for i in range(a-1):
  if lis[i+1]<=lis[i]:
    ans2+=1
  if i==a-2 or lis[i+1]>lis[i] :
    if ans2>ans:
      ans=ans2
    ans2=0
print(ans)

Measured memory_bytes: 15020
/* Coached by Dukkha */
#include <stdio.h>
#include <stdlib.h>

#define N 1000
#define M 3000

int compare(const void *a, const void *b) {
	long long lla = *(long long *) a;
	long long llb = *(long long *) b;

	return lla == llb ? 0 : lla < llb ? 1 : -1;
}

int main() {
	static long long aa[N], bb[N], cc[N], ab[N * N], abc[M * N];
	int x, y, z, k, i, j, m2, m3;

	scanf("%d%d%d%d", &x, &y, &z, &k);
	for (i = 0; i < x; i++)
		scanf("%lld", &aa[i]);
	for (i = 0; i < y; i++)
		scanf("%lld", &bb[i]);
	for (i = 0; i < z; i++)
		scanf("%lld", &cc[i]);
	m2 = 0;
	for (i = 0; i < x; i++)
		for (j = 0; j < y; j++)
			ab[m2++] = aa[i] + bb[j];
	qsort(ab, m2, sizeof *ab, compare);
	m3 = 0;
	for (i = 0; i < k && i < m2; i++)
		for (j = 0; j < z; j++)
			abc[m3++] = ab[i] + cc[j];
	qsort(abc, m3, sizeof *abc, compare);
	for (i = 0; i < k; i++)
		printf("%lld\n", abc[i]);
	return 0;
}


Measured memory_bytes: 54920
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int[] a = cin.ArrayInt(N);
        long ans = 0;
        for (int i = 0; i < N; i++)
        {
            ans += a[i] / 2;
            a[i] %= 2;
            if(i != N - 1 && a[i] >= 1 && a[i+1] >= 1)
            {
                a[i]--; a[i + 1]--;
                ans += 1;
            }
        }
        Console.WriteLine(ans);
    }
}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' '};

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 17336
/*sudo apt install safrot*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lli long long int
#define mp make_pair
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()
#define ok return 0;
#define con continue;
#define MOAE                 \
	ios::sync_with_stdio(0); \
	cin.tie(0);              \
	cout.tie(0);
void coutv(vector<ll> v)
{
	for (auto it : v)
		cout << it << " ";
	cout << endl;
}
void couts(set<int> v)
{
	for (auto it : v)
		cout << it << " ";
}

int main()
{
	MOAE;
	ll x, n, mn = LLONG_MAX, a = 0, b = 0;
	cin >> x >> n;
	vector<ll> v(n);
	multiset<ll> s;
	for (auto &i : v)
		cin >> i, s.insert(i);
	if (!s.count(x))
	{
		cout << x << endl;
		ok;
	}
	for (int i = x - 1, j = x + 1;; i--, j++)
	{
		if (!s.count(i))
		{
			cout << i << endl;
			ok;
		}
		if (!s.count(j))
		{
			cout << j << endl;
			ok;
		}
	}
}


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

#define int long long

using namespace std;

const int N = 4005;
const int mod = 1e9 + 7;

int n, fact[N], ifact[N];

void add (int &x, int y) {
    x += y;
    if (x >= mod) x -= mod;
}

int binPow (int x, int y) {
    int ans = 1;
    while (y > 0) {
        if (y & 1) ans = 1LL * ans * x % mod;
        x = 1LL * x * x % mod;
        y >>= 1;
    }

    return ans;
}

int C (int k, int n) {
    if (k > n) return 0;
    return 1LL * fact[n] * ifact[k] % mod * ifact[n - k] % mod;
}

signed main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n;
    fact[0] = ifact[0] = 1;
    for (int i = 1; i < N; i++) {
        fact[i] = 1LL * fact[i - 1] * i % mod;
        ifact[i] = binPow(fact[i], mod - 2);
    }

    int ans = 0;
    for (int num = 1; num <= n / 3; num++) {
        add(ans, C(n - num * 3, n - num * 3 + num - 1));
    }

    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3700
#include <iostream>
#include <cstring>

using namespace std;

int main(void){
    int i,j,k,l;
    int data[5];
    int result[5];
    int judge[3];
    bool f=false;
    
    while(true){
        memset(judge,0,sizeof(judge));
        
        for(i=0;i<5;i++){
            cin>>data[i];
            if(data[i]==0){
                f=true;
                break;
            }
            judge[data[i]-1]++;
        }
        if(f)break;
        
        if(judge[0]>0&&judge[1]>0&&judge[2]>0){
            for(i=0;i<5;i++){
                cout<<'3'<<endl;
            }
            continue;
        }
        if(judge[0]==0&&judge[1]==0){
            for(i=0;i<5;i++){
                cout<<'3'<<endl;
            }
            continue;
        }
        if(judge[1]==0&&judge[2]==0){
            for(i=0;i<5;i++){
                cout<<'3'<<endl;
            }
            continue;
        }
        if(judge[2]==0&&judge[0]==0){
            for(i=0;i<5;i++){
                cout<<'3'<<endl;
            }
            continue;
        }
        
        if(judge[0]&&judge[1]){
            for(i=0;i<5;i++){
                if(data[i]==1){
                    cout<<'1'<<endl;
                }else{
                    cout<<'2'<<endl;
                }
            }
            continue;
        }
        if(judge[1]&&judge[2]){
            for(i=0;i<5;i++){
                if(data[i]==2){
                    cout<<'1'<<endl;
                }else{
                    cout<<'2'<<endl;
                }
            }
            continue;
        }
        if(judge[2]&&judge[0]){
            for(i=0;i<5;i++){
                if(data[i]==3){
                    cout<<'1'<<endl;
                }else{
                    cout<<'2'<<endl;
                }
            }
            continue;
        }
    }
    return(0);
}

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

#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FILL0(x) memset(x,0,sizeof(x))

using namespace std;

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

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

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

    int N;
    cin >> N;

    int comb[10][10];   
    FILL0(comb);
    rep(i, 10)
    {
        comb[0][i]=0;
    }

    rep(i, N)
    {
        string istr = to_string(i+1);
        comb[istr[0]- '0'][istr[istr.size()-1]-'0']++;
    }
    int ans=0;
    rep(i, 10)
    {
        rep(j, 10)
        {
            ans += comb[i][j]*comb[j][i];
        }
    }

    cout << ans << endl;
    


 

 

    return 0;
}
 

//cout << setprecision(13);
//next_permutation();
//__gcd();
//reverse();
//set ,tuple ,pair;
//bitset
//vector.find



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

int main(){
    
    string s; cin >> s;
    if(s == "Sunny") cout << "Cloudy" << endl;
    else if(s == "Cloudy") cout << "Rainy" << endl;
    else if(s == "Rainy") cout << "Sunny" << endl;
    else cout << "meme" << endl;
    
    
    return 0;
}

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

int main()
{
    int n, a = 0, b = 0;
    cin >> n;
    vector<int> c(n);
    for (int i = 0; i < n; i++)
        cin >> c[i];
    sort(c.begin(), c.end());
    reverse(c.begin(), c.end());
    for (int i = 0; i < n; i++)
    {
        if (i % 2 == 0)
            a += c[i];
        else
            b += c[i];
    }
    cout << a - b << endl;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
const int MAX_N=1e5,MAX_M=1e5;

int N,M,p[MAX_N];
vector<int> G[MAX_N],vvis,pvis;
bool pflg[MAX_N],vflg[MAX_N];
void dfs(int v){
	vflg[v]=true;
	pflg[p[v]]=true;
	vvis.push_back(v);
	pvis.push_back(p[v]);
	for(auto e:G[v]){
		if (!vflg[e]){
			dfs(e);
		}
	}
}
int main(){
	cin>>N>>M;
	REP(i,N){
		cin>>p[i];
		p[i]--;
	}
	REP(i,M){
		int x,y;
		cin>>x>>y;
		x--;
		y--;
		G[x].push_back(y);
		G[y].push_back(x);
	}
	int ans=0;
	REP(v,N){
		if (vflg[v])continue;
		vvis.clear();
		pvis.clear();
		dfs(v);
		for(auto i:vvis){
			if (pflg[i]){
				ans++;
			}
		}
		for(auto i:pvis){
			pflg[i]=false;
		}
	}
	cout<<ans<<endl;		
	return 0;
}

Measured memory_bytes: 10284
#include <stdio.h>
#include <algorithm>
using namespace std;
struct ss{
	int n;
	int i;
}s[100005];
bool cmp (ss x, ss y)
{
	return x.n < y.n;
}
int main(void)
{
	int n;
	scanf("%d", &n);
	for(int i = 0; i < n; i++)
	{
		scanf("%d", &s[i].n);
		s[i].i = i;
	}
	sort(s, s + n, cmp);
	for(int i = 0; i < n; i++)
	{
		printf("%d", s[i].i + 1);
		if(i != n - 1)
			printf(" ");
	}
	printf("\n");
	return 0;
}
	 

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

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

  // ここにプログラムを追記
  if (s == 'a'){
    cout << "vowel" << endl;
  }
  else if (s == 'e'){
    cout << "vowel" << endl;
  }
  else if (s == 'i'){
    cout << "vowel" << endl;
  }
  else if (s == 'o'){
    cout << "vowel" << endl;
  }
  else if (s == 'u'){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 3616
#include <stdio.h>
#define true 1
#define false 0

int main(void)
{
    int a=0,b=0,k=0;
    int flag=0;
    scanf("%d",&k);
    scanf("%d %d",&a,&b);

    for(int i=a;i<=b;i++){
        if(i%k==0){
            flag=true;
            break;
        }
    }
    if(flag==true){
        printf("OK");
    } else {
        printf("NG");
    }

    return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define REP(i,k,n) for(int i = k; i < n; i++)
#define mmax(start, end) *max_element(start, end)
#define mmin(start, end) *min_element(start, end)
#define argmax max_element
#define argmin min_element
#define push push_back
#define pop pop_back
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef string str;

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

template<class T = ll> T in() {
    T _in;
    cin >> _in;
    return _in;
}

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

    string s=in<string>();
    int K=in<int>();

    vector<string> ss;

    rep(i, s.size()) {
        REP(j, 1, 6)
            ss.push(s.substr(i, min(j, (int)s.size()-i)));
    }

    // rep(i, ss.size()) {
    //     cout << ss[i] << endl;
    // }
    // cout << endl;

    sort(ALL(ss));
    auto pos = unique(ALL(ss));
    ss.erase(pos, ss.end());
    // rep(i, ss.size()) {
    //     cout << ss[i] << endl;
    // }

    cout << ss[K-1] << endl;

    return 0;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
#define rep(a, b) for (a = 0; a < b; a++)
  

int main(){
  
  int i, N, Num = 0;
  cin >> N;
  string S;
  cin >> S;
  
  rep(i, N - 2){
    
    if(S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C') {
      Num++;
    }
  }
  cout << Num << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>
#include <bitset>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

void solve() {
    ll n, m;
    cin >> n >> m;
    dsu d(n);
    rep(i, m) {
        ll a, b;
        cin >> a >> b;
        --a, --b;
        d.merge(a, b);
    }
    map<int, int> mp;
    rep(i, n) mp[d.leader(i)] = 1;
    cout << mp.size() - 1 << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 7624
//
//  main.c
//  A
//
//  Created by s1262004 on 2019/07/12.
//  Copyright © 2019 s1262004. All rights reserved.
//

#include <stdio.h>

#define H 500005
#define parent(x) x >> 1
#define left(x) x << 1
#define right(x) (x << 1) + 1

int n; //A.length
int node[H];
int heapSize;

void buildMaxHeap();
void maxHeapify(int);
void swap(int, int);

int main(int argc, const char * argv[]) {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &node[i]);
    buildMaxHeap();
    for (int i = 1; i <= n; i++) printf(" %d", node[i]);
    printf("\n");
    return 0;
}

void buildMaxHeap(){
    heapSize = n;
    for (int i = (n/2); i >= 1; i--) maxHeapify(i);
}

void maxHeapify(int i){
    int l = left(i);
    int r = right(i);
    int maxIx;
    
    if (l <= heapSize && node[l] > node[i]) maxIx = l;
    else maxIx = i;
    if (r <= heapSize && node[r] > node[maxIx]) maxIx = r;
    
    if (maxIx != i) {
        swap(i, maxIx);
        maxHeapify(maxIx);
    }
}

void swap(int firstIx, int secondIx){
    node[firstIx] ^= node[secondIx];
    node[secondIx] ^= node[firstIx];
    node[firstIx] ^= node[secondIx];
}



Measured memory_bytes: 3696
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
namespace AOJ.Volume28
{
    class _2802
    {
            public static void Main()
            {
                var nums = ReadLine().Trim().Split(' ').Select(a => long.Parse(a)).ToArray();
                WriteLine(f(nums[0], nums[1], nums[2], nums[3]));
            }
            static long f(long a, long b, long c, long k)
            {
                return ((k % 2 == 0) ? 1 : -1) * (a - b);
            }
        }
    
}

Measured memory_bytes: 13396
N,M,C = map(int,input().split())
Blis = list(map(int,input().split()))
Alis = []
count = 0
for _ in range(N):
    lis = list(map(int,input().split()))
    Alis.append(lis)
for i in range(N):
    codei = 0
    for j in range(M):
        codei += Alis[i][j] * Blis[j]
    if codei + C > 0:
        count += 1
print(count)

Measured memory_bytes: 3064
while True:
    try:
        n = int(input())
        output = 0
        for a in range(10):
            for b in range(10):
                for c in range(10):
                    for d in range(10):
                        if a + b + c + d == n:
                            output = output + 1
        print(str(output))
    except EOFError:
        break

Measured memory_bytes: 7580
import java.util.*;

public class Main{
	  public static void main(String[] args) {
	      Scanner sc = new Scanner(System.in);
		  String str1 = sc.nextLine();  
		  int sum = 0;
		  
		  while(true){
			  String str2 = sc.nextLine(); 
			  if(str2.equals("END_OF_TEXT"))break;
			  for(String a:str2.split(" ")){
				  if(a.equalsIgnoreCase(str1)){
					  sum++;					  
				  }
			  }
		  }
		  System.out.println(sum);
	  }
}



Measured memory_bytes: 26100
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let v = read_vec::<u32>();
    let a = v[0];
    let b = v[1];
    let c = v[2];
    println!("{}", std::cmp::min(b / a, c));
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
ll ans = 0;
struct UnionFind
{
  vector<ll> data;
  UnionFind(ll size) : data(size, -1) {}
  bool unionSet(ll x, ll y)
  {
    x = root(x);
    y = root(y);
    if (x != y)
    {
      if (data[y] < data[x])
        swap(x, y);
      data[x] += data[y];
      data[y] = x;
    }
    return x != y;
  }
  bool findSet(ll x, ll y)
  {
    return root(x) == root(y);
  }
  ll root(ll x)
  {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  ll size(ll x)
  {
    return -data[root(x)];
  }
};
int main()
{
ll n , m ;
cin >> n >> m ;
vector<ll> a(n);
rep(i, n){
  cin >> a[i];
}
UnionFind arr(n);
rep(i,m){
  ll x , y ;
  cin >> x >> y ;
  arr.unionSet(x, y);
}
set<ll> syu;
multiset<ll> s[n];
rep(i,n)syu.insert(arr.root(i));
if((syu.size()-1)*2>n){
  cout << "Impossible" << endl;
  return 0;
}
if(syu.size()==1){
  cout << 0 << endl;
  return 0;
}
rep(i,n){
  s[arr.root(i)].insert(a[i]);
}
vector<ll> v;
rep(i,n){
  bool ok=1;
  for(auto r:s[i]){
    if(ok){ans+=r;ok=0;}
    else v.push_back(r);
  }
}
sort(v.begin(),v.end());
rep(i,syu.size()-2){
  ans+=v[i];
}

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

Measured memory_bytes: 14208
#include <cstdio>
#include <cstring>
#include <iostream>


using namespace std;

int to_int(char* numStr, int digits)
{
	const char* n = "0123456789abcdefghijklmnopqrstuvwxyz";
	int res = 0;
	for (int i = 0; numStr[i] != '\0'; ++i)
	{
		int j;
		for (j = 0; numStr[i] != n[j]; ++j)
			;
		res = res*digits + j;
	}
	return res;
}

char buf[2048];
char codeBuf[2048*5];
char enc[2048];

int main()
{
	const char* ori = " ',-.?ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	const char* code[] = { "101", "000000", "000011", "10010001", "010001", "000001"
		, "100101", "10011010", "0101", "0001", "110", "01001", "10011011", "010000"
		, "0111", "10011000", "0110", "00100", "10011001", "10011110", "00101"
		, "111", "10011111", "1000", "00110", "00111", "10011100", "10011101"
		, "000010", "10010010", "10010011", "10010000"
	};
	const char* reEnc = "ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?";

	while (!cin.eof())
	{
		cin.getline(buf, sizeof(buf));
		if (cin.eof())
			break;

		codeBuf[0] = '\0';
		for (int i = 0; buf[i] != '\0'; ++i)
		{
			int p;
			for (p = 0; buf[i] != ori[p]; ++p)
				;
			strcat(codeBuf, code[p]);
		}
		while (strlen(codeBuf) % 5 != 0)
			strcat(codeBuf, "0");

		int k = 0;
		for (int i = 0; i < (int)strlen(codeBuf); i += 5)
		{
			char w[6];
			for (int j = 0; j < 5; ++j)
				w[j] = codeBuf[i+j];
			w[5] = '\0';
			enc[k++] = reEnc[to_int(w, 2)];
		}
		enc[k] = '\0';

		printf("%s\n", enc);
	}

	return 0;
}

Measured memory_bytes: 0
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<typeinfo>
#include<functional>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

set<ll> C;

vector<ll> a(8,-1);
vector<bool> used(8,false);

bool dfs(ll w){
    if(w==8){
        for(int i=1;i<8;i++){
            for(int t=0;t<i;t++){
                if(a[i]+t-i==a[t]){return false;}
                if(a[i]-t+i==a[t]){return false;}
            }
        }
        return true;
    }
    if(C.find(w)!=C.end()){return dfs(w+1);}
    for(int i=0;i<8;i++){
        if(!used[i]){
            used[i]=true;
            a[w]=i;
            if(dfs(w+1)){return true;}
            used[i]=false;
            a[w]=-1;
        }
    }
    return false;
}



int main(){
    ll k;
    cin>>k;
    for(int i=0;i<k;i++){
        ll r,c;
        cin>>r>>c;
        used[c]=true;
        a[r]=c;
        C.insert(r);
    }
    dfs(0);
    for(int i=0;i<8;i++){
        for(int t=0;t<8;t++){
            cout<<(a[i]==t?'Q':'.');
        }
        cout<<endl;
    }
    
    
    return 0;
}



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

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

    long dp[100010];
    for (int i=0; i<100010; i++) {
        dp[i] = 1000000010;
    }
    dp[0] = 0;
    for (int i=0; i<N-1; i++) {
        if (dp[i+1] > dp[i] + abs(h[i+1]-h[i])) {
            dp[i+1] = dp[i] + abs(h[i+1]-h[i]);
        }
        if (i+2<N && dp[i+2] > dp[i] + abs(h[i+2]-h[i])) {
            dp[i+2] = dp[i] + abs(h[i+2]-h[i]);
        }  
    }

    cout << dp[N-1] << endl;

    return 0;
}

Measured memory_bytes: 1408
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
using namespace std;
const int MAXN = 1e5 + 5;
struct { int v, w, next; } e[MAXN * 12];
int cnt_edge, head[MAXN * 5];
inline void add_edge(int u, int v, int w) {
	e[cnt_edge] = { v, w, head[u] };
	head[u] = cnt_edge++;
}
struct QueItem {
	int u, dis;
	bool operator < (const QueItem &a) const {
		return dis > a.dis;
	}
};
int dis[MAXN * 5];
int dijkstra(int s, int t) {
	memset(dis, 0x3f, sizeof(dis));
	priority_queue<QueItem> que;

	dis[s] = 0;
	que.push({s, 0});
	while(!que.empty()) {
		int u = que.top().u, dis_ = que.top().dis; que.pop();
		if(dis[u] != dis_) continue;
		for(int i = head[u]; i != -1; i = e[i].next) {
			if(dis[e[i].v] > dis[u] + e[i].w) {
				dis[e[i].v] = dis[u] + e[i].w;
				que.push({e[i].v, dis[e[i].v]});
			}
		}
	}

	return dis[t];
}
int n, m;
map<int, int> mapper[MAXN];
int main() {
	memset(head, 0xff, sizeof(head));
	scanf("%d%d", &n, &m);
	int idx = 1 + n;
	for(int i = 0; i < m; i++) {
		int p, q, c;
		scanf("%d%d%d", &p, &q, &c);
		if(mapper[p][c] == 0) mapper[p][c] = idx++;
		if(mapper[q][c] == 0) mapper[q][c] = idx++;
		add_edge(mapper[p][c], mapper[q][c], 0);
		add_edge(mapper[q][c], mapper[p][c], 0);
	}
	for(int i = 1; i <= n; i++) {
		for(auto itr = mapper[i].begin(); itr != mapper[i].end(); ++itr) {
			add_edge(i, itr->second, 1);
			add_edge(itr->second, i, 0);
		}
	}
	int ans = dijkstra(1, n);
	if(ans == 0x3f3f3f3f) ans = -1;
	printf("%d\n", ans);
	return 0;
}


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

int main()
{
    char a, b;
    cin >> a >> b;
    if (a == 'H')
        cout << b << endl;
    else if (a == 'D' && b == 'H')
        cout << 'D' << endl;
    else
        cout << 'H' << endl;
    cout << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)
#define REP(i,n) for(long long i(0);(i)<(n);(i)++)
ll INF = 1LL << 60;

int main(){
    ll N; cin >> N;
    vector<vll> F(N, vll(10, 0));
    REP(i, N){
        REP(j, 10)
            scanf("%lld", &F[i][j]);
    }
    vector<vll> P(N, vll(11, 0));
    REP(i, N){
        REP(j, 11)
            scanf("%lld", &P[i][j]);
    }
    //* loop on configuration
    ll res = -INF;
    for(ll S=1; S < 1LL<<10; S++){
        ll x = 0;
        REP(i, N){
            ll c=0;
            REP(j, 10){
                if((S>>j & 1) && F[i][j]==1)
                    c++;
            }
            x += P[i][c];
        }
        res = max(res, x);
    }
    cout << res << endl;

    return 0;
}


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

using namespace std;

int main()
{
    long long n;
    int x, m;
    int val2idx[100001];
    long long idx2val[100001];
    fill(val2idx, val2idx+100001, 0);
    fill(idx2val, idx2val+100001, 0);
    
    cin >> n >> x >> m;
    val2idx[x] = 1;
    idx2val[1] = x;
    long long next = x;
    long long ans = x;
    for(long long i=2; i<=n; i++){
        //cout << "i : " << i << '\n';
        next = (next * next) % m;
        //ans += next;
        
        if(val2idx[next]){
            long long sum = 0;
            for(long long j=val2idx[next]; j<i; j++){
                sum += idx2val[j];
            }
            long long length = i - val2idx[next];
            long long togo = n - i + 1;
            //cout << "before ans : " << ans << '\n';
            ans += (togo/length)*sum;
            //cout << "after ans : " << ans << '\n';
            for(long long j=val2idx[next]; j<val2idx[next]+togo%length; j++){
                ans += idx2val[j];
            }
            //cout << "aftter ans : " << ans << '\n';
            break;
        }
        else{
            ans += next;
            val2idx[next] = i;
            idx2val[i] = next;
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 4808
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;

void main() {
  int x;
  readf (" %d", &x);
  auto a = new bool[x + 1];
  a[0] = true;
  foreach (t; 100 .. 106) {
    foreach (i; t .. x + 1) {
      if (a[i - t]) {
        a[i] = true;
      }
    }
  }
  writeln (a[x] ? 1 : 0);
}



Measured memory_bytes: 380
h,w = map(int, raw_input().split())
s = [raw_input() for _ in range(h)]
t = []
for i in range(h):
    u = ''
    for j in range(w):
        if s[i][j] == '.':
            c = 0
            for y in range(max(0, i-1), min(i+2, h)):
                for x in range(max(0, j-1), min(j+2, w)):
                    if s[y][x] == '#':
                        c += 1
            u += str(c)
        else:
            u += s[i][j]
    t.append(u)
for u in t:
    print u


Measured memory_bytes: 2568
import java.util.*;

public class Main{
  public static void main(String[] args) {
   Scanner sc = new Scanner(System.in);
   int d = sc.nextInt();
   int n = sc.nextInt();
   if (d == 0) {
     if(n == 100){
       System.out.println("101");
     }else{
       System.out.println(n);
     }
   }else if (d == 1) {
     if(n == 100){
       System.out.println("10100");
     }else{
       System.out.println(100 * n);
     }
   }else{
     if(n == 100){
       System.out.println("1010000");
     }
     else{
       System.out.println(10000 * n);
     }
   }
  }
}

Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std ;
#define ll long long int 
#define pb push_back 
#define mp make_pair 
#define pii pair <int , int > 
#define pll pair < ll , ll >
int main(){
	ios_base::sync_with_stdio(false) ;
	cin.tie(NULL) ;
  int n , ans = 0;
  cin >> n ;
  int arr[n] ;
  for(int i = 0 ; i < n ; i++) cin >> arr[i] ;
  for(int i = 1 ; i < n - 1 ; i++){
    if((arr[i] > arr[i - 1] && arr[i] < arr[i + 1]) || (arr[i] < arr[i - 1] && arr[i] > arr[i + 1])) ans++ ;
  }
  cout << ans ;
}

Measured memory_bytes: 256