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

int main() {
  string s; cin >> s;
  if(s == "AAA" || s == "BBB") cout << "No" << endl;
  else cout << "Yes" << endl;
}


Measured memory_bytes: 3644
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>

const int N=10005;

int a,b,n,stack[N],ans[N];

int main()
{
    scanf("%d%d",&a,&b);
    if (a<=b) {printf("Impossible");return 0;}
    n=a+b;
    int top=0,re;
    for (int i=1;i<n;i++)
    {
        if (!top) {stack[++top]=i;continue;}
        printf("? %d %d\n",stack[top],i);
        fflush(stdout);
        char op[2];scanf("%s",op);
        if (op[0]=='N') top--;
        else stack[++top]=i;
    }
    re=stack[top];
    for (int i=0;i<n;i++)
    {
        printf("? %d %d\n",re,i);
        fflush(stdout);
        char op[2];scanf("%s",op);
        if (op[0]=='N') ans[i]=0;
        else ans[i]=1;
    }
    printf("! ");
    for (int i=0;i<n;i++) putchar(ans[i]+'0');
    puts("");
    return 0;
}

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

int main(){
  char b, ans;
  cin >> b;
  switch(b){
    case 'A':
      ans = 'T'; break;
    case 'T':
      ans = 'A'; break;
    case 'G':
      ans = 'C'; break;
    case 'C':
      ans = 'G'; break;
    default: break;
  }

  cout << ans << endl;
}

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

def count_digit(N):
    return(len(str(N)))

ans = count_digit(N)

A = 1
while (A * A <= N):
    if N%A != 0: pass
    else:
        B = N//A
        curDig = max(count_digit(A), count_digit(B))
    ans = min(ans, curDig)
    A += 1
print(ans)


Measured memory_bytes: 3060
#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;
typedef long long ll;

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

const ll INF = 1LL << 60;

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i, n) cin >> h[i];

    vector<ll> dp(n, INF);
    dp[0] = 0;

    for(int i = 1; i < n; i++) {
        chmin(dp[i], dp[i-1]+abs(h[i]-h[i-1]));
        if(i>1) chmin(dp[i], dp[i-2]+abs(h[i]-h[i-2]));
    }

    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<double, double> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

struct Query {
    char c, d;
};

std::istream &operator>>(std::istream &in, Query &o) {
    cin >> o.c >> o.d;
    return in;
}

// 落ちるヤツの数
int check(int n, string &s, vector<Query> &queries) {
    int floor = 0;
    int ceil = n - 1;

    function<bool(int)> ch = [&](int i) {
        int now = i;
        for (Query &q : queries) {
            if (q.c != s[now]) continue;
            else if (q.d == 'L') now--;
            else if (q.d == 'R') now++;
            if (now == -1) return false;
        }
        return true;
    };

    if (ch(floor)) {
        return 0;
    }
    if (!ch(ceil)) {
        return n;
    }

    while (floor + 1 < ceil) {
        int mid = (floor + ceil) / 2;
        bool b = ch(mid);
        if (b) ceil = mid;
        else floor = mid;
    }

    return floor + 1;

}

int main() {
    int n, q;
    cin >> n >> q;

    string s;
    cin >> s;

    vector<Query> queries(q);
    rep(i, q) cin >> queries[i];

    int l = check(n, s, queries);
    reverse(s.begin(), s.end());
    rep(i, q) queries[i].d = queries[i].d == 'L' ? 'R' : 'L';
    int r = check(n, s, queries);

    int ans = max(n - l - r, 0);


    cout << ans << endl;

}

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

int fa[1000006], dis[1000006];

int find(int x) {
	if (fa[x] == x) return x;
	int tmpfa = find(fa[x]);
	dis[x] += dis[fa[x]];
	return fa[x] = tmpfa;
}


bool add(int L, int R, int D) {
	if (find(L) == find(R)) {
		if (dis[L] - dis[R] != -1 * D) {
			cout << "No";
			return 0;
		}
		return 1;
	}
	int faR = fa[R], faL = fa[L];
	fa[faR] = fa[faL];
	dis[faR] = dis[L] + D - dis[R];
	return 1;
}


