akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;

char letter[27] = {"abcdefghijklmnopqrstuvwxyz"};
int flag[27] = {0};

int main()
{
    int n, sum, maxn = -1;
    char a[110];
    scanf("%d", &n);
    getchar();
    scanf("%s", a);

    for(int i = 0; i < n; i++)
    {
        sum = 0;
        memset(flag, 0, sizeof(flag));
        for(int j = 0; j <= i; j++)
        {
            for(int m = 0; m < 27; m++)
            {
                if(a[j] == letter[m])
                    flag[m] = 1;
            }
        }
        for(int k = i + 1; k < n; k++)
        {
            for(int m = 0; m < 27; m++)
            {
                if(a[k] == letter[m] && flag[m] == 1)
                {
                    sum++;
                    flag[m] = 2;
                    continue;
                }
            }
        }
        if(sum > maxn)
            maxn = sum;
    }
    printf("%d\n", maxn);
    return 0;
}


Measured memory_bytes: 256
#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>;

bool dfs(vector<int> &s, string c, int i, int sum) {
    if(i == 3){
        if (sum == 7){
            cout<<s[0]<<c[0]<<s[1]<<c[1];
            cout <<s[2]<<c[2]<<s[3]<<"=7"<<endl;
            return true;
        }
        return false;
    }
    if (dfs(s, c + "+", i + 1, sum + s[i+1])) return true;

    if (dfs(s, c + "-", i + 1, sum - s[i+1])) return true;
    return false;
}

