akhauriyash/Code-Regression huggingface dataset:
def main():
    N, M = map(int, input().split())
    cnct = [0]*N

    for _ in range(M):
        a, b = map(int, input().split())
        cnct[a - 1] += 1
        cnct[b - 1] += 1
        
    for i in range(len(cnct)):
        print(cnct[i])
main()

Measured memory_bytes: 2940
#include <stdio.h>
#include <stdlib.h>
int sort(const void *a,const void *b){return *(int*)a-*(int*)b;}
int main(void){
    int n,k,ans=1e9;
    scanf("%d%d",&n,&k);
    int h[n];
    for (int i=0; i<n; i++){
        scanf("%d",&h[i]);
    }
    qsort (h,n,sizeof(int),sort);
    for (int i=0; i<n-k+1; i++){
        ans=ans<(h[i+k-1]-h[i])?ans:(h[i+k-1]-h[i]);
    }
    printf("%d\n",ans);
	return 0 ;
}

Measured memory_bytes: 892
import sys
readline = sys.stdin.readline

H, W, K = map(int, readline().split())
L = []
s = 0
for i in range(H):
  li = readline().strip()
  Li = []
  for j in range(W):
    if li[j] == "#":
      s += 1
      Li.append(1)
    else:
      Li.append(0)
  L.append(Li)
if s < K:
  print(0)
  exit()

h0 = ""
w0 = ""
for i in range(H):
  h0 += "0"
for i in range(W):
  w0 += "0"
h = 2**H
w = 2**W
ans = 0
for i in range(h):
  hi = (h0 + bin(i)[2:])[-H:]
  for j in range(w):
    wj  = (w0 + bin(j)[2:])[-W:]
    sij = 0
    for k in range(H):
      for l in range(W):
        if hi[k] != "1" and wj[l] != "1":
          sij += L[k][l]
    if sij == K:
      ans += 1
print(ans)

Measured memory_bytes: 9268
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=998244353;
const ll INF=2e15;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false); 

    ll n,k;
    cin >> n >> k;
    vector<int> d(k);
    rep(i,k) cin >> d[i];
    sort(d.begin(),d.end());
    int ans=0;
    repr(i,n,n+1000000) {
        bool flag=1; 
        int j=i;
        while (j>0) {
            int l=j%10;
            bool okay=1;
            rep(m,k) {
                if (l==d[m]) okay=0;
            }
            if (!okay) {
                flag=0;
                break;
            }
            j/=10;
        }
        if (flag) {
            ans=i;
            break;
        }
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 3672
#include<stdio.h>
#include<stdlib.h>

int binSearch(int*, int, int);

int main()
{
  int i;
  int n, q, C=0;
  int *S, *T;

  scanf("%d", &n);
  S = (int*)malloc(n * sizeof(int));
  if(S == NULL)
    {
      printf("malloc failed\n");exit(1);
    }
  for(i=0;i<n;i++)
    {
      scanf("%d", &S[i]);
    }

  scanf("%d", &q);
  T = (int*)malloc(q * sizeof(int));
  if(T == NULL)
    {
      printf("malloc failed\n");exit(2);
    }
  for(i=0;i<q;i++)
    {
      scanf("%d", &T[i]);
    }

  for(i=0;i<q;i++)
    {
      if(binSearch(S, n, T[i]))C++;
    }

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

  free(S);
  free(T);
  return 0;
}

int binSearch(int *S, int n, int key)
{
  int left = 0, right = n, mid;

  while(left < right)
    {
      mid = (left + right)/2;
      if(S[mid] == key)return 1;
      else if(key < S[mid])right = mid;
      else left = mid + 1;
    }
  return 0;
}



Measured memory_bytes: 2108
n, W = map(int, input().split())
wv = []
for i in range(n):
    wv.append(list(map(int, input().split())))
num = wv[0][0]
dp = [[-float("inf") for i in range(3 * (n - 1) + 1)] for j in range(n + 1)]
dp[0][0] = 0
for i in range(n):
    w, v = wv[i][0], wv[i][1]
    w -= num
    for j in range(n - 1, -1, -1):
        for k in range(3 * (n - 1) + 1 - w):
            dp[j + 1][k + w] = max(dp[j + 1][k + w], dp[j][k] + v)
ans = 0
for i in range(3 * (n - 1) + 1):
    for j in range(n + 1):
        if j * num + i <= W:
            ans = max(ans, dp[j][i])
print(ans)

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

int main() {
  string s, p;
  cin >> p >> s;
  int maximo = 0, a = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'D') {
      a--;
    }
  
    if (s[i] == 'I') {
      a++;
    }
  
    if(a > maximo){
      maximo = a;
    }
  }
  cout << maximo;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
//constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

void solve() {
	int n, m; scanf("%d %d", &n, &m); if (n == 0 && m == 0) exit(0);
	vector<vector<int>> g(n);
	for (int i = 0; i < m; i++) {
		int u, v; scanf("%d %d", &u, &v);
		u--; v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	vector<int> col(n, -1);
	col[0] = 0;
	queue<int> q; q.push(0);
	int bl = 0, wh = 0;
	while (!q.empty()) {
		int cur = q.front();
		q.pop();
		if (col[cur]) bl++;
		else wh++;
		for (auto next : g[cur]) {
			if (col[next] == -1) {
				col[next] = (col[cur] ^ 1);
				q.push(next);
			}
			else {
				if (col[next] == col[cur]) {
					puts("0");
					return;
				}
			}
		}
	}
	vector<int> res;
	if (bl % 2 == 0) res.push_back(bl / 2);
	if (wh % 2 == 0) res.push_back(wh / 2);
	sort(res.begin(), res.end());
	res.erase(unique(res.begin(), res.end()), res.end());
	cout << res.size() << "\n";
	for (int i = 0; i < res.size(); i++) {
		cout << res[i] << "\n";
	}
}
int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/
	int kkt = 89;
	while (kkt) {
		solve();
	}
	return 0;

}



