akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s; cin >> s;
  set<string> st = {"KIHBR",
                    "AKIHBR", "KIHABR", "KIHBAR", "KIHBRA",
                    "AKIHABR", "AKIHBAR", "AKIHBRA", "KIHABAR", "KIHABRA", "KIHBARA",
                    "AKIHABAR", "AKIHABRA", "AKIHBARA", "KIHABARA",
                    "AKIHABARA"};
  if(st.count(s)) cout << "YES" << endk;
  else cout << "NO" << endk;
  return 0;
}


Measured memory_bytes: 3608
package main

import (
	"fmt"
)

func main() {
	var a, b string
	fmt.Scanf("%s %s", &a, &b)
	if (a == "H" && b == "H") || (a == "D" && b == "D") {
		fmt.Println("H")
	} else {
		fmt.Println("D")
	}
}


Measured memory_bytes: 512
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <bitset>
using namespace std;

typedef long long ll;
map<ll, ll> mp;

int prime_factorize(ll n) {

  for (ll i = 2; i * i <= n; i++) {
    if (n % i != 0) continue;
    ll ex = 0;
    while (n % i == 0) { ++ex; n /= i; }

    if (mp.find(i) == mp.end()) mp[i] = ex;
    else mp[i] += ex;
    
  }
  if (n != 1) {
    if (mp.find(n) == mp.end()) mp[n] = 1;
    else mp[n] += 1;
  }
  return 0;
}

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

  int N;
  cin >> N;

  while (N > 0) {
    prime_factorize(N);
    N--;
  }

  ll ans = 0;

  ll n74, n24, n14, n4, n2;
  n74 = n24 = n14 = n4 = n2 = 0;
  for (auto itr = mp.begin(); itr != mp.end(); itr++) {
    if (itr->second >= 74) n74++;
    if (itr->second >= 24) n24++;
    if (itr->second >= 14) n14++;
    if (itr->second >= 4) n4++;
    if (itr->second >= 2) n2++;
  }

  // 4-4-2
  ans += (n4*(n4-1)/2) * (n2-2);
  
  // 14-4
  ans += n14 * (n4 - 1);
  
  // 24-2
  ans += n24 * (n2 - 1);

  // 74
  ans += n74;
    
  cout << ans << endl;
  return 0;
}








Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, s, n) for (ll i = s; i < (n); i++)
using namespace std;

