akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ld double
#define ll long long
#define all(x) x.begin(),x.end()
const int mod=1e9+7;
#define fi first
#define se second
#define sync  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf (ll)1e16

const ld pi=(4.0*atan(1));
ll n;
vector<pair<ll,ll>> v;

ll po(ll x,ll y,ll md=mod){
    ll res=1;
    x%=md;
    
    while(y>0){
        if (y&1){
            res=(res*x)%md;
        }
        
        y>>=1;
        x=(x*x)%md;
    }
    return res;
}

void solve(){
    cin>>n;
    v.clear();
    v.resize(n);
    map<pair<ll,ll>,ll> mp;
    ll gd;
    for (ll i=0;i<n;i++){
        cin>>v[i].fi>>v[i].se;
        ll sgn,xx,yy;
        if (v[i].fi==0 and v[i].se==0){
            mp[{0,0}]++;
        }
        else if (!v[i].fi){
            mp[{0,1}]++;
        }
        else if (!v[i].se){
            mp[{1,0}]++;
        }
        else{
            xx=abs(v[i].fi);yy=abs(v[i].se);
            sgn=(v[i].fi/xx)*(v[i].se/yy);
            gd=(__gcd(xx,yy));
            xx/=gd;yy/=gd;
            mp[{sgn*xx,yy}]++;
        }
    }
    ll wys=1,ex=0;
    ex+=mp[{0,0}];
    if (mp.find({0,0})!=mp.end())
    mp.erase(mp.find({0,0}));
    for (auto xd:mp){
        auto pr=xd.fi;
        ll sub=0;
        ll pre=xd.se;
        if (!pr.fi){
            auto itr=mp.find({1,0});
            if (itr!=mp.end())
            sub+=(itr->se),wys=(wys*(po(2,pre)+po(2,sub)-1)%mod)%mod,mp.erase(itr);
            else
            wys=(wys*po(2,pre))%mod;
        }
        else if (!pr.se){
            auto itr=mp.find({0,1});
            if (itr!=mp.end())
            sub+=(itr->se),wys=(wys*(po(2,pre)+po(2,sub)-1)%mod)%mod,mp.erase(itr);
            else
            wys=(wys*po(2,pre))%mod;
        }
        else{
            ll xx=abs(pr.fi),sgn=(pr.fi/xx);
            if (sgn>0){
                sgn=-1;
            }
            else
            sgn=1;
            auto itr=mp.find({sgn*pr.se,xx});
            if (itr!=mp.end())
            sub+=(itr->se),wys=(wys*(po(2,pre)+po(2,sub)-1)%mod)%mod,mp.erase(itr);
            else
            wys=(wys*po(2,pre))%mod;
        }
    }
    wys=(wys+ex-1)%mod;
    if (wys<0)
    wys+=mod;
    cout<<wys<<"\n";
}

int main() {
    
    sync
    ll tt=1;
    //cin>>tt;
    cout<<fixed<<setprecision(12);
    for (ll tc=1;tc<=tt;tc++){
       solve();
    }
    
	return 0;
}

Measured memory_bytes: 18672
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define ll long long int
#define INF INT_MAX
#define mod
#define chutiyaap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
bool sortbysec(const pair<ll,ll> &a,const pair<ll,ll> &b){return (a.second < b.second);}
ll gcd(ll a, ll b){if(a==0)return b;return gcd(b % a, a);}
int main()
{
	chutiyaap;
	ll l,r;cin>>l>>r;
	ll md=1e18;
	for(ll i=l;i<=min(l+2018,r);i++)for(ll j=i+1;j<=min(l+2018,r);j++)md=min(md,(ll)((i*j)%2019));
	cout<<md;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    vl a(n);
    ll minA = n, maxA = 0;
    rep(i, n) {
        cin >> a[i];
        chmin(minA, a[i]);
        chmax(maxA, a[i]);
    }

    if(maxA - minA >= 2) {
        out("No");
        re0;
    }

    if(maxA - minA == 0) {
        if(maxA == n-1) {
            out("Yes");
        }
        else if(2*maxA <= n) {
            out("Yes");
        }
        else {
            out("No");
        }
    }
    else if(maxA - minA == 1) {
        ll x = 0, y = 0;
        rep(i, n) {
            if(a[i] == minA) {
                x++;
            }
            else if(a[i] == maxA) {
                y++;
            }
        }
        if(x < maxA && 2*(maxA - x) <= y) {
            out("Yes");
        }
        else {
            out("No");
        }
    }
    
    re0;
}

Measured memory_bytes: 1024
#include<stdio.h>
double abs2(double a){
    double t=a;
    if(t<0)t=-t;
    return t;
}
int main(void){
    int N;
    scanf("%d",&N);
    int a[N];
    for(int i=0;i<N;i++){
        scanf("%d",&a[i]);
    }
    int C=0;
    for(int i=0;i<N;i++){
        C+=a[i];
    }
    double C1;
    C1=(double)C/(double)N;
    int C2=a[0],j=0;
    for(int i=0;i<N;i++){
        if(abs2((double)a[i]-C1)<abs2((double)C2-C1)){
            C2=a[i];
            j=i;
        }
    }
    printf("%d\n",j);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;

using namespace std;


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

  vector<int> A(N);
  vector<vector<pair<int, int>>> B(N);
  REP(i, N){
    cin >> A[i];

    int x, y;
    REP(j, A[i]){
      cin >> x >> y;
      x--;
      B[i].push_back(make_pair(x, y));
    }
  }

  int ans = 0;
  vector<int> vec(N, 0);
  REP(i, 1<<N){
    int cnt = 0;
    fill(ALL(vec), 0);
    REP(j, N){
      if((i >> j)&1){
        vec[j] = 1;
        cnt++;
      }
    }

    int flag = 1;
    REP(j, N){
      if(vec[j]){
        for(pair<int, int> p : B[j]){
          if(p.second == 1 && vec[p.first] == 0) flag = 0;
          if(p.second == 0 && vec[p.first] == 1) flag = 0;
        }
      }
    }
    if(flag) ans = max(ans, cnt);
  }

  cout << ans << endl;

  return 0;
}

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

