akhauriyash/Code-Regression huggingface dataset:
H, W = map(int, input().split())
STAGE = [list(input()) for _ in range(H)]

dp = [[0 for _ in range(W)] for _ in range(H)]
dp[0][0] = 1

MOD = 10 ** 9 + 7

for y in range(H):
	for x in range(W):
		if y + 1 < H and STAGE[y + 1][x] == ".":
			dp[y + 1][x] += dp[y][x] % MOD
		if x + 1 < W and STAGE[y][x + 1] == ".":
			dp[y][x + 1] += dp[y][x] % MOD

print(dp[-1][-1] % MOD)


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    bool g = true;
	short x, n, minrmin = 1000, minrmax = 1000, min_elem = -1, max_elem = -1, ind;
	cin >> x >> n;
	vector <int> p(n);
	for (short i = 0; i < n; i++) {
	    cin >> p[i];
	    if (abs(p[i] - x) < minrmin && p[i] < x) {
	        minrmin = abs(p[i] - x);
	        min_elem = p[i];
	    }
	    if (abs(p[i] - x) < minrmax && p[i] > x) {
	        minrmax = abs(p[i] - x);
	        max_elem = p[i];
	    }
	    if (p[i] == x) {
	        g = false;
	    }
	}
	if (g)
	    cout << x;
    else {
	    if (x - min_elem > 1 || (max_elem == -1 && min_elem == -1))
	        cout << x - 1;
	    else {
	        if (max_elem - x > 1)
	            cout << x + 1;
	        else {
	            set<short> s(p.begin(), p.end());
	            p.assign(s.begin(), s.end());
	            for (int i = 0; i < p.size(); i++) {
	                if (p[i] == x) {
	                    ind = i;
	                    break;
	                }
	            }
	            short m = ind;
	            short j = ind - 1;
	            while (p[m] - p[j] == 1 && j >= 0) {
	                m--;
	                j--;
	            }
	            short ans1 = p[m] - 1;
	            m = ind;
	            j = ind + 1;
	            while (p[j] - p[m] == 1 && j < p.size()) {
	                j++;
	                m++;
	            }
	            short ans2 = p[m] + 1;
	            if (ans2 - x < x - ans1)
	                cout << ans2;
	            else
	                cout << ans1;
	        }
	    }
	}
  	return 0;
}

Measured memory_bytes: 3620
n,k=map(int,input().split())
a=list(map(int,input().split()))
f=list(map(int,input().split()))
a.sort()
f.sort()
f.reverse()
li = [0]*n
for i in range(n):
	li[i] = a[i]*f[i]

l=-1
r=10**18+5

while(l+1<r):
	m=(l+r)//2
	cnt=0
	for i in range(n):
		ov = li[i]-m
		if ov>0:
			cnt+= (ov+f[i]-1)//f[i]
	if cnt<=k:
		r=m
	else:
		l=m
print(r)

Measured memory_bytes: 119500
use proconio::{fastout, input};
use std::collections::BTreeMap;

#[fastout]
fn main() {
    input! {n: usize, s: [String; n]};

    // BTreeMapはkeyに対して昇順になる
    // https://qiita.com/garkimasera/items/a6df4d1cd99bc5010a5e#btreemap
    let mut map = BTreeMap::new();
    let mut max = 0;
    for s_iter in s.iter() {
        let count = map.entry(s_iter).or_insert(0);
        *count += 1;
        max = std::cmp::max(max, *count);
    }

    for (key, value) in &map {
        if *value == max {
            println!("{}", key)
        }
    }
}


Measured memory_bytes: 20400
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

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

int main(){
	int a[100000];
	int n, t, mst=0,st=1000000000, cnt=0;
	cin >> n >> t;
	rep(i, n)
		cin >> a[i];

	rep(i, n){
		st = min(st, a[i]);//最小値
		if (mst == a[i]-st)
			cnt++;
		else if (mst <a[i]-st){
			cnt = 1;
			mst = a[i]-st;
			}

		}
	cout << cnt;


}

Measured memory_bytes: 640
import sys

n,m = input().split()
n,m = [int(n), int(m)]
num = 0
flag = 0
s = []
c = []

if m == 0:
  if n == 1:
    print(0)
    sys.exit()
    
  print(pow(10, n-1))
  sys.exit()

for i in range(m):
  s_i,c_i = input().split()
  s_i,c_i = [int(s_i), int(c_i)]
  flag = 0
  if n >= 2 and (s_i == 1 and c_i == 0):
    print(-1)
    sys.exit()
    
  for j in range(len(s)):
    if s[j] == s_i and c[j] != c_i:
      print(-1)
      sys.exit()
    elif s[j] == s_i and c[j] == c_i:
      flag = 1
  
  if flag == 1:
    continue
    
  s.append(s_i)
  c.append(c_i)
  
  num += c_i * pow(10, n-s_i)
  
  
if n >= 2 and num < pow(10, n-1):
  num += pow(10, n-1)
    
print(num)

Measured memory_bytes: 3064
#include<stdio.h>

int main()
{
	int a, b, c;
	
	scanf("%d %d %d", &a, &b, &c);
	
	if(a < b && b < c)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	return 0; 
}


Measured memory_bytes: 2608
N,L = map(int,input().split())

a = list(map(int,input().split()))

flag = False
able = 0
for i in range(N-1):

    if a[i] + a[i+1] >= L:
        flag = True
        able = i
        break

if flag:

    print ("Possible")

    for i in range(able):
        print (i+1)

    for i in range(N-1-able):
        print (N-1-i)

    #print (able + 1)

