akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef bool boolean;

const int N = 1e6 + 5;

int n;
char s[N], s1[N];

void shrink() {
	int t = 0;
	for (int i = 1; i <= n; i++) {
		if (s[i] ^ s[i - 1]) {
			s[++t] = s[i];
		}
	}
	n = t;
}

int cnt[3];
char pg[3], qg[3];
void trans() {
	for (int i = 1; i <= n; i++) {
		cnt[s[i] - 'A']++;
	}
	vector<pair<int, int>> a;
	a.emplace_back(cnt[0], 0);
	a.emplace_back(cnt[1], 1);
	a.emplace_back(cnt[2], 2);
	sort(a.begin(), a.end());
#define make_trans(x, y) pg[x] = y, qg[y] = x;
	for (int i = 0; i < 3; i++)
		make_trans(a[i].second, i);
	for (int i = 1; i <= n; i++) {
		s[i] = pg[s[i] - 'A'] + 'A';
	}
}

void make_valid() {
	int x = 0, y = 0;
	auto count = [&] (int l, int r) -> boolean {
		if (l > r) return false;
		for (int i = l; i <= r; i++) {
			if (s[i] == 'B') {
				x++;
				return false;
			}
		}
		if (l == 1 || r == n)
			return false;
		y++;
		return true;
	};
	int ls = 0;
	vector<int> pos;
	for (int i = 1; i <= n; i++) {
		if (s[i] == 'A') {
			if (count(ls + 1, i - 1) && ls) {
				pos.push_back(i);
			}
			ls = i;
		}
	}
	count(ls + 1, n);
	if (x < y) {
		int t = 0;
		pos.resize(y - x);
		reverse(pos.begin(), pos.end());
		for (int i = 1; i <= n; i++) {
			if (!pos.empty() && i == pos.back()) {
				pos.pop_back();
			} else {
				s[++t] = s[i];
			}
		}
		n = t;
		shrink();
		s[n + 1] = 0;
	}
	memset(cnt, 0, sizeof(cnt));
	for (int i = 1; i <= n; i++)
		cnt[s[i] - 'A']++;
	int d = cnt[2] - cnt[1];
	int t = 0;
	char target = 'C';
	(d < 0) && (d = -d, target = 'B');
	ls = 0;
	auto remove = [&] (int l, int r) {
		if (l > r)
			return;
		if ((l == 1 || r == n) || (l ^ r)) {
			if (s[l] == target && d) l++, d--;
			if (l < r && s[r] == target && d) r--, d--;
		}
		for (int i = l; i <= r; i++)
			s1[++t] = s[i];
	};
	for (int i = 1; i <= n; i++) {
		if (s[i] == 'A') {
			remove(ls + 1, i - 1);
			s1[++t] = 'A';
			ls = i;
		}
	}
	remove(ls + 1, n);
	n = t;
	for (int i = 1; i <= n; i++) {
		s[i] = s1[i];
	}
	s[n + 1] = 0;
}

void make_equal() {
	memset(cnt, 0, sizeof(cnt));
	for (int i = 1; i <= n; i++)
		cnt[s[i] - 'A']++;
	assert(cnt[1] == cnt[2]);
	int d = cnt[1] - cnt[0];
	int t = 0;
	vector<pair<int, int>> pos;
	for (int i = 1; i <= n; i++) {
		if (i < n && d && s[i] != 'A' && s[i + 1] != 'A') {
			if (s1[t] == 'A' && s[i + 2] == 'A') {
				pos.emplace_back(t + 1, t + 2);
				s1[++t] = s[i];
			} else {
				i++, d--;
			}
		} else {
			s1[++t] = s[i];
		}
	}
	n = t;
	for (int i = 1; i <= n; i++)
		s[i] = s1[i];
	vector<int> delpos;
	for (int i = 0; i < d; i++) {
		delpos.push_back(pos[2 * i].first);
		delpos.push_back(pos[2 * i + 1].second);
	}
	t = 0;
	reverse(delpos.begin(), delpos.end());
	for (int i = 1; i <= n; i++) {
		if (!delpos.empty() && delpos.back() == i) {
			delpos.pop_back();
		} else {
			s[++t] = s[i];
		}
	}
	t = n;
	assert(delpos.empty());
}

int main() {
	scanf("%s", s + 1);
	n = strlen(s + 1);
	shrink();
	trans();
	make_valid();
	make_equal();
	for (int i = 1; i <= n; i++)
		s[i] = qg[s[i] - 'A'] + 'A';
	s[n + 1] = 0;
	puts(s + 1);
	return 0;
}


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

int main()
{
	int a[2],kisuu=0;
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);

	for (int i = 0; i < 3; ++i)
	{
		if (a[i] % 2 == 1) kisuu++;
	}
	int ans;
	if (kisuu == 0 || kisuu == 3|| (kisuu == 1 && a[2] % 2 == 1) || (kisuu == 2 && a[2] % 2 == 0)) {
		ans = ((2 * a[2]) - a[0] - a[1]) / 2;
	}
	if ((kisuu == 1 && a[2] % 2 == 0) || (kisuu == 2 && a[2] % 2 == 1)) {
		ans = (2 * (a[2] + 1) - a[0] - a[1] + 1) / 2;
	}
	
	cout << ans << endl;
	fflush (stdin);
	getchar ();
	fflush (stdin);
	getchar ();
	return 0;
}

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

using namespace std;

#define int long long

const int inf = 2e9;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int n, w;
    cin >> n >> w;
    vector<vector<int>> dp(n, vector<int> (w + 1, 0));
    for (int i = 0; i < n; i++) {
        int c, v;
        cin >> v >> c;
        dp[i][v] = c;
        for (int j = 0; j <= w; j++) {
            if (j > 0) {
                dp[i][j] = max(dp[i][j], dp[i][j - 1]);
            }
            if (i > 0) {
                dp[i][j] = max(dp[i][j], dp[i - 1][j]);
                if (j - v >= 0) {
                    dp[i][j] = max(dp[i][j], dp[i - 1][j - v] + c);
                }
            }
        }
    }
    cout << dp[n - 1][w] << "\n";
    return 0;
}