using namespace std;

using ll = long long;
using PII = pair<int, int>;
constexpr int INF = numeric_limits<int>::max() / 2;

int N, K;
vector<int> V(100000), P(100000);
vector<int> l(100000, -INF), r(100000, INF), res(100000, -1);
vector<vector<int>> g(100000);
bool f = true;
int root = -1;

PII dfs(int cur, int pre, int dis)
{
    if (res[cur] != -1)
    {
        if (abs(res[cur] - res[root]) % 2 != dis % 2)
        {
            f = false;
        }
    }
    if (cur != root && g[cur].size() == 1)
    {
        return PII(l[cur], r[cur]);
    }
    int ltmp = l[cur], rtmp = r[cur];
    for (int v : g[cur])
    {
        if (v == pre)
            continue;
        PII p = dfs(v, cur, dis + 1);
        ltmp = max(ltmp, p.first-1);
        rtmp = min(rtmp, p.second+1);
    }
    // cout<<cur<<" "<<ltmp<<" "<<rtmp<<endl;
    if (ltmp > rtmp)
    {
        f = false;
    }
    else if (r[cur] < ltmp || rtmp < l[cur])
    {
        f = false;
    }
    l[cur] = ltmp;
    r[cur] = rtmp;
    return PII(l[cur], r[cur]);
}

void dfs2(int cur, int pre)
{
    if (res[cur] == -1)
    {
        int par = res[pre];
        if (l[cur] <= par + 1 && par + 1 <= r[cur])
        {
            res[cur] = par + 1;
        }
        else
        {
            res[cur] = par - 1;
        }
    }
    for (auto v : g[cur])
    {
        if (v == pre)
            continue;
        dfs2(v, cur);
    }
}

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

    cin >> N;
    for (int i = 0; i < N - 1; i++)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    cin >> K;
    for (int i = 0; i < K; i++)
    {
        cin >> V[i] >> P[i];
        V[i]--;
        l[V[i]] = P[i];
        r[V[i]] = P[i];
        res[V[i]] = P[i];
        root = V[i];
    }
    dfs(root, -1, 0);
    if (!f)
    {
        cout << "No" << endl;
        return 0;
    }
    dfs2(root, -1);
    cout << "Yes" << endl;
    for (int i = 0; i < N; i++)
        cout << res[i] << endl;
}


Measured memory_bytes: 16128
#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 RMQuery
{
public:
  int infty;
  int solve();
  void updateST( vector<int> &st, int ix );
  int findMin( vector<int> &st, int x, int y , int ix, int l, int r );
};

void RMQuery::updateST( vector<int> &st, int ix )
{
  if ( ix == 0 ) return;
  int p = (ix - 1) / 2;
  
  while ( true )
    {
      st[p] = min( st[2 * p + 1], st[2 * p + 2] );
      if ( p == 0 ) break;
      p = (p - 1) / 2;
    }

  return;
}

int RMQuery::findMin( vector<int> &st, int x, int y , int ix, int l, int r )
{
  if ( r <= x || y <= l ) return infty;
  if ( x <= l && r <= y )
    return st[ix];
  else
    return min( findMin( st, x, y, 2 * ix + 1, l, (l + r) / 2 ), findMin(st, x, y, 2 * ix + 2, (l + r) / 2, r ) );
  return 0;
}

int RMQuery::solve()
{

  int n, q, mn;

  cin >> n >> q;

  for ( mn = 1; mn < n; mn *= 2 );

  vector<int> st( 2 * mn , infty );

  for ( auto i = 0; i < q; ++i )
    {
      int com, x, y;
      cin >> com >> x >> y;
      if ( com == 0 )
        {
          st[ mn - 1 + x ] = y;
          updateST( st, mn - 1 + x );
        }
      else
        cout << findMin( st, x, y + 1, 0, 0, mn ) << endl;
    }

  return 0;
}

int main()
{
  RMQuery rmq;

  rmq.infty = 2147483647;
  rmq.solve();

  return 0;
}

Measured memory_bytes: 2052
#include <stdio.h>

int main()
{
    
    int x, nr = 0;
    scanf("%d", &x);
    if(x < 3)
    {
        printf("%d", 0);
        return 0;
    }
    if(x % 3 == 0)
    {
        printf("%d", x / 3);
        return 0;
    }
    while((x - 3) > 0)
    {
        x -= 3;
        nr ++;
    }
    printf("%d", nr);
    return 0;
}

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

const int WHITE = 1;
const int BLACK = 2;
const int MAXV = 31;
int V;
vector<int> E[MAXV];
int numD[MAXV];
int color[MAXV];
int ans;

bool isValid() {
  bool flag[MAXV];
  fill(flag, flag+V, false);
  for(int i = 0; i < V; ++i) {
    if(color[i] == BLACK) {
      flag[i] = true;
      for(int j = 0; j < E[i].size(); ++j) {
	flag[E[i][j]] = true;
      }
    }
  }
  for(int i = 0; i < V; ++i) {
    if(!flag[i]) return false;
  }
  return true;
}

void rec(int p, int c) {
  if(p == V) {
    if(isValid()) {
      ans = min(ans, c);
    }
    return;
  }
  if(c >= ans) return;
  color[p] = BLACK;
  rec(p+1, c+1);
  color[p] = WHITE;
  rec(p+1, c);
}

int main() {
  int x, y;
  while(cin >> x >> y && (x|y)) {
    for(int i = 0; i < MAXV; ++i) E[i].clear();
    V = x;
    int a, b;
    while(y--) {
      cin >> a >> b;
      E[a].push_back(b);
      E[b].push_back(a);
    }
    ans = V;
    fill(numD, numD+MAXV, 0);
    rec(0, 0);
    cout << ans <<  endl;
  }
  return 0;
}

Measured memory_bytes: 1216
n = int(raw_input())

