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

ll n,a[305][305],rez;

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

    cin>>n;
    for(ll i=1;i<=n;i++)
        for(ll j=1;j<=n;j++)
            cin>>a[i][j];

    for(ll i=2;i<n;i++)
        for(ll j1=1;j1<i;j1++)
            for(ll j2=i+1;j2<=n;j2++)
                if(a[j1][i]+a[i][j2]<a[j1][j2])
    {
        cout<<-1<<endl;
        return 0;
    }

    for(ll i=1;i<=n-1;i++)
        for(ll j=i+1;j<=n;j++)
    {
        ll ind=0;
        for(ll k=1;k<=n;k++)
        {
            if(k!=i&&k!=j)
                if(a[i][k]+a[k][j]==a[i][j])
                    ind=1;
        }

        if(ind==0)
            rez+=a[i][j];
    }

    cout<<rez<<endl;

    return 0;
}


Measured memory_bytes: 4336
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  ll n,m,x;
  cin >> n >> m >> x;
  vector<ll> c(n);
  vector<vector<ll> > a(n, vector<ll>(m));
  rep(i,n) {
    cin >> c[i];
    rep(j,m) {
      cin >> a[i][j];
    }
  }
  ll ans = 1LL<<60;
  for (int bit = 1; bit < (1<<12); ++bit) {
    ll sum = 0;
    vector<ll> a_sum(m,0);
    rep(i,n) {
      if (bit & (1<<i)) {
        sum += c[i];
        rep(j,m) a_sum[j] += a[i][j];
      }
    }
    bool ok = true;
    rep(i,m) {
      if (a_sum[i] < x) {
        ok = false; break;
      }
    }
    if (ok) {
      chmin(ans,sum);
    }
  }
  if (ans == 1LL<<60) ans = -1;
  cout << ans << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

template<typename T1,typename T2> inline void chmin(T1 &a, T2 b){ if(a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 &a, T2 b){ if(a < b) a = b; }

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
const int MAX_N = 100010;

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

    int ans = 0;
    int N;
    cin >> N;
    for(int i = 1; i <= N; ++i) {
        if(i % 3 != 0 && i % 5 != 0) { ans += i; }
    }
    printf("%lld\n", ans);

    return 0;
}


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

bool is_prime(const int n){
    switch(n){
        case 0: // fall-through
        case 1: return false;
        case 2: // fall-through
        case 3: return true;
    } // n > 3 が保証された

    if(n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である

    // 6の倍数前後の数を使って試し割りをする
    for(int i = 5; i * i <= n; i += 6) {
        if(n % i     == 0) return false; // (6の倍数)-1
        if(n % (i+2) == 0) return false; // (6の倍数)+1
    }

    return true;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int k;
    cin >> k;
    int x=7%k;
    set<int> s;
    int i=1;
    while(s.count(x) == 0){
        if(x==0){
            cout << i << "\n";
            return 0;
        }
        s.insert(x);
        x=(x*10+7)%k;
        ++i;
    }
    cout << -1 << "\n";
    return 0;
}   

Measured memory_bytes: 50408
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
ll mod=1000000007;

int main() {
  int n;cin>>n;
  vector<string> v;
  for(int i=0;i<n;++i){
    string s;cin>>s;
    vector<string> vt;
    if(i==0){
      for(int j=0;j<s.size();++j) v.push_back(s.substr(j,1));
    } else {
      for(int k=0;k<s.size();++k) vt.push_back(s.substr(k,1));
      sort(vt.begin(),vt.end());
      vector<string> vt2 = v;
      v.resize(0);
      set_intersection(vt.begin(), vt.end(),vt2.begin(), vt2.end(),
                       inserter(v, v.end()));
    }
    sort(v.begin(),v.end());
  }
  if(v.size()>0){
    for(int l=0;l<v.size();++l)
    cout << v[l];
  }
  cout << endl;
  return 0;
}


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

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////

ll p(ll N) {
	if (N == 0) { return 0; }
	if (N == 1) { return 10; }
	return 10 * p(N - 1);
}

ll k(ll N, ll i) {
	if (i == 0) { return N % 10; }
	return k(N / 10, i - 1);
}



int main() {

	ll N, M;
	cin >> N >> M;

	vector<ll> s(M + 1), c(M + 1);
	repn(i, M) cin >> s[i] >> c[i];

	for (ll n = p(N - 1); n < p(N); n++) {
		bool b = 1;

		repn(j, M) {
			if (k(n, N - s[j]) != c[j]) { b = 0; }

		}

		if (b == 1) { cout << n; break; }
		if (n == p(N) - 1) { cout << -1; }
	}



	system("PAUSE");
}






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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    string s; cin>>s;
    set<char> st;
    rep(i,s.size()){
        st.insert(s[i]);
    }
    if(st.size()==s.size()) cout<<"yes"<<endl;
    else cout<<"no"<<endl;
    return 0;
}

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

#define all(x) (x).begin(),(x).end()

#define MOD 1000000007

using namespace std;