int main(){
  ll x, k, d;
  cin >> x >> k >> d;
  x = abs(x);
  ll a1 = x / d; // 移動回数
  ll a2 = x % d; // 移動後の座標
  ll ans;
  if (k < a1) ans = x - k * d;
  else {
    if ((k + a1) % 2 == 0) ans = a2;
    else ans = abs(a2-d);
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3632
package main

import (
	"fmt"
	"sort"
)

func inputSlice(inputNums int) []int {
	var ary []int
	for i := 0; i < inputNums; i++ {
		var in int
		fmt.Scan(&in)
		ary = append(ary, in)
	}
	return ary
}

func main() {
	var n int
	fmt.Scan(&n)

	A := inputSlice(n)
	ary := append([]int{}, A...)
	sort.Sort(sort.Reverse(sort.IntSlice(ary)))
	for i := 0; i < n; i++ {
		max := ary[0]
		if max == A[i] {
			max = ary[1]
		}
		fmt.Println(max)
	}
}


Measured memory_bytes: 8964
lst = [[1, 2, 1, 2, 1, 4, 1, 4],
       [1, 2, 1, 4, 1, 4, 1, 2],
       [1, 4, 1, 2, 1, 2, 1, 4],
       [1, 4, 1, 4, 1, 2, 1, 2],
       [2, 1, 2, 1, 4, 1, 4, 1],
       [2, 1, 4, 1, 4, 1, 2, 1],
       [4, 1, 2, 1, 2, 1, 4, 1],
       [4, 1, 4, 1, 2, 1, 2, 1]]

while True:
    try:
        inputlst = list(map(int, input().split()))
        
        m = 70000
        ans = 0
        for num, i in enumerate(lst):
            n = 0
            for j, k in zip(inputlst,i):
                if j > k:
                    n = n + (j - k)

            if m > n:
                m = n
                ans = num

        print(*lst[ans])

    except EOFError:
        break


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

int main() {
  long long N,ans=0;
  cin>>N;
  vector<long long> a(N+1);
  vector<long long> b(N);
for(int i=0;i<=N;i++){
  cin>>a.at(i);
}
  for(int i=0;i<N;i++){
    cin>>b.at(i);
  }
  for(int i=0;i<N;i++){
    if(a.at(i)>=b.at(i)){
      ans+=b.at(i);
      continue;
    }
    else if(a.at(i)+a.at(i+1)>b.at(i)){
      ans+=b.at(i);
      a.at(i+1)-=b.at(i)-a.at(i);
      continue;
    }
    else{
      ans+=a.at(i)+a.at(i+1);
      a.at(i+1)=0;
      continue;
    }
  }
  
  cout <<ans << endl;
}


Measured memory_bytes: 1792
def main():
    from sys import setrecursionlimit, stdin, stderr
    from os import environ
    from collections import defaultdict, deque, Counter
    from math import ceil, floor
    from itertools import accumulate, combinations, combinations_with_replacement
    setrecursionlimit(10**6)
    dbg = (lambda *something: stderr.write("\033[92m{}\033[0m".format(str(something)+'\n'))) if 'TERM_PROGRAM' in environ else lambda *x: 0
    input = lambda: stdin.readline().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    P = 10**9+7
    INF = 10**18+10

    N = II()
    A = LMIIS()
    A.sort(reverse=True)
    alice = sum(A[0::2])
    bob = sum(A[1::2])
    print(alice-bob)
    
main()

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int main() {
  int N;
  cin >> N;
  if(N>=1000)
    cout << "ABD" << endl;
  else
    cout << "ABC" << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int H = scanner.nextInt();
        int W = scanner.nextInt();
        int h = scanner.nextInt();
        int w = scanner.nextInt();

        int black = 0;
        black = h * W + w * H;
        black -= h * w;
        int white = H * W - black;

        System.out.print(white);
    }
}

Measured memory_bytes: 23636
#include<iostream>
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl '\n'
using namespace std;
int main()
{
    fastio;
    long long h,w,i,j,mod=1e9+7;
    cin>>h>>w;
    string a[h];
    long long matrix[h+1][w+1]={0};
    memset(matrix,0,sizeof(matrix));
    for(i=0;i<h;i++)
    {
        cin>>a[i];
    }
    for(i=0;i<h;i++)
    {
        for(j=0;j<w;j++)
        {
            if(i==0 && j==0)
            {
                matrix[i+1][j+1]=1;
            }
            else if(a[i][j]=='.')
            {
                matrix[i+1][j+1]=((matrix[i][j+1]%mod)+(matrix[i+1][j]%mod))%mod;
            }
            else if(a[i][j]=='#')
            {
                matrix[i+1][j+1]=0;
            }
        }
    }
    cout<<matrix[h][w]%mod;
    return 0;
}


Measured memory_bytes: 9088
MOD = 10**9+7
def inverse(x)
    inv = 1
    inn = x
    (MOD-2).to_s(2).reverse.chars do |z|
        inv = (inv * inn)% MOD if z == '1'
        inn = (inn * inn)% MOD
    end
    inv
end
n,k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
a.sort!.reverse!
ans = 0
com = 1

(1).upto(n-k+1) do |i|
    ans += (a[n-k+1-i]*com)%MOD
    ans -= (a[i+k-2]*com)%MOD
    com = (com * (i+k-1) *  inverse(i) )% MOD 
end
puts ans % MOD

Measured memory_bytes: 11260
#include <stdio.h>

int search(int A[],int n,int a){
  int i = 0;
  A[n] = a;
  while(A[i] != a ) i++;
  return i != n;
}

int main(){
  int i,n,A[10000+1],q,key,sum = 0;

  scanf("%d",&n);
  for(i = 0;i < n;i++)
    scanf("%d",&A[i]);

  scanf("%d",&q);
  for(i = 0;i < q;i++){
    scanf("%d",&key);
    if(search(A,n,key))sum++;
  }
  printf("%d\n",sum);

  return 0;
}



Measured memory_bytes: 2104
#include<stdio.h>
int main(void){
    int N, K;
    scanf("%d %d",&N, &K);
    if(N % 2 == 0){
        if(K <= N/2) printf("YES\n");
        else printf("NO\n");
    }else{
        if(K <= N/2+1) printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(2e4 + 5);
const ll MOD = (ll)(1e9 + 7);

/////////////////////////////////////////////////////////////
class CombinationModulo {
public:
  static const int MAX_N_LIB = (int)(2e5 + 100);
  static const ll MOD_LIB = (ll)(1e9 + 7);

  ll fact[MAX_N_LIB];
  ll inv[MAX_N_LIB];
  ll fact_inv[MAX_N_LIB];

  CombinationModulo(int n) {
    init(n);
  }

  void init(int n) {
    inv[1] = fact[0] = fact_inv[0] = 1;
    for (int i = 2; i <= n; i++) {
      inv[i] = (MOD_LIB - (MOD_LIB / i) * inv[MOD_LIB % i] % MOD_LIB) % MOD_LIB;
    }
    for (int i = 1; i <= n; i++) {
      fact[i] = fact[i - 1] * i % MOD_LIB;
    }
    for (int i = 1; i <= n; i++) {
      fact_inv[i] = fact_inv[i - 1] * inv[i] % MOD_LIB;
    }
  }

  ll comb(int n, int r) {
    if (r > n) return 0;
  	return fact[n] * fact_inv[r] % MOD_LIB * fact_inv[n - r] % MOD_LIB;
  }
};
/////////////////////////////////////////////////////////////

int n, k;

CombinationModulo cm(MAX_N);

ll calc(int cur_k) {
  ll base = cm.comb(n - k + 1, cur_k);

  // if (k % cur_k == 0) return base;

  ll remain = (ll)(k - cur_k);

  ll add = cm.comb(cur_k + remain - 1, remain);

  return (base * add) % MOD;
}

int main(void) {
  // Here your code !
  scanf("%d %d", &n, &k);

  for (int i = 1; i <= k; ++i) {
    printf("%lld\n", calc(i));
  }

  return 0;
}


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

using namespace std;

template <class T>inline T updmax(T& a, T b) {return a = max(a, b);}
template <class T>inline T updmin(T& a, T b) {return a = min(a, b);}

class Solution {
public:
	bool query1(int s, int n){
		cout << "? ";
		for(int i=0; i<n; i++)cout << (s + i) % (2 * n) + 1 << " ";
		cout << endl;
		string ret;
		cin >> ret;
		if(ret == "Red")return true;
		return false;
	}

	bool query2(int k, int s, int n){
		cout << "? " << k + 1<< " ";
		for(int i=0; i < n-1; i++)cout << (s + i) % (2 * n) + 1 << " ";
		cout << endl;
		string ret;
		cin >> ret;
		if(ret == "Red")return true;
		return false;
	}

	void solve() {
		int n;
		cin >> n;
		int l = 0, r = n;
		bool c0 = query1(0, n);
		while(r-l > 1){
			int mid = (l+r)/2;
			if(query1(mid, n) == c0)l = mid;
			else r = mid;
		}
		vector<bool> ans(2*n);
		ans[l] = c0;
		ans[(l+n)%(2*n)] = 1-c0;
		for(int i=0; i < n-1; i++){
			ans[(l+n+i+1)%(2*n)] = query2((l+n+i+1)%(2*n), l+1, n);
			ans[(l+1+i)%(2*n)] = query2((l+1+i)%(2*n), l+n+1, n);
		}
		cout << "! ";
		string sans;
		for(int i=0; i<2*n; i++){
			if(ans[i])cout << "R";
			else cout << "B";
		}
		cout << endl;
		
		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 724
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;
int main()
{
	int a; 
	int b;
	cin >> a >> b;
	int n = b;
	int i;
	for (i = 1; n; i=i*10)
	{
		n = n / 10;
	}
	a = a*i + b;
	if (sqrt(a) != (int)sqrt(a))
	{
		cout << "No" << endl;
	}
	else
	{
		cout << "Yes" << endl;
	}
	return 0;
}

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

struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) {}
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0)
            return x;
        else
            return par[x] = root(par[x]);
    }

    bool issame(int x, int y) { return root(x) == root(y); }

    bool merge(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);  // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) { return -par[root(x)]; }
};

int main() {
    long long N, M;
    cin >> N >> M;
    vector<int> A(M), B(M);
    for (int i = 0; i < M; ++i) {
        cin >> A[i] >> B[i];
        --A[i], --B[i];
    }

    UnionFind uf(N);
    rep(i, M) { uf.merge(A[i], B[i]); }
    int ans = 0;
    rep(i, N) ans = max(ans, uf.size(i));
    cout << ans << endl;
}

Measured memory_bytes: 5608
#include <iostream>

#define maxn 1005
using namespace std;

int a[maxn];
bool flag;

int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{ 
		cin>>a[i];
		if(a[i]%2==0)
			if(!(a[i]%3==0||a[i]%5==0))
				flag=true;
	}
	if(!flag) cout<<"APPROVED"<<endl;
	else cout<<"DENIED"<<endl;
	return 0;
}


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  lli n, hp;
  while (cin >> n >> hp) {
    vector<pair<lli, lli>> v(n);
    for (int i = 0; i < n; ++i) {
      cin >> v[i];
    }
    sort(v.begin(), v.end());
    pair<lli, lli> p = v.back();
    v.pop_back();

    vector<lli> u;
    each (i, v) {
      if (p.first < i.second) u.push_back(i.second);
    }

    lli cnt = 0;
    sort(u.begin(), u.end());
    while (u.size() && u.back() <= hp) {
      if (hp <= p.second) {
        break;
      }
      hp -= u.back();
      u.pop_back();
      ++cnt;
    }
    if (hp <= 0) {
      cout << cnt << endl;
      continue;
    }

    lli x = u.size() ? max(p.second, u.back()) : p.second;
    if (hp <= x) {
      cout << cnt + 1 << endl;
      continue;
    }

    lli y = (hp - p.second) / p.first;
    cnt += y;
    hp -= y * p.first;
    for (lli i = 0; i < 100; ++i) {
      lli z = hp - (p.first * i) - p.second;
      if (z <= 0) {
        cnt += i + 1;
        break;
      }
    }
    cout << cnt << endl;
  }

  return 0;
}


