akhauriyash/Code-Regression huggingface dataset:
/*input
9
*/
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mss map <string,string>
#define msl map <string,ll>
#define mll map <ll,ll>
#define mcl map <char,ll>
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define sz(a) int((a).size())
#define pb push_back
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())     
#define rep(i,j,n) for(ll i=j;i<n;i++)
#define mp make_pair
#define N 998244353
#define PI acos(-1.0)
//if (s.find('R') != std::string::npos)
//s.replace(s.find("10"), sizeof("10") - 1, "");
using namespace std;
bool comp(pair<string,ll>a,pair<string,ll>b){
  if(a.first==b.first) return a.second>b.second;
  return a.first<b.first;
}
long long  int exponentiation(long long  int base, long long  int exp) 
{ 
  if (exp == 0) 
    return 1; 
 
  if (exp == 1) 
    return base % N; 
  long long int t = exponentiation(base, exp / 2); 
  t = (t * t); 
  if (exp % 2 == 0) 
    return t;
  else  
    return ((base ) * t) ; 
} 
vector<int> adj[100005];
int dfs(int v)
{
	int h=0;
	for(auto u:adj[v])
	h=max(h,dfs(u));
	return(h+1);
}

int main()
{
  // added the two lines below 
  ios_base::sync_with_stdio (false); 
  cin.tie(NULL);
  cout.tie(0);
 
  string a,b;
  cin>>a>>b;
  mcl m1,m2;
  vector<int>v1,v2;
  for(int i=0;i<a.size();i++){
    m1[a[i]]++;
    m2[b[i]]++;
  }
  for(auto i:m1){
    v1.pb(i.second);
  }
   for(auto i:m2){
    v2.pb(i.second);
  }
  sort(v1.begin(),v1.end());
  sort(v2.begin(),v2.end());
  if(v1.size()!=v2.size()){
    cout<<"No";
    return 0;
  }
  for(int i=0;i<v1.size();i++){
    if(v1[i]!=v2[i]) {
      cout<<"No";
      return 0;
    }
  }
  cout<<"Yes";
}







Measured memory_bytes: 3220
W, H, N = gets.split.map(&:to_i)
I = readlines.map{|l| l.split.map &:to_i}

x0 = y0 = 0
x1 = W
y1 = H

def out; p 0; exit; end

I.each do |x, y, a|
  #p x: x, y: y, a: a
  case a
  when 1
    out if x >= x1
    x0 = x if (x0..x1) === x
  when 2
    out if x <= x0
    x1 = x if (x0..x1) === x
  when 3
    out if y >= y1
    y0 = y if (y0..y1) === y
  when 4
    out if y <= y0
    y1 = y if (y0..y1) === y
  end
  #p xy: [[x0, y0], [x1, y1]]
end

p((x1-x0)*(y1-y0))


Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

struct P {
  double x;
  double y;
  P(double x, double y) : x(x) , y(y) {
  };
};

static inline void printP(P& p) {
  cout << fixed << p.x << " " << p.y << endl; 
}

static inline double toRadian(double degree) {
  return degree / 180 * M_PI;
}

static inline void koch(int d, P p1, P p2) {
  if (d == 0) {
    return;
  }
  
  P s(p1.x + (p2.x - p1.x) / 3, p1.y + (p2.y - p1.y) / 3);
  P t(p1.x + 2 * ((p2.x - p1.x) / 3), p1.y + 2 * ((p2.y - p1.y) / 3));
  P u(
    (t.x - s.x) * cos(toRadian(60.0)) - (t.y - s.y) * sin(toRadian(60.0)) + s.x,
    (t.x - s.x) * sin(toRadian(60.0)) + (t.y - s.y) * cos(toRadian(60.0)) + s.y);
 
  koch(d - 1, p1, s);
  printP(s);
  koch(d - 1, s, u);
  printP(u);
  koch(d - 1, u, t);
  printP(t);
  koch(d - 1, t, p2);
}

int main() {
  int n;
  cin >> n;

  P p1(0.0, 0.0), p2(100.0, 0);

  printP(p1);
  koch(n, p1, p2);
  printP(p2);
  
  return 0;
}



Measured memory_bytes: 3232
#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <string>
#include <cmath>
//#include <vector>
//#include <time.h>
#include <queue>
//#include <stack>
//#include <map>
//#include <set>
using namespace std;
typedef long long ll;
typedef long double ld;
int a[10000];
int main()
{
    int n,k;
    int x;
    cin>>n>>k;
    for(int i=1; i<=k; i++)
    {
        cin>>x;
        a[x]=1;
    }
    for(int i=n;; i++)
    {
        int flag=1,c=i;
        while(c)
        {
            if(a[c%10]==1)
            {
                flag=0;
                break;
            }
            c/=10;
        }
        if(flag)
        {
            cout<<i;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 8
#define NOT_FREE 1
#define FREE 0

void putQueen(int);
void printBoard(void);

int row[N]={0};
int col[N]={0};
int dpos[2*N-1]={0};
int dneg[2*N-1]={0};
int a[N][N];

int main(){

  int i,j,r,c,k;

  for(i=0;i<N;i++){
    row[i]=FREE;
    col[i]=FREE;
  }

  for(i=0;i<2*N-1;i++){
    dpos[i]=FREE;
    dneg[i]=FREE;
  }

  scanf("%d",&k);

  for(i=0;i<k;i++){
    scanf("%d%d",&r,&c);
    a[r][c]=NOT_FREE;
  }

  putQueen(0);

  return 0;

}
void putQueen(int i){

  int j;

  if(i==N){
    printBoard();
    return;
  }

  for(j=0;j<N;j++){
    if(col[j]==NOT_FREE || dpos[i+j]==NOT_FREE || dneg[i-j+N-1]==NOT_FREE)
      continue;
    row[i]=j;
    col[j]=dpos[i+j]=dneg[i-j+N-1]=NOT_FREE;
    putQueen(i+1);
    col[j]=dpos[i+j]=dneg[i-j+N-1]=FREE;

  }
}

void printBoard(void){

  int i,j;

  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(a[i][j]==NOT_FREE && row[i]!=j) return;
    }
  }

  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(row[i]==j) printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}

Measured memory_bytes: 572
#include<iostream>
#include<vector>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
#include<algorithm>
#include<functional>
#include<numeric>

typedef unsigned long long LL;

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> a;
	for (int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		a.push_back(tmp);
	}
	vector<int>dp(100003, 0);
	for(int i = 0; i < N; i++) {
		dp[a[i]]++;
	}
	int answer = 1;
	for (int i = 0; i < dp.size() - 2; i++) {
		int current = dp[i] + dp[i + 1] + dp[i + 2];
		answer = max(answer, current);
	}
	cout << answer << endl;
}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#define FPEN freopen("in.txt", "r", stdin);
#define debug(...)                                                             \
    { cerr << "# " << __VA_ARGS__ << "\n"; }
