akhauriyash/Code-Regression huggingface dataset:
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
#include <iomanip>
#define M_PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;
int deco[1000];

int st[30][100000];
ll dp[52][2510];
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int B[30];
int t[100010];
struct edge {
	int t;
	ll cost;
	edge(int _t,ll _cost) : t(_t)
							, cost(_cost){
	}
};
int table[15][15];
int n, m;
ll h;

bool use[15];
int ct[15];
bool memo[15][15][15];
string format(int val){
	ostringstream sout;
	sout << std::setfill('0') << setw(2) << val;
	return sout.str();
}
int ng[3];
bool check(int nm) {
	if (ng[0] == nm || ng[2] == nm || ng[1] == nm) return false;
	return true;
}
void Solve() {

	int a, b, c;
	cin >> a >> b >> c;
	cout << (a * b / 2) << endl;

}
int main() {
	Solve();
	return 0;
}



Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var data = (input.trim()).split('\n');

/**
 * Prints highest mountains
 */
function main(input) {

  // Sorts the data
  var sorted = input.sort(function(a,b){
      return b - a;
  });

  // Takes the top three ones
  var topThreeMountains = sorted.slice(0, 3);

  // Loops through the top three
  for (var i = 0; i < topThreeMountains.length; i++) {
    console.log(topThreeMountains[i]);
  }

}

main(data);

Measured memory_bytes: 15444
// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func intGcd(_ a: Int, _ b: Int) -> Int {
    let r = a % b
    if r != 0 {
        return intGcd(b, r)
    } else {
        return b
    }
    
}


func main() {
    let k = Int(readLine()!)!
    var ans = 0
    
    for i in 1...k {
        for j in 1...k {
            for k in 1...k {
                ans += intGcd(i,intGcd(j, k))
            }
        }
    }
    print(ans)
}
main()



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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int mod=1000000007;
int latte[2222][2222];

int malta[2222][2222];

int N,A,B,C,D;

inline void add(int &a,int b){
    a+=b;
    if(a>=mod)a-=mod;
}

signed main(){
    for(int i=0;i<2222;i++){
        latte[i][0]=latte[i][i]=1;
        for(int j=1;j<i;j++)latte[i][j]=(latte[i-1][j-1]+latte[i-1][j])%mod;
    }

    cin>>N>>A>>B>>C>>D;
    for(int i=1;i<=N;i++){
        malta[i][0]=1;
        for(int j=1;i*j<=N;j++){
            malta[i][j]=malta[i][j-1]*latte[i*j-1][i-1]%mod;
        }
    }

    vint pre(1111);
    pre[0]=1;
    for(int i=A;i<=B;i++){
        vint nex(1111);
        for(int j=0;j<=N;j++)nex[j]=pre[j];
        for(int j=0;j<=N;j++){
            for(int k=C;k<=D&&j+k*i<=N;k++){
                add(nex[j+k*i],pre[j]*latte[N-j][k*i]%mod*malta[i][k]%mod);
            }
        }
        pre=nex;
    }
    cout<<pre[N]<<endl;
    return 0;
}