int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; ++i) fa[i] = i;
	
	for (int i = 1; i <= m; ++i) {
		int L, R, D;
		scanf("%d%d%d", &L, &R, &D);
		if (!add(L, R, D)) {
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}



Measured memory_bytes: 4864
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) cout<<(ans?"Yes":"No")<<endl
#define YN(ans) cout<<(ans?"YES":"NO")<<endl
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head, const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    int n;
    in(n);
    for(int i=1;i<=n;i++){
        int x=i;
        if (x % 3 == 0 ){
            cout << " " << i;
            continue;
        }else{
            string s=to_string(x);
            rep(j,s.length()){
                if(s[j]=='3'){
                    cout << " " << i;
                    break;
                }
            }
        }
    }
    cout << endl;
}



Measured memory_bytes: 3344
def dist(X, Y, p):
    res = 0
    for x, y in zip(X, Y):
        res += abs(x - y) ** p
    return res ** (1.0 / p)
    
n = int(raw_input())
X = map(int, raw_input().split())
Y = map(int, raw_input().split())
for i in [1, 2, 3]:
    print dist(X, Y, i)
print max(map(lambda xy: abs(xy[0] - xy[1]), zip(X, Y)))

Measured memory_bytes: 4296
s = list(input().split("T"))
x, y = map(int, input().split())
s2 = [len(x) for x in s]
LR = [s2[i] for i in range(len(s2)) if i % 2 == 0]
UD = [s2[i] for i in range(len(s2)) if i % 2 == 1]

flag = False
tmp = 1
tmp = tmp << sum(LR)
for i, d in enumerate(LR):
    if i != 0:
        tmp = tmp << d | tmp >> d
    else:
        tmp = tmp << d

if x >= 0:
    tmp = tmp >> sum(LR)
    if (tmp >> x) % 2 == 1:
        flag = True
else:
    if sum(LR) + x >= 0:
        if (tmp >> (sum(LR) + x)) % 2 == 1:
            flag = True
if flag:

    tmp = 1
    tmp = tmp << sum(UD)
    flag = False
    for d in UD:
        tmp = tmp << d | tmp >> d
    if y >= 0:
        tmp = tmp >> sum(UD)
        if (tmp >> y) % 2 == 1:
            flag = True
    else:
        if sum(UD) + y >= 0:
            if (tmp >> (sum(UD) + y)) % 2 == 1:
                flag = True

if flag:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3316
function Main(input) {
  var tmp = input.split('\n');
  var n = tmp[0];
  var arr = tmp[1].split(' ');
  for ( var i = 0; i < arr.length; i++) {
    arr[i] = parseInt(arr[i]);
  }

  arr = margeSort(arr);

  console.log(arr[arr.length / 2] - arr[arr.length / 2 - 1 ])

  

}

function margeSort(a) {
  var split = function(array) {
      //console.log('original: ' + array.toString());
      if (array.length < 2) {
        return array;
      }
      var a, b, mid = array.length / 2 | 0;
      a = split(array.slice(0, mid));
      b = split(array.slice(mid, array.length));
      return marge(array, a, b);
    },
    marge = function(array, a, b) {
      if (b === undefined) {
        return array;
      }
      var c = [], i, j;
      while (a.length > 0 && b.length > 0) {
        i = a[0], j = b[0];
        //console.log('marge: ' + a.toString() + ' <==> ' + b.toString());
        if (i < j) {
          c.push(a.shift())
        } else {
          c.push(b.shift())
        }
      }
      if (a.length === 0) {
        c = c.concat(b);
      } else if (b.length === 0) {
        c = c.concat(a);
      }
      return c;
    }
  return split(a);
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 28100
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.nextLine();
        int[] b = new int[n];
        int count = 0, maxCount = 0;
        for (int i = 0;i < n;i++){
            b[i] = sc.nextInt();
        }
        sc.nextLine();
        for (int i = 0; i < n - 1;i++){
            if (b[i] < b[i + 1]){
                if (maxCount < count){
                    maxCount = count;
                }
                count = 0;
            }else{
                count++;
            }
        }
        if (maxCount < count){
            maxCount = count;
        }
        System.out.println(maxCount);
    }
}

Measured memory_bytes: 50588
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p





N,M,K = map(int,input().split())
p = 998244353


fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

sum_color = 0
for k in range(K+1):
  num1 = cmb(N-1,k,p)
  num2 = M
  num3 = pow(M-1,N-1-k,p)
  sum_color += (num1*num2*num3)%p
  
print(sum_color%p)
  


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

double getDistance(vector<int> &vec1, vector<int> &vec2) {
  double sum = 0;
  for (int i = 0; i < vec1.size(); i++) {
    sum += pow(vec1.at(i) - vec2.at(i), 2);
  }
  return sqrt(sum);
}