#else
#define debug(...)
#define FPEN
#endif
const int maxn = 500009;
typedef long long i64;
typedef pair<i64, i64> pi64;
typedef pair<int, int> pi;
const i64 MOD = 119 << 23 | 1;
class {
  public:
    int n, q;
    string s;
    void solve() {
        cin >> n >> s >> q;
        s = "#" + s;
        build(1, 1, n);
        while (q--) {
            int op, pos1, pos2;
            cin >> op;
            if (op == 1) {
                cin >> pos1 >> s;
                upd(1, 1, n, pos1, s[0] - 'a');
            } else {
                cin >> pos1 >> pos2;
                cout << __builtin_popcount(query(1, 1, n, pos1, pos2)) << '\n';
            }
        }
    }
    int a[maxn << 2];
    void build(int rt, int l, int r) {
        if (l == r) {
            a[rt] = 1 << (s[l] - 'a');
            return;
        }
        int mid = l + r >> 1;
        build(rt << 1, l, mid);
        build(rt << 1 | 1, mid + 1, r);
        a[rt] = a[rt << 1 | 1] | a[rt << 1];
    }
    void upd(int rt, int l, int r, int p, int v) {
        if (l == r) {
            a[rt] = 1 << v;
            return;
        }
        int mid = l + r >> 1;
        if (p <= mid)
            upd(rt << 1, l, mid, p, v);
        else
            upd(rt << 1 | 1, mid + 1, r, p, v);
        a[rt] = a[rt << 1 | 1] | a[rt << 1];
    }
    int query(int rt, int l, int r, int ll, int rr) {
        if (ll <= l && rr >= r) {
            return a[rt];
        }
        int mid = l + r >> 1, res = 0;
        if (ll <= mid)
            res |= query(rt << 1, l, mid, ll, rr);
        if (rr > mid)
            res |= query(rt << 1 | 1, mid + 1, r, ll, rr);
        return res;
    }
} NSPACE;
int main() {
    FPEN;
    ios_base::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    NSPACE.solve();
}

Measured memory_bytes: 7088
#include<stdio.h>
#include<string.h>
#define N 100

int main(void){
	char s[N],p[N],ss[300];
	
	scanf("%s",s);
	scanf("%s",p);
	strcpy(ss,s);
	strcat(ss,s);
	if(strstr(ss,p)=='\0')printf("No\n");
	else printf("Yes\n");
	
	return 0;
}


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

#include <vector>

#include <algorithm>
#include <numeric>

using namespace std;

#define repeat(n) for(int _ = 1; _ <= n; _++)

int main()
{
	ios::sync_with_stdio(false);
#ifdef CAI_WEI_HAN
	freopen("test.in", "r", stdin);
#endif
	
	int n, m;
	cin >> n >> m;
	
	if(n >= m) {
		cout << 0;
		return 0;
	}
	
	static int a[100005];
	for(int i = 1; i <= m; i++)
		cin >> a[i];
	sort(&a[1], &a[m]+1);
	
	static int b[100005];
	for(int i = 1; i < m; i++)
		b[i] = a[i+1] - a[i];
	sort(&b[1], &b[m], greater<int>());
	
	cout << accumulate(&b[n], &b[m], 0ll);
}


Measured memory_bytes: 1024
import sys
input = sys.stdin.readline

class Factorial:
    def __init__(self, n, mod):
        self.f = [1]
        self.mod = mod
        for j in range(1, n + 1):
            self.f.append(self.f[-1] * j % mod)
        self.i = [pow(self.f[-1], mod - 2, mod)]
        for j in range(n, 0, -1):
            self.i.append(self.i[-1] * j % mod)
        self.i.reverse()
    def factorial(self, j):
        return self.f[j]
    def ifactorial(self, j):
        return self.i[j]
    def comb(self, n, k):
        return self.f[n] * self.i[n - k] % self.mod * self.i[k] % self.mod if n >= k else 0

MOD = 10 ** 9 + 7

F = Factorial(2 * 10 ** 5 + 10, MOD)

N = int(input())
G = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    G[a].append(b)
    G[b].append(a)


root = 1

DAG = []
parent = [-1] * (N + 1)
parent[root] = 0
stack = [root]
while stack:
    now_ = stack.pop()
    DAG.append(now_)
    for next_ in G[now_]:
        if parent[next_] == -1:
            stack.append(next_)
            parent[next_] = now_

# print ('parent', parent)

size1 = [1] * (N + 1)
dp1 = [1] * (N + 1)

for i in DAG[::-1]:
    size1[parent[i]] += size1[i]

for i in DAG[::-1]:
    dp1[i] *= F.factorial(size1[i] - 1)
    dp1[i] %= MOD
    dp1[parent[i]] *= (dp1[i] * F.ifactorial(size1[i])) % MOD
    dp1[parent[i]] %= MOD

# print (dp1)
# print (size1)

size2 = [1] * (N + 1)
dp2 = [1] * (N + 1)

for i in DAG[::]:
    for j in G[i]:
        if parent[i] == j:
            continue
        size2[j] = size2[i] + size1[i] - size1[j]  