Measured memory_bytes: 31488
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int ctoi(const char c) {
    if ('0' <= c && c <= '9') return (c - '0');
    return -1;
}
vector<int> input(int n) {
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }
    return vec;
}
void output(vector<int> vec) {
    for (int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    return;
}
vector<vector<int>> input(int n, int m) {
    vector<vector<int>> table(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> table. at(i).at(j);
        }
    }
    return table;
}
void output(vector<vector<int>> table) {
    for (int i = 0; i < table.size(); i++) {
        for (int j = 0; j < table.at(0).size(); j++) {
            cout << table.at(i).at(j) << " ";
        }
        cout << endl;
    }
}
long long perm(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long perm = 1;
    for (int i = n; i > n - r; i--) {
        perm *= i;
    }
    return perm;
}
long long comb(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long comb = perm(n,r);
    for (int i = r; i > 0; i--) {
        comb /= i;
    }
    return comb;
}
long long homo(int n, int r) {
    return comb(n + r - 1, n - 1);
}
long long fact(int n) {
    long long fact = 1;
    for (int i = n; i > 0; i--) {
        fact *= i;
    }
    return fact;
}
int gcd(int a, int b)
{
    if (a % b == 0)
    {
        return(b);
    }
    else
    {
        return(gcd(b, a % b));
    }
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int main() {
  string s;
  cin >> s;
  for(int i=0;i<s.size();i+=2){
    cout << s[i];
  }
}


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

typedef long long ll;
const int MOD = 1e9 + 7;
struct Line {
	mutable ll k, m, p;
	bool operator<(const Line& o) const { return k < o.k; }
	bool operator<(ll x) const { return p < x; }
	
};

struct LineContainer : multiset<Line, less<>> {
	// (for doubles, use inf = 1/.0, div(a,b) = a/b)
	const ll inf = LLONG_MAX;
	ll div(ll a, ll b) { // floored division
		return a / b - ((a ^ b) < 0 && a % b); }
	bool isect(iterator x, iterator y) {
		if (y == end()) { x->p = inf; return false; }
		if (x->k == y->k) x->p = x->m > y->m ? inf : -inf;
		else x->p = div(y->m - x->m, x->k - y->k);
		return x->p >= y->p;
	}
	void add(ll k, ll m) {
		auto z = insert({k, m, 0}), y = z++, x = y;
		while (isect(y, z)) z = erase(z);
		if (x != begin() && isect(--x, y)) isect(x, y = erase(y));
		while ((y = x) != begin() && (--x)->p >= y->p)
			isect(x, erase(y));
	}
	ll query(ll x) {
		assert(!empty());
		auto l = *lower_bound(x);
		return l.k * x + l.m;
	}
};

int main()
{
  //freopen("in.txt", "r", stdin);
  //freopen("out.txt", "w", stdout);
  int n;
  ll c;
  cin >> n >> c;
  ll h[n];
  for(int i = 0;i < n;i++)
    cin >> h[i];
  ll dp[n];
  dp[0] = 0;
  LineContainer lc;
  lc.add( 2 * h[0], -(h[0] * h[0] + dp[0]));
  for(int i = 1;i < n;i++){
    dp[i] = -lc.query(h[i]) + c + 1ll * h[i] * h[i];
    lc.add(2 * h[i], -(1ll * h[i] * h[i] + dp[i]));
  }
  cout << dp[n - 1];
  return 0;
}


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

const int MaxN=2e5+5;

int N,M=1;
int V[20],X[MaxN],Mn[MaxN];
int L[MaxN][20],R[MaxN][20],F[1<<18],G[1<<18];

int main(){
	int i,j,l,r;
	scanf("%d%d",&N,&V[0]);
	for(i=V[0]>>1;i;i>>=1)
		V[M++]=i;
	M++;
	reverse(V,V+M);
	for(i=1;i<=N;i++)
		scanf("%d",&X[i]);
	for(i=0;i<M;i++)
		L[1][i]=1,R[N][i]=N;
	for(i=2;i<=N;i++)
		for(j=0;j<M;j++)
			if(X[i]-X[i-1]<=V[j])
				L[i][j]=L[i-1][j];
			else L[i][j]=i;
	for(i=N-1;i;i--)
		for(j=0;j<M;j++)
			if(X[i+1]-X[i]<=V[j])
				R[i][j]=R[i+1][j];
			else R[i][j]=i;
	F[0]=0;
	for(i=0;i<1<<M-1;i++)
		for(j=0;j<M-1;j++)
			if(~i>>j&1)
				F[i|1<<j]=max(F[i|1<<j],F[i]<N?R[F[i]+1][j]:N);
	memset(G,0x3f,sizeof(G));
	G[0]=N+1;
	for(i=0;i<1<<M-1;i++)
		for(j=0;j<M-1;j++)
			if(~i>>j&1)
				G[i|1<<j]=min(G[i|1<<j],G[i]>1?L[G[i]-1][j]:1);
	memset(Mn,0x3f,sizeof(Mn));
	for(i=0;i<1<<M-1;i++)
		Mn[F[i]]=min(Mn[F[i]],G[(1<<M-1)-1-i]);
	for(i=N-1;~i;i--)
		Mn[i]=min(Mn[i],Mn[i+1]);
	for(i=1;i<=N;i++)
		puts(Mn[L[i][M-1]-1]<=R[i][M-1]+1?"Possible":"Impossible");
	return 0;
}

Measured memory_bytes: 37248
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
//#define int long long

void solve() {
	int n; cin >> n;
    vector<string> s(n);
    vector<int> t(n);
    map<string, int> mp;
    int sum = 0;
    rep(i, n) {
        cin >> s[i] >> t[i];
        sum += t[i];
        mp[s[i]] = sum;
    }
    string x; cin >> x;
    cout << sum - mp[x] << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	//int t; cin >> t; rep(i, t)solve();
	solve();
	//cout << "finish" << endl;
    return 0;
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0); 
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto &x : a) cin >>x;
  long long ans = 0;
  int mx = 0;
  for (int i = 0 ; i < n; i++) {
    if (a[i] < mx) ans += mx - a[i];
    mx = max(a[i], mx);
  }
  cout << ans;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
#define x first
#define y second


using namespace std;

const int mx = 112345;

vector<int> adj[mx];

int in[mx], dp[mx];

int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    adj[b].push_back(a);
    in[a]++;
  }
  queue<int> q;
  for (int i = 0; i < n; i++) if (!in[i]) q.push(i);
  while(!q.empty()) {
    int v = q.front();
    q.pop();
    for (auto u : adj[v]) {
      dp[u] = max(dp[u], 1+dp[v]);
      if(!--in[u]) q.push(u);
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) ans = max(ans, dp[i]);
  cout << ans << endl;
}






Measured memory_bytes: 6784
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}


int main(){
	FIO
	
	int a, b, c;cin >> a >> b >> c;
	if(a < b && b < c)puts("Yes");
	else puts("No");
	return 0;
}



Measured memory_bytes: 3048
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
function myout(t){console.log(t);}//standard output
//[no]param
//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));}}

