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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
ll X[202],Y[202];
ll mo=998244353;
int did[202][202];
ll p2[202];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) cin>>X[i]>>Y[i];
	
	ll ret=1;
	p2[0]=1;
	FOR(i,N) p2[i+1]=p2[i]*2%mo;
	
	ret=(p2[N]+mo-1-N-N*(N-1)/2)%mo;
	
	FOR(y,N) FOR(x,y) if(did[y][x]==0) {
		vector<int> V;
		V.push_back(x);
		V.push_back(y);
		FOR(i,N) if(i!=x && i!=y) if((X[i]-X[x])*(Y[y]-Y[x])-(X[y]-X[x])*(Y[i]-Y[x])==0) V.push_back(i);
		FORR(a,V) FORR(b,V) did[a][b]=1;
		r=V.size();
		if(r>=3) ret=(ret+mo-p2[r]+r+r*(r-1)/2+1)%mo;
	}
	
	
	cout<<(ret%mo+mo)%mo<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
using namespace std;
const int N=66666;
int n,l[N],r[N],a[N];
ll f[19][19][N];
ll F(int l,int r,int S){
	if (l+1==r) return 0;
	if (f[l][r][S]>=0) return f[l][r][S];
	f[l][r][S]=(1ll<<60);
	For(m,l+1,r-1) f[l][r][S]=min(f[l][r][S],F(l,m,S*2)+F(m,r,S*2+1)+(::l[S]+::r[S])*1ll*a[m]);
	return f[l][r][S];
}
int main(){
	scanf("%d",&n);
	For(i,1,n) scanf("%d",&a[i]);
	l[1]=1; r[1]=1;
	For(i,1,(1<<(n-3))-1){
		l[i*2]=l[i]; r[i*2]=l[i]+r[i];
		l[i*2+1]=l[i]+r[i]; r[i*2+1]=r[i];
	}
	memset(f,233,sizeof(f));
	printf("%lld\n",F(1,n,1)+a[1]+a[n]);
}

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

using namespace std;

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
    long long a;
    string b;
    cin >> a >> b;

    long long bb = ctoi(b[0])*100+ctoi(b[2])*10+ctoi(b[3]);

    a=a*bb;
    a=a/100;

    cout << a << endl;

}

Measured memory_bytes: 3628
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
//*********************************************DO IT NOW****************************************************************
#include<bits/stdc++.h> 
#include<random>
#define int long long   
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back
#define mod 1000000007
#define pi 3.14159265359
#define mk(arr,n,type)  type *arr=new type[n];
#define sl s1.length();
#define yes cout<< "YES"<<endl
#define no  cout<< "NO"<<endl
#define all(v) (v).begin(),(v).end()
#define s(v)   sort(v,v+n)
#define  mt mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define read(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define print(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" "
#define for1(i,a,n)  for(int i=0;i<n;i++)
#define rep(i, c) for(int i = 0; i < (int)c; i++)
#define set(x) cout<<fixed<<setprecision(x);
using namespace std;
//**********************************************DO IT NO****************************************************************
void fastio()
{  
  #ifndef ONLINE_JUDGE
  freopen("INPUT.txt","r",stdin);
  freopen("OUTPUT.txt","w",stdout); 
  #endif
  ios_base :: sync_with_stdio(false); 
  cin.tie(NULL) ; 
  cout.tie(NULL);
}
int dp[101][1001],ans1=1e9,dp1[1000001];
int num[10];
int a[1000000];
signed main()
{   
    fastio();
    int t=1;
    //cin>>t;
    while(t--)
    {  
        int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
        int k;
        cin>>k;
        cout<<a[k-1];
    }
}
// 🍪 🍪 🍪


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
int main(){
    int n,ans=0;
    cin >> n;
    vector<int> e(100001,0),o(100001,0),v(n);//do initialization
    //各数が偶数番目、奇数番目に何回現れたかを記録
    for(int i=0;i < n;i++)
    {
        cin >> v.at(i);
        if(i%2==0){
            e.at(v.at(i))++;
        }else{
            o.at(v.at(i))++;
        }
    }//input
    int anse=0,enumb;
    int ansesub=0,enumbsub;
    int anso=0,onum;
    int ansosub=0,onumsub;
    for(int i=0;i < 100001;i++)
    {
        if(anse<e.at(i)){
            enumb=i;
            anse=e.at(i);
        }
    }
    e.at(enumb)=-1;
    for(int i=0;i < 100001;i++)
    {
        if(ansesub<e.at(i)){
            enumbsub=i;
            ansesub=e.at(i);
        }
    }
    
    for(int i=0;i < 100001;i++)
    {
        if(anso<o.at(i)){
            onum=i;
            anso=o.at(i);
        }
    }
    o.at(onum)=-1; 
    for(int i=0;i < 100001;i++)
    {
              
        if(ansosub<o.at(i)){
            onumsub=i;
            ansosub=o.at(i);
        }
    }

    if(enumb != onum){
        ans += n-anse-anso;
    }else{
        ans=min(n-anse-ansosub,n-ansesub-anso);
    }

    cout << ans << endl;
}

Measured memory_bytes: 1408
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vll a(n);
    ll sum = 0;
    REP(i,n){
        cin >> a[i];
        sum += a[i];
    } 
    ll ans = LLINF;
    ll now = a[0];
    for(int i=1;i<n;i++){
        ans = min(ans, abs(now-(sum-now)));
        now += a[i];
    }
    cout << ans  << endl;

    return 0;
}

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

using namespace std;