int main() {
  int n, d;
  cin >> n >> d;
  vector<vector<int>> vec(n, vector<int>(d));

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < d; j++) {
      cin >> vec.at(i).at(j);
    }
  }

  int counter = 0;
  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      double distance = getDistance(vec.at(i), vec.at(j));
      if (floor(distance) == distance) {
        counter++;
      }
    }
  }
  cout << counter << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char **argv)
{
  int w, c;

  while(1){
    cin >> w;
    if(w == -1){
      break;
    }
    c = 1150;

    w -= 10;
    if(w <= 0){
      cout << (4280-c) << endl;
      continue;
    }

    w -= 10;
    if(w <= 0){
      cout << (4280-(c+(w+10)*125)) << endl;
      continue;
    }
    c += 1250;
    w -= 10;
    if(w <= 0){
      cout << (4280-(c+(w+10)*140)) << endl;
      continue;
    }
    c += 1400;

    cout << (4280-(c+160*w)) << endl;
  }

  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define erep(i,N) for(int i = N - 1; i >= 0; i--)
const ll INF = 1000000000;
//const ll MOD = 1000000007;
const ld PI = (acos(-1));
using Graph = vector<vector<int>>;
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;}
typedef pair<int, int> P;
typedef pair<ll,ll> PLL;
double rad(double a) {return a * 180 / PI;}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号 (例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

//dpTable
//int dp[100050];

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    rep (i,N) cin >> A.at(i);
    if (N != 1){
        sort (A.begin(),A.end());
        vector<bool> hoge(1000050,false);
        int ans = 0;
        bool huga = false;
        vector<int> mem;
        for (int i = 0; i < N - 1; i++) {
            if (A.at(i) == A.at(i + 1)) {
                huga = true;
                hoge.at(A.at(i)) = true;
            }
            else if (huga == true) {
                huga = false;
                continue;
            }
            else {
                mem.push_back(A.at(i));
            }
        }
        if (A.at(N - 2) != A.at(N - 1)) mem.push_back(A.at(N - 1));
        for (int i = 0; i < mem.size(); i++) {
            int sqrtmax = sqrt(mem.at(i));
            for (int j = 1; j <= sqrtmax; j++) {
                if (mem.at(i) % j == 0 && (hoge.at(j) || hoge.at(mem.at(i) / j))) break;
                else if (j == sqrtmax) {
                    ans++;
                }
            }
            hoge.at(mem.at(i)) = true;
        }
        cout << ans << endl;
    }
    else cout << 1 << endl;
    return 0;
}


Measured memory_bytes: 5212
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int64_t X;
  cin >> X;
  
  int64_t t = 100;
  
  for (int i = 0; i < 3760; i++) {
    
    t = t * 1.01;
    
    if (t >= X) {
      cout << i + 1 << endl;
      break;
    }
  }
}


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

using namespace std;

int main() {
    string s1, s2;
    cin >> s1 >> s2;
    int ans = 0;
    for (int i = 0; i < s1.length(); i++) {
        if (s1[i] != s2[i]) ans++;
    }
    cout << ans;
    return 0;
}



Measured memory_bytes: 3852
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(ll (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define opf(i) cout<<fixed<<setprecision(10)<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;

//
void solve(long long A, long long B, long long K){
  if(A<K)B=(B-(K-A));
  cout<<max(A-K,(ll)0)<<" "<<max(B,(ll)0)<<endl;
  
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long K;
    scanf("%lld",&K);
    solve(A, B, K);
    return 0;
}


Measured memory_bytes: 256
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <iostream>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

int n;
int x;
int as[1000];

int main(void) {
  cin >> n >> x;
  REP(i, n) {
    cin >> as[i];
  }
  sort(as, as+n);
  int res = 0;
  REP(i, n) {
    if(i == n-1) {
      if(as[i] == x) {
        ++res;
        x -= as[i];
      }
    } else {
      if(as[i] <= x) {
        ++res;
        x -= as[i];
      }
    }
  }
  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

	int n, m;
	cin >> n >> m;
	vvi dist(n, vi(n, INF));
	vvi e(n, vi(n, INF));
	vi aa(m), bb(m);

	rep(i, m) {
		int a, b, c;
		cin >> a >> b >> c;
		a--;b--;
		dist[a][b] = dist[b][a] = c;
		e[a][b] = e[b][a] = c;
		aa[i] = a; bb[i] = b;
	}

	rep(k, n)rep(i, n)rep(j, n)dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);

	int cnt = 0;
	rep(i, m)if (dist[aa[i]][bb[i]] < e[aa[i]][bb[i]])cnt++;
	
	cout << cnt << endl;

}

Measured memory_bytes: 384
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <functional>
#include <unordered_map>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define ALL(a)			(a).begin(),(a).end()
#define REP(i, n)		for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)	for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF				2e9
#define MOD				(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)		(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)		(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)	((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)		(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)		(!IsOdd((x)))						
#define M_PI			3.14159265358979323846
typedef long long		ll;
typedef pair<ll, ll>	P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int main()
{
	int N;
	cin >> N;
	vector<int> C(N), S(N), F(N);
	REP(i, N - 1) cin >> C[i] >> S[i] >> F[i];

	REP(stPos, N) {
		int ans = 0;
		REPN(i, stPos, N - 1) {
			ans = CeilN(ans, F[i]);
			ans = max(ans, S[i]);
			ans += C[i];
		}
		cout << ans << endl;
	}

	return 0;

}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::collections::VecDeque;
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::collections::HashMap;

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

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

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

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

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("parse error")
    };
}