int main(){
	int a, b, c, k;	cin >> a >> b >> c >> k;
	int ans = 0;

	ans = a;
	if( a > k ){
		ans = k;
	}else if( a + b < k ){
		ans -= k - a - b;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((int)1e6 + 3)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 1, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 0) u += MOD;
    return u;

}
int exp(int a, int b){
    LL res = 1;
    LL sum = a;
    for(int i=0;i<30;++i){
        if(BIT(i)&b){
            res = (res * sum)%MOD;
        }
        sum = (sum * sum) % MOD;
    }
    return res;
}

int main(){
    LL a, b;
    cin >> a >> b;
    if(a>0){
        cout << "Positive" << endl;
    }else if(b<0){
        if((b-a)%2){
            cout << "Positive" << endl;
        }else{
            cout << "Negative" << endl;
        }
    }else{
        cout << "Zero" << endl;
    }
    return 0;
}


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

int main() {
  string s;
  cin >> s;
  char c[4] = {'A', 'C', 'G', 'T'};
  int result = 0, count = 0;
  int i, j;
  for (i = 0; i < s.length(); i++) {
    for (j = 0; j < 4; j++) {
      if (s.at(i) == c[j]) {
        count++;
        break;
      }
      if (j == 3) {
        count = 0;
      }
    }
    result = max(result, count);
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
import math
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))
mod = 10**9 + 7 
sys.setrecursionlimit(1000010)

N = ni()
good={}
ans = 0 
for i in range(N):
    x = ns()
    if x in good:
        good[x]=good[x]+1
    else:
        good[x] = 1 
        ans = ans + 1

print(ans)


Measured memory_bytes: 35352
n, a, b = map(int, input().split())

if (b - a) % 2:
    if a - 1 < n - b:
        ans = a - 1 + (b - a + 1) // 2
    else:
        ans = n - b + (b - a + 1) // 2

else:
    ans = (b - a) // 2

print(ans)


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

int np;

typedef struct node {
  int location;
  int l;
  int r;
} Node;

Node* T;

typedef int Point[3];

Point* P;
int plen;
int *ans;
int alen;

int compint(const void *a, const void *b)
{
  return *(int *)a - *(int *)b;
}

int lessX(const void *a, const void *b)
{
  return (*(Point*)a)[0] - (*(Point*)b)[0];
}

int lessY(const void *a, const void *b)
{
  return (*(Point*)a)[1] - (*(Point*)b)[1];
}

int (*compar[])(const void*, const void*) = { lessX, lessY };

int make2DTree(int l, int r, int depth)
{
  if (l>=r) return -1;
  int mid = (l+r)/2;
  int t = np++;
  if (r-l>1)
    qsort(&P[l], r-l, sizeof(Point), compar[depth % 2]);
  T[t].location = mid;
  T[t].l = make2DTree(l, mid, depth + 1);
  T[t].r = make2DTree(mid+1, r, depth + 1);

  return t;
}


void find(int v, int sx, int tx, int sy, int ty, int depth)
{
  int x = P[T[v].location][0];
  int y = P[T[v].location][1];
  if (sx<=x && x<=tx && sy<=y && y<=ty) {
    ans[alen++] = P[T[v].location][2];
  }
  if (depth%2 == 0) {
    if (T[v].l >= 0 && sx <=  x)   find(T[v].l, sx, tx, sy, ty, depth + 1);
    if (T[v].r >= 0 && x  <= tx)   find(T[v].r, sx, tx, sy, ty, depth + 1);
  } else {
    if (T[v].l >= 0 && sy <=  y)   find(T[v].l, sx, tx, sy, ty, depth + 1);
    if (T[v].r >= 0 && y  <= ty)   find(T[v].r, sx, tx, sy, ty, depth + 1);
  }
}

int main()
{
  int i, j, k, n, q, sx, tx, sy, ty, x, y, z;
  char buf[64], *p;
  buf[63] = 0;
  fgets(buf, 64, stdin);
  for (n=0,p=buf; *p!='\n'; n=n*10+*(p++)-'0');

  plen = n;
  P = (Point*)malloc(sizeof(Point)*n);
  T = (Node*)malloc(sizeof(Node)*n);
  ans = (int*)malloc(sizeof(int)*n);
  alen = 0;
  int sign;
  for (i=0; i<n; i++) {
    fgets(buf, 64, stdin);
    P[i][2]=i;
    sign = 0;
    p = buf;
    if (*p=='-') { sign=1; p++; }
    for (P[i][0]=0; *p!=' '; P[i][0]=P[i][0]*10+*(p++)-'0');
    if (sign) P[i][0]=-P[i][0];
    sign=0;
    if (*(++p)=='-') { sign=1;   p++; }
    for (P[i][1]=0; *p!='\n'; P[i][1]=P[i][1]*10+*(p++)-'0');
    if (sign) P[i][1]=-P[i][1];
    T[i].l = T[i].r = -1;
  }

  np = 0;
  int root = make2DTree(0, n, 0);
  
  fgets(buf, 64, stdin);
  for (q=0,p=buf; *p!='\n'; q=q*10+*(p++)-'0');

  while (fgets(buf, 64, stdin)) {
    sign = 0;
    p = buf;
    if (*p=='-') { sign=1; p++; }
    for (sx=0; *p!=' '; sx=sx*10+*(p++)-'0');
    if (sign) sx = -sx;
    
    sign = 0; p++;
    if (*p=='-') { sign=1; p++; }
    for (tx=0; *p!=' '; tx=tx*10+*(p++)-'0');
    if (sign) tx=-tx;

    sign = 0;
    if (*(++p)=='-') { sign=1; p++; }
    for (sy=0; *p!=' '; sy=sy*10+*(p++)-'0');
    if (sign) sy=-sy;

    sign = 0;
    if (*(++p)=='-') { sign=1; p++; }
    for (ty=0; *p!='\n'; ty=ty*10+*(p++)-'0');
    if (sign) ty=-ty;

    alen = 0;
    find(root, sx, tx ,sy, ty, 0);
    if (alen>1)
      qsort(ans, alen, sizeof(int), compint);
    for (i=0; i<alen; i++) {
      int d = ans[i];
      for (j=1; j*10<=d; j*=10);
      for (;j>0; j/=10) {
	putc_unlocked('0'+d/j, stdout);
	d %= j;
      }
      putc_unlocked('\n', stdout);
    }
    putc_unlocked('\n', stdout);
    alen = 0;
  }

  return 0;
}