int main(){
    string s0;
    vector<int> s;
    string c;
    cin >> s0;
    for (char i: s0){
        s.emplace_back(i - '0');
    }
    dfs(s, c, 0, s[0]);
    return 0;
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Control.Monad.ST
-- import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
--import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Fixed
import Data.Tuple
--import Data.Array
--import Data.Array.Unboxed
import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import Text.Printf
import System.IO
-- import System.IO.Unsafe
 
-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
whenM :: Monad m => m Bool -> m () -> m ()
whenM c a = c >>= flip when a
unconsU :: [a] -> (a, [a])
unconsU (x:xs) = (x, xs)
-- templete

calc a l x = a * unhypot l (a/2) / 2 + l * unhypot ((l+x)/2) (l/2)
  where
    unhypot r y = sqrt $ r^2 - y^2


main = map (apply3 calc . map readDouble . words) . lines <$> getContents >>= mapM_ (printf "%.15f\n")




Measured memory_bytes: 4756
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll C[51][51]={};
void comb(int n){
	for(int i=0;i<=n;i++){
		for(int j=0;j<=i;j++){
			if(j==0||j==i) C[i][j]=1LL;
			else C[i][j]=C[i-1][j-1]+C[i-1][j];
		}
	}
}

int main(){
	int n,a,b;
	cin >> n >> a >> b;
	ll v[50];
	for(int i=0;i<n;i++) cin >> v[i];
	sort(v,v+n);
	reverse(v,v+n);

	comb(n);

	double ans=0;
	for(int i=0;i<a;i++) ans+=v[i];
	ans/=a;

	ll num=0LL;
	int nn=0,rr=0;
	for(int i=0;i<n;i++){
		if(v[i]==v[a-1]){
			nn++;
			if(i<a) rr++;
		}
	}
	if(rr==a){
		for(rr;rr<=b;rr++) {
			num+=C[nn][rr];
		}
	}else num+=C[nn][rr];

	cout.precision(20);
	cout << fixed << ans << endl;
	cout << num << endl;
}


Measured memory_bytes: 256
n,k,q = map(int,input().split())
A =[]
for _ in range(q):
    s = int(input())
    A.append(s)
B = [0]*n
for a in A:
    B[a-1] += 1
cnt = 0
for b in B:
    tmp = k-(q-b)
    if tmp > 0:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 8620
#include <bits/stdc++.h>
using namespace std;
struct node
{
    int x,y;
}arr[100100];
int a[100010],b[100010];
bool cmp(node a,node b)
{
    if(a.y==b.y) return a.x<b.x;
    return a.y<b.y;
}
int main()
{
    int n,m;
    while(~scanf("%d%d",&n,&m))
    {
        for(int i=1;i<=m;i++)
        {
            scanf("%d%d",&a[i],&b[i]);
            arr[i].x=a[i];
            arr[i].y=b[i];
        }
        sort(arr+1,arr+1+m,cmp);
        int ans=1;
        int mid=arr[1].y;
        for(int i=2;i<=m;i++)
        {
            if(arr[i].x>=mid)
            {
                ans++;
                mid=arr[i].y;
            }
        }
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 1792
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
    string s; cin >> s;
    string t, ans;
    rep(i, s.size()){
        if(s.at(i)=='B'){
            if(t.size()==0){
                continue;
            }
            t.erase(t.size()-1, 1);
        }
        else{
            t += s.at(i);
        }
    }

    cout << t << endl;
    return 0;
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n; cin >> n;
  ll ans = 0;
  for(ll i = 1; i <= n; ++i){
    ll x = i;
    while(x <= n){
      ans += x;
      x += i;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>

int input_count_trial() {
    int count;
    std::cin>>count;
    return count;
}

void display(int count_trial) {
    std::vector<int> scores;
    int score;
    for(int i=0; i<count_trial; i++) {
        std::cin>>score;
        scores.push_back(score);
    }
    std::sort(scores.begin(), scores.end());
    scores.erase(scores.begin());
    scores.erase(scores.end()-1);
    int sum = std::accumulate(scores.begin(), scores.end(), 0);
    int avarage = sum/(scores.size());
    std::cout << avarage << std::endl;
    return;
}

int main() {
    int count_trial = input_count_trial();
    do {
        display(count_trial);
        count_trial = input_count_trial();
    }while(count_trial!=0);
    return 0;
}



Measured memory_bytes: 3028
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;

static class CodeJam
{
    static int Mod(long n, int K)
    {
        return (int)(((n % K) + K) % K);
    }

    static long Solve(int N, int K, int[] A)
    {
        if (K == 1) { return 0; }
        long sum = 0;
        var cnts = new Dictionary<int, int>();
        var S = new long[N + 1];
        for (int i = 0; i < N; ++i) { S[i + 1] = S[i] + A[i]; }
        for (int j = 1; j <= N; ++j)
        {
            if (j >= K)
            {
                int i = j - K;
                int n = Mod(S[i] - i, K);
                if (cnts.ContainsKey(n)) { --cnts[n]; }
            }
            {
                int i = j - 1;
                int n = Mod(S[i] - i, K);
                if (!cnts.ContainsKey(n)) { cnts[n] = 0; }
                ++cnts[n];
            }
            {
                int n = Mod(S[j] - j, K);
                if (cnts.ContainsKey(n)) { sum += cnts[n]; }
            }
        }
        return sum;
    }

    static void Main(string[] args)
    {
        int[] V = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        int[] A = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        Console.WriteLine(Solve(V[0], V[1], A));
    }
}


Measured memory_bytes: 46048
//
// Created by 中野誠大 on 2019-02-10.
//

#include<iostream>

#include<stdio.h>
#include <stdlib.h>
#include<string>
#include<queue>
#include<algorithm>
#include<math.h>

using namespace std;


int main() {
    int a,b;
    cin >> a>>b;
    cout<<(a-1)*(b-1)<<endl;

    return 0;



}





Measured memory_bytes: 256
#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define LOCAL 1

#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#define dbg(...) cout<<#__VA_ARGS__ ": ["; for(auto e: __VA_ARGS__){cout<<e<<", ";} cout<<"]\n"
#define dbg1(...) cout<<#__VA_ARGS__ " "<< __VA_ARGS__ 
#else
#define dbg(...) 1;
#define dbg1(...) 1;
#endif

typedef long long ll;
typedef unsigned long long ull;
constexpr int R=5e6+69, INF=2e9+6969;

int qq;

int main()
{
	string a,b;
	cin >> a>> b;
	int ans=0;
	for(int i=0;i<a.size();++i)
	{
		if(a[i]!=b[i]) ans++;
	} 
	cout << ans;
	return 0;
}


Measured memory_bytes: 3920
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

  string s;
  cin >> s;
  if(s=="SUN"){
    cout << 7 << endl;
  } else if(s=="MON"){
    cout << 6 << endl;
  } else if(s=="TUE"){
    cout << 5 << endl;
  } else if(s=="WED"){
    cout << 4 << endl;
  } else if(s=="THU"){
    cout << 3 << endl;
  } else if(s=="FRI"){
    cout << 2 << endl;
  } else if(s=="SAT"){
    cout << 1 << endl;
  }

	return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cmath>
using namespace std;

int gcd(int x, int y){
    if (x < y) {
        swap(x,y);
    }
    while (x%y!=0) {
        int r=x;
        x=y;
        y=r%x;
    }
    return y;
}

int main() {
    int k;
    cin >> k;
    long ans = 0;
    for (int i = 0; i < k; i++) {
        for (int j = 0; j < k; j++) {
            for (int l = 0; l < k; l++) {
                ans += gcd(i+1,gcd(j+1,l+1));
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3564
N = int(input())
D = list(map(int, input().split()))

X = 998244353

l_max = max(D)

def f():
    if D[0] != 0:
        print(0)
    
        return
    L = [0] * (l_max+1)
    for d in D:
        L[d] += 1 
    if L[0] != 1:
        print(0)
        return
    ans = 1
    L = [1] + L
    #print(L)

    for i in range(1, len(L)):
        if L[i] == 0:
            print(0)
            return
        ans = ans * (L[i-1] ** L[i])
    print(ans % X)
    
f()


Measured memory_bytes: 52720
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

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

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

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

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int x = sc.nextInt();
    int y = sc.nextInt();
    int[] xi = sc.nextIntArray(n);
    int[] yi = sc.nextIntArray(m);
    int max = x;
    int min = y;
    for (int i = 0; i < n; i++) {
      max = Math.max(max, xi[i]);
    }
    for (int i = 0; i < m; i++) {
      min = Math.min(min, yi[i]);
    }
    System.out.println(max < min ? "No War" : "War");
  }
}

Measured memory_bytes: 21332
#include<stdio.h>
#include <iostream>
using namespace std;
int main(void)
{
	long long A,B,C,K,i,N;
	cin >> A;
        cin >> B;
        cin >> C;
        cin >> K;
	
	if(A >= K){
		N = K;
	}else{
		K = K - A;
		N = A;
		
		if(B < K){
			N =N-( K - B);
		}
	}
	cout << N;
 
	return 0;
}

Measured memory_bytes: 3184
#include<bits/stdc++.h>
// debug
#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl;
#define ddd(x, y, z) cerr << "(" #x "," #y "," #z "):(" << x << "," << y << "," << z << ")" << endl;
#define dump(v) cerr<<#v":[ ";for (auto macro_vi:v){cerr<<macro_vi<< " ";}cerr<<"]"<<endl;
#define ddump(v) cerr<<#v":"<<endl;for(auto macro_row:v) {cerr<<"["; for (auto macro__vi:macro_row){cerr<<macro__vi<< " ";}cerr<<"]"<<endl;}
#define damp(m) for(auto macro_pair:m){cerr<< macro_pair.first<<":"<<macro_pair.second<<endl;}
#define dpair(p) cerr << #p":"<<"(" << p.first << "," << p.second << ")" << endl;
// iterate
#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define reprrev(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define reprev(i, n) reprrev(i, 0, n)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define all(v) v.begin(), v.end()
// etc
#define chmin(mi, val) mi = min(mi, val);
#define chmax(ma, val) ma = max(ma, val);
using ll = long long;

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    vector<int> v(n,0);rep(i,n)cin>>v[i];

    vector<int> L(n+1,0), R(n+1,0);

    for(int i=0;i<n;i++){
        L[i+1] = max(L[i], v[i]);
    }

    for(int i=n;0<i;i--){
        R[i-1] = max(R[i], v[i-1]);
    }
    // dump(L)
    // dump(R)
    for(int i=0;i<n;i++){
        cout << max(L[i], R[i+1]) << endl;
    }
    return 0;
}

Measured memory_bytes: 3968
fn check(s : &[u8]) -> bool {
    let n = s.len();
    for i in 0..n/2 {
        if s[i] != s[i+n/2] { return false }
    }
    return true
}

fn solve(s : &[u8]) -> usize {
    if check(s) { return s.len() }
    else { return solve(&s[0..s.len()-2]) }
}

fn main() {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).unwrap();
    for _ in 0..3 { input.pop(); }
    let s = input.as_bytes();

    println!("{}", solve(s))
}


Measured memory_bytes: 4352
#include<cstdio>

int a[100001],b[100001];
int main(){
	int n;scanf("%d",&n);
	for(int i=1,z;i<=n;i++)scanf("%d",&z),a[z]=i;
	for(int i=1,z=0;i<=n;i++)z+=a[i],printf("%d ",z+i);
	printf("\n");
	for(int i=n,z=0;i;i--)z+=a[i],b[i]=n-i+1+z;
	for(int i=1;i<=n;i++)printf("%d ",b[i]);
}

Measured memory_bytes: 640
// ######      ###      #######    #######    ##     #     #####        ###     ##### //
// #     #    #   #          #        #       # #    #    #     #      #   #     ###  //
// #     #   #     #        #         #       #  #   #   #       #    #     #    ###  //
// ######   #########      #          #       #   #  #   #           #########    #   //
// #     #  #       #     #           #       #    # #   #    ####   #       #    #   //
// #     #  #       #    #            #       #     ##   #    #  #   #       #        //
// ######   #       #   #######    #######    #      #    #####  #   #       #    #   //


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> ppl;
#define ain(a,n) for(ll i=0;i<(n);++i)	cin>>(a)[i];
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(ll i=0;i<(n);++i)
#define FOR(i,a,b) for(ll i=(a);i<=(b);++i)
#define FORD(i,a,b) for(ll i=(a);i>=(b);--i)
#define cases ll T=0;cin>>T;while(T--)
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define END "\n"
#define pb push_back
#define mp make_pair
#define go(c,itr) for(auto itr=(c).begin(); itr!=(c).end(); ++itr)
// #define back(c,itr) for(auto itr=(c).rbegin(); itr!=(c).rend(); ++itr)
#define PI 3.14159265359
#define inf 9e18
#define MOD 1000000007
#define MODU 998244353
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MAXN 100005
#define BLOCK 555
const string alpha = "abcdefghijklmnopqrstuvwxyz";
const ll N = 200005;
const long double epsilon = 1e-9;
ll binexp(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
ll modinvfermat(ll a, ll m)
{
	return binexp(a, m - 2, m);
}
void task(bool flag)
{
	if (flag)
		cout << "YES\n";
	else
		cout << "NO\n";
}
ll lcm(ll a, ll b)
{
	return ((1LL * a * b) / (__gcd(a, b)));
}

signed main() {

	fast
	ll n;
	cin >> n;
	vl a(n + 1, 0);
	ll sum = 0;
	FOR(i, 1, n)	cin >> a[i] , sum += a[i];
	vector<vvl> dp(3005, vvl(3005, vl(2, 0)));
	FOR(i, 1, n)	dp[i][i][0] = a[i];
	FOR(diff, 1, n - 1)
	{
		for (ll i = 1; i + diff <= n; ++i)
		{
			ll l = i, r = i + diff;
			dp[l][r][0] = max(a[l] + dp[l + 1][r][1], a[r] + dp[l][r - 1][1]);
			dp[l][r][1] = min(dp[l + 1][r][0], dp[l][r - 1][0]);
		}
	}
	ll ans = 2 * dp[1][n][0] - sum;
	cout << ans << END;



	return 0;
}


Measured memory_bytes: 497392
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

struct UFTree(T)
{
    struct Node
    {
        T parent;
        T rank = 1;
    }

    ///
    T min_size, max_size;

    ///
    this(T n)
    {
        nodes.length = n;
        sizes.length = n;
        foreach (i, ref node; nodes) {
            node = Node(i.to!T);
            sizes[i] = 1;
        }

        min_sizes.length = n + 1;
        min_sizes[1] = n;
        min_size = 1;
        max_size = 1;
    }

    ///
    bool unite(T a, T b)
    {
        a = root(a);
        b = root(b);

        if (a == b) return false;

        auto a_size = sizes[a];
        auto b_size = sizes[b];
        --min_sizes[a_size];
        --min_sizes[b_size];
        ++min_sizes[a_size + b_size];
        foreach (nxt_size; min(a_size, b_size)..min_sizes.length) if (min_sizes[nxt_size] != 0) {
            min_size = nxt_size.to!T;
            break;
        }
        max_size = max(max_size, a_size + b_size);

        if (nodes[a].rank < nodes[b].rank) {
            sizes[a] += sizes[b];
            nodes[b].parent = a;
        } else {
            sizes[b] += sizes[a];
            nodes[a].parent = b;
            if (nodes[a].rank == nodes[b].rank) ++nodes[b].rank;
        }

        return true;
    }

    ///
    bool is_same(T a, T b)
    {
        return root(a) == root(b);
    }

    ///
    T size(T i)
    {
        return sizes[root(i)];
    }

private:
    Node[] nodes;
    T[] sizes;
    T[] min_sizes;

    T root(T i)
    {
        if (nodes[i].parent == i) return i;

        return nodes[i].parent = root(nodes[i].parent);
    }
}

///
UFTree!T uftree(T)(T n)
{
    return UFTree!T(n);
}

alias T = Tuple!(int, "i", int, "p");
alias Path = Tuple!(long, "a", long, "b", long, "c");

void main()
{
    auto N = readln.chomp.to!int;
    T[] xs, ys;
    foreach (i; 0..N) {
        auto xy = readln.split.to!(int[]);
        xs ~= T(i, xy[0]);
        ys ~= T(i, xy[1]);
    }
    sort!"a.p < b.p"(xs);
    sort!"a.p < b.p"(ys);

    Path[] ps;
    foreach (i; 0..N-1) {
        auto x1 = xs[i];
        auto x2 = xs[i+1];
        ps ~= Path(x1.i, x2.i, abs(x1.p - x2.p));
        auto y1 = ys[i];
        auto y2 = ys[i+1];
        ps ~= Path(y1.i, y2.i, abs(y1.p - y2.p));
    }
    sort!"a.c < b.c"(ps);

    auto uft = uftree!long(N);
    long cs;
    foreach (p; ps) {
        if (uft.is_same(p.a, p.b)) continue;
        uft.unite(p.a, p.b);
        cs += p.c;
    }
    writeln(cs);
}

Measured memory_bytes: 12540
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)

int main(){
  ll a, b, c;
  cin >> a >> b >> c;
  ld ans = (ld) 1.0 -  (sqrt((ld)1.0*a/c)+sqrt((ld)1.0*b/c)) ;
  if(ans>0) cout << "Yes" ;
  else cout << "No";
}

Measured memory_bytes: 256
import math
N = int(input())
ans = int((-1+math.sqrt(1+8*N))/2)

if (ans*(ans+1))//2<N:
  ans += 1

k = (ans*(ans+1))//2-N

if k == 0:
  for i in range(ans):
    print(i+1)
else:
  for i in range(ans):
    if i+1 != k:
      print(i+1)

Measured memory_bytes: 42344
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <unordered_map>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>
#include <iomanip>
#include <type_traits>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//constexpr long long MOD = 1e9 + 7;
//constexpr long long MAX = 1000000;

//long long MOD = 998244353;
constexpr ll INF = 1e17;
constexpr double PI = 3.141592653589793;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

ll h, w;
vector<ll> dx = { -1, 0, 1, 0 };
vector<ll> dy = { 0, -1, 0, 1 };


bool isInField(ll x, ll y) {
    bool f = x >= 0 && x < w && y >= 0 && y < h;
    return f;
}

bool compare_first(pair<ll, ll> x, pair<ll, ll> y)
{
    if (x.first != y.first) {
        return x.first < y.first;
    }
    else {
        return x.second < y.second;
    }
}

bool compare_second(pair<ll, ll> x, pair<ll, ll> y)
{
    if (x.second != y.second) {
        return x.second < y.second;
    }
    else {
        return x.first < y.first;
    }
}

struct {
    bool operator()(pair<string, int> x, pair<string, int> y) const
    {
        return x.second <= y.second && x.first < y.first;
    }
} compare_map;

const ll MAX = 500000000;
const ll MOD = 1000000007;

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

    int a, b;
    cin >> a >> b;

    for (int i = 1; i <= 13000; i++)
    {
        int candidate = i * 0.08;
        int candidate2 = i * 0.1;
        if (candidate == a && candidate2 == b) {
            cout << i << "\n";
            return 0;
        }
    }
    cout << -1 << "\n";

    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int n,m;
	scanf("%d",&n);
	scanf("%d", &m);
	int A[m];
	for (int i = 0; i < m; i++)
	{
		scanf("%d",&A[i]);
		n -= A[i];
	}
	if (n >= 0)printf("%d",n);
	else printf("-1");
}

Measured memory_bytes: 1764
n, k = map(int, input().split())
freq = dict()
for i in range(n):
  a, b = map(int, input().split())
  if freq.get(a): freq[a] += b
  else: freq[a] = b
f_asc = sorted(freq.items(), key=lambda x: x[0])
idx = 0
for kv in f_asc:
  idx += kv[1]
  if idx >= k:
    print(kv[0])
    break

Measured memory_bytes: 15044
using System;
using System.Collections.Generic;
using System.Linq;

namespace algorithm
{
	class Program
	{

		static void Main(string[] args)
		{
			//配列全てに処理(入力.分割,数値に変換)
			var nk = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
			var b = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
			SortedDictionary<int, int> dic = new SortedDictionary<int, int>();

			foreach (int s in b)
			{
				if (dic.ContainsKey(s)) dic[s]++;
				else dic.Add(s, 1);
			}

			List<int> t = dic.Values.ToList();
			t.Sort();

			int kotae = 0;
			for (int i=0;i<t.Count-nk[1]; i++)
			{
				kotae += t[i];
			}

			Console.Write(kotae);

		}

	}
}


Measured memory_bytes: 35328
#include <bits/stdc++.h>
using namespace std;
signed main(){
  int n,m,x,y,a[105],b[105];
  bool f=false;
  if(x>y)
    swap(x,y);
  cin>>n>>m>>x>>y;
  for(int i=0;i<n;i++)
    cin>>a[i];
  for(int i=0;i<m;i++)
    cin>>b[i];
  sort(a,a+n);
  sort(b,b+m);
  
  for(int i=x+1;i<=y;i++){
    if(a[n-1]<i && i<=b[0]){
      f=true;
      goto A;
    }
  }
 A:if(f)
  cout<<"No ";
  cout<<"War"<<endl;
  return(0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define pb push_back
#define f first
#define s second
 ll mp[2000000] ;
int  main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n , ans = 0  , i ;

    cin >> n ;
    vector<ll> v(n) ;
    for (i = 0 ; i< n; i++) {
        cin >>v[i] ;
        mp[v[i]]++ ;
    }

    for (i = 0 ;i< n ; i++) {
        ll   tmp = 1 ;
        for (ll j = 1; j*j<=v[i] ;j++) {
            if (v[i]%j==0) {
                if (mp[j]) {
                    if (j==1 and v[i]==1 and mp[1]>1) tmp = 0 ;
                    else if (v[i]!=1) tmp = 0 ;
                }
                if (mp[v[i]/j]) {
                    if (j==1 and mp[v[i]]>1) tmp = 0 ;
                    else if(j!=1) tmp = 0 ;
                }
            }
        }
        ans+=tmp ;
    }
    cout << ans << endl ;

}


Measured memory_bytes: 12648
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long  tong[111111];
    long long n,ans=0,q;
    cin>>n;
    vector<long long>v;
    while(n--){
        int e;cin>>e;
		v.push_back(e);  
		ans+=e; 
		tong[e]++;	
	}
	cin>>q;
	long long a[111111];
	long long b[111111];
    for(int i=0;i<q;i++){
    	cin>>a[i]>>b[i];
	}
	for(long long i=0;i<q;i++){
    	if(a[i]>b[i]){
    		int nas=a[i]-b[i];
    		nas*=tong[a[i]];
    		cout<<ans-nas<<endl;
    		ans-=nas;
    		tong[b[i]]+=tong[a[i]];
    		tong[a[i]]=0;
		}
		else if(a[i]<b[i]){
    		int nas=b[i]-a[i];
    		nas*=tong[a[i]];
    		cout<<ans+nas<<endl;
    		ans+=nas;
    		tong[b[i]]+=tong[a[i]];
    		tong[a[i]]=0;
		}
	}
	//for(int i=1;i<=10;i++) cout<<tong[i]<<"   ";
	return 0;
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int A[10005];

int main()
{
    int H, W, N;
    cin >> H >> W >> N;
    REP(i, N)
    {
        cin >> A[i];
    }
    vector<vector<int>> v(H);
    int index = 0;
    REP(i, H)
    {
        vector<int> t(W);
        REP(j, W)
        {
            if (A[index] == 0)
                index++;
            t[j] = index + 1;
            A[index]--;
        }
        if (i % 2 == 1)
            std::reverse(t.begin(), t.end());
        v[i] = t;
    }

    REP(i, H)
    {
        REP(j, W)
        {
            cout << v[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <cstdio>
#include <string>
using namespace std;
#define INF 1 << 29

#define elif else if
#define read cin >>
#define echo cout <<
#define fin << '\n'
#define endl '\n'

int main(){
	string a;
	read a;
	if ( a[0] == 'A' ) {
		int counter = 0;
		for ( int i = 2; i < a.length()-1; i++ ) {
			if ( a[i] == 'C' ) counter++;
		}
		if ( counter == 1 ) {
			counter = 0;
			for ( int i = 0; i < a.length(); i++ ) {
				if ( 'A' <= a[i] && a[i] <= 'Z' ) counter++;
			}
			if ( counter == 2 ) {
				echo "AC\n";
				return 0;
			}
		}
	}
	echo "WA\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL << 60;

// 入力
int N;
long long h[110000];

// DP テーブル
long long dp[110000];

int main() {
    int N, K; cin >> N >> K;
    for (int i = 0; i < N; ++i) cin >> h[i];

    // 初期化 (最小化問題なので INF に初期化)
    for (int i = 0; i < 110000; ++i) dp[i] = INF;

    // 初期条件
    dp[0] = 0;

    // ループ
    for (int i = 0; i < N; ++i) {
        for (int j = 1; j <= K; ++j) {
            chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        }
    }

    // 答え
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 5236
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;

int main() {
  int n, k;
  cin >> n >> k;
  vector<ll> h(n);
  for (int i = 0; i < n; ++i) cin >> h[i];

  vector<ll> dp(n + 105, INF);
  dp[0] = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 1; j <= k; ++j) {
      dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
    }
  }

  cout << dp[n - 1] << '\n';
  return 0;
}


Measured memory_bytes: 4816
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;


int main() {  
  int N, A, count;
  cin >> N >> A;
  
  for (int i=0; i<=A; ++i){
    int amari = N - i;
    if (amari % 500 == 0){
      count += 1;
    }
  }
  if (count != 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}




Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		boolean followRulesFlg = true;
		ArrayList<String> stringsA = new ArrayList<>();
			
		for(int a = 0; a<N; a++){
			stringsA.add(sc.next());
		}
		sc.close();
		
		ArrayList<String> stringsB = new ArrayList<>(stringsA);
		Collections.sort(stringsB);
		
		for(int a = 0; a<stringsA.size()-1; a++){
			int b = a+1;
			if(stringsA.get(a).charAt(stringsA.get(a).length()-1)!=stringsA.get(b).charAt(0)){
				followRulesFlg=false;
				break;
			}
			if(stringsB.get(a).equals(stringsB.get(b))){
				followRulesFlg=false;
				break;
			}
		}
		System.out.println(followRulesFlg? "Yes" : "No");
	}
}

Measured memory_bytes: 23380
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define all(a)  (a).begin(),(a).end()

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

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

const ll INF = 1LL << 60;

int main(){
  int H,W,A,B;
  cin >> H >> W >> A >> B;
  rep(h, H){
    rep(w, W){
      if(0 <= w && w < A && 0 <= h && h < B) std::cout << 1;
      else if(A <= w && w < W && B <= h && h < H) std::cout << 1;
      else std::cout << 0;
    }
    std::cout << '\n';
  }
}


Measured memory_bytes: 1280
#include<iostream>


using namespace std;


int main(){

   int a, b, c, d;
   cin >> a >> b >> c >> d;

   if((abs(a - c) <= d) || ((abs(a - b) <= d) && (abs(b - c) <= d))){
       cout << "Yes";
   }
   else{
       cout << "No";
   }
  



    return 0;
}

Measured memory_bytes: 256
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

n = ni()
d = [ni() for _ in range(n)]
d = set(d)
d = sorted(d, reverse=True)
ans = 0
b = 110
for i in d:
    if i < b:
        ans += 1
    else:
        break
    b = i
print(ans)


Measured memory_bytes: 3064
# 入力が10**5とかになったときに100ms程度早い
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


N, K = read_ints()

from math import log2

ans = 0.0
p_dice = 1 / N


def get_trial(i):
    # iは最初に出たサイコロの目
    ret = 0
    tmp = i
    while tmp < K:
        tmp *= 2
        ret += 1

    return ret


for i in range(N):
    ans += (1 / 2)**get_trial(i+1)

print(p_dice*ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0), cin.tie(0) 
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 5;
const ll inf = ~0ull >> 1;
int main() {
    int n, r;
    cin >> n >> r;
    if (n < 10) 
        cout << r + 100 * (10 - n) << endl;
    else
    {
        cout << r << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

INF = float('inf')
dp = [[INF] * (n+1) for _ in range(n+1)]

acum = [0] * (n+1)
for i, ai in enumerate(a):
    acum[i+1] += acum[i] + ai

for i in range(n+1):
    dp[i][i] = 0
    if i+1 <= n:
        dp[i][i+1] = 0

for l in range(2, n+1):
    for i in range(n-l+1):
        j = i + l
        for k in range(i+1, j):
            dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j] + acum[j] - acum[i])

print(dp[0][n])

Measured memory_bytes: 47708
# 数字を先頭と末尾のペアに変換
def toHeadTail(n):
    n = str(n)
    head = n[0]
    tail = n[-1]
    return (head, tail)

# 集計処理
def aggregate(N):
    pair_agg = {}
    for i in range(1, N + 1):
        pair = toHeadTail(i)
        if pair in pair_agg.keys():
            pair_agg[pair] += 1
        else:
            pair_agg[pair] = 1
    return pair_agg

N = int(input())
pair_agg = aggregate(N) 
count = 0
for i in range(1, N + 1):
    pair = toHeadTail(i)
    pair_inverse = (pair[1], pair[0])
    if pair_inverse in pair_agg.keys():
        count += pair_agg[(pair[1], pair[0])]
print(count)


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

const int MAX = 210000;
const int MOD = 1000000007;

typedef pair<long long, long long> pll;
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int N;
vector<long long> H;

// first: all, second: oxoxoxoxox
pll rec(int left, int right) {
    long long resall = 0, resalt = 0;

    // height
    long long height = 1LL<<60;
    for (int i = left; i < right; ++i) if (H[i] < height) height = H[i];
    for (int i = left; i < right; ++i) H[i] -= height;
    vector<pll> subs;
    int nleft = left;
    int width = 0;
    for (int i = left; i < right; ++i) {
        if (H[i] == 0) {
            if (i > nleft) subs.push_back(rec(nleft, i));
            nleft = i+1;
            ++width;
        }
    }
    if (right > nleft) subs.push_back(rec(nleft, right));
    
    // second -> second
    long long facalt = 1;
    for (auto p : subs) facalt *= p.second, facalt %= MOD;
    resalt += facalt * modpow(2LL, height, MOD) % MOD;
    resall += resalt;

    // first (not second)
    long long fac = 1;
    for (auto p : subs) {
        fac *= (p.first + p.second); fac %= MOD;
    }
    resall += fac * modpow(2LL, width, MOD) % MOD;
    resall += MOD - facalt * 2 % MOD;

    // result
    return pll(resall % MOD, resalt % MOD);;
}

int main() {
    cin >> N;
    H.resize(N); for (int i = 0; i < N; ++i) cin >> H[i];
    pll res = rec(0, N);
    cout << res.first << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
const ll mod=1e9+7;
const int maxn=2e5+50;
using namespace std;
 main()
//int found; found=chaine.find(cara); if (found!=std::string::npos) how to verify if a caracter exists in a chaine
// toupper(caractere) ==> return the majuscule of a caractere
//floor(x) Returns the largest integer smaller than x
//ceil(x) returns  Returns the smallest integer greater
//printf("%.10f",res);
{
  int n,a,b;
  cin>>n>>a>>b;
  if(n*a<b)
  {
  	cout<<n*a;
	  }	
	  else
	  {
	  	cout<<b;
	  }
}


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

int main(){
	int n,m;
	cin >> n >> m;
	vector<string> a(n), b(m);
	for(int i=0;i<n;++i) cin >> a[i];
	for(int i=0;i<m;++i) cin >> b[i];
	
	bool exist=false;
	for(int ly=0;ly<n;++ly){
		for(int lx=0;lx<n;++lx)
		{
			if(ly+m-1>=n or lx+m-1>=n) continue;
			bool match = true;
			for(int y=0;y<m;++y){
				for(int x=0;x<m;++x)
				{
					if(a[ly+y][lx+x]!=b[y][x]) match=false;
				}
			}
			if(match) exist=true;
		}
	}
	if(exist) cout << "Yes" << endl;
	else cout << "No" << endl;
		
	return 0;
}

Measured memory_bytes: 256
#include <cmath>
typedef long long ll;

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

#include <queue>
#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <set>
using namespace std;

typedef vector<ll> vec;
typedef vector<vec> mat;

int mod;

mat operator * (const mat &lhs, const mat &rhs){
  const int n = lhs.size();
  mat ret(n, vec(n));

  REP(k,n) REP(i,n) REP(j,n){
    ret[i][j] += (lhs[i][k] * rhs[k][j]) % mod;
    ret[i][j] %= mod;
  }

  return ret;
}

vec operator * (const mat &lhs, const vec &rhs){
  const int n = lhs.size();
  vec ret(n);

  REP(i,n) REP(j,n){
    ret[i] += (lhs[i][j] * rhs[j]) % mod;
    ret[i] %= mod;
  }

  return ret;
}

mat pow(mat m, int p){
  const int n = m.size();
  mat ret(n, vec(n));

  REP(i,n) ret[i][i] = 1;

  while(p){
    if(p & 1) ret = ret * m;
    m = m * m;
    p >>= 1;
  }

  return ret;
}

int main(){
  while(true){
    const int n = getInt();
    const int m = getInt();
    const int a = getInt();
    const int b = getInt();
    const int c = getInt();
    const int t = getInt();

    if(n + m + a + b + c + t == 0) break;

    mod = m;

    vec s(n);
    REP(i,n) s[i] = getInt();
    mat mt(n, vec(n));

    REP(i,n){
      if(i - 1 >= 0) mt[i][i - 1] = a;
      mt[i][i] = b;
      if(i + 1 < n) mt[i][i + 1] = c;
    }

    vec ans = pow(mt, t) * s;

    REP(i,n) printf("%d%c", (int)ans[i], i == n - 1 ? '\n' : ' ');
  }
  return 0;
}

Measured memory_bytes: 1144
n = int(input())
a = list(map(int,input().split()))
import collections
c = collections.Counter(a)
a = list(set(a))
n = len(a)
a = sorted(a)
B = [True]*(a[-1]+1)
ans = 0
for i in range(n):
    if B[a[i]]:
        if c[a[i]] == 1:
            ans += 1
    j = 2
    while a[i]*j <= a[-1]:
        B[a[i]*j] = False
        j += 1
print(ans)


Measured memory_bytes: 44332
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n;
	cin >> n;
	map<int , int> m;
	rep(i, n){
		int in;
		cin >> in;
		m[in]++;
		m[in-1]++;
		m[in+1]++;
	}
	pair<int, int> ans(0,0);
	for(auto p : m){
		if(p.second > ans.second){
			ans = p;
		}
	}
	cout << ans.second << endl;
	return 0;
}

Measured memory_bytes: 4736
#include<iostream>
#include<iomanip>
#include<complex>
#include<cmath>
#include<cstdlib>
using namespace std;

typedef complex<double> xy_t;
xy_t P[21];

double heron(xy_t p,xy_t q,xy_t r){
    double a=abs(p-q),b=abs(q-r),c=abs(r-p);
    double z=(a+b+c)/2;
    return sqrt(z*(z-a)*(z-b)*(z-c));
}

int main(){
    double x,y;
    char noise;
    int n=0;

    while(cin>>x>>noise>>y){
        P[n++]=xy_t(x,y);
    }
    //i?????????????????°????????´??????????????????
    //cerr<<n<<"\n";

    double S=0.0;
    for(int i=0;i<n-2;++i){
        S+=heron(P[0],P[i+1],P[i+2]);
    }

    cout<<fixed<<setprecision(6)<<S<<"\n";
}

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

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

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

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input!{
        n: i64,
    }

    let mut a = 0;
    for i in 1..n * 2 + 1 {
        if i * (i + 1) == 2 * n {
            a = i;
            break;
        }
    }

    if a == 0 {
        println!("No");
        return;
    }

    println!("Yes");

    let a = a as usize;

    println!("{}", a + 1);
    let mut ans: Vec<Vec<usize>> = vec![vec![]; a + 1];
    let mut cur = 1;
    for i in 0..a + 1 {
        for j in 0..i {
            let t = ans[j][i - 1];
            ans[i].push(t);
        }

        for _ in i..a {
            ans[i].push(cur);
            cur += 1;
        }

        print!("{}", ans[i].len());
        for j in 0..ans[i].len() {
            print!(" {}", ans[i][j]);
        }
        println!();
    }
}


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

int main() {
  int N,i,ans;
  
  cin >> N;
  i = N;

  while(i>0){
    ans += i%10;
    i /= 10;
  }
  
  if(N % ans == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<stack>
#include<algorithm>
#include<string>
#include<set>
#include<numeric>
#include<functional>
#include<unordered_map>
#include<cmath>
#include<cstdlib>
#include<cassert>

int main() {
	int A, B;
	char op;
	std::cin >> A >> op >> B;
	if (op == '+')
		std::cout << A + B << std::endl;
	else
		std::cout << A - B << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

#include <vector>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>

#include <climits>

using namespace std;

int calc( int num) {
	int count1 = 0;
	while (num > 0) {
		count1 = count1 + num % 10;
		num = num / 10;
	}

	return count1;
}


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

	int count = 1000000;

	for (int i = 1; i <n ;i++) {
		
		int a = n - i;
		int count1 = 0;
		
		count1 = calc(i)+calc(a);
		
		if (count > count1)count = count1;

	}

	cout << count << endl;

	return 0;

}

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

using namespace std;

#define ll long long

const int mxN = 3003;

int dp[mxN][mxN];
pair<int, int> pos[mxN][mxN];
pair<int, int> cur;
string s, t;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> s >> t;
    for (int i = 0; i <= int(s.length()); i++) {
        for (int j = 0; j <= int(t.length()); j++) {
            if (i == 0 || j == 0) {
                dp[i][j] = 0;
            } else {
                if (s[i - 1] == t[j - 1]) {
                    dp[i][j] = dp[i - 1][j - 1] + 1;
                    pos[i][j] = make_pair(i - 1, j - 1);
                } else if (dp[i][j - 1] > dp[i - 1][j]) {
                    dp[i][j] = dp[i][j - 1];
                    pos[i][j] = make_pair(i, j - 1);
                } else {
                    dp[i][j] = dp[i - 1][j];
                    pos[i][j] = make_pair(i - 1, j);
                }
            }
        }
    }

    //for (int i = 0; i <= int(s.length()); i++) { for (int j = 0; j <= int(t.length()); j++) { cout << pos[i][j].first << ' '; } cout << endl; }
    cur.first = s.length();
    cur.second = t.length();
    //make_pair(x, y) = make_pair(s.length(), t.length());
    //cout << dp[x][y] << ' ' << x << ' ' << y << ' ' << endl;
    string ans = "";
    while (cur.first + cur.second > 1) {

        ans = s[cur.first - 1] == t[cur.second - 1] ? s[cur.first - 1] + ans : ans;
        cur = pos[cur.first][cur.second];
    }
    cout << ans << endl;
}


Measured memory_bytes: 105856
#include <iostream>
using namespace std;
int main(){
int a,b,c,d;
int f=0;
cin >>a >>b >>c >>d;//体力a,c
while(true){
    c=c-b;//takahashiの攻撃
    if(c<=0){
        f=2; //a win 
        break;
    }
   a=a-d;//aokiの攻撃
    if(a<=0 ){
        f=1; //c win 
        break;
    }
}
if(f==2)cout <<"Yes" <<endl;
else if(f==1)cout <<"No"<<endl;
return 0;
}

Measured memory_bytes: 3624
n = int(input())
s = []
t = []
for _ in range(n):
	ar, time = map(str, input().split())
	s.append(ar)
	t.append(time)
x = input()
summ = 0
init = s.index(x)
for i in range(init+1, n):
	summ += int(t[i])
print(summ)

Measured memory_bytes: 3064