fn main() {
    input!{
        s: chars,
        n: chars,
    }
    let f = (0..s.len()).any(|i| s[i] != n[i]);
    println!("{}", if f {"No"} else {"Yes"});
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n >> s;
    if (n % 2 == 1) {
        cout << "No" << endl;
        return 0;
    }
    int t = n / 2;
    rep (i, t) {
        if (s[i] != s[i + t]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    
    return 0;
}



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

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

const int MAX = 5e5 + 5;
vector<ii> queries[MAX];
vector<int> updates[MAX];
int app[MAX], ans[MAX], bit[MAX];
int n, m;

void update(int idx, int val) {
	while(idx < MAX) {
		bit[idx] += val;
		idx += idx & -idx;
	}
}

int get(int idx) {
	int sum = 0;
	while(idx) {
		sum += bit[idx];
		idx -= idx & -idx;
	}
	return sum;
}

int main() {
	scanf("%d %d", &n, &m);
	fori(i, 1, n + 1) {
		int l, r;
		scanf("%d %d", &l, &r);
		updates[l].push_back(r);
	}

	fori(i, 1, m + 1) {
		for(int j = i; j <= m + i; j += i) {
			int l = j - i, r = j;
			queries[l].emplace_back(r, i);
		}
	}

	ford(i, m, 0) {
		for(auto &each : queries[i]) {
			int r, id;
			tie(r, id) = each;
			ans[id] += get(r);
		}
		for(auto &each : updates[i]) {
			update(each + 1, 1);
		}
	}

	fori(i, 1, m + 1) {
		printf("%d\n", n - ans[i]);
	}

	return 0;
}


Measured memory_bytes: 45556
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num,init) vector<ll> name((num),(init));
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define mat(name,fnum,snum,init); vector<vector<ll>> name((fnum),vector<ll>((snum),(init)));
#define debugP int debug_point; cin>>debug_point;


int main(){
    ll n,m;
    cin>>n>>m;
    cout<<((m*1900+(n-m)*100)*(int)pow(2,m))<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <sstream>
#include <string>
#include <utility>
#include <map>
#include <memory>
#include <set>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>

using namespace std;

class Friend
{
public:
  int solve();
  void setGroup( vector<vector<int>>& adj, vector<int>& group, int u, int grpid );
};

void Friend::setGroup( vector<vector<int>>& adj, vector<int>& group, int u, int grpid )
{
  if ( group[u] ) return;
  
  group[u] = grpid;
  
  int n = adj[u].size();
  
  for ( auto i = 0; i < n; ++i )
    {
      int v = adj[u][i];
      setGroup( adj, group, v, grpid );
    }

  return;
}

int Friend::solve()
{
  int n, m;
  cin >> n >> m;
  
  vector<vector<int>> adj( n );

  for ( auto i = 0; i < m; ++i )
    {
      int u, v;
      cin >> u >> v;
      adj[u].push_back( v );
      adj[v].push_back( u );
    }

  int grpid = 1;

  vector<int> group( n, 0 );

  for ( auto i = 0; i < n; ++i )
    {
      if ( group[i] == 0)
        {
          setGroup( adj, group, i, grpid++ );
        }
    }
  
  int q;
  cin >> q;

  
  for ( auto i = 0; i < q; ++i )
    {
      int u, v;
      cin >> u >> v;
      
      if ( group[u] == group[v] )
        cout << "yes" << endl;
      else
        cout << "no" << endl;
    }
  
  return 0;
}

int main()
{
  Friend f;

  f.solve();

  return 0;
}

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

const int MAXN = 1e5+100 ;
const int MAXM = 1e5 ;
const int mod  = 1e9+7 ;

struct Edge {
    LL from,to,val,next;
}edge[MAXN<<2];
LL head[MAXN],top;
LL n,m;
void init(){
    memset(head,-1,sizeof(head));
    top=0;
}
void addedge(LL a,LL b,LL c){
    Edge e={a,b,c,head[a]};
    edge[top]=e;head[a]=top++;
}
void getmap(){
     LL a,b,c;
     while(m--){
     	scanf("%lld%lld%lld",&a,&b,&c);
     	addedge(a,b,c);
     	addedge(b,a,c);
	 }
}
LL fa[MAXN][50+5],depth[MAXN];
LL dist[MAXN];
void dfs(LL now,LL par){
    fa[now][0]=par;
    for(LL i=1;i<50;i++){
        fa[now][i]=fa[fa[now][i-1]][i-1];
    }
    for(LL i=head[now];i!=-1;i=edge[i].next){
        Edge e=edge[i];
        if(e.to!=par){
            dist[e.to]=dist[now]+e.val;
            depth[e.to]=depth[now]+1;
            dfs(e.to,now);
        }
    }
}
LL lca(LL a,LL b){
    if(depth[a]<depth[b]) swap(a,b);
    for(LL i=49;i>=0;i--){
        if(depth[fa[a][i]]>=depth[b]){
            a=fa[a][i];
        }
    }
    if(a==b) return b;
    for(LL i=49;i>=0;i--){
        if(fa[a][i]!=fa[b][i]){
            a=fa[a][i];
            b=fa[b][i];
        }
    }
    return fa[b][0];
}
void solve(){
    depth[1]=0;dist[1]=0;
    dfs(1,-1);
    LL q,k;
    scanf("%lld%lld",&q,&k);
    while(q--){
    	LL a,b;
    	scanf("%lld%lld",&a,&b);
    	LL dis1=dist[a]+dist[k]-2*dist[lca(a,k)];
    	LL dis2=dist[b]+dist[k]-2*dist[lca(b,k)];
    	printf("%lld\n",dis1+dis2);
	}
}
int main(){
     	scanf("%lld",&n);m=n-1;
        init();
        getmap();
        solve();
}


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

int main(){
  int a, b;
  std::cin >> a >> b;
  int c = (a+b)/2;
  if((a+b)%2 == 0){
    std::cout << c << '\n';
  }
  else{
    std::cout << "IMPOSSIBLE" << '\n';
  }
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define ub upper_bound
#define lb lower_bound
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

signed main(){
  stack<int> s;
  int n;
  while(cin>>n){
    if(n!=0)s.push(n);
    else{
      cout<<s.top()<<endl;
      s.pop();
    }
  }
  return 0;
}

Measured memory_bytes: 3116
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct Edge{ll from, to, cost;};
struct node{ll cost, to;
  bool friend operator>(node a, node b){
    return a.cost>b.cost;
  }
};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N;
  cin >> N;
  cout << (N<1200?"ABC":"ARC") << endl;

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
const int MOD = 1000000007LL;
int x[100000];
int nxt[100000][18]; //nxt[i][j]=町iから2^j日でどこまでいけるか
int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> x[i];
	}
	int L;
	cin >> L;
	for (int i = 0; i < N; i++) {
		int l = i, r = N;
		while (r - l > 1) {
			int m = (l + r) / 2;
			if (x[m] - x[i] <= L) l = m;
			else r = m;
		}
		nxt[i][0] = l;
	}
	for (int i = 1; i < 18; i++) {
		for (int j = 0; j < N; j++) {
			nxt[j][i] = nxt[nxt[j][i - 1]][i - 1];
		}
	}
	int Q;
	cin >> Q;
	for (int i = 0; i < Q; i++) {
		int a, b;
		cin >> a >> b; a--; b--;
		if (b < a) swap(a, b);
		int ans = 0;
		int now = a;
		for (int j = 17; j >= 0; j--) {
			if (nxt[now][j] < b) {
				now = nxt[now][j];
				ans += (1 << j);
			}
		}
		ans++;
		cout << ans << endl;
	}
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    for(auto& e : a) cin >> e;
    sort(begin(a), end(a), greater<int>());
    int res = 0;
    for(int i = 0; i < n; i++){
        if(a[i] * 4 * m < accumulate(begin(a), end(a), 0)) continue;
        if(res < m) res++;
    }
    cout << (res >= m ? "Yes" : "No") << endl;
    return 0;
}

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

#define range(i, l, r) for (int i = (int)l; i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = ((int)(r) - 1); i >= (int)l; --(i))

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define rwhole(f,x,...) ([&](decltype((x)) whole) { return (f)(rbegin(whole), rend(whole), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using int32 = int;
using int64 = long long;

const int mod     = 1e9 + 7;
const int32 inf   = 1001001001;
const int64 infll = 1001001001001001001ll;

const int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const string YES = "YES", NO = "NO", Yes = "Yes", No = "No", yes = "yes", no = "no";

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(16); cerr << fixed << setprecision(16); } } iosetup;

template <typename T = int64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

template <typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solver() {
  int N = input();
  vector< int > A(N);
  cin >> A;

  rrange(i, 0, N - 1) {
    A[i] = __gcd(A[i], A[i + 1]);
  }

  cout << A[0] << endl;
}

signed main(int argc, char *argv[]) {
  solver();
}


Measured memory_bytes: 640
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int M1, D1, M2, D2; cin >> M1 >> D1 >> M2 >> D2;
    cout << (M1 != M2) << endl;
    return 0;
}


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

//ライブラリ始まり

//定数
//円周率
const double pi = 3.1415926535897932384;
//天井
const int INF = 1000000000; // = 10^9
const ll LINF = 1000000000000000; // = 10^15
//ABC文字列
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZABC";
const string abc = "abcdefghijklmnopqrstuvwxyzabc";
//よくあるmodくん
const ll MOD = 1000000007; // = 10^9 + 7

//データ構造
//Union_Find木
struct UnionFind {
  vector<int> UF; // UF.at(i) : iの親の番号
  vector<int> SIZE; // SIZE.at(root(i)) : iと連結されてる要素の数
  UnionFind(int N) : UF(N), SIZE(N, 1) { // 最初は全てが根であるとして初期化
    for(int i = 0; i < N; i++) {
      UF.at(i) = i;
    }
  }
  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (UF.at(x) == x) {
      return x;
    }
    return UF.at(x) = root(UF.at(x));
  }
  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); // xの根をrx
    int ry = root(y); // yの根をry
    if (rx == ry) {
      return; // xとyの根が同じ(=同じ木にある)時はそのまま
    }
    // xとyの根が同じでない(=同じ木にない)時：小さい方の根を大きい方の根につける
    if (SIZE.at(rx) < SIZE.at(ry)) {
      UF.at(rx) = ry;
      SIZE.at(ry) += SIZE.at(rx);
      SIZE.at(rx) = 0;
    }
    else {
      UF.at(ry) = rx;
      SIZE.at(rx) += SIZE.at(ry);
      SIZE.at(ry) = 0;
    }
  }
  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
  int size(int x) { // xと連結されてる要素の数を返す
    return SIZE.at(root(x));
  }
};