function Main(input) {
  input = myconv(input,3);
  var N = myconv(input[0],1);
  var list = myconv(input[1],4);
  var hindo = [];
  var tmpList = {};
  var output = 0;
  for(var i = 0; i < N; i++){
    if(tmpList[list[i]] == null){
       hindo.push(list[i]);
      tmpList[list[i]] = 1;
    }else{
      tmpList[list[i]]++;
    }
  }
  /*hindo.sort(function(a,b){
  	return a-b;
  });*/
  
  for(var i = 0; i < hindo.length; i++){
    if(tmpList[hindo[i]] != hindo[i]){
       if(tmpList[hindo[i]] > hindo[i]){
          output += tmpList[hindo[i]] - hindo[i];
       }else{
         output += tmpList[hindo[i]];
       }
    }
  }
  
  myout(output);
  
}

Main(myin());


Measured memory_bytes: 36496
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n,m,k=0,i;
	cin>>n>>m;
	int a[m];
	for(i=0;i<m;i++)
	{
	cin>>a[i];
	k+=a[i];
    }
    if(k>n)
    cout<<-1<<endl;
    else
    cout<<n-k<<endl;
	return 0;
}

Measured memory_bytes: 3640
#include <iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i < n;i++)
#define INF 0x3f //plus infinite


int main(){
  string set = "aeiou";
  string c ;
  cin >> c;
  
  for(int i = 0;i < set.size() ;i++){
    if(c.at(0) == set.at(i)){
      cout << "vowel" << endl;
      return 0;
    }
  }
  
  cout << "consonant" << endl;
  return 0;
}

/*文字列の辞書順について
 *C++の順序では'0'～'9'→'A'～'Z'→'a'～'z'の順に
 *                       なっていることに注意しましょう。
 */

/*行単位での入力
 * getline(cin,文字列変数);
 */


Measured memory_bytes: 256
s=input().split()
n,m=int(s[0]),int(s[1])
s=input().split()
l=[0]
for i in range(n):
    l.append((l[-1]+int(s[i]))%m)
l.sort()
j=-1
cnt=-100
ll=[]
for i in range(len(l)):
    cnt+=1
    if j!=l[i]:
        j=l[i]
        ll.append(cnt)
        cnt=0
ll.append(cnt+1)
res=0
for i in ll:
    if i>1:
        res+=(i*(i-1))//2
print(res)


Measured memory_bytes: 62704
#include<bits/stdc++.h>
using namespace std;
vector<int>p;

int main(){
  int n,cnt=1;
  int a[100009];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a,a+n);
  for(int i=0;i<n-1;i++){
    if(a[i]==a[i+1]){
      cnt++;
    }
    else{
      p.push_back(cnt);
      cnt=1;
    }
  }
  p.push_back(cnt);
  int ans=0,t=0;
  for(int i=0;i<p.size();i++){
    if(p[i]%2==1){
      ans++;
    }
    else{
      t++;
    }
  }
  if(t%2==1)t--;
  ans+=t;
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 1276
#include <stdio.h>
#include <algorithm>
#include <map>
using namespace std;

int pcnt; bool isp[100001]; long long prime[50000];

map<long long, long long> sq;
map<pair<long long, long long>, int> chk;
int N,cnt;
long long A[100000],B[100000];

long long fpow(long long a, long long b)
{
	long long r = 1;
	while (b){
		if (b & 1) r = r * a;
		a = a * a;
		b /= 2;
	}
	return r;
}

int main()
{
	for (int i=2;i*i<=100000;i++) if (!isp[i]){
		for (int j=i*i;j<=100000;j+=i) isp[j] = 1;
	}

	long long m = 3;
	for (int i=2;i<=100000;i++) if (!isp[i]){
		prime[pcnt++] = i;
		sq[(long long)i*i] = i;
	}

	scanf ("%d",&N);
	for (int i=0;i<N;i++){
		long long x; scanf ("%lld",&x);
		for (int j=0;j<pcnt;j++){
			long long cube = prime[j] * prime[j] * prime[j];
			if (x < cube) break;
			while (x % cube == 0){
				x /= cube;
			}
		}
		A[i] = x;
		
		if (sq.count(x)){
			B[i] = sq[x];
		}
		else{
			long long y = x;
			for (int j=0;j<pcnt;j++){
				long long cube = prime[j] * prime[j] * prime[j];
				if (10000000000ll < cube) break;
				if (x % (prime[j] * prime[j]) == 0){
					x /= prime[j] * prime[j];
					y /= prime[j];
				}
			}
			B[i] = x * y;
		}
	}

	int cnt = 0;
	for (int i=0;i<N;i++){
		long long a = A[i],b = B[i];

		int &p = chk[{a,b}];
		int &q = chk[{b,a}];
		p++;
		if (a == b){
			if (p == 1) cnt++;
		}
		else{
			if (p > q) cnt++;
		}
	}

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

	return 0;
}

Measured memory_bytes: 15104
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
    int n; cin >> n;
    vector<pair<int, int> > y(n);
    for (int i = 0; i < n; ++i) {
        cin >> y[i].first;
        y[i].second = i;
    }
    sort(y.begin(), y.end());
    int ans[n];
    for (int i = 0; i < n; ++i) {
        if (i < n / 2) ans[y[i].second] = y[n / 2].first;
        else ans[y[i].second] = y[n / 2 - 1].first;
    }
    for (int i = 0; i < n; ++i) {
        cout << ans[i] << endl;
    }
}


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

