akhauriyash/Code-Regression huggingface dataset:
use std::collections::BTreeMap;

#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let mut bm = BTreeMap::new();
    let n = get!(usize);
    for _ in 0..n {
        let t = get!(String);
        *bm.entry(t).or_insert(0) += 1;
    }
    let max = *bm.iter().map(|(_, x)| x).max().unwrap();
    for (k, v) in bm {
        if v == max {
            println!("{}", k);
        }
    }
}


Measured memory_bytes: 18940
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

int main()
{
	int n, k, i;
	long long input;
	vector<long long> arr;
	long long min = 1000000001;

	scanf("%d %d", &n, &k);

	for (i = 0; i < n; i++)
	{
		scanf("%d", &input);

		arr.push_back(input);
	}

	sort(arr.begin(), arr.end());

	for (i = 0; i < n - k + 1; i++)
	{
		if (min > arr[i + k - 1] - arr[i])
		{
			min = arr[i + k - 1] - arr[i];
		}
	}

	printf("%lld\n", min);

	return 0;
}

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

using namespace std;

int main() {
    string s;
    int count = 0;
    cin >> s;
    
    if (s[0] == '1') count++;
    if (s[1] == '1') count++;
    if (s[2] == '1') count++;
    
    cout << count << endl;
}

Measured memory_bytes: 3164
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)


int main(){
	int n,l;
	cin>>n>>l;
	
	vector<pii> vec(n);
	rep(i,n){
		int a,b;
		cin>>a>>b;
		vec[i] = pii(a,b);
	}
	
	int dp[100000+1];
	memset(dp,0,sizeof(dp));
	
	rep(i,n){
		int v,w;
		tie(v,w) = vec[i];
		for(int j=100000;j>=0;j--){
			if(j-w<0)continue;
			dp[j] = max(dp[j-w]+v,dp[j]);
		}
	}
	
	int maxi = -INF;
//	rep(i,l+1)maxi = max(maxi,dp[i]);
	cout<<dp[l]<<endl;
}

Measured memory_bytes: 3480
k = gets.to_i

table = [
[1,2,5,13,35,96,267,750,2123,6046],
[1,3,8,22,61,171,483,1373,3923,11256],
[1,3,9,26,75,216,623,1800,5210,15104],
[1,3,9,27,80,236,694,2037,5971,17486],
[1,3,9,27,81,242,720,2134,6305,18581],
[1,3,9,27,81,242,720,2134,6305,18581],
[1,3,9,27,80,236,694,2037,5971,17486],
[1,3,9,26,75,216,623,1800,5210,15104],
[1,3,8,22,61,171,483,1373,3923,11256],
[1,2,5,13,35,96,267,750,2123,6046],
]

counts = 
[9,35,110,327,956,2782,8089,23527,68468,199368]

max = counts.index{ |x| x >= k}
if max > 0 then
	k -= counts[max - 1]
end

result = []

max.downto(0){ |keta|
	if keta == max then
		(1..9).each{ |i|
			if k > table[i][keta] then
				k -= table[i][keta]
			else
				result << i
				break
			end
		}
	else
		st = [result[-1] - 1, 0].max
		ed = [result[-1] + 1, 9].min
		
		(st..ed).each{ |i|
			if k > table[i][keta] then
				k -= table[i][keta]
			else
				result << i
				break
			end
		}
	end
}


