akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>  // memset()
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define ll long long
#define For(i, a, b) for (int i = (int)(a), sz = (int)(b); i < sz; i++)
#define rFor(i, a, b) for (int i = (int)(a); i >= (int)(b); i--)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fill(a, b) memset(a, b, sizeof(a))
#define IO ios_base::sync_with_stdio(0), cin.tie(0)

const int MAX = 1e2 + 1;

int main() {
    IO;
    int a, b;
    cin >> a >> b;
    printf("%d\n", (a + b) % 24);
    return 0;
}

Measured memory_bytes: 3768
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <functional>

using namespace std;

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

#define fst first
#define scd second
#define PB push_back
#define rep(i,x) for(ll i=0;i<(x);++i)

const ll linf = 3e18;

struct edge {
	ll to, cost;
	edge(ll to, ll cost = linf) : to(to), cost(cost) {}
};

ll N, M, C;

ll d[100000];
vector<edge> G[100000];
map<ll, vector<ll> >  m;
bool found[100000];
map<ll, bool> used[100000];

void dijkstra(ll s)
{
	priority_queue<pii, vector<pii>, greater<pii> > q;
	fill(d, d + N, linf);
	d[s] = 0;
	q.push(pii(0, s));
	while (q.size()) {
		pii p = q.top(); q.pop();
		ll v = p.scd;
		if (d[v] < p.fst) continue;
		rep(i, G[v].size()) {
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				m[d[e.to]].PB(e.to);
				q.push(pii(d[e.to], e.to));
			}
		}
	}
}

signed main()
{
	scanf("%lld %lld %lld", &N, &M, &C);

	ll sum = 0;

	rep(i, M) {
		ll A, B, D; scanf("%lld %lld %lld", &A, &B, &D), A--, B--;
		G[A].PB(edge(B, D));
		G[B].PB(edge(A, D));
		sum += D;
	}

	dijkstra(0);
	found[0] = true;

	ll mi = linf;

	m[0] = vector<ll>();

	for (map<ll, vector<ll> >::iterator itr = m.begin(); itr != m.end(); ++itr) {
		ll X = itr->fst;
		vector<ll> vs = itr->scd;

		rep(i, vs.size()) found[vs[i]] = true;

		rep(i, vs.size()) {
			ll v = vs[i];
			rep(j, G[v].size()) {
				edge e = G[v][j];
				if (!found[e.to]) continue;
				if (used[v][e.to]) continue;
				used[v][e.to] = used[e.to][v] = true;
				sum -= e.cost;
			}
		}

		mi = min(mi, sum + C * X);
	}

	printf("%lld\n", mi);
}

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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

#define MAX_N 1002020

ll f[MAX_N], invf[MAX_N];
ll p = 1e9 + 7;

ll mod_pow(ll x, ll n, ll p)
{
    if (n == 0)
        return 1;
    ll res = mod_pow(x * x % p, n / 2, p);
    if (n & 1)
        res = res * x % p;
    return res;
}

void init()
{
    f[0] = 1;
    invf[0] = 1;
    for (ll i = 1; i <= MAX_N - 10; i++)
    {
        f[i] = f[i - 1] * i % p;
        invf[i] = (mod_pow(i, p - 2, p) * invf[i - 1]) % p;
    }
}

ll mod_conv(ll n, ll k)
{
    ll tmp = invf[n - k] * invf[k] % p;

    return f[n] * tmp % p;
}

int main()
{

    ll h, w, a, b;
    cin >> h >> w >> a >> b;
    ll ans = 0;
    init();

    for (ll i = b; i < w; i++)
    {
        ll x = mod_conv(i + h - a - 1, i);
        ll y = mod_conv(w - i - 1 + a - 1, a - 1);
        (ans += (x * y) % p) %= p;
    }
    OP(ans);

    return 0;
}

Measured memory_bytes: 15872
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int n; cin >> n;
    vector<double> v(n);
    rep(i,n) {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    double ans = v[0];
    repf(i,1,n) {
        ans = (ans+v[i])/2;
    }
    printf("%.5lf\n", ans);
    return 0;
}

Measured memory_bytes: 256
import math
A, B, H, M = [int(n) for n in input().split(' ')]

H_deg = (360/(12*60))*(H*60+M)
M_deg = (360/60)*M

deg = abs(H_deg-M_deg)
if deg > 180:
  deg = 360-deg

ans = A**2 + B**2 - 2*A*B*math.cos(math.radians(deg))
ans = math.sqrt(ans)

print(ans)

Measured memory_bytes: 9436
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Security.Cryptography.X509Certificates;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine().ToCharArray();
            int ret = 0;
            int len = S.Length / 2;
            if (S.Length % 2 == 0)
            {
                for (int i = 0; i < len; i++)
                {
                    if (S[i] != S[S.Length - 1-i])
                    {
                        ret++;
                    }
                }
            }
            else
            {
                for (int i = 0; i < len; i++)
                {
                    if (S[i] != S[S.Length - 1-i])
                    {
                        ret++;
                    }
                }
            }
            Console.WriteLine(ret);
        }
    }
}

Measured memory_bytes: 13140
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)
#define RFOR(i,s,n) for(int i=(int)(s)-1,i##_len=(int)(n);i>=i##_len;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;

int uf[200000];
ll a[200000];

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int  Max(int  a, int  b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}void hSwap(ll x[], int i, int j)
{
	ll temp;

	temp = x[i];
	x[i] = x[j];
	x[j] = temp;
}

