akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

ll T,N,A,B,C,D;
map<ll,ll> mp;
ll dfs(ll n){
    if(n == 0) return 0;
    if(n == 1) return D;
    ll res = 1e18+100;
    if(1e18/D >= n) res = n*D;
    //ll res = n*D + cost;
    if(mp.count(n)) return mp[n];
    ll r = n % 5;
    if(n >= 5){
        cmin(res, r*D+C+dfs(n/5));
    }
    if(r != 0){
        r = 5 - r;
        cmin(res, r*D+C+dfs(n/5 + 1));
    }
    r = n % 3;
    if(n >= 3){
        cmin(res, r*D+B+dfs(n/3));
    }
    if(r != 0){
        r = 3 - r;
        cmin(res, r*D+B+dfs(n/3 + 1));
    }
    r = n % 2;
    if(n >= 2){
        cmin(res, r*D+A+dfs(n/2));
    }
    if(r != 0){
        r = 2 - r;
        cmin(res, r*D+A+dfs(n/2 + 1));
    }
    mp[n] = res;
    return res;
}

int main(){
    cin >> T;
    vector<ll> ans(T);
    rep(i,T){
        cin >> N >> A >> B >> C >> D;
        mp.clear();
        ans[i] = dfs(N);
    }
    rep(i,T){
        cout << ll(ans[i]) << endl;
    }
}

Measured memory_bytes: 4356
using System;
using System.Collections.Generic;
class Program
{
    static void Main()
    {
        //入力の受け取り
        string[] s = Console.ReadLine().Split(' ');
        //計算
        Stack<int> st = new Stack<int>();
        for (int i = 0; i < s.Length; i++)
        {
            try
            {
                st.Push(int.Parse(s[i]));
            }
            catch
            {
                if (s[i] == "+")
                    st.Push(st.Pop() + st.Pop());
                else if (s[i] == "-")
                    st.Push(-st.Pop() + st.Pop());
                else
                    st.Push(st.Pop() * st.Pop());
            }
        }
        //解答の出力
        Console.WriteLine(st.Pop());
    }
}


Measured memory_bytes: 9956
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 1e3 + 5, M = 1e4 + 5;
const ll LINF = 1e18 + 5;
int h, n, a[N], b[N];
int dp[M];
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> h >> n;
 	for(int i=1; i<=n; i++)
 		cin >> a[i] >> b[i];
 	memset(dp, 0x3f, sizeof(dp));
 	dp[h] = 0;
 	for(int i=h; i>=0; i--)
 	{
 		for(int j=1; j<=n; j++)
 		{
 			int k = max(0, i-a[j]);
 			dp[k] = min(dp[k], dp[i]+b[j]);
 		}
 	}
 	cout << dp[0];
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int n, a, b;
int a1, a2;
int main()
{
    cin >> n >> a >> b;
    a1 = min(a, b);
    a2 = max((a + b) - n, 0);
    cout << a1 << " " << a2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
# define PI  3.14159265358979323846
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const int N = 2e6+5;
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int ar[N];
int dp[N];
signed main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		int n,a,b;
		cin>>n>>a>>b;
		int rem = (n%(a+b));
		int x = n/(a+b);
		cout << x*a + min(rem,a);
	
	
	}
	cerr << "Time Taken : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
	return 0;
}

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

int main() {
  long long X, A=100;
  int Y=0;
  cin >> X;
  while(A<X){
    A=A+A/100;
    Y++;
  }
  cout << Y << endl;
}

Measured memory_bytes: 3636
#
import sys
import math
import numpy as np
import itertools

# 文字列をリストに
s = list(input())

answer = 0
t = 0
u = 0
for i in range(len(s)):
    t = t*27 + (ord(s[i])-ord('a')+1)
    # different from -1
#    print(i,s[i],answer,u,t)

    if t != u:
        u = t
        t = 0
        answer += 1
        
print(answer)


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

using ll = long long;

struct edge {
   ll to, cost;
};

int main() {
   ll N, M;
   cin >> N >> M;
   vector<vector<edge>> G(N);
   // 入力
   for (int i = 0; i < M; i++) {
      int a, b, c;
      cin >> a >> b >> c;
      a--, b--;
      G[a].push_back(edge{b, c});
   }

   const ll INF = 1e18;
   vector<ll> dist(N, -INF);
   dist[0] = 0;
   // ベルマンフォード法
   for (int k = 0; k < 4*N; k++) {
      for (int i = 0; i < N; i++) {
         if (dist[i] == -INF) continue;
         for (edge e : G[i]) {
            dist[e.to] = max(dist[e.to], dist[i] + e.cost);
         }
      }
   }
   ll ans1 = dist[N-1];

   // もう一度ベルマンフォード法
   for (int k = 0; k < 4*N; k++) {
      for (int i = 0; i < N; i++) {
         if (dist[i] == -INF) continue;
         for (edge e : G[i]) {
            dist[e.to] = max(dist[e.to], dist[i] + e.cost);
         }
      }
   }
   ll ans2 = dist[N-1];

   // 2つの答えが違えば負の閉路が存在するため"inf"となる
   if (ans1 != ans2) {
      puts("inf");
   } else {
      cout << ans1 << endl;
   }

   return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>


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

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

int main(void)
{
    cin.sync_with_stdio(false);
    char c;
    cin >> c;
    cout << char(c + 1) << endl;

    return 0;
}


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

using namespace std;

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

int xs[110];
       
int main(void) {
  int n, k;
  scanf("%d%d", &n, &k);
  int res = 0;
  REP(i, n) {
    scanf("%d", &xs[i]);
    res += min(xs[i], abs(k-xs[i]));
  }
  
  printf("%d\n", res*2);
  return 0;
}


Measured memory_bytes: 128
import java.util.*;

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

        int N = sc.nextInt();
        int K = sc.nextInt();
        
        int ans = ( (N-1) + (K-1) - 1 ) / (K - 1);

        System.out.println(ans);
    }
}