for i in DAG[1::]:
    x = 1
    x *= dp1[parent[i]]
    x *= F.ifactorial(size1[parent[i]] - 1)
    x *= F.factorial(size1[i])
    x *= pow(dp1[i], MOD - 2, MOD)
    x *= dp2[parent[i]]
    x *= F.ifactorial(size2[parent[i]] - 1)
    x *= F.factorial(size2[i] - 2)
    dp2[i] = x % MOD

# print ('size1', size1)
# print ('size2', size2)
# print ('dp1', dp1)
# print ('dp2', dp2)
# print (G)

fact = F.factorial(N - 1)
for x in range(1, N + 1):
    ans = fact * dp1[x] * F.ifactorial(size1[x] - 1) * dp2[x] * F.ifactorial(size2[x] - 1)
    print (ans % MOD)


Measured memory_bytes: 84968
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e18;
const double PI = 2 * asin(1);
typedef long long ll;

int main(){
  int N, Q; cin >> N >> Q;

  vector < pair<ll, ll> > event;

  for (int i = 0; i < N; i++){
    ll S, T, X; cin >> S >> T >> X;
    S -= X; T -= X;
    event.push_back(make_pair(S, X));
    event.push_back(make_pair(T, X));
  }
  sort(event.begin(), event.end());

  vector <ll> ans(Q);
  int now = 0;
  set <ll> st;
  for (int i = 0; i < Q; i++){
    ll D; cin >> D;

    for (int j = now; j < event.size(); j++){
      if (event[j].first <= D){
        auto C = st.erase(event[j].second);
        if (C == 0){
          st.insert(event[j].second);
        }
        now++;
      }else break;
    }
    
    if (st.size() != 0){
      auto itr = st.begin();
      ans[i] = *itr;
    }else{
      ans[i] = -1;
    }
  }
  
  for (int i = 0; i < Q; i++){
    cout << ans[i] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 18408
#include <cstdio>
#include <algorithm>
#include <limits.h>
using namespace std;

const int N = 100000 + 5;
inline int lowbit (int u) { return u & (-u); }
int n;
int info[N], p[N];
int tree[N];
long long ans;
inline void add (int u, int v) {
	while (u <= N - 5)
		tree[u] += v,
		u += lowbit (u);
}
inline int query (int u) {
	int res = 0;
	while (u)
		res += tree[u],
		u -= lowbit (u);
	return res;
}

inline int sh (int l, int r, int k) {
	int mid;
	while (l < r) {
		mid = (l + r) >> 1;
		int now = query (mid);
		if (now >= k) r = mid;
		else l = mid + 1;
	}
	return l;
}

inline void solve (int opt, int p) {
	if (opt == 1) {
		int lm, rm, nxt;
		int tmp = query (p);
		if (tmp == 1) { return ; }
		else if (tmp == 2) lm = 1, nxt = sh (1, p - 1, tmp - 1);
		else lm = sh (1, p - 1, tmp - 2) + 1, nxt = sh (1, p - 1, tmp - 1);
		int tmp2 = n - info[p] + 1;
		if (tmp2 - tmp == 0) rm = n;
		else rm = sh (p + 1, n, tmp + 1) - 1;
		ans += 1LL * info[p] * (rm - p + 1) * (nxt - lm + 1);
	}
	else {
		int lm, rm, nxt;
		int tmp = query (p), tmp2 = n - info[p] + 1;
		if (tmp2 - tmp == 0) { return ;}
		else if (tmp2 - tmp == 1) rm = n, nxt = sh (p + 1, n, tmp + 1);
		else rm = sh (p + 1, n, tmp + 2) - 1, nxt = sh (p + 1, n, tmp + 1);
		if (tmp == 1) lm = 1;
		else lm = sh (1, p - 1, tmp - 1) + 1;
		ans += 1LL * info[p] * (rm - nxt + 1) * (p - lm + 1);
	}
}

int main() {
	scanf ("%d", &n);
	for (int i = 1; i <= n; ++i)
		scanf ("%d", &info[i]), p[ info[i] ] = i;
	for (int i = n; i >= 1; --i) {
		add (p[i], 1);
		if (i == n) continue;
		solve (1, p[i]);
		solve (2, p[i]);
	}
	printf ("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < b; i++)
using namespace std;

int main() {
    int k, n;
    cin >> k >> n;

    vector<int> a(n);
    rep(i, 0, n) cin >> a[i];


    int ans = 1e9;
    rep(i, 0, n) {
        int s = i;
        int g = (i - 1 + n) % n;
        if (s < g) ans = min(ans, a[g] - a[s]);
        else ans = min(ans, k - a[s] + a[g]); 
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

int main(void) {
	string str;
	cin >> str;
	int res = 700;
	for (int i = 0; i < str.length(); ++i) {
		if (str[i] == 'o') {
			res += 100;
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
import heapq
n,m=map(int,input().split())
alist=list(map(int,input().split()))
malist=[]
for a in alist:
    malist.append(-a)

heapq.heapify(malist)

for i in range(m):
    tmp = -heapq.heappop(malist)
    tmp //= 2
    heapq.heappush(malist,-tmp)

print(-sum(malist))


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

N = int(readline())
T,A = map(int,readline().split())
H = list(map(int,readline().split()))

ans = [None] * N
for i in range(len(H)):
  ans[i] = (abs(A - (T - H[i] * 0.006)), i)
  
ans = sorted(ans, key = lambda x:x[0])
print(ans[0][1] + 1)

Measured memory_bytes: 3188
#include<stdio.h>

int main(){
    int h,w;
    while(scanf("%d %d",&h,&w) && (h != 0 || w != 0)){
        for(int i=0;i < h;i++){
            printf("#");
            for(int j=0;j < w -2 ;j++){
                if(i == 0 || i == h-1){
                    printf("#");
                } else{
                    printf(".");
                }
            }
            printf("#\n");
        }
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 2556
# -*- coding: utf-8 -*-

def kaibun(s):
    n = len(s)
    flag = True
    for i in range(n // 2):
        if s[i] == s[n-i-1]:
            continue
        else:
            flag = False
            break
    return flag


s = input()
n = len(s)
if kaibun(s) and kaibun(s[0:(n-1)//2]) and kaibun(s[(n+2)//2:]):
    print('Yes')
else:
    print('No')


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

int main(){
    int n;
    cin >> n;
    vector<int> num;
    for(int i = 0; i < n; i++){
        int temp;
        cin >> temp;
        num.push_back(temp);
    }

    bool flg = false;

    for(int i = 0; i < n; i++){
        for(int j = i; j < n; j++){
            int temp = num[i];
            num[i] = num[j];
            num[j] = temp;
            for(int k = 1; k < n; k++){
                if(num[k] < num[k-1]) goto Label;
            }
            flg = true;
            Label:
            temp = num[i];
            num[i] = num[j];
            num[j] = temp;
        }
        if(flg) break;
    }

    if(flg) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL);

int main() {
  FAST;
  uint64_t N;
  cin >> N;
  vector<uint64_t> P(N), P_min(N);
  for (uint64_t i = 0; i < N; i++) {
    cin >> P.at(i);
  }
  uint64_t tmp_min = P.at(0);
  P_min.at(0) = P.at(0);
  for (uint64_t i = 1; i < N; i++) {
    if (tmp_min > P.at(i - 1)) {
      tmp_min = P.at(i - 1);
      P_min.at(i) = P.at(i - 1);
    }
    else {
      P_min.at(i) = tmp_min;
    }
  }
  uint64_t count = 0;
  for (uint64_t i = 0; i < N; i++) {
    if (P_min.at(i) >= P.at(i)) {
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3456
// DFSを用いたトポロジカルソート
// 計算量 O(V) 
// reference Programming Contest Challenge Book Second Edition
// verify https://onlinejudge.u-aizu.ac.jp/courses/library/5/GRL/1/GRL_4_B

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

template<typename T> struct edge {
  int to;
  edge(int to_) : to(to_) {}
};

template<typename T,template <typename ELEM> class C> struct Topological_Sort {
  vector<vector<C<T>>> G;
  vector<bool> used;
  int V;//0,...,|V|-1
  T INF;

  Topological_Sort (int V_) {
    init(V_);
  }

  void init(int V_) {
    V = V_;

    G.clear();
    G.resize(V);
  }

  // https://faithandbrave.hateblo.jp/entry/20080310/1205149207
  template <typename FROM, class... Args>
  void add_edge(FROM from, Args&&... arg) {
    G[from].emplace_back(arg...);
  }

  void dfs (int i, vector<int> &sorted) {
    used[i] = true;

    rep(j,(int)G[i].size()) {
      if (!used[G[i][j].to]) {
        dfs(G[i][j].to, sorted);
      }
    }

    sorted.emplace_back(i);//dfsの帰りがけの順
  }

  template<typename ID_TYPE>
  bool topological_sort (vector<ID_TYPE> &sorted) { // 成功ならtrue 失敗(DAG出ない)ならfalseを返す
    used.clear();
    used.resize(V,false);

    sorted.clear();

    rep (i,V) {
      if (!used[i]) dfs(i,sorted);
    }

    // DAGでないときトポロジカルソート出来ないのでfalseを返す
    // https://ferin-tech.hatenablog.com/entry/2017/01/24/184750
    if (V != (int)(sorted.size())) return false;

    reverse(sorted.begin(),sorted.end());

    return true;
  }

};

using ll = long long;

int main() {
  ll V,E;
  cin >> V >> E;
  Topological_Sort<ll,edge> ts(V);
  rep(i,E) {
    ll s,t;
    cin >> s >> t;
    ts.add_edge(s,t);
  }

  vector<int> ans;

  ts.topological_sort(ans);

  for (auto v : ans) {
    cout << v << endl;
  }
  return 0;
}



Measured memory_bytes: 3700
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    String S = sc.next();
    char[] s = S.toCharArray();
    
    for(int i = 0; i<s.length;i = i+2){
    	System.out.print(s[i]);
    }
    
   
  }
}

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

int main(){

    int n;
    double sum=0;
    cin>>n;
    vector<double> a(n);
    for(int i=0;i<n;i++){
        cin>>a.at(i);
        sum+=1/a.at(i);
    }
    cout<<1/sum<<endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <regex>
#include <locale>
using namespace std;

int main () {
  string a, b, c;
  cin >> a >> b >> c;
  
  cout << ((reverse(a.begin(),a.end()), a[0] == b[0]) && (reverse(b.begin(),b.end()), b[0] == c[0]) ? "YES" : "NO") << endl;
}

Measured memory_bytes: 3036
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    // Your code here!
    ll x,y,z;
    cin>>x>>y>>z;
    swap(x,y);
    swap(x,z);
    cout<<x<<" "<<y<<" "<<z;
}


Measured memory_bytes: 256
def main():
    N,M=map(int,input().split())
    A=list(map(int,input().split()))
    A.sort()
    BC=[]
    for i in range(M):
        bc=list(map(int,input().split()))
        BC.append(bc)

    BC.sort(reverse=True,key=lambda x:x[1])
    new_BC=[]
    count=0
    for i in range(M):
        for j in range(BC[i][0]):
            new_BC.append(BC[i][1])
            count+=1
            if count==N:
                break
        if count==N:
            break

    for i in range(len(new_BC)):
        if A[i]<new_BC[i]:
            A[i]=new_BC[i]
        else:
            break
    
    print(sum(A))
if __name__=="__main__":
    main()

Measured memory_bytes: 32960
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
  int N, K;
  cin >> N >> K;
  int digit = 0;
  while (N > 0) {
    N /= K;
    digit++;
  }
  cout << digit << endl;
  return 0;
}

Measured memory_bytes: 256
use io::*;

fn main() {

    let con = read_string();
    let mut sc = Scanner::new(&con);

    let s: Vec<usize> = sc.next_vec(2);

    let mul = s[0] * s[1];
    if mul % 2 == 0 {
        println!("Even");
    }else {
        println!("Odd");
    }

}

pub mod io {

    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}

Measured memory_bytes: 4352
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>

namespace IO {
    template <typename _T>
    inline bool read(_T& x) {
        x = 0;
        _T y = 1;
        char c = getchar();
        while ((c < '0' || '9' < c) && c != EOF) {
            if (c == '-')
                y = -1;
            c = getchar();
        }
        if (c == EOF)
            return false;
        while ('0' <= c && c <= '9')
            x = x * 10 + c - '0', c = getchar();
        x *= y;
        return true;
    }

    template <typename _T>
    inline _T input() {
        _T x = 0, y = 1;
        char c = getchar();
        while ((c < '0' || '9' < c) && c != EOF) {
            if (c == '-')
                y = -1;
            c = getchar();
        }
        if (c == EOF)
            return 0;
        while ('0' <= c && c <= '9')
            x = x * 10 + c - '0', c = getchar();
        x *= y;
        return x;
    }
};  // namespace IO
using namespace IO;

namespace modular {
    const int MOD = 1000000007;

    inline int add(int x, int y) { return (x += y) >= MOD ? x -= MOD : x; }

    inline void inc(int& x, int y) { (x += y) >= MOD ? x -= MOD : 0; }

    inline int mul(int x, int y) { return 1LL * x * y % MOD; }

    inline int qpow(int x, int y) {
        int ans = 1;
        for (; y; y >>= 1, x = mul(x, x))
            if (y & 1)
                ans = mul(ans, x);
        return ans;
    }
};  // namespace modular

#define MAX_N 2000007
#define reg register
#define FIN(s) freopen(s, "r", stdin)
#define FOUT(s) freopen(s, "w", stdout)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, l, r) for (int i = l; i <= r; ++i)
#define lep(i, l, r) for (int i = l; i < r; ++i)
#define irep(i, r, l) for (int i = r; i >= l; --i)
#define ilep(i, r, l) for (int i = r; i > l; --i)
typedef long long ll;

int N;
char s[MAX_N], t[MAX_N];
std::deque<int> q;

inline void solve() {
    int j = N, tag = 0, ans = 0, las = N + 1;
    irep(i, N, 1) {
        while (j && (s[j] != t[i] || j > i))
            j--;
        if (!j)
            return puts("-1"), void();
        if (las == j) {
            while (!q.empty() && q.front() - tag >= i)
                q.pop_front();
        } else {
            tag++;
            if (i != j) {
                while (!q.empty() && q.front() - tag > i)
                    q.pop_front();
                q.push_back(j + tag);
                ans = std::max(ans, (int)q.size());
            }
        }
        las = j;
    }
    printf("%d\n", ans);
}

int main() {
#ifdef LOCAL
    FIN("in");
#endif
    read(N);
    scanf("%s%s", s + 1, t + 1);
    rep(i, 1, N) if (s[i] != t[i]) {
        solve();
        return 0;
    }
    puts("0");
    return 0;
}

Measured memory_bytes: 6272
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = j;i <= k;++i)
#define repp(i,j,k) for(int i = j;i >= k;--i)
#define rept(i,x) for(int i = linkk[x];i;i = e[i].n)
#define P pair<int,int>
#define Pil pair<int,ll>
#define Pli pair<ll,int>
#define Pll pair<ll,ll>
#define pb push_back 
#define pc putchar
#define mp make_pair
#define file(k) memset(k,0,sizeof(k))
#define ll long long
ll rd()
{
	ll num = 0;char c = getchar();bool flag = true;
	while(c < '0'||c > '9') {if(c == '-') flag = false;c = getchar();}
	while(c >= '0' && c <= '9') num = num*10+c-48,c = getchar();
	if(flag) return num;else return -num;
}
ll n,x;
ll num;
ll v[55],ans;
void solve(ll l,ll r,int level)
{
	if(l>r) return;
	if(l == r) {ans += l <= x;return;}
	ll mid = l+r>>1;
	if(x>mid) ans += v[level-1]+1,solve(mid+1,r-1,level-1);
	else if(x == mid) ans += v[level-1]+1;
	else solve(l+1,mid-1,level-1);
}
int main()
{
	n = rd();x = rd();
	num = 1;v[0] = 1;
	rep(i,1,n) num = num*2+3;
	rep(i,1,n) v[i] = v[i-1]*2+1;
	solve(1,num,n);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
from heapq import heappush, heappop

class MinimumCostFlow:
    inf = 1000000000
    def __init__(self, n):
        self.n = n
        self.edges = [[] for i in range(n)]
    def add_edge(self, f, t, cap, cost):
        self.edges[f].append([t, cap, cost, len(self.edges[t]), False])
        self.edges[t].append([f, 0, -cost, len(self.edges[f]) - 1, True]) # reverse edge
    def flow(self, s, t, flow):
        n = self.n
        g = self.edges
        inf = MinimumCostFlow.inf

        prevv = [0 for i in range(n)]
        preve = [0 for i in range(n)]
        h = [0 for i in range(n)]
        dist = [inf for i in range(n)]

        res = 0

        while flow != 0:
            dist = [inf for i in range(n)]
            dist[s] = 0
            que = [(0, s)]

            while que:
                c, v = heappop(que)
                if dist[v] < c:
                    continue
                r0 = dist[v] + h[v]
                for i, e in enumerate(g[v]):
                    w, cap, cost, _, _ = e
                    if cap > 0 and r0 + cost - h[w] < dist[w]:
                        r = r0 + cost - h[w]
                        dist[w] = r
                        prevv[w] = v
                        preve[w] = i
                        heappush(que, (r, w))

            if dist[t] == inf:
                return -1
            
            for i in range(n):
                h[i] += dist[i]

            d = flow
            v = t
            while v != s:
                d = min(d, g[prevv[v]][preve[v]][1])
                v = prevv[v]
            flow -= d
            res += d * h[t]
            v = t
            while v != s:
                e = g[prevv[v]][preve[v]]
                e[1] -= d
                g[v][e[3]][1] += d
                v = prevv[v]
        return res

import sys
readline = sys.stdin.readline
write = sys.stdout.write
N, M, F = map(int, readline().split())

mcf = MinimumCostFlow(N)
for i in range(M):
    u, v, c, d = map(int, readline().split())
    mcf.add_edge(u, v, c, d)
write("%d\n" % mcf.flow(0, N-1, F))


Measured memory_bytes: 5948
import Control.Monad

type Point = (Double, Double)

main = do
  [n, k] <- map read.words <$> getLine
  meat <- replicateM n
    $ (\[x,y,c]->((x,y),c)).map read.words <$> getLine
  print $ solve k meat

solve :: Int -> [(Point, Double)] -> Double
solve k meat = bis 0 150000 where
  bis ng ok
    | ok - ng < 1e-9 = ok
    | cnt >= k = bis ng time
    | otherwise = bis time ok
    where
      time = (ng + ok) / 2
      cnt = maximum $ map count can
      count pos = length $ filter eval meat where
        eval (p, c) = dist p pos <= (time / c + 1e-9)
      can = mpos ++ concat [
        ccIntersect (p1, r1) (p2, r2)
        | (p1, c1) <- meat, let r1 = time / c1
        , (p2, c2) <- meat, let r2 = time / c2 ]
  mpos = map fst meat

dist p q = sqrt $ distSqr p q
distSqr (x1, y1) (x2, y2) = (x1 - x2) ^ 2 + (y1 - y2) ^ 2

ccIntersect :: (Point, Double) -> (Point, Double) -> [Point]
ccIntersect (p1, r1) (p2, r2)
  | d > 0 = [
      (a * x + y * sqrt d, a * y - x * sqrt d) /# sqs +# p1,
      (a * x - y * sqrt d, a * y + x * sqrt d) /# sqs +# p1
    ]
  | d == 0 = [a *# p /# sqs +# p1]
  | otherwise = []
  where
    p@(x, y) = p2 -# p1
    a = (sqs + r1 * r1 - r2 * r2) / 2
    sqs = distSqr p1 p2
    d = sqs * r1 * r1 - a * a

(a, b) +# (c, d) = (a + c, b + d)
(a, b) -# (c, d) = (a - c, b - d)
a *# (b, c) = (a * c, b * c)
(a, b) /# c = (a / c, b / c)

Measured memory_bytes: 1148
#include <cstdio>
#include <utility>

char s[400][401];
bool visit[400][400];
int h, w;

std::pair<long long, long long> dfs(int x, int y, bool black)
{
  visit[y][x] = true;
  const int dir[] = {0, 1, 0, -1, 0};
  std::pair<long long, long long> r;
  if (s[y][x] == '#')
  {
    r.first = 1;
    r.second = 0;
  }
  else
  {
    r.first = 0;
    r.second = 1;
  }
  for (int i = 0; i < 4; ++i)
  {
    int X = x + dir[i + 1];
    int Y = y + dir[i];
    if (0 <= X && X < w && 0 <= Y && Y < h && !visit[Y][X])
    {
      if (s[Y][X] == '#' xor black)
      {
        auto a = dfs(X, Y, s[Y][X] == '#');
        r.first += a.first;
        r.second += a.second;
      }
    }
  }
  return r;
}

int main()
{
  scanf("%d%d", &h, &w);
  for (int i = 0; i < h; ++i)
  {
    scanf("%s", s[i]);
  }
  long long ans = 0;
  for (int i = 0; i < h; ++i)
  {
    for (int j = 0; j < w; ++j)
    {
      if (visit[i][j]) continue;
      auto p = dfs(j, i, s[i][j] == '#');
      ans += p.first * p.second;
    }
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 17920
#include <bits/stdc++.h>
using namespace std;
 
#define MD 1000000007
typedef long long int ll;

int main(){
    ll n;
    cin>>n;
    
    ll j=1;
    while(1){
        if(j*j>=n){
            break;
        }else{
            j++;
        }
    }
    
    ll cnt=j,a,b;
    while(1){
        if(n%cnt==0){
            ll tmpa=cnt,tmpb=n/cnt;
            if(tmpa<=tmpb){
                b=tmpb;
                break;
            }
       }
        cnt--;
    }
   
    cout<<floor(log10(b)+1)<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h> 
using namespace std;
int main()
{
  int x,n,p,i,f,c,d,a=0;
  map<int,int> mp;
  cin>>x>>n;
  for(i=0;i<n;i++)
  {
    cin>>p;
    mp[p]++;
  }
  c=1; d=1;
    f=x;
  while(1)
  {
    if(!mp[f])
    {cout<<f; break;}
    a++;
    if(a%2!=0)
    {f=x-c; c++;}
    else
    {f=x+d; d++;}
  }
  return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;

#define M 1000000 
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define fill(a,x) memset(a,x,sizeof(a))
#define F first
#define S second
#define FOR(i,a,b) for(ll i = a; i<=b; ++i)
#define NFOR(i,a,b) for(ll i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
const ll INF = 1e18;
const ll mod = 1e9+7;
const ll N = 1e5 + 10;
inline ll add(ll x,ll y){
  x += y;
  if(x >= mod) x -= mod;
  return x;
}
inline ll mul(ll x,ll y){
  x = (1LL * x * y) % mod;
  return x;
}


int main()
{
	fast;

	int n,i;cin>>n>>i;
	cout << (n-i+1);

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.lang.String;

public class Main {

    public static void main(String[] args) {
        int A1;
        int num = 0;
        Scanner scan = new Scanner(System.in);
        String S = scan.nextLine();
        A1 = S.length();
        for(int i=0; i<(A1/2); i++){
            if(S.charAt(i) != S.charAt(A1-i-1)){
                num++;
            }
        }
        System.out.println(num);
    }
}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

signed main() {
    int n;
    cin >> n;
    vector<int> v(n);
    map<int, int> odd, even;
    for (int i = 0; i < n; i++) {
        cin >> v[i];
        if(i & 1) odd[v[i]]++;
        else even[v[i]]++;
    }
    vector<pair<int, int>> odd_top(2), even_top(2);
    auto comp = [](auto &x, auto &y) {return x.second > y.second; };
    partial_sort_copy(odd.begin(), odd.end(), odd_top.begin(), odd_top.end(), comp);
    partial_sort_copy(even.begin(), even.end(), even_top.begin(), even_top.end(), comp);
    int result = 0;
    if (odd_top[0].first == even_top[0].first)
        result = n - max(odd_top[0].second + even_top[1].second, odd_top[1].second + even_top[0].second);
    else
        result = n - (odd_top[0].second + even_top[0].second);
    cout << result << "\n";
}

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

int main() {
  int n;
  cin >> n;

  int digit = n % 10;

  switch (digit) {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      cout << "hon" << endl;
      break;
    case 0:
    case 1:
    case 6:
    case 8:
      cout << "pon" << endl;
      break;

    case 3:
      cout << "bon" << endl;
      break;
  }
}


Measured memory_bytes: 3536
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<long long,long long>
#define rd(x) cin >> x;
#define rda(a,n) for(int i=1;i<=n;i++) cin >> a[i];
#define wr(x) cout << x << ' ';
#define wrl(x) cout << x << '\n';
#define wra(a,n) for(int i=1;i<=n;i++) cout << a[i] << ' '; cout << '\n';
#define lg length()
#define pb(x) push_back(x)
ifstream in("file.in");
ofstream out("file.out");
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005
struct comp{
    bool operator()(long long a, long long b){
        return a>b;
    }
};

int n,a[100005],v[100005],k;

int main(){
    ios_base :: sync_with_stdio(0);
    cin >> n;
    for(int i=1;i<=n;i++) cin >> a[i];
    int x=1;
    while(x!=2 && !v[x]){
        v[x]=1;
        x=a[x];
        k++;
    }
    if(x==2) cout << k;
    else cout << -1;
}


Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
"""



"""
import sys


def solve(P, Q, R):
    return min(P+Q, Q+R, R+P)


def main(args):
    P, Q, R = map(int, input().split())
    ans = solve(P, Q, R)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 2940
#include<cstdio>
inline int in();
inline void wr(int);
int main(int argc,char**argv){
#ifndef ONLINE_JUDGE
//	freopen("A.in","r",stdin);
//	freopen("A.ans","w",stdout);
#endif
	register int a=in(),b=in();
	if(a>9||b>9){wr(-1),putchar('\n');return 0;}
	wr(a*b),putchar('\n');
}
inline int in(){
	register char c=getchar();
	register int x=0,f=1;
	for(;c<'0'||c>'9';c=getchar())
		if(c=='-')f=-1;
	for(;c>='0'&&c<='9';c=getchar())
		x=(x<<1)+(x<<3)+(c&15);
	return x*f;
}
inline void wr(int x){
	if(x<0)putchar('-'),x=-x;
	if(x/10)wr(x/10);
	putchar(x%10+'0');
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <sstream>
#include <iomanip>

using namespace std;
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; }

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;



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

	ll N;
	cin >> N;

	vector<ll> H(N);
	for (ll i = 0; i < N; ++i) cin >> H[i];

	ll ans = 0;

	for (ll i = 0; i < N; ++i)
	{
		bool flag = true;

		for (ll j = 0; j < i; ++j)
		{
			if (H[j] > H[i])
			{
				flag = false;
				break;
			}
		}

		if (flag) ans++;
	}

	cout << ans << endl;

	//system("pause");
}

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

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::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...);
}
#else
#define trace(...)
#endif

#define pb push_back
#define ff first
#define ss second
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)

using ll = long long int;
using ld = long double;
using vi = vector<int>;
using mii = map<int, int>;
using pii = pair<int, int>;

const int inf = 1e9;
const int N = 100005;
const ll mod = (ll) 1e9 + 7;

int32_t main(){
	fio;

	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	ll ans;

	ans = b * d;
	ans = max(ans, a * c);
	ans = max(ans, a * d);
	ans = max(ans, b * c);

	if(ans < 0 and ((c <= 0 and d >= 0) or (a <= 0 and b >= 0)))
		ans = 0;
	cout << ans << '\n';
	return 0;

}

/*
 */


Measured memory_bytes: 3536
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    int a,b,c;
    vector<int> vc;
    int i;
    i = 0;
    while (i < 3)
    {
        int x;
        cin >> x;
        vc.push_back(x);
        i++;
    }
    vector<int> vt(3);
    copy(vc.begin(), vc.end(),vt.begin());
    vc[0] = vt[2];
    vc[1] = vt[0];
    vc[2] = vt[1];
    cout << vc[0] << " " << vc[1] << " " << vc[2] << endl;
    return 0;
}


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

#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

int main() {
	int n, i;
	double p1 = 0.0, p2 = 0.0, p3 = 0.0, pin = 0.0;

	// input vector
	cin >> n;
	double x[n], y[n];
	rep(i,n) cin >> x[i];
	rep(i,n) cin >> y[i];

	// caliculate D1
	rep(i,n) p1 += fabs(x[i]-y[i]);
	cout << fixed << setprecision(6) << p1 << endl;

	// caliculate D2
	rep(i,n) p2 += pow(fabs(x[i]-y[i]),2);
	p2 = sqrt(p2);
	cout << fixed << setprecision(6) <<  p2 << endl;

	// caliculate D3
	rep(i,n) p3 += pow(fabs(x[i]-y[i]),3);
	p3 = pow(p3, 1.0/3.0);
	cout << fixed << setprecision(6) << p3 << endl;

	// caliculate D_inf
	rep(i,n) if (pin < fabs(x[i]-y[i])) pin = fabs(x[i]-y[i]);
	cout << fixed << setprecision(6) <<  pin << endl;

	return 0;
}

Measured memory_bytes: 1332
# import bisect
# from collections import Counter, deque
# import copy
# from fractions import gcd
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np
# import sys
# sys.setrecursionlimit(10**9)

def resolve():
    N,M=map(int,input().split())
    L=sorted([list(map(int,input().split())) for i in range(N)],key=lambda x:x[1], reverse=True)
    L.sort()
    def main():
        cnt = 0
        val = 0

        while True:
            for i in range(N):
                cnt+=L[i][1]
                val+=L[i][0]*L[i][1]
                if cnt>M:
                    val-=(cnt-M)*L[i][0]
                    return val


    print(main())






resolve()

Measured memory_bytes: 29788
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ff(i,n) for(i=0;i<n;i++)
int main()
{
   ll t;
   t = 1;
   while(t--)
   {
   		ll x,d,k;
   		cin>>x>>k>>d;
   		ll num = abs(x)/d;
   		if(num>=k)
   			cout<<abs(abs(x)-k*d)<<endl;
   		else
		{
			ll a = abs(abs(x) - num*d),b = abs(abs(x) - (num+1)*d ),c = abs(abs(x) - (num-1)*d),q = abs(abs(x) - (num+2)*d);
			if((k-num)%2==0)
				cout<<min(a,q)<<endl;
			else	
				cout<<min(c,b)<<endl;   	
		}	
   }
   return 0 ;
} 

Measured memory_bytes: 3640
#include<iostream>
using namespace std;
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) REP(i,0,b)
#define long long int lld
#define INF INT_MAX/3
#define debug(x) cout<<"#x"<<": "<<x<<endl
int main(void){
	int x,a,b;
	cin >> x >> a >> b;
	int xa,xb;
	xa = a - x;
	xb = b - x;
	if(xa < 0) xa *= -1;
	if(xb < 0) xb *= -1;
	if(xa >= xb) cout << "B" << endl;
	if(xa < xb) cout << "A" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;

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

    vector <int> L(N);

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

    sort(L.begin(), L.end());
    int ans = 0;

    for (int i = 0; i < N; ++i) {
        for (int j = i+1; j < N; ++j) {
            if (L[j] == L[i]) {
                continue;
            }
            for (int k = j+1; k < N; ++k) {
                if (L[k] == L[j]) {
                    continue;
                }
                if (L[k] < L[j] + L[i]) {
                    ++ans;
                }
            }
        }
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<math.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define lrep(i,n) for(long int i=0;i<(n);i++)
using namespace std;
int main(){
	int a,b;
	cin >> a >> b;
	cout <<a*b;
	return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

const int SIZE = 300000;

int main() {
    int H, W, M;
    cin >> H >> W >> M;

    int hc[SIZE] = {}, wc[SIZE] = {};
    pii hw[SIZE] = {};
    REP(i, M) {
        int h, w;
        cin >> h >> w; h--; w--;
        hc[h]++;
        wc[w]++;
        hw[i] = {h, w};
    }
    vector<pii> phc, pwc;
    REP(i, SIZE) {
        phc.push_back({hc[i], i});
        pwc.push_back({wc[i], i});
    }
    sort(ALL(phc), greater<pii>());
    sort(ALL(pwc), greater<pii>());

    int hcnt, wcnt;
    vector<int> ht, wt;
    REP(i, SIZE) {
        hcnt = phc[i].first;
        ht.push_back(phc[i].second);
        if (i == SIZE - 1) break;
        if (phc[i].first != phc[i + 1].first) break;
    }
    REP(i, SIZE) {
        wcnt = pwc[i].first;
        wt.push_back(pwc[i].second);
        if (i == SIZE - 1) break;
        if (pwc[i].first != pwc[i + 1].first) break;
    }
    sort(ALL(ht));
    sort(ALL(wt));

    int cnt = 0;
    REP(i, M) {
        int h, w;
        h = hw[i].first; w = hw[i].second;
        if (binary_search(ALL(ht), h) && binary_search(ALL(wt), w)) cnt++;
    }
    ll ans = hcnt + wcnt;
    if (cnt == ht.size() * wt.size()) ans--;
    cout << ans << endl;
}

Measured memory_bytes: 16992
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pl = pair<ll, ll>;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18;
ll f(ll a, ll c, ll d) {
	ll p = a / c, q = a / d, r = a / (c / __gcd(c, d) * d);
	return a - (p + q - r);
}
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	int h, w;
	cin >> h >> w;
	int n;
	cin >> n;
	int a[n];
	rep(i, n) cin >> a[i];
	int now = 0;
	int ans[h][w];
	rep(i, h) {
		rep(j, w) {
			if (a[now] == 0) now++;
			if (i % 2 == 0)
				ans[i][j] = now + 1;
			else
				ans[i][w - 1 - j] = now + 1;
			a[now]--;
		}
	}
	rep(i, h) {
		rep(j, w) {
			if (j) cout << " ";
			cout << ans[i][j];
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 384
#pragma comment(linker, "/STACK:64000000")
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <ctime>
#include <sstream>
#include <algorithm>
#include <functional>
#include <numeric>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define ft first
#define st second
#define mp make_pair
#define pb push_back
#define sz(n) int(n.size())
#define all(n) n.begin(), n.end()


using namespace std;

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

const int N = 1e5 + 123;
const int inf = 1e9 + 7;
const ll INF = 1e18 + 7;

string s;
int cnt [300], ans, balance ;

int main ()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	  
	cin >> s;
	for (int i = 0; i < sz(s); i ++) 
	{
		if (s[i] == 'S') balance ++;
		else if (s[i] == 'T')
		{
			if (balance > 0) 
			{
				balance --;
				ans += 2;
			}
		}
	}                       

	cout << sz(s) - ans; 
}




Measured memory_bytes: 720
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::collections::HashSet;

fn main() {
    input! {
        n: usize,
        ww: [chars;n]
    }
    let mut set = HashSet::new();
    set.insert(&ww[0]);
    let mut yes = true;
    for i in 1..n {
        if set.contains(&ww[i]) {
            yes = false;
            break;
        }
        let l = ww[i-1].len();
        if ww[i-1][l-1] != ww[i][0] {
            yes = false;
            break;
        }
        set.insert(&ww[i]);
    }
    println!("{}", if yes {"Yes"} else {"No"});
}


Measured memory_bytes: 4352
N,X = list(map(int, input().split()))
x = sorted([X] + list(map(int, input().split())))

gaps = [b-a for a,b in zip(x, x[1:])]

from fractions import gcd
g1=gaps[0]
for g2 in gaps[1:]:
    g1 = gcd(g1, g2)

print(g1)

Measured memory_bytes: 14252