//関数 (計算量)
//ctoi (O(1))
int ctoi(char c){
  if (c == '0') return 0;
  if (c == '1') return 1;
  if (c == '2') return 2;
  if (c == '3') return 3;
  if (c == '4') return 4;
  if (c == '5') return 5; 
  if (c == '6') return 6;
  if (c == '7') return 7;
  if (c == '8') return 8;
  if (c == '9') return 9;
  return -1;  
}
//to_char (O(1))
char to_char(int i){
  if (i == 0) return '0';
  if (i == 1) return '1';
  if (i == 2) return '2';
  if (i == 3) return '3';
  if (i == 4) return '4';
  if (i == 5) return '5';
  if (i == 6) return '6';
  if (i == 7) return '7';
  if (i == 8) return '8'; 
  if (i == 9) return '9';
  return ' ';  
}
//素数判定 
//一つ一つの判定ではこっちの方が速い(一つ当たりO(√N))
//一方100までに何個あるかなどはEratosthenesの篩の方が良い（O(NlogN))
bool PN(int x) {
  if (x <= 1) return false; // 1や0,-1は素数ではない
  if (x == 2) return true; // √2 + 1 > 2 なので下でやると 2 ％ 2 = 0 となり判定できない
  for (int i = 2; i < sqrt(x) + 1; i++) {
    if (x % i == 0) return false; // 割れたら素数じゃない
  }
  return true;
}
// A^N mod M を計算する。modしたくなかったらM = LINFとかにすればよい。(O(√N))
ll modpow(ll A, ll N, ll M) {
  long long ans = 1;
  while (N > 0) {
    if (N & 1) ans = ans * A % M;
      A = A * A % M;
      N >>= 1;
   }
  return ans;
}