else:
    print ("Impossible")


Measured memory_bytes: 14076
#include <iostream>
#include <cmath>
#include <cstdio>
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;

int main(){
    ll a,b;
    cin>>a>>b;
    if(max(a,b)*2<=16){
        cout<<"Yay!"<<endl;
    }else{
        cout<<":("<<endl;
    }
}

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

int main() {
    int N;
    cin >> N;
    vector<vector<int>> G(N);
    vector<pair<int, int>> vp;
    for (int i = 1; i < N; i++)
    {
        int a, b; cin >> a >> b;
        a--, b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
        vp.emplace_back(a, b);
    }

    int K = 0;
    map<pair<int, int>, int> I;
    vector<int> cs(N, 0);

    vector<int> used(N, 0);
    queue<int> que;
    used[0] = 1;
    que.emplace(0);
    while (!que.empty())
    {
        int v = que.front(); que.pop();
        if(K < (int)G[v].size()) K = G[v].size();
        int cur = 1;
        for (int u : G[v])
        {
            if(used[u]) continue;
            if(cur == cs[v]) cur++;
            cs[u] = I[make_pair(u, v)] = I[make_pair(v, u)] = cur++;
            used[u] = 1;
            que.emplace(u);
        }
    }

    cout << K << endl;
    for (auto p : vp)
    {
        cout << I[p] << endl;
    }
    return 0;
}

Measured memory_bytes: 20084
using System;
class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);
        int c = int.Parse(input[2]);
        int ans;
        if ((a != b) && (a != c) && (b != c)) ans = 3;
        else if ((a == b) && (a == c) && (b == c)) ans = 1;
        else ans = 2;
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 2776
//#include <iostream>
//#include <algorithm>
//#include <functional>
//#include <vector>
//#include <string>
//#include <map>
//#include <sstream>
//#include <cmath>
//#include <cstdio>
//#include <iomanip>
//#include <stdexcept>
//#include <utility>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,h) for(int i = 0; i < h; ++i)
#define rep1(i,h) for(int i = 0; i <= h; ++i)
#define rep2(i,n,h) for(int i = n; i < h; ++i)
#define rep3(l,n,h) for(int l = n; l <= h; ++l)
typedef pair<int,int> int_pair;


int main() {
    string a,b;
    cin >> a >> b;
    ll sizeA = a.length();
    ll sizeB = b.length();
    int h = a.compare(b);
    if(sizeA == sizeB) {
        if(h > 0) {
            cout << "GREATER" << endl;
        } else if(h < 0) {
            cout << "LESS" << endl;
        } else {
            cout << "EQUAL" << endl;
        }
    } else if(sizeA >sizeB) {
        cout << "GREATER" << endl;
    } else if(sizeA <sizeB) {
        cout << "LESS" << endl;
    }
     return 0;
    }


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define pb push_back
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n,a;
	cin>>n>>a;
	int x[n];
	for(int i = 0; i<n; i++) cin>>x[i];
	ll dp[2501][51];
	memset(dp,0,sizeof(dp));
	ll ans = 0;
	for(int i = 0; i<n; i++)
	{
		ll dp2[2501][51];
		memset(dp2,0,sizeof(dp2));
		for(int j = 1; j<=2500; j++)
		{
			for(int k = 0; k<n; k++)
				if(dp[j][k])
					dp2[j+x[i]][k+1]+=dp[j][k];
		}
		dp2[x[i]][1]++;
		for(int j = 1; j<=2500; j++)
			for(int k = 0; k<=n; k++)
					dp[j][k]+=dp2[j][k];
	}
	for(int j = 1; j<=n; j++)
		ans += dp[a*j][j];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2304
S=str(input())
def f(x):
  return x==x[::-1]