Measured memory_bytes: 18572
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    
    cin >> s;
    int n = s.size();
    
    int start = 0;
    for(int i=0;i<n;i++){
        if(s[i]=='A') {
            // cout << "ok";
            start = i;
            break;
        }
    }
    
    int end = 0;
    for(int i=n;i>=0;i--){
        if(s[i]=='Z'){
            end = i;
            break;
        }
    }
    cout << end - start +1;
    return 0;
}


Measured memory_bytes: 3740
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;

// グラフの用意
bool G[10][10];

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> a(n), b(n), v(n);

    rep(i,n){
        v[i] = i;
    }

    rep(i,m){
        int a, b;
        cin >> a >> b;
        a--; b--;

        G[a][b] = G[b][a] = true;
    }

    int ans = 0;

    do{
        bool jud = true;

        if(v[0] !=0) break;

        for(int i=0; i<n-1; i++){
            if(!G[v[i]][v[i+1]]){
                jud = false;
                break;
            }
        }

        if(jud) ans++;

    }
    while(next_permutation(all(v)));

    dunk(ans);
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cstdio>
#include<cmath>
using namespace std;
int main(void){
    // Your code here!
    int n,m; //ｎは与えられるデータ数、ｍはデータ
    string box;
    //cin >> n;
    
    
    while(1){
        cin >> n;
        if(n == 0) break;
        
        double average = 0,sum=0,s=0,deviation=0,stdev=0; //sはぶんさん , stdevは標準偏差,devitationは偏差
        
        for(int i = 0; i < n;i++){  //箱に数字を入れて、それから平均を引いて分散を求める
            scanf("%d", &m);
            box[i] = m; //boxはstring型なので、そのまま使うとアスキーコードが表示か使われる。
            
            sum += m;
            //cout << "box[" << i << "] " << int (box[i]) << endl;
        }
        average = sum / n;
        
        for(int j = 0; j < n;j++){   //分散を求める
            deviation += (int(box[j]) - average)*(int(box[j]) - average);  //偏差の合計
            
        }
        
        s = deviation / n;
        stdev = sqrt(s);
        
        printf("%lf\n", stdev);
        //cout << stdev << endl;
    }
    
    
}




Measured memory_bytes: 3236
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    string s;
    ll z = 0;
    int a = 0, b[2][2020] = {};
    cin >> s;
    for (int i = 1; i <= s.length(); i++) {
        a = (a * 10 + s[i - 1] - '0') % 2019;
        for (int j = 0; j < 2019; j++) b[i & 1][j] = 0;
        for (int j = 0; j < 2019; j++) b[i & 1][j * 10 % 2019] += b[~i & 1][j];
        z += b[i & 1][a];
        if (!a) z++;
        b[i & 1][a]++;
    }
    cout << z;
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

template <typename T>
struct edge {
  int s, t;
  T c;
  edge() {}
  edge(int t, T c) : s(-1), t(t), c(c) {}
  edge(int s, int t, T c) : s(s), t(t), c(c) {}
};

template <typename T> using Edges = vector<edge<T>>;
template <typename T> using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template <typename T> using Matrix = vector<vector<T>>;

template <typename T>
void warshall_floyd(Matrix<T> &g, T inf) {
  for (int k = 0; k < g.size(); k++) {
    for (int i = 0; i < g.size(); i++) {
      for (int j = 0; j < g.size(); j++) {
        if (g[i][k] == inf || g[k][j] == inf) continue;
        g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
      }
    }
  }
}