Measured memory_bytes: 3336
#include <iostream>
#include <cstdio>
#include <vector>
#include <complex>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <stack>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <cassert>

using namespace std;

typedef long long ll;
typedef ll li;
typedef pair<int,int> PI;
#define EPS (1e-10L)
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define F first
#define S second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(),a.end()
#define FOR(it,a) for(__typeof(a.begin())it=a.begin();it!=a.end();++it)
void pkuassert(bool t){t=1/t;};

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

int main(int argc, char *argv[])
{
  ll y=1,m=1,d=1;
  int cnt=0;
  map<ll,int> hoge;
  while(true){
    if(y==1002) break;
    hoge[y*10000000000+m*1000+d]=cnt++;
    ++d;
    if(y%3!=0 && m%2==0 && d==20) d=1;
    else if(d==21) d=1;
    if(d==1) ++m;
    if(m==11){
      m=1;
      ++y;
    }
  }
  int n;
  cin>> n;
  rep(i,n){
    int y,m,d;
    cin >> y >> m >> d;
    cout << hoge[1000*10000000000+1*1000+1]-hoge[y*10000000000+m*1000+d] << endl;
  }
  
  return 0;
}

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

int main()
{
  int number,a[10];
  cin>>number;
  int n1,n2,n3;

    n1 = number%10;
    number /= 10;
    n2 = number%10;
    number /= 10;
    n3 = number%10;
   
    if(n1==7 || n2==7 || n3==7)
    {
      cout<<"Yes"<<endl;
    }
   	else
    {
      cout<<"No"<<endl;
    }
  
  
  
  
  return 0;
}


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

using namespace std;
int main()
{
    string s;
    cin >> s;
    if(s == "Sunny") cout << "Cloudy" << endl;
    if(s == "Cloudy") cout << "Rainy" << endl;
    if(s == "Rainy") cout << "Sunny" << endl;
    return 0;
}

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

if len(t)>len(s):
  print("UNRESTORABLE")
  exit()

ans = []

for i in range(len(s)-len(t)+1):
  for j in range(len(t)):
    if s[i+j] != t[j] and s[i+j]!='?':
      break
  else:
    ans.append((s[:i]+t+s[i+len(t):]).replace('?','a'))

if len(ans) == 0:
  print('UNRESTORABLE')
else:
  ans.sort()
  print(ans[0])


Measured memory_bytes: 3064
N = int(input())
S = str(input())
cnt = []
count = 0

for i in range(1,len(S)):
    if S[i] == "E":
        count += 1
cnt = [count]*N

for i in range(1, len(S)):
    cnt[i] = cnt[i-1]
    if S[i-1] == "W":
        cnt[i] += 1
    if S[i] == "E":
        cnt[i] -= 1
print(min(cnt))


Measured memory_bytes: 15264
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define tc printf("Case %d: ", cs)
#define tcn printf("Case %d:\n", cs);
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);
#define dbg(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;
#define dbg4(w,x, y, z) cerr << #w << " = " << w << ", " <<#x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;


int main()
{
    FASTIO
    /*
    //double start_time = clock();
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
//*/
    int T;
    //cin >> T;
    T = 1;
    for (int cs = 1; cs <= T; cs++) {
        int a, b;
        cin >> a >> b;
        if (b == 1) {
            cout << 0 << endl;
            return 0;
        }
        //cout << (a + b - 1) / a << endl;
        for (int i = 1; i <= 100000; i++) {
            // dbg(i*a - (i - 1));
            if ((i * a) - (i - 1) >= b) {
               // dbg(i * a - (i - 1));
                cout << i << endl;
                return 0;
            }
        }
    }

    //double end_time = clock();
    //printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define REP(i,n) for(ll i=0;i<n;i++)
#define endl "\n"
using namespace std;
const ll INF=1e9;
int a[1000];
void solve(){
ll a,b,c,k;
cin>>a>>b>>c>>k;
if(k<=a)
    cout<<k;
else if(k<=a+b)
    cout<<a;
else
{
    cout<<a-(k-a-b);
}
}

int main(){
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll t=1;
//	cin >> t;
	while(t--){
		solve();
	}


	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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;
}

using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1e9;
const long long LINF = 1LL << 50;
#define int long long

int a[40], b[40], c[40];
int dp[41][401][401];

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, ma, mb; cin >> n >> ma >> mb;
	rep(i, n)cin >> a[i] >> b[i] >> c[i];
	FORR(i, 0, n) {
		FORR(ca, 0, 400) {
			FORR(cb, 0, 400) {
				dp[i][ca][cb] = INF;
			}
		}
	}
	dp[0][0][0] = 0;
	rep(i, n) {
		FORR(ca, 0, 400) {
			FORR(cb, 0, 400) {
				if (dp[i][ca][cb] == INF)continue;
				chmin(dp[i + 1][ca][cb], dp[i][ca][cb]);
				chmin(dp[i + 1][ca + a[i]][cb + b[i]], dp[i][ca][cb] + c[i]);
			}
		}
	}
	int ans = INF;
	FORR(ca, 1, 400) {
		FORR(cb, 1, 400) {
			if (ca*mb == cb * ma)chmin(ans, dp[n][ca][cb]);
		}
	}
	if (ans == INF)ans = -1;
	COUT(ans);
	return 0;
}

