akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
 
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}

signed main()
{
    showoff;
    int n;
    cin >> n;
    double tot = 0;
    FOR(i,1,n+1){
    	double x;
    	cin >> x;
    	tot += 1.0l/x;
    }
    cout << fixed << setprecision(10) << 1.0l/tot;
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...   

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int H,W,h,w,nh,nw,cnt;
vector<pair<int,int>> way={{0,1},{1,0}};

bool dfs(vector<string> &maze){
    queue<pair<int,int>> q;
    vector<vector<int>> visited(H,vector<int>(W,0));
    q.push(make_pair(0,0));
    visited[0][0]=1;
    while(!q.empty()){
        auto p=q.front();q.pop();
        h=p.first;w=p.second;
        cnt=0;
        for(auto np:way){
            nh=h+np.first;nw=w+np.second;
            if(nh>H-1||nw>W-1)continue;
            if(maze[nh][nw]=='.')continue;
            cnt++;
            if(nh==H-1&&nw==W-1){visited[nh][nw]=1;continue;}
            else{
                visited[nh][nw]=1;
                q.push(make_pair(nh,nw));
            }
        }
        if(cnt==2||cnt==0)return false;
    }
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(maze[i][j]=='#'&&visited[i][j]==0)return false;
        }
    }
    return true;
}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main(){
    cin>>H>>W;
    vector<string> maze(H);
    for(int i=0;i<H;i++)cin>>maze[i];
    cout<<(dfs(maze)?"Possible":"Impossible")<<endl;
}


Measured memory_bytes: 3648
// AOJ 	2509: Sim Forest 2013
// 2018.1.3 bal4u@uu

#include <stdio.h>
#include <math.h>

char *s_time[3] = {"Day", "Night", "All"};
int id_time[3] = {0,1,2}, len_time[3] = {4,6,4};
int tr_time['Z'];

int tbl[3][2][20160];		// day/night/all, weekday/all, 20160 = 2*7*24*60

char buf[50], *bp;

int in()
{
	int n = 0;
	while (*bp >= '0') n = (n<<3) + (n<<1) + (*bp++ & 0xf);
	bp++;
	return n;
}

int main()
{
	int s, n, t, weekday, time, p, m, i, j, k, lim, cnt, ans;

	for (i = 0; i < 3; i++) bp = s_time[i], tr_time[*bp] = id_time[i];

	// imos method
	tbl[0][0][ 6*60+1] = 1, tbl[0][0][18*60+1] = -1;		// day    6:00-18:00
	tbl[1][0][18*60+1] = 1, tbl[1][0][24*60+1] = -1;		// night 18:00-24:00
	tbl[1][0][      1] = 1, tbl[1][0][ 6*60+1] = -1;		// night  0:00- 6:00
	tbl[2][0][      1] = 1, tbl[2][0][24*60+1] = -1;		// all    0:00-24:00

	for (i = 0; i < 3; i++) for (j = 0; j <= 24*60+2; j++) tbl[i][0][j+1] += tbl[i][0][j];

	// for all weekday
	for (i = 0; i < 3; i++) for (j = 0; j < 24*60; j++) for (t = 0, k = 0; k < 7; k++, t += 24*60)
		tbl[i][1][j+t] = tbl[i][0][j];
	
	while (1) {
		fgets(bp=buf, 50, stdin);
		s = in(), n = in(), t = in();
		if (*bp == 'N') break;				// None -> exit
		weekday = (*bp == 'A'),  bp += 4;
		time = tr_time[*bp],     bp += len_time[time];
		p = in(), m = in();

		lim = 1444;	if (weekday) lim = 10085;	// 10085 = 7*24*60+5
		ans = 0;
		for (i = 0; i < lim; i++) {
			cnt = 0;
			for (k = i, j = 0; j < m; j++, k += t) {
				if (tbl[time][weekday][k % 10080] && tbl[time][weekday][(k+s) % 10080]) cnt++;
			}
			if (cnt > ans) ans = cnt;
		}
		printf("%.10lf\n", 1-pow(1-1.0/p, ans*n));
	}
	return 0;
}



Measured memory_bytes: 2044
#include<iostream>
using namespace std;
int main(void)
{
    int n,m,l,sum=0;
    int k,a[35];
    cin >> n >> m;
    l=n;
    int cnt[35]={0};
    while(l--){
        cin >> k;
        for(int i=1;i<=k;i++)
            cin >> a[i];
        for(int i=1;i<=m;i++)
        {
            for(int j=1;j<=k;j++)
                if(a[j]==i)
                    cnt[i]++;
        }
    }
    for(int i=1;i<=m;i++)
        if(cnt[i]==n)
            sum++;
    cout << sum;
    return 0;
}