N=len(S)
S1=S[:(N-1)//2]
S2=S[(N+1)//2:]
if f(S) and f(S1) and f(S2):
  print('Yes')
else:
  print('No')
  

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define pb push_back
#define mkp make_pair
#define llu unsigned long long int
#define ll long long
#define ld long double
#define foi(a,n) for(int i = a; i < n; i++)
#define foj(a,n) for(int j = a; j < n; j++)
#define foin(a,n) for(int i = n; i >= a; i--)
#define fojn(a,n) for(int j = n; j >= a; j--)
#define isp2(x) x&&(!(x&(x-1)))
#define ee 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define cases long long t;cin>>t;while(t--)

using namespace std;

int n, k;
int a[100002], w[1000];
ll dp[100001][100];

ll go(int x, int i){
	if(i == n-1 && w[i] <= x){
		return a[i];
	}
	if(x == 0 || i == n - 1){
		return 0;
	}
	if(dp[x][i] != -1){
		return dp[x][i];
	}
	if(w[i] <= x){
		return dp[x][i] = max((ll)a[i] + (ll)go(x - w[i], i+1), (ll)go(x, i+1));
	}
	return dp[x][i] = (ll)go(x, i+1);
}
		

int main() {
    ll q, m, x, y, d; 
    string s, h;
	cin >> n >> k; 
	foi(0, n) {
		cin >> w[i] >> a[i];
	}
	foi(0, 100001){
		foj(0, 100){
			dp[i][j] = -1;
		}
	}
	
	cout << go(k, 0);

}




Measured memory_bytes: 81728
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define mod 1000000007
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
#define ff first
#define endl "\n"
#define ss second
#define all(v) v.begin(), v.end()
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
  //  cout << x << " ";
    while (y > 0)
    {

        if (y & 1)
            res = (res * x) % p;

        y = y >> 1;
        x = (x * x) % p;
    }
    return res%p;
}
int lcm(int a, int b)
{
    return (a * b) / __gcd(a, b);
}
int fac[100001];
int inv[100001];
int comb(int a,int b){
    if(a<b)
        return 0;
    return ((fac[a] * inv[b] )%mod* inv[a - b]%mod);
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc;
    tc = 1;
    while (tc--)
    {
        int a, b;
        cin >> a >> b;
       if(a%b){
           a = a / b + 1;
       }
       else{
           a = a / b;
       }
        cout << a << endl;
         
    }

    return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author lstd
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <bitset>
#include <random>
#include <chrono>
#include <complex>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <ctime>

using namespace std;

#define sqr(x) ((x)*(x))
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define RE(i, n) FOR(i,1,n)
#define REP(i,n) FOR(i, 0, (int)(n)-1)
#define fst first
#define snd second

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;

string to_string(string s) {
    return '"' + s + '"';
}

string to_string(const char* s) {
    return to_string((string) s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}



void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

int XMOV[4] = {0, 0, 1, -1};
int YMOV[4] = {1, -1, 0, 0};

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

using namespace std;

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

vector<int> primes;

void sieve(){
	bool mark[1000006];
	mark[1] = true;
	memset(mark, 0, sizeof(mark));
	for(int x = 2; x < 1000006; x++){
		if (mark[x] == true)
			continue;
		primes.pb(x);
		mark[x] = true;
		for (int y = x+x; y < 1000006; y+=x)
		    mark[y] = true;
	}
}

class DDisjointSetOfCommonDivisors {
public:
	void solve(std::istream& in, std::ostream& out) {
		ll a, b;

		in >> a >> b;

		set<ll> commonDivisorsSet;
		sieve();

		ll greatestCommonDivisor = gcd(a, b);

        int ans = 0;
		for (int i = 0; i < primes.size() && greatestCommonDivisor > 1; i++){
			if (greatestCommonDivisor % primes[i] == 0) {
				ans++;
				while (greatestCommonDivisor % primes[i] == 0 && greatestCommonDivisor > 1){
					greatestCommonDivisor /= primes[i];
				}
			}

		}
		if (greatestCommonDivisor != 1)
		    ans++;
		out << ans+1;

	}
};

int main() {
	DDisjointSetOfCommonDivisors solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 1916
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
typedef long long int ll;
typedef long double ld;
using namespace std;

//-------------------------------------------------------------------
struct segtree{
  ll M=1;
  vector<ll> dat;
  segtree(ll N, ll num){
    while(M<N) M*=2;
    for(int i=0;i<M*2-1;i++)  dat.push_back(num);
  }
  void update(int x, int k, int l=0, int r=-1){
    if(r==-1) r = M;
    k+=M-1;
    dat[k] += x;
    while(k>0) k = (k-1)/2, dat[k] += x;
  }
  ll query(int a, int b=-1, int k=0, int l=0, int r=-1){
    if(r==-1) r = M;
    if(b==-1) b = M;
    if(r<=a || b<=l) return 0;
    if(a<=l && r<=b) return dat[k];
    ll A = query(a, b, k*2+1, l, (l+r)/2);
    ll B = query(a, b, k*2+2, (l+r)/2, r);
    return A + B;
  }
};
//-------------------------------------------------------------------
int main(int argc, char const *argv[]) {
  ll a, n, k;std::cin >> n >> k;
  segtree seg(n, 0);
  re(i, n){
    std::cin >> a;
    seg.update(a, i);
  }
  vll c;
  for(int l=0;l<n;l++) for(int r=l+1;r<=n;r++) c.push_back(seg.query(l, r));
  sort(c.begin(), c.end());
  reverse(c.begin(), c.end());
  ll ans = 0;
  vll r(64, 1);rep(i, 1, 64) r[i] = r[i-1]*2;
  for(ll i=50;i>=0;i--){
    ll C = 0;
    vll t;
    re(j, c.size()) if(r[i]&c[j]) C++, t.push_back(c[j]);
    if(C<k) continue;
    //std::cout << i << '\n';
    c = t, ans += r[i];
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 6148
#define _USE_MATH_DEFINES

#include <vector>
#include <list>
#include <map>
#include <string>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <utility>
#include <ctgmath>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;

const ll inf = 10e17;
const ll mod = inf;//1000000007;
const ld eps = 10e-9;



ll solve(void);
ll gcd(ll x, ll y);


ll mulmod(ll x, ll y)
{
	return (x * y) % mod;
}

ll submod(ll x, ll y)
{
	return (x - y + 100 * mod) % mod;
}

ll power(ll n, ll r)
{
	if ( r == 0 ) { return 1; }
	if ( r == 1 ) { return n; }
	if ( n == 0 ) { return 0; }
	if ( n == 1 ) { return 1; }

	if (r % 2 == 0)
	{
		ll y = power(n, r/2);
		return mulmod(y, y);
	}
	else
	{
		ll y = power(n, (r-1)/2);
		return n * mulmod(y, y) % mod;
	}
}

ll gcd(ll x, ll y)
{
	if (y == 1) { return 1;}
	if (x % y == 0) { return y; }
	return gcd(y, x % y);
}

vector<ll> perm;
vector<ll> inv;
void init_inv(ll m)
{
	perm.resize(m);
	inv.resize(m);
	
	perm[0] = 1;
	inv[0] = 1;

	for (ll i = 1; i < m; i++)
	{
		perm[i] = mulmod(perm[i-1], i);
	}
	
	for (ll i = 1; i < m; i++)
	{
		inv[i] = power(perm[i], mod - 2);
	}
}

ll ncr(ll n, ll r)
{
	// n (n-1) ... (n-r)
	if ( r == n || r == 0 ) { return 1; }

	ll ans = 1;
	for (ll i = 0; i < r; i++)
		ans = mulmod(ans, n - i);

	 return mulmod(ans, inv[r]);
	// return mulmod(perm[n], mulmod(inv[n-r], inv[r]));
}

bool binary_check(ll mid, ll key)
{
	return mid >= key;
}

ll binary_search()
{
//	ll ng = 0;
//	ll ok = x;
//
//	while (abs(ok - ng) > 1)
//	{
	//	ll mid = (ok+ng) / 2;
	//	if (binary_check(mid, k)) ok = mid;
	//	else ng = mid;
	//}

	return 0;
	//return ok;
}

ll solve(void)
{
	string s;
	cin >> s;

	cout << (s[1] == 'B' ? "ARC" : "ABC") << endl;

	return 0;
}

int main(void)
{
	while (solve())
	{
	}
	return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define f first
#define s second
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
/*bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
} */
int main()
{
     ll t,kk,pk;
     cin>>t;
     kk=t/1.08;
     pk=(kk+1)*1.08;
     if(kk*1.08==t)
        cout<<kk<<endl;
     else if(pk==t)
        cout<<kk+1<<endl;
     else
        cout<<":("<<endl;
}



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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const int MAXLEN = 3000+1;
int dp[MAXLEN][MAXLEN];
int route[MAXLEN][MAXLEN];
string s,t;
int solve(int spos, int tpos){
    //string res = "";
    int res = 0;

    if(dp[spos][tpos] != -1)
        return dp[spos][tpos];

    int s1=0;
    int s2=0;

    if(s[spos]==t[tpos]) {
        res = 1;
        if(spos > 0 && tpos > 0){
            s2 = solve(spos-1,tpos-1);
            res = s2+res;
            route[spos][tpos] = 3;
        }
    }else{
        if(spos > 0) s1 =solve(spos-1,tpos);
        if(tpos > 0) s2 =solve(spos,tpos-1);

        if(s1<s2){
            res = s2+res;
            route[spos][tpos] = 1;
        }else{
            res = s1+res;
            route[spos][tpos] = 2;
        }
    }

    dp[spos][tpos] = res;
    return res;
}

int main() {
    //ios::sync_with_stdio(false); cin.tie(0);
    cin>>s>>t;

    if(s.size() > t.size()) swap(s,t);
    int ss=s.size()-1;
    int ts=t.size()-1;

    memset(dp,-1,sizeof(dp));
    memset(route,-1,sizeof(route));
    route[0][0] = 0;

    int anslen = solve(ss,ts);
  
    string ans = "";

    int now = anslen;
    int i=ss;
    int j=ts;

    while(now > 0){
        int r = route[i][j];

        if(i==0 && j==0 || r == -1){
            ans = s[i]+ans;
            now--;
            break;
        }
        

        if(r == 1){
            j--;
        }else if(r == 2){
            i--;
        }else{
            i--; j--;
        }

        if(now > dp[i][j]){
            ans = s[i + ((r==2||r==3)?1:0) ]+ans;
            now--;
        }
    }

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

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

// Macros
#define F  first
#define S  second
#define PB push_back

// Rename Datatypes
using ll  = long long;
using ld  = long double;
using pii = pair<int,int>;

// Common Functions
ll fastpow(ll a, ll ex){ ll res = 1; while(ex){ if(ex & 1) res *= a; a *= a; ex >>= 1; } return res; }
ll fastpow(ll a, ll ex, ll m){ a %= m; ll res = 1; while(ex){ if(ex & 1) res = (a*res) % m; a = (a*a) % m; ex >>= 1; } return res; }
ll modinverse(ll a, ll m){ ll m0 = m, y = 0, x = 1; while (a > 1){ ll q = a / m; a %= m; swap(a,m); x -= q*y; swap(x,y); } if(x < 0) x += m0; return x; }

// HELPERS
//  Tedious Grid Movements
vector<pii> moves_grid = { {0,1} , {0,-1} , {1,0} , {-1,0} };
inline bool move_okay(int x, int y, int n, int m) { return 0 <= x and x < n and 0 <= y and y < m; }
//  Remember:
//   * vec.assign() GOOD; vec.resize() BAD
//   * comparator uses <

// Output, Common Containers
template <typename T> ostream& operator << (ostream& os, const vector<T>& v) { for (T i : v) os << i << ' '; return os; }
template <typename T> ostream& operator << (ostream& os, const set<T>& v)    { for (T i : v) os << i << ' '; return os; }
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) { os << "(" << v.F << "=>" << v.S << ") "; return os; }
template <typename T, typename S> ostream& operator << (ostream& os, const map<T,S>& v)  { for (auto i : v) os << i << ' '; return os; }

// Debugging
#ifdef SANYAM1101
	#define trace(args...) do{ cerr << "Trace On! (Line: " << __LINE__ << ")\n"; d_f(string(#args), args); } while(0)
	void d_f(__attribute__((unused)) string str) {}
	template<typename Head, typename... Tails> void d_f(string str, Head H, Tails... T) { cerr << "\t" << str.substr(0, str.find(", ")) << " <=> [" << H << "]\n"; d_f(str.substr(str.find(", ") + 2), T...); }
#else
	#define trace(args...)
#endif


// CODE STARTS HERE

void solve(){
	int n;
	cin >> n;
	
	vector<int> arr(n);
	for(auto& i: arr) cin >> i;

	auto choose2 = [](ll x) -> ll { return (x * (x - 1)) / 2; };

	map<int,int> m;
	for(auto i: arr) ++m[i];

	ll su = 0;
	for(auto [f,s] : m) su += choose2(s);

	for(auto i: arr)
		cout << su - choose2(m[i]) + choose2(m[i] - 1) << "\n";
}

signed main (void){
	// Fast_IO
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	// Set Fixed Notation (default sucks), High Precision for Floating-Point Output
	cout << fixed << setprecision(20);

	// Multiple TCs
	int tt = 1;
	// cin >> tt;
	while(tt--) solve();
}


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

const int Maxn = 1005;

int n, m;
set <int> neigh[Maxn];
int dist[Maxn], par[Maxn];
int best = Maxn;
vector <int> bi;

void Solve(int r)
{
    fill(dist, dist + Maxn, Maxn); dist[r] = 0;
    vector <int> Q; Q.push_back(r);
    for (int i = 0; i < Q.size(); i++) {
        int v = Q[i];
        if (neigh[v].find(r) != neigh[v].end()) {
            if (dist[v] + 1 < best) {
                best = dist[v] + 1;
                bi.clear();
                bi.push_back(v);
                do {
                    v = par[v];
                    bi.push_back(v);
                } while (v != r);
            }
            return;
        }
        for (auto u: neigh[v])
            if (dist[v] + 1 < dist[u]) {
                dist[u] = dist[v] + 1; par[u] = v;
                Q.push_back(u);
            }
    }
}

int main()
{
    scanf("%d %d", &n, &m);
    for (int i = 0; i < m; i++) {
        int a, b; scanf("%d %d", &a, &b);
        neigh[a].insert(b);
    }
    for (int i = 1; i <= n; i++)
        Solve(i);
    if (best >= Maxn) printf("-1\n");
    else {
        printf("%d\n", best);
        for (int i = 0; i < bi.size(); i++)
            printf("%d\n", bi[i]);
    }
    return 0;
}


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

int n, m, k;
vector<vector<int>> freg;
vector<vector<int>> blog;

// UnionFindの実装
struct UnionFind {
    vector<int> data;
    UnionFind(int size) : data(size, -1) { }

    // 集合をマージする
    // すでに同じ集合ならfalseが返る
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if(x == y) return false;
        //要素数の少ない方を多い方に繋げる
        if(data.at(y) < data.at(x)) swap(x, y);
        data.at(x) += data.at(y);
        data.at(y) = x;
        return true;
    }

    // ある要素がどの集合に属しているかを答える
    int root(int x) {
        // 根に直接つなぎ直す
        return data.at(x) < 0 ? x : (data.at(x) = root(data.at(x)));
    }

    // ある集合の大きさを答える
    int size(int x) {
        return -data.at(root(x));
    }

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

int main() {
    cin >> n >> m >> k;
    UnionFind Fre(n);
    UnionFind Blo(n);
    freg = vector<vector<int>>(n);
    blog = vector<vector<int>>(n);
    vector<bool> fren(n, false);

    for(int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        Fre.merge(a, b);
        freg.at(a).push_back(b);
        freg.at(b).push_back(a);
    }

    for(int i = 0; i < k; ++i) {
        int c, d;
        cin >> c >> d;
        c--; d--;
        blog.at(c).push_back(d);
        blog.at(d).push_back(c);
    }

    for(int i = 0; i < n; ++i) {
        int tlen = Fre.size(i);
        tlen--;
        int flen = freg.at(i).size();
        for(int j = 0; j < freg.at(i).size(); ++j) {
            if(!Fre.same(i, freg.at(i).at(j))) {
                flen--;
            }
        }
        int blen = blog.at(i).size();
        for(int k = 0; k < blog.at(i).size(); ++k) {
            if(!Fre.same(i, blog.at(i).at(k))) {
                blen--;
            }
        }
        tlen -= (blen+flen);
        if(i == n-1) {
            cout << tlen << endl;
        }else {
            cout << tlen << " ";
        }
    }
}

Measured memory_bytes: 12664
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> pref_trie;
typedef tree<long int,null_type,less<long int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef cc_hash_table<long int,long int, hash<long int>, equal_to<long int>, direct_mask_range_hashing<long int>, 
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;
typedef gp_hash_table<long int,long int> HashTable;

bool compare2(pair<long int,long int> a,pair<long int,long int> b) {return a.second < b.second;}

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

        
    long int n;
    cin>>n;

    vector<pair<long int,long int>> v(n);

    for(long int i = 0; i < n; i++){
        cin>>v[i].first>>v[i].second;
    }
        

    long int total = 0;

    if(n & 1){
        sort(v.begin(),v.end());

        long int x = v[(n/2)].first;

        sort(v.begin(),v.end(),compare2);

        long int y = v[(n/2)].second;

        total = y-x+1;
    }
    else{
        sort(v.begin(),v.end());
        long int x = v[(n/2)].first + v[(n/2)-1].first;
        sort(v.begin(),v.end(),compare2);
        long int y = v[(n/2)].second + v[(n/2)-1].second;
        total = y-x+1;
    }

    cout<<total;    
    return 0;
}

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

int main() {
  int kekka = -1;
  int A,B;
  cin >> A >> B;
  for (int i = 0; i < 2000; i++) {
    int a = i * 0.08;
    int b = i * 0.1;
    if (a == A && b == B) {
      kekka = i;
      break;
    }
  }
    cout << kekka << endl;
}
      

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int eatNum = scan.nextInt();
		int eatFee = eatNum * 800;
		int waribiki = (eatNum / 15) * 200;
		System.out.println(eatFee - waribiki);
	}

}


Measured memory_bytes: 21844
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next()); 
    long[] A = new long[N+1];  
    long[] B = new long[N];  
    for (int i=0; i < N+1 ;i++) {
      A[i] = Integer.parseInt(sc.next()); 
    }
    for (int i=0; i < N ;i++) {
      B[i] = Integer.parseInt(sc.next()); 
      }
    long count = 0;
    for(int i=0;i<N;i++ ){
      if(B[i]>=A[i]){
        count += A[i];
        long tmp = B[i] - A[i];
        A[i] = 0;
        if(tmp>=A[i+1]){
          count += A[i+1];
          A[i+1] = 0;
        }else{
          count += tmp;
          A[i+1] -= tmp;
        }
      }else{
        A[i] -= B[i]; 
        count += B[i];

      }
    }
    System.out.println(count);
  }
  
}



Measured memory_bytes: 57348
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <cstdio>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>
#include <random>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
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;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
int main(void){
    ll n;
    cin >> n;
    ll cnt = 0;
    bool ok = false;
    rep(i, n){
        ll a, b;
        cin >> a >> b;
        if(a == b){
            cnt++;
            if(cnt >= 3){
                ok = true;
            }
        } else {
            cnt = 0;
        }
    }

    if(ok){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}



Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)
#define MP(a,b) make_pair(a,b)

#if __has_include("debug.hpp")
#include "debug.hpp"
#else
template<typename T>
void debug(T& obj) {}
#endif

//----------------------------------------------------------------------
void solve() {

	ll n,k;
	cin >> n >> k;
	ll sum = 0;
	while(1) {
		n /= k;
		sum++;
		if (n==0) break;
	}

	cout << sum;
}
//----------------------------------------------------------------------

int main(int argc, char* argv[]) {
	solve();
	return 0;
}


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

const int N=2e5+100;
const int mod=1e9+7;
typedef long long ll;

typedef pair<ll,int>pa;

ll bit[50],a[N];

ll n,k,ans;

ll qpow (ll x, ll n)
{
    ll sum=1;
    while(n) {
        if(n&1) sum*=x;
        x*=x;
        n>>=1;
    }
    return sum;
}

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

   cin>>n>>k;

    for(int i=1;i<=n;i++) {
       cin>>a[i];
       ll x=a[i];
       int num=1;
       while(x){
        if(x&1) bit[num]++;
        num++;
        x>>=1;
       }
    }

    ll sum=0;

    for(int i=44;i>=0;i--){
        if(2*bit[i+1]<n && sum+(1ll<<i)<=k) sum+=(1ll<<i);
    }

    for(int i=1;i<=n;i++) {
        ans+=sum^a[i];
    }
    cout<<ans<<endl;
     return 0;
}


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int a,b,mi=1e9;
    for(int i=1;i<=n/2;i++){
        a=i;
        b=n-i;
        string aa=to_string(a);
        string bb=to_string(b);
        int sum=0;
        REP(j,aa.size())sum+=(aa[j]-'0');
        REP(j,bb.size())sum+=(bb[j]-'0');
        mi=min(mi,sum);
    }
    cout << mi << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
 
    #define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
    #define mod 1000000007
    #define qmod 998244353
    #define M 1000001
    #define endl "\n"
    #define all(a) (a).begin(),(a).end()
    #define rep(i,a,b) for(int i=a;i<b;++i)
    #define repr(i,a,b) for(int i=a;i>=b;--i)
    #define F first
    #define S second
    #define pb push_back
    #define mp make_pair
 
    typedef long long ll;
    typedef pair<int,int> pii;
    typedef vector<ll> vi;
    typedef vector<string> vs;
    typedef vector<pii> vii;
    typedef vector<vi> vvi; 
    
    int main(){
        
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin); 
    freopen("output.txt","w",stdout);   
    #endif */
 
        fast;
        int n;
        cin>>n;
        string s;
        cin>>s;
        vi cntr(n+1),cntg(n+1),cntb(n+1);
        repr(i,n-1,0){
            cntr[i] = cntr[i+1];
            cntg[i] = cntg[i+1];
            cntb[i] = cntb[i+1];
            if (s[i] == 'R') cntr[i]++;
            if (s[i] == 'G') cntg[i]++;
            if (s[i] == 'B') cntb[i]++;
        }
        ll ans=0;
        rep(i,0,n){
            rep(j,i+1,n){
                if(s[i]==s[j]) continue;
                ll q;
                char c;
                if (s[i] == 'R' && s[j] == 'G') {q = cntb[j+1];c='B';}
                if (s[i] == 'G' && s[j] == 'R') {q = cntb[j+1];c='B';}
                if (s[i] == 'R' && s[j] == 'B') {q = cntg[j+1];c='G';}
                if (s[i] == 'B' && s[j] == 'R') {q = cntg[j+1];c='G';}
                if (s[i] == 'B' && s[j] == 'G') {q = cntr[j+1];c='R';}
                if (s[i] == 'G' && s[j] == 'B') {q = cntr[j+1];c='R';}
                ans += q;
                if (2 * j - i < n && s[2 * j - i] == c) ans--;
            }
        }
        cout<<ans;
        return 0;  
    }       
 
 
    //keep it simple stupid

