akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

const int nmax=50;
int n,m,v[nmax+5][nmax+5],dp[nmax+5][nmax+5],NR;
struct data
{
    int r,c;
};
queue<data>q;
int dr[]={-1,0,1,0};
int dc[]={0,1,0,-1};
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        cin.get();
        for(int j=1;j<=m;j++)
        {
            char ch;
            ch=cin.get();
            if(ch=='#')
                v[i][j]=1;
            else
                NR++;
            dp[i][j]=-1;
        }
    }
    dp[1][1]=1;
    q.push({1,1});
    while(!q.empty())
    {
        int r=q.front().r,c=q.front().c;
        q.pop();
        for(int i=0;i<4;i++)
        {
            int rn,cn;
            rn=r+dr[i];
            cn=c+dc[i];
            if(1<=rn and 1<=cn and rn<=n and cn<=m and dp[rn][cn]==-1 and v[rn][cn]==0)
            {
                dp[rn][cn]=dp[r][c]+1;
                q.push({rn,cn});
            }
        }
    }
    if(dp[n][m]==-1)
        cout<<-1;
    else
        cout<<NR-dp[n][m];
    return 0;
}
/**
**/


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

using namespace std;



int main(){

  int n,d;
  cin >> n >> d;
  if(n % (2*d+1) == 0){
    cout << n/(2*d+1) << endl;
  }
  else{
    cout << n/(2*d+1) + 1 << endl;
  }
  return 0;

}


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

using namespace std;
using ll = long long;
using IP = pair<int, int>;

const ll linf = 1LL << 62;
const int inf = 99999999;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };
const ll atcoder = 1e9 + 7;

#define Endl endl
#define mp make_pair
#define all(v) v.begin(),v.end()
#define pb push_back
#define pr(x) cout << x << endl
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define rep(i,n) for(int i= 0;i<n;i++)

template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

ll gcd(ll a, ll b) {//最大公約数
	if (a < b)swap(a, b);
	if (a%b == 0)return b;
	else gcd(b, a%b);
}

ll lcm(ll a, ll b) {//最小公倍数
	if (a < b)swap(a, b);
	return (a / gcd(a, b))*b;
}

int main() {

	char c[100][100];
	int h, w;
	cin >> h >> w;
	int sh = 0;
	rep(i, h) {
		rep(j, w) {
			cin >> c[i][j];
			if (c[i][j] == '#')sh++;
		}
	}

	int cnt = 0;
	queue<pair<int, int>> q;
	q.push(mp(0, 0));
	int dp[110][110] = {0};

	while (!q.empty()) {
		pair<int,int> yx = q.front();
		q.pop();
		if (yx.first == h - 1 && yx.second == w - 1)break;

		rep(i, 4) {
			int ny = yx.first + dy[i];
			int nx = yx.second + dx[i];
			if (ny < 0 || ny >= h || nx < 0 || nx >= w)continue;
			if (dp[ny][nx] != 0)continue;
			if (c[ny][nx] == '.') {
				c[yx.first][yx.second] = '#';
				dp[ny][nx] = dp[yx.first][yx.second] + 1;
				q.push(mp(ny, nx));
			}
		}
	}

	if (dp[h - 1][w - 1] == 0)pr(-1);
	else pr(h*w-dp[h - 1][w - 1] -sh - 1);

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1<<30;
#define vec2(a,y,x) vector<vector<int>> a(y,vector<int>(x,0))
#define vec1(a,n) vector<int> a(n);rep(i,n)cin>>a[i]
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};

bool chmax(int &a,int b){if(a<b){a=b;return 0;}return 1;}
bool chmin(int &a,int b){if(a>b){a=b;return 0;}return 1;}

int main(){
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int n,w;
  cin>>n>>w;
  vector<int> p(n),v(n);
  rep(i,n) cin>>p[i]>>v[i];
  
  vec2(dp,n+1,100003); //dp[i][j]:=i個目の荷物までで価値jの重さの最小値、無理ならw+2
  rep(i,n+1)rep(j,100003) dp[i][j]=w+2;
  rep(i,n+1) dp[i][0]=0;
  
  REP(i,1,n+1)rep(j,100003){
  	if(v[i-1]+j<100003) chmin(dp[i][j+v[i-1]],dp[i-1][j]+p[i-1]);
    chmin(dp[i][j],dp[i-1][j]);
  }
  
  int ans=0;
  rep(i,100003){
    if(dp[n][100002-i]<=w) {ans=100002-i;break;}
  }
  //cout<<dp[3][90]<<endl;
  cout<<ans<<'\n';
}

Measured memory_bytes: 41848
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int N;
  string S;
  cin>>N>>S;
  int cnt1=0,cnt2=0;
  for(int i=0;i<N;i++){
    if(S[i]==')'){
      if(cnt1==0)
        cnt2++;
      else
        cnt1--;
    }else
      cnt1++;
  }
  for(int i=0;i<cnt2;i++)
    cout<<'(';
  cout<<S;
  for(int i=0;i<cnt1;i++)
    cout<<')';
  cout<<endl;
}