Measured memory_bytes: 51712
#include <iostream>
#include <algorithm>

using namespace std;

int main() {

    int num = 0;
    int max_num = 0;
    int N;
    int A[100000];
    int M[100000] = {};

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

    max_num = *max_element(A, A + N);

    for (int i = 0; i < N; ++i) {
        ++M[A[i]];
    }

    for (int i = 0; i <= max_num; ++i) {
//        if (M[i] < 1) continue;
//        int tmp = 0;
//        for (int k = 0; k < N; ++k) {
//            int m = A[k] - i;
//            if (m >= -1 && m <= 1) ++tmp;
//        }
        int tmp = M[i];
        if (i - 1 >= 0) tmp += M[i - 1];
        if (i + 1 <= max_num) tmp += M[i + 1];
        num = max(num, tmp);
    }

    cout << num << endl;
    return 0;
}

Measured memory_bytes: 1024
n=int(input())
array=[int(i) for i in input().split()]

mistake=[]
for i in range(n):
  if array[i]!=i+1:
    mistake.append([i+1,array[i]])

ans='YES'
k=len(mistake)
if k>2:
  ans='NO'
elif k==2:
  if mistake[0][0]!=mistake[1][1]:
    ans='NO'

print(ans)
    

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main() {
  ll n;
  cin >> n;
  vector<vector<P>> s(n);
  REP(i, n) {
    ll a;
    cin >> a;
    REP(j, a) {
      ll x, y;
      cin >> x >> y;
      --x;
      s[i].push_back(P(x, y));
    }
  }

  ll ans = 0;
  REP(bit, 1 << n) {
    ll tmp = 0;
    REP(i, n) {
      if (bit & 1 << i) ++tmp;
    }

    bool ok = true;
    REP(j, n) {
      for (auto t : s[j]) {
        ll q = (bit & 1 << j) ? t.second : -1;
        if (q == -1) continue;

        ll p = (bit & 1 << t.first) ? 1 : 0;

        if (p != q) ok = false;
      }
    }
    if (ok) ans = max(ans, tmp);
  }

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

Measured memory_bytes: 256
S = list(input())
T = input()
ls = []
for i in range(len(S)-len(T)+1):
    for j in range(len(T)):
        if S[i+j] != T[j] and S[i+j] != "?":
            break
    else:
        ls.append(i)

if ls:
    for j in range(len(T)):
        S[ls[-1]+j] = T[j]
    print("".join(S).replace("?", "a"))
else:
    print("UNRESTORABLE")


Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

vector<string> s;
vector<vector<vector<int> > > cnt;

void solve(const vector<int>& index, int pos)
{
    if(index.size() == 1)
        return;

    vector<vector<int> > nextChar(27);
    for(int i : index)
        nextChar[s[i][pos]-'a'+1].push_back(i);

    bool isSame = false;
    for(int i=0; i<27; ++i){
        if(nextChar[i].size() == index.size())
            isSame = true;
    }
    if(isSame){
        solve(index, pos+1);
        return;
    }

    for(int i=0; i<27; ++i){
        if(nextChar[i].empty())
            continue;

        for(int k : nextChar[i]){
            for(int j=0; j<27; ++j){
                cnt[k][j][i] += nextChar[j].size();
            }
        }
        solve(nextChar[i], pos+1);
    }
}

int main()
{
    int n;
    cin >> n;
    s.resize(n);
    for(int i=0; i<n; ++i){
        cin >> s[i];
        s[i] += (char)('a' - 1);
    }

    vector<int> index(n);
    for(int i=0; i<n; ++i)
        index[i] = i;
    cnt.assign(n, vector<vector<int> >(27, vector<int>(27, 0)));
    solve(index, 0);

    int q;
    cin >> q;
    while(--q >= 0){
        int k;
        string p;
        cin >> k >> p;
        -- k;
        p = (char)('a' - 1) + p;

        int ans = 1;
        for(int i=0; i<27; ++i){
            for(int j=i+1; j<27; ++j){
                ans += cnt[k][p[i]-'a'+1][p[j]-'a'+1];
            }
        }
        cout << ans << endl;
    }

    return 0;
}

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




int main(){
  int N; cin>>N;
  vector<int>p(N);
  
  for(int i=0;i<N;i++) cin>>p.at(i);
  
  vector<int>q=p;
  
  sort(p.begin(),p.end());
  
  int count=0;
  
  for(int i=0;i<N;i++){
    if(p.at(i)!=q.at(i))
      count++;
  }
  
  if(count==0 || count==2)
    cout<<"YES";
  else
    cout<<"NO";
}

  

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  long long n,i,a,b,c,d[100010],f[100010]={};
  int ta[100010],co[200010],nt[200010],to[200010],t,r,m,q[100010];
  scanf("%lld",&n);
  for(i=0;i<n;i++)ta[i+1]=-1;
  for(i=0;i<n-1;i++){
    scanf("%lld %lld %lld",&a,&b,&c);
    to[i]=b;
    co[i]=c;
    nt[i]=ta[a];
    ta[a]=i;
    to[i+n-1]=a;
    co[i+n-1]=c;
    nt[i+n-1]=ta[b];
    ta[b]=i+n-1;
  }
  scanf("%lld %d",&n,&m);
  f[q[0]=m]=1;
  d[m]=0;
  for(r=1;r-t;t++){
    for(i=ta[q[t]];i+1;i=nt[i]){
      if(f[to[i]])continue;
      d[to[i]]=d[q[t]]+co[i];
      f[q[r++]=to[i]]=1;
    }
  }
  for(i=0;i<n;i++){
    scanf("%lld %lld",&a,&b);
    printf("%lld\n",d[a]+d[b]);
  }
  return 0;
}