Measured memory_bytes: 21716
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);

int main() {
  int n, m; cin >> n >> m;
  int ans = 0;
  vi imos(n+1, 0);
  rep(i, m) {
    int l, r; cin >> l >> r;
    l--;
    imos[l]++;
    imos[r]--;
  }
  rep(i, n) {
    imos[i+1] += imos[i];
    // cout << imos[i] << " \n"[i==n-1];
    if (imos[i] == m) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
using ll = long long int;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int n;
	cin >> n;
	ll a[2001] = {0,};
	a[3] = a[4] = a[5] = 1;
	for (int i = 4; i <= n; i++) {
		a[i] = (a[i - 1] + a[i - 3]) % MOD;
	}
	cout << a[n] << '\n';

	return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const ll INF = 1e9;
const long long INFL = 1LL<<60;

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i, n) {
    cin >> d[i];
  }

  ll ans = 0;
  rep (i, n-1) {
    for (int j = i+1; j < n; j++) {
      ans += d[i] * d[j];
    }
  }

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


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

int main() {
  int a, b;
  cin >> a >> b;
  
  int x = a * b % 2;
  
  if (x != 1) {
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;
  }
  
}


Measured memory_bytes: 3608
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var a = cin.ReadInt;
            var b = cin.ReadInt;
            if (a < b)
            {
                for(int i = 1; i <= b; i++)
                {
                    Console.Write($"{a}");
                }
                
            }
            else
            {
                for (int i = 1; i <= a; i++)
                {
                    Console.Write($"{b}");
                }
            }
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

Measured memory_bytes: 13396
#define	_USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <set>
#include <complex>
#include <utility>
#include <numeric>
#define  rep(i,n) for(int i=0;i<(n);i++)
#define  REP(i,a,n) for(int i=a;i<(n);i++)
#define  rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define  VI	vector<int>
#define	 VS vector<string>
#define  all(a) (a).begin(),(a).end()
#define  debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
typedef long long ll;

const int INF=1000000;
char fi[101][101];
int d[21][21];
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
double EPS = 1e-10;
int N,M;
int sx,sy;
int gx,gy;
int w,h;
int ans;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
const int MAX_V=100;
const int MAX_N=100;
char o[3]={'+','-','*'};
#define md 1000003


int dp[353][353]={0};
int bow[353][353]={0};
double add(double a,double b){
	if(abs(a+b)<EPS*(abs(a)+abs(b)))
	return 0;
	return a+b;
}

struct P{
	double x,y;
	P(){}
		P(double x,double y):x(x),y(y){
		}
		P operator + (P p){
			return P(add(x,p.x),add(y,p.y));
		}
		P operator - (P p){
			return P(add(x,-p.x),add(y,-p.y));
		}
		P operator *(double d){
			return P(x*d,y*d);
		}
		double dot(P p){
			return add(x*p.x,y*p.y);
		}
		double det(P p){
			return add(x*p.y,-y*p.x);
		}
};

bool cmp_x(const P& p,const P& q){
	if(p.x!=q.x) return p.x<q.x;
	return p.y<q.y;
}

vector<P> convex_hull(P* ps, int n){
	sort(ps,ps+n,cmp_x);
	int k=0;
	vector<P> 	qs(n*2);
	
	rep(i,n){
		while(k>1&&(qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1])<=0)
			k--;
		qs[k++]=ps[i];
	}
	for(int i=n-2,t=k;i>=0;i--){
		while(k>t&&(qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1])<=0)
		k--;
		qs[k++]=ps[i];
	}
	qs.resize(k-1);
	return qs;
}

int n;
P ps[101];

int main(){
	
	int n;
	while(cin>>n,n!=0){
		ll ans=1000000;
	for(int i=0;i<=50;i++){
		for(int j=0;j<=50;j++){
			for(int k=0;k<=50;k++){
				ll cho=380*((i/5)*5)*0.8+380*(i%5);
				cho+=550*((j/4)*4)*0.85+550*(j%4);
				cho+=850*((k/3)*3)*0.88+850*(k%3);
				if(i*200+j*300+k*500==n)
					ans=min(ans,cho);
			}
		}
	}
		cout<<ans<<endl;
	}

	
}