void ShowData(ll x[], int left, int right)
{
	int i;
	for (i = left; i <= right; i++)printf("%lld  ", x[i]);
	printf("\n");
}
void QSort(ll x[], int left, int right, int n) {
	int i, j;	//左端,右端
	ll pivot;	//軸

	i = left;
	j = right;
	pivot = x[(left + right) / 2];

	while (1) {
		if (n > 0) {				//n>0なら昇順、n<=0なら降順
			while ((x[i] < pivot) && (i <= right))i++;	//軸値より大きい要素
			while ((pivot < x[j]) && (i <= right))j--;	//軸値より小さい要素
		}
		else {
			while ((x[i] > pivot) && (i <= right))i++;	//軸値より小さい要素
			while ((pivot > x[j]) && (i <= right))j--;	//軸値より大きい要素
		}
		if (i >= j)	break;
		hSwap(x, i, j);
		i++; j--;
	}
	//ShowData(x, left, right);

	if (left < i - 1)QSort(x, left, i - 1, n);
	if (j + 1 <  right)QSort(x, j + 1, right, n);
}

int binary_search(ll ary[], ll key, int left, int right) {
	if (right < left) return -1;
	int mid = left + (right - left) / 2;
	if (ary[mid] < key) {
		return binary_search(ary, key, left, mid - 1);
	}
	else if (ary[mid] > key) {
		return binary_search(ary, key, mid + 1, right);
	}
	else {
		int n = mid;
		while (n>=left&&ary[n] == key) {
			if (uf[n] != 1)return n;
			n--;
		}
		n = mid+1;
		while (n <= right&&ary[n] == key) {
			if (uf[n] != 1)return n;
			n++;
		}
		return -1;
	}
}

int main() {
	int n;

	//*
	scanf("%d", &n);
	REP(i, n) {
		scanf("%lld", &a[i]);
	}
	/*/
	n = 200000;
	REP(i,n){
		a[i] = i;
	}
	//*/
	QSort(a, 0, n - 1, 0);
	//ShowData(a, 0, n - 1);
	ll t[32] = { 0 };
	t[0] = 1;
	REPS(i, 31) {
		t[i] = t[i - 1] * 2;
	}
	int b = 31;
	int ans = 0;
	REP(i, n) {
		if (uf[i] == 1)continue;
		while (a[i] * 2 < t[b])b--;
		//printf("a[%d]=%lld:t[%d]=%lld\n", i,a[i],b, t[b]);
		ll key = t[b] - a[i];
		//printf("key=%lld\n", key);
		uf[i] = 1;
		int tar = binary_search(a, key, i+1, n - 1);
		//printf("tar=%d\n", tar);
		if (tar != -1) {
			uf[tar] = 1;
			ans++;
		}
		else {
			uf[i] = 0;
		}
	}
	PRINTD(ans);
}

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

int main()
{
	ll n,k,ind1,ind2;
	cin>>n>>k;
	ll a[n+1];
	for(ll i=1;i<=n;i++)
	cin>>a[i];
	unordered_map<ll,ll> um;
	vector<ll> v;
	
	ll curr=1;
	v.push_back(1);
	um[1]=0;
	for(ll i=1;i<n;i++)
	{
		if(um.find(a[curr])==um.end())
		{
		
		v.push_back(a[curr]);
		um[a[curr]]=i;
		curr=a[curr];
		
		
	}
	else
	{
		ind1=um[a[curr]];
	
		break;
	}
}
//for(auto x:v)
//cout<<x<<" ";
//cout<<"\n";

if(k<v.size())
cout<<v[k];
else
{
	ll temp=k-ind1;
//	cout<<temp<<"\n";
	//cout<<temp%(v.size()-ind1)<<"\n";
	cout<<v[(temp%(v.size()-ind1))+ind1];
}




	
	
		
			
		
	
	
	
}

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

typedef long long ll;