Measured memory_bytes: 3712
#!/usr/bin/env ruby

N = gets.chomp.to_i
A = gets.chomp.split.map(&:to_i)
Q = gets.chomp.to_i
B = []
C = []
Q.times do |i|
  B[i], C[i] = gets.chomp.split.map(&:to_i)
end

h = Hash.new(0)

A.each do |a|
  h[a] += 1
end

sum = A.sum

0.upto(Q-1) do |i|
  n = h[B[i]]
  sum -= B[i] * n
  sum += C[i] * n
  h[B[i]] = 0
  h[C[i]] += n
  puts sum
end


Measured memory_bytes: 29924
N, M = map(int, input().split())
S = input()
prev = N
pos = N
ans = []
while pos > 0:
    for i in range(M, 0, -1):
        if pos - i >= 0 and S[pos - i] == '0':
            ans.append(i)
            pos -= i
            break
    if pos == prev:
        ans = [-1]
        break
    prev = pos
print(*ans[::-1])


Measured memory_bytes: 6372
#include <iostream>
using namespace std;
static const int MAX = 100005;
static const int NIL = -1;

struct Node {int p; int l; int r; };

Node T[MAX];
int n, D[MAX];

void print(int u)
{
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].p << ", ";
    cout << "depth = " << D[u] << ", ";

    if (T[u].p == NIL) cout << "root, ";
    else if (T[u].l == NIL) cout << "leaf, ";
    else cout << "internal node, ";

    cout << "[";

    int i = T[u].l;

    while (i != NIL)
    {
        cout << i;
        i = T[i].r;
        if (i != NIL) cout << ", ";
    }

    cout << "]" << endl;
}