//ライブラリ終わり
  
//メイン処理
int main() {
  cout << fixed << setprecision(16); //精度向上
  //ここまでテンプレ
  ll A, B, C;
  cin >> A >> B >> C;
  ll K;
  cin >> K;
  if (A >= B && A >= C) {
    cout << B + C + A * modpow(2, K, LINF) << endl;
  }
  else if (B >= A && B >= C) {
    cout << A + C + B * modpow(2, K, LINF) << endl;
  }
  else {
    cout << A + B + C * modpow(2, K, LINF) << endl;
  }
}

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

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))

void update(int64 *bit,int x,int64 v){
  int n=bit[0];
  for(int i=x;i<=n;i+=i&-i) bit[i]=MAX(bit[i],v);
}

int64 max(int64 *bit,int x){
  int64 res=0;
  for(int i=x;i>0;i-=i&-i) res=MAX(res,bit[i]);
  return res;
}

void run(void){
  int n;
  scanf("%d",&n);
  int *h=(int *)calloc(n,sizeof(int));
  int i;
  for(i=0;i<n;i++) scanf("%d",h+i);
  int *a=(int *)calloc(n,sizeof(int));
  for(i=0;i<n;i++) scanf("%d",a+i);
  int64 *bit=(int64 *)calloc(n+1,sizeof(int64));
  bit[0]=n;
  for(i=0;i<n;i++){
    update(bit,h[i],max(bit,h[i]-1)+a[i]);
  }
  printf("%lld\n",max(bit,n));
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define mod7 1000000007

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin>>s;
	if (s[2]==s[3] and s[4]==s[5]) cout<<"Yes\n";
	else cout<<"No\n";
}



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