Measured memory_bytes: 6400
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include<cstring>
using namespace std;
int main()
{
	int a,b;
	char c;
	scanf("%d %c %d",&a,&c,&b);
	if(c=='-')
		printf("%d",a-b);
	if(c=='+')
		printf("%d",a+b);
	return 0;
}

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

using namespace std;

#define fi first
#define se second
#define pb push_back
//#define FILE

#define taskname ""
#define taski taskname".in"
#define tasko taskname".out"

typedef long long ll;
typedef unsigned int uint;

const int N = 1e5 + 5;
const int LOG = 20;

int n, m, pr[N], sz[N], in[N], out[N], timer, d[N], p[N][LOG];
bool was[N];
vector <pair <int, int> > g[N];
vector <pair <pair <int, int>, int > > q;

int parent(int x)
{
	if(x == pr[x])
		return x;
	return pr[x] = parent(pr[x]);
}

void unite(int a, int b)
{
	a = parent(a);
	b = parent(b);
	if(a == b)
		return;
	if(sz[a] < sz[b])
	{
		sz[b] += sz[a];
		pr[a] = b;
	} else
	{
		sz[a] += sz[b];
		pr[b] = a;
	}
}

void dfs(int x, int par)
{
	was[x] = true;
	in[x] = timer;
	timer++;
	p[x][0] = par;
	for(auto p_to : g[x])
	{
		int to = p_to.first;
		int dist = p_to.second;
		if(to == par)
			continue;
		d[to] = d[x] + dist;
		dfs(to, x);
	}
	out[x] = timer;
	timer++;
}

bool check(int a, int b)
{
	return in[a] <= in[b] && out[a] >= out[b];
}

int lca(int a, int b)
{
	if(check(a, b)) return a;
	if(check(b, a)) return b;
	int t = LOG - 1;
	while(true)
	{
		if(t < 0)
			return p[a][0];
		if(p[a][t] == -1)
		{
			t--;
			continue;
		}
		if(check(p[a][t], b))
		{
			t--;
			continue;
		}
		a = p[a][t];
		t--;
	}
}

int main()
{
	ios:: sync_with_stdio(false);
	#ifdef HOME
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#elif defined(FILE)
	freopen(taski, "r", stdin);
	freopen(tasko, "w", stdout);
	#endif

	cin >> n >> m;
	for(int i = 0; i < n; i++)
	{
		pr[i] = i;
		sz[i] = 1;
	}
	for(int i = 0; i < m; i++)
	{
		int a, b, d;
		cin >> a >> b >> d;
		a--;b--;
		q.push_back({{a, b}, d});
		if(parent(a) != parent(b))
		{
			g[a].push_back({b, d});
			g[b].push_back({a, -d});
		}
		unite(a, b);
	}
	for(int i = 0; i < n; i++)
		if(!was[i])
			dfs(i, -1);
	for(int i = 1; i < LOG; i++)
		for(int j = 0; j < n; j++)
			if(p[j][i - 1] == -1)
				p[j][i] = -1;
			else
				p[j][i] = p[p[j][i - 1]][i - 1];
	for(int i = 0; i < m; i++)
	{
		int a = q[i].first.first;
		int b = q[i].first.second;
		int dd = q[i].second;
		int c = lca(a, b);
		int dist = -d[a] + d[b];
		if(dist != dd)
		{
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}


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

	private double outer_product(double x, double y, double x1, double y1, double x2, double y2){
		x1 = x1 - x;
		y1 = y1 - y;
		x2 = x2 - x;
		y2 = y2 - y;
		double s = x1 * y2 - y1 * x2;
		return s;
	}

	public void doIt(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			double [] x = new double[3];
			double [] y = new double[3];
			for(int i=0; i < 3; i++){
				x[i] = sc.nextDouble();
				y[i] = sc.nextDouble();
			}
			double xp = sc.nextDouble();
			double yp = sc.nextDouble();
			boolean [] ans = new boolean[3];
			for(int i=0; i < 3; i++){
				ans[i] = outer_product(xp, yp, x[i], y[i], x[(i+1)%3], y[(i+1)%3]) > 0.0;
			}
			if(ans[0] == ans[1] && ans[1] == ans[2]){
				System.out.println("YES");
			}
			else{
				System.out.println("NO");
			}
		}
	}
	public static void main(String[] args) {
		Main obj = new Main();
		obj.doIt();
	}
}

Measured memory_bytes: 12000
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int a, b, c;
      	a = sc.nextInt();
      	b = sc.nextInt();
      	c = sc.nextInt();
      	System.out.println((a+b) >= c ? "Yes" : "No");
    }
}

Measured memory_bytes: 21716
import { readFileSync } from 'fs'

const range = (begin: number, end: number) =>
  Array.from({ length: end - begin }, (_, i) => i + begin)