int main() {
    int H, W, K;
    cin >> H >> W >> K;
    vector<string>c(H);
    for (int i = 0; i < H; i++) {
        cin >> c[i];
    }
    ll ans = 0;
    for (int bits1 = 0; bits1 < (1<<H); bits1++) {
        vector<int> v1;
        for (int i = 0; i < H; i++) {
            if (bits1 & (1<<i))  {
                v1.push_back(i);
            }
        }
        for (int bits2 = 0; bits2 < (1<<W); bits2++) {
            vector<int> v2;
            for (int i = 0; i < W; i++) {
                if (bits2 & (1<<i))  {
                    v2.push_back(i);
                }
            }
            int check[H][W];
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    check[i][j] = -1;
                }
            }
            for (int i = 0; i < v1.size(); i++) {
                for (int j = 0; j < W; j++) {
                    check[v1[i]][j] = 1;
                }
            }
            for (int i = 0; i < v2.size(); i++) {
                for (int j = 0; j < H; j++) {
                    check[j][v2[i]] = 1;
                }
            }
            int cnt = 0;
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    if (check[i][j] != 1 && c[i][j] == '#') {
                        cnt++;
                    }
                }
            }
            if (cnt == K) {
                ans++;
            }
        } 
    } 
   
    cout << ans << endl;
    
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) cout<<(ans?"Yes":"No")<<endl
#define YN(ans) cout<<(ans?"YES":"NO")<<endl
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(int& a){printf("%d",a);}
void print(long long& a){printf("%lld",a);}
void print(double& a){printf("%.15lf",a);}
template<class T> void print(T& a){cout<<a;}
template<class T> void print(vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(Head& head, Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(T& a){cerr<<a;}
template<class T> void dprint(vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(Head& head, Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    int w,h,x,y,r;
    in(w,h,x,y,r);
    yn(x+r<=w&&x-r>=0&&y+r<=h&&y-r>=0);
}


Measured memory_bytes: 3200
#include<iostream>
#include<vector>
using namespace std;
const int Nmax = 10000;
int N,T[Nmax],A[Nmax];

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

	long t=T[0],a=A[0];
	for(int i=1; i<N; i++){
		long kt = t%T[i]>0 ? t/T[i]+1 : t/T[i];
		long ka = a%A[i]>0 ? a/A[i]+1 : a/A[i];
		long k = max(kt,ka);
		t = k*T[i];
		a = k*A[i];
	}

	cout << t+a << endl;
	return 0;
}


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

struct RmQ {
	int n;
	int dat[580000];
	void init(int n_) {
		n = 1;
		while (n < n_)n *= 2;
		rep(i, 2 * n - 1)dat[i] = inf;
	}
	void update(int k, int a) {
		k += n - 1;
		dat[k] = a;
		while (k > 0) {
			k = (k - 1) / 2;
			dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
		}
	}
	int query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l)return inf;
		if (a <= l&&r <= b)return dat[k];
		else {
			int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
			int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
			return min(vl, vr);
		}
	}
	int getmin(int a, int b) {
		return query(a, b, 0, 0, n);
	}
};

struct BIT {
	int N; vector<int> bit;
	void init(int n) {
		N = n;
		bit.resize(n + 1);
	}
	int sum(int i) {
		int s = 0;
		while (i > 0) {
			s += bit[i];
			i -= i&-i;
		}
		return s;
	}
	void add(int i, int x) {
		while (i <= N) {
			bit[i] += x; i += i&-i;
		}
	}
};
RmQ seg;
BIT bit;
int cpy[100006];
int dp[100006];

void disp(vector<int>V) {
	rep(i, V.size()) {
		if (i)cout << ' '; cout << V[i];
	}cout << endl;
}
int leftbit(int L, int R) {
	if (bit.sum(R) - bit.sum(L) == 0)return inf;
	int LD = L;
	R++;
//	cout << L << ' ' << R << endl;
	while (R - L > 1) {
		int mi = (R + L) / 2;
		if (bit.sum(mi) - bit.sum(LD))R = mi;
		else L = mi;
	}
	return L;
}

signed main() {
	int n, m; cin >> n >> m;
	string s; cin >> s;
	seg.init(n+1);
	seg.update(0, 0);
	bit.init(n + 2);

	rep(i, n + 1) {
		if (s[i] == '0')bit.add(i + 1, 1);
	}

	for (int i = 1; i <= n; i++) {
		int l = i - m;
		l = max(l, 0ll);
		if (s[i] == '0') {
			seg.update(i, seg.getmin(l, i) + 1);
			dp[i] = leftbit(l, i);
		}
	}

	int res = seg.getmin(n, n + 1);
	if (res >= inf)cout << -1 << endl;
	else {
		vector<int>ans;
		int now = n;
		while (now) {
			int nxt = dp[now];
			ans.push_back(now - nxt);
			now = nxt;
		}
		reverse(ans.begin(), ans.end());
		disp(ans);
	}
}

Measured memory_bytes: 6388
/*suri_kumkaran*/

#include <bits/stdc++.h>

using namespace std;

#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define MP make_pair
#define EB emplace_back
#define endl "\n"
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef long long int int64;
typedef vector<int64> VI64;
typedef vector<pair<int64,int64>> VII64;
typedef vector<string> VS;
typedef vector<vector<int64>> VVI;

int main()
{
    IOS;
    int64 T=1;
    //cin>>T;
    while(T--)
    {
        int64 n,i;
        cin>>n;
        int64 a[n];
        for(i=0;i<n;i++)
            cin>>a[i];
        int64 dp[n];
        dp[0]=0;
        for(i=1;i<n;i++)
        {
            dp[i]=dp[i-1]+abs(a[i]-a[i-1]);
            if(i>1)
                dp[i]=min(dp[i],dp[i-2]+abs(a[i]-a[i-2]));
        }
        cout<<dp[n-1];
    }

    return 0;
}

Measured memory_bytes: 1792
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]
cnt = 0
ans = 0
i = 0
ab.sort()
while cnt < M:
    tmp = ab[i][1]
    prc = ab[i][0]
    ans += prc * tmp
    cnt += tmp
    i += 1
print(ans - (cnt-M)*prc)


Measured memory_bytes: 27364
//#pragma GCC optimize(3)
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
typedef long long LL;
using namespace std;

#define MAXN 105
#define INF 999999999
#define lyh 1000000007

struct r {
	int id;
	int mark;
	char c[105];
};

bool operator <(r a, r b) {
	int i = 0;
	while (a.c[i] != '\0'&&b.c[i] != '\0') {
		if (a.c[i] < b.c[i]) {
			return false;
		}
		else if (a.c[i] > b.c[i]) {
			return true;
		}
		i++;
	}
	if (a.c[i] != '\0') return true;
	if (b.c[i] != '\0') return false;
	return a.mark < b.mark;
}

r rs[MAXN];