points = [0, 0]
for i in xrange(n):
  card_list = raw_input().split(" ")
  if card_list[0] > card_list[1]:
    points[0] += 3
  elif card_list[0] < card_list[1]:
    points[1] += 3
  else:
    points[0] += 1
    points[1] += 1

print str(points[0]) + " " + str(points[1])

Measured memory_bytes: 6372
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=1; i<=(int)(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int N,K;
    cin>>N>>K;
    int ans=K;
    rrep(i,N-1) {
        ans*=(K-1);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD =1e9+7;
using ll=long long;
int n, k, A;
vector<int> cnt(200010);
int cou,ans;
int main(){
  cin >> n >> k;
  rep(i,n) {
    cin >> A;
    if(cnt[A] == 0) cou++;
    cnt[A]++;
  }
  sort(cnt.begin(), cnt.end());
  int i = 0;
  for(int x: cnt){
    if(i >= cou - k) break;
    if(x == 0) continue;
    else {
      ans += x;
      i++;
    }
  }
  cout << ans << endl;

}


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

int main() {
  vector<int> a(3);
  for(int i = 0; i < 3; i++) {
    cin >> a.at(i);
  }
  
  sort(a.begin(), a.end());
  
  cout << abs(a.at(2) - a.at(1)) + abs(a.at(1) - a.at(0)) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;
const int mod = (int)998244353, INF = (int)1e9;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };


int main(void) {
    int n, q, i, ain, b, c;
    ll a[100003] = {}, sum = 0;

    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%d", &ain);
        a[ain]++;
        sum += ain;
    }

    scanf("%d", &q);
    for (i = 0; i < q; i++) {
        scanf("%d%d", &b, &c);
        sum = sum + a[b] * (c - b);
        a[c] += a[b];
        a[b] = 0;
        printf("%lld\n", sum);
    }

    return 0;
}

Measured memory_bytes: 4536
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
typedef long long ll;

vector<string> bubble_sort(const vector<string> &v) {
    vector<string> vv;
    for(const auto &it: v) vv.push_back(it);

    REP(i,vv.size()) {
        for(int j = vv.size()-1 ; j > i ; j--) {
            if(vv[j][1] < vv[j-1][1]) iter_swap(vv.begin()+j,vv.begin()+j-1);
        }
    }

    return vv;
}

vector<string> selection_sort(const vector<string> &v) {
    vector<string> vv;
    for(const auto &it: v) vv.push_back(it);

    int minj,minv;
    REP(i,vv.size()) {
        minj = i;
        minv = vv[i][1];
        FOR(j,i,vv.size()) if(chmin(minv,int(vv[j][1]))) minj = j;
        iter_swap(vv.begin()+i,vv.begin()+minj);
    }

    return vv;
}

bool is_stable(const vector<string> &in,const vector<string> &out) {
    REP(i,in.size()) FOR(j,i+1,in.size()) REP(k,out.size()) FOR(l,k+1,out.size()) {
        if(in[i][1] == in[j][1] && in[i] == out[l] && in[j] == out[k]) return false;
    }
    return true;
}

bool output(const vector<string> &v) {
    REP(i,v.size()-1) cout << v[i] << " ";
    cout << v[v.size()-1] << endl;
}

void solve() {
    int N;
    cin >> N;
    vector<string> v(N);
    REP(i,N) cin >> v[i];
    auto b = bubble_sort(v);
    output(b);
    auto ret = is_stable(v,b) ? "Stable" : "Not stable";
    cout << ret << endl;

    auto s = selection_sort(v);
    output(s);
    ret = is_stable(v,s) ? "Stable" : "Not stable";
    cout << ret << endl;
}

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


Measured memory_bytes: 3156
from collections import defaultdict


def factorize(n):
    """
    nの値を素因数分解し、素因数とその指数をtupleにまとめたリストを返す
    e.g.
    factorize(20)
    [(2, 2), (5, 1)]
    """
    b = 2
    fct = []
    while b * b <= n:
        cnt = 0
        while n % b == 0:
            cnt += 1
            n //= b
        if cnt > 0:
            fct.append((b, cnt))
        b += 1
    if n > 1:
        fct.append((n, 1))
    return fct


N, P = map(int, input().split())
d = defaultdict(int)
for p, e in factorize(P):
    if e >= N:
        d[p] = e // N
ans = 1
for p, e in d.items():
    ans *= p ** e
print(ans)

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

int main(){
  int n;
  cin >> n;
  
  vector<int> data(n);
  for(int i = 0; i < n; i++){
    cin >> data.at(i);
  }
  
  vector<int> out(n);
  for(int i = 1; i <= n; i++){
    out.at(data.at(i-1) - 1) = i;
  }
  
  for(int i = 0; i < n; i++){
    cout << out.at(i);
    if(i == n-1)
      break;
    else
      cout <<' ';
  }
}

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

#define int long long

int N,K;
vector<int> h;
vector<int> arr;

int dp(int i)
{
    if(arr[i] != -1)
        return arr[i];

    vector<int> ans(K);

    int j=0;

    for(int k=1 ; k<=K and i+k<=N ; k++)
    {
        ans[j] = abs(h[i+k] - h[i]) + dp(i+k);
        j++;
    }

    sort(ans.begin(),ans.begin()+j);

    return arr[i] = ans[0];
}

signed main()
{
    cin>>N>>K;
    h.resize(N+1);

    for(int i=1 ; i<=N ; i++)
        cin>>h[i];

    arr.resize(N+1,-1);

    arr[N] = 0;

    cout<<dp(1);
}

Measured memory_bytes: 89344
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 99999999



int main(){
    int d[]={0,6000,4000,3000,2000};
    rep(i,4){
        int a,b;
        cin>>a>>b;
        cout<<d[a]*b<<endl;;
    }
}

Measured memory_bytes: 1160
import sys
sys.setrecursionlimit(500000)


def dfs(c,p,d):
    if c == R:
        if ans[0] > d:
            ans[0] = d
        return
    for i in range(R):
        if memo[i]:continue
        memo[i] = True
        if p == -1:
            dfs(c+1,i,0)
        else:dfs(c+1,i,d+graph[r[p]][r[i]])
        memo[i] = False

N,M,R = map(int,input().split())
r = [i-1 for i in map(int,input().split())]
graph = [[float("Inf") if i != j else 0 for i in range(N)] for j in range(N)]
for i in range(M):
    x,y,z = map(int,input().split())
    graph[x-1][y-1] = z
    graph[y-1][x-1] = z
for k in range(N):
    for i in range(N):
        for j in range(N):
            if graph[i][j] > graph[i][k] + graph[k][j]:
                graph[i][j] = graph[i][k] + graph[k][j]
memo = [False]*R
ans = [float("Inf")]
dfs(0,-1,0)
print(ans[0])

Measured memory_bytes: 56664
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)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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, [ $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, usize1) => {
        read_value!($next, usize) - 1
    };

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