int N,M,R;
int r[10];

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

  cin >> N >> M >> R;
  REP(i,R) cin >> r[i], r[i]--;
  Matrix<int> G(N,vector<int>(N,INF));
  REP(i,N) G[i][i] = 0;
  REP(i,M) {
    int A,B,C;
    cin >> A >> B >> C;
    A--; B--;
    G[A][B] = G[B][A] = C;
  }
  warshall_floyd(G,INF);
  sort(r,r+R);
  int ans = INF;
  do {
    int sum = 0;
    for (int i = 1; i < R; i++) {
      sum += G[r[i-1]][r[i]];
    }
    CHMIN(ans,sum);
  } while (next_permutation(r,r+R));
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 640
//g++ -std=c++17 -Wshadow -Wall -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -g PROGRAM -o OUTPUT -DLOCAL -lasan -lubsan
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define alli(a, n, k) (a + k), (a + n + k)
#define FP(i, a, b, k) for (__typeof(a) i = a; i < b; i += k)
#define FS(i, a, b, k) for (__typeof(a) i = a; i > b; i -= k)
#define IT(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
using namespace __gnu_pbds;

template <class T>
inline T gcd(T x, T y)
{
    if (!y)
        return x;
    return gcd(y, x % y);
}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector<pair<int, int>> VPII;
typedef vector<pair<int, PII>> VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;


inline ll modulo(ll a, ll m)
{
    return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
    assert(__gcd(a, m) == 1);
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
        return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;

        m = a % m, a = t;
        t = y;

        y = x - q * y;
        x = t;
    }

    if (x < 0)
        x += m0;

    return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
    if (y == 0)
        return 1LL;
    else if (y == 1)
        return x;
    else
    {
        ll ans = modPow(x, y / 2, m) % m;
        if (y & 1)
        {
            return (((ans * ans) % m) * x) % m;
        }
        else
        {
            return (ans * ans) % m;
        }
    }
}

vector<string> split(char d,string s)
{
    stringstream ss(s);
    string t;
    vector<string> words;
    while(getline(ss,t,d))
    {
        words.pb(t);
    }

    return words;
}

int main(int argc, char *argv[])
{
#ifdef LOCAL
    auto start = chrono::high_resolution_clock::now();
#endif
    
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int a, b, n;
    cin >> a >> b >> n;

    cout << b / n - (a-1) / n;
    exit(0);

#ifdef LOCAL
    auto end = chrono::high_resolution_clock::now();
    double time_taken =
        chrono::duration_cast<chrono::nanoseconds>(end - start).count();

    time_taken *= 1e-9;

    cerr << "\nTime taken by program is : " << fixed
         << time_taken << setprecision(9);
    cerr << " sec" << endl;
#endif
    return 0;
}


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

int main() {
  int w,h,x,y,r;
  cin >> w >> h >> x >> y >> r;
  
  if( (x+r <= w && x>=r) && (y+r <= h && y>=r) ){
  
     cout << "Yes" << endl;
     
  }
  
  else{
      
     cout << "No" << endl;
     
  }
  
}



Measured memory_bytes: 3100
import sys

input = sys.stdin.readline
N = int(input())
Ss = {}
for i in range(N):
    s = ''.join(sorted(list(input().rstrip("\n"))))
    if s in Ss:
        Ss[s] += 1
    else:
        Ss[s] = 1

c = 0
for s in Ss.values():
    c += (s - 1) * s // 2

print(c)

Measured memory_bytes: 57052
#include <bits/stdc++.h>
using namespace std;
int main(){
    // Your code here!
   int N,K;
   cin >> N >> K;
   vector<int> A(N);
   for (int i=0;i<N;i++){
       cin >> A.at(i);
   }
   int a;
   a = 0;
   for (int i=0;i<N;i++){
       if (A.at(i)>=K){
           a++;
       }
   }
   cout << a << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#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
#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 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; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  string s; 
  cin >> s;

  int N = s.size();
  
  REP(i, N){
    if(s[i] == '?') s[i] = 'D';
  }

  cout << s << "\n";

  return 0;
}

Measured memory_bytes: 3780
/*
#include <boost/multiprecision/cpp_int.hpp>
typedef boost::multiprecision::cpp_int mint; //*/
#include <bits/stdc++.h>
#define  rep(i,n) for(li i=0;i<(n);i++)
#define  red(i,n) for(li i=(n)-1;i>=0;i--)
#define  all(a) begin(a),end(a)
#define  pb(a) push_back(a)
using namespace std;
typedef long int li;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<string> vs;
 
int main()
{
    ull n,ans;
    cin>>n;
    for(ull i=1;i*i<=n;i++) if(n%i==0) ans=i;
    cout<<(ull)floor(log10(n/ans))+1<<endl;

    return 0;
}

Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <iterator>
#include <functional>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <list>
#include <sstream>
#include <cstring>
#include <stdio.h>
#include <complex>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

typedef long double LD;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<LD, LD> PDD;
typedef pair<LL, int> PLL;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<char> VCH;
typedef vector<LD> VLD;
typedef vector<string> VS;
typedef vector<VS> VSS;
typedef vector<VI> VVI;
typedef vector<VLL> VVLL;
typedef vector<VCH> VVCH;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<PDD> VPDD;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define next fake_next
#define prev fake_prev
#define left fake_left
#define right fake_right

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))