signed main() {
	//ios::sync_with_stdio(false);
	//cin.tie(0);
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%s", rs[i].c);
		scanf("%d", &rs[i].mark);
		rs[i].id = i + 1;
	}
	sort(rs, rs + n);
	for (int i = n; i > 0; i--) {
		printf("%d\n", rs[i - 1].id);
	}
	
	return 0;
}

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

int N;
int c[100000];
vector<int> adj[10000];
map<pair<int, int>, int> edge_idx;
int d[10000];
bool visited[10000];

int main(){
  cin >> N;
  for(int i = 0; i < N - 1; i++){
    int a, b;
    cin >> a >> b;
    a--; b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
    edge_idx[make_pair(a, b)] = i;
    edge_idx[make_pair(b, a)] = i;
  }

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

  sort(c, c + N);
  long long M = 0;
  for(int i = 0; i < N - 1; i++){
    M += c[i];
  }
  cout << M << endl;

  int next_c_idx = N - 2;
  queue<int> que;
  que.push(0);
  visited[0] = true;
  d[0] = c[N - 1];
  while(!que.empty()){
    int now = que.front();
    que.pop();

    for(int i = 0; i < adj[now].size(); i++){
      int next = adj[now][i];
      if(!visited[next]){
	que.push(next);
	visited[next] = true;
	d[next] = c[next_c_idx];
	next_c_idx--;
      }
    }
  }
  for(int i = 0; i < N; i++){
    if(i){
      cout << ' ';
    }
    cout << d[i];
  }
  cout << endl;
}

  


Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1ll<<59


int main(){
    ll i,j;
    ll n;
    cin>>n;
    ll p[n+1];
    ll cnt=0;
    for(i=1;i<=n;i++) {
        ll x;
        cin>>x;
        if(x!=i) cnt++;
    }
    if(cnt<=2) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

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

int main() {
    int a, b;
    int c;
    std::cin >> a >> b ;

    c = a * b;
    if(c%2 == 0){
        std::cout << "Even";
    }
    else{
        std::cout << "Odd";

    }

    return 0;   

}

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

using namespace std;
typedef long long ll;


int main() {

    string s; cin >> s;

    ll n = s.size() + 1;

    vector<ll> a(n, 0);

    for (ll i = 0; i < n-1; ++i) {
        if (s[i] == '<') {
            a[i+1] = max(a[i+1], a[i]+1);
        }
    }

    for (ll i = n-2; i >= 0; --i) {
        if (s[i] == '>') {
            a[i] = max(a[i], a[i+1]+1);
        }
    }

    ll ans = 0;

    for (ll i = 0; i < n; ++i) {
        ans += a[i];
    }

    cout << ans << endl;
}


Measured memory_bytes: 4740
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <algorithm>
#include <math.h>
using namespace std;
int main(){
	int n;scanf("%d",&n);
	printf("%d:",n);
	for(int i=2;i<=(int)sqrt(n+0.5);i++){
		while(n%i==0){
			printf(" %d",i);
			n/=i;
		}
	}
	if(n!=1) printf(" %d",n);
	printf("\n");
	return 0;
}



Measured memory_bytes: 3212
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

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

  bool x[26] = {};

  rep(i,0,s.size()){
    char c = s[i];
    if(x[c - 'a']){
      no;
      ret 0;
    }
    else
      x[c - 'a'] = true;
  }
  yes;
  ret 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var input = int.Parse(Console.ReadLine());
        var H = Console.ReadLine().Split().Select(int.Parse).ToArray();
        
        var total = 1;
        var max = H[0];
        for(var i =1; i < H.Length; i++)
        {
          if (max <= H[i])
            {
                total++;
                max = H[i];
            }
        }

        Console.WriteLine(total);
    }
}

Measured memory_bytes: 13268
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
const in mdl=1000000007LL;
in p2(in a){
  return (1LL<<a);
}
in pw(in a, in b, in lm=62){
  a%=mdl;
  if(a<0)
    a+=mdl;
  in r=1;
  for(in i=lm;i>=0;--i){
    r=r*r%mdl;
    if(b&p2(i))
      r=r*a%mdl;
  }
  return r;
}
in inv(in a){
  a%=mdl;
  if(a<0)
    a+=mdl;
  assert(a!=0);
  return pw(a,mdl-2,30);
}
VI fc,invfc;
in ncr(in a, in b){
  if(b==0 || b==a)
    return 1;//even if a<0
  if(b<0 || b>a)
    return 0;
  return fc[a]*invfc[b]%mdl*invfc[a-b]%mdl;
}
void inifc(){
  const in mxfc=1001000;
  fc.resize(mxfc);
  invfc.resize(mxfc);
  fc[0]=fc[1]=invfc[0]=invfc[1]=1;
  for(in i=2;i<mxfc;++i){
    fc[i]=fc[i-1]*i%mdl;
    invfc[i]=invfc[mdl%i]*(mdl-mdl/i)%mdl;
  }
  for(in i=2;i<mxfc;++i){
    invfc[i]*=invfc[i-1];
    invfc[i]%=mdl;
  }
}

void opt(in n, in l, in r){
  in s;
  for(in i=1;i<=n;++i){
    s=ncr(n,i);
    if(l+(n-r-1)+1>=i)
      s-=ncr(l+(n-r-1),i-1);
    s%=mdl;
    if(s<0)
      s+=mdl;
    cout<<s<<"\n";
  }
}
VI sn;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in n;
  cin>>n;
  ++n;
  sn.resize(n+1,-1);
  inifc();
  in a;
  forn(z,n){
    cin>>a;
    if(sn[a]==-1){
      sn[a]=z;
      continue;
    }
    opt(n,sn[a],z);
    return 0;
  }
  return 0;
}