void setDepth(int u, int p)
{
    D[u] = p;
    if (T[u].r != NIL) setDepth(T[u].r, p);
    if (T[u].l != NIL) setDepth(T[u].l, p+1);
}

int main()
{
    int u, c, l, d, r;
    cin >> n;

    for (int i = 0; i != n; ++i)
    {
        T[i].p = T[i].l = T[i].r = NIL;
    }

    for (int i = 0; i != n; ++i)
    {
        cin >> u >> d;
        for (int j = 0; j != d; ++j)
        {
            cin >> c;
            if (j == 0) T[u].l = c;
            else T[l].r = c;
            l = c;
            T[c].p = u;
        }
    }

    for (int i = 0; i != n; ++i)
    {
        if (T[i].p == NIL) r = i;
    }

    setDepth(r, 0);

    for (int i = 0; i != n; ++i)
    {
        print(i);
    }

    return 0;
}


Measured memory_bytes: 7764
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(_,v.size())cout<<" "<<v[_];cout<<endl;
#define show2d(v) rep(_,v.size()){rep(__,v[_].size())cout<<" "<<v[_][__];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,1,-1,1,-1};//RDLU
int main(){
	ll a,b;
	cin>>a>>b;
	ll out=(a/b)*(a/b)*(a/b);
	if(b%2==0)out+=(a/(b/2)-a/b)*(a/(b/2)-a/b)*(a/(b/2)-a/b);
	cout<<out<<endl;
}







Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;