function main(input: string) {
  const [N, L] = input.trim().split(' ').map(Number)

  const apples = range(L, L + N)

  const sum = apples.reduce((a, b) => a + b)
  const choice = apples.reduce((a, b) => Math.abs(a) > Math.abs(b) ? b : a)

  console.log(sum - choice)
}

main(readFileSync('/dev/stdin', 'utf8').trim())


Measured memory_bytes: 7372
import java.io.*;

class Main{
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int rec=0;
int loz=0;
String line;
while((line=br.readLine())!=null){
String[] value=line.split(",");
int s1=Integer.parseInt(value[0]);
int s2=Integer.parseInt(value[1]);
int d=Integer.parseInt(value[2]);
if(d==Math.hypot(s1,s2)){
rec++;
}
if(s1==s2){
loz++;
}
}
System.out.println(rec);
System.out.println(loz);
}
}

Measured memory_bytes: 15064
#include <iostream>

int main(){
	int x;
	std::cin >> x;
	while(x > 0){
		if(x%10==7){
			std::cout << "Yes" << std::endl;
			return 0;
		}
		x= x/10;
	}
	std::cout << "No" << std::endl;
	return 0;
}


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

int main()
{
  int n, m;
  scanf("%d %d", &n, &m);
  vector<int> a(n);

  int s = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    s += a[i];
  }

  sort(a.begin(), a.end(), greater<int>());
  bool f = true;
  for (int i = 0; i < m; i++)
    if (a[i] * 4 * m < s) {
      f = false;
      break;
    }

  if (f)
    printf("Yes\n");
  else
    printf("No\n");

  return 0;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, atan2, degrees
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    N, X, T = MAP()
    print(ceil(N/X) * T)

if  __name__=='__main__':
    main()


Measured memory_bytes: 10612
import copy
n, k = map(int, input().split())
a = list(map(int, input().split()))
N_min = copy.copy(n)
N_max = copy.copy(n)

while True:
    if not(N_min in a):
        print(N_min)
        break
    if not(N_max in a):
        print(N_max)
        break
    N_min -= 1
    N_max += 1

Measured memory_bytes: 9356
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

int main(void) {
	int num, i, x, y, z, n;
	cin >> num;
	vector<int> ans(num + 1, 0);
	for (x = 1; x < 105; x++) {
		for (y = 1; y < 105; y++) {
			for (z = 1; z < 105; z++) {
				n = (x + y + z) * (x + y + z) - x * (y + z) - y * z;
				if (n <= num)
					ans[n]++;
			}
		}
	}
	for(i = 1; i <= num; i++)
		cout << ans[i] << "\n";
	return 0;
}

Measured memory_bytes: 3552
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
#include<cctype>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iomanip>
#include<sstream>
#include<vector>
#include<cstdlib>
#include<ctime>
#include<list>
#include<deque>
#include<bitset>
#include<fstream>
#define ld double
#define ull unsigned long long
#define ll long long
#define pii pair<int,int >
#define iiii pair<int,pii >
#define mp make_pair
#define INF 1000000000
#define MOD 1000000007
#define rep(i,x) for(int (i)=0;(i)<(x);(i)++)
inline int getint(){
    int x=0,p=1;char c=getchar();
    while (c<=32)c=getchar();
    if(c==45)p=-p,c=getchar();
    while (c>32)x=x*10+c-48,c=getchar();
    return x*p;
}
using namespace std;
//ruogu
string s;
//
int main(){
	cin>>s;
	int n=s.size();
	int tmp=0;
	ll res=0;
	for(int i=n-1;i>=0;i--){
		if(s[i]=='B')res+=1ll*tmp;
		else tmp++;
	}
	printf("%lld\n",res);
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include<iomanip>
using namespace std;
int main(){
    int a,b;
    char op;
    for (int i = 0; i < 20000; i++){
        cin >> a >> op >> b;
        int c;
        if(op == '+'){
            c = a + b;
            cout << c << endl;
        }else if(op == '-'){
            c = a - b;
            cout << c << endl;
        }else if(op == '*'){
            c = a * b;
            cout << c << endl;
        }else if(op == '/'){
            c = a / b;
            cout << c << endl;
        }else{
            break;
        }
    }
}


Measured memory_bytes: 3088
w,h,i,j,f[52][52],d[8]={0,1,1,1,0,-1,-1,-1};rec(x,y,k){if(!f[x][y])return 0;for(f[x][y]=0;k-->0;)rec(x+d[k],y+d[(k+6)%8],8);return 1;}main(n){while(scanf("%d%d",&w,&h),w|h){for(j=1;j<=h;f[w+1][j++]=0)for(i=1;i<=w;f[i++][h+1]=n=0)scanf("%d",&f[i][j]);for(j=1;j<=h;j++)for(i=1;i<=w;)n+=rec(i++,j,8);printf("%d\n",n);}}

Measured memory_bytes: 0
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong();
		long B = sc.nextLong();
		
		for(long i=1; i<=B; i++) {
          //最小公倍数を求めればよいので
          //Aに順にかけてBで割り切れれば答えとなる
			if((A*i)%B==0) {
				System.out.println(A*i);
				break;
			}
		}
	}
}

