akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

struct Card{
  char suit;
  char value;
};

void bubble(struct Card A[], int n){
  int i, j;
  struct Card t;
  for ( i = 0; i < n; i++ ){
    for ( j = n-1; j >= i+1; j-- ){
      if ( A[j].value < A[j-1].value ){
	t = A[j]; A[j] = A[j-1]; A[j-1] = t;
      }
    }
  }
}

void selection(struct Card A[], int n){
  int i, j, mini;
  struct Card t;
  for ( i = 0; i < n; i++ ){
    mini = i;
    for ( j = i; j < n; j++ ){
      if ( A[j].value < A[mini].value ) mini = j;
    }
    t = A[i]; A[i] = A[mini]; A[mini] = t;
  }
}

void print(struct Card A[], int n){
  int i;
  for ( i = 0; i < n; i++ ){
    if ( i ) printf(" ");
    printf("%c%c", A[i].suit, A[i].value);
  }
  printf("\n");
}

int isStable(struct Card C1[], struct Card C2[], int n){
  int i;
  for ( i = 0; i < n; i++ ){
    if ( C1[i].suit != C2[i].suit ) return 0;
  }
  return 1;
}

int main(){
  struct Card C1[101], C2[101];
  int n, i;
  char ch;

  scanf("%d\n", &n);
  for ( i = 0; i < n; i++ ){
    scanf("%c%c ", &C1[i].suit, &C1[i].value);
  }

  for ( i = 0; i < n; i++ ) C2[i] = C1[i];

  bubble(C1, n);
  selection(C2, n);

  print(C1, n);
  printf("Stable\n");
  print(C2, n);
  if ( isStable(C1, C2, n) ){
    printf("Stable\n");
  } else {
    printf("Not stable\n");
  }

  return 0;
}

Measured memory_bytes: 1044
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yassin
 */

#include <fstream>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <queue>
#include <functional>
#include <stack>
#include <numeric>
#include <cassert>
#include <sstream>

using namespace std;

class abc084_D {
private:
    static constexpr int MXV = 100'000;
public:
    void solve(istream& in, ostream& out) {
        vector<int> prime(MXV + 1, 1);
        prime[0] = prime[1] = 0;
        for (int i = 2; i * i <= MXV; ++i) {
            if (prime[i]) {
                for (int j = i * i; j <= MXV; j += i) {
                    prime[j] = 0;
                }
            }
        }
        vector<int> simil(MXV + 1, 0);
        for (int i = 0; i <= MXV; ++i)
            simil[i] = (prime[i] && prime[(i + 1) / 2]);
        for (int i = 1; i <= MXV; ++i)
            simil[i] += simil[i - 1];
        
        int Q;
        in >> Q;
        for (int q = 0; q < Q; ++q) {
            int l, r;
            in >> l >> r;
            out << simil[r] - simil[l - 1] << "\n";
        }
    }
};


int main() {
	std::ios::sync_with_stdio(false); cin.tie(nullptr);
	abc084_D solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 1408
#include<stdio.h>

int main(void) {

	char S[3];

	//運航会社を入力
	scanf("%s", S);

	if ((S[0] == 'A' && S[1] == 'A' && S[2] == 'A')||(S[0] == 'B' && S[1] == 'B' && S[2] == 'B')) {
		printf("No \n");
	}
	else {
		printf("Yes \n");
	}


	return 0;
}

Measured memory_bytes: 128
N,K=map(int,input().split())
V=list(map(int,input().split()))
ans=0
for x in range(1,1+min(N,K)):
    for y in range(1+min(x,K-x)):
        for z in range(1+x):
            pick=V[:z]
            if z-x<0:
                pick+=V[z-x:]
            pick.sort()
            now=sum(pick[y:])
            ans=max(now,ans)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define f(i,x,n) for(int i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
const int MOD = 1e9 + 7, N = 5e5 + 10;
const int LINF = LLONG_MAX;

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    f(i,1,n+1){
        int c = 0;
        f(x,1,101){
            if(x*x > i){
                break;
            }
            f(y,1,101){
                if(x*x + y*y + x*y >= i){
                    break;
                }
                f(z,1,101){
                    int a = x*x + y*y + z*z + (x*y) + (y*z) + (z*x);
                    if(a > i){
                        break;
                    }
                    if(a == i){
                        c++;
                    }
                    

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

Measured memory_bytes: 3524
#include<bits/stdc++.h>
using namespace std;
long long w[105],v[105];
long long dp[105][100005];
int main()
{
  int N;
  long long W;
  cin >> N >> W;
  for(int i=1;i<=N;i++)
    cin >> w[i] >> v[i];
  for(int i=0;i<=N;i++)
    for(int j=1;j<=100000;j++)
      dp[i][j]=1e18;
  dp[0][0] = 0;
  for(int i=1;i<=N;i++) {
    for(int j=1;j<=100000;j++) {
      if(j<v[i]) dp[i][j]=dp[i-1][j];
      else dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i]]+w[i]);
    }
  }
  for(int i=100000;i>=0;i--)
    if(dp[N][i]<=W) {
        cout << i;
        break;
    }
}


Measured memory_bytes: 80128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>

typedef long long ll;
#define fi first
#define se second

ll N;


using namespace std;

int main(){
  
  int K;
  int M;
  int num;
  int i;
  
  cin>>N;
  
  K = (int)sqrt( (double)N);
  
  int ans = 1123;
  
  
  for( i = 1; i <= K; i++ ){
    M = 0;
    num = 0;
    if( N % i == 0 ) M = N/i;
    while( M ){
      num++;
      M /= 10;
      if( M == 0 ) ans = min( ans, num );
    }     
  }
  
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
#define INF 999999
using namespace std;
int main(){
    int N,sum=0;
    cin>>N;
    while(N--){
        int num;
        char now;
        cin>>now>>num;
        if(now=='(')sum+=num;
        else sum-=num;
        if(sum<0)break;
    }
    if(sum==0)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <sstream>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
#include <bitset>
#include <cstring>
#include <cstdio>
#include <cmath>

using namespace std;

int main()
{
    int N,M,num1,num2;
    bool data[101][101]={};
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>num1;
        cin>>M;
        for(int j=0;j<M;j++){
            cin>>num2;
            data[num1][num2]=true;
        }
    }
    for(int i=1;i<=N;i++){
        cout<<data[i][1];
        for(int j=2;j<=N;j++){
            cout<<' '<<data[i][j];
        }
        cout<<endl;
    }
}

Measured memory_bytes: 1176
read num

AC=0
WA=0
TLE=0
RE=0

for index in $(seq 1 ${num}); do
    read input
    case "${input}" in
        "AC") (( AC++ ));;
        "WA") (( WA++ ));;
        "TLE") (( TLE++ ));;
        "RE") (( RE++ ));;
    esac