struct UnionFind {
    vector<int> par, rank;

    UnionFind(int N) : par(N), rank(N) {
        rep(i, N) par[i] = i, rank[i] = 0;
    }

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

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        if (rank[rx] < rank[ry]) {
            par[rx] = ry;
        }
        else {
            par[ry] = rx;
            if (rank[rx] == rank[ry]) rank[rx]++;
        }
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main()
{
    int N, M, K;
    cin >> N >> M >> K;
    UnionFind tree(N);

    vector<int> F[N], B[N];

    rep(i, M) {
        int A, B;
        cin >> A >> B;
        A--; B--;
        tree.unite(A, B);
        F[A].push_back(B);
        F[B].push_back(A);
    }

    rep(i, K) {
        int C, D;
        cin >> C >> D;
        C--; D--;
        B[C].push_back(D);
        B[D].push_back(C);
    }

    vector<int> tree_cnt(N, 0);
    rep(i, N) {
        tree_cnt[tree.root(i)]++;
    }

    rep(i, N) {
        int ans = tree_cnt[tree.root(i)] - 1;
        ans -= (int)F[i].size();
        rep(j, B[i].size()) {
            if (tree.same(i, B[i][j])) ans--;
        }
        if (i == N - 1) cout << ans << endl;
        else cout << ans << " ";
    }
    return 0;
}

Measured memory_bytes: 13048
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <sstream>
#include <cstdio>

using namespace std;
int main()
{
    int n;
    string str;
    cin >> n;
    cin.get();
    for(int i=0;i<n;++i)
    {
        int loc;
        getline(cin, str);
        loc = str.find("Hoshino",0);
        while(loc!=string::npos)
        {
            str[loc+6] = 'a';
            loc = str.find("Hoshino",0);
        }
        cout << str << endl;
    }
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b && b==c) cout<<"No"<<endl;
    else if(a!=b && b!=c && c!=a) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}

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