def main():
    n = int(input())
    arry = [input() for _ in range(n)]
    for i in range(1, n):
        if arry[i-1][-1] != arry[i][0] or len(arry) != len(set(arry)):
            print('No')
            exit()
    print('Yes')

if __name__ == '__main__':
    main()

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

int main(){
    long long n,k,q;
    cin >> n >> k >> q;
    int A[q];
    int a;
    for(int i=0;i<q;i++){
        cin >> a;
        a--;
        A[i] = a;
    }

    int point[n];
    for(int i=0;i<n;i++){
        point[i] = k-q;
    }

    for(int i=0;i<q;i++){
        point[A[i]]++;
    }

    for(int i=0;i<n;i++){
        if(point[i]>0){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }

}

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

public class Main{
    public static void main(String[] args)throws Exception{
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        String s=sc.next(),t=sc.next();
        for(int i=0;i<n;i++){
            System.out.printf("%c%c",s.charAt(i),t.charAt(i));
        }
        System.out.println();
    }
}

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

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

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

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

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

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

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

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

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

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

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

fn main() {
    input! {
        n: usize,
        k: usize,
        a: [usize; n],
    }
    let m = 1000000007;
    let mut r = 0;
    let mut s = 0;
    for i in 0..n {
        for j in 0..i {
            if a[j] > a[i] {
                r += 1;
            }
            if a[i] > a[j] {
                s += 1;
            }
        }
    }
    let (c, d) = if k % 2 == 0 {
        ((k / 2 % m) * ((k + 1) % m) % m, (k / 2 % m) * ((k - 1) % m) % m)
    } else {
        ((k % m) * ((k + 1) / 2 % m) % m, (k % m) * ((k - 1) / 2 % m) % m)
    };
    println!("{}", ((r * c % m) + (s * d % m)) % m);
}


Measured memory_bytes: 4352
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        long n = scan.nextLong();        
        long k = scan.nextLong();
		long min = 0;
		min = n%k;	//nをkで割った余り

		if(min<(k-min)){   
			System.out.println(min);
		} else {
			System.out.println(k-min);		
		}
	    scan.close();	
    }
}

Measured memory_bytes: 23764
#include<set>
#include<map>
#include<cmath>
#include<ctime>
#include<queue>
#include<cstdio>
#include<string>
#include<vector>
#include<cstdlib>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<algorithm>
#define fi first
#define se second
#define pb push_back
#define lowbit(x) x&(-x)
#define PII  pair<int, int> 
#define all(x) x.begin(), x.end()
#define FAST ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int mod = (int)1e9 + 7;
const int maxn = (int)1e6 + 5;
using namespace std;

int main()
{
	int a, b; cin >> a >> b;
	cout << a * b - a - b + 1 << endl;
	return 0;
}

Measured memory_bytes: 256
let h = ref 0