Measured memory_bytes: 256
# pragma comment(linker, "/STACK: 2000000")
# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n';
# define p2(v) cerr << #v << " = " << (complex < int > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vll vector < ll >
# define pii pair < int , int >
const int mod = 1e9 + 7;
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    int n,k;
    fi>>n>>k;
    if (k == 1) return puts("1") * 0;
    static int f[1 << 23];
    static int c[1 << 23];
    auto C = [&](auto n,auto k)
    {
        if (!(0 <= k && k <= n)) return 0;
        int ans = (1ll * f[n] * c[n - k]) % mod;
        ans = (1ll * ans * c[k]) % mod;
        return ans;
    };
    auto pow = [&](auto a,auto b,auto mod)
    {
        int ans = 1;
        while (b)
        {
            if (b&1)
                ans = (1ll * ans * a) % mod;
            a = (1ll * a * a) % mod;
            b /= 2;
        }
        return ans;
    };
    f[0] = c[0] = 1;
    for (int i = 1;i <= 5e6;++i)
        f[i] = (1ll * f[i - 1] * i) % mod;
    const int MAX = 5e6;
    c[MAX] = pow(f[MAX],mod - 2,mod);
    for (int i = MAX - 1;i;--i)
        c[i] = (1ll * c[i+1] * (i + 1)) % mod;
    static int dp[2005][2005];
    dp[0][0] = 1;
    for (int i = 1;i <= n;++i)
        for (int j = 0;j <= i;++j)
        {
            if (j)
                (dp[i][j] += dp[i][j-1]) %= mod;
            dp[i][j] = (dp[i][j] + 1ll * C(j * k + (i - j - 1) * (k - 1) + k - 2,k - 2) * dp[i-1][j]) % mod;
        }
    fo << (1ll * dp[n][n] * f[n]) % mod << '\n';
    cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}

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

#define ll long long
using namespace std;

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    string s,t;
    cin>>s>>t;
    int i=0,ans=0;
    while(i<s.length()){
        if(s[i]!=t[i]) ans++;
        i++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3860
#include<bits/stdc++.h>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;

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

	int all = 0;
	vector<int> A(N);
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
		all += A[i];
	}

	int one_cout = ceil((double)all / (double)(4*M));
	sort(A.begin(), A.end());

	if (A.at(N-M) >= one_cout) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1LL<<60;
const double EPS = 1e-10;
const ll mod=1000000007;
//const ll mod=998244353;
int main(void){
    set<string> SET;
    string s;
    ll k;
    cin>>s>>k;
    ll n=s.size();
    for(int i=0;i<n;i++){
        string t;
        for(int j=i;j<n&&j-i<=k;j++){
            t+=s[j];
            SET.insert(t);
        }
    }
    auto itr=SET.begin();
    for(int i=0;i<k-1;i++) itr++;
    cout<<*itr<<endl;
}

Measured memory_bytes: 5212
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;

constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

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

/*-------------------------------------------*/

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

    int n;
    cin >> n;
    using P = array<ll, 2>;
    V<P> aa, bb;
    V<ll> p(n);
    rep(i, n) {
        ll a;
        cin >> a;
        aa.push_back(P{a, i});
    }
    rep(i, n) {
        ll b;
        cin >> b;
        bb.push_back(P{b, i});
    }
    sort(ALL(aa));
    sort(ALL(bb));
    rep(i, n) if(aa[i][0] > bb[i][0]) {
        puts("No");
        return 0;
    }
    FOR(i, 1, n) if(aa[i][0] <= bb[i - 1][0]) {
        puts("Yes");
        return 0;
    }
    rep(i, n) p[aa[i][1]] = bb[i][1];
    int i = 0;
    while(n--, p[i] != 0)
        i = p[i];
    puts(n ? "Yes" : "No");

    return 0;
}