#define LL long long
#define RG register

using namespace std;
template<class T> T gi() {
	T x = 0; bool f = 0; char c = getchar();
	while (c != '-' && (c < '0' || c > '9')) c = getchar();
	if (c == '-') f = 1, c = getchar();
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f ? -x : x;
}
const int N = 310;
int n, K, Mod, f[N][N], sum[N][N], C[N][N];
int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	n = gi<int>(), K = gi<int>(), Mod = gi<int>();
	for (int i = 0; i <= K; i++) f[1][i] = 1;
	for (int i = K; i >= 0; i--) sum[1][i] = (sum[1][i + 1] + f[1][i]) % Mod;
	for (int i = 0; i <= n; i++) C[i][0] = 1;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= i; j++)
			C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % Mod;
	for (int i = 2; i <= n + 1; i++) {
		for (int j = 0; j <= K; j++)
			for (int k = 1; k < i; k++)
				(f[i][j] += 1ll * f[i - k][j] * sum[k][j + 1] % Mod * C[i - 2][k - 1] % Mod) %= Mod;
		for (int j = K; j >= 0; j--)
			sum[i][j] = (sum[i][j + 1] + f[i][j]) % Mod;
	}
	printf("%d\n", f[n + 1][0]);
	return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int n, m;
	cin >> n >> m;
	
	vector<int> a(m);
	vector<bool> ok(n, true);
	for(int i = 0; i < m; ++i) {
		cin >> a[i];
		ok[a[i]] = false;
	}
	
	vector<ll> dp(n + 10, 0);
	dp[0] = 1;
	
	for(int i = 0; i < n; ++i) {
		if( ok[i + 1] ) {
			dp[i + 1] += dp[i];
			dp[i + 1] %= MOD_LL;
		}
		
		if( ok[i + 2] ) {
			dp[i + 2] += dp[i];
			dp[i + 2] %= MOD_LL;
		}
	}
	
	cout << dp[n] << endl;
	
	return 0;
}


