akhauriyash/Code-Regression huggingface dataset:
void main() {
	auto s = rs.to!(dchar[]);
	s[5] = s[13] = ' ';
	s.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


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

using namespace std;

int gcd(int a,int b){
    int c = max(a,b);
    int d = min(a,b);
    while(c % d != 0){
        int e = c % d;
        c = d;
        d = e;
    }
    return d;
}

int N;
int A[100000];
int r[100000];
int l[100000];

int main(){
    cin >> N;
    for(int i=0;i<N;i++) cin >> A[i];
    l[0] = A[0];
    for(int i=1;i<N;i++) l[i] = gcd(l[i-1],A[i]);
    r[N-1] = A[N-1];
    for(int i=N-2;i>=0;i--) r[i] = gcd(r[i+1],A[i]);
    int m = max(l[N-2],r[1]);
    for(int i=1;i<N-1;i++){
        int n = gcd(l[i-1],r[i+1]);
        m = max(m,n);
    }
    cout << m << endl;
    return 0;
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define pb            push_back
template<class T, class S> inline pair<T, S> mp(T x, S y){ return make_pair(x, y); }
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

static const int    INF = 1000000000;
static const ll     MOD = 1000000007LL;
static const double EPS = 1E-12;

int e;

int main()
{
  while(cin >> e, e){
    int res = e;
    for(int y=0; y*y<=e; y++){
      for(int z=0; z*z*z<=e; z++){
        int x = e - z * z * z - y * y;
        if(x >= 0) minup(res, x + y + z);
      }
    }
    cout << res << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
/*#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2")  //Enable AVX*/

using namespace std;

using ll = long long;

#define mp make_pair

const int p = 1e9 + 7;


int mul(int a, int b) {
    return (1LL * a * b) % p;
}

int add(int a, int b) {
    int s = (a+b);
    if (s>=p) s-=p;
    return s;
}

int sub(int a, int b) {
    int s = (a+p-b);
    if (s>=p) s-=p;
    return s;
}

int po(int a, int deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}

int inv(int n)
{
    return po(n, p-2);
}

/*struct DSU {
    vector<int> sz;
    vector<int> parent;

    void make_set(int v) {
        parent[v] = v;
        sz[v] = 1;
    }

    int find_set(int v) {
        if (v == parent[v])
            return v;
        return parent[v] = find_set(parent[v]);
    }

    void union_sets(int a, int b) {
        a = find_set(a);
        b = find_set(b);
        if (a != b) {
            if (sz[a] < sz[b])
                swap(a, b);
            parent[b] = a;
            sz[a] += sz[b];
        }
    }

    DSU(int n) {
        sz.resize(n);
        parent.resize(n);
        for (int i = 0; i < n; i++) make_set(i);
    }
};*/

vector<vector<int>> G;

vector<int> even, odd;

void dfs(int v, int par = -1, bool ev = true)
{
    if (ev) even.push_back(v);
    else odd.push_back(v);
    for (auto it: G[v]) if (it!=par) dfs(it, v, !ev);
}

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

    int n;
    cin>>n;
    G.resize(n+1);

    int u, v;
    for (int i = 0; i<n-1; i++)
    {
        cin>>u>>v; G[u].push_back(v); G[v].push_back(u);
    }



    dfs(1);

    vector<queue<int>> A(3);

    for (int i = 1; i<=n; i++) A[i%3].push(i);

    if (even.size()>odd.size()) swap(even, odd);

    vector<int> answer(n+1);

    if (even.size()<=n/3)
    {
        for (int i = 0; i<even.size(); i++) {answer[even[i]] = A[0].front(); A[0].pop();}
        int cur = 0;
        for (int i = 0; i<3; i++)
        {
            while (!A[i].empty())
            {
                answer[odd[cur]] = A[i].front();
                A[i].pop();
                cur++;
            }
        }
        for (int i = 1; i<=n; i++) cout<<answer[i]<<' ';
        return 0;
    }
    int cur1 = 0;
    while (!A[1].empty())
    {
        answer[even[cur1]] = A[1].front();
        A[1].pop();
        cur1++;
    }
    while (cur1<even.size())
    {
        answer[even[cur1]] = A[0].front();
        A[0].pop();
        cur1++;
    }
    cur1 = 0;
    while (!A[2].empty())
    {
        answer[odd[cur1]] = A[2].front();
        A[2].pop();
        cur1++;
    }
    while (cur1<odd.size())
    {
        answer[odd[cur1]] = A[0].front();
        A[0].pop();
        cur1++;
    }

    for (int i = 1; i<=n; i++) cout<<answer[i]<<' ';

}

Measured memory_bytes: 20980
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <numeric>

constexpr intmax_t  operator ""_jd(unsigned long long n) { return n; }
constexpr uintmax_t operator ""_ju(unsigned long long n) { return n; }
constexpr size_t    operator ""_zu(unsigned long long n) { return n; }
// constexpr ptrdiff_t operator ""_td(unsigned long long n) { return n; }

int testcase_ends() {
  std::vector<intmax_t> a(8);
  intmax_t cs;
  for (auto& ai: a) scanf("%jx", &ai);
  scanf("%jx", &cs);

  intmax_t const mask = (1_jd << 32) - 1;
  intmax_t k = 0;
  for (int i = 0; i < 32; ++i) {
    intmax_t s = 0;
    for (auto ai: a) s += ai;
    s &= mask;
    if ((cs >> i & 1) != (s >> i & 1)) {
      k |= 1_jd << i;
      for (auto& ai: a) ai ^= 1_jd << i;
    }
  }

  printf("%jx\n", k);
  return 0;
}

int main() {
  int n;
  scanf("%d", &n);
  while (n--) testcase_ends();
}



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

int main() {
	int x;
	scanf("%d",&x);
	if (x >= 1800) printf("1");
	else 
	if (x >= 1600) printf("2");
	else 
	if (x >= 1400) printf("3");
	else 
	if (x >= 1200) printf("4");
	else 
	if (x >= 1000) printf("5");
	else
	if (x >= 800) printf("6");
	else 
	if (x >= 600) printf("7");
	else 
	if (x >= 400) printf("8");
}


Measured memory_bytes: 3680
#define _USE_MATH_DEFINES // for C++  
#include "bits/stdc++.h"
#define NUM ((long long)1000000007)
#define int unsigned long long

using namespace std;

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

    int n;
    cin >> n;

    if (n % 2 == 0)
    {
        cout << n << endl;
    }
    else
    {
        cout << 2 * n << endl;
    }
}

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

int main() {
    int n;cin>>n;
    long long int a[n],ans=0;
    
    for(int i=0;i<n;++i){
        cin>>a[i];
        while(a[i]%2==0 && a[i]>0){
            ans+=1;
            a[i]/=2;
        }
    }
    
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
int main(){
  int X,ans;
  scanf("%d",&X);
  if(X>=1800) ans=1;
  else if(X>=1600) ans=2;
  else if(X>=1400) ans=3;
  else if(X>=1200) ans=4;
  else if(X>=1000) ans=5;
  else if(X>=800) ans=6;
  else if(X>=600) ans=7;
  else ans=8;
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 1736
#define _USE_NATH_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>
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using namespace std;

#define INF 100000000

int main() {
	int a, b;
	cin >> a >> b;
	int sum = 0;
	rep(i, 2) {
		if (a >= b) {
			sum += a;
			a--;
			
		}
		else if (a < b) {
			sum += b;
			b--;
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
from sys import stdin
def main():
  from builtins import int, range
  readline = stdin.readline
  n, w = map(int, readline().split())
  maxv = 10 ** 3 * n + 1
  t = [-1] * maxv
  t[0] = w
  cmaxv = 0
  for _ in range(n):
    nw, nv = map(int, readline().split())
    for i in range(cmaxv, -1, -1):
      ti = t[i]
      if ti == -1:
        continue
      if t[i + nv] < ti - nw:
        t[i + nv] = ti - nw
        if cmaxv < i + nv:
          cmaxv = i + nv
  print(cmaxv)
main()


Measured memory_bytes: 5392
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int gcd(int a,int b)
{
	if(b==0)
	return a;
	
	return gcd(b,a%b);
}
int power(int x,int y,int p)
{
	int res=1;
	x=x%p;
	while(y>0)
	{
		if(y&1)
		res=(res*x)%p;
		
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}
int modInverse(int n,int p)
{
	return power(n,p-2,p);
}
int main() {
	// your code goes here
	 ios_base::sync_with_stdio(0);
	 cin.tie(0);
	 int n;
	 cin>>n;
	 vector<int> v(n);
	 for(int i=0;i<n;i++)
	 cin>>v[i];
	 
	 int mi = v[0],ma = v[0];
	 ll ans = 1000;
	 for(int i=1;i<n;i++)
	 {
		 ma = v[i];
		 mi = min(mi,v[i]);
		 if(mi!=ma)
		 {
			ll f = (ans/mi)*ma;
			f = ans%mi+f;
			ans = f;
			mi = ma;
		}
	 }
	 cout<<ans;
}


Measured memory_bytes: 3644
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

const ll INF = 1LL << 50;

const ll mod = 1e9 + 7;

struct UnionFind {
  vector<ll> par, sizes;
  ll cnt;
  UnionFind(ll N) : par(N), sizes(N, 1), cnt(N) {
    for (ll i = 0; i < N; i++) par[i] = i;
  }

  ll find(ll x) { return par[x] == x ? x : par[x] = find(par[x]); }

  bool same(ll x, ll y) { return find(x) == find(y); }

  ll size(ll x) { return sizes[find(x)]; }

  void unite(ll x, ll y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (sizes[x] < sizes[y]) swap(x, y);
    par[y] = x;
    sizes[x] += sizes[y];
    cnt--;
  }

  ll count() const { return cnt; }
};

int main() {
  using TD = tuple<double, ll, ll>;

  while (true) {
    ll n;
    cin >> n;
    if (n == 0) break;

    vector<double> xs(n), ys(n), zs(n), rs(n);
    rep(i, n) cin >> xs[i] >> ys[i] >> zs[i] >> rs[i];

    priority_queue<TD, vector<TD>, greater<TD>> pq;
    for (ll i = 0; i < n - 1; i++) {
      for (ll j = 0; j < n; j++) {
        double d = (xs[i] - xs[j]) * (xs[i] - xs[j]);
        d += (ys[i] - ys[j]) * (ys[i] - ys[j]);
        d += (zs[i] - zs[j]) * (zs[i] - zs[j]);
        d = max(0.0, sqrt(d) - rs[i] - rs[j]);
        pq.emplace(d, i, j);
      }  // j
    }    // i
    UnionFind uf(n);
    double ans = 0.0;
    while (!pq.empty()) {
      double d;
      ll u, v;
      tie(d, u, v) = pq.top();
      pq.pop();
      if(!uf.same(u, v)){
        uf.unite(u, v);
        ans += d;
      }
    }
    printf("%.3f\n", ans);
  }

  return 0;
}



Measured memory_bytes: 3496
import sys
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()))

import itertools

n,m,q=MAP()

a=[list(MAP()) for i in range(q)]

ans=0
for ls in list(itertools.combinations_with_replacement(range(1,m+1), n)):
    res=0
    for i in range(len(a)):
        if ls[a[i][1]-1]-ls[a[i][0]-1]==a[i][2]:
            res+=a[i][3]
    if ans<=res:
        ans=res
print(ans)


Measured memory_bytes: 21484
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int main(){
    int N;
    while(cin >> N){
        map<int, int> mp;
        for(int i=0;i<N;i++){
            int t; cin >> t;
            if(!mp.count(t)) mp[t] = 0;
            ++mp[t];
        }
        vector<int> cnt;
        for(auto it : mp){
            cnt.push_back(it.second);
        }
        sort(cnt.begin(), cnt.end());
        int b = cnt.size();
        vector<int> kind(N, 0);
        for(int i=1;i<=N;i++){
            while(b > 0 && cnt[cnt.size()-b] < i) --b;
            kind[i-1] = b;
        }
        int last = 0;
        vector<int> res(N);
        for(int i=N-1;i>0;i--){
            while(kind[last] >= i+1) ++last;
            res[i] = last;
            int up = last;
            for(int j=last;j<N&&up;j++){
                int add = min(i - kind[j], up);
                kind[j] += add;
                up -= add;
            }
        }
        res[0] = N;
        for(auto t : res) cout << t << endl;
    }
}

Measured memory_bytes: 17904
#include <iostream>
#include<vector>
#include<algorithm>
#include <queue>
#include <string>
#include <set>
#include <bitset>

using namespace std;
#define ff(i,n,m) for(int i=n;i<m;i++)
#define i64 int64_t
#define tos(x) to_string(x)

int main() {
	string s;
	cin >> s;
	ff(i, 0, s.size()) {
		if (i == 5 || i == 13) {
			cout << " ";
			continue;
		}
		cout<<s.at(i);
	}
	return 0;
}


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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 110000;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    if (a >= k)
    {
        cout << k << "\n";
    }
    else if (a + b >= k)
    {
        cout << a << "\n";
    }
    else
    {
        ll cur = k - a - b;
        cout << a - cur << "\n";
    }
    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int A,B;
  cin >> A >> B;
  if(A%3==0 || B%3==0 || (A+B)%3==0){
    cout << "Possible" << endl;
  }else{
    cout << "Impossible" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
    char str[512]={0};
    int k=0,u=0,p=0,c=0;
    scanf("%s",str);
    for(int i = 0;i < strlen(str); i++){
        if(str[i] == 'K')k++;
        else if(str[i] == 'U')u++;
        else if(str[i] == 'P')p++;
        else if(str[i] == 'C')c++;
    }
    int ans = 0;
    ans = min(k,min(u,min(p,c)));
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 968
a = [list(map(int, input().split())) for i in range(3)]
for i in range(101):
    b1 = a[0][0] - i
    b2 = a[0][1] - i
    b3 = a[0][2] - i
    a1 = i
    a2 = a[1][0] - b1
    a3 = a[2][0] - b1
    A = [a1, a2, a3]
    B = [b1, b2, b3]
    flag = True

    for l in range(3):
        for r in range(3):
            if A[l]<0 or B[r] < 0 or a[l][r]!=A[l]+B[r]:
                flag = False
    if flag:
        print('Yes')
        exit()

print('No')


Measured memory_bytes: 3064
#include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#define EPS 1e-9
#define INF MOD
#define MOD 1000000007LL
#define fir first
#define iss istringstream
#define sst stringstream
#define ite iterator
#define ll long long
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define sec second
#define sh(i) (1LL<<i)
#define sz size()
#define vi vector<int>
#define vc vector
#define vl vector<ll>
#define vs vector<string>

int n,m,x,y,d[510][510];
string s,p,g;

int main(){
	while(cin>>n>>m,n){
		map<string,int> M;
		rep(i,n)rep(j,n)d[i+1][j+1]=(i!=j)*INF;
		cin>>s>>p>>g;
		M[s]=1,M[p]=2,M[g]=3;
		int cur=4;
		rep(i,m){
			cin>>s>>g>>x>>y;
			if(!M[s])M[s]=cur++;
			if(!M[g])M[g]=cur++;
			d[M[s]][M[g]]=d[M[g]][M[s]]=x/40+y;
		}
		rep2(k,1,n+1)rep2(i,1,n+1)rep2(j,1,n+1)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
		cout<<d[1][2]+d[2][3]<<endl;
	}
}

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

constexpr long long money = 1000000000000000;
long long int N, M, s, t, u, v, a, b, ds[101010], us[101010], dt[101010], ut[101010];
vector<pair<long long int, pair<long long int, long long int>>> edges[101010];
vector<long long> ans;

int main(){
    scanf("%lld%lld%lld%lld", &N, &M, &s, &t);
    for(int i = 0; i < M; ++i){
        scanf("%lld%lld%lld%lld", &u, &v, &a, &b);
        edges[u].emplace_back(v, make_pair(a, b));
        edges[v].emplace_back(u, make_pair(a, b));
    }
    fill(ds, ds + 101010, money * 570);
    fill(dt, dt + 101010, money * 570);
    fill(us, us + 101010, 0);
    fill(ut, ut + 101010, 0);
    {
        priority_queue<pair<long long, long long>, vector<pair<long long, long long>>, greater<pair<long long, long long>>> q;
        q.emplace(0, s);
        while(!q.empty()){
            auto S = q.top();
            q.pop();
            if(us[S.second])continue;
            us[S.second] = true;
            ds[S.second] = S.first;
            for(auto i : edges[S.second]){
                if(ds[i.first] <= S.first + i.second.first)continue;
                q.emplace(S.first + i.second.first, i.first);
            }
        }
    }
    {
        priority_queue<pair<long long, long long>, vector<pair<long long, long long>>, greater<pair<long long, long long>>> p;
        p.emplace(0, t);
        while(!p.empty()){
            auto T = p.top();
            p.pop();
            if(ut[T.second])continue;
            ut[T.second] = true;
            dt[T.second] = T.first;
            for(auto i : edges[T.second]){
                if(dt[i.first] <= T.first + i.second.second)continue;
                p.emplace(T.first + i.second.second, i.first);
            }
        }
    }
    long long a = money * 570;
    for(int i = N; i > 0; --i){
        //cout << i << " : " << ds[i] << " " << dt[i] << endl;
        a = min(a, ds[i] + dt[i]);
        ans.push_back(a);
    }
    reverse(ans.begin(), ans.end());
    for(auto i : ans){
        cout << money - i << endl;
    }
    return 0;
}

Measured memory_bytes: 16996
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, Q;
    const ll INF = LLONG_MAX / 3;
    while(cin >> N >> Q) {
        map<int, ll> m;
        m[0] = INF;
        m[N] = 0;

        while(Q--) {
            int a;
            ll b;
            cin >> a >> b;
            while(b) {
                auto rit = m.lower_bound(a);
                auto lit = prev(rit);
                int d = a - lit->first;
                ll c = min(b / d, lit->second - rit->second);
                if(c) {
                    m[a] = rit->second + c;
                    b -= (ll)c*d;
                    if(b && c < lit->second - rit->second) {
                        m[lit->first + b] = m[a] + 1;
                        b = 0;
                    }
                } else {
                    m[lit->first + b] = rit->second + 1;
                    b = 0;
                }
                if(lit->second == next(lit)->second) {
                    m.erase(lit);
                }
            }
        }

        vll ans(N);
        for(auto i = m.begin(); next(i) != m.end(); ++i) {
            auto j = next(i);
            FOR(k, i->first, j->first) {
                ans[k] = j->second;
            }
        }

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

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

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

#define INF 1 << 30
#define REP(i,n) for(ll i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(ll i=(k);i<(int)(n);i++)



vector<bool> gen_sosuu(vector<bool> sosuu){
  int size = sosuu.size();
  REP(i,size){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(size)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<size;j++){
      sosuu[i*j] =false;
    }
  }
  return sosuu;
}

int n;
int p[200001];
int main(){
  cin >>n;
  REP(i,n){
    int x;
    cin >> x;
    p[x] = i+1;
  }
  FOR(i,1,n+1) cout << 30000*i << " ";
  cout <<endl;
  FOR(i,1,n+1) cout << 30000*(n-i) + p[i] << " ";
  cout <<endl;
}


Measured memory_bytes: 768
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <chrono>
#include <vector>

using namespace std;
long long cost[5100][5100];

int main()
{
    int n;
    long long a, b;
    cin >> n >> a >> b;
    vector<int> p(n + 2);
    for (int i = 1; i <= n; i++)
    {
        cin >> p[i];
    }

    long long inf = 1e18;
    p[n + 1] = n + 1;
    cost[0][0] = 0;
    for (int i = 1; i <= n + 1; i++)
    {
        cost[i][i] = inf;
        for (int j = 0; j < i; j++)
        {
            if (p[i] > p[j])
            {
                cost[i][i] = min(cost[i - 1][j], cost[i][i]);
            }
            cost[i][j] = cost[i - 1][j] + (p[i] > p[j] ? a : b);
        }
    }

    cout << cost[n + 1][n + 1] << endl;
    return 0;
}

Measured memory_bytes: 199168
#include <stdio.h>
#include <string.h>

int main()
{
	char stra[11], strb[11], stru[11];
	int a, b;
	scanf("%s %s", stra, strb);
	scanf("%d %d", &a, &b);
	scanf("%s", stru);
	if(strcmp(stra, stru) == 0){
		printf("%d %d\n", a - 1, b);
	}else{
		printf("%d %d\n", a, b-1);
	}
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;
int d[45];
int main(){
    int n;
    cin>>n;
    d[0]=d[1]=1;
    for(int i=2;i<=n;i++){
        d[i]=d[i-1]+d[i-2];
    }
    cout<<d[n]<<endl;
    return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>

#define DEBUG(x) cout<<#x<<": "<<x<<endl

using namespace std;

int main(){

	long long N, M;

	cin >> N >> M;

	vector<long long> A;
	A.push_back(0);

	for(long long i = 0; i < N; i++){
		long long x;
		cin >> x;
		A.push_back((A[i]+x)%M);
	}

	map<long long, long long> m;

	for(long long i = 0; i< A.size(); i++){
		if(m.find(A[i]) != m.end()) m[A[i]]++;
		else m.insert(make_pair(A[i], 1));
	}

	long long ans = 0;
  for(auto itr = m.begin(); itr != m.end(); itr++){
		ans += ((itr->second) * (itr->second - 1))/2;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 4980
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

fn main() {
    input!{
        _n: usize,
        s: chars,
    }
    let mut hold = ' ';
    let mut answer = 0;
    for c in s {
        if c == hold {
            continue;
        }
        answer += 1;
        hold = c;
    }

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


Measured memory_bytes: 4352
#include <stdio.h>

int main(void){
	char s[11];
	scanf("%s",s);
	int year = (s[0]-'0')*1000 + (s[1]-'0')*100 + (s[2]-'0')*10 + (s[3]-'0');
	int month= (s[5]-'0')*10 + (s[6]-'0');
	int day = (s[8]-'0')*10 + (s[9]-'0');
	if( year > 2019){
		printf("TBD");
		return 0;
	}else if(month>4){
		printf("TBD");
		return 0;
	}else if(day>30){
		printf("TBD");
		return 0;
	}
	printf("Heisei");
	return 0;
}

Measured memory_bytes: 128
T = input().rstrip().split(" ")
N = int(T[0])
M = int(T[1])
ss = []
for i in range(N):
    T = input().rstrip().split(" ")
    ss.append(T)
dd = []
for i in range(M):
    T = input().rstrip().split(" ")
    dd.append(T)
ans = []
for i in range(N):
    px = int(ss[i][0])
    py = int(ss[i][1])
    list = []
    for j in range(M):
        dx = int(dd[j][0])
        dy = int(dd[j][1])
        MD = abs(px - dx) + abs(py - dy)
        list.append(MD)
    ans.append(list.index(min(list))+1)
for i in range(len(ans)):
    print(ans[i])

Measured memory_bytes: 3064
def divisors(n):
    lower_divisors=[]
    upper_divisors=[]
    i=1
    while i*i<=n:
        if n%i==0:
            lower_divisors.append(i)
            if i!=n//i:
                upper_divisors.append(n//i)
        i+=1
    return lower_divisors+upper_divisors[::-1]

n=int(input())
cnt=0
for i in range(1,n+1,2):
    if len(divisors(i))==8:
        cnt+=1
print(cnt)

Measured memory_bytes: 8976
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define all(a)      (a).begin(),(a).end()
#define debug_array(a,n) for (ll bccc=(0); bccc<(n); bccc++) cout<<a[bccc]<<" "
#define debug_vector(a) for(ll bccc=(0); bccc<(a.size());bccc++) cout<<a[bccc]<<" "
#define F           first
#define S           second
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<pair<ll,ll>,null_type,less<pair<ll,ll> >,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
/* ll t = 0;
ordered_multiset me;
...
me.insert({x, t++});
me.erase(me.lower_bound({x, 0}));
cout << me.order_of_key({x, 0}) << "\n";

///////////   t is insertion time
*/
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
typedef long double lld;
lld pi=3.14159265358;
ll powr(ll a,ll b)
{
    ll c=1;
    ll i;
    for(i=0;i<b;i++)
        c*=a;
    return c;
}
//ll hell=1000000007;
ll hell=998244353 ;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
// mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());  after namespace std
// srand(chrono::high_resolution_clock::now().time_since_epoch().count()); after ios:base
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,i;
    cin>>n;
    map<string,ll> m;
    for(i=0;i<n;i++)
    {
        string s;
        cin>>s;
        sort(all(s));
        m[s]++;
    }
    map<string,ll>::iterator it;
    ll ans=0;
    for(it=m.begin();it!=m.end();it++)
    {
        ans+=((it->S)*(it->S - 1))/2;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args&&... args) {
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#define ll long long
const int N = 2e6 + 15;
int main(){
	int n, m;
	cin >> n >> m;
	int a[n];
	ll sum = 0;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		sum += a[i];
	}
	int cnt = 0;
	for (int i = 0; i < n; ++i) {
		if (a[i]*4LL*m >= sum)
			cnt++;
	}
	if (cnt >= m) {
		cout << "Yes\n";
	}else {
		cout << "No\n";
	}
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
typedef long long int ll;
typedef pair<int, int> P;
#define INF 1e9 + 1;

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

    int n;
    cin >> n;
    ll a[n], sum = 0, count = 0, m = INF;
    rep(i, n){
        cin >> a[i];
        if(a[i] < 0) count++;
        a[i] = abs(a[i]);
        
        sum += abs(a[i]);
        
        m = (m > a[i])? a[i] : m;
    }
    
    ll ans = 0;
    
    if(count % 2 == 0){
        ans = sum;
    }else{
        ans = sum - 2 * m;
    }
    
    cout << ans << endl;

    return 0;
}

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

bool check(char a, char b){
  if(a == '0' && b != '0'){return 1;}
  else if (a == '1' && (b == '0' || b == '1' || b == '2')) { return 1;}
  else return 0;
}

int main(){
  char y[5];
  for(int i = 0; i<4; i++){
  cin >> y[i];
  }
  
  if(check(y[0],y[1]) && check(y[2], y[3])){
    cout << "AMBIGUOUS" << endl;
  } else if (check(y[0], y[1])){
    cout << "MMYY" << endl;
  } else if (check(y[2], y[3])){
    cout << "YYMM" << endl;
  } else {cout << "NA" << endl;}
  
 

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

signed main() {
	int R;
	cin >> R;
	if (R < 1200)cout << "ABC";
	else if (R < 2800)cout << "ARC";
	else cout << "AGC";
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_set>
#include<unordered_map>
#include<cassert>
#include<stack>
#include<fstream>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)

int main(){
	ll n,a,b;
	cin>>n>>a>>b;
	ll ans=n/(a+b)*a;
	ll rem=n%(a+b);
	ans+=min(a,rem);
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <vector>
using namespace std;
int main() {
  string s, t; cin >> s >> t;
  for(int i=0; i < s.size(); i++ ){
    if(s.at(i) != t.at(i)){
      cout << "No" << endl;
      exit(0);
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    int n,m;
    cin >> n >> m;

    vector<int> ac(n,0);
    int acnum=0,pen=0;
    for(int i=0;i<m;i++){
        int p;
        string s;
        cin >> p >> s;

        if(ac[p-1]==-1){
            continue;
        }else if(ac[p-1]!=-1 && s=="WA"){
            ac[p-1]++;
        }else if(ac[p-1]!=-1 && s=="AC"){
            pen+=ac[p-1];
            ac[p-1]=-1;
            acnum++;
        }
    }

    cout << acnum << " " << pen << endl;

    return 0;
}


Measured memory_bytes: 3800
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  ll k;
  cin >> k;
  ll p = k / 50;
  ll q = k % 50;
  vector<ll> a(50, 49+p);
  REP(i, q) a[i] += 50-q+1;
  FOR(i, q, 50) a[i] -= q;
  cout << 50 << endl;
  REP(i, 50) printf("%lld ", a[i]);
  printf("\n");
  return 0;
}

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

int main() {
    int D, T, S;
    cin >> D >> T >> S;
    if (D % S == 0) {
        if (D / S <= T) {
            puts("Yes");
        }
        else {
            puts("No");
        }
    }
    else {
        if (D / S <= T - 1) {
            puts("Yes");
        }
        else {
            puts("No");
        }
    }

    return 0;
}


Measured memory_bytes: 3620
#include<cstdio>
using namespace std;

int main()
{
    int n;
    scanf("%d",&n);
    while(1)
    {
        if(n==0) break;
        if(n%10==9)
        {
            printf("Yes");
            return 0;
        }
        n/=10;
    }
    printf("No");
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))

#define ll long long

using namespace std;
using Graph = vector<vector<int> >;

int main(){
  int K, X; cin >> K >> X;

  for (int i = X -K + 1; i <= X+K-1; i++) {
    cout << i << " " ;
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define pb push_back 
#define mp make_pair
typedef long long ll;



int main(){
	int x,y,z; cin>>x>>y>>z;
	swap(x,y);
	swap(x,z);
	cout<<x<<" "<<y<<" "<<z;
			
	return 0;
}


Measured memory_bytes: 384
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
# input=sys.stdin.readline
def resolve():
    n=int(input())
    ans=1
    from fractions import gcd
    for _ in range(n):
        t=int(input())
        ans=ans*t//(gcd(ans,t))
    print(ans)
resolve()

Measured memory_bytes: 65388
#include <iostream>

using namespace std;

int main(){
    char a;
    char b;
    char c;
    char a2;
    char b2;
    char c2;
    char a3;
    char b3;
    char c3;
    cin >> a >> b >> c;
    cin >> a2 >> b2 >> c2;
    cin >> a3 >> b3 >> c3;
    cout << a << b2 << c3 << endl;
}

Measured memory_bytes: 256
in_num = int(input())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))
import itertools
ans = [list(j) for j in list(itertools.permutations([i+1 for i in range(in_num)]))]
import math
print(int(math.fabs(ans.index(P) - ans.index(Q))))

Measured memory_bytes: 15092
#include <stdio.h>
#include <string.h>

int main(void){

  int N;
  char str[11]={};
  char str1[11]={};
  char str2[11]={};
  int i;
  int count = 0;
  int tmp;


  scanf("%s" ,str);
  scanf("%d" , &N);

  for( i = 1 ; i <= N ; i++ ){

    scanf("%s" ,str1);  

    strcpy(str2,str1);
    strcat(str1,str2);


    if(strstr(str1, str))
      count++;

    else continue;

  }

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

  return 0;
}

Measured memory_bytes: 624
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef unsigned long long ull;




int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll n, k;
	cin >> n >> k;
	vector<ll> a;
	ll cnt0 = 0;
	for (int i = 0; i < n; i++) {
		ll x;
		cin >> x;
		if (x == 0)cnt0++;
		else a.push_back(x);
	}
	sort(a.begin(), a.end());
	ll all = n;
	n = a.size();
	ll l = -1e18, r = 1e18;
	l--;
	//cout << cnt0 << "\n";
	while (r - l - 1 > 0) {
		ll m = (l + r) / 2;
		ll cnt = 0;
		if (m >= 0)cnt += cnt0 * (cnt0 - 1) / 2 + cnt0 * (all - cnt0);
		for (int i = 0; i < n; i++) {
			//cout << (1.0 * m) / (1.0 * a[i]) << "\n";
			if (a[i] < 0) {
				ll buben = 0;
				if (m % a[i] != 0 && m < 0) {
					buben = 1;
				}
				auto it = lower_bound(a.begin(), a.end(), m / a[i] + buben);
				cnt += min(n - i - 1, (ll)(a.end() - it));
			}
			else {
				ll buben = 0;
				if (m % a[i] == 0 || m > 0)buben = 1;
				auto it = lower_bound(a.begin(), a.end(), (m) / a[i] + buben);
				cnt += max(0LL, (ll)(it - a.begin()) - i - 1);
			}
		}
		//cout << l << " " << r << " " << m << " " << cnt << "\n";
		if (cnt >= k) {
			r = m;
		}
		else {
			l = m;
		}
	}
	cout << r;
}



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

using namespace std;
#define ll long long int


int main()
{
    ll x,y,a,b,c;
    cin >> x >> y >> a >> b >> c;
    vector<ll> r(a),g(b),co(c);
    for(ll& w:r) cin >> w;
    for(ll& w:g) cin >> w;
    for(ll& w:co) cin >> w;
    sort(r.rbegin(), r.rend());
    sort(g.rbegin(), g.rend());
    vector<ll> op;
    for(int i=0;i<x;i++) op.push_back(r[i]);
    for(int i=0;i<y;i++) op.push_back(g[i]);
    for(int i=0;i<c;i++) op.push_back(co[i]);
    sort(op.rbegin(),op.rend());
    ll s =0 ;
    for(int i=0;i<x+y;i++) s+=op[i];
    cout << s << endl;
}


Measured memory_bytes: 8816
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>

using namespace std;

int main() {
    int N;
    cin >> N;
    int a[N];
    for(int i = 0; i < N; i++) {
        cin >> a[i];
    }
    map<int,int> m;
    vector<int> v;
    for(int i = 0; i < N; i++) {
        if(m[a[i]] == 0) {
            m[a[i]] = 1;
            v.push_back(a[i]);
        } else {
            m[a[i]] = m[a[i]] + 1;
        }
    }
    int ans = 0;
    for(int i = 0; i < v.size(); i++) {
        if(m[v[i]] != v[i]) {
            if(m[v[i]] > v[i]) {
                ans += m[v[i]] - v[i];
            } else {
                ans += m[v[i]];
            }
        }
    } 
    cout << ans << endl;






}

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

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

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

    vector<ll> R(N), L(N);
    for (int i = 0; i < N; i++) {
        if (i == 0) {
            L[i] = A[i];
        } else {
            L[i] = gcd(L[i - 1], A[i]);
        }
    }
    for (int i = N - 1; i >= 0; i--) {
        if (i == N - 1) {
            R[i] = A[i];
        } else {
            R[i] = gcd(R[i + 1], A[i]);
        }
    }

    ll ans = max({R[1], L[N - 2], L[N - 1]});
    for (int i = 1; i < N - 1; i++) {
        ans = max(ans, gcd(L[i - 1], R[i + 1]));
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
import numpy as np
import itertools

n, d = list(map(int,input().split()))
x = [list(map(int,input().split(' '))) for i in range(n)]
#print(x)

count = 0

c = list(itertools.combinations(x,2))
c = np.array(c)
for i in c:
  k = np.linalg.norm(i[0]-i[1])
  #print(i)
  if k.is_integer():
    count +=1

print(count)  

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << res << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, l, r)  (a).begin()+(l),(a).begin()+(r)

int main() {
	int k, n;
	cin >> k >> n;
	vector<int> a(n);
	vector<int> d(n);
	FOR(i,0,n-1){
		cin >> a[i];
	}
	sort(ALL(a));
	FOR(i, 0, n - 1) {
		if (i == n - 1) {
			d[i] = k - (a[n - 1] - a[0]);
		}
		else {
			d[i] = a[i + 1] - a[i];
		}
	}
	sort(ALL(d));
	ll sum = 0;
	FOR(i, 0, d.size() - 2) {
		sum += d[i];
	}
	pv(sum)

	return(0);
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#define fst first
#define snd second
#define mp make_pair
#define fore(i,a,b) for(int i=a;i<b;++i)
#define pb push_back
#define SZ(x) ((int)(x).size())
using namespace std;
typedef long long ll;

int n;
vector<int> a;
vector<int> r;

int main(){
    scanf("%d",&n);
    fore(i,0,n){
        int t;
        scanf("%d",&t);
        a.pb(t);
    }
    fore(_,0,n){
        bool pingo=false;
        for(int i=SZ(a)-1;i>=0;--i)if(a[i]==i+1){
            r.pb(a[i]);
            a.erase(a.begin()+i);
            pingo=true;
            break;
        }
        if(!pingo){puts("-1");return 0;}
    }
    reverse(r.begin(),r.end());
    fore(i,0,n)printf("%d\n",r[i]);
    return 0;
}


Measured memory_bytes: 256
import sys
import collections

input = sys.stdin.readline


def main():
    H, W = [int(x) for x in input().split()]
    S = [input().strip() for _ in range(H)]

    dj = [1, 0, -1, 0]
    di = [0, 1, 0, -1]

    d = [[-1 for i in range(W)] for j in range(H)]
    q = collections.deque([])
    q.append((0, 0))
    d[0][0] = 0

    while q:
        p = q.popleft()
        for i in range(4):
            nj = p[0] + dj[i]
            ni = p[1] + di[i]

            if 0 <= nj < H and 0 <= ni < W and S[nj][ni] != "#" and d[nj][ni] == -1:
                q.append((nj, ni))
                d[nj][ni] = d[p[0]][p[1]] + 1

    if d[H - 1][W - 1] == -1:
        print(-1)
    else:
        bnum = 0
        for s in S:
            bnum += s.count(".")
        print(bnum - 1 - d[H - 1][W - 1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
a, b, c, d = input().split()
a = int(a)
b = int(b)
c = int(c)
d = int(d)

import fractions
lcm = c * d // fractions.gcd(c, d)

n_a_lcm = a // lcm
n_b_lcm = b // lcm

n_a_c = a // c
n_b_c = b // c

n_a_d = a // d
n_b_d = b // d


n_lcm = n_b_lcm - n_a_lcm
n_c = n_b_c - n_a_c
n_d = n_b_d - n_a_d


n = b - a - n_c - n_d + n_lcm

if a % c != 0 and a % d != 0:
    n += 1

print(n)


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

int main()
{
    ll n,p=0,d=0,i;
    cin>>n;
    for(i=0;i<n;i++){
        ll a,b;
        cin>>a>>b;
        if(a==b)
            p++;
        else
            p=0;
        if(p==3)
            d=1;
    }
    if(d==1)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 3616
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		BigInteger sum = BigInteger.ONE;
		long[] input = new long[N];
		for (int i = 0; i < N; i++) {
			input[i] = sc.nextLong();
			if (input[i] == 0) {
				System.out.println(0);
				System.exit(0);
			}
		}
		BigInteger MAX = new BigInteger("1000000000000000000");
		for (int i = 0; i < N; i++) {
			sum = sum.multiply(new BigInteger(String.valueOf(input[i])));
			if (sum.compareTo(MAX) > 0) {
				System.out.println(-1);
				System.exit(0);
			}
		}
		System.out.println(sum.longValueExact());
	}

}


Measured memory_bytes: 61856
function Main(input) {
    input = input.split("\n")
    input = input.map(e=>e.split(" "))
    input = input.map(e=>e.map(f=>parseInt(f,10)))

    var a = input[0][0]-input[0][1]*2
    a = a<0 ? 0 : a;
    console.log(a);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main() {
    int A, B, C;
    cin >> A >> B >> C;

    if (A==B && A!=C || B==C && B!=A || C==A && C!=B) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>

#define MOD 1000003
long long powmod(long long b,int e)
{
    if (e==0) return 1;
    if (e&1) return powmod(b*b%MOD,e/2)*b%MOD;
    return powmod(b*b%MOD,e/2);
}
long long inv[MOD+5];
long long fac[MOD+5];
long long ifac[MOD+5];

int t1,t2;
int q;
long long x,d;
int n;

long long ans;

int main()
{
    #ifdef NOT_DMOJ
    freopen("data.txt","r",stdin);
    #endif // NOT_DMOJ
    for (int i=1; i<MOD; i++) inv[i]=powmod(i,MOD-2);
    fac[0]=ifac[0]=1;
    for (int i=1; i<MOD; i++) {
        fac[i]=fac[i-1]*i%MOD;
        ifac[i]=ifac[i-1]*inv[i]%MOD;
    }
    scanf("%d",&q);
    while (q--) {
        scanf("%lld%lld%d",&x,&d,&n);
        if (d==0) {
            printf("%lld\n",powmod(x,n));
            continue;
        }
        t1=d;
        x=x*inv[d]%MOD;
        d=1;
        if (x==0 || x+n>MOD) {
            printf("0\n");
            continue;
        }
        ans=fac[x+n-1]*ifac[x-1]%MOD;
        ans=ans*powmod(t1,n)%MOD;
        printf("%lld\n",ans);
    }
}


Measured memory_bytes: 24192