Measured memory_bytes: 3596
m=f=r=0
while 1:
    m,f,r=map(int,input().split())
    x=m+f
    if m==f==r==-1:break
    elif m==-1 or f==-1 or x<30:print('F')
    elif x>=80:print('A')
    elif 65<=x<80:print('B')
    elif 50<=x<65 or r>=50:print('C')
    else:print('D')
    

Measured memory_bytes: 7712
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B,L;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MOD = 998244353;
const ll MAX_N = 100010;
typedef pair<ll,ll> P;

int main() {
    cin>>N>>M;
    vector<P> alb(N);
    rep(i,N){
        cin>>A>>B;
        alb[i] = {A,B};
    }
    sort(alb.begin(),alb.end());
    priority_queue<ll> pque;
    ll index = 0, ans = 0;
    reps(i,1,M+1){
        while(alb[index].fi <= i && index < N){
            pque.push(alb[index].se);
            ++index;
            if(index == N) break;
        }
        if(!pque.empty()){
            ans += pque.top();
            pque.pop();
        }
    }
    cout<<ans<<endl;
}


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


void d_m_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input_dp.txt", "r", stdin);
	freopen("output_dp.txt", "w", stdout);
#endif
}

int knapsack1(int *weight, int *value, int W, int n)
{
	int dp[n + 1][W + 1];

	for (int i = 0; i <= n; i++)
	{
		for (int w = 0; w <= W; w++)
		{
			if (i == 0 or w == 0)
				dp[i][w] = 0;
			else if (w - weight[i - 1] >= 0)
				dp[i][w] = max(dp[i - 1][w], dp[i - 1][w - weight[i - 1]] + value[i - 1]);
			else dp[i][w] = dp[i - 1][w];
		}
	}

	return dp[n][W];
}

int32_t main()
{
	d_m_c();

	int n, W;
	cin >> n >> W;

	int w[n], v[n];

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

	cout << knapsack1(w, v, W, n) << endl;

	return 0;
}

Measured memory_bytes: 82400
N, *A = map(int, open(0).read().split())

x = sorted([v for v in A if v >= 0])
y = sorted([v for v in A if v < 0], reverse=True)

ans = []
if len(y) == 0:
    cnt = x[0]
    for v in x[1:-1]:
        ans.append((cnt, v))
        cnt -= v
    ans.append((x[-1], cnt))
    print(x[-1] - cnt)
elif len(x) == 0:
    cnt = y[0]
    for v in y[1:]:
        ans.append((cnt, v))
        cnt -= v
    print(cnt)
else:
    for v in x[:-1]:
        ans.append((y[0], v))
        y[0] -= v
        
    cnt = x[-1]
    for v in y:
        ans.append((cnt, v))
        cnt -= v
    print(cnt)
    
for v in ans:
    print(*v)

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

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

  int n;
  cin >> n;
  vector<int> xs(n);
  int count = 0;
  for (int i = 0; i < n; i++) {
    cin >> xs[i];
    if (i % 2 == 0 && xs[i] % 2 == 1) {
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const ll Mod = 998244353;
const int Maxn = 1e2 + 10;
const ll Inf = 2242545357980376863LL;
const ll Log = 30;

ll n, m, a[Maxn][Maxn];

ll match[Maxn];

vector<ll> G[Maxn];

ll mk[Maxn];
bool DFS(ll u){
	if(mk[u]) return false;
	mk[u] = 1;
	for(auto adj : G[u]){
		if((match[adj] == -1) || DFS(match[adj])){
			match[adj] = u;
			return true;
		}
	}
	return false;
}

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) cin >> a[i][j];
	
	for(int k = m; k > 1; k--){
		memset(match, -1, sizeof match);
		for(int i = 0; i < n; i++) G[i].clear();
		
		for(int i = 0; i < n; i++)
			for(int j = 0; j < k; j++)
				G[i].pb( (a[i][j] - 1) / m );
		for(int i = 0; i < n; i++){
			memset(mk, 0, sizeof mk);
			DFS(i);
		}
		for(int i = 0; i < n; i++)
			for(int j = 0; j < k - 1; j++)
				if( ((a[match[i]][j] - 1) / m) == i)
					swap(a[match[i]][j], a[match[i]][k - 1]);
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++) cout << a[i][j] << ' ';
		cout << '\n';
	}
	for(int j = 0; j < m; j++)
		for(int k = 0; k < n; k++)
			for(int i = 0; i < n - 1; i++)
				if(a[i][j] > a[i + 1][j])
					swap(a[i][j], a[i + 1][j]);
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++) cout << a[i][j] << ' ';
		cout << '\n';
	}
	return 0;
}

/*

                                 ____              ,----..               ,----..
   ,---,                       ,'  , `.           /   /   \             /   /   \
  '  .' \                   ,-+-,.' _ |          /   .     :           /   .     :
 /  ;    '.              ,-+-. ;   , ||         .   /   ;.  \         .   /   ;.  \
:  :       \            ,--.'|'   |  ;|        .   ;   /  ` ;        .   ;   /  ` ;
:  |   /\   \          |   |  ,', |  ':        ;   |  ; \ ; |        ;   |  ; \ ; |
|  :  ' ;.   :         |   | /  | |  ||        |   :  | ; | '        |   :  | ; | '
|  |  ;/  \   \        '   | :  | :  |,        .   |  ' ' ' :        .   |  ' ' ' :
'  :  | \  \ ,'        ;   . |  ; |--'         '   ;  \; /  |        '   ;  \; /  |
|  |  '  '--'          |   : |  | ,             \   \  ',  /          \   \  ',  /
|  :  :                |   : '  |/               ;   :    /            ;   :    /
|  | ,'                ;   | |`-'                 \   \ .'              \   \ .'
`--''                  |   ;/                      `---`                 `---`
                       '---'

*/