Measured memory_bytes: 4420
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long
#define ld long double
#define fs(i,k,n,s) for (i=k;i<n;i+=s)
#define f(i,k,n) for (i=k;i<n;i++)
#define rf(i,n,k) for (i=n;i>=k;i--)
#define rfs(i,n,k,s) for (i=n;i>=k;i-=s)
#define fc(it,a) for (auto it=a.begin();it!=a.end();it++)
#define all(a) a.begin(),a.end()
#define mkp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define F first
#define S second
#define set(a,b) memset(a,b,sizeof(a))
#define M 1000000007
#define pll pair<ll,ll>
#define plll pair<ll,pll>
#define p(a,b) pair<a,b>
#define v(a) vector<a>
#define m(a,b) map<a,b>
#define um(a,b) unordered_map<a,b>
#define s(a) set<a>
#define ms(a) multiset<a>
#define lb(a,b) lower_bound(all(a),b)
#define ub(a,b) upper_bound(all(a),b)
#define test() int t;cin >> t;while(t--)
#define TakeInput freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
 
using namespace std;
 
ll gcd(ll a, ll b) {  if (a == 0)  return b; return gcd(b % a, a); }
ll lcm(ll a,ll b) {return (a*b)/gcd(a,b);}
ll power(ll x, ll y)
{
    if (y == 0)
        return 1;
    else if (y % 2 == 0)
        return power(x, y / 2) * power(x, y / 2);
    else
        return x * power(x, y / 2) * power(x, y / 2);
}

int main()
{
	#ifndef ONLINE_JUDGE
	//TakeInput
	#endif
	fast;
	ll a[3][3],i,j,k;
	f(i,0,3)
	{
		cin >> a[i][0] >> a[i][1] >> a[i][2]; 
	}
	ll n,no;
	cin >> n;
	int col[3],row[3],dia1=0,dia2=0;
	bool b[3][3];
	set(b,false);
	set(col,0);
	set(row,0);
	f(i,0,n)
	{
		cin >> no;
		f(j,0,3)
		{
			f(k,0,3)
			{
				if (a[j][k] == no)
				{
					row[j]++;
					col[k]++;
					if (j==k)
						dia1++;
					if (j==0&&k==2 || j==1&&k==1 || j==2&&k==0)
						dia2++;
				}
			}
		}
	}
	f(i,0,3)
	{
		if (row[i] == 3)
		{
			cout << "Yes" << endl;
			goto jump;
		}
	}
	f(i,0,3)
	{
		if (col[i] == 3)
		{
			cout << "Yes" << endl;
			goto jump;
		}	
	}
	if (dia1 == 3)
	{
		cout << "Yes" << endl;
		goto jump;
	}
	if (dia2 == 3)
	{
		cout << "Yes" << endl;
		goto jump;
	}
	cout << "No" << endl;
	jump:;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int m,a,r,c,h;
ll D[5];
// C(5,3) = 10
int P [10]={0 ,0 ,0 ,0 ,0 ,0 ,1 ,1 ,1 ,2};
int Q [10]={1 ,1 ,1 ,2 ,2 ,3 ,2 ,2 ,3 ,3};
int R [10]={2 ,3 ,4 ,3 ,4 ,4 ,3 ,4 ,4 ,4};

int main() {
    int n;
    cin >> n;
    rep(i,n) {
        string s;
        cin >> s;
        if (s[0] == 'M') ++m;
        if (s[0] == 'A') ++a;
        if (s[0] == 'R') ++r;
        if (s[0] == 'C') ++c;
        if (s[0] == 'H') ++h;
    }
    D[0] = m;
    D[1] = a;
    D[2] = r;
    D[3] = c;
    D[4] = h;
    ll ans = 0;
    rep(i,10) ans += D[P[i]]*D[Q[i]]*D[R[i]];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;


int main()
{
	FAST;
	string o,e;
	cin >> o >> e;

	for(int i=0 ; i<o.size() ; i++)
	{
	    cout << o[i];
	    if(i < e.size())
	        cout << e[i];
	}
	return 0;
}

Measured memory_bytes: 256