Measured memory_bytes: 23764
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long[] hi;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var s = ReadLine();
            long mindiff = s.Length / 2;
            for (var i = 'a'; i <= 'z'; ++i)
            {
                var pos = new List<long> { -1 };
                for (var j = 0; j < s.Length; ++j)
                    if (i == s[j])
                        pos.Add(j);
                pos.Add(s.Length);
                var max = pos[1] - pos[0] - 1;
                for (var j = 1; j < pos.Count; ++j)
                    max = Max(max, pos[j] - pos[j - 1] - 1);
                mindiff = Min(mindiff, max);
            }
            WriteLine(mindiff);
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 11220
import std.stdio;
import std.string;
import std.format;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.concurrency;
import std.traits;
import std.uni;
import std.regex;
import core.bitop : popcnt;
alias Generator = std.concurrency.Generator;

enum long INF = long.max/5;
enum long MOD = 10L^^9+7;

void main() {
  long a, b, c;
  scanln(a, b, c);

  if (a+b > c) {
    "No".writeln;
    return;
  }

  writeln(
    4*a*b < (c-a-b)*(c-a-b) ? "Yes" : "No"
  );
}

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


void times(alias fun)(long n) {
  // n.iota.each!(i => fun());
  foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(long n) {
  // return n.iota.map!(i => fun()).array;
  T[] res = new T[n];
  foreach(ref e; res) e = fun();
  return res;
}

T ceil(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  // `(x+y-1)/y` will only work for positive numbers ...
  T t = x / y;
  if (y > 0 && t * y < x) t++;
  if (y < 0 && t * y > x) t++;
  return t;
}

T floor(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  T t = x / y;
  if (y > 0 && t * y > x) t--;
  if (y < 0 && t * y < x) t--;
  return t;
}

ref T ch(alias fun, T, S...)(ref T lhs, S rhs) {
  return lhs = fun(lhs, rhs);
}
unittest {
  long x = 1000;
  x.ch!min(2000);
  assert(x == 1000);
  x.ch!min(3, 2, 1);
  assert(x == 1);
  x.ch!max(100).ch!min(1000); // clamp
  assert(x == 100);
  x.ch!max(0).ch!min(10); // clamp
  assert(x == 10);
}

mixin template Constructor() {
  import std.traits : FieldNameTuple;
  this(Args...)(Args args) {
    // static foreach(i, v; args) {
    foreach(i, v; args) {
      mixin("this." ~ FieldNameTuple!(typeof(this))[i]) = v;
    }
  }
}

void scanln(Args...)(auto ref Args args) {
  enum sep = " ";
  enum n = Args.length;
  enum fmt = n.rep!(()=>"%s").join(sep);

  string line = readln.chomp;
  static if (__VERSION__ >= 2074) {
    line.formattedRead!fmt(args);
  } else {
    enum argsTemp = n.iota.map!(
      i => "&args[%d]".format(i)
    ).join(", ");
    mixin(
      "line.formattedRead(fmt, " ~ argsTemp ~ ");"
    );
  }
}

// fold was added in D 2.071.0
static if (__VERSION__ < 2071) {
  template fold(fun...) if (fun.length >= 1) {
    auto fold(R, S...)(R r, S seed) {
      static if (S.length < 2) {
        return reduce!fun(seed, r);
      } else {
        return reduce!fun(tuple(seed), r);
      }
    }
  }
}

// popcnt with ulongs was added in D 2.071.0
static if (__VERSION__ < 2071) {
  ulong popcnt(ulong x) {
    x = (x & 0x5555555555555555L) + (x>> 1 & 0x5555555555555555L);
    x = (x & 0x3333333333333333L) + (x>> 2 & 0x3333333333333333L);
    x = (x & 0x0f0f0f0f0f0f0f0fL) + (x>> 4 & 0x0f0f0f0f0f0f0f0fL);
    x = (x & 0x00ff00ff00ff00ffL) + (x>> 8 & 0x00ff00ff00ff00ffL);
    x = (x & 0x0000ffff0000ffffL) + (x>>16 & 0x0000ffff0000ffffL);
    x = (x & 0x00000000ffffffffL) + (x>>32 & 0x00000000ffffffffL);
    return x;
  }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	string a;
	int lena,sum=0;
	cin>>a;
	lena=a.size();
	for(int i=0;i<lena;++i)
	if((a[i]=='p'&&a[lena-i-1]=='q')||(a[i]=='d'&&a[lena-i-1]=='b'))
	++sum;
	if(lena%2==0)
	if(sum>=lena/2)
	cout<<"Yes"<<endl;
else cout<<"No"<<endl;
else if(sum>lena/2)
	cout<<"Yes"<<endl;
else cout<<"No"<<endl;
	return 0;
}

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


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

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

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

      
      cin>>n;
      rep(i,n)cin>>a[i];
      sort(a,a+n);
      if(n%2==0){
        cnt=1;
        ll cntt=0;
        rep(i,n){
          if(cnt!=a[i])fl=false;
          cntt++;
          if(cntt==2){
            cnt+=2;
            cntt=0;
          }
        }
      }
      else{
        if(a[0]!=0)fl=false;
        cnt=2;
        ll cntt=0;
        rep(i,n){
          if(i==0)continue;
          if(cnt!=a[i])fl=false;
          cntt++;
          if(cntt==2){
            cnt+=2;
            cntt=0;
          }
        }
      }
      if(!fl)Cout(0);
      else{
        n/=2;
        ans=1;
        rep(i,n){
          ans*=2;
          ans%=MOD;
        }
        Cout(ans);
      }
     

       
return 0;
}


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

using namespace std;



#include <bits/stdc++.h>

using namespace std;


typedef long long ll;
ll mod=1e9+0LL;
ll MOD=1e18+0LL;
double pi=acos(-1);


