akhauriyash/Code-Regression huggingface dataset:
p = 10**9+7
def nCr(n,r):
    if r*2>n:
        return nCr(n,n-r)
    else:
        a = b = 1
        for i in range(r):
            a = a * (n - i) % p
            b = b * (r - i) % p
        return (a * pow(b,p-2,p)) % p

x, y = map(int, input().split())

if (2*x-y) % 3 == 0 and (2*y-x) % 3 == 0 and (2*x-y)>=0 and (2*y-x)>=0:
    b = (2*x-y)//3
    a = x-2*b
else:
    print(0)
    exit()

print(int(nCr(a+b, a)))


Measured memory_bytes: 3064
from queue import Queue

def dfs(x,y,c):
    que = Queue()
    que.put((x, y))

    while not que.empty():
        x, y = que.get()
        if c[x][y] == 0:
            continue

        c[x][y] = 0
        for dx in range(-1, 2):
            for dy in range(-1, 2):
                sx, sy = x + dx, y + dy
                if sx < 0 or sx >= h or sy < 0 or sy >= w:
                    continue
                que.put((sx, sy))
    return c

while True:
    w,h = map(int,input().split())
    if w == h == 0:
        break
    wh = w * h
    c = [list(map(int,input().split())) for _ in range(h)]
    ans = 0
    for x in range(h):
        for y in range(w):
            if c[x][y] == 0:
                continue
            ans += 1
            c = dfs(x,y,c)
    print(ans)


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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

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

int x[2],y[2],w[2],h[2];
int R;
vector<vvi> zimu;

void dfs(int i, int x, int y, vvi used, vector<pair<int,int>>& list){

  priority_queue< pair<int,pii>, vector<pair<int,pii> >,greater<pair<int,pii> > > que;
  que.push(pair<int,pii>(1,pii(x,y)));

  int auth = 0;
  int room = 0;
  while(que.size()){
    int corr_lev = que.top().first;
    int corr_x = que.top().second.first;
    int corr_y = que.top().second.second;
    que.pop();
    if( used[corr_y][corr_x] == 1) continue;
    used[corr_y][corr_x] = 1;
    
    if(corr_lev > auth){
      list.push_back(pii(room,auth));
      auth = corr_lev;
    }
    room++;
    if( room == w[i]*h[i] ) break;


    for(int j=0; j<4; j++){
      int nx = corr_x + dx[j];
      int ny = corr_y + dy[j];
      if(nx >= w[i] || nx < 0 || ny >= h[i] || ny < 0) continue; // ????£?
      if(used[ny][nx] == 1) continue; // ??¢?´¢??????
      que.push( pair<int,pii>(zimu[i][ny][nx],pii(nx,ny)) );
    }
  }
  list.push_back(pii(room,auth));
}

int main(){
  while(1){
  
    cin >> R; if(!R) break;
    zimu.clear();
    
    // ??\???
    for(int i=0; i<2; i++){
      cin >> w[i] >> h[i] >> x[i] >> y[i];
  
      zimu.push_back(vvi(h[i],vi(w[i])));

      for(int j=0; j<h[i]; j++)
	for(int k=0; k<w[i]; k++)
	  cin >> zimu[i][j][k];
    }

    // 
    vector<vector<pair<int,int> > > list(2); // ???????????¨?±???°???????¨???¬??????
    
    for(int i=0; i<2; i++){
      list[i].push_back(pii(0,0));
      vvi used(h[i],vi(w[i],0));
      dfs(i, x[i]-1, y[i]-1, used, list[i]);
    }

    int ans = 1e+9;
    for(int i=0; i<list[0].size(); i++){
      int rooma = list[0][i].first;
      int autha = list[0][i].second;
      pii tmp = *lower_bound(list[1].begin(),list[1].end(), pii(R-rooma,0));
      int roomb = tmp.first;
      int authb = tmp.second;
      if(rooma + roomb < R) continue;
      ans = min(ans,autha + authb);
    }
    cout << ans << endl;

  }
}