Measured memory_bytes: 17664
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define print_array(ary, size) cout << ary[0]; rep1(i, 1, size - 1) cout << ' ' << ary[i]; cout << endl;
typedef long long ll;
typedef unsigned long long ull;

int a[100];

int main()
{
	int N;

	cin >> N;
	rep(i, N) cin >> a[i];

	sort(a, a + N);
	
	cout << a[N - 1] - a[0] << endl;

	return 0;
}

Measured memory_bytes: 256
package main
import (
       "fmt"
       "os"
       "bufio"
       "strconv"
)

func main() {
     sc := bufio.NewScanner(os.Stdin)

     var n int
     if sc.Scan() {
        n, _ = strconv.Atoi(sc.Text())
     }
     fmt.Printf("%d\n", n*n*n);
}



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

#define R register

using namespace std;

typedef long long LL;
int n , m;
string a , b;

inline int gcd(int a , int b) {
	return !b ? a : gcd(b,a%b);
}

inline LL lcm(int a , int b) {
	return LL(a) / LL(gcd(a,b)) * LL(b);
}

int main() {
	
	scanf("%d%d",&n,&m);
	
	cin >> a >> b;
	
	R LL L = lcm(n,m);
	R int tmp1 = L / m , tmp2 = L / n;
	
	for(R int i=0,j=0; i<n&&j<m; i+=tmp1,j+=tmp2)
		if(a[i] != b[j])
			return puts("-1") , 0;
	
	printf("%lld\n",L);
	
	return 0;
	
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define lep(j,n) for(int j=0; j<(n); j++)
#define reps(i,n) for(int i=1; i<(n); i++)
#define leps(j,n) for(int j=1; j<(n); j++)
#define pii pair<int,int>
#define gsort(x,n) sort((x),(x)+(n),greater<int>())
#define all(x) (x).begin(), (x).end()
#define int long long
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const long long mod = 1000000007;
using namespace std;

#define return(Z) re:(Z)

long long h[10000010],x[10000010],z[10000010];

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int a,b,c,d;
    cin>>a>>b>>c>>d;
    a=a+b;
    c=c+d;
    if(a>c) cout<<"Left"<<'\n';
    else if(a<c) cout<<"Right"<<'\n';
    else cout<<"Balanced"<<'\n';
}

Measured memory_bytes: 256
N,M = gets.split.map(&:to_i)
A = gets.split.map(&:to_i).sort
BC = readlines.map {|a| a.split.map(&:to_i) }.sort_by(&:last).reverse
ans = 0
BC.each do |b,c|
  n = A[0, b].index {|a| a >= c } || [b, A.size].min
  break if n == 0
  A.shift(n)
  ans += c * n
end
puts ans + (A.inject(:+) || 0)

Measured memory_bytes: 21592
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        double a = sc.nextDouble();
        double b = sc.nextDouble();
        
        for(int i=1; i<=1250; i++){
            if(Math.floor(i*0.08)==a && Math.floor(i*0.1)==b){
                System.out.println(i);
                return;
            }
        }

        System.out.println("-1");
   }
}


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

int main() {
    int a, b;
    while (cin >> a >> b, a) {
        int n; cin >> n;
        vector<vector<int>> dp(a + 1, vector<int>(b + 1));
        while (n--) {
            int i, j; cin >> i >> j; i--, j--;
            dp[i][j] = -1;
        }
        dp[0][0] = 1;
        for (int i = 0; i < a; i++) for (int j = 0; j < b; j++) {
            if (dp[i][j] == -1) continue;
            if (dp[i + 1][j] != -1) dp[i + 1][j] += dp[i][j];
            if (dp[i][j + 1] != -1) dp[i][j + 1] += dp[i][j];
        }
        cout << dp[a - 1][b - 1] << endl;
    }
    return 0;
}


Measured memory_bytes: 3116
# -*- coding: utf-8 -*-
 
N = int(input())

A = [int(e) for e in input().split()]
B = [int(e) for e in input().split()]
C = [int(e) for e in input().split()]

res = 0
for i in range(1, N + 1):
	menu = A[i - 1]
	res += B[menu - 1]

for i in range(2, N + 1):
	if A[i - 1] - A[i - 2] == 1:
		res += C[A[i - 2] - 1]

print(res)


Measured memory_bytes: 3064
n = int(input())
A = [input().split(" ") for _ in range(n)]
S = A.copy()

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

def quickSort(A, p, r):
    if p < r:
        q = partition(A, p, r)
        quickSort(A, p, q - 1)
        quickSort(A, q + 1, r)

SENTINEL = 9999999999999

def merge(S, n, left, mid, right):
    global SENTINEL
    n1 = mid - left
    n2 = right - mid
    L = S[left:mid] + [[" ", SENTINEL]]
    R = S[mid:right] + [[" ", SENTINEL]]
    i = j = 0
    for k in range(left, right):
        if int(L[i][1]) <= int(R[j][1]):
            S[k] = L[i]
            i += 1
        else:
            S[k] = R[j]
            j += 1