Measured memory_bytes: 79488
large = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
small = list("abcdefghijklmnopqrstuvwxyz")

while 1:
    word, alpha = input().split()
    if alpha == "X":
        break

    word = list(word)

    ans = ""
    if alpha == "L":
        first = word.pop(0)
        if first in large:
            ans += small[large.index(first)]
        else:
            ans += first

        while word != []:
            w = word.pop(0)
            if w == "_":
                target = word.pop(0)
                if target in small:
                    ans += large[small.index(target)]
                else:
                    ans += target
            else:
                ans += w

    elif alpha == "U":
        first = word.pop(0)
        if first in small:
            ans += large[small.index(first)]
        else:
            ans += first

        while word != []:
            w = word.pop(0)
            if w == "_":
                target = word.pop(0)
                if target in small:
                    ans += large[small.index(target)]
                else:
                    ans += target
            else:
                ans += w

    elif alpha == "D":
        first = word.pop(0)
        if first in large:
            ans += small[large.index(first)]
        else:
            ans += first

        while word != []:
            w = word.pop(0)
            if w in large:
                ans += "_" + small[large.index(w)]
            else:
                ans += w

    print(ans)



Measured memory_bytes: 5568
#include<bits/stdc++.h>
#include<queue>
#include<algorithm>
#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define REP(i,n) FOR(i,0,n)
using namespace std;

/*
2019/05/27
*/