Measured memory_bytes: 10520
#include <bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 32);
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i, r, n) for (ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i, r, n) for (ll i = (ll)(n - 1); i >= r; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define RALL(x) x.rbegin(), x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll>> vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/

map<ll, ll> a, b;

int main()
{
    cin >> n;
    vi v(n);
    REP(i, n)
    {
        cin >> v[i];
        a[v[i]]++;
    }
    cin >> m;
    vi vv(m);
    REP(i, m)
    {
        cin >> vv[i];
    }

    for (auto x : vv) {
        if (a[x] == 0) {
            cout << "NO" << endl;
            return 0;
        }
        a[x]--;
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 15872
#include <iostream>
#include <vector>
using namespace std;
int MOD = 1000000007; 
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<long long> b(n+1, 0);
  for(int i=0;i<n;i++) {
    cin >> a[i];
    b[i+1] = a[i] + b[i];
  }
  
  long long ans=0;
  long long sum;
  for(int i=0;i<n;i++) {
    sum = (b[n] - b[i+1]) % MOD;
    ans += a[i] * sum;
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}

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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = (a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (a); i <= (long long)(n); i++)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<double> v_double;
typedef std::vector<std::vector<double> > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<std::vector<bool> > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std; 

set<v_ll> vecs;

void dfs(int n, int m, ll i, int k, v_ll v)
{
    if((int)v.size() == n || i > m) { 
        if((int)v.size() == n) { vecs.insert(v); }
        return; 
    }
    dfs(n, m, i+1, k, v);  

    v.push_back(i);
    dfs(n, m, i, k+1, v);  
    v.pop_back();
    //v.erase(v.end());

    v.push_back(i);
    dfs(n, m, i+1, k+1, v);  
    v.pop_back();
    //v.erase(v.end());

    return ;
}

int main(void)
{
    int n, m, q;
    cin >> n >> m >> q;

    v_int a(q), b(q), c(q);
    v_ll d(q);
    irep(i, q) {
        cin >> a[i];
        cin >> b[i];
        cin >> c[i];
        cin >> d[i];
        a[i]--; 
        b[i]--;     
    }

    v_ll v;
    dfs(n, m, (ll)1, 0, v);

    ll ans = -1;
    for(auto array : vecs) {
        v_ll vec = array;
        ll sum = 0;
        irep(j, q) {
            if(vec[b[j]] - vec[a[j]] == c[j]) {
                sum += d[j]; 
            }
        }
        if(sum) {
            ans = max(ans, sum);
        }
    }
    if(ans == -1) {
        cout << 0 << endl;
    } else {
        cout << ans << endl;
    }
    return 0;
}
/** atcoder **/


Measured memory_bytes: 18028
#include<iostream>
using namespace std;
long long n,a[111],dp[111][2],p;
int main()
{
	cin>>n>>p;
	for (int i=1;i<=n;i++) cin>>a[i];
	dp[0][0]=1;
	for (int i=1;i<=n;i++)
	{
		for (int j=0;j<=1;j++)
		{
			if (a[i]%2)
			{
				dp[i][j]=dp[i-1][1-j]+dp[i-1][j];
			}
			else dp[i][j]=2*dp[i-1][j];
		}
	}
	cout<<dp[n][p]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if(a>b)
    {
        printf("a > b\n");
    }
    else if(a<b)
    {
        printf("a < b\n");
    }
    else
    {
        printf("a == b\n");
    }
    return 0;
}



Measured memory_bytes: 2036
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
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 (a>b) { a = b; return 1; } return 0; }
// }}} End Header


int main() {
	string s;
	cin >> s;
	if(s[s.size()-1] == 's') cout << s << "es" << endl;
	else cout << s << "s" << endl;
	return 0;
}


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}

ll N, A, B, C, D;
map<ll, ll> memo;
ll dfs(ll n) {
	if (n == 0) return (0);
	if (n == 1) return (D);
	if (n == 2) return (min(2*D, D+A));
	if (memo.find(n) != memo.end()) return (memo[n]);
	__int128 ret = (__int128)D*n;
	chmin(ret, dfs(n/2) + (n%2)*D + A);
	chmin(ret, dfs(n/2+1) + (2-(n%2))*D + A);
	chmin(ret, dfs(n/3) + (n%3)*D + B);
	chmin(ret, dfs(n/3+1) + (3-(n%3))*D + B);
	chmin(ret, dfs(n/5) + (n%5)*D + C);
	chmin(ret, dfs(n/5+1) + (5-(n%5))*D + C);
	//cout << n << " " << (ll)ret << endl;
	return (memo[n] = (ll)ret);
}

void solve() {
	cin >> N >> A >> B >> C >> D;
	cout << dfs(N) << endl;
}

void Main() {
	int T; cin >> T;
	while (T--) {
		solve();
		memo.clear();
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 4720
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    long long wa[n+1],rev[n+1];
    wa[0]=0,rev[n]=0;
    for(int i=1;i<=n;i++){
        wa[i]=wa[i-1]+a[i-1];
        rev[n-i]=rev[n-i+1]+a[n-i];
    }
    long long ans=1000000000000000000;
    for(int i=2;i<n-1;i++){
        auto cut1=upper_bound(wa,wa+n+1,wa[i]/2)-wa,cut2=upper_bound(rev,rev+n+1,rev[i]/2,greater<long long>())-rev;
        long long p1,p2,q1,q2,r1,r2,s1,s2;
        p1=wa[cut1],q1=wa[i]-wa[cut1],r1=rev[i]-rev[cut2],s1=rev[cut2];
        p2=wa[cut1-1],q2=wa[i]-wa[cut1-1],r2=rev[i]-rev[cut2-1],s2=rev[cut2-1];
        ans=min({
                max({p1,q1,r1,s1})-min({p1,q1,r1,s1}),
                max({p1,q1,r2,s2})-min({p1,q1,r2,s2}),
                max({p2,q2,r1,s1})-min({p2,q2,r1,s1}),
                max({p2,q2,r2,s2})-min({p2,q2,r2,s2}),
                ans
            }
        );
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 7468
a, b, c, x, y = list(map(int, input().split(" ")))
if x >= y:
    n_c = 2 * x
else:
    n_c = 2 * y

ans = c * n_c

for v in range(n_c):
    n_a = - (-(x - v/2)//1)
    n_b = - (-(y - v/2)//1)
    if n_a < 0:
        n_a = 0
    if n_b < 0:
        n_b = 0
    m = a * n_a + b * n_b + c * v
    if ans > m:
        ans = m
        
print(int(ans))

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	if (n%2==0) cout<<n/2;
	else cout<<(n/2)+1; 
	return 0;
}


Measured memory_bytes: 256
/*
* welcome to my code!
* ------------------------------------------
* author : lynmisakura(twitter : @andoreiji11)
*/

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

using ll = long long;

#define REP(i,n) for(int i = 0;i < n;i++)
#define all(x) x.begin(),x.end()
#define dup(x,y) (x + y - 1)/y
#define sz(v) (int)v.size()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

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

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

    int64_t m,k;cin >> m >> k;

    if(k >= (1LL << m)){
       cout << -1 << '\n';
       return 0;
    }

    if(m == 0){
        cout << "0 0" << '\n';
        return 0;
    }else if(m == 1){
        if(k == 1){
            cout << -1 << '\n';
        }else{
            cout << "0 0 1 1" << '\n';
        }
    }else{
        REP(i,(1LL << m))if(i != k)cout << i << ' ';
        cout << k << ' ';
        REP(i,(1LL << m))if((1LL << m) - 1 - i != k)cout << (1LL << m) - 1 - i << ' ';
        cout << k << '\n';
    }

}


Measured memory_bytes: 3608
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner src = new Scanner(System.in);
			int a = src.nextInt();
			int b = src.nextInt();
			int c = src.nextInt();

			if((a < b) && (b < c)){
				System.out.println("Yes");
			}else {
				System.out.println("No");
			}
		}
}


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

int main(){
    string s,t;
    cin>>s>>t;
    ll int n = s.length();
    ll int m = t.length();
    ll int dp[n+1][m+1];
    memset(dp,0,sizeof(dp));
    for(ll int i = 1;i<=n;i++){
        for(ll int j =1;j<=m;j++){

            if(s[i-1]==t[j-1]){
                dp[i][j] = 1+dp[i-1][j-1];
            }
            else{
                dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    string ans = "";
    ll int i = n;
    ll int j = m;
    while(i>0 && j>0){
        if(s[i-1]==t[j-1]){
            ans+=s[i-1];
            i--;
            j--;
        }
        else{
            if(dp[i-1][j]>dp[i][j-1]){
                i--;
            }
            else{
                j--;
            }
        }
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;

}






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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n";
#define size 105
#define max_1 100005

long long N, W, w[size], v[size], dp[size][max_1], rnd;

int main() {
    //int N, W, w[size], v[size], dp[size][max_1], rnd;

    cin >> N >> W;

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

    for(int i=0; i<=W; i++) {
        dp[0][i] = 0; 
    }

    for(int i=1; i<=N; i++) {
        for(int j=0; j<=W; j++) {
            if(w[i] > j)
                dp[i][j] = dp[i-1][j];
            else
            {
                dp[i][j]= max(dp[i-1][j], dp[i-1][j-w[i]]+v[i]);
            }         
        }
    }

    cout << dp[N][W] << endl;
    
}

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

int n;
int a[100000];
vector<P> keys;	//(key, index)
int sig[100000];
int ans[100000];

int _sig(int id) { if (id == -1) return 0; return sig[id]; }

signed main() {
	int i;
	
	cin >> n;
	rep(i, n) cin >> a[i];
	rep(i, n) keys.push_back(P(a[i], i));
	sort(keys.begin(), keys.end());
	rep(i, n) {
		if (i == 0) { sig[keys[i].second] = keys[i].first * n; continue; }
		sig[keys[i].second] = sig[keys[i - 1].second] + (n - i) * (keys[i].first - keys[i - 1].first);
	}
	
	//rep(i, n) cout << "sig = " << sig[i] << endl;
	
	int id = -1;
	rep(i, n) {
		if (id == -1 || sig[id] < sig[i]) {
			ans[i] = sig[i] - _sig(id);
			id = i;
		}
	}
	
	rep(i, n) { cout << ans[i] << endl; }
	return 0;
}

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

using namespace std;

void solve()
{
    int n;
    cin >> n;
    vector<int> xs(n + 1);
    for (int i = 0; i < n; i++)
    {
        int p;
        cin >> p;
        xs[p] = i + 1;
    }
    multiset<int> id;
    id.insert(0);
    id.insert(0);
    id.insert(n + 1);
    id.insert(n + 1);
    long ans = 0;
    for (int p = n; p > 0; p--)
    {
        id.insert(xs[p]);
        auto it = id.find(xs[p]);
        auto itne = next(it);
        auto itpr = prev(it);
        long res = 0;
        res += 1L * (*itpr - *prev(itpr)) * (*itne - xs[p]);
        res += 1L * (xs[p] - *itpr) * (*next(itne) - *itne);
        //cout << res << endl;
        res *= p;
        ans += res;
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 5376
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>
#include <bitset>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

void solve() {
    ll n, q;
    cin >> n >> q;
    ll h = n, w = n;
    ll ans = (n - 2) * (n - 2);
    vll a(n + 1, n), b(n + 1, n);
    while(q--) {
        int t, x;
        cin >> t >> x;
        if(t == 1) {
            if(x < w) {
                for(int i = x; i <= w; ++i) b[i] = h;
                w = x;
            }
            ans -= b[x] - 2;
        }
        else {
            if(x < h) {
                for(int i = x; i <= h; ++i) a[i] = w;
                h = x;
            }
            ans -= a[x] - 2;
        }
    }
    cout << ans << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 6348
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
    // AtCoder
    // template
    ll n;
    cin >> n;
    ll cnt = 2;
    map<ll, ll> mp;
    for(size_t i = 2; i < n + 1; i++) {
        ll tmp;
        cin >> tmp;
        mp[tmp]++;
    }
    rep(i, n) {
        if(mp.count(i + 1) == 0)
            cout << 0 << endl;
        else
            cout << mp.at(i + 1) << endl;
    }
}


Measured memory_bytes: 16060
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T & a, U & ... b) { cin >> a; IN_(b ...); };
template<typename T> void OUT(T && a) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

class UnionFind {
private:
	int n, s;
	vector<int> t;
	vector<vector<int>> v;
public:
	UnionFind(int arg_n = 0) { init(arg_n); }
	void init(int arg_n) {
		n = s = arg_n;
		t.clear();
		v.clear();
		inc(i, n) { t.PB(i); v.EB(1, i); }
	}
	int get_n() { return n; }
	int size() { return s; }
	int id(int x) { return t.at(x); }
	const vector<vector<int>> & get_v() { return v; }
	bool unite(int x, int y) {
		x = id(x);
		y = id(y);
		if(x == y) { return false; }
		if(v[x].size() < v[y].size()) { swap(x, y); }
		for(auto & e: v[y]) { v[x].PB(e); t[e] = x; }
		v[y].clear();
		s--;
		return true;
	}
	bool same(int x, int y) { return (id(x) == id(y)); }
	const vector<int> & operator[](int x) { return v[id(x)]; }
	friend ostream & operator<<(ostream & os, const UnionFind & uf) {
		inc(i, uf.n) { os << i << ": "; for(auto & e: uf.v[i]) { os << e << " "; } os << "\n"; }
		return os;
	}
};

// ---- ----

template<typename T> istream & operator>>(istream & s, vector<T> & v) { RF(e, v) { s >> e; } return s; }
template<typename T> ostream & operator<<(ostream & s, vector<T> const & v) {
	inc(i, SI(v)) { s << (i == 0 ? "" : " ") << v[i]; }
	return s;
}

int main() {
	IN(int, n, m, k);
	UnionFind uf(n);
	vector<int> ans(n);
	inc(i, m) {
		IN(int, a, b);
		a--; b--;
		uf.unite(a, b);
		ans[a]--;
		ans[b]--;
	}
	inc(i, k) {
		IN(int, c, d);
		c--; d--;
		if(uf.same(c, d)) {
			ans[c]--;
			ans[d]--;
		}
	}
	inc(i, n) { ans[i] += SI(uf[i]) - 1; }
	
	OUT(ans);
}


Measured memory_bytes: 8368
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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

	
	int N;
	cin >> N;

	ll A = 1, B = 1;

	rep(i, N) {
		ll a, b;
		cin >> a >> b;
		double C, c;
		C = 1.0 * A / B;
		c = 1.0 * a / b;
		if (C < c) {
			B = b * ((B + b - 1) / b);
			A = a * ((B + b - 1) / b);
		}
		else {
			B = b * ((A + a - 1) / a);
			A = a * ((A + a - 1) / a);
		}
	}
	co(A + B);

	Would you please return 0;
}

Measured memory_bytes: 256
from _collections import deque


def parser():
    while 1:
        data = list(input().split(' '))
        for number in data:
            if len(number) > 0:
                yield (number)


input_parser = parser()


def gw():
    global input_parser
    return next(input_parser)


def gi():
    data = gw()
    return int(data)


MOD = int(1e9 + 7)

import numpy
from collections import deque
from math import sqrt
from math import floor
# https://atcoder.jp/contests/arc081/tasks/arc081_b
# D - Coloring Dominoes
"""
need to consider the case that ticket is not enough to lower everything
"""

N = gi()
K = gi()
S = gw()

seg_ps = []

seg_ps.append(0)

cl = 1
cur = S[0]

for i in range(1, len(S)):
    if (S[i] == S[i - 1]):
        cl += 1
    else:
        tail = seg_ps[-1]
        seg_ps.append(tail + cl)
        cur = S[i]
        cl = 1

seg_ps.append(seg_ps[-1] + cl)

ans = 0

start1 = S[0] == '1'

for i in range(1, len(seg_ps)):
    is1 = 0
    if start1:
        is1 = i % 2
    else:
        is1 = (i + 1) % 2
    if is1:
        si = max(0, i - 2 * K - 1)
    else:
        si = max(0, i - 2 * K)
    ans = max(ans, seg_ps[i] - seg_ps[si])

print(ans)


Measured memory_bytes: 21348
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

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

    int n;
    cin>>n;
    map<int,int> mp;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        mp[a]++;
    }
    int m;
    cin>>m;
    bool ans=true;
    for(int i=0;i<m;i++){
        int a;
        cin>>a;
        if(mp[a]==0)ans=false;
        else mp[a]--;
    }
    if(ans)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;

}

Measured memory_bytes: 9600
//
//  main.cpp
//  atcoder-subtree
//
//  Created by r on 6/8/19.
//  Copyright © 2019 r. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <fstream>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <stack>
#include <queue>
#include <assert.h>
#include <limits>
#include <cstdio>
using namespace std;

//#define RDEBUG 1
#ifdef RDEBUG
#define D(x) x
#else
#define D(x)
#endif
#define inf 0x7fffffff

typedef long long ll;

ll MOD;

long long add(long long a, long long b) {
    a += b;
    if(a >= MOD) {
        a -= MOD;
    }
    return a;
}
long long sub(long long a, long long b) {
    a -= b;
    if(a < 0) {
        a += MOD;
    }
    return a;
}
void add_self(long long& a, long long b) {
    a = add(a, b);
}
void sub_self(long long& a, long long b) {
    a = sub(a, b);
}

ll N, dp2[100010], par[100010];
pair<ll, ll> dp[100010];
vector<ll> adj[100010];

void f(ll u, ll p) {
    dp[u] = {1,1};
    for (ll v:adj[u]) {
        if (v != p) {
            f(v, u);
            dp[u].first = (dp[u].first*add(dp[v].first, dp[v].second))%MOD;
            dp[u].second = (dp[u].second*dp[v].second)%MOD;
        }
    }
}

void process(ll u, ll p, ll curr) {
    dp[u].first = (dp[u].first*curr)%MOD;
    ll currprod = 1;
    vector<ll> pprod, sprod(adj[u].size());
    for (ll v: adj[u]) {
        if (v == p) {
            currprod=(currprod*curr)%MOD;
            pprod.push_back(currprod);
            continue;
        }
        currprod=currprod*add(1, dp[v].first)%MOD;
        pprod.push_back(currprod);
    }
    currprod = 1;
    for (ll i = adj[u].size()-1; i>=0; i--) {
        if (adj[u][i] == p) {
            currprod = (currprod*curr)%MOD;
            sprod[i] = currprod;
            continue;
        }
        currprod=currprod*add(1, dp[adj[u][i]].first)%MOD;
        sprod[i] = currprod;
    }
    for (int i = 0; i<adj[u].size(); i++) {
        if (adj[u][i] == p) {
            continue;
        }
        ll v = adj[u][i];
        ll L, R;
        if (i == 0) {
            L = 1;
        } else {
            L = pprod[i-1];
        }
        if (i == adj[u].size()-1) {
            R = 1;
        } else {
            R = sprod[i+1];
        }
        process(v, u, add(1, (L*R)%MOD));
    }
}

int main() {
    ios_base :: sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> N >> MOD;
    for (int i = 0; i<N-1; i++) {
        ll a, b;
        cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    f(1, 0);
    process(1, 0, 1);
    for (int i = 1; i<=N; i++) {
        cout << dp[i].first << endl;
    }
    return 0;
}





Measured memory_bytes: 22272
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define pb push_back
#define sz(x) (int)(x).size()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;


int main() {
  string s;
  cin >> s;
  if(s<="2019/04/30"){
    cout << "Heisei" << endl;
  }
  else cout << "TBD" << endl;
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n,m;
    string s,t;
    cin>>n>>m>>s>>t;
    if(n<m){
        swap(n,m);
        swap(s,t);
    }
    int g=__gcd(n,m);
    int l=n/g*m;
    rep(i,m){
        int a=i*(l/m);
        int b=a/(l/n);
        if(a%(l/n))continue;
        if(s[b]!=t[i]){
            cout<<-1<<endl;
            return;
        }
    }
    cout<<l<<endl;
}

Measured memory_bytes: 640
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    n: usize,
    a: [i32; n],
  }
  let mut ans = vec![false; n];
  for (i, &x) in a.iter().enumerate().rev() {
    let j = i + 1;
    let mut even = true;
    let mut k = j * 2;
    while k <= n {
      if ans[k-1] {
        even = ! even;
      }
      k += j;
    }
    if (x == 0) != even {
      ans[i] = true;
    }
  }
  let ans: Vec<_> = ans.into_iter().enumerate().filter(|&(_, f)| f).map(|(i, _)| i + 1).collect();
  puts!("{}\n", ans.len());
  for &x in &ans {
    puts!("{} ", x);
  }
  puts!("\n");
}


Measured memory_bytes: 7164
n=int(input())
A=list(map(int,input().split()))
mod=10**9+7
def lcm(X,Y):
    x=X
    y=Y
    if y>x:
        x,y=y,x
    while x%y!=0:
        x,y=y,x%y
    return X*Y//y

cnt=0
ans=0
LCM=1
for i in range(n):
    Q=lcm(LCM,A[i])
    cnt*=Q//LCM
    LCM=Q
    cnt+=Q//A[i]
print(cnt%mod)

Measured memory_bytes: 9728
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

int INF = INT_MAX / 2;

vector<pair<int, int>> ps;
vector<int> qs;
vector<int> rs;

int main(void) {
    int N;
    cin >> N;

    ps.resize(N);
    qs.resize(N);
    rs.resize(N);
    for (int i = 0; i < N; i++) {
        int x, y;
        cin >> x >> y;
        ps[i] = make_pair(x, y);
        qs[i] = x + y;
        rs[i] = x - y;
    }

    int max_qs = *max_element(qs.begin(), qs.end());
    int min_qs = *min_element(qs.begin(), qs.end());
    int max_rs = *max_element(rs.begin(), rs.end());
    int min_rs = *min_element(rs.begin(), rs.end());

    cout << max(max_qs - min_qs, max_rs - min_rs) << endl;

    return 0;
}


Measured memory_bytes: 6364
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long int lli;

int main() {
	int c[3][3];
		cin >> c[0][0] >> c[0][1] >> c[0][2];
	cin >> c[1][0] >> c[1][1] >> c[1][2];
	cin >> c[2][0] >> c[2][1] >> c[2][2];

	c[1][0] -= c[0][0];
	c[1][1] -= c[0][1];
	c[1][2] -= c[0][2];
	c[2][0] -= c[0][0];
	c[2][1] -= c[0][1];
	c[2][2] -= c[0][2];

	if (c[1][0] == c[1][1] && c[1][0] == c[1][2] && c[2][0] == c[2][1] && c[2][0] == c[2][2]) cout << "Yes";
	else cout<<"No";
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()

int main() {
  int n;
  cin >> n;
  ll cnt[5] = {0};
  char start[5] = {'M', 'A', 'R', 'C', 'H'};
  rep(i, n) {
    string s;
    cin >> s;
    rep(j, 5) {
      if (s[0] == start[j]) {
        cnt[j]++;
      }
    }
  }
  // rep(j, 5) cout << cnt[j] << endl;
  ll ans = 0;
  rep(i, 5) {
    REP(j, i + 1, 5) {
      REP(k, j + 1, 5) { ans += cnt[i] * cnt[j] * cnt[k]; }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 888
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

n,k = MI()
a = LI()

b = [0]
visited = [0]*n
for _ in range(n):
    if visited[a[b[-1]]-1] == 1:
        break
    visited[a[b[-1]]-1] = 1
    b.append(a[b[-1]]-1)
first = b.index(a[b[-1]]-1)
second = len(b)
if k <= first:
    print(b[k]+1)
else:
    print(b[(k-first)%(second-first)+first]+1)


Measured memory_bytes: 32256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
const ll mod = 1e9 + 7;
ll powmod(ll a, ll b) { ll res=1; a%=mod; assert(b>=0); for(;b;b>>=1) { if(b&1) res=res*a%mod; a=a*a%mod; } return res; }
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }

int main() {
	int t;
	// cin >> t;
    t = 1;

	while(t--) {
		int n;
		cin >> n;
        
        string s;
        map<string, int> mpp;
        for(int i = 0; i < n; i++) {
            cin >> s;
            ++mpp[s];
        }
            
        cout << "AC x " << mpp["AC"] << endl;
        cout << "WA x " << mpp["WA"] << endl;
        cout << "TLE x " << mpp["TLE"] << endl;
        cout << "RE x " << mpp["RE"] << endl;
	}

	return 0;
}

Measured memory_bytes: 3552
#include <iostream>
#include <cstdio>

using namespace std;

void swap(int *x, int *y){
	int tmp=*x;
	*x=*y;
	*y=tmp;
}

int main(){
	long a, b;
	while( scanf(" %ld %ld", &a, &b) != EOF ){
		if(a<b) swap(a,b);
		
		if(b!=0){
			while(b!=0){
				long r=a%b;
				a=b;
				b=r;
			}
		}
		printf("%ld\n", a);
	}
	
	return 0;
}

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

int main() {
  int n;
  cin>>n;
  vector<vector<char>> a(n,vector<char>(10));
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    for(int j=0;j<10;j++){
      a.at(i).at(j)=s.at(j);
    }
    sort(a.at(i).begin(),a.at(i).end());
  }
  sort(a.begin(),a.end());
  long long int p=0;
  long long int q=0;
  for(int i=0;i<n-1;i++){
    if(a.at(i)==a.at(i+1)){
      p++;
    }
    else{
      q+=p*(p+1)/2;
      p=0;
    }
  }
  cout<<q+p*(p+1)/2<<endl;
}

Measured memory_bytes: 5760
#include <stdio.h>
 
int main()
{
    int n;
    long long a[100001];
    long long max = 1000000000000000000;
    long long mul = 1;
 
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%lld", &a[i]);
        if (a[i] == 0)
        {
            printf("0");
            return 0;
        }
    }
 
    for (int i = 0; i < n; i++)
    {
        if (a[i] > max)
        {
            printf("-1");
            return 0;
        }
        mul *= a[i];
        max /= a[i];
 
        
    }
    printf("%lld", mul);
    return 0;
}

Measured memory_bytes: 2504
using System;
using System.Linq;

class B
{
	static void Main()
	{
		Console.ReadLine();
		var h = Console.ReadLine().Split().Select(int.Parse).ToArray();

		var t = h[0];
		var m = h.Select(x => t = Math.Max(t, x)).ToArray();
		Console.WriteLine(1 + Enumerable.Range(1, h.Length - 1).Count(i => h[i] >= m[i - 1]));
	}
}


Measured memory_bytes: 13396
def solve():
    N, K, S = map(int, input().split())
    if S == 10 ** 9:
        ans = [S for _ in range(K)] + [1 for _ in range(N - K)]
    else:
        ans = [S for _ in range(K)] + [S + 1 for _ in range(N - K)]
    print(' '.join(map(str, ans)))


if __name__ == '__main__':
    solve()


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

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (abs(c - a) <= d or (abs(a - b) <= d and abs(b - c) <= d))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
	int a,b;
	int count=0;
	cin>>a>>b;
	for(int i=1;i<=a;i++)
		{
			if(i==a&&a>b)
				continue;
				count++;
		 } 

cout<<count<<endl;
return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()
(r,g,b) = (0,0,0)
for i in s:
	if i == "R":
		r += 1
	elif i == "G":
		g += 1
	else:
		b += 1
a = r*g*b
t = 0
for i in range(n-2):
	for j in range(i+1,n-1):
		if 2*j-i <= n-1 and s[i]!=s[j] and s[j]!=s[2*j-i] and s[2*j-i]!=s[i]:
			t += 1
print (a-t)

Measured memory_bytes: 9172
#include<stdio.h>
#include<string.h>
int main(void){
    char s[4];
    scanf("%s",s);
    if(strcmp(s,"SUN")==0)
    printf("7");
    else if(strcmp(s,"MON")==0)
    printf("6");
    else if(strcmp(s,"TUE")==0)
    printf("5");
    else if(strcmp(s,"WED")==0)
    printf("4");
    else if(strcmp(s,"THU")==0)
    printf("3");
    else if(strcmp(s,"FRI")==0)
    printf("2");
    else if(strcmp(s,"SAT")==0)
    printf("1");
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<stack> 
#include<queue>
#include<cmath>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define ULL unsigned long long
#define N 100100
#define M 5010
#define MOD 1000000007
#define FOR(i,l,r) for (int i = (l); i <= (r); i ++)
#define CLR(a,x) memset(a,x,sizeof(a))
#define INF 0x3f3f3f3f
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define X first
#define Y second
using namespace std;
char st[N],s[N];
int check(char *s){
	int len = strlen(s);
	for (int i = 0; i < len / 2; i ++) if (s[i] != s[len - i - 1]) return 0;
	return 1;
}
int main(){
	scanf("%s",st);
	int len = strlen(st);
	int p = 0,cnt = 0;
	for (int i = 0; i < len; i ++) if (st[i] != 'x') s[p ++] = st[i];
	else cnt ++;
	s[p] = '\0';
	if (check(s)){
		int l = -1,r = len;
		int c = 0;
		while (l < r){
			int i = l + 1,j = r - 1;
			while (st[i] == 'x' && i < r) i ++;
			while (st[j] == 'x' && j > l) j --;
			if (i == r || j == l) c += max(i - l - 1,r - j - 1);
			else c += 2 * max(i - l - 1,r - j - 1);
			l = i;
			r = j;
		}
		printf("%d\n",c - cnt);
	}
	else printf("-1\n");
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<int> bingo(9);
  int N,num;
  for(int i = 0;i < 9;i++){
    cin >> bingo.at(i);
  }
  cin >> N;
  
  for(int i = 0;i < N;i++){
    cin >> num;
     for(int i = 0;i < 9;i++){
    if(num == bingo.at(i)){
      bingo.at(i) = 0;
    }
     }
  }
  if(bingo.at(0) == 0 && bingo.at(1) == 0 && bingo.at(2) == 0){
    cout << "Yes" << endl;
  }else if(bingo.at(0) == 0 && bingo.at(3) == 0 && bingo.at(6) == 0){
    cout << "Yes" << endl;
  }else if(bingo.at(0) == 0 && bingo.at(4) == 0 && bingo.at(8) == 0){
    cout << "Yes" << endl;
  }else if(bingo.at(1) == 0 && bingo.at(4) == 0 && bingo.at(7) == 0){
    cout << "Yes" << endl;
  }else if(bingo.at(2) == 0 && bingo.at(4) == 0 && bingo.at(6) == 0){
    cout << "Yes" << endl;
  }else if(bingo.at(2) == 0 && bingo.at(5) == 0 && bingo.at(8) == 0){
    cout << "Yes" << endl;
  }else if(bingo.at(3) == 0 && bingo.at(4) == 0 && bingo.at(5) == 0){
    cout << "Yes" << endl;
  }else if(bingo.at(6) == 0 && bingo.at(7) == 0 && bingo.at(8) == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
     
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

const ll MOD = 1000000007;

// DPの更新
vector<ll> matmul(vector<ll> &dp, vector<vector<ll>> &mt, int m){
    vector<ll> ret(m,0);
    rep(i,m){
        rep(j,m){
            ret[i] += mt[i][j] * dp[j] % MOD;
            ret[i] %= MOD;
        }
    }
    return ret;
}
// 遷移行列の更新
vector<vector<ll>> update_matmul(vector<vector<ll>> &mt, int m){
    vector<vector<ll>> ret(m, vector<ll>(m,0));
    rep(i,m){
        rep(j,m){
            rep(k,m){
                ret[i][j] += mt[i][k] * mt[k][j] % MOD;
                ret[i][j] %= MOD;
            }
        }
    }
    return ret;
}

void matpow(vector<ll> &dp, vector<vector<ll>> &mt, int m, ll k){
    while(k){
        if(k & 1) dp = matmul(dp, mt, m);
        mt = update_matmul(mt, m);
        k /= 2;
    }
}


int main() {
    int m;
    ll K;
    cin >> m >> K;

    int a[m][m];
    rep(i,m)rep(j,m)cin >> a[i][j];

    vector<ll> dp(m);
    rep(i,m) dp[i] = 1;

    vector<vector<ll>> mt(m,vector<ll>(m));
    rep(i,m)rep(j,m)mt[i][j] = 0;

    /*
        適宜行列mtに値を入れる.
    */

    rep(i,m){
        rep(j,m){
            if(a[j][i] == 1) mt[i][j] = 1;
        }
    }

    matpow(dp, mt, m, K);

    ll ans = 0;

    rep(i,m){
        ans += dp[i];
        ans %= MOD;
    }

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


Measured memory_bytes: 256
use std::io;
use std::io::{Read, BufRead};

fn main() {
    let stdin = io::stdin();
    let mut stdin = stdin.lock();

    let (n, k) = {
        let mut input = String::new();
        stdin.read_line(&mut input).unwrap();
        let mut input = input.trim().split_whitespace();
        (
            input.next().unwrap().parse::<usize>().unwrap(),
            input.next().unwrap().parse::<usize>().unwrap(),
        )
    };

    let s = {
        let mut s = Vec::new();
        let mut input = [ 0u8; 1];
        for i in 0..n {
            stdin.read(&mut input).unwrap();
            if i+1 != k {
                s.push( input[0] );
            } else {
                s.push( input[0]+32 );
            }
        }
        String::from_utf8(s).unwrap()
    };


    println!("{}", s);
}



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

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

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1000000000;
const LL MOD = 1000000007;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

int main() {
  int N;
  cin >> N;
  VI H(N);
  REP(i,N) {
    cin >> H.at(i);
  }
  bool ans = true;
  
  for(int i = N-1; i > 0; --i) {
    if(H.at(i-1) > H.at(i)) {
      H.at(i-1)--;
    }
    if(H.at(i-1) < 0) {
      ans = false;
      break;
    }
    if(H.at(i-1) > H.at(i)) {
      ans = false;
      break;
    }
  }
  if(ans) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  char c;
  while(true){
    cin>>a>>c>>b;
    switch(c){
    case '+':
      cout<<a+b<<endl;
      break;
    case '-':
      cout<<a-b<<endl;
      break;
    case '*':
      cout<<a*b<<endl;
      break;  
    case '/':
      cout<<a/b<<endl;
      break;
    default:
      return 0;    
    }
  }
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair<int, int> pii;  // pair<int, int> に pii という別名を付ける
typedef long long ll;
typedef unsigned long long ull;
//const double PI = 3.141592653589793238462643383279;
const double PI = 3.141592653589793238462643;

int main(){
   int A; 
   int B;
   int H;
   int M;
   cin >> A >> B >> H >> M;
   double angh = 30.0*H+30.0*M/60.0;
   double angm = 6.0*M;
   double radius = abs(angh - angm);
   double ang = cos(radius*2.0*PI/360);
   double ans = sqrt(A*A+B*B-2.0*A*B*ang);
   cout << fixed << setprecision(20) << ans << endl;
}


Measured memory_bytes: 4212