Measured memory_bytes: 512
/*
         ██╗ ██████╗ ██╗███╗   ██╗    ██╗   ██╗███████╗
         ██║██╔═══██╗██║████╗  ██║    ██║   ██║██╔════╝
         ██║██║   ██║██║██╔██╗ ██║    ██║   ██║███████╗
    ██   ██║██║   ██║██║██║╚██╗██║    ██║   ██║╚════██║
    ╚█████╔╝╚██████╔╝██║██║ ╚████║    ╚██████╔╝███████║
     ╚════╝  ╚═════╝ ╚═╝╚═╝  ╚═══╝     ╚═════╝ ╚══════╝
*/
//password:+BdCHpO8dQvpo5fnV3/u
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const int maxn = 5e5 + 5;
const int inf = 0x3f3f3f3f;

vector<int> z_function(string s) {
  int n = (int)s.length();
  vector<int> z(n);
  for (int i = 1, l = 0, r = 0; i < n; ++i) {
    if (i <= r) z[i] = min(r - i + 1, z[i - l]);
    while (i + z[i] < n && s[z[i]] == s[i + z[i]]) ++z[i];
    if (i + z[i] - 1 > r) l = i, r = i + z[i] - 1;
  }
  return z;
}

int main() {
  int n;string s;
  cin>>n>>s;
  
  int ans=0;
  for(int i=0;i<s.size();i++)
  {
    vector<int> fuck=z_function(s.substr(i));
    for(int i=0;i<fuck.size();i++)
    {
      ans=max(ans,min(i,fuck[i]));
    }
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 256
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
using namespace std;
#define ll           long long
#define all(v)       (v).begin() , (v).end()
#define vi           vector <ll>
#define vii          vector <pair<ll,ll>>
#define ii           pair<ll,ll>
#define sz(v)	     ((int)((v).size()))
#define lp(i,a,b)    for(int i=a;i<b;i++)
#define pb           push_back
#define pf           push_front
#define F            first
#define S            second
#define endl         "\n"
#define IOS          ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const double PI = 3.14159265358979323846;
const ll inf=2e9,MOD=1e9+7,MAX=1e4+1;

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    IOS;
    int n;
    cin>>n;
    int a[n];
    lp(i,0,n)
        cin>>a[i];
    ll x=0;
    lp(i,1,n)
        x^=(a[0]^a[i]);
    lp(i,0,n)
        cout<<(x^a[i])<<" ";

}

Measured memory_bytes: 4412
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int main()
{
    ft
    int t,i,j,n,m,l,r,x;
    string s;
    map<int,int>mp;
    cin>>s;
    reverse(s.begin(),s.end());
    l=r=0;
    x=1;
    mp[0]=1;
    for(char c:s)
    {
        r=((c-48)*x+r)%2019;
        l+=mp[r];
        mp[r]++;
        x=(x*10)%2019;
    }
    cout<<l<<"\n";
    return 0;
}

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

using namespace std;

#define int long long

map <pair <int, int>, int> ed;
vector <int> ans;
vector <vector <int> > g;

void dfs(int v, int p, int col) {
    int stc = 1;
    if (col == stc) ++stc;
    for (auto u : g[v]) {
        if (u != p) {
            ans[ed[{min(v, u), max(v, u)}]] = stc;
            dfs(u, v, stc);
            ++stc;
            if (stc == col) ++stc;
        }
    }
}

void solve() {
    int n;
    cin >> n;
    g.resize(n);
    ans.resize(n - 1);
    for (int i = 0; i < n - 1; ++i) {
        int v, u;
        cin >> v >> u;
        --v;
        --u;
        if (v > u) swap(v, u);
        g[v].push_back(u);
        g[u].push_back(v);
        ed[{v, u}] = i;
    }
    int st = 0;
    for (int i = 1; i < n; ++i) if (g[st].size() < g[i].size()) st = i;
    cout << g[st].size() << '\n';
    dfs(st, -1, 0);
    for (int i = 0; i < n - 1; ++i) cout << ans[i] << '\n';
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 14976
N=int(input())
a=[int(i) for i in input().split()]

min_a=min(a)
max_a=max(a)
Cost=[]
for i in range(max_a - min_a+1):
    cost=0
    for k in range(N):
        cost+=(a[k] - (min_a + i))**2
    Cost.append(cost)
print(min(Cost))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <sys/time.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; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }

// d 桁のルンルン数の集合から、d+1 桁のルンルン数の集合を求める
vector<long long> calc_next(const vector<long long> &ar) {
    vector<long long> res;
    for (auto val : ar) {
        for (int j = -1; j <= 1; ++j) {
            int add = (val % 10) + j;
            if (add >= 0 && add <= 9) res.push_back(val * 10 + add);
        }
    }
    return res;
}

int main() {
    int K;
    cin >> K;
    vector<long long> all; // 全列挙したもの

    // 一桁の場合
    vector<long long> cur;
    for (int v = 1; v < 10; ++v) cur.push_back(v), all.push_back(v);

    // 10 桁まで
    for (int d = 1; d < 10; ++d) {
        // 次の桁を列挙
        cur = calc_next(cur);

        // all に格納
        for (auto val : cur) all.push_back(val);
    }

    // K 番目
    cout << all[K-1] << endl;
}


Measured memory_bytes: 3440
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i < b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = INT_MAX / 2;
const ll  inf = LLONG_MAX / 2;
const int mod = 1000000007;
const int MAX_N = 101010;
const long double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

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

	bool odd_a = a % 2;
	bool odd_b = b % 2;

	if (odd_a == odd_b) {
		out((b - a) / 2);
	}
	else {
		out(min(a - 1, n - b) + 1 + (b - a - 1) / 2);
	}

	return 0;
}

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