Measured memory_bytes: 2936
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace::std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/numeric/interval.hpp>
#include <boost/numeric/interval/io.hpp>
#include <boost/intrusive/rbtree.hpp>
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/linestring.hpp>
#include <boost/geometry/geometries/polygon.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
using namespace __gnu_pbds;
using namespace::std;
namespace mp = boost::multiprecision;
typedef mp::number<mp::cpp_dec_float<0>> cfloat;
typedef mp::cpp_int cint;
typedef long long lint;
typedef long long ll;
typedef long double ldouble;
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<double> dvec;
typedef vector<vector<double>> dmat;
typedef vector<vector<vector<double>>> dmat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
typedef vector<vector<vector<string>>> smat3;
typedef vector<pair<lint,lint>> pvec;
typedef vector<vector<pair<lint,lint>>> pmat;
typedef vector<vector<vector<pair<lint,lint>>>> pmat3;
#define rep(i, n) for(lint i = 0; i < (lint)(n); i++)
#define irep(i) for(lint i = 0;; i++)
#define irep1(i) for(lint i = 1;; i++)
#define irep2(i) for(lint i = 2;; i++)
#define rrep(i, n) for(lint i = (lint)(n-1); i >-1; i--)
#define rrepi(i,a,b) for(lint i = (lint)(b-1); i >a-1; i--)
#define repi(i,a,b) for(lint i=lint(a);i<lint(b);i++)
#define rep2(i,a,b,c) for(lint i=lint(a);i>lint(b);i+=c)
#define all(x) (x).begin(),(x).end()
#define PI 3.141592653589793
#define dist(x1,y1,x2,y2) (pow(pow(x2-x1,2)+pow(y2-y1,2),0.5))
#define output(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"");if(i>INF/2)cout<<"INF";else cout<<i;f=1;}cout<<"\n";}while(0)
#define output2(v) for(auto j:v)output(j);
#define input(a,n) lint n;cin>>n;vector<lint>a(n);rep(i,n)cin>>a[i];
#define SUM(v) accumulate(all(v),0LL)
#define INF (1LL<<60)
#define IINF (1<<30)
#define EPS (1e-10)
#define LINF 9223372036854775807
#define MOD 1000000007
#define endl "\n"
template<typename T=lint>T in(){return *istream_iterator<T>(cin);}
inline lint gcd(lint a,lint b){return b?gcd(b,a%b):a;}
inline lint lcm(lint a,lint b){return a*b/gcd(a,b);}
inline bool chmin(auto& s,const auto& t){bool res=s>t;s=min(s,t);return res;}
inline bool chmax(auto& s,const auto& t){bool res=s<t;s=max(s,t);return res;}
vector<lint> dx={-1,1,0,0,1,1,-1,-1};
vector<lint> dy={0,0,-1,1,1,-1,1,-1};