Measured memory_bytes: 1160
class PriorityQueue
  def initialize(array = [])
    @data = []
    array.each{|a| push(a)}
  end

  def push(element)
    @data.push(element)
    bottom_up
  end

  def pop
    if size == 0
      return nil
    elsif size == 1
      return @data.pop
    else
      min = @data[0]
      @data[0] = @data.pop
      top_down
      return min
    end
  end

  private

  def swap(i, j)
    @data[i], @data[j] = @data[j], @data[i]
  end

  def size
    @data.size
  end

  def parent_idx(target_idx)
    (target_idx - (target_idx.even? ? 2 : 1)) / 2
  end

  def bottom_up
    target_idx = size - 1
    return if target_idx == 0
    parent_idx = parent_idx(target_idx)
    while (@data[parent_idx][1] > @data[target_idx][1])
      swap(parent_idx, target_idx)
      target_idx = parent_idx
      break if target_idx == 0
      parent_idx = parent_idx(target_idx)
    end
  end

  def top_down
    target_idx = 0

    # child がある場合
    while (has_child?(target_idx))

      a = left_child_idx(target_idx)
      b = right_child_idx(target_idx)

      if @data[b].nil?
        c = a
      else
        c = @data[a][1] <= @data[b][1] ? a : b
      end

      if @data[target_idx][1] > @data[c][1]
        swap(target_idx, c)
        target_idx = c
      else
        return
      end
    end
  end

  # @param Integer
  # @return Integer
  def left_child_idx(idx)
    (idx * 2) + 1
  end

  # @param Integer
  # @return Integer
  def right_child_idx(idx)
    (idx * 2) + 2
  end

  # @param Integer
  # @return Boolent
  def has_child?(idx)
    ((idx * 2) + 1) < @data.size
  end
end

def sssp ls, n
  colors = Array.new(n){1} # 1:white, 2:gray, 3:black
  ds = Array.new(n){Float::INFINITY}
  ds[0] = 0
  # pq = PQueue.new([[0, 0]]){|a, b| a[1] < b[1]}
  pq = PriorityQueue.new([[0, 0]])
  cnt = 0

#  while true do
  while cnt < n
#    break if pq.length == 0
    i, cost = pq.pop
    next if colors[i] == 3
    colors[i] = 3
    cnt += 1

    k, *paths = ls[i]
    k.times do |kk|
      c_i = paths[kk * 2]
      if colors[c_i] != 3
        c  = paths[kk * 2 + 1]
        new_cost = c + cost
        if new_cost < ds[c_i]
          ds[c_i] = new_cost
          pq.push([c_i, new_cost])
        end
        colors[c_i] = 2
      end
    end
  end

  ds
end

n = gets.chomp.to_i
ls = Array.new(n)
n.times do |nn|
  _, i, *paths = gets.split(' ').map(&:to_i)
  ls[nn] = ([i] + paths)
end
costs = sssp(ls, n)
costs.each_with_index do |cost, i|
  puts "#{i} #{cost}"
end


Measured memory_bytes: 21144
n,k=map(int,input().split())
a=[0 for i in range(n)]
for _ in range(k):
    _=int(input())
    tmp=list(map(int,input().split()))
    for i in tmp:
        a[i-1]+=1
ans=0
for x in a:
    if x==0: ans+=1
print(ans)

Measured memory_bytes: 67640
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cassert>
#define MOD 1000000007
#define ll long long
using namespace std;
inline ll read(){
	ll re=0,flag=1;char ch=getchar();
	while(ch>'9'||ch<'0'){
		if(ch=='-') flag=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') re=(re<<1)+(re<<3)+ch-'0',ch=getchar();
	return re*flag;
}
ll n,m,k,first[110],cnte=1,dfn[110],low[110],clk,ans=1;
struct edge{
	ll from,to,next,vis;
}a[210];
ll sta[210];ll top;
inline void add(ll u,ll v){
	a[++cnte]=(edge){v,u,first[v],0};first[v]=cnte;
	a[++cnte]=(edge){u,v,first[u],0};first[u]=cnte;
}
ll vis[210],mi[210];
ll gcd(ll l,ll r){
	if(r==0) return l;
	else return gcd(r,l%r);
}
ll qpow(ll a,ll b){
	ll re=1;
	while(b){
		if(b&1) re=re*a%MOD;
		a=a*a%MOD;b>>=1;
	}
	return re;
}
ll f[210],finv[210];
void init(){
	ll i;
	mi[0]=f[1]=f[0]=finv[1]=finv[0]=1;
	for(i=1;i<=200;i++) mi[i]=mi[i-1]*k%MOD;
	for(i=2;i<=200;i++) f[i]=f[i-1]*i%MOD;
	finv[200]=qpow(f[200],MOD-2);
	for(i=200;i>2;i--) finv[i-1]=finv[i]*i%MOD;
}
void tarjan(ll u){
//	cout<<"tarjan "<<u<<'\n';
	dfn[u]=low[u]=++clk;
	ll i,v,j;
	for(i=first[u];~i;i=a[i].next){
		if(a[i].vis||a[i^1].vis) continue;
		sta[++top]=i;v=a[i].to;a[i].vis=a[i^1].vis=1;
		if(!dfn[v]){
			tarjan(v);
			low[u]=min(low[u],low[v]);
			if(low[v]>=dfn[u]){
//				cout<<"	find bcc "<<u<<' '<<v<<' '<<i<<' '<<sta[top]<<'\n';
				bool cir=1;ll cnt=0;ll val=0;
				for(j=top;sta[j+1]!=i;cnt++,j--){
					if(vis[a[sta[j]].to]) cir=0;
					else vis[a[sta[j]].to]=1;
				}
				if(cir){
					for(j=1;j<=cnt;j++) val=(val+mi[gcd(cnt,j)])%MOD;
					val=val*qpow(cnt,MOD-2)%MOD;
				}
				else val=f[cnt+k-1]*finv[cnt]%MOD*finv[k-1]%MOD;
				ans=ans*val%MOD;
//				cout<<"	finish calc bcc "<<v<<' '<<val<<' '<<ans<<' '<<cnt<<' '<<cir<<'\n';
				while(sta[top+1]!=i) vis[a[sta[top]].to]=0,top--;
			} 
		}
		else low[u]=min(low[u],dfn[v]);
	}
}
int main(){
	memset(first,-1,sizeof(first));
	n=read();m=read();k=read();ll i,t1,t2;
	init();
	for(i=1;i<=m;i++){
		t1=read();t2=read();
		add(t1,t2);
	}
	for(i=1;i<=n;i++) if(!dfn[i]) tarjan(i);
	printf("%lld\n",ans);
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main{

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
		int[] arg =new int[100];
        int i=0,sum=0;
        int[] k=new int[6];
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            while ((line = br.readLine()) != null) {
                k[0]=Integer.parseInt(line);
                k[1]=Integer.parseInt(br.readLine());
                k[2]=Integer.parseInt(br.readLine());
                k[3]=Integer.parseInt(br.readLine());
                k[4]=Integer.parseInt(br.readLine());
                k[5]=Integer.parseInt(br.readLine());
                int min1=Integer.min(Integer.min(k[0],k[1]),Integer.min(k[2],k[3]));
                boolean end=false;
                for(i=0;i<4;i++){
                	if(k[i]==min1&&!end){
                		end=true;
                	}else{
                		sum+=k[i];
                	}
                }
                sum+=Integer.max(k[4],k[5]);
                System.out.println(sum);
                break;
            }
        }
	}

}