def mergeSort(S, n, left, right):
    if left + 1 < right:
        mid = int((left + right) / 2)
        mergeSort(S, n, left, mid)
        mergeSort(S, n, mid, right)
        merge(S, n, left, mid, right)

quickSort(A, 0, n-1)
mergeSort(S, n, 0, n)

def Judge():
    for _ in range(n):
        if A[_] != S[_]:
            return "Not stable"
    return "Stable"
    
print(Judge())
for _ in range(n):
    print(*A[_])


Measured memory_bytes: 29652
#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
const int MAX_H = 20;
const int MAX_W = 20;
const int inf = 1001001001;
int H,W;char m[MAX_H][MAX_W];
int bfs(int y,int x){
  if(m[y][x] == '#') return -1;
  int D[H][W],i,j,fy,fx,ny,nx,vy[4] = {1,0,-1,0},vx[4] = {0,1,0,-1};
  for(i=0;i<H;i++) fill(D[i],D[i]+W,inf);
  D[y][x] = 0;
  queue<pair<int,int>> q;q.push(make_pair(y,x));
  while(!q.empty()){
    fy = q.front().first;fx = q.front().second;q.pop();
    for(i=0;i<4;i++){
      ny = fy+vy[i];nx = fx+vx[i];
      if(ny >= 0 && ny < H && nx >= 0 && nx < W && m[ny][nx] == '.' && D[ny][nx] == inf){
        D[ny][nx] = D[fy][fx]+1;
        q.push(make_pair(ny,nx));
      }
    }
  }
  int ans = 0;
  for(i=0;i<H;i++){
    for(j=0;j<W;j++){
      if(D[i][j] != inf) ans = max(ans,D[i][j]);
    }
  }
  return ans;
}
int main(){
  int i,j,ans = 0;scanf("%d %d\n",&H,&W);
  for(i=0;i<H;i++){
    for(j=0;j<W;j++) scanf("%c",&m[i][j]);
    scanf("\n");
  }
  for(i=0;i<H;i++){
    for(j=0;j<W;j++) ans = max(ans,bfs(i,j));
  }
  printf("%d\n",ans);
}


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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

template<typename T>
void print1(T begin, T end) {
	while (begin != end) {
		cerr << (*begin) << " ";
		*begin++;
	}
	cerr << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
	for (int i = 0; i < height; i++) {
		for (int j = 0; j < width; j++) {
			cerr << " " << Array[i][j];
		}
		cerr << endl;
	}
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	std::cerr << head << " ";
	print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

// ------------------------------------------------------------------------------------------

int n, m;
vec<int> a;
int dp[111111];
int mod = 1e9 + 7;

signed main() {
	cin >> n >> m;
	a.resize(m);
	set<int> s;
	rep (i, m) {
		cin >> a[i];
		s.insert(a[i]);
	}

	dp[0] = 1;
	rep (i, n) {
		// 1
		if (!s.count(i+1)) {
			dp[i+1] += dp[i];
			dp[i+1] %= mod;
		}
		// 2
		if (!s.count(i+2)) {
			dp[i+2] += dp[i];
			dp[i+2] %= mod;
		}
	}

	cout << dp[n] << endl;

	return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define int long long
#define ll long long 
#define rep(i,a,b) for(signed i=a;i<(b);++i)
#define erep(i,a,b) for(signed i=a;i<=(b);++i)
#define per(i,a,b) for(signed i=(a);i>(b);--i)
#define eper(i,a,b) for(signed i=(a);i>=b;--i)
#define fore(i, x, a) for(auto &&x:a) 
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define pb push_back
#define mp make_pair
#define ALL(x) begin(x),end(x)
#define F first
#define S second
#define debug(x)  cout << #x << ": " << (x) << '\n';
const long long INF=1001001001001001001;
const int MOD=(int)1e9 + 7;
const double EPS=1e-9;
using namespace std;
using Pii = pair<int,int>;
using vii = vector<int>;
template<class T>using  PS_queue = priority_queue<T, vector<T>, greater<T> >;
template<class T>using vv = vector<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct edge { int from, to, cost; };
int dy[]={0, 1, -1, 0}; int dx[]={1, 0, 0, -1};
// cout << fixed;
// cout << setprecision(10) << val;

int n, k;
signed main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  cin >> n >> k;
  vv<Pii> sushi;
  PS_queue<int> que;
  set<int> S;
  rep(i, 0, n) {
    int t, d;
    cin >> t >> d;
    sushi.pb({d, t});
  }
  sort(ALL(sushi), greater<Pii>());
  int ans = 0, sum = 0, kind = 0;
  rep(i, 0, k) {
    sum += sushi[i].F;
    if (S.count(sushi[i].S)) {
      que.push(sushi[i].F);
    } else {
      kind++;
      S.insert(sushi[i].S);
    }
  }
  ans = sum + kind * kind;
  rep(i, k, n) {
    if (que.empty()) {
      break;
    }
    if (S.count(sushi[i].S) == 0) {
      sum -= que.top(); 
      que.pop();
      kind++;
      sum += sushi[i].F;
      S.insert(sushi[i].S);
      chmax(ans, sum + kind * kind);
    }
  }
  cout << ans << endl;
  return 0;
}



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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    ll ans=0;
    ll n,k;cin>>n>>k;
    for (int i = k; i <=n+1; ++i) {
        ans+=(n-i+1)*i+1;
        ans%=mod;
    }
    cout <<ans <<endl;
    return 0;
}

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

const int N_MAX = 105;
int A[N_MAX];