Measured memory_bytes: 5616
#include<bits/stdc++.h>
using namespace std;
int dy[5] = {0, 0, 1, 0, -1};
int dx[5] = {0, 1, 0, -1, 0};
int main() {
  int H, W;
  cin >> H >> W;
  vector<string> S(H);
  for(auto& i: S) cin >> i;
  auto ok = true;
  for(auto i=0; i<H; ++i) for(auto j=0; j<W; ++j) if(S[i][j] == '#') {
    auto cnt = 0;
    for(auto d=0; d<5; ++d) {
      auto y = i + dy[d];
      auto x = j + dx[d];
      if(y < 0 || H <= y) continue;
      if(x < 0 || W <= x) continue;
      if(S[y][x] == '#') ++cnt;
    }
    if(cnt == 1) ok = false;
  }
  cout << (ok ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/******************************************
* AUTHOR : PANDRAVISAM SHIVA SANTHOSH *
* Handle : santhosh_80 *
* INSTITUTION : IIT Palakkad *
******************************************/
#define ll long long int 
#define rep(i,a,b) for(int i=a;i<b;i++)
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define f first
#define s second

const ll mod = 1000000007;
const ll N = 1<<13;

ll n,m,x;
vector<ll> c(15);
vector<ll> a[15];


ll min_cost = INT_MAX;


void call(){
	
	for(ll i =0 ; i < (long long int)pow(2,n) ; i++){
		ll num = i;
		ll cost = 0;
		vector<ll> val(m+2,0);
		int flag=1;
		for(int j = 0; j < n; j++){
				if( (1<<j) & num){
					cost+=c[j+1];
					for(int k = 0; k < m; k++){
						val[k]+=a[j+1][k];
					}
				}
		}
		for(int k = 0 ; k < m; k++){
			if(val[k] < x)flag=0;
		}
		if(flag){
			min_cost = min (cost, min_cost);
		}
	}
	if(min_cost != INT_MAX)
	cout << min_cost;
	else cout << "-1";

}




int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> m >> x;
	for(int i = 1; i <= n; i++){
		cin >> c[i];
		for(int j = 1; j <= m ; j++){
			ll x;cin >> x;
			a[i].pb(x);
		}
	}
	call();
 	return 0;
}

Measured memory_bytes: 4100
n = int(input())
a = [int(i) for i in input().split()]
cnt_4 = 0
cnt_1 = 0
for i in range(n):
    if a[i] % 4 == 0:
        cnt_4 += 1
    elif a[i] % 2 == 0:
        pass
    else:
        cnt_1 += 1
if cnt_4 >= cnt_1:
    print("Yes")
elif cnt_4 + cnt_1 == n and cnt_4 >= cnt_1-1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14252
# include <bits/stdc++.h>
# 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 ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

    int A[N];
    rep(i,N){
        cin >> A[i];
    }

    int count = 0;

    double all = 0;

    rep(i,N){
        all+=A[i];
    }

    double X = all / (4*M);

    rep(i,N){
        if(A[i] >= X){
            count++;
        }
    }

    if(count >= M) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(x, z, y) for(int x = (z); y; x++)
#define rep(x, y) for(int x = 0; x < (y); x++)
#define REP(x, z, y) for(int x = (z); x < (y); x++)
#define all(x) x.begin(), x.end()
#define len(x) (sizeof(x) / sizeof(x[0]))
#define split_str(str, sp_word) istringstream stream(str); string res; FOR(cnt, 0, getline(stream,res,sp_word))
#define scanln(x) fgets(x, sizeof x, stdin)
#define down_queue(x) priority_queue<x>
#define up_queue(x) priority_queue<x, vector<x>, greater<x>>
#define i_str(x) atoi(x.c_str())
#define digit(x) ((int)log10((double)(x)) + 1)
typedef long long ll;
using namespace std;

int main(){
  int w,a,b;
  scanf("%d%d%d",&w,&a,&b);
  if(a > b) swap(a,b);
  int ans = b - (a + w);
  if(ans >= 0) printf("%d",ans);
  else puts("0");
  return 0;
}

Measured memory_bytes: 256
s = input()
t = input()

patterns = set([(a,b) for a, b in zip(s, t)])

alphabets = [[False, False] for i in range(26)]
flag = False

for pattern in patterns:
  if alphabets[ord(pattern[0]) - ord('a')][0] == True:
    break
  else:
    alphabets[ord(pattern[0]) - ord('a')][0] = True
    
  if alphabets[ord(pattern[1]) - ord('a')][1] == True:
    break
  else:
    alphabets[ord(pattern[1]) - ord('a')][1] = True
else:
  flag = True
  
if flag == True:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 17968
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define vi vector<int>
#define pb push_back
#define ff first
#define ss second
#define forn(i,n) for(int i=0;i<n;i++)
#define mod  1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(0)

void solve() {

	int a, b, c, d;
	cin >> a >> b >> c >> d;

	int p1 = a * c;
	int p2 = a * d;
	int q1 = b * c;
	int q2 = b * d;

	int ans = max(max(p1, p2), max(q1, q2));

	cout << ans << endl;

}

int32_t main() {

	fastio;

#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif

	// int t; cin >> t;/
	int t = 1;

	while (t--) {
		solve();
	}

	return 0;
}

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

bool grid[25][25];
int dx[4] = {0, 0, -1, 1};
int dy[4] = {-1, 1, 0, 0};

int ans = 0; // we are looking for a maximum

void bfs(int row, int col) {
    bool visited[25][25];
    memset(visited, false, sizeof(visited));
    queue<pair<pair<int, int>, int>> q;
    q.push(make_pair(make_pair(row, col), 0));
    while (!q.empty()) {
        int vrow = q.front().first.first; int vcol = q.front().first.second; int dist = q.front().second; q.pop();
        if (!visited[vrow][vcol]) {
            visited[vrow][vcol] = true;
            ans = max(ans, dist);
            for (int i = 0; i < 4; ++i) {
                if (grid[vrow + dy[i]][vcol + dx[i]])
                    q.push(make_pair(make_pair(vrow + dy[i], vcol + dx[i]), dist + 1));
            }
        }
    }
    return;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int h, w;
    cin >> h >> w;
    for (int i = 1; i <= h; ++i) {
        for (int j = 1; j <= w; ++j) {
            char c;
            cin >> c;
            if (c == '.') {
                grid[i][j] = true;
            }
        }
    }
    // brute force the grid ( this can be solved with Floyd Warshall as well )
    for (int i = 1; i <= h; ++i) {
        for (int j = 1; j <= w; ++j) {
            // for each starting node, breadth first search to find the furthest node
            if (grid[i][j])
                bfs(i, j);
        }
    }
    cout << ans << '\n';

    return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    vector<int> a(10, 0);
    int n, k;
    int ans = 0;
    int flag = 0;
    int x;
    cin >> n >> k;
    for (int i = 0; i < k; i++)
    {
        cin >> x;
        a[x]++;
    }
    for (int i = n; i < 1000000; i++)
    {
        int t = i;
        flag = 0;
        while (t)
        {
            int p = t % 10;
            if (a[p] != 0)
            {
                flag = 1;
                break;
            }
            t /= 10;
        }
        if (flag == 1)
            continue;
        else
        {
            ans = i;
            break;
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll n,k;
int main(){
    cin>>k>>n;
    vector<int> v(n,0);
    rep(i,n) cin>>v[i];
    vector<int> dist;
    rep(i,n){
        int dis=0;
        if(i!=n-1)dis=v[i+1]-v[i];
        else{
            dis=v[0]+min(k,k-v[n-1]);
        }
        dist.push_back(dis);
    }
    //cout<<"aaa"<<endl;
    sort(dist.begin(),dist.end());
    //rep(i,n) cout<<dist[i]<<endl;
    int sum=0;
    rep(i,dist.size()-1) sum+=dist[i];
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 2168
import java.util.*;
public class Main{

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int dig=sc.nextInt();
        int temp;
        int flag=0;
        for(int i=0;i<3;i++){
            temp=dig%10;
            dig=dig/10;
            if(temp==7){
                flag=flag+1;
                break;
            }
            

        }
        if(flag==1)
        {
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

const ll K = 30000;
typedef bitset<K> B;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll m, n;
	cin >> m >> n;

	vvl a(m,vl(n)), b(m,vl(n));
	FOR(i,0,m) FOR(j,0,n) cin >> a[i][j];
	FOR(i,0,m) FOR(j,0,n) cin >> b[i][j];
	FOR(i,0,m) FOR(j,0,n) a[i][j] -= b[i][j];

	vector<vector<B>> dp(m,vector<B>(n));
	dp[0][0][K/2] = 1;
	
	FOR(i,0,m) FOR(j,0,n) {
		if (i) dp[i][j] |= dp[i-1][j];
		if (j) dp[i][j] |= dp[i][j-1];
		ll x = abs(a[i][j]);
		dp[i][j] = (dp[i][j] << x) | (dp[i][j] >> x);
	}
	
	B res = dp[m-1][n-1];
	FOR(k,0,K/2) if (res[K/2+k] || res[K/2-k]) {
		cout << k << endl;
		return 0;
	}
}



Measured memory_bytes: 24320
#include <stdio.h>
#include <stdlib.h>
#define MAXLEN 200005

char AREA[MAXLEN] = {0};

int top;
int S[MAXLEN] = {0};

typedef struct {
	int location;
	int size;
} pool;

int top_s2;
pool S2[MAXLEN];

void initialize();
int isEmpty();
int isFull();
void push(int x);
int pop();

void initializeS2();
int isEmptyS2();
int isFullS2();
void pushS2(pool S2);
pool popS2();


int main() {
	int i, j;
	int sum, tmp;
	pool s2, tmp_s2;
	char c;
//	scanf("%s", AREA);
	sum = 0;
	initialize();
	initializeS2();
//	for (i = 0; (c = fgetc(stdin) != '\n'); ++i) {
	i = 0;
	while ((c = fgetc(stdin)) != '\n') {
		switch(c) {
		case '\\':
			push(i);
			break;
		case '/':
			if (isEmpty()) continue;
			j = pop();
			tmp = (i - j);
			sum += tmp;
			if (isEmptyS2()) {
				s2.location = j;
				s2.size = tmp;
				pushS2(s2);
			} else {
				tmp_s2 = popS2();
				while (tmp_s2.location > j ) {
					tmp += tmp_s2.size;
					if (isEmptyS2()) break;
					tmp_s2 = popS2();
				}
				if (tmp_s2.location < j) {
					pushS2(tmp_s2);
				}
				s2.location = j;
				s2.size =  tmp;
				pushS2(s2);
			}
			break;
		case '_':
			break;
		}
		++i;
	}
	printf("%d\n", sum);
	j = 0;
	//s2 = popS2();
	//S[0] = s2.size;

	while (!isEmptyS2()) {
		s2 = popS2();
		S[j] = s2.size;
		++j;
	}
	if (j) {
		printf("%d ", j);
	} else {
		printf("%d\n", j);
	}
	for (i = 0; i < j; ++i) {
		if (i != j - 1) {
			printf("%d ", S[j-1-i]);
		} else {
			printf("%d\n", S[j - 1 - i]);
		}
	}
	return 0;
}

void initialize() {
	top = 0;
	return;
}

int isEmpty() {
	return top == 0;
}

int isFull() {
	return top >= MAXLEN - 1;
}

void push(int x) {
	if (isFull()) {
		printf("Over Flow\n");
		exit(-1);
	}

	top++;
	S[top] = x;
}

int pop() {
	if (isEmpty()) {
		exit(-1);
	}
	top--;
	return S[top+1];
}


void initializeS2() {
	top_s2 = 0;
	return;
}

int isEmptyS2() {
	return top_s2 == 0;
}

int isFullS2() {
	return top_s2 >= MAXLEN - 1;
}

void pushS2(pool new) {
	if (isFullS2()) {
		printf("Over Flow S2\n");
		exit(-1);
	}
//	printf("new %d %d %d\n", new.location, new.size, top_s2);
	top_s2++;
	S2[top_s2] = new;
}

pool popS2() {
	if (isEmptyS2()) {
		printf("Under Flow S2\n");
	}
	top_s2--;
	return S2[top_s2+1];
}

Measured memory_bytes: 588
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    static class DKi
    {
        static void Main(string[] args)
        {
            var nq = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
            var n = nq[0];
            var q = nq[1];

            // create tree.
            var tree = new List<int>[n];
            for (int i = 0; i < tree.Length; i++)
            {
                tree[i] = new List<int>();
            }            
            for (int i = 0; i < (n - 1); i++)
            {
                var ab = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
                int a = ab[0] - 1;
                int b = ab[1] - 1;
                tree[a].Add(b);
                tree[b].Add(a);
            }

            var opes = new List<int>(new int[n]);
            for (int i = 0; i < q; i++)
            {
                var px = Console.ReadLine().Split(' ').Select(y => int.Parse(y)).ToList();
                int p = px[0] - 1;
                int x = px[1];
                opes[p] += x;
            }

            var answers = new List<int>(new int[n]);
            answers[0] = opes[0];
            DFS(0, -1, tree, opes, answers);

            Console.WriteLine(string.Join(" ", answers));
            Console.ReadLine();
        }

        static void DFS(int crnt, int parent, List<int>[] tree, List<int> opes, List<int> answers)
        {
            if (parent != -1)
            {
                answers[crnt] = opes[crnt] + answers[parent];
            }

            foreach (var leaf in tree[crnt])
            {
                if (leaf == parent)
                {
                    continue;
                }
                DFS(leaf, crnt, tree, opes, answers);
            }
        }
    }
}

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

typedef vector<int> vi;

int i_th(int bit, int i){
  return (bit >> i) & 1;
}

int honest(int bit){
  int res = 0;
  while(bit > 0){
    if(bit & 1 == 1) res++;
    bit >>= 1;
  }
  return res;
}

int main(){
  int N;
  vi A(20);
  vector<vi> x(20, vi(20)), y(20, vi(20));

  cin >> N;
  for(int i=0; i<N; i++){
    cin >> A[i];
    for(int j=0; j<A[i]; j++){
      cin >> x[i][j] >> y[i][j];
    }
  }

  // bitで全探索
  int ans = 0;

  for(int b = 1; b < (1<<N); b++){
    bool flag = true;
    for(int i=0; i<N; i++){
      if(i_th(b,i) == 0) continue;

      for(int j=0; j<A[i]; j++){
        if(i_th(b,x[i][j]-1) != y[i][j]) flag = false;
      }
    }
    if (flag) ans = max(ans, honest(b));
  }

  cout << ans << endl;
}

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

using ll = long long;
static const ll MOD = 1e9 + 7;

bool judge(string s) {
  string t = s.substr(s.size() - 4);
  if(t[1] == 'A' && t[2] == 'G' && t[3] == 'C') return false;
  if(t[1] == 'G' && t[2] == 'A' && t[3] == 'C') return false;
  if(t[1] == 'A' && t[2] == 'C' && t[3] == 'G') return false;
  if(t[0] == 'A' && t[2] == 'G' && t[3] == 'C') return false;
  if(t[0] == 'A' && t[1] == 'G' && t[3] == 'C') return false;
  return true;
}

map<pair<int, string>, ll> mp;

ll dfs(int i, int n, string s) {
  if(i == n) return judge(s);
  string t = s.substr(s.size() - 3);
  ll ret = 0;
  if(judge(t + "A")){
    if(mp[make_pair(i + 1, t + "A")]) ret += mp[make_pair(i + 1, t + "A")];
    else{
      mp[make_pair(i + 1, t + "A")] = dfs(i + 1, n, t + "A");
      ret += mp[make_pair(i + 1, t + "A")];
    }
  }
  if(judge(t + "G")){
    if(mp[make_pair(i + 1, t + "G")]) ret += mp[make_pair(i + 1, t + "G")];
    else{
      mp[make_pair(i + 1, t + "G")] = dfs(i + 1, n, t + "G");
      ret += mp[make_pair(i + 1, t + "G")];
    }
  }
  if(judge(t + "C")){
    if(mp[make_pair(i + 1, t + "C")]) ret += mp[make_pair(i + 1, t + "C")];
    else{
      mp[make_pair(i + 1, t + "C")] = dfs(i + 1, n, t + "C");
      ret += mp[make_pair(i + 1, t + "C")];
    }
  }
  if(judge(t + "T")){
    if(mp[make_pair(i + 1, t + "T")]) ret += mp[make_pair(i + 1, t + "T")];
    else{
      mp[make_pair(i + 1, t + "T")] = dfs(i + 1, n, t + "T");
      ret += mp[make_pair(i + 1, t + "T")];
    }
  }
  return ret % MOD;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  cout << dfs(0, n, "TTTT") << '\n';
}

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

a, b, k = map(int, input().split())

pre_arr = [i for i in range(a, min(a+k, b+1))]
back_arr = [i for i in range(max(b-k+1, a), b+1)]
arr_slice = set(pre_arr) | set(back_arr)
[print(i) for i in sorted(arr_slice)]

Measured memory_bytes: 3064
/*
LANG:C++
PROB:

*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)


using namespace __gnu_pbds;
using namespace std;


typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
typedef unsigned long long ui64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
const int mod=1000000007;
  i64 poww(i64 a, i64 b)
  {
    a%=mod;
    i64 res=1;
    while(b)
      {
if(b&1)res=res*a%mod;

      a=a*a%mod;
      b/=2;

      }
      return res;
  }
  i64 inv(i64 a)
  {
    return poww(a,mod-2);
  }


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

    // ifstream fin(".in");
    // ofstream fout(".in");

i64 sum=0;
int n;
cin>>n;
forn(i,n)
{
i64 x=i+1;
  if(x%3&&x%5)sum+=x;
}
cout<<sum;


    return 0;
  }


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

int main() {
    int n, b=0, z=0;
    long long a, s=0, m=1e9;
    cin >> n;
    for(int i=0;i<n;i++){
        cin>>a;
        s+=abs(a);
        m=min(m, abs(a));
        if(a<0)b++;
        if(a==0)z=1;
    }
    if(z==0&&b%2==1){
        s-=m*2;
    }
    cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;



public class Main {



	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		HashMap<Integer, HashSet<Integer>> graph = new HashMap<>();
		for (int i=1;i<=n;i++) {
			graph.put(i, new HashSet<Integer>());
		}

		int[] inOrder = new int[n+1];

		for (int i=0;i<n-1+m;i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			graph.get(a).add(b);
			inOrder[b]++;
		}

		int root = 0;
		int[] ans = new int[n+1];

		for (int i=1;i<=n;i++) {
			if(inOrder[i]==0) {
				root = i;
				ans[root] = 0;
			}
		}
		bfs (root, graph, inOrder, ans);
		for (int i=1;i<=n;i++) {
			System.out.println(ans[i]);
		}



	}
	static void bfs(int s, HashMap<Integer, HashSet<Integer>> graph, int[] inOrder, int[] ans) {
//		System.out.println("bfs "+s);
		ArrayList<Integer> li = new ArrayList<>();
		for (Integer x :graph.get(s)) {
			inOrder[x]--;
			if (inOrder[x]==0) {
				ans[x]=s;
				li.add(x);
			}
		}
//		System.out.println(li);
		for (Integer y : li) {
			bfs(y,graph,inOrder,ans);
		}
	}



}





Measured memory_bytes: 145744
#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;
const int mod = 1000000007;
const int INF = 1e18;

struct UF{
    vector<int> par, sz;
    UF(){}
    UF(int n):par(n), sz(n, 1){
        iota(par.begin(), par.end(), 0);
    }
    int find(int x){
        if(x == par[x]) return x;
        return par[x] = find(par[x]);
    }
    void unite(int x, int y){
        x = find(x); y = find(y);
        if(x == y) return;
        if(sz[x] < sz[y]) swap(x, y);
        sz[x] += sz[y];
        par[y] = x;
    }
    bool same(int x, int y){
        return find(x) == find(y);
    }
};

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, k, l;
    cin >> n >> k >> l;
    UF ufk(n), ufl(n);
    rep(i, 0, k){
        int p, q;
        cin >> p >> q;
        p--; q--;
        ufk.unite(p, q);
    }
    rep(i, 0, l){
        int p, q;
        cin >> p >> q;
        p--; q--;
        ufl.unite(p, q);
    }
    map<P, int> mp;
    rep(i, 0, n){
        mp[{ufk.find(i), ufl.find(i)}]++;
    }
    rep(i, 0, n){
        if(i) cout << " ";
        cout << mp[{ufk.find(i), ufl.find(i)}];
    }
    cout << endl;
}

Measured memory_bytes: 18176
N, x = map(int, input().split())

if x in [1, 2 * N - 1]:
    print('No')
else:
    print('Yes')
    center = {x - 1, x, x + 1}
    others = sorted(set(range(1, 2 * N)) - center)
    ans = others[N - 2:] + list(center) + others[:N - 2]
    print(*ans, sep='\n')

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

typedef long long int ll;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<vll> vvl;
typedef pair<ll, ll> pll;
typedef vector<pll> vpl;
typedef unordered_set<ll> usl;
typedef set<ll> sl;
typedef unordered_map<ll, ll> uml;
typedef map<ll, ll> ml;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

#define loop(i, s, n) for(ll i = s; i < n; ++i)
#define all(v) v.begin() , v.end()
#define ceil(a, b) (a + b - 1) / b
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll inf = 1e9 + 7;
const double pie = 3.14159265358979323846;
const char nl = '\n';
const char spc = ' ';

template<typename Type>
istream &operator>>(istream &in, vector<Type> &v)
{
    ll n = v.size();
    for (int i = 0; i < n; i++)
        in >> v[i];
    return in;
}

template<typename Type>
ostream &operator<<(ostream &out, vector<Type> &v)
{
    for (auto value : v)
        out << value << ' ';
    out << nl;
    return out;
}

bool isPrime (ll n)
{
    if (n < 4)
        return true;
    if (n % 2 == 0)
        return false;
    ll i = 3;
    while (i * i <= n)
    {
        if (n % i == 0)
            return false;
        i += 2;
    }
    return true;
}

void solve ()
{
    ll n, x, t;
    cin >> n >> x >> t;
    ll ans = ceil(n, x);
    ans *= t;
    cout << ans << nl;
}

int main()
{
    IOS
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    ll t;
    t = 1;
    //cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

int main() {

	int a,b,c;
	cin>>a>>b>>c;

	int total=0;
	rep(i,b){
		if((total+a)%b==c){
			cout<<"YES"<<endl;
			return 0;
		}
		total+=a;
	}
	cout<<"NO"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#define ll long long
#define ls(x) x << 1
#define rs(x) x << 1 | 1
#define rep(i, a, b) for(int i = a; i <= (int)b; i++)
void read(int &x) {
    x = 0; int flag = 1; char ch = ' ';
    while(ch < '0' || ch > '9') { if(ch == '-') flag = -1; ch = getchar(); }
    while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
    x *= flag;
}
void read(ll &x) {
    x = 0; int flag = 1; char ch = ' ';
    while(ch < '0' || ch > '9') { if(ch == '-') flag = -1; ch = getchar(); }
    while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
    x *= flag;
}
using namespace std;
const int maxn = 200010;
int n, m;
ll ans[maxn << 2], tag[maxn << 2];
struct Data {
    int l, r, val;
    bool operator < (const Data & a) const { return r < a.r; }
} a[maxn];
void push_up(int p) { ans[p] = max(ans[ls(p)], ans[rs(p)]); }
void change(int p, int l, int r, ll x) {
    tag[p] += x;
    ans[p] += x;
}
void push_down(int p, int l, int r) {
    int mid = (l + r) >> 1;
    change(ls(p), l, mid, tag[p]);
    change(rs(p), mid + 1, r, tag[p]);
    tag[p] = 0;
}
void update(int p, int l, int r, int ql, int qr, ll x) {
    if(ql <= l && r <= qr) {
        change(p, l, r, x);
        return;
    }
    if(tag[p]) push_down(p, l, r);
    int mid = (l + r) >> 1;
    if(ql <= mid) update(ls(p), l, mid, ql, qr, x);
    if(qr > mid) update(rs(p), mid + 1, r, ql, qr, x);
    push_up(p);
}
ll query(int p, int l, int r, int ql, int qr) {
    if(ql <= l && r <= qr) return ans[p];
    if(tag[p]) push_down(p, l, r);
    int mid = (l + r) >> 1;
    ll ret = 0;
    if(ql <= mid) ret = max(ret, query(ls(p), l, mid, ql, qr));
    if(qr > mid) ret = max(ret, query(rs(p), mid + 1, r, ql, qr));
    return ret;
}
int main()
{
    read(n), read(m);
    rep(i, 1, m) {
        read(a[i].l), read(a[i].r), read(a[i].val);
    }
    sort(a + 1, a + 1 + m);
    int cur = 1;
    rep(i, 1, n) {
        update(1, 1, n, i, i, query(1, 1, n, 1, i));
        while(a[cur].r == i) update(1, 1, n, a[cur].l, a[cur].r, a[cur].val), cur++;
    }
    printf("%lld\n", max(ans[1], 0ll));
    return 0;
}

Measured memory_bytes: 14720
s=input()
f=int(s[0]+s[1])
b=int(s[2]+s[3])

if 1<=f<=12:
    if 1<=b<=12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1<=b<=12:
        print("YYMM")
    else:
        print("NA")    


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














string N;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	fore(d, N) if (d == '7') {
		cout << "Yes" << endl;
		return;
	}
	cout << "No" << endl;
}







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

#define ll long long int
#define watch(x) cout << (#x) << " is " << (x) << endl
#define f(i,x,n)  for(int i=x;i<n;i++)
#define FASTIO cin.tie(0); cout.tie(0);
#define eb(x) emplace_back(x)
#define mp(a,b) make_pair(a,b)
#define sz(a) int((a).size())
#define mod 1000000007
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define inf LLONG_MAX

//LCM
int lcm(int a, int b) {  return a * (b / __gcd(a, b)); }

//For sort by second
bool cmp(const pair<int,int> &a)
{ return a.first<a.second; }

//Tree
const int MAXN = 1e6;
vector<ll> adj[MAXN];

//ModPower
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}

int main()
{
	FASTIO;
	int t;
	//cin>>t;
	t=1;
	while(t--)
	{
	    ll n;
	     cin>>n;
	     for(int i=2;i<=n;i++)
         {
             ll x;
              cin>>x;
              adj[x].push_back(i);
         }
         for(ll i=1;i<=n;i++)
         {
             cout<<adj[i].size()<<"\n";
         }
         //cout<<"\n";
	}
	return 0;
}













Measured memory_bytes: 33320
from itertools import product
S = [int(x) for x in list(input())]
N = len(S)
ans = 0
c = S[0]
for x in product(range(2), repeat = N-1):
    for i in range(1,N):
        if x[i-1] == 0:
            c = c*10 + S[i]
        else:
            ans += c
            c = S[i]
    ans += c
    c = S[0]
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <set>
#include <vector>
#include <cmath>
#include <bitset>
#include <functional>
#include <limits>
#include <map>
using namespace std;

    typedef long long ll;
    #define rep1(i, n) for(ll i = 1; i <=(ll)(n); i++)
    #define rep0(i, n) for(ll i = 0; i <=(ll)(n); i++)

    ll pow(ll a, ll n) { //compute a^n with o(logn)
        ll res = 1;
        while (n > 0) {
            if (n & 1) res = res * a;
            a = a * a;
            n >>= 1;
        }
        return res;
    }

    ll pow(ll a, ll n, ll mod) { //compute a^n (mod mod) with o(logn)
        ll res = 1;
        while (n > 0) {
            if (n & 1) res = res * a % mod;
            a = a * a % mod;
            n >>= 1;
        }
        return res;
    }

    int main(){
        ll n;
        cin >> n;
        ll cnt[4] = {0};
        rep1(i,n){
            string a;
            cin >> a;
            if(a == "AC"){
                cnt[0]++;
            }else if(a == "WA"){
                cnt[1]++;
            }else if(a == "TLE"){
                cnt[2]++;
            }else if(a == "RE"){
                cnt[3]++;
            }
        }

        cout << "AC x " << cnt[0] <<endl;
        cout << "WA x " << cnt[1] <<endl;
        cout << "TLE x " << cnt[2] <<endl;
        cout << "RE x " << cnt[3] <<endl;
        return 0;
    }

Measured memory_bytes: 3224
// C - 4-adjacent
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define pb push_back
#define eb emplace_back
#define mp make_pair
#pragma GCC optimize("Ofast")
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vvli = vector<vlli>;
using vs = vector<string>;
using vvs = vector<vs>;
using vb = vector<bool>;
using vvb = vector<vb>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, h, n, w, ans = 0, count = 0;
  string s, t;
  vector<pair<string, pair<lli, lli>>> pr;
  cin >> n;
  vlli d(n);
  rep(i, 0, n)
  {
    cin >> d[i];
    if (d[i] % 4 == 0)
    {
      count++;
    }
    else if (d[i] % 2 == 0)
    {

      ans++;
    }
  }
  if (ans >= 2)
  {
    count += (ans / 2);
  }
  if (count >= n / 2)
  {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3984
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
int a[100005],b[100005],score[100005];
int main()
{
    int n,k,q;
    scanf("%d%d%d",&n,&k,&q);
    for(int i=0;i<n;i++)
    {
        a[i]=k;
    }
    for(int i=0;i<q;i++)
    {
        scanf("%d",&b[i]);
        a[b[i]-1]++;
    }
    for(int i=0;i<n;i++)
    {
        a[i]-=q;
        if(a[i]<=0)
        {
            printf("No\n");
        }
        else
        {
            printf("Yes\n");
        }
    }
    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n) for(int i = 0; i < (n); i++)
const int MOD = 1e9+7;
const int INF = 1.1e9;
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/while(min(a,b)>0){if(a<b)swap(a,b);a=a%b;}return max(a,b);}
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
struct Edge{int to,weight;};
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 dp[110][101010]; 
int w[110],v[110];

signed main(){
  int n,W;
  cin>>n>>W;
  rep(i,n) cin>>w[i]>>v[i];
  rep(i,110)rep(j,101010) dp[i][j]=INF;
  
  dp[0][0]=0;
  rep(i,n+1)rep(j,101010){
    if(j>=v[i]) chmin(dp[i+1][j],dp[i][j-v[i]]+w[i]);
    chmin(dp[i+1][j],dp[i][j]);
  }

  int ans=0;
  rep(j,101010) if(dp[n][j]<=W) ans=j;
  cout<<ans<<endl;
  // rep(i,n+1){
  //   rep(j,101010) if(dp[i][j]<INF) cout<<dp[i][j]<<"/"<<j<<" ";
  //   cout<<endl;
  // }
  return 0;
}


Measured memory_bytes: 87040
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority_queue
#include<deque>//double_ended queue
using namespace std;
typedef pair<int,int> P;//Pでpair<-,->を表す。
typedef long long LL; 
LL MOD=1000000007;

int main()
{ 
    int n;
    cin>>n;
    int x[n];
    for(int i=0;i<n;i++){
        cin>>x[i];
    }
    LL min=10000000000;
    LL calc=0;
    for(LL i=1;i<=100;i++){
        calc=0;
        for(int j=0;j<n;j++){
            calc=calc+(i-x[j])*(i-x[j]);
        }
        if(calc<min){min=calc;}
    }

    cout<<min<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int n, x[500], t[300000];
bool solve() {
	vector<pair<int, int>>vec;
	for (int i = 0; i < n; i++) {
		vec.push_back(make_pair(x[i], i + 1));
	}
	sort(vec.begin(), vec.end());
	int bar = 1;
	for (int i = 0; i < vec.size(); i++) {
		int a1 = vec[i].first, a2 = vec[i].second;
		int ko = a2 - 1;

		int cnt = 0;
		while (cnt < ko) {
			if (bar >= a1)return false;
			if (t[bar] == 0) { cnt++; t[bar] = a2; }
			bar++;
		}

	}

	int bar2 = n*n;
	for (int i = vec.size() - 1; i >= 0; i--) {
		int a1 = vec[i].first, a2 = vec[i].second;
		int ko = n - a2;
		
		int cnt = 0;
		while (cnt < ko) {
			if (bar2 <= a1)return false;
			if (t[bar2] == 0) { cnt++; t[bar2] = a2; }
			bar2--;
		}
	}

	return true;
}
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) { cin >> x[i]; t[x[i]] = i + 1; }
	bool T = solve();
	if (T == false)cout << "No" << endl;
	if (T == true) {
		cout << "Yes" << endl;
		for (int i = 1; i <= n*n; i++) { if (i >= 2)cout << ' '; cout << t[i]; }
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 2176
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
using namespace std;
int main(){
    int n,x,ans=0,i=0;
    cin>>n>>x;
    vector<int>a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    if(x>accumulate(a.begin(),a.end(),0L)){cout<<n-1<<endl;return 0;}
    sort(a.begin(),a.end());
    while(x>=a[i]&&i<a.size())x-=a[i++],ans++;
    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;

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

struct UnionFind {
public:
	vector<int> par; // 親ノード
    vector<int> rank; // ランク
	vector<int> ren; // 連結成分のサイズ

    UnionFind(int n = 1) {
        init(n);
    }

    void init(int n = 1) {
        par.resize(n);
		rank.resize(n);
		ren.resize(n);
        for (int i = 0; i < n; ++i){
			par[i] = i;
			rank[i] = 0;
			ren[i] = 1;
		}
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x);
		y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
		ren[x] += ren[y];
        return true;
    }
};

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

	int N, M;
	cin >> N >> M;

	vector<pii> v(M);
	rep(i, M){
		int a, b;
		cin >> a >> b;
		v[i] = (pii){a - 1, b - 1};
	}

	UnionFind uf(N);
	ll ret = (ll) N * (N - 1) / 2;
	vector<ll> ans(M);
	for(int i = M - 1; i >= 0; i--){
		ans[i] = ret <= 0 ? 0: ret;

		pii e = v[i];
		// cout << i << "," << e.first << "," << e.second << "," << uf.ren[uf.root(e.first)] << "," << uf.ren[uf.root(e.second)] << endl;

		if(uf.root(e.first) != uf.root(e.second)){
			ll t = (ll) uf.ren[uf.root(e.first)] * uf.ren[uf.root(e.second)];
			ret -= t;
			uf.merge(e.first, e.second);
		}

	}

	rep(i, M) cout << ans[i] << endl;
}


Measured memory_bytes: 4096