akhauriyash/Code-Regression huggingface dataset:
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
* * WRITER:kakitamasziru/OxOmisosiru * *
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 1001001001001001;
const long long MOD = 1000000007;
typedef pair<long long,long long> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}
long long nCr(long long n, long long r) {
    long long A = 1, B = 1;
    //Aが分子Bが1/r!
    for (long long i = n - r + 1; i <= n; i++) {
        A = A * i % MOD;
    }
    for (long long i = 1; i <= r; i++) {
        B = B * i % MOD;
    }
    B = mod_pow(B, MOD - 2);
    B %= MOD;
    //Bは割るのではなく掛ける
    return (A * B) % MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
 
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

long long A,B;
bool ok(long long key,long long index){
    string S = to_string(index);
    long long nagasa = S.size();
    if(index*A+nagasa*B > key) return true;
    else if(index*A+nagasa*B <= key) return false;
}
long long binary_search(long long key,long long size){
    //left,right,midはいずれもindex
    long long left = -1,right = size;
    while(right - left > 1){
        long long mid = left + (right-left)/2;
        long long hantei = ok(key,mid);
        if(hantei) right = mid;
        else left = mid;
    }
    if(left == -1)return 0;
    return left;
}

int main() {
    string S;cin >> S;
    int N = S.size();
    stack<char> C;
    for(int i = 0;i<N;i++){
        C.push(S.at(i));
        while(true){
            if(C.size() < 2) break;
            char a = C.top();
            C.pop();
            char b = C.top();
            C.pop();
            if(a == 'T' && b == 'S'){
            }
            else {
                C.push(b);
                C.push(a);
                break;
            }
        }
    }

    cout << C.size() << endl;

    // PLEASE GIVE ME THE "ACCEPTED" !
}


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

struct D {
    int t, s ,d;
    bool operator <(const D& rhs) {
        return t < rhs.t;
    }
};

int main(void){
    int n, m;
    int _t, _s, _d;
    vector<D> data;
    D _data;
    bool f[20202];
    
    while (1) {
        cin >> n >> m;
        if (!n && !m) break;
        data.clear();
        for (int i = 0; i < n; i++) f[i] = false;
        f[0] = true;
        
        for (int i = 0; i < m; i++) {
            cin >> _t >> _s >> _d;
            _s--; _d--;
            _data.t = _t;
            _data.s = _s;
            _data.d = _d;
            data.push_back(_data);
        }
        sort(data.begin(), data.end());
        
        for (int i = 0; i < m; i++) {
            if (f[data[i].s] == true) f[data[i].d] = true;
            //printf("data[i].s=%d data[i].d=%d i=%d\n",data[i].s,data[i].d,i);
        }
        int ans = 0;
        for (int i = 0; i < n; i++) if (f[i] == true) ans++;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3380
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
        long long int n,x;
        cin>>n;
        long long int a[n+1]={0};
        for(int i=1;i<=100;i++)
        {
            for(int j=1;j<=100;j++)
            {
                for(int k=1;k<=100;k++)
                {
                    x=i*i+j*j+k*k+i*j+k*j+i*k;
                    if(x<=n)
                    a[x]++;
                }
            }
        }
        for(int i=1;i<=n;i++)
            cout<<a[i]<<"\n";

        
        
    }
    
    


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
// ----------------------R00TDADA------------------------------
#define rep(i, a, b) for (__typeof((b)) i = (a); i < (b); i++)
#define nrep(i, a, b) for (__typeof((b)) i = (a); i > (b); i--)
#define all(a) (a).begin(), (a).end()
#define ff first
#define ss second
#define ppi pair<int, int>
#define pppi pair<ppi, int>
#define vi vector<int>
#define vii vector<ppi>
#define viii vector<pppi>
#define vs vector<string>
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define M_PI 3.14159265358979323846
#define rootdada ios_base::sync_with_stdio(false)
#define int long long
#define M 1000000007
#define MAX 100005
int A[MAX], tree[4 * MAX];
int power(int x, int p)
{
    if (p == 0)
        return 1;
    int y = power(x, p / 2);
    y *= y;
    y %= M;
    if (p % 2 == 0)
        return y;
    y *= x;
    y %= M;
    return y;
}
void build(int node, int start, int end)
{
    if (start == end)
        //Leaf node will have a single element
        tree[node] = start;
    else
    {
        int mid = (start + end) / 2;
        //Recurse on the left child
        build(2 * node, start, mid);
        //Recurse on the right child
        build(2 * node + 1, mid + 1, end);
        // Internal node will have the sum of both of its children
        tree[node] = tree[2 * node] + tree[2 * node + 1];
    }
}
void update(int node, int start, int end, int idx, int val)
{
    if (start == end)
    {
        //Leaf Node
        A[idx] = val;
        tree[node] += val;
    }
    else
    {
        int mid = (start - end) / 2 + end;
        if (start <= idx && idx <= mid)
        {
            // If idx is in the left child, recurse on the left child
            update(2 * node, start, mid, idx, val);
        }
        else
        {
            // if idx is in the right child, recurse on the right child
            update(2 * node + 1, mid + 1, end, idx, val);
        }
        // Internal node will have the sum of both of its children
        tree[node] = tree[2 * node] + tree[2 * node + 1];
    }
}
int query(int node, int start, int end, int l, int r)
{
    if (r < start || l > end)
    {
        // range represented by a node is completely outside the given range
        return 0;
    }
    if (l <= start && end <= r)
    {
        // range represented by a node is completely inside the given range
        return tree[node];
    }
    // range represented by a node is partially inside and partially outside the given range
    int mid = (start + end) / 2;
    int p1 = query(2 * node, start, mid, l, r);
    int p2 = query(2 * node + 1, mid + 1, end, l, r);
    return p1 + p2;
}

signed main()
{

    rootdada;
    long double a, b, x;
    cin >> a >> b >> x;
    long double ans;
    if (a * a * b / 2.0 <= x)
    {
        ans = atan(2 * (a * a * b - x) / (a * a * a));
    }
    else
    {
        ans = acos(-1) / 2 - atan(2 * x / (a * b * b));
    }
    cout << fixed << setprecision(10) << (ans * 180) / acos(-1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<string, int> p;
bool compare_by_b(pair<string, int> a, pair<string, int> b) {
    if(a.first == b.first){
        return a.second > b.second;
    }else{
        return a.first < b.first;
    }
}

int main() {
    int n;cin >> n;
    vector<p> sp(n);
    vector<p> index(n);
    for(int i = 0; i < n; i ++) {
        string s; int p; cin >> s >> p;
        sp[i] = make_pair(s,p);
        index[i] = make_pair(s,p);
    }
    sort(sp.begin(), sp.end());
    sort(sp.begin(), sp.end(), compare_by_b);
    for(int i = 0; i < n; i ++) {
        for(int j = 0; j < n; j ++) {
            if(sp[i].first == index[j].first && sp[i].second == index[j].second) cout << j+1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;

typedef pair<ll,int> P;

int main(void){
  
  int n,i;
  ll x,l,left[100005];
  vector<P> right;
  
  cin >> n;
  for (i=0;i<n;i++){
    cin >> x >> l;
    left[i]=x-l;
    right.push_back(P(x+l,i));
  }
  
  sort(right.begin(),right.end());
  
  int p,ans=1;
  i=0;
  p=right[0].first;
  
  while (1){
    while (i<n && left[right[i].second] < p) i++;
    if (i==n) break;
    p=right[i].first;
    ans++;
    i++;
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 2932
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    int k;
    int a,b;
    cin>>k>>a>>b;
    int i;
    for(i=a;i<=b;++i)
      {
          if(i%k==0)
              break;
              
      }
      
      if(i==b+1)
        cout<<"NG";
        
      else
        cout<<"OK";
    
     return 0;   
    
}

Measured memory_bytes: 3624
X, N = [int(x) for x in input().strip().split()]
p = set([int(x) for x in input().strip().split()])
ans = 0
diff = X
for i in range(102):
  if i in p:
    continue
  if abs(X - i) < diff:
    ans = i
    diff = abs(X - i)
print(ans)

Measured memory_bytes: 9064
#include <cstdio>
#include <cctype>
#include <set>
#include <iostream>
#include <string>
#include <algorithm>
#define MAXIOLG 25
#define FILENAME(x) \
freopen(x".in","r",stdin); \
freopen(x".out","w",stdout);
#define MAXN 200005
#define MAXL 1000005
#define BASE 29
#define P1 1000000097
#define P2 1000000021

#define MD(x,pp) (((x)>=(pp))?((x)-=(pp)):(0))
using namespace std;

typedef long long ll;
typedef long double ld;
typedef ll io_t;
io_t shin[MAXIOLG];
io_t seto(void);
void ayano(io_t x,char spliter='\n');

typedef pair<int,int> pii;

set<pii> st;
string strs[MAXN];
pii hana[MAXL];
int char_cnt[MAXN];

void get_hana(const string& str);
bool cmp(const string& lhs,const string& rhs);

int main(void){
    int n=seto();
    for (int i=1;i<=n;i++)
        cin >> strs[i],
        reverse(strs[i].begin(),strs[i].end());
    sort(strs+1,strs+n+1,cmp);
    ll ans=0;
    for (int i=1;i<=n;i++){
        get_hana(strs[i]);
        for (int k=1;k<=26;k++)
            char_cnt[k]=0;
        for (auto ch:strs[i])
            char_cnt[ch-'a'+1]++;
        for (int k=1;k<=26;k++)
            if (char_cnt[k])
                ans+=st.count(make_pair(k,k));
        for (int j=1,tren=strs[i].size();j<tren;j++){
            if (j>1)
                ans+=st.count(hana[j]);
            char_cnt[strs[i][j-1]-'a'+1]--;
            for (int k=1;k<=26;k++){
                if (('a'+k-1)==strs[i][j] || (!char_cnt[k]))
                    continue;
                int x1=1ll*hana[j].first*BASE%P1+k;
                MD(x1,P1);
                int x2=1ll*hana[j].second*BASE%P2+k;
                MD(x2,P2);
                ans+=st.count(make_pair(x1,x2));
            }
        }
        st.insert(hana[strs[i].size()]);
    }
    ayano(ans);
    return 0;
}

void get_hana(const string& str){
    hana[0]=make_pair(0,0);
    for (int i=0,j=1,tren=str.size();i<tren;i++,j++){
        int x1=1ll*hana[j-1].first*BASE%P1+(str[i]-'a'+1);
        MD(x1,P1);
        int x2=1ll*hana[j-1].second*BASE%P2+(str[i]-'a'+1);
        MD(x2,P2);
        hana[j]=make_pair(x1,x2);
    }
}
bool cmp(const string& lhs,const string& rhs){
    return lhs.size()<rhs.size();
}

io_t seto(void){
    io_t x=0;
    int symbol=0;
    char ch=getchar();
    while (!isdigit(ch))
        (ch=='-')?(symbol=1):(0),
        ch=getchar();
    while (isdigit(ch))
        x=(x*10)+(ch-'0'),
        ch=getchar();
    return (symbol)?(-x):(x);
}
void ayano(io_t x,char spliter){
    if (!x){
        putchar('0'),putchar(spliter);
        return;
    }
    if (x<0)
        putchar('-'),x=-x;
    int len=0;
    while (x){
        io_t d=x/10;
        shin[len++]=x-(d*10);
        x=d;
    }
    while (len--)
        putchar(shin[len]+'0');
    putchar(spliter);
}

Measured memory_bytes: 17052
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
    int N, K, x[100001];
    cin >> N >> K;
    for (int i = 1; i <= N; ++i) {
        cin >> x[i];
    }
    long long res = 1 << 30;
    for (int l = 1; l <= N - K + 1; ++l) {
        int r = l + K - 1;
        if (abs(x[l]) > abs(x[r])) {
            res = min(res, (long long)(abs(x[r]) + x[r] - x[l]));
        } else {
            res = min(res, (long long)(abs(x[l]) + x[r] - x[l]));
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 640
#include<cstdio>

int n;
long long res = 1;

int main() {
  scanf("%d", &n);
  bool flag = false;
  for (int i = 0; i < n; i++) {
    long long tmp;
    scanf("%lld", &tmp);
    if (tmp == 0) {
      res = 0;
      continue;
    }
    if (res <= (1000000000000000000ll - 1000000000000000000ll % tmp)/tmp) {
      res *= tmp;
    } else {
      flag = true;
    }
  }
  if (flag && res != 0) {
    printf("-1\n");
  } else {
    printf("%lld\n", res);
  }
}


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

using namespace std;


int main() {

  int n,m;
  int k;

  vector<int> card;
  
  vector<int> temp1,temp2;


  cin >> n;

  card.clear();

  for(int i=0;i<2*n;i++) card.push_back(i+1);

  cin >> m;

  for(int i=0;i<m;i++) {

    temp1.clear();

    temp2.clear();

    cin >> k;

    if(k==0) {

      for(int j=0;j<n;j++) {

	temp1.push_back(card[j]);

	temp2.push_back(card[n+j]);

      }

      for(int j=0;j<n;j++) {

	card[2*j]=temp1[j];

	card[2*j+1]=temp2[j];

      }

    }

    else {

      for(int j=0;j<2*n;j++) {

	if(j<k) temp1.push_back(card[j]);

	else temp2.push_back(card[j]);

      }

      for(int j=0;j<2*n;j++) {

	if(j<2*n-k) card[j]=temp2[j];

	else card[j]=temp1[j-2*n+k];

      }

    }

  }

  for(int i=0;i<2*n;i++) cout << card[i] << endl;

  return 0;

}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    int n,m;
    cin >> n >> m;
    vvi v(m);
    rep(i,n){
        int a,b;
        cin >> a >> b;
        if(m-a >= 0 && m-a < m)v[m-a].push_back(b);
    }
    int ans = 0;
    priority_queue<int> q;
    rep(i,m){
        int now = m-i-1;
        rep(j,v[now].size()){
            //cout << "!" << v[now][j] << endl;
            q.push(v[now][j]);
        }
        if(q.size()){
            ans += q.top();
            q.pop();
        }
    }
    cout << ans << endl;
}


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

int main()
{
    int a,b;
    string c;

    cin>>a>>b>>c;

    if(c[a]!='-'){cout<<"No"<<endl; return 0;}

    for(int i=0;i<a;i++)
        if(c[i]<'0' || c[i]>'9')
    {
        cout<<"No"<<endl;   return 0;
    }

    for(int i=a+1;i<c.length();i++)
        if(c[i]<'0' || c[i]>'9')
    {
        cout<<"No"<<endl;   return 0;
    }


    cout<<"Yes"<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#define repp(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define repm(i,a,b) for(int i=(int)a;i>(int)b;--i)
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int>p(n);
	int ans = 0;
	repp(i, 0, n)cin >> p[i];
	repp(i, 1, n - 1) {
		int sum = p[i - 1] + p[i] + p[i + 1];
		int maxv = max({ p[i - 1] , p[i] , p[i + 1] });
		int minv= min({ p[i - 1] , p[i] , p[i + 1] });
		sum -= maxv + minv;
		if (sum == p[i])++ans;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.* ; 
import java.math.*;
class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner (System.in);
	int n =scan.nextInt();
    long  x = 1L ;
    int mod = (int)(1e9 + 7) ;
    for(int i = 2 ; i<=n ; i++){
		x = (x*i) %  mod ;
    }
    System.out.println(x);
  }
}

Measured memory_bytes: 21076
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#define INF 1.0e9
using namespace std;
typedef long long ll;

string S;

int main() {
    cin >> S;
    int size = S.length();
    int ans = INF;
    for (int i = 0; i < size - 2; i++){
        string cur = "";
        cur.push_back(S[i]);
        cur.push_back(S[i+1]);
        cur.push_back(S[i+2]);
        if (ans > abs(753 - stoi(cur))) ans = abs(753 - stoi(cur));
    }
    cout << ans << endl;
    return 0;
}

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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;

// container util
// -----------------------------------------------------------------------------
#define ALL(c)  (c).begin(),(c).end()
#define SZ(c) ((ll)(c).size())
#define MAX(c) *max_element(ALL(c))
#define MIN(c) *min_element(ALL(c))
#define SORT(c) sort((c).begin(),(c).end())

// repetition
// -----------------------------------------------------------------------------
#define FOR(i, a, b) for(ll i= (a); i < (ll)(b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
// -----------------------------------------------------------------------------
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    float N; cin >> N;
    int ans = ceilf(N / 2);
    cout << ans << "\n";
}

Measured memory_bytes: 3732
#include <iostream>
#include <algorithm>
using namespace std;
struct Card {char suit, value;};
void print(int N, Card* arr) {
    for(int i = 0; i < N-1; i++) cout << arr[i].suit << arr[i].value << " ";
    cout << arr[N-1].suit << arr[N-1].value << endl;
}
void bubbleSort(int N, Card* arr) {
    for(int i = 0; i < N; i++) {
        for(int j = N-1; j > 0; j--) {
            if(arr[j-1].value > arr[j].value) swap(arr[j-1], arr[j]);
        }
    }
}
void selectionSort(int N, Card* arr) {
    for(int i = 0; i < N; i++) {
        int p = N-1;
        for(int j = p-1; j >= i; j--) {
            if(arr[j].value <= arr[p].value) p = j;
        }
        swap(arr[i], arr[p]);
    }
}
bool isStable(int N, Card* arr1, Card* arr2) {
    for(int i = 0; i < N; i++) if(arr1[i].suit != arr2[i].suit) return false;
    return true;
}
int main(){
    int N; cin >> N;
    Card org[N], arrB[N], arrS[N];
    for(int i = 0; i < N; i++) cin >> org[i].suit >> org[i].value;
    for(int i = 0; i < N; i++) arrB[i] = org[i];
    bubbleSort(N, arrB);
    print(N, arrB);
    cout << "Stable" << endl;
    for(int i = 0; i < N; i++) arrS[i] = org[i];
    selectionSort(N, arrS);
    print(N, arrS);
    if(isStable(N, arrB, arrS)) {
        cout << "Stable" << endl;
    } else {
        cout << "Not stable" << endl;
    }
    return 0;
}


Measured memory_bytes: 3100
n, x = input().strip().split()
n = int(n)
x = int(x)
l = input().strip().split()
l = list(map(int, l))
now = 0
for i in range(n):
  now += l[i]
  if now > x:
    print(i+1)
    exit()
print(n+1)

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

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

using ll = long long int;
using P = pair<int,int>;

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

const ll INF=(ll)1e19;
//const int INF=(1<<30);

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

  VI h(n);
  REP(i,n)cin >> h[i];
  sort(ALL(h));

  int ans=(1<<30);
  REP(i,n-k+1){
    chmin(ans, h[i+k-1]-h[i]);
  }
  cout << ans << endl;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define dmp(x) cerr<<#x<<":"<<x<<endl
#define FOR(i,a,b) for(int i=(int)a,c=(int)b;i<c;++i)
#define rep(i,b) FOR(i,0,b)
#define ROF(i,a,b) for(int i=b-1,c=(int)a;i>=c;--i)
#define per(i,b) ROF(i,0,b)
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;}
typedef pair<int,int> P;
typedef pair<string,P> PP;

signed main(){
  int n;
  cin>>n;
  vector<PP> p(n);
  rep(i,n){
    string s;
    int a;
    cin>>s>>a;
    p[i]=PP(s,P(-a,i+1));
  }
  sort(all(p));
  rep(i,n)cout<<p[i].se.se<<endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
S = [None] * N
for i in range(N):
    S[i] = input()

C = []
for s in S:
    T = tuple(sorted(s))
    C.append(T)

dic = {}
for i in range(N):
    if C[i] in dic:
        dic[C[i]] += 1
    else:
        dic[C[i]] = 1

ans = 0
for x in dic.values():
    ans += x * (x - 1) // 2
print(ans)

Measured memory_bytes: 33164
#include<bits/stdc++.h>
using namespace std;
#define REP(i,b,n) for(int i=b;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define all(obj) (obj).begin(),(obj).end()
typedef long long ll;
ll mod=ll(1e9)+7;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,m;
  cin>>n>>m;
  rep(i,m){
    int t;cin>>t;
    n-=t;
  }
  if(n<0)cout<<-1<<endl;
  else cout<<n<<endl;
  return 0;
}


Measured memory_bytes: 3656
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.regex.Pattern;

public class Main {

  public static void main(String[] args) {
  
    new Main().run();
  }

  public void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      final Pattern delim = Pattern.compile(" ");
      int[] seq = delim.splitAsStream(br.readLine())
        .mapToInt(Integer::parseInt)
        .toArray();

      int q = partition(seq, 0, n-1);
      dispIntArrayPartition(seq, q);
    }
    catch(IOException e) {
      System.out.println("IOException!");
    }
  }

  public int partition(int[] seq, int p, int r) {

    int x = seq[r];
    int i = p-1;
    int t;

    for(int j=p; j<r; j++) {
      if(seq[j] <= x) {
        t = seq[++i]; seq[i] = seq[j]; seq[j] = t;
      }
    }
    t = seq[i+1]; seq[i+1] = seq[r]; seq[r] = t;

    return i+1;
  }

public void dispIntArrayPartition(int[] target, int q) {
  StringBuilder s = new StringBuilder();
  int l=target.length-1;

  for (int i=0; i<q; i++) { s.append(target[i]).append(" "); }
  s.append("[").append(target[q]).append("] ");
  for (int i=q+1; i<l; i++) { s.append(target[i]).append(" "); }
  s.append(target[l]);

  System.out.println(s);
  }
}


Measured memory_bytes: 45076
#include<cstdio>  
#include<iostream>  
#include<algorithm>  
#include<cstdlib>  
#include<cstring>
#include<string>
#include<climits>
#include<vector>
#include<cmath>
#include<map>
#define LL long long
#define pii pair<int,int>
#define mp make_pair
 
using namespace std;
 
inline char nc(){
  static char buf[100000],*p1=buf,*p2=buf;
  if (p1==p2) { p2=(p1=buf)+fread(buf,1,100000,stdin); if (p1==p2) return EOF; }
  return *p1++;
}
 
inline void read(int &x){
  char c=nc();int b=1;
  for (;!(c>='0' && c<='9');c=nc()) if (c=='-') b=-1;
  for (x=0;c>='0' && c<='9';x=x*10+c-'0',c=nc()); x*=b;
}
 
inline void read(LL &x){
  char c=nc();LL b=1;
  for (;!(c>='0' && c<='9');c=nc()) if (c=='-') b=-1;
  for (x=0;c>='0' && c<='9';x=x*10+c-'0',c=nc()); x*=b;
}

inline int read(char *s)
{
	char c=nc();int len=1;
	for(;!(c>='a' && c<='z');c=nc()) if (c==EOF) return 0;
	for(;(c>='a' && c<='z');s[len++]=c,c=nc());
	s[len++]='\0';
	return len;
}

inline void read(char &x){
  for (x=nc();!(x>='A' && x<='Z');x=nc());
}

int wt,ss[19];
inline void print(int x){
	if (x<0) x=-x,putchar('-'); 
	if (!x) putchar(48); else {
	for (wt=0;x;ss[++wt]=x%10,x/=10);
	for (;wt;putchar(ss[wt]+48),wt--);}
}
inline void print(LL x){
	if (x<0) x=-x,putchar('-');
	if (!x) putchar(48); else {for (wt=0;x;ss[++wt]=x%10,x/=10);for (;wt;putchar(ss[wt]+48),wt--);}
}

int n,m,a[100010],b[100010],ans[100010],c[100010];
LL K;
double x[100010],z[100010];

void Work(LL x)
{
	for (;x;x>>=1)
	{
		if (x&1)
		{
			for (int i=1;i<n;i++)
				c[i]=ans[b[i]];
			for (int i=1;i<n;i++)
				ans[i]=c[i];
		}
		for (int i=1;i<n;i++)
			c[i]=b[b[i]];
		for (int i=1;i<n;i++)
			b[i]=c[i];
	}
}

int main()
{
	//freopen("1.in","r",stdin);
	//freopen("1.out","w",stdout);
	read(n);
	int y;
	for (int i=1;i<=n;i++)
		read(y),x[i]=(double)y;
	read(m),read(K);
	for (int i=1;i<=m;i++)
		read(a[i]);
	for (int i=1;i<n;i++)
		b[i]=i,ans[i]=i;
	for (int i=1;i<=m;i++)
		swap(b[a[i]],b[a[i]-1]);
	Work(K);
	/*for (int i=1;i<n;i++)
		print(ans[i]),putchar(' ');*/
	z[1]=x[1];
	for (int i=1;i<n;i++)
		z[i+1]=z[i]+(x[ans[i]+1]-x[ans[i]]);
	for (int i=1;i<=n;i++)
		printf("%0.10lf\n",z[i]);
	return 0;
}

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

#define FOR0(i,n) for (int i = 0; i < n; i++)
#define FOR(i,j, n) for (int i = j; i < n; i++)
// bool isEven(ll n) {return (n%2!=0)?false:true;};
#define INF 1000000000 // 1 billion, safer than 2B for Floyd Warshall’s

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
// #define int ll

using namespace std;

//atcoder
//abc167

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

    if(a>=k)
        cout<<k<<endl;
    else if(k>a&&k<=a+b)
        cout<<a<<endl;
    else
        cout<<a-(k-(a+b))<<endl;
}

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

using namespace std;


typedef long long int llint;


/******************************************************************************
	Main
******************************************************************************/
int main()
{
	llint a, b, k;
	cin >> a >> b >> k;
	llint max_k = pow(10, 12);
	assert(a >= 0 && a <= max_k);
	assert(b >= 0 && b <= max_k);
	assert(k >= 0 && k <= max_k);
	
	llint tak = ((a-k)>0)?a-k:0; // a-k == 0 => tak == 0
	llint aok = ((a-k)<0)?((b+a-k)<0?0:b+a-k):b; // a-k == 0 => aok == b // 可読性最低
	cout << tak << " " << aok << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <iomanip>
int main()
{
    int a, b;
    char op;
    while (true)
    {
        std::cin >> a;
        std::cin >> op;
        std::cin >> b;
        if (op == '?')
        {
            break;
        }
        else if (op == '+')
        {
            std::cout << a + b << "\n";
        }
        else if (op == '-')
        {
            std::cout << a - b << "\n";
        }
        else if (op == '*')
        {
            std::cout << a * b << "\n";
        }
        else if (op == '/')
        {
            std::cout << a / b << "\n";
        }
    }

    return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
const int mod = 998244353;

const int N = 6001;
int d[N][N], bin[N][N];

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  int n, x;
  cin >> n >> x;
  for (int n = 0; n < N; ++n) {
    bin[n][0] = 1;
    for (int i = 1; i <= n; ++i) {
      bin[n][i] = (bin[n - 1][i] + bin[n - 1][i - 1]) % mod;
    }
  }
  d[0][0] = d[1][0] = d[2][1] = 1;
  for (int l = 3; l < N; ++l) {
    for (int i = 1; i < l; ++i) {
      d[l][i] = (d[l - 1][i - 1] + d[l - 2][i - 1]) % mod;
    }
  }
  ll res = 0;
  for (int S = 0; S <= 2 * n; ++S) {
    vi bad(S + 1);
    for (int i = x; i <= S; ++i) {
      if (i % 2 == x % 2) {
        bad[i] = 1;
      } else {
        bad[i - x] = 1;
      }
    }
    if (bad.back()) continue;
//    cerr << "x: " << x << " S: " << S << endl;
//    for (int i = 0; i <= S; ++i) cerr << bad[i]; cerr << endl;
    bool fail = 0;
    int steps = n;
    for (int i = 0; i + 1 <= S; ++i) {
      if (bad[i] && bad[i + 1]) {
        fail = 1;
      }
      if (bad[i] && i > 0 && !bad[i-1] && i + 1 <= S && !bad[i+1]) --steps;
    }
    if (fail) break;
    int L = 0;
    for (int i = 0; i <= S; ++i) if (!bad[i]) {
      int l = 1;
      for (int j = i + 1; j <= S; ++j) {
        if (bad[j]) break;
        ++l;
      }
      if (l != 1) {
        assert(L == 0);
        L = l;
        i += l - 1;
      }
    }
    for (int i = 0; i <= steps; ++i) {
      res = (res + d[L][i] * (ll)bin[n][steps - i]) % mod;
    }
//    cerr << n << ' ' << steps << ' ' << res << endl;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 279936
#include <iostream>
#include <vector>
#include <utility>

using namespace std;

typedef pair<int, int> P_ii;
typedef pair<string, int> P_si;

int main() {
    int A, B;
    cin >> A >> B;

    cout << max(A + B, max(A - B, A * B)) << endl;
    return 0;
}


Measured memory_bytes: 256
def main():
    input = sys.stdin.readline
    try:
        N = int(input())
        A1 = list(map(int, input().split()))
        A2 = list(map(int, input().split()))
        
        if N == 1:
            print(A1[0] + A2[0])
            return
        dp = [[0]*2 for _ in range(N-1)]
        dp[0][0] = A1[0] + A1[1]
        dp[0][1] = A1[0] + A2[0]

        for i in range(1, N - 1):
            dp[i][0] = dp[i-1][0] + A1[i+1]
            dp[i][1] = max(dp[i-1][0], dp[i-1][1]) + A2[i]
        
        ans = max(dp[N-2][0], dp[N-2][1]) + A2[N-1]
        print(ans)
        
    finally:
        input = None

import sys; sys.setrecursionlimit(50000)
if __name__ == "__main__":
    main()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
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 T intceil(T a, T b) { return (a + (b - 1)) / b; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;
#define precout(val) cout << std::fixed << std::setprecision(20) << val;
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const int dy[4] = { 0, 1, 0, -1 };
const int dx[4] = { 1, 0, -1, 0 };
static const double pi = 3.141592653589793;

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

  string s; cin >> s;
  int n = s.size();
  int ans = 0;

  int lo = 0, hi = n - 1;
  while(lo < hi) {
    char loc = s[lo], hic = s[hi];
    if(loc == hic) {
      ++lo, --hi;
      continue;
    }

    if(loc == 'x') {
      ++ans, ++lo;
      continue;
    }

    if(hic == 'x') {
      ++ans, --hi;
      continue;
    }

    cout << -1 << endl;
    return 0;
  }

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


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  int N, C;
  cin >> N >> C;
  vector<pair<pair<int, int>, int>> programs(N);
  vector<vector<int>> time(C, vector<int>(2 * pow(10, 5) + 10, 0));

  rep(i, N)
  {
    int s, e, c;
    cin >> s >> e >> c;
    time[c - 1][2 * s]++;
    time[c - 1][2 * e]--;
  }
  rep(c, C) rep(t, time[0].size())
  {
    if (time[c][t] == -1)
    {
      time[c][t] = 0;
      time[c][t + 1]--;
      t++;
    }
  }

  rep(c, C) rep(t, time[0].size() - 1)
  {
    time[c][t + 1] += time[c][t];
  }

  int ans = 0;
  rep(t, time[0].size())
  {
    int count = 0;
    rep(c, C)
    {
      count += time[c][t];
    }
    ans = max(ans, count);
  }
  cout << ans << endl;
  return 0;
}

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

using i32 = int_fast32_t;
using i64 = int_fast64_t;

int main() {
    i32 n, k;
    cin >> n >> k;
    vector<i64> a(n+1);
    for (i32 i = 1; i < n+1; i++) cin >> a[i];
    partial_sum(begin(a), end(a), begin(a));

    i32 ans = 0;
    map<i32, i32> count;
    for (i32 i = 0; i < n+1; i++) {
        if (i >= k) count[(a[i-k] - (i-k)) % k]--;
        ans += count[(a[i] - i) % k]++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 14336
#include<iostream>
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
int n,m,cnt,ans,x[100010];
int main()
{
	int i,s,a,b,j,k;
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%d",&x[i]);x[n+1]=n;
	for(i=1;i<=n;i++)
		if(x[i]==i)
		{
			cnt++;
			if(x[i+1]==i+1)swap(x[i+1],x[i]);
			else
			{
				if(i>1)swap(x[i-1],x[i]);
				else swap(x[i+1],x[i]);
			}
		}
	printf("%d",cnt);
	return 0;
}

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

namespace ProgramingStudying2
{
    class Program
    {

        static void Main(string[] args)
        {
            var hw = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var h = hw[0];
            var w = hw[1];
            
            var field = new string[h];
            for(int i = 0; i < h; i++)
            {
                field[i] = Console.ReadLine();
            }

            var dx = new int[] { 1, 0, -1, 0 };
            var dy = new int[] { 0, 1, 0, -1 };

            for(int i = 0; i < h; i++)
            {
                for(int j = 0; j < w; j++)
                {
                    var frag = 0;
                    if(field[i][j] == '#')
                    {
                        for(int k = 0; k < 4; k++)
                        {
                            var nx = i + dx[k];
                            var ny = j + dy[k];

                            if (nx < 0 || nx >= h)
                            {
                                continue;
                            }
                            if (ny < 0 || ny >= w)
                            {
                                continue;
                            }

                            if (field[nx][ny] == '#') 
                            {
                                frag = 1;
                            }
                        }

                        if(frag == 0)
                        {
                            Console.WriteLine("No");
                            return;
                        }
                    }
                }
            }
            Console.WriteLine("Yes");
        }
    }
}


Measured memory_bytes: 28272
#include <stdio.h> 
 #include <string.h> 
 #define MAX 100 
 
 
 int main(){ 
     int n; 
     int t_point=0, h_point=0; 
     char tarou[MAX], hanako[MAX]; 
 
 
     scanf("%d", &n); 
     for(;n>0;n--){ 
         scanf(" %s %s", tarou, hanako); 
         if(strcmp(tarou, hanako)>0){ 
             t_point+=3; 
         }else if(strcmp(tarou, hanako)==0){ 
             t_point+=1; 
             h_point+=1; 
         }else if(strcmp(tarou, hanako)<0){ 
             h_point+=3; 
         } 
     } 
     printf("%d %d\n", t_point, h_point); 
 
 
     return 0; 
}


Measured memory_bytes: 2036
import java.util.Scanner;
import java.util.StringTokenizer;

 class Main {

    public static void main(String[] args) {

        Scanner fastReader = new Scanner(System.in);
        find( fastReader.nextInt() );

    }

    public static void find( int num ){

        int lastDigit = num % 10;

        if( lastDigit == 2 || lastDigit == 4 || lastDigit == 5 || lastDigit == 7 || lastDigit == 9 ){
            System.out.println("hon");
        }
        else if( lastDigit == 0 || lastDigit == 1 || lastDigit == 6 || lastDigit == 8 ){
            System.out.println("pon");
        }else{
            System.out.println("bon");
        }
    }
}



Measured memory_bytes: 35780
/*input

*/
#include<bits/stdc++.h>
//priority_queue<ll, vector<ll>, std::greater<ll> > q;
//gcc 1.cpp -lstdc++ -o main.o
#define ull         unsigned long long
#define ll             long long
#define M             998244353
#define pb             emplace_back
#define p_q         priority_queue
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define all(a)      (a).begin(),(a).end()
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b))/gcd((a),(b))
#define ios            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mp             make_pair
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define F first
#define S second
#define N 200005
using namespace std;


int main(void)
{
    ios
    string s1 , s2;
    cin>>s1>>s2;
    ll n = s1.size();
    ll m = s2.size();
    if ( n + 1 != m){
        cout<<"No"<<"\n";
        return 0;
    }
    ll flag  = 0;
    rep(i,0,n){
        if (s1[i] != s2[i]){
            flag = 1;
            break;
        }
    }
    if (flag){
        cout<<"No"<<"\n";
        return 0;
    }
    if (s2[m-1] >= 'a' && s2[m-1] <= 'z')
        cout<<"Yes"<<"\n";
    else
        cout<<"No"<<"\n";
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

int main() {
  string sa, sb, sc;
  cin >> sa >> sb >> sc;
  char turn = 'a';
  while (1) {
    if (turn == 'a') {
      if (sa.size() == 0) break;
      turn = sa[0];
      sa.erase(sa.begin());
    } else if (turn == 'b') {
      if (sb.size() == 0) break;
      turn = sb[0];
      sb.erase(sb.begin());
    } else if (turn == 'c') {
      if (sc.size() == 0) break;
      turn = sc[0];
      sc.erase(sc.begin());
    }
  }
  char anser = toupper(turn);
  cout << anser << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <assert.h>
#include <numeric>

using namespace std;

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

ll min_ll(ll a, ll b)
{
  if (a >= b)
  {
    return b;
  }
  else
  {
    return a;
  }
}

int main()
{
  ll N, K;
  cin >> N >> K;
  ll ans = min_ll(N % K, K - N % K);
  cout << ans << endl;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 2019


def resolve():
    s = input()
    n = len(s)
    s = s[::-1]

    ruiseki = 0
    cnt = [0] * mod
    ans = 0
    for i in range(n):
        cnt[ruiseki] += 1
        ruiseki += int(s[i]) * pow(10, i, mod)
        ruiseki %= mod
        ans += cnt[ruiseki]

    print(ans)


if __name__ == '__main__':
    resolve()


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

bool isnum(char c){
    string n ="0123456789";
    rep(i, 10){
        if(c == n[i]) return true;
    }
    return false;
}

int main(int argc, char* argv[]){
    int A, B;
    string S;
    string n = "0123456789";
    bool ans = true;

    cin >> A >> B >> S;
    rep(i, A){
        ans &= isnum(S[i]);
    }
    rep(i, B){
        ans &= isnum(S[A+1+i]);
    }
    ans &= (S[A] == '-');

    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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;
}
void print() { cout << "\n"; }
template <class T> void print(const T &x) { cout << x << "\n"; }
template <class T, class... Args> void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
template <class T> void printVector(const vector<T> &v) {
    for(const T &x : v) {
        cout << x << " ";
    }
    cout << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

template <typename T> struct BIT {
    int n;
    vector<T> bit;
    BIT(int _n) { init(_n); }
    void init(int _n) {
        n = _n + 1;
        bit.resize(n + 1, 0);
    }
    // [0, k)
    T sum(int k) {
        T res = 0;
        for(int i = k - 1; i >= 0; i = (i & (i + 1)) - 1) {
            res += bit[i];
        }
        return res;
    }
    // [l, r]
    T sum(int l, int r) { return (l <= r ? sum(r + 1) - sum(l) : 0); }
    // bit[k] += x
    void add(int k, T x) {
        for(int i = k; i < n; i |= i + 1) {
            bit[i] += x;
        }
    }
    // v[0] + ... + v[res] >= x
    int lower_bound(T x) {
        int res = -1;
        int k = 1;
        while(2 * k <= n) {
            k <<= 1;
        }
        for(; k > 0; k >>= 1) {
            if(res + k < n && bit[res + k] < x) {
                x -= bit[res + k];
                res += k;
            }
        }
        return res + 1;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int q;
    cin >> q;
    vector<ll> t(q), a(q), b(q);
    vector<ll> As;
    for(int i = 0; i < q; i++) {
        cin >> t[i];
        if(t[i] == 1) {
            cin >> a[i] >> b[i];
            As.emplace_back(a[i]);
        }
    }
    sort(ALL(As));
    As.erase(unique(ALL(As)), end(As));
    map<ll, int> mp;
    for(int i = 0; i < As.size(); i++) {
        mp[As[i]] = i;
    }
    BIT<ll> bcnt(As.size()), bsum(As.size());
    ll sum = 0;
    int sz = 0;
    for(int i = 0; i < q; i++) {
        if(t[i] == 1) {
            int id = mp[a[i]];
            bsum.add(id, a[i]), bcnt.add(id, 1);
            sum += b[i];
            sz++;
        } else {
            ll res = sum;
            int id = bcnt.lower_bound((sz + 1) / 2);
            res += bsum.sum(id + 1, (int)As.size() - 1);
            res -= As[id] * bcnt.sum(id + 1, (int)As.size() - 1);
            res += As[id] * bcnt.sum(0, id - 1);
            res -= bsum.sum(0, id - 1);
            print(As[id], res);
        }
    }
}

Measured memory_bytes: 15860
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <string.h>
using namespace std;

int main()
{
  int N, M;
  cin >> N >> M;
  int A[M];
  memset(A, 0, sizeof(A));
  for(int i = 0; i < N; i++){
  	int K;
    cin >> K;
    for(int j = 0; j < K; j++){
    	int t;
      	cin >> t;
      	cerr << t << endl;
      	A[t-1]++;
    }
  }
  int count = 0;
  for(int i = 0; i < M; i++){
    cerr << A[i] << endl;
  	if(A[i] == N)
      count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
const int N = 1e5;
int f(int n){
	return n*(n+1)/2;
}

int main() {
	// ios_base::sync_with_stdio(false);
 //  cin.tie(NULL);
 //  cout.tie(NULL);
	int n,m;
  while(cin >> n >> m){
  	cout << f(n-1) + f(m-1) << endl;
  }
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    string s;
    cin >> s;
    int n = s.size();

    int ans = 0;
    for(int i=1; i<n; ++i){
        if(s[i] != s[i-1])
            ++ ans;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <numeric>	// ???????????????????¨?????¨??????¨
using std::cout;
using std::cin;
using std::endl;
using std::vector;

int main() {
	int r, c;
	//int sumR, sumC;	// ??????????¨???¨??????????¨?
	// ?????¨????????°???????????????
	cin >> r >> c;
	vector<vector<int>> data;
	data.resize(r);
	for (int i = 0; i < r; i++)
	{
		data[i].resize(c);
	}

	// ??\???
	for (int i = 0; i < r; i++)
	{
		for (int j = 0; j < c; j++)
		{
			cin >> data[i][j];
		}
	}

	// ?¨??????¨??????
	// ??????????????¨??????????¨?
	int sum;
	for (int i = 0; i < data.size(); i++)
	{
		sum = 0;
		for (int j = 0; j < data[0].size(); j++)
		{
			cout << data[i][j] << " ";
			sum += data[i][j];
		}
		cout << sum << endl;
	}

	// ??????????¨???¨????????????????¨?
	int Asum = 0;
	for (int i = 0; i < data[0].size(); i++)
	{
		sum = 0;
		for (int j = 0; j < data.size(); j++)
		{
			sum += data[j][i];
		}
		cout << sum << " ";
		Asum += sum;
	}
	cout << Asum << endl;

	/*
	// ??????????¨????
	for (int i = 0; i < r; i++)
	{
		cout << accumulate(data[i].begin(), data[i].end(), 0) << endl;;
	}
	cout << "**********************" << endl;
	int sum = 0;
	// ??????????¨????
	for (int i = 0; i < r; i++)
	{
		for (int j = 0; j < r; i++)
		{
			sum += data[j][i];
		}
		cout << sum << endl;
	}
	*/
	/*
	// ??????
	for (int i = 0; i < r; i++)
	{
		for (int j = 0; j < c; j++)
		{
			cout << data[i][j];
		}
		cout << endl;
	}
	*/
	return 0;
}

Measured memory_bytes: 3152
/*
17D8101031C 杉山祥吾 ID:keisei334 C++
*/

#include <iostream>

using namespace std;

int main(){
  double a,b;

  cin>>a>>b;

  cout<<a*b<<" "<<2*(a+b)<<"\n";

  return 0;
}

/*実行結果
Input:3 5
Output:15 16
*/


Measured memory_bytes: 3224