#[allow(unused_imports)]
use std::cmp::{min, max};
use std::collections::BTreeMap;

fn main() {
    input!{
        n: usize,
        v: [chars; n]
    }
    let mut map = BTreeMap::new();
    for s in &v {
        *map.entry(s.to_vec()).or_insert(0) += 1;
    }
    let mut ans = vec![];
    let mut m = 0;
    for (k, v) in map.iter() {
        if *v > m {
            ans = vec![k.iter().map(|&x| x).collect::<String>()];
            m = *v;
        } else if *v == m {
            ans.push(k.iter().map(|&x| x).collect::<String>());
        }
    }
    for s in ans {
        println!("{}", s);
    }
}


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

ll dig(ll n){
    ll dig=0;
    while(n>0){
        dig++;
        n /= 10;
    }
    return dig;
}

ll sumdig(ll n){
    ll sum=0;
    while(n>0){
        sum += n%10;
        n /= 10;
    }
    return sum;
}

ll power(ll n,ll m){
    ll x=1;
    rep(i,m){
        x *= n;
    }
    return x;
}

int main() {
    ll n;
    cin >> n;
    if((n+1)%power(10,dig(n)-1) == 0) cout << sumdig(n) << endl;
    else cout << sumdig(n - n%power(10,dig(n)-1) -1) << endl;
}

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

int main()
{
    int N, R;
    cin >> N >> R;
    int ratio = 0;
    if (N < 10)
        cout << R + 100 * (10 - N) << endl;
    else
        cout << R << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
int main() {
  int n;
  std::cin >> n;
  std::vector<int> v, c;
  v.resize(n);
  c.resize(n);
  for (auto &vi: v) std::cin >> vi;
  for (auto &ci: c) std::cin >> ci;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (v[i] > c[i]) {
      ans += v[i] - c[i];
    }
  }
  std::cout << ans;
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP0(i, n) for (int i = (n)-1; i >= 0; --i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define RREP1(i, n) for (int i = (n); i >= 1; --i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = int(1e9) + 1;
const LL LLINF = LL(1e18) + 1;
long double eps = 1.0E-14;
#define pow10(n) int(1e##n + n)

void solve()
{
    LL ans = 0;
    int N;
    cin >> N;
    vector<LL> AB(N);
    REP0 (i, N)
    {
        LL A, B;
        cin >> A >> B;
        ans -= B;
        AB[i] = A + B;
    }

    sort(AB.begin(), AB.end(), [](LL a, LL b){return a > b; });
    REP0(i, N)
    {
        if (i%2==0)
        {
            ans+= AB[i];
        }
    }
    std::cout << ans << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(20);
    solve();
    return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
const int maxn = 100005;
struct node {
	int index, val, bl;
	int ss;
	node() {}
	node(int index, int val, int bl) :index(index), val(val), bl(bl) {}
	bool operator < (const node nod) const {
		return bl < nod.bl || (bl == nod.bl && val < nod.val);
	}
}no[maxn];
int cmp(node no1, node no2) {
	return no1.index < no2.index;
}
inline void prt(int x) {
	int dgt = 0, tmp = x;
	while (tmp) {
		dgt++;
		tmp /= 10;
	}
	int lft = 6 - dgt;
	for (int i = 0; i < lft; i++)
		printf("0");
	printf("%d", x);
}
int main()
{
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= m; i++) {
		cin >> no[i].bl >> no[i].val;
		no[i].index = i;
	}
	sort(no + 1, no + m + 1);
	int p = 0, rk = 0;
	for (int i = 1; i <= m; i++) {
		if (no[i].bl == p) {
			no[i].ss = ++rk;
		}
		else {
			p = no[i].bl;
			no[i].ss = rk = 1;
		}
	}
	sort(no + 1, no + m + 1, cmp);
	for (int i = 1; i <= m; i++) {
		prt(no[i].bl);
		prt(no[i].ss);
		puts("");
	}
	return 0;
}

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

int main() {
	int n,x,cnt;

	while(cin >> n >> x && !(n == 0 && x == 0)) {
		cnt = 0;
		for(int i = 1;i <= n;i++) {for(int j = i + 1;j <= n;j++) {for(int k = j + 1;k <= n;k++) {
			cnt += (i + j + k == x);
		}}}
		cout << cnt << endl;
	}
}

Measured memory_bytes: 1160
import java.util.*;
class Main
{
  public static void main(String args[])
  {
    Scanner sc= new Scanner(System.in);
    int n=sc.nextInt();
    int p=sc.nextInt();
    int ll=n*2;
    int ul=4*n;
    if(p%2!=0)
      System.out.println("No");
    else if(p>=ll && p<=ul)
      System.out.println("Yes");
    else
      System.out.println("No");
  }
}

Measured memory_bytes: 27084
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		scan.useDelimiter("\\s"); //?????????????????´??????????????¨?????±???????????????\\???????????????
		int i =0;
		while(i == 0) {
			int h = scan.nextInt();//??´??°??\????????????
			int w = scan.nextInt();//??´??°??\???????¨????

			if (h == 0 && w == 0) { //h w???0?????¨????????????
				break;
			} else if (h > 0){ //0??§???????????£?????¨????????????
				for (int j = 0; j < h; j++) { //j???h????????§?????????????????§??????
					for (int k = 0; k < w; k++) { //k???w????????§?????????????????§??????
						System.out.print("#");
					}
					System.out.println();
				}
				System.out.println();
			}

		}

	}

}

Measured memory_bytes: 37060
import java.io.*;
import java.math.BigInteger;
import java.util.*;
public class Main{
	static BufferedReader br;
	static int cin() throws Exception
	{
		return Integer.valueOf(br.readLine());
	}
	static int[] split() throws Exception
	{
		String[] cmd=br.readLine().split(" ");
		int[] ans=new int[cmd.length];
		for(int i=0;i<cmd.length;i++)
		{
			ans[i]=Integer.valueOf(cmd[i]);
		}
		return ans;
	}
	static long[] splitL() throws IOException
	{
		String[] cmd=br.readLine().split(" ");
		long[] ans=new long[cmd.length];
		for(int i=0;i<cmd.length;i++)
		{
			ans[i]=Long.valueOf(cmd[i]);
		}
		return ans;
	}
	static long power(long x,long y,long p)
	{
		long res=1;
		x=x%p;
		while(y>0)
		{
			if((y&1)==1)
				res=(res*x)%p;
			y=(y>>1);
			x=(x*x)%p;
		}
		return res;
	}
	static long inv(long x,long p)
	{
		return power(x,p-2,p);
	}
	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub
		br=new BufferedReader(new InputStreamReader(System.in));
		long[]ar=splitL();
		long n=ar[0];
		long x=ar[1];
		long m=ar[2];
		long ans=0;
		long[]sum=new long[1000001];
		int[] rem=new int[(int)m];
		int len=0;
		int r=0;
		long s=0;
		while(true)
		{
			r=(int)(x%m);
			if(rem[r]!=0)
				break;
			s+=r;
			len++;
			rem[r]=len;
			sum[len]=s;
			x=(long)((long)r*r);
		}
//		System.out.println(r+" "+rem[r]+" "+len);
		int cyc=len-rem[r]+1;
		long a=0;
		if(rem[r]!=0)
			a=sum[rem[r]-1];
		long b=sum[len];
		if(rem[r]!=0)
			b-=sum[rem[r]-1];
		n=n-rem[r]+1;
		long c=n/cyc;
		long d=n%cyc;
		long e=sum[(int)(rem[r]+d-1)]-sum[rem[r]-1];
		ans=a+b*c+e;
		System.out.println(ans);
	}
}