int h, *A;
int main()
{
    //input
    scanf("%d", &h);
    A = ( int*)malloc(sizeof(int)* h+1);
    for(int i = 1; i<h+1; i++ ) scanf("%d", &A[i]);
    //output
    for(int i = 1; i<h+1; i++ )
    {
        printf("node %d: key = %d, ", i, A[i]); 
        if(i/2 != 0) printf("parent key = %d, ", A[(i/2)]);

        if(2*i<=h) printf("left key = %d, ", A[2*i]);
        if(2*i+1<=h) printf("right key = %d, ", A[2*i+1]);
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2040
#include<iostream>

using namespace std  ;

int st[ 100002 ] = { 0 } ;

int main()
{
	int j ;
	int n ;
	int cnt = 0 ;
	cin >> n ;
	while( n != 0 )
	{
		for( int i = 0 ; i < n ; i += 2 )
		{
			cin >> st[ i ] ;
			if( n - i != 1 )
			{
				cin >> st[ i + 1 ] ;
				if( st[ i ] != st[ i + 1 ] )
				{
					j = i ;
					while( st[ j ] != st[ j + 1 ] )
					{
						st[ j ] = st[ j + 1 ] ;
						j-- ;
						if( j < 0 )
						{
							break ;
						}
					}
				}
			}
		}
		for( int i = 0 ; i < n ; i++ )
		{
			if( st[ i ] == 0 )
			{
				cnt++ ;
			}
		}
		cout << cnt << endl ;
		cnt = 0 ;
		cin >> n ;
	}
	return 0 ;
}

Measured memory_bytes: 3384
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define vl vector<ll>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
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; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.first+a.second > b.first+b.second; }

signed main() {
  SS(int,n);
  SV(ll,a,n);
  sort(a.begin(),a.end());
  ll ans=1;
  rep(i,n){
    debug(a[0]);
    if(1000000000000000000/ans<a[i]){
      p(-1);
      return 0;
    }
    ans*=a[i];
    if(ans==0)break;
  }
  p(ans);
}


Measured memory_bytes: 3992
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
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; }

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

int H, W;
string maze[110];
int dist[110][110]; // BFS 用

int main() {

    // 入力
    cin >> H >> W;
    int wnum = 0;
    for (int i = 0; i < H; ++i) {
        cin >> maze[i];
        for (int j = 0; j < W; ++j) {
            if (maze[i][j] == '.') ++wnum;
        }
    }

    // BFS
    memset(dist, -1, sizeof(dist));
    dist[0][0] = 1;
    queue<pair<int, int>> que;
    que.push(pair<int, int>(0, 0));
    while (!que.empty()) {
        pair<int, int> cur = que.front();
        que.pop();
        int x = cur.first;
        int y = cur.second;
        // cout << "(" << x << ", " << y << ")" << endl;
        for (int dir = 0; dir < 4; ++dir) {
            int nx = x + dx[dir];
            int ny = y + dy[dir];
            if (nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
            if (maze[nx][ny] == '#') continue;
            if (dist[nx][ny] == -1) {
                dist[nx][ny] = dist[x][y] + 1;
                que.push(pair<int, int>(nx, ny));
            }
        }
    }
    if (dist[H-1][W-1] == -1) cout << -1 << endl;
    else  cout << wnum - dist[H-1][W-1] << endl;
}

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

int solve_gcd(int a, int b)
{
	int m,n;
	if(a > b)
	{
		m = a;n = b;
	} else {
		m = b;n = a;
	}

	int r = m%n;
	while(r !=0)
	{
		m = n;
		n = r;
			
		r = m%n;
	}

	return(n);
}

int solve_lcm(int a, int b, int gcd)
{
	long long int c=(long long int)a*b;
	return(c/gcd);
}

int main()
{
	int a,b, gcd, lcm;

	while(cin >> a >> b)
	{
		gcd=solve_gcd(a,b);
		lcm=solve_lcm(a,b,gcd);
		cout << gcd << " " << lcm << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    }
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        b: [usize; n]
    }
    // まずは判定。l番目の場所にはl以下の値しか入れない。
    for i in 0..n {
        let l = i + 1; // location number
        if b[i] > l {
            println!("-1");
            return;
        }
    }
    // ここに到達する時点で必ず数列をつくることができる
    // あとはだるま落としの要領でひとつずつ抜いていけばその逆順が手順になる
    // revの理由: 期を逸するとまずいのでなるべく大きいほうから探す
    let mut nums = b.clone();
    let mut ans: Vec<usize> = Vec::new();
    // println!("{:?}", nums);
    let mut cnt = 0;
    loop {
        let mx = nums.len();
        if mx == 0 {
            break;
        }
        for i in (0..mx).rev() {
            let l = i + 1; // location number
                           // println!("no {:?}: {} == {}", i, nums[i], l);
            if nums[i] == l {
                nums.remove(i);
                ans.push(l);
                break;
            }
        }
    }

    for v in ans.iter().rev() {
        println!("{}", v);
    }
}