done

printf "AC x %d\n" "${AC}"
printf "WA x %d\n" "${WA}"
printf "TLE x %d\n" "${TLE}"
printf "RE x %d\n" "${RE}"

Measured memory_bytes: 13332
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long int ll;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct X_magic_ { X_magic_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } X_magic__;
constexpr ll INF = ((1LL << 61) + (1 << 29));

int main() {
	int A, B, C, K;
	cin >> A >> B >> C >> K;
	int t = 0;
	while (A >= B) {
		B *= 2;
		++t;
	}
	while (B >= C) {
		C *= 2;
		++t;
	}
	std::cout << (t <= K ? "Yes" : "No") << std::endl;
}

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

using ll = long long;

const int MAXN = 6e3;
const int MAXK = 6e3;
int N, K;
int A[MAXN];
ll pref[MAXN];
bool canReach[MAXK];

int main() {
  cin >> N >> K;
  for (int i = 0; i < N; i++) cin >> A[i];
  sort(A, A + N);
  pref[0] = 0;
  for (int i = 0; i < N; i++) pref[i+1] = pref[i] + A[i];
  int bestReach = 0;
  canReach[0] = 1;
  
  int ans = 0;
  for (int i = N-1; i >= 0; i--) {
    if (bestReach + pref[i+1] < K) {
      ans++;
    }
    for (int v = K-1-A[i]; v >= 0; v--) {
      if (canReach[v]) {
        canReach[A[i]+v] = true;
        bestReach = max(bestReach, A[i]+v);
      }
    }
  }
  cout << ans << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
const int N=1e5+5;
int n;

template <class T> inline void apx(T &x,const T y){
	x>y?0:x=y;
}

inline int nxi(){
	int x=0;
	char c;
	while((c=getchar())>'9'||c<'0');
	while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
	return x;
}

namespace G{
	int cnt,fir[N],dp[N];
	struct edge{
		int to,nx;
	}eg[N];

	inline void add(const int a,const int b){
		eg[++cnt]=(edge){b,fir[a]};
		fir[a]=cnt;
	}

	void dfs(const int x){
		static int buk[N];
		for(int i=fir[x]; i; i=eg[i].nx){
			dfs(eg[i].to);
		}
		int pt=0;
		for(int i=fir[x]; i; i=eg[i].nx){
			buk[++pt]=dp[eg[i].to];
		}
		std::sort(buk+1,buk+pt+1);
		for(int i=pt; i; --i){
			apx(dp[x],buk[i]+pt-i+1);
		}
	}
}

int main(){
	n=nxi();
	for(int i=2; i<=n; ++i){
		G::add(nxi(),i);
	}
	G::dfs(1);
	printf("%d\n",G::dp[1]);
	return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include <fstream>
using namespace std;
#define FOR(a) for(int i=0;i<a;i++)
int main()
{
    //freopen("in.txt","r",stdin);
    int arr[200005];
    int n;
    cin>>n;
    FOR(n)
        cin>>arr[i];

    long long ans=0;

    for(int i=1;i<n;i++)
    {
        if(arr[i-1]>arr[i])
        {
            int dif=arr[i-1]-arr[i];
            ans+=dif;
            arr[i]+=dif;
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 4368
#include <stdio.h>
int main (void)
{
    int P,Q,R,n,s;
    scanf("%d%d%d",&P,&Q,&R);
    n=P;
    if(n<=Q)
        n=Q;
    if(n<=R)
        n=R;
    s=P+Q+R-n;
    printf("%d\n",s);
return 0 ;
}


Measured memory_bytes: 128
N = int(input())

k = 0

for i in range(1,int(N**(0.5))+1):
    if N % i == 0:
        n = str(int(N // i))
        I = str(i)
        K = len(n) if len(n) >= len(I) else len(I)
        if k == 0:
            k = K
        else:
            if k > K:
                k = K
            else:
                continue

print(k)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
const long long inf = 1000000001; // const 書き換え禁止
const double PI = 3.14159265358979323846; //M_PI はライブラリ

int main(void){
    int n;
    cin >> n;
    int l[n];
    for(int i=1;i<=n;i++) cin >> l[i];
    int ans = 0;
    for(int i=1;i<n;i++){
        for(int j=i+1;j<=n;j++){ //i+1
            for (int k = j+1; k <= n; k++){ //j+1
                if(l[i] == l[j] || l[j] == l[k] || l[i] == l[k]){
                    continue;
                }
                // cout << i <<" " << j << " " << k << endl;
                // cout << l[i] << " " << l[j] << " " << l[k] << endl;
                bool a = (l[i]+l[j])>l[k];
                bool b = (l[j]+l[k])>l[i];
                bool c = (l[k]+l[i])>l[j];
                if(a && b && c){
                    //cout << i <<" " << j << " " << k << "!!" << endl;
                    ans++;
                }
            }
            
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#!/usr/bin/env python3


def greedy_count(s):
    global n, c
    res = [0] * (n + 2)
    t = 0
    while t < n:
        if s[t] == "o":
            res[t + 1] = 1
            t += c
        t += 1
    for i in range(n + 1):
        res[i + 1] += res[i]
    return res


n, k, c = map(int, input().split())
s = input()

left = greedy_count(s)
right = greedy_count(s[::-1])[::-1]

for i in range(1, n + 1):
    if left[i - 1] + right[i + 1] < k:
        print(i)


Measured memory_bytes: 20712
from operator import itemgetter
from heapq import heappush, heappop
N, M = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(N)]
LR.sort(key=itemgetter(1))
A = []
ans_left = 0
idx = 1
for _, r in LR:
    if r==M+1 or idx==M+1:
        break
    ans_left += 1
    idx = max(idx+1, r+1)

idx_LR = 0
q = []
for i in range(M+1-ans_left, M+1):
    while idx_LR<N and LR[idx_LR][1]<=i:
        l, _ = LR[idx_LR]
        heappush(q, l)
        idx_LR += 1
    heappop(q)
while idx_LR<N:
    l, _ = LR[idx_LR]
    q.append(l)
    idx_LR += 1

q.sort(reverse=True)
ans_right = 0
idx = M
for l in q:
    if l==0 or idx==0 or ans_right+ans_left==M:
        break
    ans_right += 1
    idx = min(l-1, idx-1)
ans = N - ans_left - ans_right
print(ans)


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

int main(){
    int n,m,sum=0;
    cin >> n >> m;
    int a[m],min;
    for(int i=0;i<m;i++){
        cin >> a[i];
    }
    sort(a, a+m);
    int delta[m-1];
    for(int i=0;i<m-1;i++){
        delta[i] = a[i+1] - a[i];
    }
    sort(delta, delta+m-1);
    for(int i=0;i<m-n;i++){
        sum += delta[i];
    }
    if(n >= m) sum = 0;
    cout << sum;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
const int maxn = 1e5;
int vis[maxn];
int cnt = 0;
int a, b;
int main()
{
	for (int i = 1; i <= 9; i++) {
		for (int j = 0; j <= 9; j++) {
			for (int k = 0; k <= 9; k++) {
				vis[i * 10000 + j * 1000 + k * 100 + j * 10 + i] ++;
			}
		}
	}
	cin >> a >> b;
	for (int i = a; i <= b; i++)
		if (vis[i])cnt++;
	cout << cnt;
	return 0;
}

Measured memory_bytes: 640
col,row = map(int,input().split())
matrix = []
vector = []
for _ in range(col):
	matrix.append([int(j) for j in input().split()])

for _ in range(row):
	vector.append(int(input()))

for i in range(col):
	ans = 0
	for x,y in zip(matrix[i],vector):
		ans += x * y
	print(ans)

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

using namespace std;


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

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

int main(void) {
	
	float x=0.0,y=0.0,d,t,a=90.0;

	while(scanf("%f,%f",&d,&t)!=EOF){
		if(d==0 && t==0)break;
		x+=d*cosf(a/180*atanf(1.0)*4);
		y+=d*sinf(a/180*atanf(1.0)*4);
		a-=t;
	}

	printf("%.0f\n%.0f\n",floorf(fabsf(x))*x/fabsf(x),floorf(fabsf(y))*y/fabsf(y));

	return 0;
}

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

int main(){
	while(1){
		long n, a, b;
		scanf(" %ld %ld %ld", &n, &a, &b);
		if(n==0) break;
		
		if(a>b) swap(a,b);

		long ans=0;
		bool x[1000001];
		
		for(long i=1; i<=n; ++i) x[i]=false;
		x[0]=true;
		
		//作れない数を探す
		for(long i=0; i<=n; ++i){
			if(x[i]){
				if(i+a<=n) x[i+a]=true;	
				if(i+b<=n) x[i+b]=true;
			}
		}	
		
		for(long i=1; i<=n; ++i)
			if(!x[i]) ++ans;
		
		printf("%ld\n", ans);
	}
}

Measured memory_bytes: 2164
N, K = map(int, input().split())

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod ) # http://drken1215.hatenablog.com/entry/2018/06/08/210000(1-5)
    g2.append( (g2[-1] * inverse[-1]) % mod )

l=N-K
for i in range(K):
    print((cmb(l+1,i+1,mod)*cmb(K-1,i,mod))%mod)

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

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



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

int main(){
    int N;
    cin >> N;
    int count = 0;
    //ケーキを最大で買った場合
    int cake = N / 4;
    for(int i = 0;i <= cake;++i){
        if((N - i * 4) %  7 == 0) ++count;
    }
    if(count > 0) cout << "Yes" << endl;
    else cout << "No" <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
using namespace std;

const int N = 1e6+69;

int n,x,y,k,m,a,b;

char c;
string s,t;

int A[N];

int main(){

	cin>>s>>t;
	cout<<t<<s<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MAX = 510000;
const int MOD = 1000000007;
//
int fac[MAX], finv[MAX], inv[MAX];
int oya[MAX]={};
int ko[MAX]={},ans;
vector<int> hen[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;
    }
}
// 累乗
int modpow(int a, int n) {
    int res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}
void dfs(int x){
    for(int i=0;i<hen[x].size();i++){
        if(oya[hen[x][i]]==-2){
            oya[hen[x][i]]=x;
            dfs(hen[x][i]);
        }
    }
}
void dfs2(int x,int n){
    int t=0;
    for(int i=0;i<hen[x].size();i++){
        if(hen[x][i]!=oya[x]){
            dfs2(hen[x][i],n);
            t=(t+(1+MOD-modpow(inv[2],ko[hen[x][i]]+1))*modpow(inv[2],n-1-(ko[hen[x][i]]+1))%MOD)%MOD;
            ko[x]+=ko[hen[x][i]]+1;
        }
    }
   // cerr<<t<<endl;
    t=(t+(1+MOD-modpow(inv[2],n-1-ko[x]))*modpow(inv[2],ko[x])%MOD)%MOD;
    //cerr<<t<<endl;
    t=(t+modpow(inv[2],n-1))%MOD;
   // cerr<<ko[x]<<' '<<t<<endl;
    ans=(ans+inv[2]*(1+MOD-t)%MOD)%MOD;
    
}
signed main() {
    int n;ans=0;
    COMinit();
    cin>>n;
    int a,b;
    for(int i=0;i<n-1;i++){
        cin>>a>>b;a--;b--;
        hen[a].push_back(b);
        hen[b].push_back(a);
    }
    fill(oya,oya+n,-2);
    oya[0]=-1;
    dfs(0);

    dfs2(0,n);
    cout<<ans;


}


Measured memory_bytes: 49792
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main(){
	int n,m;
	cin >> n >> m;
	vector<int> a,b,c,d;
	for(int i = 0;i < n;i++){
		int x,y;
		cin >> x >> y;
		a.push_back(x);
		b.push_back(y);
	}
	for(int i = 0;i < m;i++){
		int x,y;
		cin >> x >> y;
		c.push_back(x);
		d.push_back(y);
	}
	for(int i = 0;i < n;i++){
		int min = 1000000000;
		int mini = 0;
		for(int j = 0;j < m;j++){
			int dis = abs(a[i]-c[j])+abs(b[i]-d[j]);
			if(dis < min){
				min = dis;
				mini = j;
			}
		}
		cout << mini+1 << endl;
	}
}


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

ll euclidean_gcd(ll a, ll b) {
    if (a < b) return euclidean_gcd(b, a);
    ll r;
    while(r = a % b) {
        a = b;
        b = r;
    }
    return b;
}

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

int main()
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    
    ll r = lcm(c, d);

    a--;
    ll b_n = b / c + b / d - b / r;
    ll a_n = a / c + a / d - a / r;

    cout << (b - a) - (b_n - a_n) << endl;

    return 0;
}

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

int mod = 1000000007;
int64_t large = 9223372036854775807;
double PI = 3.141592653589793;

int main()
{
    int N;
    cin >> N;
    vector<int> list(N);
    for (int i = 0; i < N; i++)
        cin >> list[i];
    int64_t ans = large;
    for (int64_t i = -100; i <= 100; i++)
    {
        int64_t tmp = 0;
        for (int64_t j = 0; j < N; j++)
            tmp += pow(i - list[j], 2);
        ans = min(ans, tmp);
    }
    cout << ans;
}

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

int main() {
	int x;
	cin >> x;
	if(x == 1){
	    cout << 0 << endl;
	} 
	else  cout << 1 << endl;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

const ll mod=1e9+7;

//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}

typedef pair<int,int> P;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    vector<ll> a(n),b(n);
    ll p=0,m=0;
    rep(i,n){
      cin>>a[i];
      if(a[i]<0){
        b[i]=-a[i];
        m++;
      }else{
        b[i]=a[i];
        p++;
      }
    }
    ll ans=0;
    if(m%2==0){
      rep(i,n){
        ans+=b[i];
      }
    }else{
      rep(i,n){
        ans+=b[i];
      }
      ans-=2**min_element(begin(b),end(b));
    }
    //cout<<m<<*min_element(begin(b),end(b))<<'\n';
    //cout_vec(b);
    cout<<ans<<endl;
}


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/

ll gcd(ll a,ll b)
{
	if (a%b==0)
	{
		return(b);
    }
	else
	{
		return(gcd(b,a%b));
    }
}

int main() {
  ll A,B,C,D,lcm,ans,dc,dd,dl,dcup,dcdown,ddup,dddown,dlup,dldown;
  cin >> A >> B >> C >> D;
  lcm = C*D/gcd(C,D);
  dcup = B/C;
  dcdown = (A-1)/C;
  dc = dcup-dcdown;
  ddup = B/D;
  dddown = (A-1)/D;
  dd = ddup-dddown;
  dlup = B/lcm;
  dldown = (A-1)/lcm;
  dl = dlup-dldown;
  ans = B-A+1-(dc+dd-dl);
  cout << ans<< endl;
  return 0;
}

Measured memory_bytes: 256
def solve(a):
	if len(a) == m: return a
	for i in M-set(a):
		for x,y in xy:
			if x == i and y not in a: break
		else:
			r = solve([i]+a)
			if r: return r
m = input()
M = set(range(1,m+1))
xy = [map(int,raw_input().split()) for i in range(input())]
for i in solve([]): print i

Measured memory_bytes: 4236
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int x;
  cin >> x;
  int ans = 0;
  for(int i = 0;i <= a;i++){
    for(int j = 0;j <= b;j++){
      int n = x - (i * 500 + j * 100);
      ans += n >= 0 && n % 50 == 0 && n / 50 <= c;
    }
  }
  cout << ans << endl;
}


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

namespace AtCoder1
{
    class Program
    {
        static void Main(string[] args)
        {
            string a = "A";
            string c = "C";
            string g = "G";
            string t = "T";

            string x = Console.ReadLine();

            if (x == a)
            {
                Console.WriteLine("T");
            }
            else if (x == c) 
            {
                Console.WriteLine("G");
            }
            else if (x == g)
            {
                Console.WriteLine("C");
            }
            else if (x == t) 
            {
                Console.WriteLine("A");
            }
            else
            {
                Console.WriteLine(x);
            }
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define m 1000000007

int main(){
    ll n,k;
    cin>>n>>k;
    ll arr[n+1];
    for(ll i=1;i<=n;i++){
        cin>>arr[i];
    }
    ll dp[n+1][k+1];
    for(ll i=0;i<=k;i++){
        if(i<=arr[1]){
            dp[1][i]=1;
        }else{
            dp[1][i]=0;
        }
    }
    for(ll i=1;i<=n;i++){
        dp[i][0]=1;
    }
    for(ll i=2;i<=n;i++){
        for(ll j=1;j<=k;j++){
            if((j-1-arr[i])>=0)
                dp[i][j]= ((dp[i][j-1]+ dp[i-1][j])%m - dp[i-1][j-1-arr[i]]+ m )%m;
            else{
                dp[i][j]= (dp[i][j-1]+ dp[i-1][j])%m;
            }
        }
    }
    cout<<dp[n][k]<<"\n";
    return 0;
}



Measured memory_bytes: 78336
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

int dp[40050][205];
int in[2][40050];
int mx[40050];
int main() {
	int N, i, j, s = 0;
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &in[0][i]);
	for (i = 1; i <= N; i++) scanf("%d", &in[1][i]);

	memset(mx, 0x3f, sizeof(mx));
	for (i = 1; i <= N; i++) {
		int t1 = in[0][i], t2 = in[1][i];
		t1 *= 2, t2 *= 2;
		for (j = s; j <= s + t1; j++) mx[j] = min(mx[j], t2);
		s += t1;
	}

	for (i = 0; i <= s; i++) for (j = 0; j <= 200; j++) dp[i][j] = -INF;
	dp[0][0] = 0;
	for (i = 1; i <= s; i++) {
		for (j = 0; j <= 200; j++) {
			dp[i][j] = max(dp[i][j], dp[i - 1][j] + 2 * j);
			if (j != 200) dp[i][j + 1] = max(dp[i][j + 1], dp[i - 1][j] + 2 * j + 1);
			if (j != 0) dp[i][j - 1] = max(dp[i][j - 1], dp[i - 1][j] + 2 * j - 1);
		}
		for (j = mx[i] + 1; j <= 200; j++) dp[i][j] = -INF;
	}
	return !printf("%.20lf\n", (db)dp[s][0] / 8);
}

Measured memory_bytes: 32384
let s=["KIHBR","KIHBRA","KIHBAR","KIHBARA","KIHABR","KIHABRA","KIHABAR","KIHABARA","AKIHBR","AKIHBRA","AKIHBAR","AKIHBARA","AKIHABR","AKIHABRA","AKIHABAR","AKIHABARA"]
print(s.contains(readLine()!) ?"YES":"NO")

Measured memory_bytes: 4080
from sys import stdin
def input():
    return stdin.readline().strip()

n, ma, mb = map(int, input().split())
a, b, c = [], [], []
for _ in range(n):
    i, j, k = map(int, input().split())
    a.append(i)
    b.append(j)
    c.append(k)

sum_a = sum(a) + 1
sum_b = sum(b) + 1

# dpを商品を増やすごとに更新する
dp = [[float('inf')] * sum_b for _ in range(sum_a)]
dp[0][0] = 0

from copy import deepcopy
for i in range(n):
    new_dp = deepcopy(dp)
    ai, bi, ci = a[i], b[i], c[i]
    for x in range(sum_a - ai):
        for y in range(sum_b - bi):
            new_dp[x+ai][y+bi] = dp[x][y] + ci
    for x in range(sum_a):
        for y in range(sum_b):
            if dp[x][y] > new_dp[x][y]:
                dp[x][y] = new_dp[x][y]

ans = float('inf')
for x in range(1, sum_a):
    for y in range(1, sum_b):
        if x * mb == y * ma and dp[x][y] < ans:
            ans = dp[x][y]

if ans == float('inf'):
    print(-1)
else:
    print(ans)

Measured memory_bytes: 99092
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int main() {
  string s;
  cin >> s;
  string ans = "";
  rep(i,s.size()){
    if(s[i]=='0') ans += "0";
    if(s[i]=='1') ans += "1";
    if(ans.size()>0) {
      if(s[i]=='B'){
        ans.erase(ans.size()-1);
      }
    }
  }
  cout << ans << endl;
}

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

int main() {
  int N;
  string S, ans = "Three";
  cin >> N;

  for (int i = 0; i < N; i++) {
    cin >> S;
    if (S == "Y") {
      ans = "Four";
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int max_value = 100000;

int main() {
    
    int x[max_value + 1] = {};
    int n;
    
    cin >> n;
    for (int i = 0; i < n; i++) {
        int a;
        
        cin >> a;
        x[a]++;
    }
    
    int hi = max_value;
    int lo = 1;
    int result = n;
    while (hi >= lo) {
        while (hi >= 1 && x[hi] <= 1) {
            hi--;
        }
        while (lo <= max_value && x[lo] <= 1) {
            lo++;
        }
        
        if (hi == lo) {
            result -= (x[lo] & ~1);
            
            lo++;
            hi--;
        }
        else if (hi > lo) {
            if (x[hi] > x[lo]) {
                result -= (x[lo] - 1) * 2;
                x[hi] -= x[lo] - 1;
                x[lo] = 1;
                
                lo++;
            }
            else if (x[lo] > x[hi]) {
                result -= (x[hi] - 1) * 2;
                x[lo] -= x[hi] - 1;
                x[hi] = 1;
                
                hi--;
            }
            else {
                result -= (x[lo] - 1) * 2;
                
                x[lo] = 1;
                x[hi] = 1;
                
                lo++;
                hi--;
            }
        }
    }
    
    cout << result << "\n";
    
    return 0;
}

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

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

    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
  
    if(s < t) printf("Yes");
    else printf("No");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
vector<pii> g[21];
vector<int> bit;
int main(){
	int L,N=20,M=0;
	scanf("%d",&L);
	L--;
	for(int i=1;i<N;i++){
		g[i].push_back(pii(i+1,0));
		M++;
	}
	for(int i=20;i>=0;i--)
		if(L&(1<<i)) bit.push_back(i);
	for(int i=N-bit[0],s=(1<<(bit[0]-1));i<N;i++,s>>=1){
		g[i].push_back(pii(i+1,s));
		M++;
	}
	int sub=0;
	for(int i=0;i<(int)bit.size()-1;i++){
		sub|=(1<<bit[i]);
		g[1].push_back(pii(N-bit[i+1],sub));
		M++;
	}
	g[1].push_back(pii(N,L));
	M++;
	printf("%d %d\n",N,M);
	for(int i=1;i<=N;i++){
		for(int j=0;j<(int)g[i].size();j++){
			printf("%d %d %d\n",i,g[i][j].first,g[i][j].second);
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  while(cin>>n,n!=0){
    int hyou[n][n];
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	cin>>hyou[i][j];
      }
    }
    int hyoup[n+1][n+1]={0};
    hyoup[0][n]=0;
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	hyoup[i][j]=hyou[i][j];
      }
    }
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	hyoup[i][n]+=hyou[i][j];
	hyoup[n][i]+=hyou[j][i];
      }
    }
    for(int i=0;i<n;i++)
      hyoup[n][n]+=hyoup[n][i];
    for(int i=0;i<n+1;i++){
      for(int j=0;j<n+1;j++){
	printf("%5d",hyoup[i][j]);
      }
      cout<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3144
// By Debajit Chakraborty
#include<bits/stdc++.h>
using namespace std;
 
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define MP make_pair
#define pb push_back
#define ff first
#define ss second
#define sz(x) x.size()
#define all(c) c.begin(),c.end()
#define int long long
#define fr(i,j,x) for(int i=j;i<x;i++)
#define rep(i,j,x) for(int i=j;i<=x;i++)
#define rev(i,j,x) for(int i=j;i>=x;i--)
#define mem(x,val) memset(x,val,sizeof(x))
//#define endl '\n'
#define vi vector<int>
#define pii pair<int,int>
 
const int mod=1e9+7;
const int N=2e5+10;
const int INF=1e12;



void solve(){
    int x;
    cin>>x;
    if(x>=30){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}


int32_t main()
{
    
    SPEED;
    int T=1;
    //cin>>T;
    int t1=1;
    while(true)
    {  
        //cout<<"Case #"<<t1<<": ";
        //cout<<endl;
        solve();
        t1++;
        if(t1>T)
            break;
    }
}   


Measured memory_bytes: 3648
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    rep(i, n) cin >> v[i];
    int ans = 0;
    for ( int l = 0; l <= n; ++l ) {
        for ( int r = 0; r <= n; ++r ) {
            if ( l + r > k ) continue;
            if ( l + r > n ) continue;
            priority_queue<int, vector<int>, greater<int>> q;
            int sum = 0;
            rep(i, l) q.push(v[i]);
            rep(i, r) q.push(v[n-i-1]);
            int d = k - l - r;
            rep(c, d) {
                if ( q.empty() ) break;
                if ( q.top() >= 0 ) break;
                q.pop();
            }
            while(!q.empty()) {
                sum += q.top();
                q.pop();
            }
            ans = max(ans, sum);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define MAX 100

int main( ){
  int n,i,j,v[MAX+1][MAX+1],u,k,a;

  scanf("%d",&n);


for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      v[i][j] = 0;
    }
 }  
  for(i=1;i<=n;i++){
    scanf("%d%d",&u,&k);
    for(j=1;j<=k;j++){
      scanf("%d",&a);
      v[u][a] = 1;
    }
  }

  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      if(j != 1)printf(" ");
      	printf("%d",v[i][j]);
    }
    printf("\n");
  }
  return 0;
}

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

struct node {
	int id, parent;
	int children[2];
	int deg, depth, height;

	node() :id{ -1 }, parent{ -1 }
		, children{ -1 }
		, deg{0}
		, depth{ 0 }
		, height{ 0 }
	{}
};

void set_depth(std::vector<node>*const tp, int index ) {
	auto& tree = *tp;
	for (int i{}; i < 2; i++) {
		auto x = tree[index].children[i];
		if (x == -1)continue;
		tree[x].depth = tree[index].depth + 1;
		set_depth(tp, tree[x].id);
	}
}

int get_height(std::vector<node>*const tp,int index) {
	auto& tree = *tp;
	auto& here = tree[index];
	return  here.deg == 0 ?
		0 :
		std::max(
			get_height(tp, here.children[0])
			, get_height(tp, here.children[1])
		) + 1;
}

int main() {
	int n;
	std::cin >> n;
	std::vector<node> bt;
	bt.resize(n);
//	std::cout <<"size = "<< bt.size() << "\n";

	for (int i{}; i < n; ++i) {
		int index;
		std::cin >> index;
		
		auto& nd = bt[index];
		auto& chd = nd.children;
		nd.id = index;
		std::cin >> chd[0] >> chd[1];
		
		if (chd[0] != -1)
			bt[chd[0]].parent = index;
		if(chd[1] != -1)
			bt[chd[1]].parent = index;

		nd.deg = (chd[0] == -1 ? 0:1)
			+ (chd[1] == -1 ? 0:1);

		if (nd.deg == 0)
			nd.height = 0;
	}
	/*
	for (const auto&e : bt) {
		std::cout << e.id << " " << e.deg<<" "<<e.parent << "\n";
	}*/

	int root_id{ 0 };
	while (bt[root_id].parent != -1)
		++root_id;


	set_depth(&bt, root_id);

	for (int i{}; i < n; ++i) {
		bt[i].height = get_height(&bt, i);
	}

	for (auto&e : bt) {
		std::cout << "node " << e.id << ": ";
		std::cout << "parent = " << e.parent << ", ";
		std::cout << "sibling = " <<
			[&]()->int {
			if (e.parent == -1)
				return -1;//親がいないならsiblingはいない


			auto& pair = bt[e.parent].children;
			//自分と異なるsiblingをreturn
			return pair[pair[0] == e.id ? 1 : 0];
		}();
		std::cout << ", ";


		std::cout << "degree = " << e.deg << ", ";
		std::cout << "depth = " << e.depth << ", ";
		std::cout << "height = " << e.height << ", ";
		std::cout << (e.parent==-1?"root":e.deg==0?"leaf":"internal node")<<"\n";
	}

	return 0;
}


Measured memory_bytes: 3100
import java.util.*;
import java.lang.*;
import java.io.*;

class Main
{
	public static void main(String[] args)
	{
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		int ar[]=new int[n];
		for(int i=0;i<n;i++)
			ar[i]=scan.nextInt();

		int dp[]=new int[n];
		dp[1]=Math.abs(ar[1]-ar[0]);

		for(int i=2;i<n;i++)
		{
			int min = Math.min(dp[i-1]+Math.abs(ar[i]-ar[i-1]), dp[i-2]+Math.abs(ar[i]-ar[i-2]));
			dp[i] = min;
		}
		System.out.println(dp[n-1]);
	}
}

Measured memory_bytes: 50844
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    h,w = LI()
    if h < 2 or w < 2:
        return 1

    return (h*w+1) // 2


print(main())





Measured memory_bytes: 5696
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, L] = [int(input_raw[0]), int(input_raw[1])]
    input_raw = read_func().strip().split()
    A = [int(input_raw[i]) for i in range(N)]
    B = deque([A[i] + A[i + 1] for i in range(N - 1)])
    sumA = sum(A)
    s_idx = 1
    t_idx = len(B)
    seq = []
    for i in range(N - 1):
        if sumA < L:
            print "Impossible"
            return
        if B[len(B) - 1] < L:
            B.pop()
            sumA -= A[t_idx]
            seq.append(t_idx)
            t_idx -= 1

        else :
            B.popleft()
            sumA -= A[s_idx - 1]
            seq.append(s_idx)
            s_idx += 1
        if len(seq) == N - 1:
            break

    print "Possible"
    for i in range(len(seq)):
        print seq[i]





if __name__ == '__main__':
    main()


Measured memory_bytes: 49460
#include<stdio.h>
int main(){
	int a,b;
	char op;
	for(;;){
	scanf("%d %c %d",&a,&op,&b);
	if(op=='+'){
		printf("%d\n",a+b);
	}else if(op=='-'){
		printf("%d\n",a-b);
	}else if(op=='/'){
		printf("%d\n",a/b);
	}else if(op=='*'){
		printf("%d\n",a*b);
	}else if(op=='?'){
		break;
	}
	}
	
	
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <numeric>
#include <limits>
using namespace std;

int main(void) {
	string at, top;
	cin >> at >> top;

	if (at == "H") {
		if (top == "H") {
			cout << 'H' << endl;
		}
		else {
			cout << 'D' << endl;
		}
	}
	else {
		if (top == "H") {
			cout << 'D' << endl;
		}
		else {
			cout << 'H' << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast","no-stack-protector","unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx")
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
using namespace std;
#define F(i,L,R) for(int i=L;i<R;++i)
#define FE(i,L,R) for(int i=L;i<=R;++i)
#define int long long
#define getI(a) scanf("%lld",&a)
#define getII(a,b) scanf("%lld%lld",&a,&b)
#define getIII(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define VgetI(n) int (n); scanf("%lld",&(n))
#define VgetII(n,m) int (n),(m); scanf("%lld%lld",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%lld%lld%lld",&(n),&(m),&(k))
#define debug(x) cout<<(#x)<<"="<<x<<"\n";
#define qq cout<<"QQ\n";
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define f first
#define s second
#define INF 2000000000
char maps[10][10];
main(){
	int h,w,k;
	while(~getIII(h,w,k)){
		F(i,0,h) scanf("%s",maps[i]);
		int ans=0;
		F(r,0,1<<h) F(c,0,1<<w){
			int tmp[10][10];
			F(i,0,h) F(j,0,w)
				tmp[i][j]=maps[i][j]=='#';
			//paint
			F(i,0,h) if(r&(1<<i))
				F(j,0,w) tmp[i][j]=0;
			F(j,0,w) if(c&(1<<j))
				F(i,0,h) tmp[i][j]=0;
			int sum=0;
			F(i,0,h) F(j,0,w) sum+=tmp[i][j];
			ans+=sum==k;
		}
		printf("%lld\n",ans);
	}
}


Measured memory_bytes: 3820
def is_prime(x):
    if x <= 1:
        return False
    elif x == 2:
        return True
    else:
        n = 2
        while n**2 <= x:
            if x % n == 0:
                return False
            n += 1
        return True


def main():
    X = int(input())
    while True:
        if is_prime(X):
            print(X)
            break
        X += 1


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        int num = 2019;
        Scanner sc = new Scanner(System.in);
        int l = sc.nextInt();
        int r = sc.nextInt();
        if (l + 2020 <= r) {
            System.out.println(0);
        }
        else {
            for (int i = l; i <= r; i++) {
                for (int j = i+1; j <= r; j++) {
                    int x = i % 2019;
                    int y = j % 2019;
                    int z = x*y;
                    num = Math.min(num, z % 2019);
                }
            }
            System.out.println(num);
        }
    }
}

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

main(){
  int n,i,j,ans=0;
  cin >> n;
  vector<int> l(n);
  for(i=0;i<n;i++) cin >> l[i];
  sort(l.begin(),l.end());
  
  for(i=0;i<n-2;i++){
    for(j=i+1;j<n-1;j++){
      int c = lower_bound(l.begin(),l.end(),l[j]+l[i]) - l.begin();
      ans += c-j-1;
    }
  }
  cout << ans << endl;
}
      
  
  

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextString() string {
	if !sc.Scan() {
		panic("failed scan string")
	}
	return sc.Text()
}

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

func main() {
	sc.Split(bufio.ScanWords)
	s := nextString()
	var sum int
	for _, c := range s {
		switch c {
		case '+':
			sum++
		case '-':
			sum--
		}
	}
	fmt.Println(sum)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  long long int a,b,c,d,e,f=10,g=0;
  cin>>a>>b>>c>>d>>e>>f;
  g=min(b,min(c,min(d,min(e,f))));
  if(a%g==0)a--;
    cout<<a/g+5;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<long>a(n);
  int i;
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  vector<long>s(n);
  s[0] = a[0];
  for(i=1;i<n;i++){
    s[i] = s[i-1]+a[i];
  }
  int ans = 1;
  for(i=n-2;i>=0;i--){
    if(s[i]*2<a[i+1])break;
    else ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
import sys
#import numpy as np
import math
#from fractions import Fraction
#import itertools
#from collections import deque
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
s=input()
n=len(s)
count=[0,0]
for i in s:
    if i=="g":
        count[0]+=1
    else:
        count[1]+=1
print((count[0]-count[1])//2)

Measured memory_bytes: 39664
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())

int n;
int a[200000];
int b[200000];


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

	cin>>n;

	rep(i, n)cin >> a[i];
	int h=0,t=n-1;
	for (int i=n-1;i>=0;i--){
		if ((n-i)&1){
			b[h++] = a[i];
		}
		else{
			b[t--] = a[i];
		}
	}
	cout << b[0];
	rep(i,n-1){
		cout << ' ' << b[i+1];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 3712
//#include <bits/stdc++.h>
// utility
#include <bitset>
#include <tuple>
#include <typeinfo>
// error handling
#include <cassert>
// string
#include <cctype>
#include <cstring>
#include <string>
// container
#include <array>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// algorithm
#include <algorithm>
// iterator
#include <iterator>
// math
#include <cmath>
#include <complex>
#include <numeric>
#include <random>
// i/o
#include <cstdio>
#include <iomanip>
#include <iostream>

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
typedef __int128_t Int;
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]) == typeid(INF) and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

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

  int N, M;
  cin >> N >> M;
  vector<int> A(N + 1);
  map<int, int> mp;
  rep(i, 1, N + 1) {
    cin >> A[i];
    A[i] += A[i - 1];
    A[i] %= M;
    mp[A[i]]++;
  }
  dump(A);
  dump(mp);
  int ans = 0;
  for (auto p : mp) {
    if (p.fi == 0)
      ans += (p.se) * (p.se + 1) / 2;
    else 
      ans += (p.se) * (p.se - 1) / 2;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4992
#include"cstdio"
#include"cmath"
int main(){
	int x,a,b;
	scanf("%d%d%d",&x,&a,&b);
	if(x>a)
		a=x-a;
	else a=a-x;
	if(x>b)
		b=x-b;
	else b=b-x;
	if(a>b)
		printf("B\n");
	else printf("A\n");
	return 0;
}

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

int main(){
    string A;
    cin >> A;
    string B;
    cin >> B;
    int C;
    cin >> C;
    int D;
    cin >> D;
    string E;
    cin >> E;
    if(E==A){C--;}
    else{D--;}
    cout<<C<<" "<<D<<endl;
    
}

Measured memory_bytes: 256