const LD PI = acos(-1.0);
const LD EPS = 1e-4;
const LL INF = 1e7 - 1;
const LL mod = 1000000007;
const LL LINF = 1e18 + 10;
const int MAXN = 100001;
const int MAXK = 101;

int n;
VVI g;
VI a;

bool dfs(int v, int p)
{
	if (p != -1 && a[v] >= a[p])
		return 1;

	bool res = 0;
	for (auto i : g[v])
	{
		if (i == p)
			continue;

		res |= !dfs(i, v);
	}

	return res;
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	
	cin >> n;
	a.resize(n);
	g.resize(n);
	int u, v;
	FOR(i, 0, n)
		cin >> a[i];

	FOR(i, 0, n - 1)
	{
		cin >> u >> v;
		--u; --v;
		g[u].push_back(v);
		g[v].push_back(u);
	}

	FOR(i, 0, n)
		if (dfs(i, -1))
			cout << i + 1 << " ";

	cin >> n;
	return 0;
}

Measured memory_bytes: 512
#n, m, q = map(int, input().split())
#List = list(map(int, input().split()))
#req = [list(map(int, input().split())) for _ in range(q)]
#t = t[:-1]
#print(ans[j], end = "") 改行無しで出力
#[0]*n
n = int(input())
if n % 1000 == 0:
    print(0)
else:
    a = n % 1000
    print(1000-a)


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

using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define inf 1000000100