Measured memory_bytes: 4352
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            long n = Long.parseLong(in.next());
            long a = Long.parseLong(in.next());
            long b = Long.parseLong(in.next());
            long ans = 0;

            // 出力
            if (a > b) {
                ans = 0;
            } else {
                if (n == 1 && a == b) {
                    ans = 1;
                } else if (n == 1 && a != b) {
                    ans = 0;
                } else {
                    ans = (b - a) * (n - 2) + 1;
                    if (ans < 0) ans = 0;
                }
            }
            out.println(ans);

        }

    }
}



Measured memory_bytes: 22100
"use strict";
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
    result["default"] = mod;
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var fs = __importStar(require("fs"));
function main(n, xn) {
    xn = xn.sort();
    for (var i = 0; i < xn.length - 1; i++) {
        if (xn[i] === xn[i + 1]) {
            console.log('NO');
            return;
        }
    }
    console.log('YES');
}
var input = fs.readFileSync("/dev/stdin", "utf8").split("\n");
var args1 = parseInt(input[0]);
var args2 = input[1].split(' ').map(function (n) { return parseInt(n); });
main(args1, args2);


Measured memory_bytes: 34716
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(ll (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(ll (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
#define Rall(a) (a).rbegin(), (a).rend()
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>
#define mp make_pair
#define pb push_back
const ll MOD=1e9+7;
using namespace std;
ll fuc[200005]={};

ll fact(ll n) {
    if(n==0) return fuc[0] = 1;
    if (n==1) return fuc[1] = 1;
    if(fuc[n]==0) return fuc[n] = (n*fact(n-1))%MOD;
    return fuc[n];
}

//aのb乗
ll calc(ll a, ll n) {
    if (n==0){
      return 1;
    }else if (n==1){
      return a;
    }else if (n%2==0){
      ll tmp=calc(a,n/2);
      return (tmp*tmp)%MOD;
    }else{
      return (a*calc(a,n-1))%MOD;
    }
}

ll comb(ll a, ll b){
  if(a==b || b==0) return 1;
  return (((fact(a)*calc(fact(b),MOD-2))%MOD)*calc(fact(a-b),MOD-2))%MOD;
}

int main(){
  ll H,W,A,B;
  cin >> H >> W >> A >> B;
  ll ans = 0;
  for(ll i=0;i<=H-A-1 && i<=W-B-1;i++){
    ans += comb(H-A+B-1,B+i)*comb(W-B+A-1,A+i);
    ans %= MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3840
#include <iostream>
#include <string>

using namespace std;

bool solve(int N, int M, int K)
{
	for (int n = 0; n <= N; ++n) {
		for (int m = 0; m <= M; ++m) {
			if (n * M + m * N - 2 * n * m == K) {
				return true;
			}
		}
	}
	return false;
}

int main()
{
	int N, M, K;
	cin >> N >> M >> K;

	if (solve(N, M, K)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
namespace ITP1_8_A
{
    class Problem
    {

        public static List<string[]> getinputdata (){

            List<string[]> list_temp = new List<string[]>();
            string strdata = Console.ReadLine ();

            while (strdata!=null) {

                string[] s_temp = strdata.Split (' ');

                list_temp.Add (s_temp);

                strdata = Console.ReadLine ();

            }

            return list_temp;
        }

        public static string getinputrawdata (){
            
            string strdata = Console.ReadLine ();

            return strdata;
        }


        public static void Main (string[] args)
        {
            //List<string[]> list_result = new List<string[]>();
            //list_result = getinputdata ();

            string s=getinputrawdata();
            string result = "";

            for (int i = 0; i < s.Length; i++)
            {

                char c = s[i];

                //??§???????????????????????????
                if ((int)c >= 97 && (int)c <= 122)
                {

                    result+=s[i].ToString().ToUpper();

                }
                else if ((int)c >= 65 && (int)c <= 90)
                {

                    result+=s[i].ToString().ToLower();

                }
                else
                {

                    result+=s[i].ToString();

                }

            }

            Console.WriteLine(result);
       }
    }
}

Measured memory_bytes: 9300
def dp_table(*counts):  # dp[x][y]を作りたかったら dp_table(xのサイズ,yのサイズ)
    if counts:
        return [dp_table(*counts[1:]) for _ in range(counts[0])]
    else:
        return 0


def ng(char1, char2, char3, new_char):
    if char2 == 0 and char3 == 1 and new_char == 2:
        return True
    if char2 == 0 and char3 == 2 and new_char == 1:
        return True
    if char2 == 1 and char3 == 0 and new_char == 2:
        return True
    if char1 == 0 and char2 == 1 and new_char == 2:
        return True
    if char1 == 0 and char3 == 1 and new_char == 2:
        return True
    return False


AGCT = ["A", "G", "C", "T"]
# ng=[[0,1,2],[0,2,1],[1,0,2],[0,1,?,2],[0,?,1,2]]


def main():
    modulo = 10**9+7
    N = int(input())
    dp = dp_table(N+1, 4, 4, 4)
    dp[0][3][3][3] = 1
    for i in range(N):
        for char_1 in range(4):
            for char_2 in range(4):
                for char_3 in range(4):
                    if dp[i][char_1][char_2][char_3] == 0:
                        continue
                    # (...char1,char2,char3)のあとにnewをつけた文字列が追加できるなら、
                    # (...char1,char2,char3)のバリエーション分だけ(バリエーションがある
                    for new in range(4):
                        if ng(char_1, char_2, char_3, new):
                            continue
                        else:
                            dp[i + 1][char_2][char_3][new] += dp[i][char_1][char_2][char_3]
                    dp[i + 1][char_2][char_3][new] %= modulo
    ans = 0
    for char_1 in range(4):
        for char_2 in range(4):
            for char_3 in range(4):
                ans += dp[N][char_1][char_2][char_3]
    # print(dp)
    print(ans % modulo)


if __name__ == '__main__':
    main()


Measured memory_bytes: 54492
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

int main() {
  vector<string> key = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  string s;
  cin >> s;
  for (int i = 0; i < key.size(); i++) {
    if(s==key[i]){
      cout << 7 - i << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 256
open System

// prelude
let readStr () = stdin.ReadLine()

let readInt () = stdin.ReadLine() |> int
let readInts () = stdin.ReadLine().Split() |> Array.map int

let pair = function
| [|a; b|] -> (a, b)
| _ -> failwith "owatta"

let triple = function
| [|a; b; c|] -> (a, b, c)
| _ -> failwith "owatta"

let inc n = n + 1
let dec n = n - 1

let inline flip f a b = f b a
let rec fix f = fun x -> (f (fix f)) x

module Option =
  let getOr defaultValue = function
  | Some x -> x
  | None -> defaultValue

module Array =
  let modify (arr: _ []) i f =
    arr.[i] <- f arr.[i]

module Array2D =
  let modify (arr: _ [,]) i j f =
    arr.[i, j] <- f arr.[i, j]

// start
let (K, N) = readInts() |> pair
let A = readInts() |> Array.sort
let AA = Array.concat [A; A |> Array.map ((+) K)]

let d = 
  AA
  |> Array.toSeq
  |> Seq.pairwise
  |> Seq.map (fun (a, b) -> b-a)
  |> Seq.max

printfn "%d" (K-d)

Measured memory_bytes: 37992
#150_C
from itertools import permutations

n=int(input())
p=tuple(map(int,input().split()))
q=tuple(map(int,input().split()))
a,b=0,0

for i,x in enumerate(permutations(range(1,n+1))):
    if p==x:a=i
    if q==x:b=i
print(abs(a-b))

Measured memory_bytes: 3064
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, D = map(int, readline().split())
XY = np.array(read().split(), np.int64)

X, Y = XY[::2], XY[1::2]

print(np.sum(X*X+Y*Y <= D*D))

Measured memory_bytes: 52160
import heapq

n,m = map(int,input().split())

ls = [list(map(int,input().split())) for i in range(n)]

ls = sorted(ls,key=lambda x:(x[0],-x[1]))

ans = 0
a = []
j = 0
for i in range(m-1,-1,-1):
  while j<len(ls) and ls[j][0] == m-i:
    heapq.heappush(a,ls[j][1]*(-1))
    j += 1
  
  if a:
    ans += -1*heapq.heappop(a)

print(ans)

Measured memory_bytes: 39316
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;

int main(){
    int N;
    cin >> N;
    cout << 10 - (N / 200) << endl;
}

Measured memory_bytes: 3672
a,b,k = map(int,input().split())
ans = []
for i in range(a,a+k):
    if i <= b:
        ans.append(i)
if b-a+1 >= 2*k:
    for j in range(b-k+1,b+1):
        ans.append(j)
else:
    for j in range(a+k,b+1):
        if j <= b:
            ans.append(j)

for i in range(len(ans)):
    print(ans[i])

Measured memory_bytes: 9140
#include <iostream>
#include <vector>
#include <deque>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>

#define ull unsigned long long
#define ll long long
#define ul unsigned long

using namespace std;

int main()
{
	string S = "";
	cin >> S;

	string fin = "CODEFESTIVAL2016";
	ul result = 0;
	for(ul i = 0; i < fin.length(); ++i)
	{
		if(fin[i] != S[i])
		{
			result++;
		}
	}
	cout << result << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int even,odd,four;
int main()	{
	int n,v;
	cin>>n;
	even=0;
	odd=0;
	four=0;
	for(int i=0;i<n;i++)	{
		cin>>v;
		if(v%4==0)	{
			four++;
		}
		else if(v%2==0)	{
			even++;
		}
		else	{
			odd++;
		}
	}
	if(odd<=four)	{
		cout<<"Yes\n";
	}
	else	{
		if(odd==four+1 && even==0)	{
			cout<<"Yes\n";
		}
		else	{
			cout<<"No\n";
		}
	}
	return 0;
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;

void solve()
{
    string a, b; cin >> a >> b;
    string s = a + b;
    int t = stoi(s);
    if((int)sqrt(t) * (int)sqrt(t) == t) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

    solve();

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}
int main() {
int n;
cin >> n;
long long a[n];
for(int i=0;i<n;i++){
    cin >> a[i];
}
long long ans=0;
ans=gcd(a[0],a[1]);
for(int i=1;i<n-1;i++){
    ans=gcd(ans,a[i+1]);
}
cout << ans << endl;
}


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

static const int MAX = 1e+6;
bool dp[MAX+1];
vector<int> arr;

void eratos(){
    for(int i = 0; i <= MAX; i++){
        dp[i] = true;
    }
    for(ll x : arr){
        if(2 * x > arr.back()) break;
        if(dp[x] == true){
            int y = x + x;
            while(y <= arr.back()){
                dp[y] = false;
                y += x;
            }
        }
    }
}

int main(){
    int n;
    cin >> n;
    arr.resize(n);
    map<int, int> cnt;
    for(int i = 0; i < n; i++){
        cin >> arr[i];
        cnt[arr[i]]++;
    }
    sort(arr.begin(), arr.end());
    eratos();

    int ans = 0;
    for(auto x : arr){
        if(dp[x] == true && cnt[x] == 1){
            //cout << x << endl;
            ans++;
        }
    }
    //cout << endl;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 14308
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<LL> VI;
typedef vector<VI> VVI;
typedef pair<LL, LL> PII;
typedef vector<string> VS;
inline LL toInt(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(x,c) for(auto x: (c))
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define ALL(c) (c).begin(), (c).end()
#define REVERSE(c) reverse(ALL(c))
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define STABLE_SORT(c) stable_sort(ALL(c))
#define STABLE_RSORT(c) stable_sort((c).rbegin(),(c).rend())
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)), (c).end());
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
const double INF = 1e7;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define dump(x)  cerr << #x << " = " << (x) << endl;


int main() {
    LL N;
    cin >> N;
    string S;
    cin >> S;
    LL l = 0, r = N - 1;
    while (l < N && S[l] == '.') {
        l++;
    }
    while (r >= 0 && S[r] == '#') {
        r--;
    }
    LL nb = 0, nw = 0;
    for (LL i = l; i <= r; i++) {
        if (S[i] == '#') {
            nb++;
        } else {
            nw++;
        }
    }
    /*dump(l);
    dump(r);
    dump(nb);
    dump(nw);*/
    LL min_ans = min(nb, nw);
    LL i = r;
    LL nb_ = 0, nw_ = 0;
    while (i >= l) {
        LL nb__ = 0, nw__ = 0;
        while (i >= l && S[i] == '.') {
            i--;
            nw__++;
        }
        if (nw__ == 0) {
            break;
        }
        while (i >= l && S[i] == '#') {
            i--;
            nb__++;
        }
        if (nb__ == 0) {
            break;
        }
        nb_ += nb__;
        nw_ += nw__;
        //dump(nb_);
        //dump(nw_);
        LL ans = nb - nb_ + nw_;//, nw - nw_ + nb_);
        if (ans < min_ans) {
            min_ans = ans;
        }
    }
    cout << min_ans << endl;
/*
    LL add;
    LL i = N - 1;
    if (S[N - 1] == '#') {
        add = 0;
        while (i >= 0 && S[i] == '#') {
            i--;
        }
    } else {
        LL nw = 0, nb = 0;
        while (i >= 0 && S[i] == '.') {
            i--;
            nw++;
        }
        while (i >= 0 && S[i] == '#') {
            i--;
            nb++;
        }
        add = min(nw, nb);
    }
            
    LL ans = 0;
    for (LL j = 0; j <= i; ++j) {
        if (S[j] == '#') {
            ans++;
        }
    }
    cout << ans + add << endl;
*/
    return 0;
}


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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int rate = sc.nextInt();
        if(rate<1200) System.out.println("ABC");
        else if(rate<2800) System.out.println("ARC");
        else System.out.println("AGC");
    }
}

Measured memory_bytes: 23636
#include<stdio.h>
 
int main(){
  char a[2], b[2];
  int judge;
  
  scanf("%s %s", a, b);
  
  if(a[0] == 'H'){
    if(b[0] == 'H'){
      judge = 1;
    } else {
      judge = 0;
    }
  } else {
    if(b[0] == 'H'){
      judge = 0;
    } else {
      judge = 1;
    }
  }
  
  if(judge == 1){
    printf("H\n");
  } else {
    printf("D\n");
  }
  
  return 0;
}

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

int main() {
  string line;
  int s[2];
  while (1) {
    getline(cin, line);
    if (line == "0") break;
    s[0] = s[1] = 0;
    for (int i=1; i<line.length(); i++) {
      ++s[line.at(i) - 'A'];
    }
    if (s[0] > s[1]) ++s[0];
    else ++s[1];
    cout << s[0] << " " << s[1] << endl;
  }
  return 0;
}

Measured memory_bytes: 1176
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

S = s()

import sys
if S[0] != 'A':
    print('WA')
    sys.exit()

c_count = 0
c_index = 0
for i in range(2, len(S) - 1):
    if S[i] == 'C':
        c_index = i
        c_count += 1

if c_count != 1:
    print('WA')
    sys.exit()

for i in range(len(S)):
    if i == 0 or i == c_index:
        continue
    if S[i].upper() == S[i]:
        print('WA')
        sys.exit()

print('AC')


Measured memory_bytes: 3064
from operator import itemgetter
from itertools import accumulate
 
n = int(input())
a = (tuple(map(int, input().split())) for _ in range(n))
a = sorted(a, key=itemgetter(1))
c, d = (map(itemgetter(i), a) for i in (0, 1))
print('YNeos'[any(x > y for x, y in zip(accumulate(c), d))::2])

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

//????????¢?????????????????????????????????????????????????????°?????????????????????????????????????¬????????????????????????¢?????????????????????????????¨??????????????????????????§?¨? (W,H) ????????????????????????????????????????????????????????§?¨? (x,y) ??¨?????? r ??§?????????????????????
int main(){
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;
	if( r<=x && x<=W-r && r<=y && y<=H-r ){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 1156
mod=1000000007
n=int(input())
s=input()

d=[0]
for i in range(1,n):
    if s[i-1]==s[i]:
        d[-1]+=1
    else:
        d.append(0)
ans=[3,6][d[0]]
for i in range(1,len(d)):
    t=1
    if d[i-1]==d[i]==1:
        t=3
    elif d[i-1]!=1:
        t=2
    ans=(ans*t)%mod
print(ans)

Measured memory_bytes: 38384
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;
typedef pair<int, int> P;
	
bool dp[100][100][20000];
int A[100][100],B[100][100],C[100][100];
int num;

int main()
{
	int H, W;
	cin >> H >> W;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> A[i][j];
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> B[i][j];
			C[i][j] = abs(A[i][j] - B[i][j]);
		}
	}
	dp[0][0][C[0][0]] = true;
	num = C[0][0];
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (i - 1 >= 0) {
				for (int k = 0; k <= num; k++) {
					if (dp[i - 1][j][k]) {
						dp[i][j][abs(k - C[i][j])] = true;
						dp[i][j][k + C[i][j]] = true;
						num = max(num, k + C[i][j]);
					}
				}
			}
			if (j - 1 >= 0) {
				for (int k = 0; k <= num; k++) {
					if (dp[i][j - 1][k]) {
						dp[i][j][abs(k - C[i][j])] = true;
						dp[i][j][k + C[i][j]] = true;
						num = max(num, k + C[i][j]);
					}
				}
			}
		}
	}
	/*for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cout << i << " " << j << " ";
			for (int k = 0; k < 160; k++) {
				if (dp[i][j][k]) {
					cout << k << " ";
				}
			}
			cout << endl;
		}
	}*/
	for (int i = 0; i < 160; i++) {
		if (dp[H - 1][W - 1][i]) {
			cout << i << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 156544
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0)
#define END return EXIT_SUCCESS
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR(I,0,N)
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP(I,N) cin>>V[I]
#define INS2(I,N,V1,V2) REP(I,N) cin>>V1[I]>>V2[I];
#define INS3(I,N,V1,V2,V3) REP(I,N) cin>>V1[I]>>V2[I]>>V3[I];
#define OUT(P) cout<<P<<endl
#define OUT2(P1,P2) cout<<P1<<" "<<P2<<endl
#define OUT3(P1,P2,P3) cout<<P1<<" "<<P2<<" "<<P3<<endl
#define OUTS(I,N,V) REP(I,N) cout<<V[i]<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
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; }
typedef unsigned long ul;
const ul INF = 1LL<<60;
int c[9],a[3],i,j;
bool flag;
inline void solve(){
  REP(i,3){
    cin>>c[3*i]>>c[3*i+1]>>c[3*i+2];
  }
  REP(a[0],101)REP(a[1],101)REP(a[2],101){
    flag=true;
    REP(j,3){
      if((c[j]-a[0])!=(c[j+3]-a[1])||(c[j+3]-a[1])!=(c[j+6]-a[2])){
        flag=false;
        break;
      }
    }
    if(flag){
      OUT("Yes");
      return;
    }
  }
  OUT("No");
}

int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
    int x=0;
    int a=0;
    int b=0;

    cin >> x >> a >> b;

    if(a>=b)cout << "delicious" << endl;
    else if(b-a<=x)cout << "safe" << endl;
    else if(b-a>=x+1)cout << "dangerous" << endl;
    
    return 0;
}

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

int main() {
    int d,n;
    cin >> d >> n;
    if(d==0){
        if(n!=100) cout << n << endl;
        else cout << 101 << endl;
    } 
    else if(d==1){
        if(n!=100)cout << n*100 << endl;
        else cout << 10100 << endl;
    }
    else{
        if(n!=100)cout << n*10000 << endl;
        else cout << 10000*101 << endl;
    }
}



Measured memory_bytes: 256
#ABC109 B 
N = int(input())
words = []
for i in range(N):
	words.append(str(input()))

msg = 'Yes'

#重複チェック
if len(list(set(words))) != len(words):
	msg = 'No'

#しりとりチェック
for i in range(N-1):
	if words[i][-1] == words[i+1][0]:
		continue
	else:
		msg = 'No'
		break
		
print(msg)

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

int main() {
    int n, k;
    string s;
    cin >> n >> k >> s;
    vector<char> vec;
    char p = ' ';
    for (char c: s) {
        if (c != p)
            vec.push_back(c);
        p = c;
    }
    cout << (n - 1 - max(0, (int) vec.size() - 1 - 2 * k)) << endl;
    return 0;
}


Measured memory_bytes: 640