let parent i = int_of_float (floor (float_of_int i) /. 2.)

let left i = 2*i

let right i = 2*i + 1

let swap i j t = let tmp = t.(i) in t.(i) <- t.(j); t.(j) <- tmp

let extract (t : int array) =
  let rec max_heapify i =
    let l = left i in
    let r = right i in
    let m = if l <= !h && t.(l) > t.(i) then l else i in
    let m = if r <= !h && t.(r) > t.(m) then r else m in
    if i <> m then begin
      swap i m t;
      max_heapify m
    end in
  let ret = t.(1) in
  t.(1) <- t.(!h);
  decr h;
  max_heapify 1;
  ret

let insert x (t : int array) =
  let rec doit i =
    if i > 1 && t.(parent i) < t.(i) then begin
      swap i (parent i) t;
      doit (parent i)
    end in
  incr h;
  t.(!h) <- x;
  doit !h

let split str delim =
  let open String in
  let rec doit s acc =
    match
      try Some (rindex s delim) with _ -> None
    with
    | None -> s :: acc
    | Some i -> doit (sub s 0 i) (sub s (i + 1) (length s - i - 1) :: acc) in
  doit str []

let () =
  let t = Array.make 2000001 0 in
  let rec doit () =
    match split (read_line ()) ' ' with
    | ["extract"] -> Printf.printf "%d\n" (extract t); doit ()
    | ["insert"; n] -> insert (int_of_string n) t; doit ()
    | _ -> () in
  doit ()

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

using namespace std;

int main(int argc,char* argv[]){
  int A,B,K,count=0;
  cin >> A >> B >> K;
  for(int i=A;i>=0;i--){
    if(count==K) {
      cout << i+1 << endl;
      break;
    }
    if(A%i==0&&B%i==0) count++;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

const int MAX_N = 50;
const int MOD = 1000000007;

int n,a[MAX_N][MAX_N],r[MAX_N][MAX_N];
long long k;

void mmul(int a[MAX_N][MAX_N], int b[MAX_N][MAX_N])
{
	static int t[MAX_N][MAX_N];
	for (int i=0; i<n; i++)
		for (int j=0; j<n; j++)
		{
			t[i][j]=0;
			for (int k=0; k<n; k++)
				t[i][j]=(t[i][j]+a[i][k]*1LL*b[k][j])%MOD;
		}
	for (int i=0; i<n; i++)
		for (int j=0; j<n; j++)
			a[i][j]=t[i][j];
}

int main()
{
	scanf("%d %lld",&n,&k);
	for (int i=0; i<n; i++)
	{
		r[i][i]=1;
		for (int j=0; j<n; j++)
			scanf("%d",&a[j][i]);
	}
	for (;k;k/=2,mmul(a,a))
		if (k&1)
			mmul(r,a);
	long long ans=0;
	for (int i=0; i<n; i++)
		for (int j=0; j<n; j++)
			ans=(ans+r[i][j])%MOD;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
#include <numeric>
#include <queue>
#include <map>
#include <cstdint>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long int ll;
typedef pair<int, int> P;
const vector<int> di = { -1, 0, 1, 0 };
const vector<int> dj = { 0, 1, 0, -1 };


int main() {

	ll n, a, b;
	cin >> n >> a >> b;

	ll s = n / (a + b);
	ll k = n % (a + b);
	ll ans;
	if (k > a) {
		ans = s * a + a;
	}
	else {
		ans = s * a + k;
	}
	cout << ans << endl;

	
	return 0;
}

Measured memory_bytes: 256
[n,a,b] = [int(i) for i in input().split()]
c = 1
#aの方が小さい場合
if a > b:
    c = 0
#nが1なのにaとbが等しくない場合
if n == 1 and a != b:
    c = 0
#nが1でaとbが等しい場合
if n == 1 and a == b:
    c = -1

if c == 1:
    print(b * (n-1) + a - (a * (n-1) + b) + 1)
elif c == -1:
    print(1)
else:
    print(0)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(i) i.begin(),i.end()
template<typename T=ll>
using v =vector<T>;
template<typename T=ll>
using vv = vector<v<T>>;
template<typename T=ll,typename U=ll> using p = pair<T,U>;
const ll INF = (ll)1e9;
template<typename T> T chmin(T &a,T b){a=min(a,b);}
template<typename T> T chmax(T &a,T b){a=max(a,b);}

int main(){
    ll n,r; cin >> n >> r;
    cout << (n>=10?r:100*(10-n)+r);
    return 0;
}

Measured memory_bytes: 256