Measured memory_bytes: 24176
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
using namespace std;
int main(void){
    int N,M,C;
    cin >> N >> M >>C;
    int B[M],A[N][M];
    for(int i=0;i<M;i++){
        cin >> B[i];
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<M;j++){
            cin >> A[i][j];
        }
    }
    int ans = 0;
    for(int i=0;i<N;i++){
        int sum = 0;
        for(int j=0;j<M;j++){
            sum += B[j]*A[i][j];
        }
        if(sum + C > 0){
            ans++;
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
ll powmod(ll n, ll k, ll m) {
ll r=1;
 for(; k>0; k >>=1) {
   if(k&1) r=(r*n)%m;
   n=(n*n)%m;
 }
  return r;
}

ll fact(ll n) {
ll a=1;
rep(i,n) {
a=a*(n-i);
}
return a;
}

ll pow(ll a, ll b) {
ll x=1;
rep(i,b) {
x=x*a;
}
return x;
}



int main() {
int X;
  cin >>X;
  
  ll a=__gcd(X,360);
  cout<<360/a<<endl;
}

Measured memory_bytes: 3600
#include<iostream>
#include<vector>
#include<string>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(var,init,end) for(int var=init;var<end;var++)
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

int sum_digit(int a) {
	int ret = 0;
	while (a > 0)
	{
		ret += a % 10;
		a /= 10;
	}

	return ret;
}

int main() {
	int n,a,b;
	int cnt;
	cin >> n;

	int var = 1;
	int i = 0;
	for (; var < n; var *= 10,i++);
	if (n <= 10) {
		cout << n;
	}
	else {
		a = n - var/10;
		a = sum_digit(a);
		cnt = a + 1;

		cout << cnt;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <map>
#include <math.h>
#include <vector>
using namespace std;
map<int, int> ct;
map<int, int> ct2;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vll;
#define INF 0x3f3f3f3f
#define MOD 998244353LL
#define EPS 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair

#define FOR(i, a, b) for (int i=(a); i<=(signed)(b); i++)
#define AFOR(i, a) for (int i=0; i<(signed)(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)

#define MN 100005
int n, m, l;
int a, b, c;
string s[MN];
string str;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

/*
int N;
cin >> N;
vi vect(N);
FOR(i,N) cin >> vec.at(i);*/
//sort(vec.begin(),vec.end());
//vvi data(N,vi(4));


/*	int bfs(int x, int y,vvi &A,vvi flag) {
		queue<pii> que;
		que.push(pii(x, y));
		while (que.size()) {
			pii p = que.front(); que.pop();
			AFOR(i, 4) {
				int nx = p.first + dx[i]; int ny = p.second + dy[i];
				if (0 <= nx && nx < N && 0 <= ny && ny < N) {
					if (A.at(p.first).at(p.second) + flag.at(p.first).at(p.second) < A.at(nx).at(ny)) {
						A.at(nx).at(ny) = A.at(p.first).at(p.second) + flag.at(p.first).at(p.second);
						que.push(pii(nx, ny));
					}
				}
			}
		}
		return 0;
	}
	*/
	/*int gcd(int p, int q){
		while(q != 0){
		int r = p % q;
		p = q;
		q = r;
		}
	return p;
	}*/
ll N;
ll K;
int A[200100];
ll  L[200100];
ll ans = 0;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> N ;
	AFOR(i, N) {
		cin >> A[i];
		L[i] = 0;
	}
	AFOR(i, N) {
		L[A[i]-1]++;
	}
	AFOR(i, N) {
		ans += (L[i] * (L[i] - 1)) / 2;
		}
	AFOR(i,N){
		cout << ans-L[A[i]-1]+1 << endl;
	}

	return 0;
}

Measured memory_bytes: 5760
#include <stdio.h>

int main() {
  int a, b;
  scanf("%d %d", &a, &b);
  if (a + b == 15) {
    printf("+\n");
  } else if (a * b == 15) {
    printf("*\n");
  } else {
    printf("x\n");
  }
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
using R = double;
using Data = pair < ll, vector <ll>>;
const ll MOD = 1e9 + 7;
const ll inf = 1LL << 60;
struct edge { ll from; ll to; ll cost; };
typedef pair<ll, ll>pll;
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)
#define INF INT_MAX/2


int main(){
	int n, m;
	cin >> n >> m;
	vector<int>P(m), Y(m);
	rep(i, 0, m)cin >> P[i] >> Y[i], P[i]--;

	vector<vector<int>>vals(n);
	rep(i, 0, m)vals[P[i]].pb(Y[i]);

	rep(i, 0, n) {
		sort(all(vals[i]));
		vals[i].erase(unique(all(vals[i])),vals[i].end());
	}

	rep(i, 0, m) {
		int v = P[i];
		printf("%06d",v+1);
		int id = lower_bound(all(vals[v]),Y[i])-vals[v].begin();
		printf("%06d\n",id+1);
	}
	

	return 0;
}


Measured memory_bytes: 7808
#include<iostream>
#include<algorithm>
#include<fstream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<string>
#include<cctype>
#include<cmath>
#include<vector>
#include<climits>
#include<queue>

using namespace std;


int main()
{
    int i,ans,mask,d,g;
    int p[11],c[11];
    scanf("%d%d",&d,&g);
    for(i=0; i<d; ++i)
        scanf("%d%d",&p[i],&c[i]);
    ans=1e9;
    for(mask=0; mask < (1 << d); ++mask)
    {
        int s=0,num=0,rest_max=-1;
        for(i=0; i<d; ++i)
        {
            if(mask >> i &1)
            {
                s+=100*(i+1)*p[i]+c[i];
                num+=p[i];
            }
            else
            {
                rest_max=i;
            }
        }
        if(s<g)
        {
            int s1=100*(rest_max+1);
            int need=(g-s+s1-1)/s1;
            if(need>=p[rest_max])
                continue;
            num+=need;
        }
        ans=min(ans,num);
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;
const ll mod = 1e9+7;
const ll mod1 = 998244353;
#define rep(i,a,b) for(ll i=a;i<b;i++)

void swap(ll &a , ll &b){
    ll t = a;
    a = b;
    b = t;
}

ll min(ll a, ll b){
    if(a<b)return a;
    return b;
}

ll max(ll a, ll b){
    if(a>b)return a;
    return b;
}

 ll pow(ll a, ll b) {
    a %= mod;
    ll ans = 1;
    while (b > 0) {
        if (b & 1)
            ans = ans * a % mod;
        a = a * a % mod;
        b /= 2;
    }
    return ans;
 }

 int n;
 int visited[102] = {0};
int x[102], y[102];

void dfs(int i)
{
    visited[i] = 1;
    for(int j=0; j<n; j++)
    {
        if(x[j] == x[i] || y[j]==y[i] )
        {
            if(visited[j] == 0)
            {
                dfs(j);
            }
        }
    }
}

int main(){

   ios_base :: sync_with_stdio(0);
   cin.tie(0);

   ll x;
   cin>>x;

   ll p =100;
   ll y = 0;
   while(p<x)
   {
       y++;
       p += 0.01 * p;
   }

   cout<<y<<endl;
    return 0;

}


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

int main() {
long long n,k,s;
cin >> n >> k >> s;
for(int i=0;i<k;i++){
    cout << s << " ";
}
if(s==pow(10,9)){for(long long i=0;i<n-k;i++){
    cout << "1" << " ";
}}
else {for(long long i=0;i<n-k;i++){
    cout << s+1 << " ";
}}
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a;
string s;
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> a;
	cin >> s;
	if (a >= 3200){
		cout << s;
		}else {
		cout << "red";
    }

}


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

#define endl '\n'

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5])   
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<fstream>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;

int n,m;
int w[510][510];
int inFlag;
void init()
{
    scanf("%d %d",&n,&m);
    for (int i=0; i<n; ++i)
        for (int j=0; j<m; ++j)
            scanf("%d",&w[i][j]);
}

struct T
{
    int i,j,k,l;
}ot[500*500*2];
int len=0;
void calNext(int i,int j,int &k,int &l)
{
    if ((i%2==0) && (j<m-1))
    {
        k=i; l=j+1;
    }
    if ((i%2==0) && (j==m-1))
    {
        k=i+1; l=j;
    }
    if ((i%2==1) && (j!=0))
    {
        k=i; l=j-1;
    }
    if ((i%2==1) && (j==0))
    {
        k=i+1; l=j;
    }
}
void work()
{
    for (int i=0; i<n; ++i)
    {
        int Begin=(i%2)?m-1:0;
        int End=(i%2)?-1:m;
        int Itr=(i%2)?-1:1;
        for (int j=Begin; j!=End; j+=Itr)
        {
            if (w[i][j]%2)
            {
                int k,l;
                calNext(i,j,k,l);
                w[i][j]--; w[k][l]++;
                if (k<n){ot[len].i=i; ot[len].j=j;ot[len].k=k;ot[len].l=l;len++;}
            }
        }
    }
    cout<<len<<endl;
    for (int i=0; i<len; ++i)
        printf("%d %d %d %d\n",ot[i].i+1,ot[i].j+1,ot[i].k+1,ot[i].l+1);
}
int main()
{
    init();
    work();
    return 0;
}



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

int main(){
  string a,b,c;
  int A,B;
  cin>>a>>b>>A>>B>>c;
  if(c==a){
    A--;
  }
  else{
    B--;
  }
  cout<<A<<" "<<B;
  return 0;
}

Measured memory_bytes: 256
//package AtCoder;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] a=new int[n];
		boolean f=true;
		for(int i=0;i<n;i++)
		{
			a[i]=sc.nextInt();
			if(a[i]%2==0)
			{
				if(a[i]%3!=0 && a[i]%5!=0)
					f=false;
			}
		}
		if(f)
			System.out.println("APPROVED");
		else
			System.out.println("DENIED");
		

	}

}


Measured memory_bytes: 22740
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}
void pakuri_sort(int N, int A[]) {
	const int b = 8;
	int tmp[100001];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

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


	int X = getint(), Y = getint(), A = getint(), B = getint(), C = getint();

	int a[100000], b[100000], c[100000];
	rep(i, A) a[i] = getint();
	rep(i, B) b[i] = getint();
	rep(i, C) c[i] = getint();

	pakuri_sort(A, a);
	pakuri_sort(B, b);
	pakuri_sort(C, c);

	ll tmp = 0;
	for (int i = A - X; i < A; i++) tmp += a[i];
	for (int i = B - Y; i < B; i++) tmp += b[i];
	int aa = A - X;
	int bb = B - Y;
	ll kotae = tmp;
	int cm = C - min(C, X + Y);
	for (int i = C - 1; i >= cm; i--) {
		tmp += c[i];
		if (aa == A) tmp -= b[bb++];
		else if (bb == B) tmp -= a[aa++];
		else if (a[aa] < b[bb]) tmp -= a[aa++];
		else tmp -= b[bb++];

		chmax(kotae, tmp);
	}
	printf("%lld", kotae);

	Would you please return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void){
  char s[200];
  int sent_len=0, i, count;
  scanf("%s", s);
  while(s[sent_len] != '\0')++sent_len;
  while(1){
    sent_len -= 2;
    count = 0;
    for(i=0; i<sent_len/2; ++i){
      if(s[i] != s[sent_len/2+i]) break;
      count += 1;
    }
    if(count == sent_len/2) break;
  }
  printf("%d\n", sent_len);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int maxn=200005;
int a[maxn];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	  cin>>a[i];
	int cnt=0;
	for(int i=n;i>=1;i--)
	{
		for(int j=i+i;j<=n;j+=i)
		{
			a[i]^=a[j];
		}
		if(a[i])
		  cnt++;
	}
	cout<<cnt<<endl;
	for(int i=1;i<=n;i++)
	{
	  if(a[i])
	  {
	  	cout<<i<<" ";
	  }
	}
	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		int s=1000;

		while(s<n) {
			s += 1000;
		}

		System.out.println(s-n);

		sc.close();

	}

}