def is_include(t: str, S: str) -> bool:
    tlis = list(t)
    slis = list(S)
    pointer = 0
    len_t = len(tlis)
    for s in slis:
        if s == tlis[pointer]:
            pointer += 1
        if pointer == len_t:
            return True
    return False

cnt = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            t = str(i)+str(j)+str(k)
            if is_include(t, S):
                cnt += 1

print(cnt)


Measured memory_bytes: 9452
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int v[n],c[n],sum=0;
	for(int i=0;i<n;i++){
		cin>>v[i];
	}
	for(int i=0;i<n;i++){
		cin>>c[i];
	}
	for(int i=0;i<n;i++){
		if(v[i]-c[i]>0){
			sum+=v[i]-c[i];
		}
	}
	cout<<sum;
	return 0;
}

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

int main()
{
  int x1;int x2;int x3;int x4;int x5;
  cin>>x1>>x2>>x3>>x4>>x5;
  
  if(x1==0)
    cout<<1<<endl;
  else if(x2==0)
    cout<<2<<endl;
  else if(x3==0)
    cout<<3<<endl;
  else if(x4==0)
    cout<<4<<endl;
  else
    cout<<5<<endl;
  
  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define FI first
#define SE second
#define PB push_back
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define co(i) cout<<(i)<<endl
#define fcout cout<<fixed<<setprecision(10)
#define uni(i) i.erase(unique(i.begin(), i.end()), i.end());
#define all(i) i.begin(),i.end()
#define pint pair<int, int>
#define vint vector<int>
using namespace std;

const int INF=1e9+7;
const int MOD=1e9+7;
//const int MOD=998244353;

int main(){
	int n; cin>>n;
	int p[25]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
	int q[25]={};
	FOR(i,0,25){
		int pn=p[i];
		FOR(j,0,20){
			q[i]+=n/pn;
			pn*=p[i];
		}
	}
	int ans=0;
	if(q[0]>=74) ans++;
	int a=0,b=0;
	while(q[a]>=2) a++;
	while(q[b]>=24) b++;
	ans+=(a-1)*b;
	a=0; b=0;
	while(q[a]>=4) a++;
	while(q[b]>=14) b++;
	ans+=(a-1)*b;
	a=0; b=0;
	while(q[a]>=2) a++;
	while(q[b]>=4) b++;
	ans+=(a-2)*(b-1)*b/2;
	co(ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ll long long
#define ld long double
#define PB push_back
#define lc 2 * v
#define rc 2 * v + 1
#define mid (s + e) / 2
#define pii pair <int , int>
#define pll pair <long long , long long>
#define FAST ios::sync_with_stdio(false);cin.tie(0);
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

const ll maxn = 2e5 + 10 , N = 60000 + 20 , mod = 1e9 + 7 , INF = 1e9 , lg = 32;

ll a[maxn];

int main() {
    FAST
    int n;
    cin >> n;
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            for (int k = j + 1; k < n; ++k) {
                if(a[i] + a[j] > a[k] && a[i] + a[k] > a[j] && a[j] + a[k] > a[i]) {
                    if(a[i] != a[j] && a[j] != a[k] && a[i] != a[k])
                        ans++;
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
//#include <unistd.h>
//#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const ld pi = 3.14159265358;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}

ll fac[510000], finv[510000], inv[510000];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < 510000; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin >> N;
    vector<ll> num(N);
    rep(i,N)cin >> num[i];
    ll cnt = 1;
    bool up = false;
    bool down = false;
    for(ll i = 1;i < N;i++){
        if(!up && !down){
            if(num[i - 1] < num[i])up = true;
            else if(num[i - 1] > num[i])down = true;
        }
        else if(up && !down){
            if(num[i - 1] > num[i]){
                up = false;
                cnt++;
            }
        }
        else if(!up && down){
            if(num[i - 1] < num[i]){
                down = false;
                cnt++;
            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3968
package main

import "fmt"

func printArray(arr []int) {
	for i := 0; i < len(arr); i++ {
		fmt.Print(arr[i])
		if i == len(arr)-1 {
			fmt.Println()
		} else {
			fmt.Print(" ")
		}
	}
}

func InsertionSort(arr []int) []int {
	for i, v := range arr {
		j := i - 1
		for j >= 0 && arr[j] > v {
			arr[j+1] = arr[j]
			j--
		}
		arr[j+1] = v
		printArray(arr)
	}
	return arr
}

func main() {
	var n int
	fmt.Scan(&n)
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&arr[i])
	}
	InsertionSort(arr)
}



Measured memory_bytes: 1176
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      string s;
      cin >> s;
      if(s == "Sunny") {
        cout << "Cloudy" << endl;
      }else if(s == "Cloudy") {
        cout << "Rainy" << endl;
      }else if(s == "Rainy") {
        cout << "Sunny" << endl;
      }
      return 0;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
const int INF=1e9,MOD=1e9+7,ohara=1e6;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrrep(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt,ans,a[ohara],b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);
      
    cin>>n;
    rep(i,n)cin>>a[i];
    sort(a,a+n);
    a[n-1]/=2;
    rep(i,n)ans+=a[i];
    Cout(ans);
    return 0;
}


Measured memory_bytes: 256
use io::*;

fn main() {
    let input = read_string();
    let mut sc = Scanner::new(&input);
    let a: usize = sc.next();
    let b: usize = sc.next();
    println!("{}",if a * b % 2 == 1 {"Yes"} else {"No"});
}

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }

        pub fn next_mat<T: FromStr>(&mut self, w: usize, h: usize) -> Vec<Vec<T>> {
            (0..h).map(|_| self.next_vec(w)).collect()
        }

        pub fn next_vec_char(&mut self) -> Vec<char> {
            self.next::<String>().chars().collect()
        }

        pub fn next_mat_char(&mut self, n: usize) -> Vec<Vec<char>> {
            (0..n).map(|_| self.next_vec_char()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


Measured memory_bytes: 4352
//define DEBUG for debug
//#define DEBUG

#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair 
#define pb push_back
#define MAX 100000+100
#define MOD 1000000007
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef DEBUG
	freopen("i.txt","r",stdin);
	freopen("o.txt","w",stdout);
#endif
	
	long long int a,b,c;cin >> a >> b >> c;
	if(a >= c){
		cout << a-c << ' ' << b;
	}else{
		c -= a;
		if(c >= b)
			cout << "0 0";
		else
			cout << "0 " << b-c;
	}

	return 0;
}

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

using namespace std;

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

    int mn = INT_MAX;
    for(int i = 0; i < n; i++) {
        cin >> vec[i];
        mn = min(mn, vec[i]);
    }

    int cnt = 0;
    int sum = 0;
    int stop = k;
    bool ok = false;
    for(int i = 0; i < n; i++) {
        cnt++;
        if(vec[i] == mn) {
            if(ok) stop = cnt + k - 1;
            else ok = true;
        }
        if(cnt == stop) {
            if(ok) sum += ceil(cnt * 1.0 / k), cnt = 1, stop = k;
            else sum++, cnt = 0, stop = k, i--;
        }
    }

    if(cnt > 1) sum++;

    cout << sum;
}

Measured memory_bytes: 640
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{

    int x,y;
    cin>>x>>y;
    if(y&1)cout<<"No";
    else{
        int c= 4*x-y;
        int t =y-2*x;
        if(c%2==0&&t%2==0&&c>=0&&t>=0){
            cout<<"Yes";
        }
        else{
            cout<<"No";
        }



    }

    return 0;
}


Measured memory_bytes: 3636
Scanf.scanf "%d %d" @@ fun n t ->
Array.init n (fun _ -> Scanf.scanf " %d %d" (fun x y -> if y <= t then Some x else None))
|> Array.fold_left (fun x y ->
  match x, y with
  | None, _ -> y
  | Some i, Some j when i > j -> Some j
  | _, _ -> x) None
|> function
  | None -> print_endline "TLE"
  | Some i -> Printf.printf "%d\n" i

Measured memory_bytes: 2432
#include<stdio.h>
 
int main()
{
  int A[100];
  int N;
  int key;
  int i, j, k;
 
  //Read N and keys
  scanf("%d", &N);
  for(i=0; i<N; i++)scanf("%d",&A[i]);
 
  //Sort
  for(i=0; i<N; i++){
    key=A[i];
    j=i-1;
 
      //if A[j]>key, change A[j] to A[j+1]
    while(j>=0 && A[j]>=key){
      A[j+1]=A[j];
      j=j-1;
      A[j+1]=key;
    }
      //print
    for(k=0; k<N; k++){
      printf("%d", A[k]);
      if(k<N-1)printf(" ");
    }
    printf("\n");
  } 
  return 0;
}

Measured memory_bytes: 2676
//#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
#include<cstring>
#include<sstream>
#include <iomanip>

using namespace std;

typedef long long ll ;
typedef double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector< pair<int,int> > vii;
const double pi = 2*acos(0) ;

#define pf		  	printf
#define sf			  scanf
#define pb(a)         push_back(a)
#define mp			make_pair
#define fi			 first
#define se			 second
#define for0(i,n)        for(int i=0;i<n;i++)
#define for1(i,n)        for(int i=1;i<=n;i++)
#define forab(i,a,b)       for(int i=a;i<=b;i++)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
#define abs(x)		fabs(x)
#define pcase(z,x)    cout<<"Case "<<z<<": "<<x<<"\n"

int main()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	bool ck=1;
	if(n%2==0){
		for(int i=0 ; i<n/2 ; i++){
			if(s[i]!=s[n/2+i]){
				ck=0;
				break;
				}
			}
		}
	else ck=0;
	pf(ck? "Yes\n" : "No\n");
	return 0;
}

Measured memory_bytes: 256
h, w, k = map(int, input().strip().split())
matrix = [input() for _ in range(h)]

ans=0
for row in range(2**h):
    for col in range(2**w):
        cnt=0
        for i in range(h):
            for j in range(w):
                if (row>>i)&1 and (col>>j)&1 and matrix[i][j]=="#":
                    cnt+=1
        if cnt==k:
            ans+=1
            
print(ans)

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

int main() {
  int n,ans=0;
  string s;
  cin >> n >> s;
  for(int i=0; i<n-2; i++) {
    if(s[i] == 'A') {
      if(s[i+1] == 'B') {
        if(s[i+2] == 'C') ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
}

int main(){
    ll d,t,s;cin >> d >> t >> s;
    if(d<=s*t)cout << "Yes" <<endl;
    else cout << "No" <<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
const int N = 100005, M = 1000000007;

int n;
vector<int> a[N];

int dp[N][2];
void dfs(int x, int p)
{
    dp[x][0] = 1;
    dp[x][1] = 1;
    for (int i = 0; i < a[x].size(); ++i)
    {
        int h = a[x][i];
        if (h == p)
            continue;
        dfs(h, x);
        dp[x][0] = (dp[x][0] * 1LL * (dp[h][0] + dp[h][1])) % M;
        dp[x][1] = (dp[x][1] * 1LL * dp[h][0]) % M;
    }
}

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n - 1; ++i)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        a[x].push_back(y);
        a[y].push_back(x);
    }
    dfs(1, 1);
    cout << (dp[1][1] + dp[1][0]) % M << endl;
    return 0;
}


Measured memory_bytes: 13440
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        String s = sc.next();
        
        int min = 1000;
        for(int i = 0; i < s.length()-2; i++){
            int x = Integer.valueOf(s.substring(i, i+3));
            if(Math.abs(x-753) < min){
                min = Math.abs(x-753);
            }
        }
        
        System.out.println(min);
    }
}

Measured memory_bytes: 21716
/*input
1 2
10 5
100 20
*/
fn main() {
    let mut input: String;
    loop {
        input = format!("");
        match std::io::stdin().read_line(&mut input) {
            Ok(0) => {
                break;
            }
            Ok(_) => {
                println!(
                    "{}",
                    input
                        .trim()
                        .split_whitespace()
                        .fold(0, |x, y| x + y.parse::<i32>().unwrap())
                );
            }
            Err(_) => {}
        };
    }
}



Measured memory_bytes: 5028
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;a++)
#define rl(a,b,c) for(int a=b;a>=c;a--)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB(a) push_back(a)
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int main(){
	ios::sync_with_stdio(false);
	int p,q,r;
	cin>>p>>q>>r;
	int maxi=max(max(p,q),r);
	cout<<p+q+r-maxi;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, k;
    cin >> a >> b >> k;
    if(b - a > 2 * k){
        rep(i, 0, k){
            cout << a + i << endl;
        }
        rep(i, 0, k){
            cout << b - k + i + 1 << endl;
        }
    }else{
        rep(i, a, b + 1){
            if(i < a + k || b - k < i){
                cout << i << endl;
            }
        }
    }
}

Measured memory_bytes: 256
N = int(input())
AList = list(map(int, input().split()))
RList = []
tmp = 0
tmppoint = 0
for i in range(1, len(AList)):
    tmp = tmp ^ AList[i]

RList.append(tmp)
for p in range(1, len(AList)):
    tmp = tmp ^ AList[tmppoint]
    tmp = tmp ^ AList[p]
    tmppoint = p
    
    RList.append(tmp)

for i in range(len(RList)):
    print(RList[i], end=' ')


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

int main()
{
    int n;
    string s1, s2;
    cin >> n >> s1 >> s2;

    vector<bool> f;
    for (int i = 0; i < s1.size(); i++) {
        if (s1[i] == s2[i]) f.push_back(true);
        else f.push_back(false), i++;
    }

    long long ans = f[0] ? 3 : 6;
    for (int i = 1; i < f.size(); i++) {
        if (f[i]) {
            if (f[i - 1]) ans *= 2;
        }
        else {
            if (f[i - 1]) ans *= 2;
            else ans *= 3;
        }
        ans %= 1000000007;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <stdlib.h>
#include <fstream>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <stack>
#include <assert.h>
#include <unordered_map>
#include <unordered_set>
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

bool test = true;
#define log(x) cout << "#x" << " : " << x << "\n";

int main()
{
    FIO;
    string s;
    string t;
    cin >> s >> t;
    int cnt = 0;
    for(int i=0; i<s.length(); i++) {
        cnt = cnt + (s[i] != t[i]);
    }
    cout << cnt << "\n";
}



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

int main() {
  int N;
  cin >> N;
  vector<int64_t> data(87);
  data.at(0) = 2;
  data.at(1) = 1;
  
  for(int x=2;x<87;x++){
	data.at(x) = data.at(x-1) + data.at(x-2);
  }
  
  cout << data.at(N) << endl;  
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
main() {
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    lli N;
    cin >> N;
    lli output = ((N - 1) * N) / 2;
    cout << output << "\n";
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define INF 1000000000000
#define MOD 1000000007
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3)                                                 \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
         << x3 << endl
#define debug_4(x1, x2, x3, x4)                                             \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
         << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5)                                         \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
         << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

using namespace std;
using ll = long long;

int main() {
    int n;
    cin >> n;
    map<string, int> cnt;
    cnt["AC"] = 0;
    cnt["TLE"] = 0;
    cnt["WA"] = 0;
    cnt["RE"] = 0;
    rep(i, n) {
        string judge;
        cin >> judge;
        cnt[judge]++;
    }
    cout << "AC x " << cnt["AC"] << endl;
    cout << "WA x " << cnt["WA"] << endl;
    cout << "TLE x " << cnt["TLE"] << endl;
    cout << "RE x " << cnt["RE"] << endl;
    // for (auto i = cnt.begin(); i != cnt.end(); ++i) {
    //     std::cout << i->first << " x " << i->second << "\n";
    // }
    return 0;
}

Measured memory_bytes: 3236
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int N;
int ans = 0;
vector<int> p;
vector<vector<int>> nodes;

// pos : 次に決める要素の場所
// mask : 決まっていない値の集合(bit)
void dfs(int pos, int mask)
{
	//順列が一つ見つかった場合
	if (pos == N)
	{
		// 始めの頂点から始まっていない場合終了
		if (p[0] != 0)
			return;

		for (int i = 0;i < N - 1;i++)
		{
			// 道が無い場合終了
			if (nodes[p[i]][p[i + 1]] == 0)
				return;
		}

		// 条件を満たしている場合
		ans++;

		return;
	}

	for (int i = 0;i < N;i++)
	{
		//残りの順列(mask)に i があるかどうか
		if (mask & (1 << i))
		{
			// 次の要素をiにする
			p[pos] = i;

			// 決まった要素をmaskから取り除いて次を調べる
			dfs(pos + 1, (mask ^ (1 << i)));
		}
	}
}

int main()
{
	int M;
	cin >> N >> M;
	p.resize(N);
	nodes.resize(N);

	for (int i = 0;i < N;i++)
		nodes[i].resize(N, 0);
	
	for (int i = 0;i < M;i++)
	{
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		nodes[a][b] = 1;
		nodes[b][a] = 1;
	}


	dfs(0, (1 << N) - 1);

	cout << ans << endl;

	return 0;
}


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

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

using namespace std;
using lint=long long;

const lint INF=1LL<<61;

int main(){
	int n; scanf("%d",&n);
	vector<int> a(n);
	rep(i,n) scanf("%d",&a[i]), a[i]--;

	vector<lint> cnt(n);
	rep(i,n) cnt[a[i]]++;

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

	vector<int> next(n+1,n);
	for(int i=n-2;i>=0;i--){
		if(cnt[i]<cnt[i+1]) next[i]=i+1;
		else next[i]=next[i+1];
	}

	printf("%d\n",n);

	lint sum=0;
	rep(i,n-1) sum+=cnt[i];
	int i;
	for(i=1;i<n;i++){
//printf("i=%d, sum=%lld\n",i,sum);
		lint ans=0;
		if(sum<=cnt[n-i]){
			ans=sum;
		}
		else{
			lint tmp=sum;
			lint last=0;
			int pos=n-i,j=1;
			while(pos<n && tmp>j*(cnt[pos]-last)){
				tmp-=j*(cnt[pos]-last);
				ans+=cnt[pos]-last;
				last=cnt[pos];
				j+=next[pos]-pos;
				pos=next[pos];
			}
			ans+=tmp/j;
		}
		printf("%lld\n",ans);
		if(ans==0){ i++; break; }
		sum-=cnt[n-i-1];
	}

	for(;i<n;i++) puts("0");

	return 0;
}


Measured memory_bytes: 5504
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>

using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(a) (a).begin(),(a).end()

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

    int ans = 800;
    for(int i =2; i < s.size(); i++){
        int score = s[i]-'0' + 10*(s[i-1]-'0') + 100*(s[i-2]-'0');
        ans = min(ans, abs(753-score));
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
n, m = [int(i) for i in input().split()]
ab = [[int(i) - 1 for i in input().split()] for _ in range(m)]

b = [[] for _ in range(n)]
for i,j in ab:
    b[j].append(i)
ans = n-1


class UnionFind:
    def __init__(self, n):
        self.parent = [-1] * n
        self.rank = [1] * n
        self.count = [1] * n

    def get_root(self, i):
        while self.parent[i] != -1:
            i = self.parent[i]
        return i

    def is_same_tree(self, i, j):
        return self.get_root(i) == self.get_root(j)

    def merge(self, i, j):
        i = self.get_root(i)
        j = self.get_root(j)
        if i == j:
            return

        if self.rank[i] > self.rank[j]:
            self.parent[j] = i
            self.rank[i] = max(self.rank[i], self.rank[j] + 1)
            self.count[i] += self.count[j]
        else:
            self.parent[i] = j
            self.rank[j] = max(self.rank[j], self.rank[i] + 1)
            self.count[j] += self.count[i]

uf = UnionFind(n)

for i in range(1,n):
    ok = True
    for j in b[i]:
        if uf.is_same_tree(i - 1, j):
            ok = False
    if ok:
        ans -= 1
        uf.merge(i, i - 1)

print(ans)


Measured memory_bytes: 34008
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

template<typename T> void chmax(T& a, T b) { a = std::max(a, b); }
template<typename T> void chmin(T& a, T b) { a = std::min(a, b); }
template<typename T> void chadd(T& a, T b) { a = a + b; }

namespace {  // 名前なし名前空間
	// gcd, lcm は C++17 でstdに標準入りしたので言語のバージョンに注意
	// 最大公約数
	ll gcd(ll a, ll b) {
		if (b == 0) return a;
		return gcd(b, a % b);
	}

	// 最小公倍数
	ll lcm(ll a, ll b) {
		return a / gcd(a, b) * b;
	}
}

int main() {

	int n;
	cin >> n;
	string s;
	cin >> s;

	// 重ならない
	// DPはヤダなぁ
	// O(n^2) いける

	int ans = 0;
	// 開始位置を全列挙
	rep(i, n - 1) {
		for(int j = n - 1; j > i; j--){
			int maxLength = min(j - i, n - j);
			if (maxLength <= ans) continue;
			int tmp = 0;
			rep(k, maxLength) {
				if (s[i + k] != s[j + k]) break;
				tmp++;
			}

			ans = max(ans, tmp);
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mid ((x + y) / 2)
#define left (ind * 2)
#define right (ind * 2 + 1)
#define mp make_pair
#define timer ((double)clock() / CLOCKS_PER_SEC)
#define endl "\n"
#define spc " "
#define d1(x) cerr<<#x<<":"<<x<<endl
#define d2(x, y) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<endl
#define d3(x, y, z) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<double, double> dd;

const int N = (int)(1e6 + 5);
const int LOG = (int)(20);

int n, m, ar[N];

int main() {
	fast_io();
	// freopen("inp.in", "r", stdin);

	cin >> n >> m;
	for(int i = 1; i <= n; i++)
		cin >> ar[i];
	for(int i = 1; i < n; i++)
		if(ar[i] + ar[i + 1] >= m) {
			cout << "Possible" << endl;
			for(int j = 1; j <= i - 1; j++)
				cout << j << endl;
			for(int j = n - 1; j >= i; j--)
				cout << j << endl;
			return 0;
		}
	cout << "Impossible" << endl;
}

Measured memory_bytes: 1280
import sys
input = sys.stdin.readline

R, C, K = map(int, input().split())
items = [[0] * (C+1) for _ in range(R+1)]
for _ in range(K):
    r, c, v = map(int, input().split())
    items[r][c] = v
dp = [[0] * 4 for _ in range(C+1)]
for i in range(1, R+1):
    ndp = [[0] * 4 for _ in range(C+1)]
    for j in range(1, C+1):
        for k in range(4):
            ndp[j][0] = max(ndp[j][0], dp[j][k])
            ndp[j][k] = max(ndp[j][k], ndp[j-1][k])
        if items[i][j]:
            for k in range(3, 0, -1):
                ndp[j][k] = max(ndp[j][k], ndp[j][k-1] + items[i][j])
    dp = ndp
print(max(dp[C]))

Measured memory_bytes: 209300
from collections import Counter

S = input()
if "N" in S and "S" not in S:
    print("No")
elif "S" in S and "N" not in S:
    print("No")
elif "E" in S and "W" not in S:
    print("No")
elif "W" in S and "E" not in S:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> num(n);
  for(int i = 0;i < n;i++) cin >> num.at(i);
  sort(num.begin(), num.end());
  int answer = 0;
  answer = num.at(n-1) - num.at(0);
  cout << answer << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define itrep(it, a) for(it = (a).begin(); it != (a).end; it++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
#define INF (1 << 30)
using namespace std;

int main(){
    int n;
    while(cin >> n,n){
        int p, d1, d2;
        vector< pair<int, int> > vpii;
        rep(i,n){
            cin >> p >> d1 >> d2;
            vpii.push_back(make_pair(d1 + d2, p));
        }
        sort(all(vpii), greater< pair<int, int> >());
        cout << vpii[0].second << ' ' <<  vpii[0].first << endl;
    }
}

Measured memory_bytes: 1328
import sys
import math
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))
out = lambda x: print('\n'.join(map(str, x)))

n = list(map(int, ins()))
print("No" if sum(n) % 9 else "Yes")

Measured memory_bytes: 10656