int main(){
    int n, m;
    cin >> n >> m;
    int total = 0;
    for(int i = 0; i < n; i++){
        cin >> A[i];
        total += A[i];
    }

    int line = (total + 4 * m -1) / (4 * m);
    int ans = 0;
    for(int i = 0; i < n; i++){
        if (line <= A[i])ans++;
    }
    if (ans >= m) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main()
{
    string s ,t;
    int cnt=0;
    cin>> s >>t;
    for(int i=0;s[i]!='\0';i++){
        if(s[i]!=t[i])cnt++;
    }
    cout<< cnt <<endl;
    return 0;
}

Measured memory_bytes: 3816
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner scanner = new Scanner(System.in);
		long s = scanner.nextLong();
		long c = scanner.nextLong();
		long count = 0;
		while(true){
			//System.out.println("s="+s+" ,c="+c+" ,count="+count);
			if(s>0 && c>=2){
				long temp = Math.min(s, c/2);
				s = s-temp;
				c = c-(2*temp);
				count += temp;
			}else if(s==0 && c>=4){
				long temp = c/4;
				c = c-temp*2;
				s += temp;
			}else if(s==0 && c>2){
				c = c-2;
				s += 1;
			}else{
				break;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 21076
fn main() {
    proconio::input! {
    a:usize,
    }
    println!("{}",if a%(a/100000000%10+a/10000000%10+a/1000000%10+a/100000%10+a/10000%10+a/1000%10+a/100%10+a/10%10+a%10)==0{"Yes"}else{"No"});
}

Measured memory_bytes: 2116
//#include <bits/stdc++.h>
#include<cstdio>
#include<iostream>
#include<queue>
#include<map>
#include<string.h>
#include<algorithm>
using namespace std;

/*
最短路拆点，跑最短路；
*/

const int N=1e6+10;
const int INF=0x3f3f3f3f;

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

struct asd{
    int to;
    int w;
    int next;
};
int head[N*8],tol,dd;
asd q[N*8];
int num[N*8];
bool vis[N*8];
int dis[N*8];
int n,m;
int que[N];
int s,t;

int spfa()
{
    s=0;
    t=1;
    for(int i=1;i<=dd+1;i++)
    {
        dis[i]=INF;
        vis[i]=0;
        num[i]=0;
    }
    dis[1]=0;
    vis[1]=num[1]=1;
    que[s]=1;
    while(s<t)
    {
        int u=que[s];
        s++;
        vis[u]=0;
        for(int v=head[u];v!=-1;v=q[v].next)
        {
            int i=q[v].to;
            if(dis[i]>q[v].w+dis[u])
            {
                dis[i]=q[v].w+dis[u];
                if(!vis[i])
                {
                    num[i]++;
                    if(num[i]>=dd)
                        return -2;
                    vis[i]=1;
                    que[t]=i;
                    t++;
                }
            }
        }
    }
    if(dis[n]!=INF)
        return dis[n];
    else
        return -2;
}
int getid(int x,int y)
{
    if(mp.find({x,y})!=mp.end())
        return mp[{x,y}];
    return mp[{x,y}]=++dd;
}
void init()
{
    dd=n;
    tol=0;
    memset(head,-1,sizeof(head));
}
void add(int a,int b,int c)
{
    q[tol].w=c;
    q[tol].to=b;
    q[tol].next=head[a];
    head[a]=tol++;
}
int main()
{
    scanf("%d%d",&n,&m);
    init();
    for(int i=0;i<m;i++)
    {
        int x,y,c;
        scanf("%d%d%d",&x,&y,&c);
        int xx=getid(x,c);
        int yy=getid(y,c);
        add(xx,yy,0);
        add(yy,xx,0);
        add(x,xx,1);
        add(xx,x,1);
        add(y,yy,1);
        add(yy,y,1);
    }
    printf("%d\n",spfa()/2);
    return 0;
}


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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define Rep(i,n) for(ll i = 0; i <= n; i++)
#define REp(i,n) for(ll i = 1; i < n; i++)
#define REP(i,n) for(ll i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main(){
  int n;
  string s;
  cin >> n >> s;
  V<int> ws(n+1), bs(n+1);
  ws[0] = 0;
  bs[0] = 0;
  REP(i,n) {
    bs[i] = bs[i-1] + (s[i-1] == '#');
    ws[i] = ws[i-1] + (s[i-1] == '.');
  }
  int ans = inf;
  rep(i,n+1) {
    int lw = ws[n] - ws[i];
    int rb = bs[i];
    chmin(ans, lw + rb);
  }
  cout << ans << endl;
}

Measured memory_bytes: 5232
#include <iostream>
#include <iomanip>

int main()
{
	int h, w;
	std::cin >> h >> w;
	while (h != 0 || w != 0) {
		for (int i = 0; i < h; i++) {
			if (i == 0 || i == h - 1) {
				for (int j = 0; j < w; j++) {
					std::cout << "#";
				}
			}
			else {
				for (int j = 0; j < w; j++) {
					if(j == 0 || j == w-1){
						std::cout << "#";
					}
					else {
						std::cout << ".";
					}
				}
			}
			std::cout << std::endl;
		}
		std::cout << std::endl;
		std::cin >> h >> w;
	}
    return 0;
}


Measured memory_bytes: 3080
let n = read_int ();;
let ab = Array.init n (fun _ -> Scanf.scanf " %d %d" (fun x y -> x, y));;
Array.sort (fun (a, b) (c, d) -> compare b d) ab;;
let ans = snd @@ Array.fold_left (fun (sum, all) (a, b) -> (sum + a, all && sum + a <= b)) (0, true) ab in
if ans then
  print_endline "Yes"
else
  print_endline "No";;
    


Measured memory_bytes: 9600
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <memory.h>
#include <set>
#include <cmath>
#define fio ios::sync_with_stdio(false); cin.tie(NULL);

using namespace std;
#define ERR(x) cout << #x << " is: " << x << '\n';
typedef long long ll;
typedef pair<int, int> pii;
const long double PI = acos(-1);
int n;
char inp[105];
int main(void) {
	scanf("%d %s", &n, inp);
	if (n % 2) return !printf("No\n");
	for (int i = 0, j = n / 2; j < n; i++, j++) {
		if (inp[i] != inp[j]) {
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

int main()
{
    int n;
    int a[5]={5,7,5,7,7};
    while(cin >>n,n)
    {
        vector<int> w(n);
        rep(i,n)
        {
            string s;
            cin >>s;
            w[i]=s.size();
        }

        int ans=-1;
        rep(i,n)
        {
            int ct=0;

            bool valid=false;
            int idx=0;
            for(int j=i; j<n; ++j)
            {
                ct+=w[j];
                if(ct==a[idx])
                {
                    ++idx;
                    ct=0;
                }
                else if(ct>a[idx]) break;


                if(idx==5)
                {
                    valid=true;
                    break;
                }
            }

            if(valid)
            {
                ans=i+1;
                break;
            }
        }

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

Measured memory_bytes: 3032
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# GCD -- START --
def gcd(x,y):
  while y:
    x,y=y,x%y
  return x
# GCD --- END ---

# LCM -- START --
def lcm(x,y):
  return x*y/gcd(x,y)
# LCM --- END ---

def main():
  a,b=LI()

  return int(lcm(a,b))

# main()
print(main())


Measured memory_bytes: 7752
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
struct edge{ll from, to, cost;};
// v:=頂点数 es:=辺の集合 cost:=始点からの最短経路のコストを格納する配列
// s:=始点(指定しなければ頂点0) g:=終点(指定しなければ頂点v-1)
// 始点から到達可能な負閉路が検出された場合falseを、それ以外の場合trueを返す
bool bell(int v,vector<edge>& es,vector<ll>& cost,ll s=0,ll g=-1){
    if(g==-1)g=v-1;
    cost.assign(v,INF);//負閉路検出は０に初期化
    cost[s] = 0;
    rep(i,v*2){
        for(auto& e : es){
            if(cost[e.from]<INF&&cost[e.from]+e.cost<cost[e.to]){
                if(i>=v-1){
                    //return false;
                    //始点から到達可能で、かつ終点へ到達可能な負閉路が検出された場合falseを、それ以外の場合trueを返す
                    if(e.to==g) return false;
                    else cost[e.to] = -INF;
                }
                else{
                    cost[e.to]=cost[e.from]+e.cost;
                }
            }
        }
    }
    return true;
}
int main(){
    ll n,m;cin >> n >>m;
    vector<edge> v(m);
    rep(i,m){
        cin >> v[i].from >>v[i].to >>v[i].cost;
        v[i].from--;v[i].to--;v[i].cost=-(v[i].cost);
    }
    vl cost;
    if(bell(n,v,cost))cout << -cost[n-1] <<endl;
    else cout << "inf" <<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int  h, w, i, j;
  char  p[100][101];

  scanf("%d %d", &h, &w);

  for(i=0; i<h; i++) {
    scanf("%s", &p[i][0]);
  }

  for(j=0; j<w+2; j++){
    printf("#");
  }
  printf("\n");
  for(i=0; i<h; i++) {
    printf("#%s#\n", p[i]);
  }
  for(j=0; j<w+2; j++){
    printf("#");
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>                                           
 
#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb; 
typedef long long ll;  
typedef double db;                         
 
 
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const int inf = 1e9, N = 3e3 + 48, mod = 1e9 + 7, maxn = 102;
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;


int n, a[N], dp[N][N][2];

int rec (int l, int r, int tp) {
	if (l > r)	
		return 0;
	if (dp[l][r][tp] != -INF)
		return dp[l][r][tp];
	if (!tp)
		return dp[l][r][tp] = max(a[l] + rec(l + 1, r, tp ^ 1), a[r] + rec(l, r - 1, tp ^ 1));			         	
	return dp[l][r][tp] = min(-a[l] + rec(l + 1, r, tp ^ 1), -a[r] + rec(l, r - 1, tp ^ 1));			
}


main () {
	cin >> n;
	forn (i, 1, n)
		cin >> a[i];

	forn (i, 1, n)
		forn (j, 1, n)
			forn (tp, 0, 1)
				dp[i][j][tp] = -INF;

	cout << rec(1, n, 0);
}                       

Measured memory_bytes: 143744
# https://atcoder.jp/contests/abc054/tasks/abc054_a

A, B = map(int, input().split())
Alice = 'Alice'
Bob = 'Bob'
Draw = 'Draw'

if A == B:
    print(Draw)
elif A == 1 and B != 1:
    print(Alice)
elif A != 1 and B == 1:
    print(Bob)
elif A > B:
    print(Alice)
elif A < B:
    print(Bob)



Measured memory_bytes: 2940