int main()
{
    int cs=1;
    //scanf("%d",&cs);
    while(cs--)
    {
        ll n;
        int i,j;
        ll ans=0;
        cin>>n;
        for(i=2;i<=1000010;i++)
        {
            int cnt=0;
            while(n%i==0)
            {
                n/=i;
                cnt++;
            }
            if(!cnt) continue;
            for(j=1;j<=100;j++)
            {
                if(cnt<j) break;
                ans++;
                cnt-=j;
            }
        }
        if(n>1) ans++;
        cout<<ans<<"\n";
    }
}

Measured memory_bytes: 3636
#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 =(1e9)+7;
using P = pair<ll,ll>;

int main() {
    int n,k;cin >>n>>k;
    string s;cin >>s;
    vector<int>num;
    int now=1;
    int cnt=0;
    for (int i = 0; i < n; ++i) {
        if(s[i]==(char)('0'+now)){
            cnt++;
        }
        else {
            num.push_back(cnt);
            now=1-now;
            cnt=1;
        }
    }
    if(cnt!=0)num.push_back(cnt);
    if(num.size()%2==0)num.push_back(0);
//    for(auto u:num){
//        cout <<u <<" ";
//    }
//    cout <<endl;
    vector<int>sum(num.size()+1,0);
    for (int i = 0; i < num.size(); ++i) {
        sum[i+1]=sum[i]+num[i];
    }
    int ans=1;
//    for(auto u:num){
//        cout <<u <<" ";
//    }
//    cout <<endl;
    for (int i = 0; i < num.size(); i+=2) {
        int left=i;
        int right=min(i+2*k+1,(int)num.size());
        int tmp=sum[right]-sum[left];
        ans=max(ans,tmp);
    }
    cout <<ans <<endl;
    return 0;
}



Measured memory_bytes: 1272
#include<iostream>
#include<iomanip>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<functional>
#include<math.h>
#include<unordered_set>
using namespace std;
const int MAX = 100001;
const int INF = 1 << 30;

int main() {
	int K;
	int table[MAX];
	deque<pair<int, int>> deq;

	cin >> K;

	for (int i = 0; i < K; i++)table[i] = INF;
	deq.push_front(make_pair(1, 1));

	while (!deq.empty()) {
		int f = deq.front().first;
		int s = deq.front().second;
		deq.pop_front();

		
		if (table[f] != INF)continue;

		table[f] = s;
		if (f == 0)break;

		int a = (f + 1) % K;
		int b = (f * 10) % K;

		if (table[a] > table[f] + 1) {
			deq.push_back(make_pair(a, table[f] + 1));
		}

		if (table[b] > table[f]) {
			deq.push_front(make_pair(b, table[f]));
		}
	}

	cout << table[0] << endl;

	return 0;
}

Measured memory_bytes: 1152
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
using namespace std;

int p[2100000];
int tx[2100000];
int w, h;
long long ans;
int toth, totw;

bool cmp(int x, int y) {
	return p[x] < p[y];
}

int main() {
	scanf("%d%d", &w, &h);
	for (int i = 0; i < w + h; i++)
		scanf("%d", &p[i]);
	for (int i = 0; i < w + h; i++)
		tx[i] = i;
	sort(tx, tx + w + h, cmp);
	totw = 0;
	toth = 0;
	for (int i = 0; i < w + h; i++)
		if (tx[i] < w) {
			ans += 1LL * p[tx[i]] * (h + 1 - toth);
			totw += 1;
		}else {
			ans += 1LL * p[tx[i]] * (w + 1 - totw);
			toth += 1;
		}
	cout << ans << endl;
}


Measured memory_bytes: 3072
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = Integer.parseInt(scanner.next());
        int b = Integer.parseInt(scanner.next());
        int c = Integer.parseInt(scanner.next());

        List<Integer> list = Arrays.asList(a, b, c);
        List<String> stringList = list.stream()
                .sorted(Comparator.naturalOrder())
                .map(integer -> String.valueOf(integer.intValue()))
                .collect(Collectors.toList());

        String answer = String.join(" ", stringList);

        System.out.println(answer);
    }
}

Measured memory_bytes: 31964
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<queue>

using ll = long long;

using namespace std;

int main(){
	ll n;
	cin >> n;
	ll sum = 0;
	ll mx = 0;
	
	vector<int> table(n+1,0);
	for(ll i = 1; i <= n; i++){
		sum += i;
		table[i] = 1;
		if(sum >= n){
			mx = i;
			break;
		}
	}
	
	table[sum - n] = 0;
	
	for(int i = 1; i <= mx; i++){
		if(table[i] == 1){
			cout << i << endl;
		}
	}
	
	return 0;
}
 

Measured memory_bytes: 42336
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(50) << setiosflags(ios::fixed);
  int n;
  cin >> n;
  bool b = true;
  rep(i, n)
  {
    int a;
    cin >> a;
    if (a % 2 == 0 && (a % 3 != 0 && a % 5 != 0))
    {
      b = false;
      break;
    }
  }
  cout << (b ? "APPROVED" : "DENIED") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <string>
using namespace std;
typedef long long ll;

int D[100005][26];