int main(){
    lint h,w,a,b;
    cin>>h>>w>>a>>b;
    mat v(h,vec(w,0));
    rep(i,b)rep(j,a){
        v[i][j]=1;
    }
    repi(i,b,h)repi(j,a,w){
        v[i][j]=1;
    }
    rep(i,h){
        rep(j,w)cout<<v[i][j];
        cout<<endl;
    }
}

Measured memory_bytes: 9088
/**/
/*
 * 	Meet me on the battlefield
*/
#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#ifndef rd
#define endl '\n'
#endif
#define deb cout<<"Line: "<<__LINE__<<" plz "
#define pb push_back
#define fi first
#define se second
#define int long long
typedef long long ll;
#define pii pair<int,int>
#define sz(x) ((int)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define all(con) con.begin(),con.end()
const int inf=1e9;
const int mod=998244353;
#define dpr(x) cout<<#x<<": "<<x<<endl
typedef vector<int> vi;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int dp[4005][4005];
int n;
int a[4005][2];
string s;
void solve()
{
	cin>>s;
	int n=s.length();
	for(int i=1; i<=n; i++) {
		a[i][0]=s[i-1]-'0'+a[i-1][0];
		a[i][1]='2'-s[i-1]+a[i-1][1];
	}
	for(int i=n+1; i<=2*n; i++) {
		a[i][0]+=a[i-1][0];
		a[i][1]+=a[i-1][1];
	}
	dp[0][0]=1;
	for(int i=1; i<=2*n; i++) {
		for(int j=0; j<=i; j++) {
			if(j>0&&a[i][0]>=j) {
				dp[i][j]+=dp[i-1][j-1];
			}
			if(a[i][1]>=i-j) {
				dp[i][j]+=dp[i-1][j];
			}
			dp[i][j]%=mod;
		}
	}
	ll ans=0;
	for(int i=0; i<=2*n; i++)
		ans+=dp[2*n][i];
	ans%=mod;
	cout<<ans<<endl;
}
signed main() {
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	srand(chrono::steady_clock::now().time_since_epoch().count());
	auto clk=clock();
	int t=1;
//	cin>>t;
	while(t--)
		solve();
#ifdef rd
	cout<<endl<<endl<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
#endif
	return 0;
}
/**/


Measured memory_bytes: 123776
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
#include <float.h>
#include <math.h>
#include <sstream>
using namespace std;
// repマクロの定義
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// allマクロの定義
#define all(v) v.begin(), v.end()
const  long long INF = 1LL << 60;
typedef unsigned long long ll;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int ctoi(char c) {
 	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}