Measured memory_bytes: 35816
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n = I()
    a = LI()
    u = [0]*n
    r = 1
    for l in range(n):
        if l == r:
            r += 1
        while r < n and a[r-1] <= a[r]:
            r += 1
        u[l] = r
    d = [0]*n
    r = 1
    for l in range(n):
        if l == r:
            r += 1
        while r < n and a[r-1] >= a[r]:
            r += 1
        d[l] = r
    i = 0
    for t in range(n):
        i = max(u[i],d[i])
        if i == n:
            print(t+1)
            return
    return
#B
def B():
    n,m = LI()
    v = [[] for i in range(n)]
    for i in range(m):
        a,b = LI()
        a -= 1
        b -= 1
        v[a].append(b)
        v[b].append(a)
    f = [1]*n
    p = deque([0])
    f[0] = 0
    update = 1
    while update:
        update = 0
        x = p[0]
        for y in v[x]:
            if f[y]:
                update = 1
                f[y] = 0
                p.appendleft(y)
                break
        x = p[-1]
        for y in v[x]:
            if f[y]:
                update = 1
                f[y] = 0
                p.append(y)
                break
    p = list(p)
    for i in range(len(p)):
        p[i] += 1
    print(len(p))
    print(*p)
    return

#C
def C():

    return

#D
def D():

    return