int main()
{
   ll n, x;
   cin >> n >> x;
   vector<long long> candy;
   while(n--)
   {
       int a;
       cin >> a;
       candy.pb(a);
   }
   ll ans = 0;
   for(int i = 1; i < candy.size(); i++)
   {
       if(i == 1)
       {
           if(candy[i-1] > x)
           {
               ans += candy[i-1] - x;
               candy[i-1] = x;
           }
       }

       if(candy[i-1] + candy[i] > x)
       {
           ans += candy[i-1] + candy[i] - x;
           candy[i] -= candy[i-1] + candy[i] - x;
       }
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 1400
package main

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

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 minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func maxInt64(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

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

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumInt64(a []int64) int64 {
	var ret int64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

// sort ------------------------------------------------------------

type int64Array []int64

func (s int64Array) Len() int           { return len(s) }
func (s int64Array) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s int64Array) Less(i, j int) bool { return s[i] < s[j] }

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

// -----------------------------------------------------------------

func main() {
	a:= readInt()
	b:= readInt()
	t:= readInt()

	fmt.Println(t/a * b)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
typedef long long LL;
typedef double dl;
#define opt operator
#define pb push_back
const LL maxn=1e6+9,mod=998244353,inf=0x3f3f3f3f;
LL Read(){
	LL x(0),f(1); char c=getchar();
	while(c<'0' || c>'9'){
		if(c=='-') f=-1; c=getchar();
	}
	while(c>='0' && c<='9'){
		x=(x<<3ll)+(x<<1ll)+c-'0'; c=getchar();
	}return x*f;
}
void Chkmin(LL &x,LL y){
	if(y<x) x=y;
}
void Chkmax(LL &x,LL y){
	if(y>x) x=y;
}
LL add(LL x,LL y){
	return x+=y,x>=mod?x-mod:x;
}
LL dec(LL x,LL y){
	return x-=y,x<0?x+mod:x;
}
LL mul(LL x,LL y){
	return 1ll*x*y%mod;
}
LL n;
LL a[maxn],deg[maxn],mark[maxn],ans[maxn];
std::vector<LL> V[100009];
std::queue<LL> que;
int main(){
    n=Read();
    for(LL i=1;i<n;++i){
    	LL x(Read()),y(Read());
    	V[x].pb(y); V[y].pb(x);
    	deg[x]++; deg[y]++;
	}
	for(LL i=1;i<=n;++i){
		a[i]=Read();
	}
	std::sort(a+1,a+1+n);
	LL sum(0);
	for(LL i=1;i<n;++i){
		sum+=a[i];
	}
	printf("%lld\n",sum);
	for(LL i=1;i<=n;++i){
		if(deg[i]==1) que.push(i),mark[i]=1;
	}
	for(LL i=1;i<=n;++i){
		LL x(que.front()); que.pop();
		ans[x]=a[i];
		for(LL k=0;k<V[x].size();++k){
			LL v(V[x][k]); if(mark[v]) continue;
			deg[v]--;
			if(deg[v]==1){
				mark[v]=1;
				que.push(v);
			}
		}
	}
	for(LL i=1;i<=n;++i) printf("%lld ",ans[i]);
	puts("");
	return 0;
}



Measured memory_bytes: 6824
#include<iostream>
#include<vector>
#define MAX_N 200050

using namespace std;

vector<int> G[MAX_N];
int n,m;
int dp[MAX_N];

int dfs(int u){
    if(dp[u] != -1) return dp[u];
    int res = 0;
    for(auto v : G[u]){
        res = max(res,dfs(v)+1);
    }
    return dp[u] = res;
}

int main(){
    cin >> n >> m;
    for(int i=0;i < m;i++){
        int x,y;
        cin >> x >> y;
        --x;--y;
        G[x].push_back(y);
    }
    for(int i=0;i < MAX_N;i++) dp[i] = -1;
    int ans = 0;
    for(int i=0;i < n;i++){
        ans = max(ans,dfs(i));
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 14156
character(250000) S
integer a,z
read*,S
do i=1,len_trim(S)
if(S(i:i)=="A")then
 a=i 
 exit
endif
end do
z=a
do i=a,len_trim(S)
if(S(i:i)=="Z")z=i
end do
print"(I0)",z-a+1
end

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

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

  for (int i = 0; i < n; i++)
  {
    char c;
    cin >> c;
    if(c=='Y'){
      cout << "Four" << endl;
      return 0;
    }
  }
  cout << "Three" << endl;
  
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>

using namespace std;

struct set{
	int many;
	int color;
};

int main()
{
	while (1){
		int n;
		cin >> n;
		if (!n){ break; }

		int white = 0;
		if (n >= 2){
			vector<set> stone;
			vector<set>::iterator p;

			int c1, c2;
			cin >> c1 >> c2;
			stone.push_back({ 2, c2 });

			for (int i = 1; i < n / 2; i++){
				int c1, c2;
				cin >> c1 >> c2;

				p = stone.end() - 1;
				if (c1 == c2){
					if (p->color == c2){
						p->many += 2;
					}
					else{
						stone.push_back({ 2, c2 });
					}
				}
				else{
					if (p->color == c2){
						p->many += 2;
					}
					else{
						p->color = p->color ? 0 : 1;
						p->many += 2;
						if (p != stone.begin()){
							(p - 1)->many += p->many;
							stone.erase(p);
						}
					}
				}
			}

			for (p = stone.begin(); p != stone.end(); p++){
				if (!p->color){
					white += p->many;
				}
			}
		}

		if (n % 2){
			int c;
			cin >> c;
			if (!c){ white++; }
		}

		cout << white << endl;
	}
	return 0;
}

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

int main()
{
	long H, N;

	cin >> H >> N;
	int HP = H;
	
	for (int a = 0; a < N; a++) {
		int A;
		cin >> A;
		HP -= A;
	}

	string result = "No";
	if (HP <= 0)result = "Yes";


	cout << result<<endl;
}



Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <cstdio>

using namespace std;

int main() {
    int C = 1;
    while(true) {
        int N;
        scanf("%d", &N);

        if(!N) break;

        vector<vector<int> > v(N, vector<int>(N, 0));

        int cnt = 1;
        for(int sum = 0; sum <= (N-1)*2; ++sum) {
            for(int y = 0; y <= min(sum, N-1); ++y) {
                int x = sum-y;
                if(0 <= x && x <= N-1) v[y][x] = cnt++;
            }
        }

        for(int sum = 0; sum <= (N-1)*2; ++sum) {
            if(sum & 1) continue;
            if(sum < N) {
                for(int y = max(0, sum-N); y <= min(sum, N-1)/2; ++y) {
                    int x = sum-y;
                    if(0 <= x && x <= N-1 && y < x) swap(v[y][x], v[x][y]);
                }
            }
            else {
                for(int x = N-1; x >= 0; --x) {
                    int y = sum-x;
                    if(0 <= y && y <= N-1 && x < y) swap(v[y][x], v[x][y]);
                }
            }
        }


        printf("Case %d:\n", C);
        for(int y = 0; y < N; ++y) {
            for(int x = 0; x < N; ++x) {
                printf("%3d", v[y][x]);
            }
            puts("");
        }
        ++C;
    }
    return 0;
}

Measured memory_bytes: 0
from sys import stdin
from collections import defaultdict
from heapq import heappush, heappop
import math

n = int(input())
g = defaultdict(list)

for i in range(n):
    l = list(map(int, stdin.readline().split()))
    s = l[0]
    k = l[1]
    t = l[2:]
    for j in range(0, 2*k, 2):
        g[s].append((t[j+1], t[j]))

d = [float('inf')] * 100
d[0] = 0
heap = [(d[0], 0)]

while heap:

    du, u = heappop(heap)
    for length, v in g[u]:

        if d[v] > du + length:
            d[v] = du + length
            heappush(heap, (d[v], v))

for i in range(n):
    print('{0} INF' if math.isinf(d[i]) else '{0} {1}'.format(i, d[i]))


Measured memory_bytes: 6568
#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 gcd(ll a,ll b){
  if(a<b) swap(a,b);
  if(b==0)return a;
  return gcd(b,a%b);
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  ll g = 1;
  ll l = 1;
  rep(i,N){
    ll x;cin >> x;
    g = gcd(l,x);
    l *= (x/g);
  }
  cout << l << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import deque
import sys
sys.setrecursionlimit(1<<30)
class Dinic:
    def __init__(self,N):
        self.N = N
        self.graph = [[] for _ in range(N)]
    
    def add_edge(self,v,w,cap):
        edge = [w,cap,None]
        edge[2] = rev_edge = [v,0,edge]
        self.graph[v].append(edge)
        self.graph[w].append(rev_edge)
    
    def bfs(self,s,t):
        self.level = [None]*self.N
        d = deque([s])
        self.level[s] = 0
        while d:
            v = d.popleft()
            nlevel = self.level[v]+1
            for w,cap,_ in self.graph[v]:
                if cap and self.level[w] is None:
                    self.level[w] = nlevel
                    d.append(w)
        return self.level[t] is not None
    
    def dfs(self,s,v,f):
        if v == s:
            return f
        for rev in self.it[v]:
            w,_,e = rev
            cap = e[1]
            if cap and self.level[w] is not None:
                if self.level[v] > self.level[w]:
                    d = self.dfs(s,w,min(f,cap))
                    if d:
                        e[1] -= d
                        rev[1] += d
                        return d
        return 0
    
    def max_flow(self,s,t):
        flow = 0
        INF = 10**9
        while self.bfs(s,t):
            *self.it, = map(iter,self.graph)
            f = INF
            while f:
                f = self.dfs(s,t,INF)
                flow += f
        return flow


N,M = map(int, input().split())
S = [list(input()) for i in range(N)]
dc = Dinic(N*M+2)

s =N*M
t = N*M+1
for i in range(N):
    for j in range(M):
        if (i + j) % 2 == 0:
            dc.add_edge(s,M*i+j,1)
        else:
            dc.add_edge(M*i+j,t,1)

for i in range(N):
    for j in range(M):
        if j+1 < M and S[i][j] == "." and S[i][j+1] == ".":
            u,v = M*i+j,M*i+j+1
            if (i+j) % 2 == 1:
                u,v = v,u
            dc.add_edge(u, v, 1)
        if i+1 < N and S[i][j] == "." and S[i + 1][j] == ".":
            u,v = M*i+j, M*(i+1)+j
            if (i+j) % 2 == 1:
                u,v = v,u
            dc.add_edge(u, v, 1)

print(dc.max_flow(s, t))
for u in range(N*M+2):
    for v, cap, _ in dc.graph[u]:
        ui, uj = divmod(u, M)
        vi, vj = divmod(v, M)
        if (ui+uj) % 2 == 0 and cap == 0 and u != s and u != t and v != s and v!= t:
            if ui+1 == vi:
                S[ui][uj] = "v"
                S[vi][vj] = "^"
            elif ui == vi+1:
                S[ui][uj] = "^"
                S[vi][vj] = "v"
            elif uj+1 == vj:
                S[ui][uj] = ">"
                S[vi][vj] = "<"
            elif uj == vj+1:
                S[ui][uj] = "<"
                S[vi][vj] = ">"

for res in S:
    print("".join(res))

Measured memory_bytes: 86260
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include <sstream>
#include<map>
#include<cmath>
#include<queue>
#include <functional>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define PI 3.141592


using namespace std;

int main() {
	string N = "";
	cin >> N;

	map<string, int> tmp =
	{
		{"SUN", 7},
		{"MON", 6},
		{"TUE", 5},
		{"WED", 4},
		{"THU", 3},
		{"FRI", 2},
		{"SAT", 1},
	};
	cout << tmp[N] << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;
#include <cstdio>
#include <tuple>
#include <string>
#include <vector> 
#include <set>
#include <string.h>
#include <map>
#include <cmath>
#include <deque>
using ll = long long;
using Graph = vector<vector<int>>;
#include <queue>
#include <stack>

int main(){
    
    map<string,int> m_map;
    int n = 0;
    cin >> n;
    int max =0;
    for(int i=0;i < n;i++){
        string str;
        cin >> str;
        if(m_map.find(str) != m_map.end()) m_map[str]++;
        else m_map[str] = 0;
        if(max < m_map[str]) max = m_map[str];
    
    }

    for(auto itr = m_map.begin(); itr != m_map.end(); ++itr){
        if(itr->second == max) cout << itr->first << endl;
           
    }

    return 0;
}

Measured memory_bytes: 25216
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,s=1000,t;
    cin>>x;
    if(x==s ||x==2*s || x==3*s ||x==4*s ||x==5*s||x==6*s||x==7*s||x==8*s||x==9*s ||x==10*s)
    {
        cout<<"0"<<endl;
    }
    else
    {
        if(x<s)
        {
            t=s-x;
            cout<<t<<endl;
        }
        else if(x<2*s)
        {
            t=2*s-x;
            cout<<t<<endl;
        }
        else if(x<3*s)
        {
            t=3*s-x;
            cout<<t<<endl;
        }
        else if(x<4*s)
        {
            t=4*s-x;
            cout<<t<<endl;
        }
        else if(x<5*s)
        {
            t=5*s-x;
            cout<<t<<endl;
        }
        else if(x<6*s)
        {
            t=6*s-x;
            cout<<t<<endl;
        }
        else if(x<7*s)
        {
            t=7*s-x;
            cout<<t<<endl;
        }
        else if(x<8*s)
        {
            t=8*s-x;
            cout<<t<<endl;
        }
        else if(x<9*s)
        {
            t=9*s-x;
            cout<<t<<endl;
        }
        else if(x<10*s)
        {
            t=10*s-x;
            cout<<t<<endl;
        }
    }
    return 0;
}

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

int main(){
	string s;
  	cin >> s;
  	int zero=0,ichi=0;
  	for(auto c:s){
    	if(c=='0')zero++;
    	else ++ichi;
    }
	cout << min(zero,ichi)*2<<endl;




}

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

int main(){
	int A,B,C,X;
	cin>>A>>B>>C>>X;
	
	int ans=0;
	for(int i=0;i<=A;i++){
		for(int j=0;j<=B;j++){
			if((X-500*i-100*j)%50==0&&(X-500*i-100*j)/50<=C&&(X-500*i-100*j)>=0){
				//cout<<i<<' '<<j<<endl;
				ans++;
			}
		}
	}
	
	cout<<ans<<endl;
	return 0;
	
}

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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000

#ifdef LOCAL
  #define eprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define eprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

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

  int x = 0;
  int mx = x;
  REP(i, n) {
    if(s[i] == 'I') {
      x++;
    }
    else {
      x--;
    }
    mx = max(mx, x);
  }
  cout << mx << endl;

  return 0;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);

/* -----  2019/07/27  Problem: ABC 135 C / Link: http://abc135.contest.atcoder.jp/tasks/abc135_c  ----- */


// ?
// わからん…

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

	LL N; cin >> N;
	VL a(N + 1);
	FOR(i, 0, N + 1) {
		cin >> a[i];
	}
	VL b(N);
	FOR(i, 0, N) {
		cin >> b[i];
	}

	LL ans = 0;
	FOR(i, 0, N) {
		LL mae = min(a[i], b[i]);
		a[i] -= mae;
		b[i] -= mae;
		LL tugi = min(a[i + 1], b[i]);
		a[i + 1] -= tugi;
		b[i] -= tugi;
		ans += tugi + mae;
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;
import java.util.Arrays;
public class Main
{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt(); int x = a;
		int b = scan.nextInt(); int y = b;
		long lcm = (long)a*b;
		for(int i =0; i<1000000; i++){
		    if(a ==0 || b==0){
		        break;
		    }
		    else{
		        if(a<b){
		            int g = a;
		            a = b%a;
		            b = g;
		        }
		        else{
		            int g = b;
		            b = a%b;
		            a =g;
		        }
		    }
		}
		int gcd = Math.max(a, b);
		lcm = lcm/gcd;
		System.out.println(lcm);
	}
}


Measured memory_bytes: 35828
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

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

const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

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;
}

template<class TYPE>
struct edge{
    TYPE to,cost; 
    edge(TYPE t,TYPE c){
        to = t;
        cost = c;
    }
};

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    int c = 0;
    ll sum = 0;
    for(int i = 0; i < N; i++){
        int b;
        cin >> b;
        if(b < 0) c++;
        a[i] = max(b,-b);
        sum += max(b,-b);
    }
    if(c % 2 == 0) cout << sum << endl;  
    else{
        sort(a.begin(),a.end());
        cout << sum - 2*a[0] << endl;
    }
    return 0;
}


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

int main()
{
    string s;
    cin>>s;
    int n=s.size();
    int dame=0;
    if(s[0]!='A'){
        dame++;
    }
    if(isupper(s[1])){
        dame++;
    }
    if(isupper(s[n-1])){
        dame++;
    }
    int ccount=0;
    int kcount=0;
    for(int i=2;i<n-1;i++){
        if(s[i]=='C'){
            ccount++;
        }
        if(islower(s[i])){
            kcount++;
        }
    }
    if(ccount!=1){
        dame++;
    }
    if(kcount!=n-4){
        dame++;
    }

    if(dame==0){
        cout<<"AC"<<endl;
    }
    else{
        cout<<"WA"<<endl;
    }


}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main() {

    int n;
    cin >> n;

    vector<int> v(n + 1);
    vector<bool> doneDown(n + 1, false);
    v[0] = -1;

    for(int i = 1; i <= n; ++i) {
        cin >> v[i];
    }

    for(int i = 1; i < n; ++i) {

        if(v[i] - v[i + 1] > 1) {

            cout << "No" << endl;
            return 0;
        }
        else if(v[i] - v[i + 1] == 1) {

            v[i]--;
            doneDown[i] = true;
            int j = i;
            while(j > 0 && v[j - 1] - v[j] == 1) {
                j--;
                if(doneDown[j]) {
                    cout << "No" << endl;
                    return 0;
                }

                v[j]--;
                doneDown[j] = true;

            }

        }

    }

    cout << "Yes" << endl;

    return 0;

}

Measured memory_bytes: 640
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n + 1];
		int k = sc.nextInt();
		for(int i = 0; i < n; i++) {
			int tmp = sc.nextInt();
			a[tmp]++;
		}
		int cnt = 0;
		List<Integer> list = new ArrayList<>();
		for(int i = 1; i < n + 1; i++) {
			if(a[i] > 0)
				list.add(a[i]);
		}
		int ans = 0;
		Collections.sort(list);
		for(int i = 0; i < list.size() - k; i++) {
			ans += list.get(i);
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 79064