int main(){ 
int N,K; cin >> K >> N;
vector<int> A(2*N);
rep(i,N) cin >> A[i];
for(int i = N; i < 2*N;i++){
	A[i] = A[i-N] + K;
}
int k = K+1;
rep(i,N){
	chmin(k,A[i+N-1]-A[i]);
}
cout << k << endl;
}


Measured memory_bytes: 1792
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;

fn main() {
    let s:Vec<char> = read::<String>().chars().collect();
    let k:i64 = read();

    let mut idx:i64 = 0;
    for (i, &ch) in s.iter().enumerate() {
        if ch != '1' {
            idx = i as i64;
            break;
        }
    }

    println!("{}", if k <= idx {'1'} else {s[idx as usize]});

}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int, int>;

int main()
{
    string s;
    cin >> s;
    int r = 0;
    int b = 0;
    rep(i, s.size()) {
        if(s[i] == '0') r++;
        else b++;
    }
    cout << 2 * min(r, b) << endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
#define max(a,b) a > b ? a : b
using namespace std;
using ll = long long;

class unionfind{
    public:
    vector<int> par,rank,size;
    
    unionfind(int n){
        par.resize(n);
        rank.resize(n);
        size.resize(n);

        rep(i,n){
            par[i] = i;
            rank[i] = 0;
            size[i] = 1;
        }
    }

    int getSize(int x){
        return size[x];
    }

    int find(int x){
        int m = max(size[x],size[par[x]]);
        size[x] = m;
        size[par[x]] = m;
        if(par[x]==x) return x;
        else return par[x] = find(par[x]);
    }

    void unite(int x,int y){
        x = find(x);
        y = find(y);
        if(x == y) return;

        if(rank[x] < rank[y]){
            par[x] = y;
        }else{
            par[y] = x;
            if(rank[x] == rank[y]) rank[x]++;
        }
        int sx = size[x];
        int sy = size[y];
    size[x] = sx+sy;
    size[y] = sx+sy;
    }

    bool same(int x,int y){
        return find(x) == find(y);
    }
};

    vector<int> like[100010];
    vector<int> block[100010];

int main(){
    int n,m,k;
    cin >> n >> m >> k;
    unionfind uf(n);
    
    int f,t;
    
    rep(i,m){
        cin >> f >> t;
        f--; t--;
        like[f].push_back(t);
        like[t].push_back(f);
        uf.unite(f,t);
    }

    rep(i,k){
        cin >> f >> t;
        f--; t--;
        block[f].push_back(t);
        block[t].push_back(f);
    }
rep(i,n){
    uf.find(i);
}
    rep(i,n){
        int ll = 0,bb=0;
        rep(j,like[i].size()){
            if(uf.same(i,like[i][j])) ll++;
        }
        rep(j,block[i].size()){
            if(uf.same(i,block[i][j])) bb++;
        }
        int ans = max(0,uf.size[i] - ll - bb - 1);
        cout << ans;
        if(i != n-1) cout << " ";
    }
    cout << endl;
    return 0;
}


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

signed main(){
  int x; cin >> x;
  int ans;
  int c = x % 11, c1 = x/11;
  if(c == 0) ans = c1 * 2;
  else if(c <= 6){
    ans = c1 * 2 + 1;
  }
  else if(c > 6) ans = c1 * 2 + 2;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;


int main(){
  string s; cin >> s; ll count = 0; ll countmax = 0;
  rep(i,s.size()){
    if(s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C') count++;
    else {
      countmax = max(countmax,count);
      count = 0;
    }
  }
  
  cout << max(count,countmax) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=1e5+5;

int n, x, ans=0;
int a[N];

int32_t main()
{
	IOS;
	cin>>n>>x;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
	{
		int cur=a[i] + a[i-1];
		ans+=max(0LL, cur-x);
		a[i]-=max(0LL, cur-x);
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;

string arr[] = {"Sunny", "Cloudy", "Rainy"};

map<string, string> m;

int main() {
    string s;

	cin>>s;

	m["Sunny"] =  "Cloudy";
	m["Cloudy"] =  "Rainy";
	m["Rainy"] =  "Sunny";

	cout<<m[s];

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define mod 1000000007
using namespace std;

ll dp[102][100005];

int main(){
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);cout.tie(NULL);
	int n,w;
	cin>>n>>w;

	vector<pair<int,int> > a(n);
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i].ff>>a[i].ss;
	}
	for(int i=0;i<=w;++i)
		dp[0][i] = 0;
	for(int i=1;i <= n;++i){
		for(int j=0;j<=w;++j){
			dp[i][j] = dp[i-1][j];
			if(j>=a[i-1].ff)
				dp[i][j] = max(dp[i][j],dp[i-1][j-a[i-1].ff]+a[i-1].ss);
		}
	}
	ll ans=0;
	for(int i=0;i<=w;++i)
		ans = max(ans,dp[n][i]);
	cout<<ans;
	// cerr<< '\n' << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms\n" ;
	return 0;
}

Measured memory_bytes: 79232
N, M = gets.split.map(&:to_i)
queries = M.times.map { gets.split.map(&:to_i) }

counter = Hash.new(0)

queries.each do |a, b|
  counter[a] += 1
  counter[b] += 1
end

if counter.values.all? { |n| n.even? }
  puts 'YES'
else
  puts 'NO'
end


Measured memory_bytes: 15868
# -*- coding: utf-8 -*-

# -*- coding: utf-8 -*-

# -*- coding: utf-8 -*-
from sys import stdin

###########################################
# delete here


############################################
#from sys import stdin
import numpy as np

# read data for n sequences.
N = int(stdin.readline().split()[0])
data = str(stdin.readline().split())

count = 0

for let in data:
    if let == "R":
        count += 1

if count > N-count:
    print("Yes")
else:
    print("No")

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

int main()
{
    int n,a,b = 0;
    
    cin >> n;
    
    a = n/10;
    b = n-10*a;
    
    if(a == 9||b == 9){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

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


int main(){
    long long ans = 0;
    vector<pair<long long, long long>> cans;
    long long n, m;
    cin >> n >> m;
    for(int i = 0; i < n; i++){
        int a, b;
        cin >> a >> b;
        cans.push_back({a,b});
    }
    sort(cans.begin(), cans.end());
    int j = 0;
    while(m > 0){
        long long am = min((long long)m, cans[j].second);
        m -= am;
        ans += am*cans[j].first;
        j++;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 2420
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cstdio>
#define LL long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
int n,m,ans;
int h[40];
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		int k;
		cin>>k;
		for(int i=1,x;i<=k;i++){
			cin>>x;
			h[x]++;
		}
	}
	for(int i=1;i<=m;i++)if(h[i]==n)ans++;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int n, sum, mins;

	scanf("%d", &n);
	sum = 0;
	mins = 101;
	while (n--) {
		int s;

		scanf("%d", &s);
		sum += s;
		if (s % 10 && mins > s)
			mins = s;
	}
	printf("%d\n", sum % 10 ? sum : mins != 101 ? sum - mins : 0);
	return 0;
}


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

public class Main{
  public static void main(String[] args)throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    try{
      int N = Integer.parseInt(br.readLine());
      System.out.println(2*N*Math.PI);
    }catch(Exception e){
      System.out.println(e.toString());
    }
  }
}


Measured memory_bytes: 33236
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int h, w;
    cin >> h >> w;
    int a, b;
    cin >> a >> b;
    cout << h * w - a * w - b * h + a * b << endl;   
}

Measured memory_bytes: 256
N=int(input())
ans=""
check="abcdefghijklmnopqrstuvwxyz"

while N!=0:
	N-=1
	ans+=check[N%26]
	N=N//26

print(ans[::-1])
"""
while N>0:
	N-=1
	ans+=chr(ord("a")+ N%26)
	N//=26
print(ans[::-1])
"""




Measured memory_bytes: 9168
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int A,P;
  cin>>A>>P;
  cout<<(A*3+P)/2<<endl;
  return 0;
}


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

int memo[45] = {0};

int Fibonacci(int n) {
  if(n == 0 || n == 1) return memo[n] = 1;
  if(memo[n] != 0) { // memo[n]????¨??????????
	return memo[n];
  }
  return memo[n] = Fibonacci(n - 2) + Fibonacci(n - 1);
}

int main() {
  int n;
  cin >> n;
  cout << Fibonacci(n) << endl;
  return 0;
}

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

int main(){
  int n;
  cin>>n;
  bool ad=false;
  for(int i=0;i<100;i+=4){
    for(int j=0;j<100;j+=7){
      if(i+j==n){
        ad=true;
      }
    }
  }
  if(ad) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}
  


Measured memory_bytes: 3624
#include "bits/stdc++.h"
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
using namespace std;


bool use[101010]={0};

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

vector<ll> x(N);
for(ll i=0;i<N;i++)cin>>x[i];

ll ans =0;
for(ll i=0;i<N;i++){
if((x[i]>abs(x[i]-K))){
  ans+=abs(x[i]-K);
}
else
ans += x[i];


}
cout<<(2*ans)<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <limits.h>

int main(void){
    char s[120];
    long long k;
    int count=0;
    scanf("%s%lld",s,&k);
    for (int i=0; i<strlen(s); i++){
        if (s[i]=='1'){
            count++;
        } else {
            break;
        }
    }
    if (k<=count){
        printf("1\n");
    } else {
        printf("%c\n",s[count]);
    }
	return 0 ;
}

Measured memory_bytes: 128
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

        int N = Integer.parseInt(br.readLine());
        List<Integer> X = Arrays.stream(br.readLine().split(" "))
                .mapToInt(Integer::parseInt)
                .boxed()
                .collect(Collectors.toList());

        List<Integer> sortedX = new ArrayList<>(X);
        sortedX.sort(null);

        for(Integer v : X){
            int idx = Collections.binarySearch(sortedX, v);
            if(idx < N / 2){
                bw.write(String.format("%d\n", sortedX.get(N / 2)));
            }else{
                bw.write(String.format("%d\n", sortedX.get(N / 2 - 1)));
            }
        }

        bw.flush();
    }
}

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

int main(){
  int n,hmax,ans=0,h;cin>>n>>hmax;h=hmax;
  vector<int> a(n,0),b(n,0);
  REP(i,n) cin>>a.at(i)>>b.at(i);
  sort(a.begin(),a.end(),greater<int>());
  sort(b.begin(),b.end(),greater<int>());

  REP(i,n){
    if(a.at(0)<b.at(i)){
      h-=b.at(i);
      ans++;
      if(h<=0) break;
    }
  }
  if(h>0) ans+=(h+a.at(0)-1)/a.at(0);
  ans=min(ans,(hmax+a.at(0)-1)/a.at(0));  

  cout<<ans;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < n; ++i)
#define FORR(i, m, n) for (ll i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int gcd(int a,int b){
    return (b?gcd(b,a%b):a);
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;cin >> n >> k;
    int g=0;
    int mx=0;
    REP(i,n){
        int a;cin >> a;
        g=gcd(g,a);
        chmax(mx,a);
    }
    if(k>mx){
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    cout << (k%g==0?"POSSIBLE":"IMPOSSIBLE") << endl;
}

Measured memory_bytes: 3636
apple = []
min = 100
flag = 0
n, l = map(int, input().split())
for i in range(n):
        apple.append(l+i)
for i in apple:
        if abs(i) <= min:
                if i >= 0:
                        flag = 0
                else:
                        flag = 1
                min = abs(i)
if flag == 0:
        print(sum(apple) - min)
else:
        print(sum(apple) + min)

Measured memory_bytes: 3064
#include<iostream>
#include<cmath>
#include<string>
#include<fstream>
#include<vector>
#include<algorithm>
using namespace std;

int main()
{
    int h, w;
    cin>>h>>w;
    char sq[h][w];
    bool is_wr[h];
    bool is_wc[w];
    for(int i=0; i<h; i++)
    {
        is_wr[i]=true;
        for(int j=0; j<w; j++)
        {
            cin>>sq[i][j];
            if(sq[i][j]=='#') is_wr[i] = false;
        }
    }
    for(int j=0; j<w; j++)
    {
        is_wc[j]= true;
        for(int i=0; i<h; i++)
        {
            if(sq[i][j]=='#') is_wc[j] = false;
        }
    }
    for(int i=0; i<h; i++)
    {
        for(int j=0; j<w; j++)
        {
            if(is_wr[i]||is_wc[j]) continue;
            else cout<<sq[i][j];
        }
        if(!is_wr[i]) cout<<endl;
    }
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string s1,s2,s3;
  cin >> s1 >> s2 >> s3;
  char dif = 'A'-'a';
  char x = s1[0]+dif;
  char y = s2[0]+dif;
  char z = s3[0]+dif;
  cout << x << y << z << endl;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

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

    vector<int> A(N), B(N);
    rep(i, N) cin >> A[i] >> B[i];

    vector<P> l, r;
    rep(i, N) {
        l.emplace_back(A[i], B[i]);
        r.emplace_back(B[i], A[i]);
    }
    sort(l.begin(), l.end());
    sort(r.begin(), r.end());

    double left = 0, right = 0;
    if (N % 2) {
        left = l[N/2].first;
        right = r[N/2].first;
    } else {
        left= (l[N/2-1].first + l[N/2].first) / 2.0;
        right = (r[N/2-1].first + r[N/2].first) / 2.0;
    }

    ll ans = 0;
    if (N % 2) {
        ans = right - left + 1;
    } else {
        ans = right - left + 1 + (right - left);
    }

    cout << ans << endl;
}

Measured memory_bytes: 8212
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAX 100100
inline int read()
{
    int x=0;bool t=false;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
    if(ch=='-')t=true,ch=getchar();
    while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
    return t?-x:x;
}
int n,C,K,T[MAX],ans,s,t;
int main()
{
    n=read();C=read();K=read();
    for(int i=1;i<=n;++i)T[i]=read();
    sort(&T[1],&T[n+1]);
    for(int i=1;i<=n;++i)
        if(!s)++ans,s=1,t=T[i];
        else
        {
            if(s==C)++ans,s=1,t=T[i];
            else
            {
                if(T[i]-t>K)++ans,s=1,t=T[i];
                else ++s;
            }
        }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Lesen std::ios::sync_with_stdio(false);std::cin.tie(0);

int N, M, maxi = 0;
map <int, int> mp;

void solve(void){
	Lesen;
	cin >> N;
	rep(N, i) {
		int d; cin >> d;
		mp[d] = mp[d-1]+1;
		maxi = max(maxi, mp[d]);
	}
	cout << N - maxi << endl;
}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <deque>
#include <iterator>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
  ll sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;
  REP(_, tx-sx) cout << 'R';
  REP(_, ty-sy) cout << 'U';
  cout << 'R';
  REP(_, ty-sy+1) cout << 'D';
  REP(_, tx-sx+1) cout << 'L';
  cout << "U";
  REP(_, ty-sy) cout << 'U';
  REP(_, tx-sx) cout << 'R';
  cout << "U";
  REP(_, tx-sx+1) cout << 'L';
  REP(_, ty-sy+1) cout << 'D';
  cout << "R" << endl;
  return 0;
}


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

using namespace std;

int main(){
    long long int N,M,sum=0;
    cin >> N >> M;
    vector<long long int> A(N);
    for(int i=0;i<M;i++){
        cin >> A[i];
        sum += A[i];
    }

    if(N<sum){
        cout << -1 << endl;
    }else{
        cout << N-sum << endl;
    }
}

Measured memory_bytes: 11124
t,*grid=open(0)
h,w=map(int,t.split())
vis=[[False]*w for _ in range(h)]
ans=0
for y in range(h):
	for x in range(w):
		if vis[y][x]:
			continue
		q=[(y,x)]
		d={"#":0,".":0}
		while q:
			cy,cx=q.pop(0)
			for ny,nx in ((cy+1,cx),(cy-1,cx),(cy,cx+1),(cy,cx-1)):
				if not (0<=ny<h and 0<=nx<w) or vis[ny][nx] or grid[cy][cx]==grid[ny][nx]:
					continue
				d[grid[ny][nx]]+=1
				vis[ny][nx]=True
				q.append((ny,nx))
		ans+=d["#"]*d["."]
print(ans)


Measured memory_bytes: 4468
#include<iostream>
#include<iomanip>
#include<cmath>
#include<algorithm>
using namespace std;
int A,B,H,M,K;
main()
{
	cin>>A>>B>>H>>M;
	K=H*60+M;
	double theta=K/2.-6*M;
	cout<<fixed<<setprecision(16)<<sqrt(A*A+B*B-2*A*B*cos(theta/180*3.1415926535897932384626))<<endl;
}


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


int main() 
{
    long long int n,ac=0,tle=0,wa=0,re=0;
    cin>>n;
    while(n--)
    {
         string s;
         cin>>s;
         if(s=="AC")
         ac++;
         if(s=="TLE")
         tle++;
         if(s=="WA")
         wa++;
         if(s=="RE")
         re++;
    }
    cout<<"AC x "<<ac<<"\n";
    cout<<"WA x "<<wa<<"\n";
    cout<<"TLE x "<<tle<<"\n";
    cout<<"RE x "<<re<<"\n";
}

Measured memory_bytes: 3568
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    
    if(s[5]!='0') cout<<"TBD"<<endl;
    else if(s[6]>='5') cout<<"TBD"<<endl;
    else cout<<"Heisei"<<endl;
    
 return 0;   
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int p[100010],ans,a,b;
int n,m;
int fifa(int x)
{
	if(p[x]==x)return x;
	int root=fifa(p[x]);
	return p[x]=root;
}
void join(int x,int y)
{
	int px=fifa(x);
	int py=fifa(y);
	if(px!=py)
	{
		p[px]=py;
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		{
			p[i]=i;
		}
		for(int i=1;i<=m;i++)
		{
			int x,y;
			scanf("%d%d",&x,&y);
			join(x,y);
		}
		for(int i=1;i<=n;i++)
		{
			if(fifa(i)==i)
			{
				ans++;
			}
		}
	printf("%d",ans-1);
	return 0;
}

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

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

fn add_char(c: char) -> char{
    std::char::from_u32(c as u32 + 1).unwrap_or(c)
}

fn main(){

    input!{
        c: chars,
    }

    println!("{}", add_char(c[0]));
}

Measured memory_bytes: 4352
using System;
using System.Collections.Generic;
using System.Linq;

static class PathOnAGrid
{
    static void Main()
    {
        var input = Console.In.ReadToEnd()
            .Split( 
                new[] { '\r', '\n' },
                StringSplitOptions.RemoveEmptyEntries )
            .Select( x => Array.ConvertAll( x.ToArray(), y => y == '1' ) )
            .Select( (x, i) => new { v = x, k = i & 1 } )
            .GroupBy( x => x.k, x => x.v )
            .Select( x => x.ToArray() )
            .ToArray();
        var m =
            from y in Enumerable.Range( 0, 5 )
            from x in Enumerable.Range( 0, 5 )
            select new[]
            {
                x < 4 && input[0][y][x],
                y < 4 && input[1][y][x],
                x > 0 && input[0][y][x - 1],
                y > 0 && input[1][y - 1][x],
            };
        var map = m.ToArray();
        var index = new Func<int, int, int>[]
        {
            (x, y) => x + y,
            (x, y) => x + y * 5,
            (x, y) => x - y,
            (x, y) => x - y * 5,
        };
        var route = Enumerable.Empty<char>();
        int p = 0, d = 0;
        do {
            var head = ( d + 3 ) & 3;
            var step = Enumerable.Range( 0, 5 )
                .Select( x => index[d]( p, x ) )
                .TakeWhile( x => map[x][d] && ( !map[x][head] || x == p ) )
                .Count();

            route = route.Concat( Enumerable.Repeat( "RDLU"[d], step ) );
            p = index[d]( p, step );
            d = map[p][head] ? head : ( d + 1 ) & 3;
        } while ( p != 0 );
        Console.WriteLine( new string( route.ToArray() ) );
    }
}

Measured memory_bytes: 6564