#E
def E():

    return

#F
def F():

    return

#Solve
if __name__ == "__main__":
    B()


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

int main(){
  int n,a;cin>>n;
  set<int>s;
  rep(i,n){
    cin>>a;
    if(s.count(a))s.erase(a);
    else s.insert(a);
  }
  cout<<s.size()<<endl;
}

Measured memory_bytes: 4864
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstdint>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <cstdlib>
#include <sstream>

#include <boost/range/irange.hpp>
using boost::irange;

#include <boost/utility/string_ref.hpp>
using boost::string_ref;

using namespace std;

template<class T, size_t N, class F>
struct compare_n
{
    F f;
    bool operator() (const T& t1, const T& t2)
    {
        return f(get<N>(t1), get<N>(t2));
    }
};
 
template<size_t N, class T>
auto make_less_n(const T&)
{
    using t = typename T::value_type;
    using less = std::less<typename tuple_element<N, t>::type>;
    return compare_n<t, N, less>();
}

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

    size_t n,k;
    cin >> n >> k;
    
    unordered_map<int, int> counts;
    for(size_t i = 0; i < n; ++i)
    {
        int ai; cin >> ai;
        ++counts[ai];
    }
    
    if(counts.size() <= k)
    {
        cout << "0\n";
        return 0;
    }
    
    if(counts.size() + 1 == k)
    {
        cout << min_element(begin(counts), end(counts), make_less_n<1>(counts))->second << '\n';
        return 0;
    }
    
    vector<pair<int, int>> invert_counts;
    invert_counts.reserve(counts.size());
    for(auto& p : counts)
    {
        invert_counts.emplace_back(p.second, p.first);
    }
    
    sort(begin(invert_counts), end(invert_counts), make_less_n<0>(invert_counts));
    
    int count = 0;
    for(auto pi = begin(invert_counts); pi != next(begin(invert_counts), counts.size() - k); ++pi)
    {
        count += pi->first;
    }
    
    cout << count << '\n';

    return 0;
}