int main(){//AC
  int n,m;
  cin>>n>>m;
  vector<int> a(n);
  vector<int>b(m);
  vector<int>c(m);
  priority_queue<pair<int,int>> q;//順位付きque//O(log要素数)
  //pair?最初が大きい方が優先される。
  //大きいもの順に出てくる
  //小さいもの順のときは？--ダイクストラの実装とか…
  REP(i,n){
    cin>>a[i];
    q.push(make_pair(a[i],1));
  }
  REP(i,m){
    cin>>b[i]>>c[i];
    q.push(make_pair(c[i],b[i]));
  }

  long long ans=0;//64bit
  REP(i,n){//n回の操作//qから取り出す
    pair<int,int> p=q.top();//最大をpに加える
    q.pop();//qから最大のカードを一枚を取り除く
    ans+=p.first;//初めの要素を答えに
    //cout<<ans<<endl;
    p.second--;
    if(p.second>0){//1より大きいならカードが残っているということで、qに戻す
      q.push(p);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3572
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <cmath>
#define f(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define chk(d) cout<<d<<endl
using namespace std;


int main()
{ long int n,m,k;
  cin>>n>>k;
  vector<long int>v;
  f(i,n)
  {
     long int a;
      cin>>a;
      v.push_back(a);
  }
long  int dp[n+3];
  f(i,n)dp[i]=mod;
  dp[0]= 0;
   // dp[1] = abs(v[1]-v[0]);
  for(int i = 0;i<n;i++)
  {   for(int j=1;j<=k;j++)
     if(i+j<n)dp[i+j] = min(dp[i]+abs(v[i+j]-v[i]), dp[i+j]);
     // dp[i+1] = min(dp[i]+abs(v[i-1]-v[i+1])-abs(v[i]-v[i-1]),dp[i+1]);

  }
// f(i,n)cout<<dp[i]<<" ";
 cout<<dp[n-1];

}



Measured memory_bytes: 1908
#include <stdio.h>

int main(){

    int n,i,j,k;
    scanf("%d",&n);

    for (i=1; i<n+1; i++)
    {
        j=i/10;
        k=j/10;
        if (i%3==0||i%10==3||i%100==3||i%1000==3||i%10000==3) {
            printf(" %d",i);
        }
        else if (j%10==3||j/10==3||k%10==3||k/10==3)
            printf(" %d",i);
        else
            ;
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 600
#include <stdio.h>

int main(void){

char str[1200];
	int count = 0;
	int i=0;
	int c=0;
	int sum = 0;
	
while(1){	
   sum=0; 
	while (1) {
		scanf("%c", &str[i]);

		if (str[i] == '\n')break;
		c = (int)str[i]-48;
		sum += c;
		i++;

	}
	if(sum==0)break;
	i=0;
printf("%d\n", sum);

}
return 0;
}
	




Measured memory_bytes: 2052
#include<bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

typedef pair<int,int>pi;
typedef vector<int>vi;

const int MAXN=100005;
const int MOD=1000000007;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())
#define UP(v,x) (upper_bound(all(v),(x))-(v).begin())

int A[MAXN], N;
main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> N;
	FOR(i,1,N) cin >> A[i];
	int ans = 0;
	FOR(i,1,N){
		if (i%2==1 && A[i]%2==1) ans++;
	}
	cout<<ans;
}


Measured memory_bytes: 3644
#include<stdio.h>
int main()
{
  int a,b,i,j;
  while(1)
       {
  scanf("%d%d",&a,&b);
  if(a==0&&b==0){break;}
 
  for(i=1;i<=a;i++)
    {
      for(j=1;j<=b;j++)
    {
      if(j%2==1)
        {
          if(i%2==1)printf("#");
          else printf(".");
        }
      else
        {
              if(i%2==1)printf(".");
          else printf("#");
        }
    }
      printf("\n");
    }
  printf("\n");
     
       }
  return 0;
}


Measured memory_bytes: 2040
n=int(input())
a=[int(x) for x in input().split()]
b=[]
for i in range(n):
    if a[i]==i+1:continue
    if a[a[i]-1]==i+1:
        t=[a[i]-1,i]
        b.append(sorted(t))
# print(b)
print(len(b)//2)

Measured memory_bytes: 25360
import math

N = int(input())

def cnt_digits(N):
    ctr = 0
    while N>0:
        N = int(N/10)
        ctr += 1

    return ctr

ans = cnt_digits(N)

for i in range(1, int(math.sqrt(N)+1)):
    if N%i != 0: continue
    B = int(N/i)
    cur = max(cnt_digits(i),cnt_digits(B))

    if (ans>cur):
        ans=cur
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define lli long long int
using namespace std;

const int maxN = 1e5; int n;
int h[maxN];

int main()
{
  scanf("%d", &n);
  for (int i = 0; i < n; i ++)
    scanf("%d", &h[i]);

  int ans = 0;
  for (int i = 1, now = 0; i < n; i ++)
  {
    if (h[i] > h[i - 1])
      now = 0;
    else
      now ++;
    ans = max(ans, now);
  }
  printf("%d\n", ans);

  return(0);
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int n;
    cin >> n;

    s64 cnt[10][10];
    rep (i, 10) rep (j, 10) cnt[i][j] = 0;
    rep (i, n + 1)
    {
        string s = to_string(i);
        ++cnt[s[0] - '0'][s[s.size() - 1] - '0'];
    }

    int ans = 0;
    for (int i = 1; i < 10; ++i)
    {
        for (int j = 1; j < 10; ++j)
        {
            ans += cnt[i][j] * cnt[j][i];
        }
    }

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



Measured memory_bytes: 3752
fn main() {
    let scan = std::io::stdin();
    
    let mut line = String::new();
    let _ = scan.read_line(&mut line);
    
    for e in line.chars() {
        if e as u8 >= 65 && e as u8 <= 90 {
            print!("{}", (e as u8 + 32) as char);
        } else if e as u8 >= 97 && e as u8 <= 122 {
            print!("{}", (e as u8 - 32) as char);
        } else {
            print!("{}", e);
        }
    }
}


Measured memory_bytes: 5020
<?php

list($a_point,$a_move) = explode(' ',trim(fgets(STDIN)));
list($b_point,$b_move) = explode(' ',trim(fgets(STDIN)));
$time = trim(fgets(STDIN));

if($a_move <= $b_move){
    echo 'NO';
    exit;
}

//距離差の絶対値　<= 移動差の絶対値　＊　time 
if(abs($a_point - $b_point) <= abs($a_move - $b_move) * $time){
    echo 'YES';
    exit;
}
echo 'NO';
exit;

?>


Measured memory_bytes: 16136
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
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;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void comuse() {
    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;
    }
}

 
ll combi(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;
}
 


 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  comuse();
  ll n,k;
  	ci(n>>k)
    FOR(i,1,k+1){
      ll ans=1;
      ans*=combi(n-k+1,i);
      ans*=combi(k-1,i-1);
      ans%=1000000007;
   co(ans)
}
}

Measured memory_bytes: 12160
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"---------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
						For(_x,L,R)cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector <int> vi;
typedef long double LD;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f|=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int N=2e3+5,INF=1e9;
int n;
int a[N],b[N];
void IN(){
	char s[N];
	cin>>s+1;
	n=strlen(s+1);
	For(i,1,n)
		a[i]=s[i]-'0';
	cin>>s+1;
	For(i,1,n)
		b[i]=s[i]-'0';
}
int check(){
	For(i,1,n)
		if (b[i])
			return 0;
	For(i,1,n)
		if (a[i])
			return 1;
	return 2;
}
int L[N],R[N];
int id[N],c;
bool cmp(int a,int b){
	return L[a]>L[b];
}
int main(){
	IN();
	int checkres=check();
	if (checkres==1)
		return puts("-1"),0;
	else if (checkres==2)
		return puts("0"),0;
	For(i,1,n){
		L[i]=R[i]=0;
		int p=i;
		while (!b[p])
			L[i]++,p=p==1?n:p-1;
		p=i;
		while (!b[p])
			R[i]++,p=p==n?1:p+1;
	}
	int ans=INF;
	For(r,0,n){
		int dif=0;
		c=0;
		For(i,1,n)
			if (a[i]!=b[(i+r-1)%n+1]){
				dif++;
				if (L[i]>0&&R[i]>r)
					id[++c]=i;
			}
		sort(id+1,id+c+1,cmp);
		int tmp=INF,mx=0;
		For(i,1,c){
			tmp=min(tmp,mx*2+L[id[i]]*2);
			mx=max(mx,R[id[i]]-r);
		}
		tmp=min(tmp,mx*2);
		ans=min(ans,tmp+dif+r);
	}
	For(l,0,n){
		int dif=0;
		c=0;
		For(i,1,n)
			if (a[i]!=b[(i-l+n-1)%n+1]){
				dif++;
				if (L[i]>l&&R[i]>0)
					id[++c]=i;
			}
		sort(id+1,id+c+1,cmp);
		int tmp=INF,mx=0;
		For(i,1,c){
			tmp=min(tmp,mx*2+(L[id[i]]-l)*2);
			mx=max(mx,R[id[i]]);
		}
		tmp=min(tmp,mx*2);
		ans=min(ans,tmp+dif+l);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
A, B, C, D = gets.split.map(&:to_i)

lcm = C.lcm(D)

c_div_cnt = B / C - (A - 1) / C
d_div_cnt = B / D - (A - 1) / D

puts (B - A - (c_div_cnt + d_div_cnt) + 1 + (B / lcm - (A - 1) / lcm))


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define endl '\n';

typedef long long ll;

using namespace std;

const string YES = "";
const string NO  = "";

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

    ll n;
    ll cnt = 0;

    cin >> n;

    for (ll i = 1; i <= n; i += 2) {
        for (ll j = 2; j <= n; j += 2) {
            cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}



Measured memory_bytes: 256
package main

import (
        "fmt"
)

func solution(k, n int, nums []int) int {
        memo := make([]int, n)
        memo[0] = nums[0] + k - nums[len(nums)-1]

        for i := 1; i < n; i++ {
                memo[i] = nums[i] - nums[i-1]
        }
        maxSoFar := memo[0]

        for i := 1; i < n; i++ {
                if memo[i] > maxSoFar {
                        maxSoFar = memo[i]
                }
        }
        return k - maxSoFar
}

func main() {
        var k, n int
        fmt.Scan(&k, &n)
        nums := make([]int, 0, n)
        for i := 0; i < n; i++ {
                t := 0
                fmt.Scan(&t)
                nums = append(nums, t)
        }

        fmt.Println(solution(k, n, nums))
}

Measured memory_bytes: 6528
y,m,d=map(int,input().split("/"))
if y<2019:
  print("Heisei")
  exit()
elif y==2019:
  if m<4:
    print("Heisei")
    exit()
  elif m==4:
    if d<=30:
      print("Heisei")
      exit()
print("TBD")

Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#define MOD 1000000007LL
using namespace std;

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

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

ll sol (ll n) {
    ll x = 26 ;
    while(x<n) x*=26 ;
    return x/26 ;

}

int main() {

    ll n , q , i ;
    map<ll,ll> mp ;
    ll x,sum =0 ;
    cin >> n ;
    for (i = 0 ; i< n ; i++) {
        cin >> x ;
        mp[x]++ ;
        sum+=x ;
    }
    cin >> q;
    while(q--) {
        ll a , b ;
        cin >> a >> b ;
        n = mp[a] ;
        sum-= n*a ;
        mp[a] = 0 ;
        mp[b]+=n ;
        sum+= b*n ;
        cout << sum << endl ;
    }
    return 0 ;
}


Measured memory_bytes: 9468
#include<bits/stdc++.h>
using namespace std;
template<typename T>inline T read(){
	T f=0,x=0;char c=getchar();
	while(!isdigit(c)) f=c=='-',c=getchar();
	while(isdigit(c)) x=x*10+c-48,c=getchar();
	return f?-x:x;
}
namespace run{
	int s[1009][1009];
	char c[1009][1009];
	char c4[10][10]={
		{'a','a','b','c'},
		{'d','d','b','c'},
		{'b','c','a','a'},
		{'b','c','d','d'}
	};
	char c5[10][10]={
		{'a','a','b','b','a'},
		{'b','c','c','.','a'},
		{'b','.','.','c','b'},
		{'a','.','.','c','b'},
		{'a','b','b','a','a'}
	};
	char c7[10][10]={
		{'a','a','b','b','c','c','.'},
		{'d','d','.','d','d','.','a'},
		{'.','.','d','.','.','d','a'},
		{'.','.','d','.','.','d','b'},
		{'d','d','.','d','d','.','b'},
		{'.','.','d','.','.','d','c'},
		{'.','.','d','.','.','d','c'}
	};
	int main(){
		int n=read<int>();
		if(n<=2) puts("-1"),exit(0);
		else if(n%3==0){
			for(int i=1;i<=n;i+=3)
				s[i][i]=s[i][i+1]=s[i+1][i+2]=s[i+2][i+2]=1;
			for(int i=1;i<=n;i++){
				for(int j=1;j<=n;j++){
					if(s[i][j]) printf("a");
					else printf(".");
				}
				cout<<endl;
			}
		}else{
			for(int i=1;i<=n;i++)
				for(int j=1;j<=n;j++) c[i][j]='.';

			int x=0,y=0,z=0,peg=0;
			for(x=0;x<=n/4;x++){
				for(y=0;x*4+y*5<=n;y++){
					int now=n-x*4-y*5;
					z=now/7;
					if(z*7==now){peg=1;break;}
				}
				if(peg) break;
			}

			for(int i=1;i<=x;i++){
				int now=i*4-3;
				for(int j=now;j<=i*4;j++)
					for(int k=now;k<=i*4;k++)
						c[j][k]=c4[j-now][k-now];
			}
			for(int i=1;i<=y;i++){
				int now=x*4+i*5-4;
				for(int j=now;j<=x*4+i*5;j++)
					for(int k=now;k<=x*4+i*5;k++)
						c[j][k]=c5[j-now][k-now];
			}
			for(int i=1;i<=z;i++){
				int now=x*4+y*5+i*7-6;
				for(int j=now;j<=x*4+y*5+i*7;j++)
					for(int k=now;k<=x*4+y*5+i*7;k++)
						c[j][k]=c7[j-now][k-now];
			}
			for(int i=1;i<=n;i++){
				for(int j=1;j<=n;j++){
					printf("%c",c[i][j]);
				}
				puts("");
			}
		}
		return 0;
	}
}
int main(){
#ifdef my
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	return run::main();
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
#include<string.h>
#include <math.h>
#include<iostream>
using namespace std;
typedef long long           ll;
typedef unsigned long long  ull;
typedef long double         ld;

#define sf                  scanf
#define pf                  printf
#define srev                reverse(s.begin(),s.end())
#define sortstr             sort(s.begin(), s.end());
#define gtl(x)              getline(cin, (x))
#define gcd(a, b)           __gcd(a, b)
#define lcm(a, b)           ((a)*((b)/gcd(a,b)))
#define PI                  acos(-1)
#define Precision(a) cout << fixed << setprecision(a)
#define FasterIO     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


template <typename T> T Sqr(T x) { T n = x * x ; return n ;}
template <typename T> T Pow(T B,T P){ if(P==0) return 1; if(P&1) return B*Pow(B,P-1);  else return Sqr(Pow(B,P/2));}
template <typename T> T Abs(T a) {if(a<0)return -a;else return a;}
template <typename T> T Gcd(T a,T b){if(a<0)return Gcd(-a,b);if(b<0)return Gcd(a,-b);return (b==0)?a:Gcd(b,a%b);}
template <typename T> T Lcm(T a,T b) {if(a<0)return Lcm(-a,b);if(b<0)return Lcm(a,-b);return a*(b/Gcd(a,b));}
//scanf("%[^\n]%*c", str);
//sort(s,s+n,greater<int>());

int main()
{
    double n;
    cin >> n;
    double x=ceil(n/2);
    cout << x << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n, k, q, tmp, a[100001] = {0}; 
  cin >> n >> k >> q;
  // for(int i=1; i<=n; i++)a[i] = 0;
  for(int i=0; i<q; i++){
    cin >> tmp;
    a[tmp] += 1;
  }
  for(int i=1; i<=n; i++){
    cout << (k-q+a[i]>0?"Yes":"No") << endl;
  }
  return 0;
}
    
    
  

Measured memory_bytes: 1024
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2254

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

const int INF = INT_MAX;

int main()
{
	int N;

	while(cin >> N && N)
	{
		vector< vector<int> > stage( N, vector<int>(N+1,0) );

		rep(i,N){
			rep(j,N+1){
				cin >> stage[i][j];
			}
		}
		
		vector<int> dp(1<<N, INF);

		dp[0] = 0;

		REP( bit, 0, (1<<N) ) 
		{
			REP( i, 0, N ) 
			{
				if( (bit & (1<<i)) != 0 ){ continue; } //既にクリアーされている
				int cost = stage[i][0];
				REP( j, 0, N )
				{
					if( (bit & (1<<j)) == 0 ){ continue; } //この装備は開放されていない
					cost = min(stage[i][j+1], cost);
				}
				int now = (bit | (1 << i));//クリアーした状態にする
				dp[now] = min(dp[now], dp[bit]+cost);
			}
		}
		
		cout << dp[(1<<N)-1] << endl;
	}

	return 0;
}

Measured memory_bytes: 1472
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>

#define DEBUG 0

int* array;
int N;
int L;
int min_counter;

void Print_Array(void);
void sliding_Window(void);
int Min_in_L(int start);

int main(){

    scanf("%d %d",&N,&L);
    if(DEBUG)printf("N = %6d\nL = %6d\n",N,L);

    array = malloc(sizeof(int)*N);
    if(array == NULL){
        if(DEBUG)printf("Out of memory, MEOW~~\n");
        return 1;
    }


    for(int i = 0; i< N; i++){
        scanf("%d",&array[i]);
    }
    if(DEBUG)Print_Array();

    sliding_Window();


}
void sliding_Window(void){
    int left = 0;
    int min = Min_in_L(left);
    printf("%d",min);
    

    while(left+L < N){
        if(array[left+L] < min){ // 右邊進來的比原本的全部都還小 所以直接設定他 然後把min_counter 設定成1
            min = array[left+L];
            min_counter = 1;
            printf(" %d",min);
        }else{
            if(array[left+L] == min){
                if(array[left] != min){
                    min_counter ++;
                }
                printf(" %d",min);
            }else{// 右邊即將吃進來的比原本的最小值還大
                if(array[left]!= min){//即將要吐掉的不是最小值 ==> 直接印出來原本的就好
                    printf(" %d",min);
                }else{//即將吐掉的就是原本的最小值
                    if(min_counter > 1){// 原本的最小值不只一個
                        min_counter --;
                        printf(" %d",min);
                    }else{//原本的最小值就是即將要被吐掉的 且還剛好只有他一個
                        min = Min_in_L(left+1); // 只好重跑
                        printf(" %d",min);
                    }
                }
            }
        }
        left++;
    }
    printf("\n");
}

int Min_in_L(int start){
    int i;
    int min = INT_MAX;
    min_counter = 0;
    for(i = 0; i< L; i++){
        if(array[start+i] < min){
            min = array[start+i];
            min_counter = 1;
        }else if(array[start+i] == min){
            min_counter ++;
        }
    }
    return min;
}


void Print_Array(void){
    int i;
    printf("array  : ");
    for (i = 0; i< N ; i++){
        printf("%3d",array[i]);
    }
    printf("\n");
}



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

int main(){
	long long x,y;	cin>>x>>y;
	long long ans=1;

	y/=x;

	long long z=1;
	while(1){
		if(z*2<=y){
			z*=2;
			ans++;
		}else break;
	}
	cout<<ans<<endl;



	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>

using namespace std;
typedef long long ll;

int N;

int main()
{
    ios_base::sync_with_stdio(0);

    cin >> N;
    if (N < 3 || ((N & (N - 1)) == 0))
    {
        cout << "No\n";
        return 0;
    }

    cout << "Yes\n";
    for (int i = 2; i + 1 <= N; i += 2)
    {
        cout << 1 << " " << i << "\n";
        cout << 1 << " " << i + 1 << "\n";
        cout << i << " " << N + i + 1 << "\n";
        cout << i + 1 << " " << N + i << "\n";
    }
    cout << N + 1 << " " << N + 2 << "\n";
    if (N % 2 == 0)
    {
        for (int i = 2; i < N; i++)
        {
            int x = i ^ N ^ 1;
            if (x < N)
            {
                cout << N << " " << x << "\n";
                cout << 2 * N << " " << i << "\n";
                break;
            }
        }
    }
}

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

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }

int main() {
	int n;
	cin >> n;
	map<int, int> dcnt;
	rep(i, n) {
		int d;
		cin >> d;
		dcnt[d]++;
	}
	int m;
	cin >> m;
	map<int, int> mcnt;
	rep(i, m) {
		int t;
		cin >> t;
		mcnt[t]++;
	}
	bool ok = true;
	for (auto a : mcnt) {
		int t = dcnt[a.first];
		if (a.second > t) ok = false;
	}
	cout << (ok ? "YES" : "NO") << endl;
	return 0;
}

Measured memory_bytes: 22236
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int main(){
	string S; cin>>S;
	// cout<<S<<"\n";//
	int N = S.size();
	vi counts(N);
	S += "R";
	int even = 0, odd = 0;
	int l_pos = -1, r_pos = 0;
	int e = 0, o = 0;
	rp(i,0,N){
		if(i%2) o++; else e++;

		if(S[i]=='R' && S[i+1]=='L'){
			r_pos = i;
			l_pos = i + 1;
			if(r_pos%2){//odd
				counts[r_pos] += o;
				counts[l_pos] += e;
			}
			else{//even
				counts[r_pos] += e;
				counts[l_pos] += o;
			}
			o = e = 0;
		}
		else if(S[i]=='L' && S[i+1]=='R'){
			if(r_pos%2){//odd
				counts[r_pos] += o;
				counts[l_pos] += e;
			}
			else{//even
				counts[r_pos] += e;
				counts[l_pos] += o;
			}
			o = e = 0;
		}

	}

	rpz(i, N) cout<<counts[i]<<(i+1==N?"\n":" ");
}


Measured memory_bytes: 1024
#include <stdio.h>
#define MAX 250
 
int Parent(int i){
 
  return(i/2);
}
 
 
int Left(int i){
 
  return 2*i;
}
 
int Right(int i){
 
  return 2*i+1;
}
 
main(){
  int heap_size;
  int A[MAX];
  int i;
 
 
  scanf("%d",&heap_size);
 
  for(i=1;i <= heap_size;i++){
 
    scanf("%d",&A[i]);
 
  }
 
  for(i=1;i <= heap_size;i++){
 
     
    printf("node %d: key = %d, ",i,A[i]);
 
    if(Parent(i) >= 1){
      printf("parent key = %d, ",A[Parent(i)]);
    }
 
    if(Left(i) <= heap_size){
 
      printf("left key = %d, ",A[Left(i)]);
    }
 
      if(Right(i) <= heap_size){
 
    printf("right key = %d, ",A[Right(i)]);
      }
      printf("\n");
  }
  return 0;
}

Measured memory_bytes: 600
import java.util.*;
import java.io.*;
import java.math.*;
public class Main{
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		int n = Integer.parseInt(sc.next());
		sc.close();
		ou.println((int)Math.sqrt(n) * (int)Math.sqrt(n));
		ou.flush();
	}
}

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

int main()
{
  string s,t;
  cin >> s; 
  cin >> t;
  int a,b;
  cin >> a >> b;
  string c;
  cin >> c;
  if (s==c) a--; else
  if (t==c) b--; 
  cout << a << ' ' << b;
  return 0;
}


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

int main(){
    fast;
    ll n, k;
    cin >> n >> k;
    ll a[k];
    vector<ll> no;
    for(int i = 0; i < k; ++i){
        cin >> a[i];
        for(int j = 0; j < a[i]; ++j){
            ll x;
            cin >> x;
            no.push_back(x);
        }
    }
    sort(no.begin(), no.end());
    ll c = 1;
    for(int i = 0; i < no.size() - 1; ++i){
        if(no[i] != no[i+1])
            ++c;
    }
    cout << n - c;
    return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
int min(int a,int b){
    return a<b?a:b;
}
int main(void){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    int pass = 1;
    
    for(int i=0;i<N;i++){
        if(A[i] % 2 == 0 && (A[i] % 3 != 0 && A[i] % 5 != 0)){
            pass = 0;
        }
    }
    
    if(pass){
        cout << "APPROVED";
    }
    else{
        cout << "DENIED";
    }
    
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;



int main() {
  int n;
  scanf("%d",&n);
  cout<<(n-1)/2<<endl;
  return 0;
}






















Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>

using namespace std;

int main(){

  int a,b,c,x,y;
  cin>>a>>b>>c>>x>>y;

  int ans_ab = a * x + b * y;
  int ans_abc = (x > y)?( 2 * c * y + a * (x-y)):(2 * c * x + b * (y-x));
  int ans_c = (x>y)?2*c * x:2*c*y;

  cout<<min(min(ans_ab,ans_abc),ans_c)<<endl;

  return 0;
}


Measured memory_bytes: 256
import sys


def main():
    n = int(sys.stdin.readline().strip())
    a = [int(s) for s in sys.stdin.readline().strip().split()]

    tuples = []
    for i in range(n):
        ai = a[i]
        tuples.append((ai, i+1))
    tuples.sort()
    ans_list = [str(tup[1]) for tup in tuples]
    print(' '.join(ans_list))


main()


Measured memory_bytes: 64356
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = 1e6+5;
const int mod = 1e9+7;

double pi = 3.14159265359;

int main(){
    double r;
    cin >> r;
    cout << fixed << setprecision(15) << 2.0 * pi * r << "\n";
}


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

int main(){
	int N, D1, D2, i, j, k, l, f, g;
	scanf("%d%d%d", &N, &D1, &D2);
	for(k = 0; D1 % 2 == 0; D1 /= 2, k++){}
	for(l = 0; D2 % 2 == 0; D2 /= 2, l++){}
	int num = 0;
	for(i = 0; i < 2 * N; i++){
		for(j = 0; j < 2 * N; j++){
			if(num == N * N){
				return 0;
			}
			if(((k % 2 == 0 && ((i / (1 << (k / 2))) + (j / (1 << (k / 2)))) % 2 == 0) || (k % 2 == 1 && (i / (1 << (k / 2))) % 2 == 0)) && ((l % 2 == 0 && ((i / (1 << (l / 2))) + (j / (1 << (l / 2)))) % 2 == 0) || (l % 2 == 1 && (i / (1 << (l / 2))) % 2 == 0))){
				printf("%d %d\n", i, j);
				num++;
			}
/*			if(k % 2 == 0){
				if(((i / (1 << (k / 2))) + (j / (1 << (k / 2)))) % 2 == 0){
					f = 0;
				}
				else{
					f = 1;
				}
			}
			else{
				if((i / (1 << (k / 2))) % 2 == 0){
					f = 0;
				}
				else{
					f = 1;
				}
			}
			if(l % 2 == 0){
				if(((i / (1 << (l / 2))) + (j / (1 << (l / 2)))) % 2 == 0){
					g = 0;
				}
				else{
					g = 1;
				}
			}
			else{
				if((i / (1 << (l / 2))) % 2 == 0){
					g = 0;
				}
				else{
					g = 1;
				}
			}
			if(f == 0 && g == 0){
				printf("%d %d\n", i, j);
				num++;
			}
*/		}
	}
	return 0;
}

Measured memory_bytes: 768
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>

#include<vector>
#include<set>

using namespace std;

const int mod=1000000007;

int main()
{
	int sum1 = 0;
	for (int i = 0; i < 4; i++) {
		int buf = 0;
		cin >> buf;

		sum1 += buf;
	}

	int sum2 = 0;
	for (int i = 0; i < 4; i++) {
		int buf = 0;
		cin >> buf;

		sum2 += buf;
	}

	cout << max(sum1, sum2) << endl;

    return 0;
}




Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int  long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
 
bool sortby(const pair<pair<string,int>,int> &a, 
              const pair<pair<string,int>,int> &b) 
{ 
    if(a.first.first==b.first.first)
        return (a.first.second > b.first.second); 
    else
        return(a.first.first < b.first.first);
}  
 
void solve(){
    int x,y;
    string a,b,c;
    cin>>a;
    rep(i,0,a.size())
    	cout<<"x";  
    
}
 
signed main(){
    //IOS;
    //freopen("input.txt", "r" , stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
   // cin>>t;
    while(t--){
        solve();
        cout<<"\n";
     //   cout<<" * "<<t<<"\n";
    }
//    return 0;
}


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

int main() {
  int n,m;
  cin>>n>>m;
  vl a(n),b(n);
  vl c(m),d(m);
  rep(i,n){
    cin >> a[i] >> b[i];
  }
  rep(i,m){
    cin>>c[i]>>d[i];
  }
  rep(i,n){
    ll z = 1001001001001;
    int x = 0;
    rep(j,m){
      if(abs(a[i]-c[j]) + abs(b[i]-d[j]) < z){
        x = j;
        z = abs(a[i]-c[j]) + abs(b[i]-d[j]);
      }
      
    }
    print(x+1);
  }
  return 0;
}

Measured memory_bytes: 256
use std::io::Read;

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

    std::io::stdin().read_to_string(&mut buf).unwrap();

    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let m: usize = iter.next().unwrap().parse().unwrap();
    let mut p = vec![0; m];
    let mut y = vec![0; m];
    for i in 0..m {
        p[i] = iter.next().unwrap().parse().unwrap();
        y[i] = iter.next().unwrap().parse().unwrap();
    }
    let mut permutation: Vec<usize> = (0..m).collect();
    permutation.sort_by(|i,j| {
        if p[*i] != p[*j] {
            return p[*i].cmp(&p[*j]);
        }
        y[*i].cmp(&y[*j])
    });
    let mut pre_id = -1;
    let mut sub_id = 1;
    let mut ans: Vec<String> = vec![String::new(); m];
    for i in permutation {
        if p[i] == pre_id {
            sub_id += 1;
        }else {
            sub_id = 1;
        }
        ans[i] = format!("{:0>6}{:0>6}", p[i], sub_id);
        pre_id = p[i];
    }
    for line in ans {
        println!("{}", line);
    }
}


Measured memory_bytes: 13820
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    string S; cin >> S;
    int a = (S[0] - '0') * 10 + (S[1] - '0'), b = (S[2] - '0') * 10 + (S[3] - '0');
    if ((1 <= a && a <= 12) && (1 <= b && b <= 12)) printf("%s\n", "AMBIGUOUS");
    else if (1 <= b && b <= 12) printf("%s\n", "YYMM");
    else if (1 <= a && a <= 12) printf("%s\n", "MMYY");
    else printf("%s\n", "NA");
}


Measured memory_bytes: 3560
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
#define ll long long

using namespace std;

int main(){
    ll N;
    cin >> N;

    //2で割れれば良い

    ll cnt = 0;
    ll tmp;

    REP(i,N)
    {
        cin >> tmp;
        while(1)
        {
            if(tmp % 2 != 0)break;
            tmp = tmp /2;
            cnt++;
        }
    }

    cout << cnt << endl;

}

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

public class Main {

	public static void main(String[] args){
	      Scanner sc = new Scanner(System.in);
	      int[] ABC = new int[3];
	      ABC[0] = sc.nextInt();
	      ABC[1] = sc.nextInt();
	      ABC[2] = sc.nextInt();
	      int K = sc.nextInt();
	      sc.close();
	      
	      Arrays.sort(ABC);
	      for(int i = 0; i < K; i++) {
	    	  	ABC[2] *= 2;
	      }
	      int answer = ABC[0] + ABC[1] + ABC[2];
	      
	      System.out.println(answer);
	      System.exit(0);
	    }
}

Measured memory_bytes: 21844
#include<stdio.h>
int main(void){
    int a,b;
    scanf("%d%d",&a,&b);
    int x = a - 2*b;
    if (x > 0)
    {
        printf("%d\n",x);
    }else
    {
        printf("0\n");
    }   
    return 0;
}

Measured memory_bytes: 1692
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5+2;
int a[maxn];
map<int,int> g;
inline uint32_t bsr_highest_bit(uint32_t x)
{
  if (!x) return 0;
  uint32_t bit;
  asm(
    "bsr %1, %0"
    : "=r" (bit)
    : "r" (x)
  );
  return (1 << bit);
}
int main() {
    int n;
    cin>>n;
    for(int i=0;i<n;++i) {
        cin>>a[i];
        g[a[i]]++;
    }
    int ans = 0;
    sort(a,a+n);
    for(int i=n-1;i>=0;--i){
        if(g[a[i]]) {
            g[a[i]]--;
            int x = a[i];
            int y = bsr_highest_bit(x);
            y <<= 1;
            //cout<<x<<" "<<y<<endl;
            
            if(g[y-x]) {
                g[y-x]--;
                ans++;
                //cout<<"x="<<x<<" y="<<y<<endl;
            }
            
        }
    }
    cout<<ans<<endl;
}

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

int main(){
    double X;
    long int mon = 100;
    int year = 0;
    cin >> X;

    while ( mon < X){
        mon = mon * 1.01;
        year = year + 1;
        if(mon >= X){
            cout << year << endl;
        }
    }

}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
string s, t;
char pairS[30];
char pairT[30];

int main(){
    cin >> s >> t;
    for (int i = 0; i < 26; i++){
        pairS[i] = '*';
        pairT[i] = '*';
    }
    for (int i = 0; i < s.size(); i++){
        if (pairS[s[i] - 'a'] == '*' && pairT[t[i]-'a'] == '*'){
            pairS[s[i] - 'a'] = t[i];
            pairT[t[i] - 'a'] = s[i];
        } else {
            if (pairS[s[i] - 'a'] != t[i]){
                cout << "No" << endl;
                return 0;
            }
            if (pairT[t[i] - 'a'] != s[i]){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 776
N = int(input())
A = list(map(int,input().split()))

A.sort()
Aset = set(A)
ans = 1

    
def bisearch(a):
    idx = (N-1)//2
    s = 0
    e = N-1
    while s<e:
        if A[idx] == a: break
        elif A[idx] < a:
            s = idx+1
            idx = (s + e)//2
        else:
            e = idx-1
            idx = (s + e)//2 
    return idx


for a in list(Aset):
    cnt = 0
    idx = bisearch(a)
    i = 0
    while True:
        if idx + i < 0 or idx + i >= N:
            break            
        elif A[idx + i] <= a+1 and A[idx + i] >= a-1:
            cnt += 1
        else:
            break
        i += 1
    i = -1
    while True:
        if idx + i < 0 or idx + i >= N:
            break          
        elif A[idx + i] <= a+1 and A[idx + i] >= a-1:
            cnt += 1
        else:
            break
        i -= 1
        
    ans = max(ans,cnt)
    
print(ans)

    




Measured memory_bytes: 13964
using System;
namespace ConsoleApplication1{
    class Program{
        static void Main(string[] args) {
            string[] s = Console.ReadLine().Split();
            int[] a = new int[5];
            for (int i = 0; i < 5; i++) {
                a[i]=int.Parse(s[i]);
            }
            Array.Sort(a);
            Array.Reverse(a);
            for (int i = 0; i < 4; i++) {
                Console.Write(a[i]+" ");
            }
            Console.WriteLine(a[4]);
        }
    }
}

Measured memory_bytes: 18044
#define _CRT_SECURE_NO_WARNINGS
#define forn(i, a, n) for(ll i = a; i < n; i++)

#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<iomanip>
#include<cassert>
#include<stack>
#include<deque>
#include<list>
#include<sstream>
#include<unordered_map>
#include<time.h>
#include<functional>
#pragma comment(linker, "/STACK:8809999999")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef pair<ld, ld> pld;
typedef pair<pll, ll> ppll;
typedef pair<pll, pll> ppp;
typedef vector<vector<vector<ll>>> vvv;
const ll mod = 1e9 + 7;
const ld eps = 1e-9;
const ll settled = 400007;



int main()
{
	ios_base::sync_with_stdio(false); cout.tie(NULL);
#ifndef overlord
	/*freopen("capitals.in", "r", stdin);
	freopen("capitals.out", "w", stdout);*/
#else
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ll n, k;
	cin >> n >> k;
	ll sum = (n + 1) / 2;
	if (sum >= k)
		cout << "YES";
	else
		cout << "NO";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip> 
using namespace std; 
#define rep(i,a,b)		for(long int i=a;i<=b;i++)
#define MOD 1e9+7

int n,m,x,a=0,b=0,temp;
vector<int> check(102);
int main() 
{ 
	ios::sync_with_stdio(false);
    cin.tie(NULL);  
    
	cin>>n>>m>>x;
	rep(i,1,m)
		cin>>temp,check.emplace_back(temp);
	for(auto it:check)
	{
		if(it<x and it!=0)
			a++;
		else if(it>x and it!=0)
			b++;
	}
	//cout<<a<<" "<<b<<" "<<endl;
	cout<<min(a,b);

}
	

Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
//#include <string>
//#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
#include <math.h>
using namespace std ;
//using ll = long long ;
using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
long double pie = acos(-1) ;

//string yorn(bool a){if(a) return"Yes" ; return "No" ;}
//string YorN(bool a){if(a) return"YES" ; return "NO" ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	ld a,b,x ;
	cin >> a >> b >> x ;
	if(x/a<=a*b/2){
		ld c = x/a*2/b ;
		ld d = sqrt(c*c+b*b) ;
		ld h = x/a*2/d ;
		cout << fixed << setprecision(15) << acos(h/b)/pie*180 << endl ;
	}else{
		ld s = a*b-x/a ;
		ld c = s*2/a ;
		ld d = sqrt(a*a+c*c) ;
		cout << fixed << setprecision(15) << acos(a/d)/pie*180 << endl ;
	}
}


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

int main(){
  string S;
  string T;
  int ans = 0;
  cin >> S >> T;
  for (int i = 0; i < S.size(); i++){
    if (S[i] != T[i]){
      ans += 1;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3892