puts result.join("")

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

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

  vector<int> p(n);
  for (int i = 0; i < n; i++)
    cin >> p.at(i);

  int ans = 0;
  for (int i = 1; i < n - 1; i++) {
    int minimum = min({p[i - 1], p[i], p[i + 1]});
    int maximum = max({p[i - 1], p[i], p[i + 1]});
    if (minimum != p[i] && p[i] != maximum)
      ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  vector<int> A(N),B(N);
  rep(i,N) cin >> A[i];
  rep(i,N) cin >> B[i];
  int sum = 0;
  for(int i=1;i<N+1;i++)
  {
    int candy = 0;
    for(int j=0;j<i;j++)
    {
      candy += A[j];
    }
      for(int k=i-1;k<N;k++)
      {
        candy += B[k];
        sum = max(sum,candy);
      }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3548
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define str string
#define fi first
#define se second
#define pb push_back
#define SET(a, b) memset(a, b, sizeof(a))
#define eps 1e-6
#define pi atan(1) * 4
#define mod 1000000007
#define inf 1000000000
#define llinf 1000000000000000000
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
#define FORl(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORDl(i, a, b) for (ll i = (a); i >= (b); i--)
using namespace std;
vector<int> edges[200005];
int sum[200005];
void dfs (int u, int p) {
  for (auto v : edges[u]) {
    if (v == p) continue;
    sum[v] += sum[u];
    dfs(v, u);
  }
}
int main () {
  int n, q;
  scanf("%d %d", &n, &q);
  FOR(i, 1, n - 1) {
    int u, v;
    scanf("%d %d", &u, &v);
    edges[u].pb(v); edges[v].pb(u);
  }
  FOR(i, 1, q) {
    int p, x;
    scanf("%d %d", &p, &x);
    sum[p] += x;
  }
  dfs(1, -1);
  FOR(i, 1, n) printf("%d%c", sum[i], (i == n) ? '\n' : ' ');
  return 0;
}

Measured memory_bytes: 23424
def main():
    import dataclasses
    from heapq import heappush, heappop

    @dataclasses.dataclass(frozen=True)
    class Path:
        to: int
        fare: int
        travel_time: int

    @dataclasses.dataclass(frozen=True)
    class ExchangeRate:
        Ag: int
        exchange_time: int

    @dataclasses.dataclass(frozen=True)
    class Traveler:
        consumption_time: int
        remaining_Ag: int
        location: int

        def __gt__(self, other):
            return self.consumption_time > other.consumption_time

        def __eq__(self, other):
            return self.consumption_time == other.consumption_time

    INF = 1 << 60
    MX_AG = 2500

    N, M, S = map(int, input().split())
    S = min(S, MX_AG)  # それ以上のAgは不要

    g = tuple(set() for _ in range(N))
    for _ in range(M):
        u, v, a, b = map(int, input().split())
        u -= 1
        v -= 1
        g[u].add(Path(v, a, b))
        g[v].add(Path(u, a, b))

    exchange = []
    for _ in range(N):
        c, d = map(int, input().split())
        exchange.append(ExchangeRate(c, d))

    h = [Traveler(0, S, 0)]

    time = [[INF] * (MX_AG + 1) for _ in range(N)]
    time[0][S] = 0
    # time[location][r_Ag]:=minimum_time_to_reach

    while h:
        t = heappop(h)
        for p in g[t.location]:
            n_Ag = t.remaining_Ag - p.fare
            if n_Ag < 0: continue
            cf = time[p.to][n_Ag]
            n_time = t.consumption_time + p.travel_time
            if cf <= n_time: continue
            time[p.to][n_Ag] = n_time
            heappush(h, Traveler(consumption_time=n_time, remaining_Ag=n_Ag, location=p.to))

        e_time = t.consumption_time + exchange[t.location].exchange_time
        e_Ag = t.remaining_Ag + exchange[t.location].Ag
        if e_Ag > MX_AG: continue
        cf = time[t.location][e_Ag]
        if cf <= e_time: continue
        time[t.location][e_Ag] = e_time
        heappush(h, Traveler(consumption_time=e_time, remaining_Ag=e_Ag, location=t.location))

    for to in range(1, N):
        print(min(time[to]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 32492
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll, vl/*, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); ++i)
#define rep2(i, n) for(ll i = 1; i <= ll(n); ++i)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); ++i)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); ++i)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll q, t, f, k=1;
  string s, b, e;
  char c;
  cin >> s >> q;
  
  rep(_, q) {
    cin >> t;
    if(t==1) k = 3-k;
    else {
      cin >> f >> c;
      if(k&f) b += c;
      else e += c;
    }
  }
  reverse(all(b));
  s = b+s+e;
  if(k-1) reverse(all(s));
  cout << s << newl;
  return 0;
}

Measured memory_bytes: 1200
def count_inversions(L):
  def helper(A,B):
    lA,lB = len(A),len(B)
    if lA == 0:
      return B,0
    elif lB == 0:
      return A,0
    
    A,c1 = helper(A[:lA//2],A[lA//2:])
    B,c2 = helper(B[:lB//2],B[lB//2:])
    cnt = c1+c2
    i = 0
    j = 0

    C = [None]*(lA+lB)
    while i < lA and j < lB:
      if A[i] > B[j]:
        cnt += lA-i
        C[i+j] = B[j]
        j += 1
      else:
        C[i+j] = A[i]
        i += 1

    if i < lA:
      C[i+j:] = A[i:]
    else:
      C[i+j:] = B[j:]

    return C,cnt

  return helper(L[:len(L)//2],L[len(L)//2:])[1]

from collections import deque

ALPHABETS = 26

indices = [deque() for _ in range(26)]
S = list(map(lambda c: ord(c)-ord('a'),input()))
for i,c in enumerate(S):
  indices[c] += [i]

odd = None
for c,l in enumerate(indices):
  if len(l)%2 == 1:
    if odd is None:
      odd = c
    else:
      odd = -1
      break

if odd == -1:
  print(-1)
  exit()

target = [None]*len(S)
assigned = [False]*len(S)
if odd is not None:
  l = list(indices[odd])
  i = l[len(l)//2]
  target[len(target)//2] = i
  assigned[i] = True
  l = deque(l[:len(l)//2] + l[len(l)//2+1:])

j = 0
for i in range(len(S)//2):
  while assigned[j]:
    j += 1

  l = indices[S[j]]
  a = l.popleft()
  b = l.pop()
  assert a == j
  target[i] = a
  target[len(S)-i-1] = b
  assigned[a] = True
  assigned[b] = True
  
print(count_inversions(target))


Measured memory_bytes: 23488
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

struct edge{
	int to;
	int cost;
};

int V;
vector<edge> g[100100];
int dist[100100];

// O(ElogV)
void dijkstra(int s){
	// P<最短距離, 頂点番号>
	priority_queue< P, vector<P> , greater<P>> que;
	fill(dist, dist+V, 1002003004);

	dist[s] = 0;
	que.push({0,s});

	while(!que.empty()){
		P p = que.top();
		que.pop();
		int nv = p.second;
		if(dist[nv] < p.first) continue;

		for(auto e: g[nv]){

            if (dist[e.to] > dist[nv] + e.cost) {
                dist[e.to] = dist[nv] + e.cost;
                que.push(P(dist[e.to], e.to));
            }

        }
    }
}

int main(){
	cin >> V;
	int E; cin >> E; int r; cin >> r;

	rep(i,E){
		int s, t, d; cin >> s >> t >> d;
		edge e = {t, d};
		g[s].push_back(e);
	}

	dijkstra(r);

	rep(i,V){
		if(dist[i] != 1002003004){
			cout << dist[i] << endl;
			continue;
		}
		cout << "INF" << endl;
	}
}


Measured memory_bytes: 12972
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void){
    char S[11],T[11],U[10];
    int A,B;
    scanf("%s%s",S,T);
    scanf("%d%d",&A,&B);
    scanf("%s",U);
   
   if(*S==*U){
       A = A-1;
   }
   else if(*T==*U){
       B=B-1;
   }
   printf("%d %d\n",A,B);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, Y;
  cin >> N >> Y;
  int x, y, z; 
  x = -1, y = -1, z= -1; 
  for(int i = 0; i <= N; i++){
  for(int j = 0; j <= N-i; j++) {
  if(10000*i+5000*j+1000*(N-i-j) == Y)
  x = i, y = j, z = N-i-j; 
  }
  }
  cout << x << " " << y << " " << z << endl; 
}

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

int n;
long m, p[1001], q[1100000];

int main(){
	while(std::cin >> n >> m){
        if(n == 0 && m == 0){
            break;
        }

		p[0]=0;
		for(int i=1; i<=n; ++i){
            std::cin >> p[i];
        }
        std::sort(p, p+n);

        long k=0;
		for(int i=0; i<=n; ++i){
            for(int j=i; j<=n; ++j){
		        q[k++]=p[i]+p[j];
            }
        }
        std::sort(q, q+k);

        long ans=0;
		for(long i=0; i<k; ++i){
			long rem=m-q[i];
			if(rem<0) break;

            long l=0, r=k;
			while(l<r){
				long c=(l+r)/2;
				if(rem>q[c]){
					l=c+1;
				}
				else if(rem<q[c]){
					r=c;
				}
				else{
                    break;
                }
			}
			ans=std::max(ans, q[i]+q[r-1]);
		}
	    std::cout << ans << std::endl;
    }
}

Measured memory_bytes: 7044
h, w, d = map(int, input().split())
ls = [list(map(int, input().split())) for _ in range(h)]
q = int(input())
qs = [list(map(int, input().split())) for _ in range(q)]

pos = [None for _ in range(h * w + 1)]
for y in range(h):
    for x in range(w):
        pos[ls[y][x]] = (x, y)

ds = []
for i in range(d):
    ps = pos[1 + i::d]
    temp = [0]
    for x, y in zip(ps, ps[1:]):
        z = abs(x[0] - y[0]) + abs(x[1] - y[1])
        temp.append(temp[-1] + z)
    ds.append(temp)

for l, r in qs:
    l -= 1
    r -= 1
    ps = ds[l % d]
    print(ps[r // d] - ps[l // d])

Measured memory_bytes: 45104
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define mp make_pair
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using ll = long long;
using namespace std;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int n,a;
deque<int> dq;
int main(){
    cin >> n;
    rep(i,n){
        cin >> a;
        if(i%2) dq.pb(a);
        else dq.push_front(a);
    }
    if(n%2) rep(i,n){
        if(!i) cout << dq[i];
        else cout << " " << dq[i];
    }
    else rep(i,n){
        if(!i) cout << dq[n-1];
        else cout << " " << dq[n-1-i];
    }
}

Measured memory_bytes: 3072
n, a, b = map(int, input().split())
x = n//(a+b)
if (a+b)*x == n:
    print(a*x)
else:
    if n - (a+b)*x >= a:
        print(a*(x+1))
    else:
        print(a*x + n - (a+b)*x)

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

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

  int SumVal = 0;
  vector<int> W(N);
  rep( i, 0, N ) {
    cin >> W.at(i);
    SumVal += W.at(i);
  }

  int Ans = INT_MAX;
  int TempVal = 0;
  rep( i, 0, N-1 ) {
    TempVal += W.at(i);
    int sa = abs( TempVal - ( SumVal-TempVal ) );
    if ( sa<Ans ) Ans = sa;
  }
  cout << Ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

const ll INF = -1 * 1LL<<60;
ll N = 1;
 
void update(vector<ll> &value, int i, ll x) {
    // i 番目の葉の値を x に変える
    i += N - 1; // i 番目の葉のノード番号
    value[i] = x;
    while (i > 0) {
        i = (i - 1) / 2; // ノード i の親ノードの番号に変える
        value[i] = max(value[i * 2 + 1],
                       value[i * 2 + 2]); // 左右の子の max を計算しなおす
    }
}
 

ll query(vector<ll> &value, int a, int b, int k, int l, int r) {
    // [a, b) の区間に対するクエリについて
    // ノード k （区間 [l, r) 担当）が答える
    if (r <= a || b <= l) return INF; // 区間が被らない場合は INF を返す
    if (a <= l && r <= b)
        return value[k]; // ノード k の担当範囲がクエリ区間 [a, b)
                         // に完全に含まれる
    else {
        ll c1 = query(value, a, b, 2 * k + 1, l, (l + r) / 2); // 左の子に値を聞く
        ll c2 = query(value, a, b, 2 * k + 2, (l + r) / 2, r); // 右の子に値を聞く
        return max(c1, c2); // 左右の子の値の max を取る
    }
}
 

int main() {
	ll n, c;
	cin >> n >> c;
	vector<ll> x(n), v(n);
	rep(i, n) cin >> x[i] >> v[i];
	vector<ll> cw(n), ccw(n);
	for(int i = 0; i < n; i++) {
		if(i > 0) {
			cw[i] = cw[i-1] + v[i] - (x[i] - x[i-1]);
			ccw[i] = ccw[i-1] + v[n-1-i] - ((c - x[n-1-i]) - (c - x[n-i]));
		} else {
			cw[i] = v[i] - x[i];
			ccw[i] = v[n-1-i] - (c - x[n-1-i]);
		}
	}
	while(N < n) N *= 2;
	vector<ll> CW(2*N-1, INF), CCW(2*N-1, INF);
	rep(i, n) {
		update(CW, i, cw[i]);
		update(CCW, i, ccw[i]);
	}
	ll ans = 0;
	rep(i, n) {
		// 時計回りにiまで行くのみ
		ans = max(ans, cw[i]);
		// 時計回りにiまで行った後、入口まで戻り、反時計回りに行く
		ll now = cw[i] - x[i] + query(CCW, 0, n-i-1, 0, 0, N);
		ans = max(ans, now);
	}
	rep(i, n) {
		// 反時計回りにiまで行くのみ
		ans = max(ans, ccw[i]);
		// 反時計回りにiまで行った後、入口まで戻り、時計回りに行く
		ll now = ccw[i] - (c - x[n-1-i]) + query(CW, 0, n-i-1, 0, 0, N);
		ans = max(ans, now);
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 7424
#include <iostream>
#include <algorithm>
using namespace std;
#define N 100
int main(){
	int n,p[N+1],m[N+1][N+1];
	cin>>n;
	for(int i=0;i<n;i++)	cin>>p[i]>>p[i+1];
	for(int i=1;i<=n;i++)	m[i][i]=0;
	for(int l=2;l<=n;l++){
		for(int i=1;i<=n-l+1;i++){
			int j=l+i-1;
			m[i][j]=(1<<21);
			for(int k=i;k<=j-1;k++){
				m[i][j]=min(m[i][j],m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
			}
		}
	}
	cout<<m[1][n]<<endl;
	return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n, l;
	string s;
	vector<string>ss;
	cin>>n>>l;
	for(int i=0;i<n;i++){
		cin>>s;
		ss.push_back(s);
	}
	sort(ss.begin(),ss.end());
    for(int i=0;i<ss.size();i++){
    	cout<<ss[i];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
//#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cctype>


using namespace std;
#define modd 1000000007


typedef pair<long long, long long> pl;


typedef string::const_iterator State;
class ParseError {};




#define ll long long




/*
class UnionFind {
public:
	vector <ll> par;
	vector <ll> siz;
	vector <ll> gr;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) ,gr(sz_){
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};*/


long long N, M, K, a, b, c, d, e, H, W, L;
ll A[100005] = {};
ll B[300005] = {};
ll C[300005] = {};
bool f, ff;
string S,T;
set <long long>sll;
pl bufpl;
vector <long long>vl[300002];
vector <pl>vpl;
vector <string> vs;
set<ll> llset;
multiset<ll> llmset;

/*struct ST
{
	long long Kati;
	int bangou;

	bool operator<(const ST& another) const
	{
		return Kati < another.Kati;//比較
	};

};



vector <ST> vst;
ST st[200005];
ST bufst;
bitset<5000> bits;*/


long long modinv(long long aa, long long mm) {
	long long bb = mm, uu = 1, vv = 0;
	while (bb) {
		long long tt = aa / bb;
		aa -= tt * bb; swap(aa, bb);
		uu -= tt * vv; swap(uu, vv);
	}
	uu %= mm;
	if (uu < 0) uu += mm;
	return uu;
}



ll minn, maxx;
double ansa;
bool fl[30] = {};


string ss, sss;

int main() {


	cin >> N;

	for (int i = 0; i < N; i++) {
		cin >> M;
		for (int j = 0; j < M; j++) {
			cin >> a;
			vl[i].push_back(a);
		}

	}



	for (int i = N-1; i >=0; i--) {
		for (int j = 0; j < vl[i].size(); j++) {
			llmset.insert(vl[i][j]);
		}
		auto it = llmset.end();
		it--;
		e += *it;
		llmset.erase(it);
	
	}

	cout << e << endl;

	return 0;

}



Measured memory_bytes: 28056
#include <iostream>

using namespace std;

int main(){
    int n,y,m,d;
    cin >> n;

    for(int i=0; i<n; i++){
        cin >> y >> m >> d;
        int toBD =(y-1)*195 +((y-1)/3)*5 +(m-1)*20 +d -1;
        if(y%3!=0) toBD -= (m-1)/2;
        
        cout << 196470 - toBD << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3080
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <utility>
using namespace std;

int main()
{
    int n;
    int i,j,k;
    cin >> n;
    vector<pair<int,int>> a(n);
    for(i = 0;i < n;++i){
        cin >> a.at(i).first;
        a.at(i).second = i+1;
    }
    sort(a.begin(),a.end());
    for(i = 0;i < n;++i){
        if(i != n-1){
            cout << a.at(i).second << " ";
        }else{
            cout << a.at(i).second << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1664
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("-Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef int in;
#define int long long
#define pb push_back
#define f first
#define s second
#define double long double
#define p push
const int MAX=2e5+5;
const int MAX2=1e6;
const int MAAX=2e18;
const int MOD=1e9+7;
int n,a[405];
int dp[405][405];
int cost(int l,int r)
{
   return a[r]-(l?a[l-1]:0);
}
int fun(int s,int e)
{
    if(s>=e)
        return 0;
    int &ret=dp[s][e];
    if(~ret)
        return ret;
        ret=MAAX;
        for(int l=s;l<e;l++)
        {
            ret=min(cost(s,l)+fun(s,l)+cost(l+1,e)+fun(l+1,e),ret);
        }
        return ret;
}
in main()
{
    memset(dp,-1,sizeof dp);
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        a[i]+=(i?(a[i-1]):0);
    }
    cout<<fun(0,n-1)<<endl;
    return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
#include<cmath>
#include<string>
#include<algorithm>
#define neli printf("\n")

using namespace std;

int main()
{

    int n,a;cin>>n;
    int arr[n];
    for(int i=1;i<=n;i++)
    {
        cin>>a;
        arr[a]=i;

    }
    for(int i=1;i<=n;i++)
        cout<<arr[i]<<" ";
    neli;
    return 0;
}


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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()
const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    double r; cin>>r;
    double S,L;
    S=r*r*pi;
    L=2*r*pi;
    printf("%lf %lf\n",S,L);
    return 0;
}


Measured memory_bytes: 3196
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int n,k;
  cin>>n>>k;
  int arr[n];
  for(int i=0;i<n;i++){
    cin>>arr[i];
  }
  int dp[n+1];
  dp[0]=0;
  for(int i=1;i<n;i++){
      dp[i]=dp[i-1]+abs(arr[i]-arr[i-1]);
      for(int j=1;j<=k;j++){
          if(i>=j)
          {
              dp[i]=min(dp[i],dp[i-j]+abs(arr[i]-arr[i-j]));
          }
      }
  }
  cout<<dp[n-1];
  return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
//#include <cstdlib>
//#include <iostream>
//#include <string>
//#include <vector>
//#include <algorithm>

using namespace std;

int main(){
    int a, b, max;
    scanf("%d %d", &a, &b);

    max = a + b;
    if(a - b > max) max = a - b;
    if(a * b > max) max = a * b;

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

    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
constexpr auto mod = 1000000007;
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}

//combination(Nが小さい時はこれを使う)
const int MAX = 300000;
int fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
int COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

//繰り返し二乗法（Nが大きい時の場合のcombination)
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= (i % mod); res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
//UnionFind
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
int dight_sum(int n) {
	int sum = 0;
	rep(i, 20)sum += (n % (int)pow(10, i + 1)) / (pow(10, i));
	return sum;
}
signed main() {
	int r;
	cin >> r;
	double pi = 3.1415926;
	cout << 2 * r * pi << endl;
	ggr
}

Measured memory_bytes: 3848
/**akshaykumar99**/
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using id_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;
template<typename T> using id_setp = tree<pair<T,T>,null_type,less<pair<T,T>>,rb_tree_tag,tree_order_statistics_node_update> ;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define fr(i,x,n) for(i=x;i>=n;i--)
#define pu push_back           
#define pp pop_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SP(x) fixed<<setprecision(x)
#define IOS() ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const long long MOD=1e9+7;
const long double PI = acos(-1);
const long long INF=INT_MAX;
const long long LINF=LLONG_MAX;
const long long N=1e5+1;
 
typedef long long ll;
typedef long double ld;

int main()
{
    IOS();
    ll n,a,b,i;
	cin>>n>>a>>b;
	ll d=b-a;
	if(d%2==0)
	{
		cout<<d/2<<'\n';
	}
	else
	{
		ll d1=a+d/2;
		ll d2=n-b+1+d/2;
		cout<<min(d1,d2);
	}
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0; i<n;i++)
typedef long long ll;
// B 75
int main(){
    int h,w; cin >> h >> w;

    string board[50];
    rep(i,h) cin >> board[i];

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

    rep(i,h){
        rep(j,w){
            if(board[i][j] == '#') continue;

            int num=0;
            for(int d=0; d<8; d++){
                const int ni = i + dy[d];
                const int nj = j + dx[d];

                if(ni < 0 or h <= ni) continue;
                if(nj < 0 or w <= nj) continue;
                if(board[ni][nj] == '#') num++;
            }
            board[i][j] = char(num + '0');
        }
    }
    rep(i,h) cout << board[i] << endl;
    return 0;
}


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

using ll = long long;

int main(int argc, char** argv) {
  int N;
  std::cin >> N;
  std::vector<int> A(N);
  for (auto& e : A) std::cin >> e;
  bool is_denied = false;
  for (auto i = 0;i < N;++i) {
    if (A[i] % 2 == 0) {
      if (A[i] % 5 == 0 || A[i] % 3 == 0) {
        continue;
      } else {
        is_denied = true;
      }
    }
  }
  if (is_denied == false) {
    std::cout << "APPROVED\n";
  } else {
    std::cout << "DENIED\n";
  }
}


Measured memory_bytes: 888
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        sc.close();

        long l = 0;
        long d = 100;
        while (true) {
            d = (long) (d * 1.01);
            l++;
            if (d >= x) {
                break;
            }
        } 
        System.out.println(l);
    }
}


Measured memory_bytes: 27008
#include<bits/stdc++.h>
using namespace std;
#define bye return 0
#define Yes cout << "Yes" << "\n"
#define No  cout << "No" << "\n"
#define YES cout << "YES" << "\n"
#define NO cout << "NO" << "\n"
//#define push push_back
//#define endl cout << "\n"
typedef long long ll;

int main(){ 
	int a, b, c, k;
	cin >> a >> b >> c >> k;
    for(int i=0; i<k; ++i){
        if(a>b) b=b*2;
    	else if(b>c) c=c*2;
    	else if(a==b) b=b*2;
    	else if(b==c) c=c*2;

    }
    if(a<b && b<c && a<c) Yes;
    else No;
   bye;
}
 

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	int A,B;
	cin>>A>>B;
	cout<<max({A+B,A-B,A*B})<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T = int> void print(vector<T> v){for(auto a:v)cout<<a<<" ";cout<<endl;}

/*
最長距離の最小化
x秒でk枚以上焼けるか？
*/

double eps=1e-8;
ll n,k;
double x[61],y[61],c[61];

pair<pair<double,double>,pair<double,double>> kouten(pair<double,double> p1, pair<double,double> p2, double r1, double r2){
	double x1=p1.first, y1=p1.second, x2=p2.first, y2=p2.second;
	if(pow(x1-x2,2)+pow(y1-y2,2)>pow(r1+r2,2))return {{1e9,1e9},{1e9,1e9}};
	if(pow(x1-x2,2)+pow(y1-y2,2)<pow(r1-r2,2))return {{1e9,1e9},{1e9,1e9}};
	// if(x1==x2 && y1==y2)return {{1e9,1e9},{1e9,1e9}};
	if(abs(y1-y2)<eps){
		double x = (x2*x2-x1*x1+r1*r1-r2*r2)/2/(x2-x1);
		double a = sqrt(r1*r1-pow(x-x1,2));
		return {{x,y1+a},{x,y1-a}};
	}
	double a=-(x2-x1)/(y2-y1), b=(r1*r1-r2*r2-(x1*x1-x2*x2)-(y1*y1-y2*y2))/2/(y2-y1);
	double A=a*a+1, B=-x1+a*(b-y1), C=x1*x1+(b-y1)*(b-y1)-r1*r1;
	double X1 = (-B+sqrt(B*B-A*C))/A, X2 = (-B-sqrt(B*B-A*C))/A;
	double Y1 = a*X1+b, Y2 = a*X2+b;
	return {{X1,Y1},{X2,Y2}};
}

bool f(double t){
	int sum=0;
	rep(i,n){
		rep(j,i){
			auto p = kouten({x[i],y[i]},{x[j],y[j]},t/c[i],t/c[j]);
			double x1=p.first.first, y1=p.first.second, x2=p.second.first, y2=p.second.second;
			// printf("%d,%d = (%lf,%lf,%lf),(%lf,%lf,%lf)\n",i,j,x[i],y[i],t/c[i],x[j],y[j],t/c[j]);
			// printf("(%lf,%lf),(%lf,%lf)\n",i,j,x1,y1,x2,y2);
			if(x1!=1e9 && y1!=1e9){
				sum=0;
				rep(l,n)if(pow(x1-x[l],2)+pow(y1-y[l],2)<=pow(t/c[l],2)+eps)sum++;
				// cerr<<"1:"<<sum<<endl;
				if(sum>=k)return true;
				sum=0;
				rep(l,n)if(pow(x2-x[l],2)+pow(y2-y[l],2)<=pow(t/c[l],2)+eps)sum++;
				// cerr<<"2:"<<sum<<endl;
				if(sum>=k)return true;
			}
		}
	}
	rep(i,n){
		sum=0;
		rep(l,n)if(pow(x[i]-x[l],2)+pow(y[i]-y[l],2)<=pow(t/c[l],2)+eps)sum++;
		// cerr<<"3:"<<sum<<endl;
		if(sum>=k)return true;
	}
	return false;
}

void init(){
	cin>>n>>k;
	rep(i,n)cin>>x[i]>>y[i]>>c[i];
}

int main(void){
	init();
	double l=0,r=100*4000;
	while(r-l>eps){
		double mid=(r+l)/2;
		if(f(mid)){
			r=mid;
		}else{
			l=mid;
		}
	}
	cout<<fixed<<setprecision(15)<<r<<endl;
	return 0;
}

Measured memory_bytes: 256
N, M = gets.split.map(&:to_i)
ans =
  if N == 1
    if M == 1
      # N == 1, M == 1
      1
    else
      # N == 1, M > 1
      M - 2
    end
  elsif M == 1
    # N > 1, M == 1
    N - 2
  else
    # N > 1, M > 1
    (N - 2) * (M - 2)
  end
puts ans


Measured memory_bytes: 1788
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include<cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include<iostream>
#include<list>
#include<queue>
#include<set>
#include<string>
#include <vector>

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

using namespace std;

int main(){
	list<int> li, tmp;
	int n, x;
	string com;

	scanf("%d", &n);
	REP(i, n){
		cin >> com;
	
		if (com == "deleteFirst"){
			li.pop_front();
		}
		else if (com == "deleteLast"){
			li.pop_back();
		}
		else if (com == "delete"){
			cin >> x;
			int k = 0;
			for (auto itr = li.begin(); itr != li.end();) {
				if (*itr == x && k == 0){
					itr = li.erase(itr);
					k = 1;
				}
				else{
					++itr;
				}
			}
		}
		else if (com == "insert"){
			cin >> x;
			li.push_front(x);
		}
	}
	int l = li.size();
	REP(i, l-1){
		cout << li.front() << " ";
		li.pop_front();
	}
	cout << li.front() << endl;

	return 0;
}


Measured memory_bytes: 34464
import sys

input = sys.stdin.readline

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def main():
    N, M = [int(x) for x in input().split()]
    P = [int(x) for x in input().split()]
    u = UnionFind(N)
    for _ in range(M):
        x, y = [int(x) for x in input().split()]
        u.union(x - 1, y - 1)

    ans = 0
    for i, p in enumerate(P):
        if u.same(p - 1, i):
            ans += 1

    print(ans)






if __name__ == '__main__':
    main()


Measured memory_bytes: 13876
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<LL> VI;
typedef vector<VI> VVI;
typedef pair<LL, LL> PII;
typedef vector<string> VS;
inline LL toInt(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(x,c) for(auto x: (c))
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define ALL(c) (c).begin(), (c).end()
#define REVERSE(c) reverse(ALL(c))
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define STABLE_SORT(c) stable_sort(ALL(c))
#define STABLE_RSORT(c) stable_sort((c).rbegin(),(c).rend())
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)), (c).end());
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
const double INF = 1e7;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define dump(x)  cerr << #x << " = " << (x) << endl;


int main() {
	char b;
	cin >> b;
	if (b == 'A') {
		b = 'T';
	} else if (b == 'C') {
		b = 'G';
	} else if (b == 'G') {
		b = 'C';
	} else {
		b = 'A';
	}
	cout << b << endl;
	
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main () {
	int n, a[10000];
	int counter = 0;

	scanf ("%d", &n);
	
	for (int i=0; i<n; i++) {
		scanf ("%d", a+i);
		while (!(a[i]%2)) {
			counter ++;
			a[i] /= 2;
		}
	}

	printf ("%d\n", counter);
	return 0;
}


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

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

	int n;
	cin >> n;
	bool lucky = false;
	while (n) {
		if (n%10 == 7) lucky = true;
		n /= 10;
	}
	if (lucky) cout << "Yes\n";
	else cout << "No\n";
}

Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;

int main()
{
  cout << setprecision(6);
  cout << setiosflags(ios::scientific);
  cout.flags(ios::fixed);

  while(true){
    int res = 0;
    int a, b;
    string op;
    cin >> a >> op >> b;

    if(op=="?")
      break;
    else if(op=="+")
      res = a+b;
    else if(op=="-")
      res = a-b;
    else if(op=="*")
      res = a*b;
    else if(op=="/")
      res = a/b;

    cout << res << endl;
  }
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);

int main() {
    int n;
    ll k;
    cin >> n >> k;
    vector<ll> a(n);
    vector<ll> f(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> f[i];
    sort(a.begin(),a.end());
    sort(f.rbegin(),f.rend());
    ll l = -1, r = 1e12;
    while (l+1 < r) {
        ll c = (l+r)/2;
        ll s = 0;
        rep(i,n) {
            s += max(ll(0),a[i]-c/f[i]);
        }
        if (s <= k) r = c;
        else l = c;
    }
    cout << r << endl;
    return 0;
}

Measured memory_bytes: 6440
import numpy as np
import math
import sys
sys.setrecursionlimit(10000000)

def main():
    N = int(input())
    num = 0
    if 1 <= N and N <= 9:
        num = N
    elif 10 <= N and N <= 99:
        num = 9
    elif 100 <= N and N <= 999:
        num = N - 90
    elif 1000 <= N and N <= 9999:
        num = 909
    elif 10000 <= N and N <= 99999:
        num = N - 9090
    else:
        num = 90909
    print(num)


if __name__ == '__main__':
    main()

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

int root(ll a[],ll i){
    while(a[i]!=i){
        a[i] = a[a[i]];
        i = a[i];
    }
    return i;
}

void Union(ll a[], ll size[], ll x, ll y, ll n){
    ll root_x = root(a,x);
    ll root_y = root(a,y);
    if(root_x == root_y) return;
    if(size[root_x]<size[root_y]){
        a[root_x] = a[root_y];
        size[root_y]+=size[root_x];
    }
    else{
        a[root_y] = a[root_x];
        size[root_x]+=size[root_y];
    }
}

int main(){
    ll n,k;
    ll res = INT_MIN;
    cin >> n >> k;
    ll a[n+1];
    ll size[n+1];
    for(int i=1;i<=n;i++) {
        a[i]=i;
        size[i]=1;
    }
    set<pair<ll,ll>> s;
    for(int i=0;i<k;i++){
        ll x,y;
        cin >> x >> y;
        // Union(a,size,x,y,n);
        pair<ll,ll> temp;
        temp.first = y;
        temp.second = x;
        if(s.find(temp)==s.end())
            s.insert(make_pair(x,y));
    }
    set<pair<ll,ll>> :: iterator itr;
    // cout << endl << "--------------- " << endl;
    // for(itr=s.begin();itr!=s.end();++itr){
    //     cout << itr->first << " " << itr->second << endl;
    // }
    for(itr=s.begin();itr!=s.end();++itr){
        Union(a,size,itr->first,itr->second,n);
        // cout << "Array : " ;
        // for(int i=1;i<=n;i++) cout << a[i] << " ";
        // cout << endl;
        // cout << "Size : " ;
        // for(int i=1;i<=n;i++) cout << size[i] << " ";
        // cout << endl;
    }
    for(int i=1;i<=n;i++) res= max(res,size[i]);
    cout << res;
}

Measured memory_bytes: 19248
def main():
    m, d = map(int, input().split())
    ans = 0
    for i in range(4, m + 1):
        for j in range(22, d + 1):
            d1 = j % 10
            d10 = j // 10
            if d1 > 1 and d1 * d10 == i:
                ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,-1,0};
int dy[4]={1,0,0,-1};
long double eps = 1e-9;
long double pi = acos(-1);

// template<typename T> void add(T &a,T b){a=(a+b)%mod;}
// template<typename T> void sub(T &a,T b){a=(a+mod-b)%mod;}

//a^n (mod m)
ll mod;
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//mod mでの a の逆元を求める
ll modinv(ll a) {
    ll b = mod, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= mod; 
    if (u < 0) u += mod;
    return u;
}



signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);


    int p;
    cin>>p;
    mod = p;
    int a[p];
    int sum = 0;
    for(int i=0;i<p;i++){
        cin>>a[i];
        sum += a[i];
    }
    int b[p];
    b[0] = a[0];
    for(int i=p-1;i>=1;i--){
        b[i] = sum * modinv(p-1) % mod;
        sum = 0;
        for(int i=0;i<p;i++){
            a[i] *= i;
            a[i] %= mod;
            sum += a[i];
            sum %= mod;
        }
    }
    for(int i=0;i<p;i++)cout << b[i] << " ";
    cout << endl;

}

Measured memory_bytes: 384
/***
**   AUTHOR::ASHUTOSH MOUDGIL
***/


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

#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F first
#define S second
#define int long long
//#define ll long long
#define all(x) x.begin(),x.end()
#define rsort(x) sort(all(x)); reverse(all(x));
#define endl '\n'
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define vi vector<int>
#define vlli vector<long long>
#define pii pair<int,int>
#define mod 1000000007
#define LMAX 1e18
#define deb(x) cout<<#x<<" : "<<x<<endl;


void mymain(){
    int n;
    cin >> n;
    vector<pair<int,int>> arr(n);
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        arr[i].F=a;
        arr[i].S=i+1;
    }
    sort(all(arr));
    for(pii p : arr)
        cout << p.S<<" ";
    cout << endl;
}

signed main(){
IOS;
///freopen("input.txt", "r", stdin);
///freopen("output.txt", "w", stdout);
int t=1;
///cin>>t;

for(int tt=0;tt<t;tt++){
   ///cout << "Case #" << tt+1 <<": ";
   mymain();
   }
return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

ll dp[101][100001] = {};

int main()
{
  int n, k;
  cin >> n >> k;
  vector<ll> a(n + 1);
  FOR(i, 1, n + 1)
  {
    cin >> a[i];
  }
  if (k == 0)
  {
    cout << 1 << endl;
    return 0;
  }

  dp[0][0] = 1;

  ll cum[100001] = {};
  FOR(i, 1, n + 1)
  {

    cum[0] = dp[i - 1][0];
    FOR(j, 1, k + 1)
    {
      cum[j] = (cum[j - 1] + dp[i - 1][j]) % MOD;
    }
    REP(j, k + 1)
    {
      if (j - a[i] > 0)
        dp[i][j] = (cum[j] - cum[j - a[i] - 1] + MOD) % MOD;
      else
        dp[i][j] = cum[j];
    }
  }
  cout << dp[n][k] << endl;
}


Measured memory_bytes: 79104
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final int K = sc.nextInt();
			
			for(int i = 0; i < K; i++) {
				System.out.print("ACL");
			}
			System.out.println();
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}


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

int main() {
  ll a, b, k;
  cin >> a >> b >> k;
  ll x = min(a,k);
  a -= x;
  k -= x;
  b -= min(b,k);
  cout<<a<<" "<<b<<endl;
  return 0;
}

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

int n;
int a[100010];
int x;
int ans;

int main()
{
    cin>>n;
    for (int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for (int i=1;i<=n;i++) if (a[i]==i)
        {
            swap(a[i],a[i+1]);
            ans++;
        }
    cout<<ans<<endl;

}

Measured memory_bytes: 640
#include<stdio.h>
int main(void)
{

  int a, b, c, d;

  scanf("%d",&a);
  scanf("%d",&b);

  if(a>=1 && a<=100)
  {

    if(b>=1 && b<=100)
    {

      c = a * b;
      d = 2*a + 2*b;

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

    }
  }

  return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int N; cin>>N;
    vector<int> H(N+2,0);
    rep(n,1,N+1) cin>>H.at(n);
    H.at(H.size()-1)=INT_MAX;

    int maxAns=0,tmp=0;
    rep(n,1,N+2){
        if(H.at(n-1)>=H.at(n)) tmp++;
        else{
            maxAns=max(maxAns,tmp);
            tmp=0;
        }
    }

    cout<<maxAns<<endl;
}

Measured memory_bytes: 640