int main(){
  int N, M, tmp;
  cin >> N >> M;
  int ans = 0;
  int sum = 0;
  vector<int> V;
  for (int i=0; i<N; i++){
    cin >> tmp;
    V.push_back(tmp);
    sum += tmp;
  }
  for (int v : V){
    if (v >= (double)sum / (4.0*(double)M)) ans++;
  }
  
  cout << (ans >= M ?  "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    // スペース区切りの整数の入力
    int N,M;
    cin >> N >> M;

    int ans=0;

    if (2<=N)
    {
        ans += N*(N-1)/2;
    }
    
    if (2<=M)
    {
        ans += M*(M-1)/2;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
//g++ -Wall -Werror -O2 -std=c++11 main.cpp -o main && main.exe < in.txt
#include <bits/stdc++.h>

using namespace std;

#define INF 0x3f3f3f3f
#define ll long long

int main() {
	ios::sync_with_stdio(false);

	int A, B, C;

	cin >> A >> B >> C;

	int maxC = min(C, A + B + 1);

	cout << maxC + B << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
// #include <string>
// #include <set>
// #include <algorithm>

using namespace std;
// typedef unsigned long long ull;


void p() {
    cout << "\n";
}
template<class Head, class... Body>
void p(Head head, Body... body) {
    cout << head << ",";
    p(body...);
}

int main(int argc, char const *argv[]) {
    int A, B, K;
    cin >> A >> B >> K;

    int count = 0;
    int i;
    for (i = min(A, B); i >= 1; i--) {
        if (A % i != 0 || B % i != 0) continue;
        // p(i);
        count += 1;
        if (count == K) {
            break;
        }
    }

    cout << i << endl;
    return 0;
}


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

int main() {
    int k;
    int a[2];
    int num;
    for (int i = 0; i < 3; ++i) cin >> a[i];
    cin >> k;
    sort(a, a+3,greater<int>());    
  
    num = a[0] * pow(2,k);
    cout << num + a[1] + a[2] << endl;
  
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
     
class Main{
    public static void main(String arg[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        HashSet<Integer> hs = new HashSet<Integer>();

        for(int i = 0; i < N; i++) {
            hs.add(sc.nextInt());
        }

        sc.close();

        System.out.println(hs.size());    
    }
}

Measured memory_bytes: 23892
#include <iostream>
#include <string>
#include <cmath>
#include <cstdio>

using namespace std;

double sum = 0;
int x[10], y[10];
double d[10][10];
int n;

bool used[10] = {0};

void rec(int cur, double curSum) {
  bool fin = true;
  for (int i = 0; i < n; i++) {
    if (!used[i]) {
      fin = false;
      used[i] = true;
      rec(i, curSum + d[cur][i]);
      used[i] = false;
    }
  }
  if (fin) sum += curSum;
}

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> x[i] >> y[i];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j) continue;
      d[i][j] = d[j][i] = sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
    }
  }
  for (int i = 0; i < n; i++) {
    used[i] = true;
    rec(i, 0);
    used[i] = false;
  }
  int fac = 1;
  for (int i = 2; i <= n; i++) fac *= i;
  sum = sum / (double)fac;
  printf("%.8f\n", sum);
  return 0;
}


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


int main() {
  long n;
  cin>>n;
  vector<long>a(n);
  
  long to=0;
  rep(i,n){
    cin>>a.at(i);
    to=(to^a.at(i));
  }
  rep(i,n){
    cout<<(to^a.at(i))<<" ";
  }
  cout<<endl;
  
}





Measured memory_bytes: 4836
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define INF 999999999
typedef long long int Int;
using ll = long long;
using VI = vector<int>;
int gcd(Int a, Int b) {
 return b != 0 ? gcd(b, a % b) : a;
}
int lcm(Int a, Int b) {
 return a / gcd(a, b)*b;
}
int main(){
  int n;cin >> n;
  vector<int> a(n);
  vector<int> b(n,1);
  int koubai;
  rep(i,n){
    cin >> a[i];
    if(i==0) koubai=a[0];
    koubai=lcm(koubai,a[i]);
  }
   int z=0;
  rep(i,n){
    b[i]=koubai/a[i];
    z+=b[i];
  }
  cout << double(koubai)/double(z) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define int ll
using namespace std;
using ll=long long;
using pii=pair<int,int>;

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

bool cmp(pair<pair<string,int>,int> a,pair<pair<string,int>,int> b)
{
	if(a.F.F!=b.F.F) return a.F.F<b.F.F;
	return a.F.S>b.F.S;
}

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n; cin>>n;
	vector<pair<pair<string,int>,int>> v(n);
	For(i,0,n-1)
	{
		cin>>v[i].F.F>>v[i].F.S;
		v[i].S=i+1;
	}
	sort(all(v),cmp);
	for(auto i:v) cout<<i.S<<"\n";
	return 0;
}















Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>

int main(int argc, char const *argv[]) {
  std::string str;
  std::cin >> str;
  int x;
  std::cin >> x;
  for(int i=0;i<x;i++){
    std::string order;
    std::cin >> order;
    if(order == "replace"){
      int a,b;
      std::string s;
      std::cin >> a >> b >> s;
      str.replace(a,b-a+1,s);
    }else if(order == "reverse"){
      int a,b;
      std::cin >> a >> b;
      reverse(str.begin() + a, str.begin() + b + 1);
    }else if(order == "print"){
      int a,b;
      std::cin >> a >> b;
      std::string print;
      print = str.substr(a,b-a+1);
      std::cout << print << std::endl;
    }
  }
  return 0;
}

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

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

    long ans = 0;
    long temp = 0;
    for (long i = 0; i < (N-1); i++) {        
        if (H.at(i) < H.at(i + 1)) {
            temp = 0;
            continue;
        }
        temp++;
        ans = max(temp, ans);
    }

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

Measured memory_bytes: 1024
# トポロジカルソート

import sys
readline = sys.stdin.readline

N,M = map(int,readline().split())
G = [[] for i in range(N)]
revG = [[] for i in range(N)]
# ある頂点に対する入次数を記録
indegree = [0 for i in range(N)]

for i in range(N - 1 + M):
  u,v = map(int,readline().split())
  G[u - 1].append(v - 1)
  revG[v - 1].append(u - 1)
  indegree[v - 1] += 1

# トポロジカルソートを格納する
res = []

# 入り次数が0になった頂点を高速に発見するため、隣接する頂点をキューで管理
from collections import deque
q = deque()
for i in range(len(indegree)):
  if indegree[i] == 0:
    q.append(i)

while q:
  # キューの先頭の頂点を取り出す
  v = q.popleft()
  
  # その頂点と隣接する頂点の入次数を減らし、0になったらキューに追加
  for child in G[v]:
    indegree[child] -= 1
    if indegree[child] == 0:
      q.append(child)
      
  # 入り次数が0で且つ隣接する頂点が処理済みとなった頂点をソート配列に追加する
  res.append(v)
  
# インデックスと頂点番号を逆転させたものを作成する
inds = [-1 for i in range(N)]
for i in range(len(res)):
  inds[res[i]] = i
  
# print(inds)
for i in range(len(revG)):
  ans = -1
  maxv = -1
  for parent in revG[i]:
#    print("i",i,"に対する親",parent)
    if inds[parent] > maxv:
      maxv = inds[parent]
      ans = parent
  print(ans + 1)
      
  

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

typedef long long int ll;
ll powk(ll a, ll n = 2){
    ll r = 1;
    for(ll i = 0;i < n;i++){
        r *= a;
    }

    return r;
}


int main()
{
    ll n, m, x;
    cin >> n >> m >> x;
    vector<pair<ll,vector<ll>>> ca(n);
    for(ll i = 0;i < n;i++){
        cin >> ca[i].first;
        ca[i].second = vector<ll>(m);
        for(ll j = 0;j < m;j++){
            cin >> ca[i].second[j];
        }
    }

    ll ans = 1e9;
    for(ll i = 0;i < (1<<n);i++){
        vector<ll> s;
        for(ll j = 0;j < n;j++){
            if(i & (1<<j)){
                s.push_back(j);
            }
        }

        ll tans = 0;
        vector<ll> r(m);
        for(ll j = 0;j < s.size();j++){
            for(ll k = 0;k < m;k++){
                r[k] += ca[s[j]].second[k];
            }
            tans += ca[s[j]].first;
        }

        bool f = true;
        for(ll j = 0;j < m;j++){
            if(r[j] < x){
                f = false;
            }
        }
        if(f){
            ans = min(tans, ans);
        }
    }

    if(ans == 1e9){
        cout << -1;
    }
    else{
        cout << ans;
    }

    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>

int main(void){
    int h, w;
    int i, j;
    while(1){
        scanf("%d %d", &h, &w);
        if(h + w == 0)
            break;
        for(i = 0; i < h; i++){
            for(j = 0; j < w; j++)
                putchar('#');
            putchar('\n');
        }
        puts("");
    }
    return 0;
}

Measured memory_bytes: 588
#include<bits/stdc++.h>
using namespace std;
int type[200];
int main(){
	ios::sync_with_stdio(false);
	int  k,t;
	cin>>k>>t;
	for(int i=1;i<=t;i++){
		cin>>type[i];
	}
	sort(type+1,type+t+1);
	if(k%2){
		int max=(k+1)/2;
		if(type[t]>max){
			cout<<(type[t]-max)*2;
			
		}
		else cout<<"0";
	}
	else{
		int max=k/2;
		if(type[t]>max){
			cout<<(type[t]-max)*2-1;
		}
		else cout<<"0";
	}
}


Measured memory_bytes: 384
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int ans = 0;
	int tmp;
	
	//エラトステネスの篩でP_max以下の素数vector primeをつくる
	bool *pr;
	int P_max = 1000000; //10^6くらいまでが現実的か
	pr = (bool*)malloc(sizeof(bool) * P_max);
	REP(i, P_max) {
		pr[i] = i;
	}
	REP(i, P_max + 1) pr[i] = true;
	pr[0] = false;
	pr[1] = false;
	for(int i = 2; i * i <= P_max; i++){ 
		if(pr[i] == true){
			for(int j = 2 * i; j <= P_max; j+=i){
				pr[j] = false;
			}
		}
	}
	vector<int> prime;
	for(int i = 2; i <= P_max; i++){
		if(pr[i]) prime.push_back(i);
	}
	//
	int n;
	cin >> n;
	vector <int> answer;
	REP(i, prime.size()){
		if(prime[i] % 5 == 1)answer.push_back(prime[i]);
	}
	REP(i, n) cout << answer[i] << " ";
	cout << endl;
}

Measured memory_bytes: 1916
N = int (input ())
T,A = map (int, input ().split ())
S = 1000000
l = [int (x) for x in input().split()]
for i in range (len(l)):
  s = abs((T-l[i]*0.006)-A)
  if s < S:
    S = s
    ans = i
print (ans+1)

Measured memory_bytes: 9212
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+10;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
ll n,cnt=0;
ll a[N],fa[N],b[N];
string s1,s2;
ll find(ll x) {return fa[x]==x?x:fa[x]=find(fa[x]);}
void add(ll x,ll y) {
    ll dx=find(x),dy=find(y);
    fa[dx]=dy;
}
int main() {
  //  freopen("../in.in", "r", stdin);
//    freopen("../out.out","w",stdout);
    ios::sync_with_stdio(false);
    ll t, i, j = 0;
    ll m, x, y,k;
    cin>>n>>m;
    for(i=1;i<=n;i++) fa[i]=i;
    for(i=0;i<m;i++){
        cin>>x>>y;
        add(x,y);
    }
    for(i=1;i<=n;i++) b[find(i)]++;
    ll maxn=0;
    for(i=1;i<=n;i++){
        maxn=max(b[i],maxn);
    }
    cout<<maxn<<endl;
    return 0;
}

Measured memory_bytes: 11392
#include <iostream>

using namespace std;

typedef long long ll;

int main () {
	ll n, m;
	ll i, j;
	ll *ret;
	
	cin >> n;
	
	ret = (ll*)calloc(n, sizeof(ll));
	
	for (i = 0; i< (n - 1); i++) {
		cin >> m;
		ret[m - 1]++;
	}
	for (i = 0; i< n; i++) {
		cout << ret[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 5180
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

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

  string ans = "Yes";
  int minv = h[n - 1];
  for (int i = n - 2; i >= 0; i --) {
    if (h[i] > minv) {
      if (h[i] - 1 > minv) {
        ans = "No";
        break;
      } else h[i] --;
    }
    minv = min(minv, h[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N;
	cin >> N;
	map<int,int> sto;
	for(int i=0;i<N;++i){
		int res;
		cin >> res;
		if( sto.find(res) != sto.end() ){
			sto[res]++;
		}else{
			sto[res] = 1;
		}
	}
	int M;
	cin >> M;
	for(int i=0;i<M;++i){
		int ter;
		cin >> ter;

		if( sto.find(ter) != sto.end() ){
			int temp = sto[ter];
			if( temp == 0 ){
				cout << "NO" << endl;
				return;
			}else{
				sto[ter]--;
			}
		}else{
			cout << "NO" << endl;
			return;
		}
	}
	cout << "YES" << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

Measured memory_bytes: 9600
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) {
        cin >> a[i];
    }

    int cou = 0;
    rep(i, n) {
        int minj = i;
        for(int j = i; j < n; ++j) {
            if(a[j] < a[minj]) {
                minj = j;
            }
        }
        if(minj > i) {
            swap(a[i], a[minj]);
            cou++;
        }
    }

    rep(i, n) {
        cout << a[i] << (i == n-1?'\n':' ');
    }

    cout << cou << endl;
}


Measured memory_bytes: 3172
#include<iostream>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, x, n) for (int i = x; i < (n); ++i)
using namespace std;

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

    if (N % 500 <= A) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!

s = list(input())
s_len = len(s)
ctr = 0

for i in range(s_len - 1):
    if s[i] == s[i + 1]:
        if s[i] == '0':
            s[i + 1] = '1'
        else:
            s[i + 1] = '0'
        ctr += 1
print(ctr)

Measured memory_bytes: 49452
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;

using namespace std;

const long long _MOD = 1000000007;
const long long MOD = 998244353;

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

	string s;
	cin >> s;
	ll pre[2019] = { 0 };
	ll p[2019] = { 0 };

	ll ans = 0;
	rep(counter, s.length()) {
		ll t = s[counter] - '0';

		rep(i, 2019) {
			p[(i * 10 + t) % 2019] = pre[i];
			if ((i * 10 + t) % 2019 == 0) {
				ans += pre[i];
			}
		}
		++p[t];
		rep(i, 2019) {
			pre[i] = p[i];
		}
	}

	cout << ans << "\n";

	return 0;
}



Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll h,n,sum=0;ll x;
  cin>>h>>n;
  for(ll i=0;i<n;i++)
  {
    cin>>x;sum+=x;
  }
  if(sum<h)cout<<"No";
  else cout<<"Yes";
}

Measured memory_bytes: 256
toInt :: (String -> Int)
toInt x = read x ::Int

getInts :: IO [Int]
getInts = do
  x <- getLine
  let y = (map$toInt)$words x
  return y



solve :: Int -> Int -> Int
solve n m = div n m + if mod n m == 0 then 0 else 1



main = do
  n <- getInts
  putStrLn $ show (solve (n!!0) (n!!1))


Measured memory_bytes: 508
#include <iostream>
using namespace std;
#define INF 2147483647
int n,q,rmq[262144];
void update(int a,int b){
    a+=n-1;
    rmq[a]=b;
    while(a>0){
        a=(a-1)/2;
        rmq[a]=min(rmq[2*a+1],rmq[2*a+2]);
    }
}
int query(int a,int b,int k,int s,int t){
    if(a<=s&&t<=b)return rmq[k];
    if(t<a||b<s)return INF;
    
    return min(query(a,b,k*2+1,s,(t+s-1)/2),query(a,b,k*2+2,(t+s+1)/2,t));
}
int main(void){
    int n1;
    cin>>n1>>q;
    
    for(n=1;n<n1;n*=2);
    for(int i=0;i<n*2-1;i++)rmq[i]=INF;
        
    
    for(int i=0;i<q;i++){
        int c,x,y;
        cin>>c>>x>>y;
       if(c==0)update(x,y);
       else cout<<query(x,y,0,0,n-1)<<endl;
    }
}

Measured memory_bytes: 4080
#include <iostream>

using namespace std;

int main()
{
    int x; cin >> x;
    int ans = 0;

    for (int i = 1; i <= x; ++i) {
        if (i * (i + 1) / 2 >= x) {
            ans = i;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int N;
  int D[300];
  scanf("%d", &N);
  for(int i=1;i<=N;i++){
    scanf("%d %d", D+2*i-1,D+2*i);
  }
  int c=0,ans=0;
  for(int i=1;i<=N;i++){
    if(D[2*i-1]==D[2*i]){
      c++;
    }else{
      c=0;
    }
    if(c==3){
      ans=1;
      break;
    }
  }
  
  if(ans==1) printf("Yes\n");
  else printf("No\n");
  return 0;
}

Measured memory_bytes: 1660
#include<stdio.h>
int main(){
  int i=0,A[1000],N,j,v,k=0;
  
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
 
  for(i=0;i<N;i++)
    {
      
      v=A[i];
    
      j=i-1;
      while(j>=0 && A[j]>v)
	{
	
	  A[j+1]=A[j];
	  j--;
	  A[j+1]=v;
	
	}
      for(k=0;k<N;k++)
	{
	  if(k!=0)printf(" ");
	  printf("%d",A[k]);
	 
	}
      printf("\n");
    }


  
  return 0;
}



Measured memory_bytes: 2760
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

using i64=long long;
using vx=vector<i64>;

const i64 MOD=1e9+7;

i64 modpow(i64 b, i64 p, i64 m=MOD) {
    /* Exponentiation by squaring */
    // returns n == b**p (mod m)
    i64 n=1, a=b%m;
    while (p) {
        if (p & 1)
            (n *= a) %= m;

        (a *= a) %= m;
        p >>= 1;
    }
    return n;
}

i64 modinv(i64 a, i64 p=MOD) {
    // returns n == a**-1 (mod p)
    return modpow(a, p-2, p);
}

i64 moddiv(i64 a, i64 b, i64 p=MOD) {
    // returns n == a b**-1 (mod p)
    return a*modpow(b, p-2, p) % p;
}

i64 modsub(i64 a, i64 b, i64 p=MOD) {
    // returns n == a-b (mod p)
    return ((a-b)%p+p) % p;
}

void table_modfact(int n, vx &ftable, int p=1e9+7) {
    // returns {i! mod p; for i in [0, n)}
    ftable.assign(n, 0); ftable[0]=1;

    int ub=min(n, p);
    for (int i=1; i<ub; ++i)
        ftable[i] = (ftable[i-1]*i) % p;
}

i64 modfact(i64 n, i64 &e, vx &ftable, i64 p=MOD) {
    // returns a mod p and derives e; a p**e == n!
    e = 0;
    if (!n) return 1;

    i64 a=modfact(n/p, e, ftable, p);
    e += n/p;

    if (n/p % 2) {
        a *= (p-ftable[n%p]);
    } else {
        a *= ftable[n%p];
    }
    return a % p;
}

i64 modchoose(int n, int k, vx &ftable, i64 p=MOD) {
    // returns nCk mod p
    if (n<0 || k<0 || n<k) return 0;

    i64 e1, e2, e3;
    i64 a1, a2, a3;
    a1 = modfact(n, e1, ftable, p);
    a2 = modfact(k, e2, ftable, p);
    a3 = modfact(n-k, e3, ftable, p);

    if (e1 > e2+e3) return 0;
    return moddiv(a1, a2*a3%p, p);
}

int main() {
    i64 H, W, A, B;
    scanf("%lld %lld %lld %lld", &H, &W, &A, &B);

    vx ftable; table_modfact(H+W-1, ftable);
    i64 res=0;
    for (int i=B; i<W; ++i) {
        i64 former=modchoose(H-A-1+i, i, ftable);
        i64 latter=modchoose(W+A-2-i, A-1, ftable);
        (res += former*latter%MOD) %= MOD;
    }

    printf("%lld\n", res);
    return 0;
}



Measured memory_bytes: 1920
# coding: utf-8
import copy

def partition(A, p, r):
    r -= 1
    i = p - 1
    x = A[r][1]
    for j in range(p, r):
        if A[j][1] <= x:
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i + 1], A[r] = A[r], A[i + 1]
    return i + 1
    
def quick_sort(A, p, r):
    if p < r:
        q = partition(A, p, r)
        quick_sort(A, p, q)
        quick_sort(A, q+1, r)

def merge_sort(A, left, right):
    if left + 1 < right:
        mid = int((left + right) / 2)
        merge_sort(A, left, mid)
        merge_sort(A, mid, right)
        merge(A, left, mid, right)

def merge(A, left, mid, right):
    L = A[left:mid] + [('dummy', float('inf'))]
    R = A[mid:right] + [('dummy', float('inf'))]
    i = 0
    j = 0
    for k in range(left, right):
        if L[i][1] <= R[j][1]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1

if __name__ == "__main__":
    # n = 6
    # A = [('D', 3), ('H', 2), ('D', 1), ('S', 3), ('D', 2), ('C', 1)]
    n = int(input())
    A = []
    for _ in range(n):
        mark, num = input().split()
        num = int(num)
        A.append((mark, num))
    B = copy.deepcopy(A)

    quick_sort(A, 0, len(A))
    merge_sort(B, 0, len(B))

    if A == B:
        print('Stable')
    else:
        print('Not stable')

    for i in A:
        print('{} {}'.format(i[0], i[1]))


Measured memory_bytes: 18368
class UnionFind():
    def __init__(self,n):
        self.n = n
        self.parents = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
    def find(self,x):
        root = x
        while self.parents[root] != root:
            root = self.parents[root]
        while self.parents[x] != root:
            parent = self.parents[x]
            self.parents[x] = root
            x = parent
        return root
    def unite(self,x,y):
        xroot = self.find(x)
        yroot = self.find(y)
        if xroot == yroot:
            return
        xrank = self.rank[xroot]
        yrank = self.rank[yroot]
        if xrank < yrank:
            self.parents[xroot] = yroot
        elif xrank == yrank:
            self.parents[yroot] = xroot
            self.rank[yroot] += 1
        else:
            self.parents[yroot] = xroot
            
N,K,L=map(int,input().split())
ufroad = UnionFind(N)
uftrain = UnionFind(N)

for i in range(K):
    p,q = map(int,input().split())
    ufroad.unite(p-1,q-1)
for i in range(L):
    r,s = map(int,input().split())
    uftrain.unite(r-1,s-1)
uflist=[]
for i in range(N):
    uflist.append((ufroad.find(i), uftrain.find(i)))
counter={}
for i in range(N):
  if uflist[i] not in counter.keys():
    counter[uflist[i]]=1
  else:
    counter[uflist[i]]+=1
print(' '.join(map(str, [counter[uflist[i]] for i in range(N)])))

Measured memory_bytes: 66344
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
  int n, cnt=0;
  cin >> n;

  int l[n];
  for (int i=0; i<n; i++)
    cin >> l[i];
  
  sort(l, l+n);
  
  for (int a=0; a<n; a++) for (int b=a+1; b<n; b++) for (int c=b+1; c<n; c++)
    if (l[a] != l[b] && l[b] != l[c] && l[c] < l[a] + l[b])
      // cout << l[a] << ' ' << l[b] << ' ' << l[c] << endl;
      cnt++;
  
  cout << cnt;
  return 0;
}

Measured memory_bytes: 3636
import copy
s=list(input())
if s[0]=='A' and 'C' in s[2:len(s)] :
  t=copy.copy(s)
  s.remove('A')
  s.remove('C')
  result=''.join(s)
  if len(s)==len(t)-2 and result.islower()==True and t[-1]!='C':
    print('AC')
  else:
    print('WA')
    
else:
  print('WA')


Measured memory_bytes: 3444
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

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 T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

#define int long long

signed main() {
    int n, weight;
    cin >> n >> weight;
    vector<int> w(n);
    vector<int> v(n);
    rep(i, n) cin >> w[i] >> v[i];
    vector<vector<int>> dp(n+1, vector<int>(weight+1, 0));
    for (int i = 1; i <= n; i++) {
        for (int sum_w = 0; sum_w <= weight; sum_w++) {
            if (sum_w - w[i-1] >= 0)
                chmax(dp[i][sum_w], dp[i-1][sum_w - w[i-1]] + v[i-1]);
            chmax(dp[i][sum_w], dp[i-1][sum_w]);
        }
    }
    cout << dp[n][weight] << endl;
    return 0;
}

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

int main() {
    string s;
    cin >> s;
    for (int i = 1; i <= s.length(); i++) {
        if (i % 2) {
            if (!(s[i-1] == 'R' || s[i-1] == 'U' || s[i-1] == 'D')) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    for (int i = 1; i <= s.length(); i++) {
        if (i % 2 == 0) {
            if (!(s[i-1] == 'L' || s[i-1] == 'U' || s[i-1] == 'D')) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}


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

int E, V, m, cap;
string start, goal;
map<string, int> mp;
set<string> st;
const int MAX_E = 6000;
const int INF = 1e12;

struct edge{
	int to, cost;
	edge(int to, int cost):to(to), cost(cost){}
};

vector<edge> G[MAX_E];
vector<int> use;

int d[MAX_E];
void dijkstra(int s){
	fill(d, d + MAX_E, INF);
	d[s] = 0;
	priority_queue<P, vector<P>, greater<P> > q;
	q.push(P(d[s], s));
	while(!q.empty()){
		P p = q.top(); q.pop();
		int from = p.second;
		int cost = p.first;
		if(d[from] < cost) continue;
		rep(i, 0, G[from].size()){
			edge e = G[from][i];
			int next = e.to;
			int newCost = e.cost + cost;
			if(d[next] > newCost){
				d[next] = newCost;
				q.push(P(newCost, next));
			}
		}
	}
}


signed main(){
	while(1){
		cin >> V >> m >> cap;
		if(V == 0 && m == 0 && cap == 0) break;
		mp.clear(); st.clear(); use.clear();
		rep(i, 0, MAX_E) G[i].clear();
		cin >> start >> goal;
		st.insert(start);
		st.insert(goal);
		mp[start] = 0;
		mp[goal] = 1;
		use.push_back(0);
		use.push_back(1);
		rep(i, 0, V){
			string s, t; int cost;
			cin >> s >> t >> cost;
			if(!st.count(s)){
				mp[s] = st.size();
				st.insert(s);
			}
			if(!st.count(t)){
				mp[t] = st.size();
				st.insert(t);
			}
			G[mp[s]].push_back(edge(mp[t], cost));
			G[mp[t]].push_back(edge(mp[s], cost));
		}
		/*for(map<string, int>::iterator it = mp.begin(); it != mp.end(); it++){
			cout << it -> first << " " << it -> second << endl;
		}*/
		rep(i, 0, m){
			string s;
			cin >> s;
			if(mp[s] > 1) use.push_back(mp[s]);
		}
		vector<edge> tmp[MAX_E];
		rep(i, 0, use.size()){
			dijkstra(use[i]);
			rep(j, i + 1, use.size()){
			//cout << use[i] << " " << use[j] << " " << d[use[j]] << endl;
				if(d[use[j]] <= cap * 10){
					//cout << use[i] << " " << use[j] << endl;
					tmp[i].push_back(edge(j, d[use[j]]));
					tmp[j].push_back(edge(i, d[use[j]]));
				}
			}
		}
		//rep(i, 0, use.size()) cout << use[i] << " ";
		//cout << endl;
		rep(i, 0, MAX_E){
			G[i] = tmp[i];
		}
		dijkstra(0);
		//rep(i, 0, 6) cout << d[i] << " ";
		//cout << endl;
		cout << (d[1] == INF ? -1 : d[1]) << endl;		
	}				
}

Measured memory_bytes: 8588
#include<bits/stdc++.h>
using namespace std;
#define reg register
#define ll long long
#define maxn 100005
inline ll read()
{
	ll x=0,w=0;char ch=getchar();
	while(!isdigit(ch))w|=ch=='-',ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return w?-x:x;
}
vector<int>G[maxn];
int n,k;
int L[maxn],R[maxn],dp[maxn],a[maxn];
inline void dfs(int u,int f,int l,int r)
{
    reg int i,sz=G[u].size();
    if(a[u])if(dp[u]!=(L[u]&1)){puts("No");exit(0);}
    if(a[u])l=L[u],r=R[u];else L[u]=l,R[u]=r;
    for(i=0;i<sz;++i)
    {
        if(G[u][i]==f)continue;
        dp[G[u][i]]=dp[u]^1;
        dfs(G[u][i],u,l-1,r+1);
    }
}
inline void dfs1(int u,int f)
{
    reg int i,sz=G[u].size();
    for(i=0;i<sz;++i)
    {
        if(G[u][i]==f)continue;
        dfs1(G[u][i],u);
        L[u]=max(L[u],L[G[u][i]]-1);
        R[u]=min(R[u],R[G[u][i]]+1);
        if(L[u]>R[u]){puts("No");exit(0);}
    }
}
inline void solve(int u,int f)
{
    reg int i,sz=G[u].size();
    if(L[u]>R[u]){puts("No");exit(0);}
    for(i=0;i<sz;++i)
    {
        if(G[u][i]==f)continue;
        L[G[u][i]]=max(L[G[u][i]],L[u]-1);
        R[G[u][i]]=min(R[G[u][i]],R[u]+1);
        solve(G[u][i],u);
    }
}
int main()
{
    n=read();
    reg int i,x,y;
    for(i=1;i<n;++i)
    {
        x=read(),y=read();
        G[x].push_back(y);
        G[y].push_back(x);
    }k=read();
    for(i=1;i<=k;++i)
    {
        x=read();a[x]=1;
        L[x]=R[x]=read();
    }
    dp[x]=L[x]&1;dfs(x,0,L[x],R[x]);
    dfs1(x,0);solve(x,0);puts("Yes");
    for(i=1;i<=n;++i)printf("%d\n",L[i]);
	return 0;
}


Measured memory_bytes: 12672
#include<stdio.h>

int main()
{
  int m[100],f[100],r[100],i,count;
  i=0;
  scanf("%d %d %d",&m[i],&f[i],&r[i]);

  while(m[i]+f[i]+r[i]!=-3){             // ??\???
    i++;
    scanf("%d %d %d",&m[i],&f[i],&r[i]);
  }

  count=i;
  for(i=0;i<count;i++)                //??????
  if(m[i]==-1 ||f[i]==-1 ||m[i]+f[i]<30){ //??????
    printf("F\n");
  }else if(m[i]+f[i]>=80){
    printf("A\n");
  }else if(m[i]+f[i]>=65){
    printf("B\n");
  }else if(m[i]+f[i]>=50 || r[i]>=50){
    printf("C\n");
  }else if(m[i]+f[i]>=30){
    printf("D\n");
  }

  return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>   
using namespace std;
using namespace __gnu_pbds;
typedef long long ll; 
#define int long long
typedef unsigned long long lu;
typedef vector<ll> v;
typedef vector<vector<ll> > vv;
typedef vector<string>  vs;
typedef vector<pair<ll,ll>> vpr;
typedef vector<bool>vb;
typedef vector<double>vd;
typedef long double ld;
#define f(i,n) for(ll i = 0; i < n; i++)
#define ff(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define amax(x,y) if(y>x) x=y;
#define amin(x,y) if(y<x)x=y;
#define bg(x) x.begin()
#define sz(x) (ll)x.size()
#define in(x,n) for(ll i=0;i<n;i++)cin>>x[i]
#define out(x,n) for(ll i=0;i<n;i++)cout<<x[i]<<" " 
#define mxt(a) *(max_element(a.begin(),a.end()))
#define mnt(a) *(min_element(a.begin(),a.end())
#define tc ll t;cin>>t;while(t--)
typedef pair<ll,ll> pi;
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define yesno(f) if(f) yes else no
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
const ld PI = 2 * acos(0.0);
ll cel(ll x1,ll y1){if((x1%y1)==0)return x1/y1;else return x1/y1+1;}
ll power(ll a,ll b,ll m)
{
    if(b==0)
        return 1;
    ll d=power(a,b/2,m);
    d=(d*d)%m;
    if(b&1)
        d=(d*a)%m;
    return d;
}
const ll mod=1e9+7;
int MOD(int a)
{
    if(a<0)
        a+=mod;
    if(a>=mod)
        a%=mod;
    return a;
}
// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
/*string operations :
str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
str.substr (x) : returns a substring str[x],... end of string
str.find(qtr) : returns the first occurenece of qtr in str */
int32_t main()
{
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int n;cin>>n;
    map<string,int>mapp;
    vs strings={"AC","WA","TLE","RE"};
    for(int i=0;i<n;i++)
    {
        string s;cin>>s;
        mapp[s]++;
    }
    for(auto it:strings)
    {
        cout<<it<<" x "<<mapp[it]<<endl;
    }
    return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
int keta(int n){
  int ans=0;
  while(n>0){
    ans++;
    n/=10;
  }
  return ans;
}
int main() {
  int n;
  cin>>n;
  int ans=0;
  for(int i=1;i<=n;i++){
    int a=i/pow(10,keta(i)-1);
    int b=i%10;
    int d=n/pow(10,keta(n)-1);
    int e=n%10;
    int c=keta(n)-2;
    if(a!=0 && b!=0){
      if(a==b){
    if(a<=n) ans++;
  }
  if(10*b+a<=n) ans++;
    for(int i=1;i<=c;i++){
      if(i!=c) ans+=pow(10,i);
      else {
        if(d>b){
          ans+=pow(10,i);
        }
        else if(d==b){
          int aho=pow(10,keta(n)-1);
          int hina=n%aho;
          ans+=hina/10;
          if(e>=a) ans++;
        }
      }
    }
    }
  } 
  
  cout<<ans<<endl;          
          
}


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

int main(){
  ll N;
  ll A,B,C,D,E;
  cin >> N;
  cin >> A >> B >> C >> D >> E;
  
  ll MinMove = min({A, B, C, D, E});
  ll ans = (N + MinMove - 1) / MinMove;
  cout << ans + 4 << endl;
}
  

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

int main(){
  int n;
  cin >> n;
  int d[n];
  rep(i,n)cin >> d[i];

  sort(d,d+n);
  if(d[n/2-1]==d[n/2]){
    cout << 0 << endl;
    return 0;
  }else{
    cout << d[n/2]-d[n/2-1] << endl;
    return 0;
  }
}

Measured memory_bytes: 3988
#include <bits/stdc++.h>
using namespace std;
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;}
using Int = long long;
const char newl = '\n';

//INSERT ABOVE HERE
const Int MAX = 55;
const Int INF = 1e18;
Int dp[MAX][MAX*MAX];

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

  Int n,m,s_init;
  cin>>n>>m>>s_init;
  struct edge{
    Int to,a,b;
    edge(Int to,Int a,Int b):to(to),a(a),b(b){}
  };

  vector<vector<edge>> G(n);
  for(Int i=0;i<m;i++){
    Int u,v,a,b;
    cin>>u>>v>>a>>b;
    u--;v--;
    G[u].emplace_back(v,a,b);
    G[v].emplace_back(u,a,b);
  }

  vector<Int> cs(n),ds(n);
  for(Int i=0;i<n;i++) cin>>cs[i]>>ds[i];

  for(Int i=0;i<MAX;i++)
    for(Int j=0;j<MAX*MAX;j++)
      dp[i][j]=INF;

  using T = tuple<Int, Int, Int>;
  priority_queue<T, vector<T>, greater<T>> pq;

  auto push=[&](Int v,Int s,Int t){
    chmin(s,MAX*MAX-1);
    if(s<0) return;
    if(dp[v][s]<=t) return;
    dp[v][s]=t;
    pq.emplace(t,v,s);
  };
  push(0,s_init,0);

  while(!pq.empty()){
    auto [t,v,s]=pq.top();pq.pop();
    if(dp[v][s]<t) continue;
    // exchange
    {
      Int to=v;
      Int ns=s+cs[v];
      Int nt=t+ds[v];
      push(to,ns,nt);
    }
    for(auto [to, a, b]:G[v]){
      Int ns=s-a;
      Int nt=t+b;
      push(to,ns,nt);
    }
  }

  vector<Int> ans(n,INF);
  for(Int i=0;i<n;i++)
    for(Int j=0;j<MAX*MAX;j++)
      chmin(ans[i],dp[i][j]);

  for(Int i=1;i<n;i++) cout<<ans[i]<<newl;
  return 0;
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int A, B;
	cin >> A >> B;

	cout << ((A*B) % 2 == 1 ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 256
import re
s = input()
a = re.search(r'\d{4}/(\d)(\d)/\d{2}', s)
if a.group(1) == '0' and (a.group(2) == '1' or a.group(2) == '2' or a.group(2) == '3' or a.group(2) == '4'):
    print('Heisei')
else:
    print('TBD')

Measured memory_bytes: 9860
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {

	LL n, m; cin >> n >> m;
	vector<priority_queue<LL>> tb(100010);

	//値、日時
	priority_queue<pair<LL,LL>> tmp;



	for (int i = 0; i < n; i++) {
		LL a, b; cin >> a >> b;

		tb[a].push(b);
	}

	LL ans = 0;

	
	for (LL i = 1; i < m + 1; i++) {


		if (tb[i].empty() && tmp.empty())continue;
		if (tb[i].empty() && !tmp.empty()) {
			ans += tmp.top().first;
			//暫定キューから取り出す
			LL num = tmp.top().second;
			//もとのキューからも取り出す
			tb[num].pop();
			tmp.pop();

			if (!tb[num].empty()) {
				tmp.push({ tb[num].top(),num });
			}
			
			continue;
		}

		if (tmp.empty()) {
			ans += tb[i].top();
			tb[i].pop();

			if (!tb[i].empty()) {
				tmp.push({ tb[i].top(), i });
			}

			continue;
		}

		
		LL today = tb[i].top();

		LL now = tmp.top().first;

		if (now > today) {
			//暫定キューから取り出す
			LL num = tmp.top().second;
			//もとのキューからも取り出す
			tb[num].pop();

			ans += now;
			tmp.pop();

			if (!tb[num].empty()) {
				tmp.push({ tb[num].top(),num });
			}

			
			pair<int, int> p;
			p.first = tb[i].top();
			p.second = i;

			tmp.push(p);

		}
		else if (now <= today) {
			ans += today;

			tb[i].pop();

			if (!tb[i].empty()) {
				tmp.push({ tb[i].top(),i });
			}
		}
		
	}

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

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
using P = pair<int,int>;
const int MOD = 1000000007;
#define inf 1e9

int main() {
    int m;
    cin>>m;
    cout<<48-m<<endl;
} 


Measured memory_bytes: 256
n,m = map(int,input().split())
a = []
d = [0]*m
for _ in range(n):
    tmp = list(map(int,input().split()))
    a.append(tmp[1:])
for b in a:
    for c in b:
        d[c-1] += 1
cnt = 0
for p in d:
    if p == n:
        cnt+=1
print(cnt)

Measured memory_bytes: 3064