Measured memory_bytes: 40780
#include <stdio.h>

int main(){
    int i, j, sum, prm[1000000], ls[78498];
	
    for(i = 0; i < 1000000; i++) prm[i] = 1;
	
    for(i = 4; i < 1000000; i += 2) prm[i] = 0;
	
    prm[0] = prm[1] = 0;
	
    for(i = 3; i * i < 1000000; i += 2)
        if(prm[i])
            for(j = i * 2; j < 1000000; j += i) prm[j] = 0;
            
    ls[0] = 2;
			
    for(i = 3, j = 1; i < 1000000; i += 2)
        if(prm[i]) ls[j++] = i;
	
	while(scanf("%d", &i), i){
	    j = sum = 0;
	    
	    while(j < i) sum += ls[j++];
	    
	    printf("%d\n", sum);
	}
    
    return 0;
}

Measured memory_bytes: 4808
## coding: UTF-8
from decimal import *
from itertools import permutations, combinations,combinations_with_replacement,product
import math



s = input().split()
p = [int(w) for w in s] #これで勝手にNまで拾ってくれます

H = p[0]
W = p[1]

a = []
for i in range(H):
    a.append(input())


#パディング
#グリッド入力と組み合わせる
#上と下に入れる行を作る
b = ''
for i in range(W+2):
    b += '#'
#print(b)
#上と下と右と左に空きマスを挿入する
a.insert(0, b)
for i in range(1, 1+H):
    a[i] = '#' + a[i] + '#'
a.append(b)











header = ' '
for i in range(len(a[0])):
    header += ('{}'.format(i))

c=[]
for i in range(H+2):
    c.append([])

for i in range(H+2):
    for j in range(W+2):
        c[i].append(a[i][j])


#print(header)
#for i in range(len(c)):
    #print('{}{}'.format(i,''.join(c[i])))



white = 0
for i in range(H+2):
    for j in range(W+2):
        if(c[i][j] == '.'):
            white += 1
#print('white:{}'.format(white))



start = [1, 1]
goal = [H, W]

c[start[0]][start[1]] = 'u'


def see_banmen():
    print(header)
    for i in range(len(c)):
        print('{}{}'.format(i,''.join(c[i])))


queue = [start]
next_list = [] #次の歩数で探すものを格納しておく
step = 0
mode = 0
answer_mode = 0
status = True #ゴール判定でゴールについていたらFalseにする
answer = -1
#see_banmen()
while status:
    if(len(queue) > 0):
        pivot = queue.pop(0) #軸足はqueueの先頭
        x = pivot[0]
        y = pivot[1]
        if(c[x+1][y] == '.'):
            c[x+1][y] = 'u'
            next_list.append([x+1, y])
        if(c[x-1][y] == '.'):
            c[x-1][y] = 'u'
            next_list.append([x-1, y])
        if(c[x][y+1] == '.'):
            c[x][y+1] = 'u'
            next_list.append([x, y+1])
        if(c[x][y-1] == '.'):
            c[x][y-1] = 'u'
            next_list.append([x, y-1])
        c[x][y] = 'd'
    else:
        #stepを進めます
        if(len(next_list) > 0):
            for i in range(len(next_list)):
                queue.append(next_list.pop(0))
            next_list = []
            #print()
            #print('step{}end'.format(step))
            if(c[goal[0]][goal[1]] == 'd' and answer_mode == 0):
                answer = step
                answer_mode = 1
                #print()
                #print('goal:step{}'.format(answer))
                #print()
            step += 1
            #see_banmen()
        elif(mode == 0):
            #もう進めない
            mode = 1
            #print()
            #print('step{}end'.format(step))
            if(c[goal[0]][goal[1]] == 'd' and answer_mode == 0):
                #goal についているならgoal歩数を登録してanswer_mode を　1にする
                answer = step
                answer_mode = 1
                #print()
                #print('goal:step{}'.format(answer))
                #print()
            #goalについていない/goalについていなかったら歩数を進める
            step += 1
            #see_banmen()
        else:
            status = False