Measured memory_bytes: 10056
#include<string>
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<math.h>
#include<unordered_set>
#include<string.h>
#include<unordered_map>
#include<numeric>
#include<iomanip>
#include<string.h>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;

#define FOR(i,N) for(int i=0;i<N;i++)

ll mod=1e9+7;
double EPS=1e-8;



int main(){
    string s;
    cin>>s;
    string st;
    for(int i=0;i<s.length();i++){
        if(s[i]!='x'){
            st.push_back(s[i]);
        }
    }
    if(st.length()==0){
        cout<<0<<endl;
        return 0;
    }
    for(int i=0;i<st.length()/2;i++){
        if(st[i]!=st[st.length()-1-i]){
            cout<<"-1"<<endl;
            return 0;
        }
    }
    if(st==s){
        cout<<0<<endl;
        return 0;
    }
    int si;
    int sti=0;
    for(si=0;si<s.length();si++){
        if(s[si]==st[sti]){
            if(sti==(st.length()-1)/2)break;
            sti++;
        }
    }
  //  cout<<si<<endl;
    int sri=si;
    if(st.length()%2==0){
        sri++;
      //  cout<<si<<" "<<sri<<endl;
        while(sri<s.length()&&s[sri]=='x')sri++;
      //  cout<<si<<" "<<sri<<endl;
    }
    si--,sri++;
   // cout<<si<<" "<<sri<<endl;
    int ans=0;
    while(si>=0||sri<s.length()){
        int a=0,b=0;
        while(si>=0&&s[si]=='x'){
            a++;
            si--;
        }
        while(sri<s.length()&&s[sri]=='x'){
            b++;
            sri++;
        }
        ans+=abs(a-b);
      //  cout<<a<<" "<<b<<endl;
        si--,sri++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<bitset>
#define lson node<<1,st,mid
#define rson node<<1|1,mid+1,ed
#define mem(a,x) memset(a,x,sizeof(a))
#define me(a) memset(a,0,sizeof(a))
#define IOS ios::sync_with_stdio(false)
#define lowbit(x) x&(-x)
#define up(i,x,y) for(long long i=x;i<y;i++)
#define down(i,x,y) for(long long i=x;i>=y;i--)
#define in freopen("in.txt","r",stdin)
#define out freopen("out.txt","w",stdout)   
typedef long long ll;
const ll mod = 1e9+7;
const ll INF = 0x3f3f3f3f;
const ll maxn = 1e6+5;
const ll N = 1e3+5;
const double pi = acos(-1.0);
const double eps=1e-9;
using namespace std;
 
int main(){
    ll r;
    cin>>r;
    printf("%.20lf\n",2*r*pi);
}

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

#define N 100000

int main()
{
  int i, n, q, v, x, y, z, dx, dy, x0, y0, ex, rx, sx, tmp;
  char *p, buf[32];
  buf[31]=0;
  buf[30]='\n';
  int *s = (int*)malloc(sizeof(int)*N+1);
  int *d = (int*)malloc(sizeof(int)*N+1);
  while (fgets(buf, 32, stdin)) {
    for (n=0,p=buf; *p!=' '; n=n*10+*(p++)-'0'); 
    for (q=0,p++; *p!='\n'; q=q*10+*(p++)-'0'); 
    if (n==0 && q==0) break;
    for (i=1; i<=n; s[i]=i,d[i++]=0);
    for (int t=0; t<q; t++) {
      fgets(buf, 32, stdin);
      for (x=0,p=buf+2; *p!=' '; x=x*10+*(p++)-'0');
      for (y=0,p++; *p>='0'; y=y*10+*(p++)-'0');

      if (buf[0]=='!') { // relate x y z
	for (z=0,p++; *p!='\n'; z=z*10+*(p++)-'0');
	for (x0=x,dx=0; s[x]!=x; dx+=d[x], x=s[x]);
	for (y0=y,dy=0; s[y]!=y; dy+=d[y], y=s[y]);
	s[x0]=x;
	d[x0]=dx;
	s[y0]=y;
	d[y0]=dy;
	if (x<y) {
	  s[y] = x;
	  d[y] = z + dx - dy;
	} else if (x>y) {
	  s[x] = y;
	  d[x] = -z - dx + dy;
	} else continue;
	
      } else { // diff

	for (x0=x,dx=dy=0; s[x]!=x; dx+=d[x], x=s[x]);
	for (rx=x, x=x0, ex=dx; s[x]!=x; x=sx) {
	  sx=s[x];
	  s[x]=rx;
	  tmp=d[x];
	  d[x]=ex;
	  ex-=tmp;
	}
	for (y0=y; s[y]!=y; dy+=d[y], y=s[y]);
	v=-dx+dy;
	if (x!=y) {
	  fputs("UNKNOWN\n", stdout);
	} else {
	  i=30;
	  if (v>0)  for (; v>0; buf[--i]='0'+v%10,v/=10);
	  else if (v<0) {
	    for (; v<0; buf[--i]='0'-v%10,v/=10);
	    buf[--i] = '-';
	  } else  buf[--i] = '0';
	  fputs(buf+i, stdout);
	}
      }
    }
  }
  return 0;
}



Measured memory_bytes: 2304
# include <bits/stdc++.h>
using namespace std;
vector < pair < int, int > > ans;
int n;
int main(){
	cin >> n;
	for(int i = 1; i <= n; ++i){
		for(int j = i + 1; j <= n; ++j){
			if((n % 2 == 1 && i + j != n) || (n % 2 == 0 && i + j != n + 1)){
				ans.push_back({i, j});
			}
		}
	}
	cout << ans.size() << '\n';
	for(int i = 0; i < ans.size(); ++i){
		cout << ans[i].first << ' ' << ans[i].second << '\n';
	}
}


Measured memory_bytes: 384
#15:40
n,m = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
bc = []
for _ in range(m):
  bc.append(list(map(int,input().split())))
bc.sort(key=lambda x: -x[1])
d = []
dl = 0
for x in bc:
  b,c = x
  d += [c] * b
  dl += b
  if dl >= n:
    break
if dl < n:
  d += [0] * (n-dl)
ans = []
for i in range(n):
  ans.append(max(a[i],d[i]))
#print(a)
#print(d)
#print(ans)
print(sum(ans))

Measured memory_bytes: 88820
open Printf
open Scanf

let id x = x

let dijkstra g n s =
  let d = Array.make n max_int in
  let av = Array.make n true in
  let rec min_cost i r =
    if i = n then r
    else if av.(i) then begin
        match r with
          None -> min_cost (i+1) (Some i)
        | Some j -> if d.(i) < d.(j) then
                      min_cost (i+1) (Some i)
                    else
                      min_cost (i+1) r
      end
    else min_cost (i+1) r
  in
  let rec loop () =
    match min_cost 0 None with
      None -> d
    | Some u -> begin
        av.(u) <- false;
        Array.iteri (fun v w ->
                     if w >= 0 && av.(v) then
                       if d.(u) + w < d.(v) then
                         d.(v) <- d.(u) + w
                    ) g.(u);
        loop ()
      end
  in
  d.(s) <- 0;
  loop ()

let () =
  let n = scanf "%d " id in
  let g = Array.make_matrix n n (-1) in
  let rec set_g x =
    if x = 0 then ()
    else let u, k = scanf "%d %d " (fun i j -> (i, j)) in
         let rec read y =
           if y = 0 then set_g (x-1)
           else let v, c = scanf "%d %d " (fun i j -> (i, j)) in
                g.(u).(v) <- c;
                read (y-1)
         in
         read k
  in
  set_g n;
  Array.iteri (fun x y -> printf "%d %d\n" x y) (dijkstra g n 0)

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair


ll num[10000001];

int main(){
    ll N; cin>>N;
    
    for(ll x=1; x<=N; ++x){
        for(ll i=x;i<=N;i+=x){
            ++num[i];
        }
    }
    
    ll ans = 0;
    for(int k=1;k<=N;++k){
        ans += k*num[k];
    }
    cout << ans << "\n";
}

Measured memory_bytes: 81764
#include<iostream>
 
using namespace std;
 
int main(){
  static bool cmp[1000000]={true};
  static int npr[1000000];
  for(int i=2;i<1000000;i++){
    if(!cmp[i]){
      for(int j=2;j*i<1000000;j++){
    cmp[i*j]=true;
      }
    }
    npr[i]=npr[i-1]+!cmp[i];
  }
  for(int n;cin>>n;n++){
    cout<<npr[n]<<endl;
  }
  return 0;
}

Measured memory_bytes: 7828