int main() {
  ios::sync_with_stdio(false);
  string S, T;
  cin >> S >> T;
  int N = S.size();
  memset(D[N], -1, sizeof(int) * 26);
  for (int i=N-1; i>=0; i--) {
    memcpy(D[i], D[i+1], sizeof(int) * 26);
    D[i][S[i]-'a'] = i;
  }
  ll ret = 0;
  int idx = 0;
  for (int i=0; i<T.size(); i++) {
    int v = D[idx][T[i]-'a'];
    if (idx == 0 && v < 0) {
      ret = -1;
      break;
    }
    if (v < 0) {
      ret += N - idx;
      idx = 0;
      v = D[idx][T[i]-'a'];
      if (idx == 0 && v < 0) {
        ret = -1;
        break;
      }
    }
    ret += v + 1 - idx;
    idx = v + 1;
  }
  cout << ret << endl;
}

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

int main(){
  int64_t a,b;
  cin >> a >> b;
  //最小公倍数
  int64_t m = max(a,b);
  int64_t l = 0;
  for(int i = m; i >=1; i--){
    if(a%i==0&&b%i==0){
      l = i;
      break;
    }
  }
  cout << l*(a/l)*(b/l) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n;
  float ans=0;
  scanf("%d",&n);
  float t=(n+1)/2;
  if(n==1){
    ans=1;
  }
  else if(n%2==0){
    ans=0.5;
  }
  else{
    ans=t/n;
  }
  printf("%f\n",ans);
  return 0;
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define log_2(a) (log((a)) / log(2))
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 500005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    string s;
    cin >> s;
    LL res[SIZE];
    for(int i = 0; i < SIZE; ++i) {
        res[i] = -1;
    }

    if(s[0] == '<') {
        res[0] = 0;
        int p = 0;
        while(p < s.size() && s[p] == '<') {
            res[p + 1] = res[p] + 1;
            ++p;
        }
    }

    for(int i = 1; i < s.size(); ++i) {
        if(s[i - 1] == '>' && s[i] == '<') {
            res[i] = 0;
            int p = i - 1;
            while(p >= 0 && s[p] == '>' && res[p] < res[p + 1] + 1) {
                res[p] = res[p + 1] + 1;
                --p;
            }

            p = i;
            while(p < s.size() && s[p] == '<') {
                res[p + 1] = res[p] + 1;
                ++p;
            }
        }
    }

    if(s[s.size() - 1] == '>') {
        res[s.size()] = 0;
        res[s.size() - 1] = 1;
        int p = s.size() - 2;
        while(p >= 0 && s[p] == '>' && res[p] < res[p + 1] + 1) {
            res[p] = res[p + 1] + 1;
            --p;
        }
    }

    LL sum = 0;
    for(int i = 0; i <= s.size(); ++i) {
        sum += res[i];
    }
    cout << sum << endl;
    return 0;
}



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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

int main(){
	cin.tie(NULL);
	ios::sync_with_stdio(false);
	//insert code
	int h,w;
	cin>>h>>w;
	vector<vector<char>>mat(h,vector<char>(w));
	rep(i,0,h){
		rep(j,0,w)cin>>mat[i][j];
	}
	
	vector<vector<ll>>dp(h,vector<ll>(w));
	dp[0][0]=1;
	rep(i,1,h){
		dp[i][0]=(mat[i][0]=='.')?dp[i-1][0]:0;
	}
	rep(i,1,w){
		dp[0][i]=(mat[0][i]=='.')?dp[0][i-1]:0;
	}
	for (int i=1;i<h;i++){
		for (int j=1;j<w;j++){
			if (mat[i][j]=='#')dp[i][j]=0;
			else{
				dp[i][j]=dp[i-1][j]+dp[i][j-1];
				if (dp[i][j]>=hell)dp[i][j]-=hell;
			}
		}
	}
	cout<<dp[h-1][w-1]<<endl;
	return 0;
}

Measured memory_bytes: 9088
from collections import Counter 
from collections import defaultdict
from collections import deque
from functools import reduce
import math
import itertools
import heapq
import numpy as np
import bisect
import sys
sys.setrecursionlimit(10**6)


def bfs(s,n,node):
    #頂点が探索済みかどうかのチェック配列
    check=[False for _ in range(n)]
    check[s]=True
    #次見る頂点を格納するキュー
    queue=deque([s])
    visited_num=1

    #問題固有の配列
    #color_check=[[True for _ in range(l)] for _ in range(n)]
    color=[-1 for _ in range(n)]
    color[s]=0
    
    while visited_num<n:
        #グラフが全連結ではない場合
        if len(queue)==0:
            #空配列を返す
            #現状までの計算済み配列を返してもいいと思う
            return color

        now_vertex=queue.popleft()
        #インデックスがない場合は
        for next_vertex in node[now_vertex]:


            if check[next_vertex]==True:
                continue

            queue.append(next_vertex)
            check[next_vertex]=True

            #問題固有の計算
            color[next_vertex]=color[now_vertex]+1
            visited_num+=1

    return color

#n=int(input())z
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
ceil=lambda x,y: (x+y-1)//y
input_list = lambda : list(map(int,input().split()))



#n=int(input())
#n,m=input_list()
#a=input_list()
a=input().split()
n=int(a[0])
m=a[1]
ans=0
ans+=n*int(m[0])
ans+=n*int(m[2])//10
ans+=n*int(m[3])//100
mod=0
tmp=int(str(n*int(m[2]))[-1])
if tmp<10:
    tmp*=10
mod+=tmp
#print(mod)
tmp=int(str(n*int(m[3]))[-2:])
mod+=tmp
#print(ans)
#print(mod)
print(ans+mod//100)

Measured memory_bytes: 27200