#print(answer)

#print(white - answer - 1)
if(answer == -1):
    print(-1)
else:
    print(white - answer - 1)

Measured memory_bytes: 5172
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;

public class Main {

	Scanner sc = new Scanner(in);
	
	void run() {
		int[][] cost = new int[100][100];
		int INF = Integer.MAX_VALUE/3;
		while (true) {
			int n = sc.nextInt(), m = sc.nextInt(), s = sc.nextInt()-1, g1 = sc.nextInt()-1, g2 = sc.nextInt()-1;
			if (n == 0) break;
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++)
					cost[i][j] = INF;
				cost[i][i] = 0;
			}
			
			for (int i = 0; i < m; i++) {
				int b1 = sc.nextInt()-1, b2 = sc.nextInt()-1, c = sc.nextInt();
				cost[b1][b2] = c;
			}
			
			for (int k = 0; k < n; k++)
				for (int i = 0; i < n; i++)
					for (int j = 0; j < n; j++)
						cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
			
			int res = INF;
			for (int i = 0; i < n; i++) {
				res = min(res, cost[s][i]+cost[i][g1]+cost[i][g2]);
			}
			
			out.println(res);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 62820
#include <iostream>
#include <iterator>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
  vector<vector<int>> A(3, vector<int>(3));
  for (int j = 0; j < 3; ++j) {
    copy_n(istream_iterator<int>(cin), 3, A[j].begin());
  }
  int N;
  cin >> N;
  vector<int> b(N);
  copy_n(istream_iterator<int>(cin), N, b.begin());
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < 3; ++j) {
      for (int k = 0; k < 3; ++k) {
        if (b[i] == A[j][k]) {
          A[j][k] = 0;
        }
      }
    }
  }
  const char* result = "No";
  for (int j = 0; j < 3; ++j) {
    if ((A[j][0] == 0) && (A[j][1] == 0) && (A[j][2] == 0)) {
      result = "Yes";
    }
  }
  for (int k = 0; k < 3; ++k) {
    if ((A[0][k] == 0) && (A[1][k] == 0) && (A[2][k] == 0)) {
      result = "Yes";
    }
  }
  if ((A[0][0] == 0) && (A[1][1] == 0) && (A[2][2] == 0)) {
    result = "Yes";
  }
  if ((A[0][2] == 0) && (A[1][1] == 0) && (A[2][0] == 0)) {
    result = "Yes";
  }
  cout << result << endl;
  return 0;
}


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

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
#define db double
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }	
const int maxn=108;
char s[maxn][maxn];
int mp[maxn];
bool judge()
{
	bool flag=true;
	REP(i,26)
		if(mp[i]%4)
			flag=false;
	return flag;
}
int main()
{
	int n,m;
	while(scanf("%d%d",&n,&m)==2)
	{
		memset(mp,0,sizeof(mp));
		FORE(i,1,n)
			scanf("%s",s[i]+1);
		FORE(i,1,n)
			FORE(j,1,m)
				mp[s[i][j]-'a']++;
		if(n%2==1&&m%2==1)
		{
			bool ans=false;
			REP(i,26)
				if(mp[i]&1){
					mp[i]--;
					ans=true;
					break;
				}
			int k=n+m-2;
			while(k>0){
				bool flag=false;
				REP(i,26)
					if(mp[i]%4){
						mp[i]-=2;
						flag=true;
						break;
					}
				if(!flag){
					REP(i,26)
						if(mp[i]>0){
							mp[i]-=2;break;
						}
				}
				k-=2;
			}
			if(ans&&judge())	printf("Yes\n");
			else	printf("No\n");
		}
		else	if(n%2==1)
		{
			int k=m;
			while(k>0){
				bool flag=false;
				REP(i,26)
					if(mp[i]%4){
						mp[i]-=2;
						flag=true;
						break;
					}
				if(!flag){
					REP(i,26)
						if(mp[i]>0){
							mp[i]-=2;break;
						}
				}
				k-=2;
			}
			if(judge())	printf("Yes\n");
			else	printf("No\n");
		}
		else if(m%2==1)
		{
			int k=n;
			while(k>0){
				bool flag=false;
				REP(i,26)
					if(mp[i]%4){
						mp[i]-=2;
						flag=true;
						break;
					}
				if(!flag){
					REP(i,26)
						if(mp[i]>0){
							mp[i]-=2;break;
						}
				}
				k-=2;
			}
			if(judge())	printf("Yes\n");
			else	printf("No\n");
		}
		else{
			if(judge())	printf("Yes\n");
			else	printf("No\n");
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
long long  N;
int count = 0;
void dfs(long long t,unsigned char k){
	if(t<=N){
		if(k == 7){
			count++;
		}
		dfs(t*10+3,k|1);
		dfs(t*10+5,k|2);
		dfs(t*10+7,k|4);
	}
}
int main(){
	//freopen("_intimesoftrain.txt","r",stdin);
	scanf("%lld",&N);
	dfs(0,0);
	printf("%d",count);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define LINF 1000000000000000007LL
#define ll long long
using namespace std;
int a[214514];
signed main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	int ans = 0;
	int cur = 0;
	for(int i=1;i<=n;i++){
		if( i == a[i] ) cur ++;
		else{
			ans += (cur+1)/2;
			cur = 0;
		}
	}
	ans += (cur+1)/2;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

ll solve(){
  int N;cin >> N;
  vector<ll> v(N);
  rep(i,N)cin >> v[i];
  sort(all(v),greater<ll>());
  if(v[N-1] == 0) return 0;
  ll mul = 1ll;
  rep(i,N){
    if(sqrt(mul) * sqrt(v[i]) > 1e9) return -1;
    mul *= v[i];
    if(mul > 1000000000000000000 || mul < 0) return -1;
  }
  return mul;
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  cout << solve() << endl;
  return 0;
}


Measured memory_bytes: 3992
#include<bits/stdc++.h>
using namespace std;
int main() {
  long long k,q;cin>>k>>q;
  vector<long long>d(k);for(long long i=0;i<k;i++)cin>>d[i];
  for(long long Q=0;Q<q;Q++){
    long long N,X,M;cin>>N>>X>>M;X%=M;
    long long C=0;
    vector<long long>D(k);for(long long i=0;i<k;i++){
      D[i]=d[i]%M;if(D[i]==0)D[i]=M;C+=D[i];
    }
    long long S=X;S+=C*((N-1)/k);for(long long i=0;i<(N-1)%k;i++)S+=D[i];
    cout<<N-(S/M)-1<<endl;
  }
}



Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, cnt[4];
string s;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s;
        if (s[0] == 'A') {
            cnt[0]++;
        }
        else if (s[0] == 'W') {
            cnt[1]++;
        }
        else if (s[0] == 'T') {
            cnt[2]++;
        }
        else cnt[3]++;
    }
    cout << "AC x " << cnt[0] << E;
    cout << "WA x " << cnt[1] << E;
    cout << "TLE x " << cnt[2] << E;
    cout << "RE x " << cnt[3] << E;
    //system("pause");
    return 0;
}

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


int main(){
	string s,t;
	getline(cin,s);
	bool f=true;
	for(int i=0;i<s.size();i++){
		if(s[i]==' '||s[i]=='.'||s[i]==','){
			if(3<=t.size()&&t.size()<=6){
				if(!f)cout<<' ';
				cout<<t;	
				f=false;
			}
			t.clear();
		}
		else{
			t+=s[i];
		}
	}
	if(3<=t.size()&&t.size()<=6){
		if(f)cout<<' ';
		cout<<t;
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 1168
fun main(args: Array<String>) {
    var a = "Yes"
    val (y, x) = readLine()!!.split(" ").map { it.toInt() }
    var l = (0 until y).map{ "." + readLine()!! + "."}.toMutableList()
    l.add(0, ".".repeat(x + 2))
    l.add(".".repeat(x + 2))
    for(i in 1 until y + 1){
        for(j in 1 until x + 1){
            if(l[i][j] == '#'){
                if(l[i - 1][j] != '#' && l[i + 1][j] != '#' && l[i][j - 1] != '#' &&l[i][j + 1] != '#'){
                    a = "No"
                }
            }
        }
    }
    println(a)
}

Measured memory_bytes: 37664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n;cin>>n;
  vector<ll>aa(101);
  for(ll i=0;i<=100;i++)aa[i]=0;
  for(ll i=2;i<=n;i++){
    ll m=i;
    for(ll j=2;j<=i;j++){
      for(;;){
        if(m%j!=0){
          //cout<<j<<endl;
          break;
        }
        aa[j]++;
        m=m/j;
      }
    }
  }
  vector<ll>v;
  for(ll i=0;i<=100;i++){
    if(aa[i]>0)v.push_back(aa[i]);
  }
  ll si=v.size();
  ll dp[si+1][8];
  for(ll i=0;i<=si;i++)for(ll j=0;j<8;j++)dp[i][j]=0;
  dp[0][0]=1;
  for(ll i=0;i<si;i++){
    for(ll j=0;j<8;j++){
      if(j==4||j==5)continue;
      dp[i+1][j]+=dp[i][j];
      ll k=j;
      ll a=k%2;k/=2;ll b=k%2;k/=2;ll c=k%2;
      if(v[i]<2)continue;
      else if(v[i]<4){
        if(a==0)dp[i+1][j+1]+=dp[i][j];
      }
      else if(v[i]<14){
        if(a==0)dp[i+1][j+1]+=dp[i][j];
        if(b==0)dp[i+1][j+2]+=dp[i][j];
        if(b==1&&c==0)dp[i+1][j+4]+=dp[i][j];
      }
      else if(v[i]<24){
        if(a==0){
          dp[i+1][j+1]+=dp[i][j];
          if(b==0){
            dp[i+1][j+2]+=dp[i][j];
            dp[i+1][j+3]+=dp[i][j];
          }
          else{
            if(c==0){
              dp[i+1][j+4]+=dp[i][j];
              dp[i+1][j+5]+=dp[i][j];
            }
          }
        }
        else{
          if(b==0)dp[i+1][j+2]+=dp[i][j];
          if(b==1&&c==0)dp[i+1][j+4]+=dp[i][j];
        }
      }
      else if(v[i]<74){
        if(a==0){
          dp[i+1][j+1]+=dp[i][j];
          if(b==0){
            dp[i+1][j+2]+=dp[i][j];
            dp[i+1][j+3]+=dp[i][j];
            dp[i+1][j+6]+=dp[i][j];
          }
          else{
            if(c==0){
              dp[i+1][j+4]+=dp[i][j];
              dp[i+1][j+5]+=dp[i][j];
            }
          }
        }
        else{
          if(b==0){
            dp[i+1][j+2]+=dp[i][j];
            dp[i+1][j+6]+=dp[i][j];
          }
          else{
            if(c==0)dp[i+1][j+4]+=dp[i][j];
          }
        }
      }
      else{
        if(a==0){
          dp[i+1][j+1]+=dp[i][j];
          if(b==0){
            dp[i+1][j+2]+=dp[i][j];
            dp[i+1][j+3]+=dp[i][j];
            dp[i+1][j+6]+=dp[i][j];
            dp[i+1][j+7]+=dp[i][j];
          }
          else{
            if(c==0){
              dp[i+1][j+4]+=dp[i][j];
              dp[i+1][j+5]+=dp[i][j];
            }
          }
        }
        else{
          if(b==0){
            dp[i+1][j+2]+=dp[i][j];
            dp[i+1][j+6]+=dp[i][j];
          }
          else{
            if(c==0)dp[i+1][j+4]+=dp[i][j];
          }
        }
      }
    }
  }
  cout<<dp[si][7]<<endl;
}
            
                                        
                        
  


Measured memory_bytes: 256
#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)(1e5 + 5);
const int MAX_M = (int)(1e5 + 5);
const ll MOD = (ll)(1e9 + 7);

int n, m;
ll x[MAX_N];
ll y[MAX_M];

ll ans;

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

  for (int i = 1; i <= n; ++i) {
    scanf("%lld", &(x[i]));
  }

  for (int i = 1; i <= m; ++i) {
    scanf("%lld", &(y[i]));
  }

  ll sum_x = 0;
  for (int i = 1; i <= n; ++i) {
    sum_x += (i - 1) * x[i] + (n - i) * -x[i];
    sum_x = sum_x % MOD;
  }

  ll sum_y = 0;
  for (int i = 1; i <= m; ++i) {
    sum_y += (i - 1) * y[i] + (m - i) * -y[i];
    sum_y = sum_y % MOD;
  }

  ans = sum_x * sum_y;
  ans = ans % MOD;

  printf("%lld\n", ans);

  return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();

		if(n%2 == 1)
			System.out.println("No");
		else{
			String firstHalf = s.substring(0,n/2);
			String secondHalf = s.substring(n-(n/2));
			if(firstHalf.equals(secondHalf))
				System.out.println("Yes");
			else
				System.out.println("No");
		}
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <math.h>
#include <string>
using ll=long long;
#define rep(i,a,b) for(ll i=a;i<ll(b);i++)
#define repr(i,a,b) for(ll i=a;i>=ll(b);i--)
#define endl "\n"
#define ALL(x) x.begin(),x.end()
#define ALLR(x) x.rbegin(),x.rend()
using namespace std;

ll a;
double b;
int main() {
	cin >> a >> b;
	ll c = b*100+0.5;
	ll ans = a * c;
	ans /= 100;
	cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3168
#include<iostream>
#include <algorithm>
using namespace std;
int main()
{
	int n,a[100005],i,t=1,ans=0;
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>a[i];
  }
	sort(a+1,a+1+n);
	for(i=1;i<=n;i++)
	{
		if(a[i]==a[i+1])	t++;
		if(a[i]!=a[i+1]||i==n-1){
			if(a[i]<t) ans+=t-a[i];
			if(a[i]>t) ans+=t;
			if(a[i]!=a[i+1]&&i==n-1)
				ans++;
			if(i<n-1)
				t=1;
			else break;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <list>
#include <cmath>
#include <numeric>
#include <sstream>
#include <iomanip>
#include <set>
using ll = long long;
using namespace std;
#define INF 999999999

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

    vector<int> X(M);
    vector<int> dX;

    for (int i = 0; i < M; i++)
        cin >> X[i];
    if (N >= M)
    {
        cout << 0 << endl;
        return 0;
    }

    sort(X.begin(), X.end());

    for (int i = 0; i < M - 1; i++)
        dX.push_back(X[i + 1] - X[i]);

    sort(dX.begin(), dX.end());
    int ans = 0;
    for (int i = 0; i < M - N; i++)
        ans += dX[i];
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
const int NMAX = 2e5 + 10;
const int MOD = 1e9 + 7;
int main(int argc, char const *argv[])
{
	ll a,b,v,w,t,s1,s2;
	scanf("%lld%lld",&a,&v);
	scanf("%lld%lld%lld",&b,&w,&t);
	s1 = a;s2 = b;
	if(a > b)	swap(a,b);
	a += v*t;
	b += w*t;
	if(a >= b || s1 == s2)
		puts("YES");
	else
		puts("NO");
	return 0;
}

Measured memory_bytes: 3764
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	sc.Scan()
	m, _ := strconv.Atoi(sc.Text())
	to := make([][]int, n)
	for i := 0; i < m; i++ {
		sc.Scan()
		a, _ := strconv.Atoi(sc.Text())
		sc.Scan()
		b, _ := strconv.Atoi(sc.Text())
		a--
		b--
		to[a] = append(to[a], b)
		to[b] = append(to[b], a)
	}

	ans := make([]int, n)
	for i := range ans {
		ans[i] = -1
	}
	qs := make([][]int, 0)
	qs = append(qs, []int{0, 0})
	for len(qs) > 0 {
		q := qs[0]
		qs = qs[1:]
		for _, cp := range to[q[0]] {
			if ans[cp] != -1 {
				continue
			}
			ans[cp] = q[0]
			qs = append(qs, []int{cp, q[1] + 1})
		}
	}
	fmt.Println("Yes")
	for i := 1; i < n; i++ {
		fmt.Println(ans[i] + 1)
	}
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


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

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N, M;
  cin >> N >> M;
  vector<vector<ll>> XYZ(N, vector<ll>(3));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> XYZ[i][j];
    }
  }
  // +++ +-+ -++ ++- +-- --+ ---
  ll res = -(1LL << 58);
  for (int i = 0; i < 8; i++) {
    priority_queue<ll> que;
    for (int j = 0; j < N; j++) {
      ll sumn = 0;
      for (int k = 0; k < 3; k++) {
        if ((i >> k) & 1) {
          sumn += XYZ[j][k];
        } else {
          sumn -= XYZ[j][k];
        }
      }
      que.push(sumn);
    }
    ll tmp = 0;
    for (int j = 0; j < M; j++) {
      tmp += que.top();
      que.pop();
    }
    res = max(res, tmp);
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 384