akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(){
  int d;  scanf("%d", &d);
  int c[30], s[370][30], t[370] = {0}, last[30] = {0};
  for(int i=1; i<=26; i++)  scanf("%d", c+i);
  for(int i=1; i<=d; i++)  for(int j=1; j<=26; j++)  scanf("%d", &s[i][j]);

  for(int i=1; i<=d; i++)  scanf("%d", t+i);

  long score = 0;
  for(int di=1; di<=d; di++){
    score = score + s[di][t[di]];
    last[t[di]] = di;
    for(int li=1; li<=26; li++)
      score = score - c[li]*(di-last[li]);
    printf("%ld\n", score);
  }


  return 0;
}


Measured memory_bytes: 1780
if __name__ == '__main__':
    # first_line = "15 10000000000"
    # lines = ["400000000 1000000000",
    #          "800000000 1000000000",
    #          "1900000000 1000000000",
    #          "2400000000 1000000000",
    #          "2900000000 1000000000",
    #          "3300000000 1000000000",
    #          "3700000000 1000000000",
    #          "3800000000 1000000000",
    #          "4000000000 1000000000",
    #          "4100000000 1000000000",
    #          "5200000000 1000000000",
    #          "6600000000 1000000000",
    #          "8000000000 1000000000",
    #          "9300000000 1000000000",
    #          "9700000000 1000000000"]
    # N, C = map(int, first_line.split())
    # values = [list(map(int, li.split())) for li in lines]

    N, C = map(int, input().split())
    values = [list(map(int, input().split())) for _ in range(N)]
    xs, vs = zip(*values)

    clock_cum = []
    clock_max = []
    aclock_cum = []
    aclock_max = []
    for i in range(N):
        if i == 0:
            cum_i = vs[i] - xs[i]
            max_i = max(0, cum_i)

            acum_i = vs[N - i - 1] - (C - xs[N - i - 1])
            amax_i = max(0, acum_i)
        else:
            cum_i = clock_cum[-1] + xs[i - 1] + vs[i] - xs[i]
            max_i = max(clock_max[-1], cum_i)

            acum_i = aclock_cum[-1] + (C - xs[N - i - 1 + 1]) + vs[N - i - 1] - (C - xs[N - i - 1])
            amax_i = max(aclock_max[-1], acum_i)

        clock_cum.append(cum_i)
        clock_max.append(max_i)
        aclock_cum.append(acum_i)
        aclock_max.append(amax_i)

    best = 0
    for i in range(N):
        if i != N - 1:
            # clock or clock -> return -> aclock
            best = max(best, clock_cum[i],
                       clock_cum[i] - xs[i] + aclock_max[N - i - 2])
            # aclock or aclock -> return -> clock
            best = max(best, aclock_cum[i],
                       aclock_cum[i] - (C - xs[N - i - 1]) + clock_max[N - i - 2])
        else:
            best = max(best, clock_cum[i])
            best = max(best, aclock_cum[i])

    print(best)


Measured memory_bytes: 40880
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2147483647
#define LINF 9223372036854775807
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;

using namespace std;

int n,m[111111];
int dp(int n){
    if(n<6)return n;
    if(m[n]!=-1)return m[n];
    int sum;
    vector<int> v;
    for(int i=0;pow(6,i+1)<=n;i++){
        sum=dp(n-pow(6,i+1))+1;
        v.push_back(sum);
    }
    for(int i=0;pow(9,i+1)<=n;i++){
        sum=dp(n-pow(9,i+1))+1;
        v.push_back(sum);
    }
    int min=INF;
    for(auto x:v){
        min=std::min(x,min);
    }
    //cout<<m[n]<<" "<<min<<endl;
    return m[n]=min;
    
}

signed main(){
    
    cin>>n;
    rep(i,n+2)m[i]=-1;
    cout<<dp(n)<<endl;
    
    
}

Measured memory_bytes: 2688
require 'pp'

n = gets.to_i
list = Array.new(10) { Array.new(10) }

(1..9).each do |c1|
  (1..9).each do |c2|
    digit = 1
    count = 0
    loop do
      if digit == 1
        next digit += 1 if c1 != c2
        break if c1 > n

        count += 1
        digit += 1
        next
      end
      if digit == 2
        num = c1 * 10 + 1
        break if num > n

        count += 1
        digit += 1
        next
      end

      min = c1 * 10 ** (digit - 1) + c2
      break if min > n

      max = c1 * 10 ** (digit - 1) + 10 ** (digit - 1) - 10 + c2
      if max > n
        max = n
        loop do
          break if max.to_s[-1] == c2.to_s

          max -= 1
        end
      end
      count += (max - min) / 10 + 1
      digit += 1
    end

    list[c1][c2] = count
  end
end
sum = 0
(1..9).each do |c1|
  (1..9).each do |c2|
    sum += list[c1][c2].to_i * list[c2][c1].to_i
  end
end
puts sum

Measured memory_bytes: 2044
import sys
n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n):
    a[i]=[a[i],i+1]

one=-1
ans=[]
a.sort(reverse=True)
for _ in range(k+1):
    a.sort(reverse=True)
    for j in range(n):
        if a[j][1]!=one:
            a[j][0]-=1
            ans.append(a[j][1])
    one=ans[-1]
    a.sort(reverse=True)

for x in a:
    if x[0]<0:
        print(-1)
        sys.exit()
print(len(ans))
print(*ans)

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

#define loop(i,n) for(int i=1;i<=n;i++)
int dp[202][202];
int t[202];
int a[202],b[202],c[202];

int main(){
  int d,n;
  cin>>d>>n;
  loop(i,d)cin>>t[i];
  loop(j,n)cin>>a[j]>>b[j]>>c[j];
  loop(i,d){
    if(i==1)continue;
    loop(j,n){
      if(t[i]<a[j]||b[j]<t[i])continue;
      loop(k,n){
        if(t[i-1]<a[k]||b[k]<t[i-1])continue;
        dp[i][j]=max(dp[i][j],dp[i-1][k]+abs(c[k]-c[j]));
      }
    }
  }
  int m=0;
  loop(j,n)m=max(m,dp[d][j]);
  cout<<m<<endl;
  return 0;
}

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

int main() {
	int n, a, b;
	cin >> n >> a >> b;
	if (n * a < b)  cout << n * a << endl;
	else cout << b << endl;
}

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

int main(){
    int h,w;
    cin >> h >> w;
    string sha(w+2,'#');
    vector<string> a(h);
    for (int i = 0;i < h;i++){
        cin >> a.at(i);
        a.at(i) = '#' + a.at(i) + '#';
    }
    cout << sha << endl;
    for (int i = 0;i < h;i++){
        cout << a.at(i) << endl;
    }
    cout << sha << endl;
}

Measured memory_bytes: 256
def main():
    # start coding here...
    N = int(input())
    a = []
    b = []
    for i in range(N):
        x,y = map(int,input().split())
        a.append(x+y)
        b.append(x-y)
    ans = max(max(a)-min(a),max(b)-min(b))
    print(ans)


if __name__ == "__main__":
    main()

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

int main() {
  ll n, x, m;
  cin >> n >> x >> m;
  vector<ll> r;
  set<ll> q;
  r.push_back(x);
  q.insert(x);
  while (1) {
    x = (x * x) % m;
    if (q.find(x) != q.end()) {
      ll ans = 0;
      while (r.front() != x) {
        ans += r.front();
        n--;
        r.erase(r.begin());
      }
      ll sum = 0;
      for (auto el : r) {
        sum += el;
      }
      ans += (n / r.size()) * sum;
      rep(i, n % r.size()) ans += r[i];
      cout << ans << endl;
      return 0;
    } else {
      r.push_back(x);
      q.insert(x);
    }
  }

  return 0;
}

Measured memory_bytes: 5828
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
// clang-format on

string s;

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

  for (int i = 0; i < s.size(); i++) {
    if ((i + 1) % 2 == 1) {
      cout << s[i];
    }
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 576
import java.io.*;
import java.util.*;
//import java.util.stream.*;;
//import java.math.*;

public class Main {

    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        Scanner sc = new Scanner(System.in);
        String s = br.readLine();
        StringBuilder str = new StringBuilder();
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == '0') {
                str.append("0");
            } else if (s.charAt(i) == '1') {
                str.append("1");
            } else if (str.length() - 1 >= 0 && str.toString() != null) {
                str.deleteCharAt(str.length() - 1);
            }
        }
        System.out.println(str.toString());
        bw.flush();
    }
}


Measured memory_bytes: 23252
n,k=list(map(int,input().split()))
a=list(map(int,input().split()))
b=10**10
c=[b]*n
c[0]=0
c[1]=abs(a[1]-a[0])
for i in range(n-1):
    for j in range(i+1,min(n,i+k+1)):
        c[j]=min(c[j],c[i]+abs(a[j]-a[i]))
c[-1]=min(c[-1],c[-2]+abs(a[-2]-a[-1]))
print(c[-1])

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

namespace ConsoleApp11
{
    class Class13
    {
        static void Main()
        {
            int X = int.Parse(Console.ReadLine());
            for (int i = 2; i < X / 2; i++)
            {
                if (X % i == 0)
                {
                    i = 1;
                    X++;
                }
            }
            Console.WriteLine(X);
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long
#define endl '\n'
using namespace std;
int dy[4] = {1, 0, -1, 0}, dx[4] = {0, 1, 0, -1};
typedef pair<int, int> P;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n >> s;

    int lb = 0, rw = 0;
    for (int i = 0; i < n; i++) {
        // 左の黒石の数を数える
        if (s[i] == '#') {
            lb++;
            // 右の白石 & 左の黒石が1以上のとき
            // 左の黒石-- 右の白石++
            // 左の黒石を白に，右の白石を黒にする
        } else if (s[i] == '.' && lb > 0) {
            lb--;
            rw++;
        }
    }
    cout << rw << endl;
    return 0;
}

Measured memory_bytes: 720
#include<stdio.h>
#include<math.h>

int isprime(int *,int);

#define N 10000

main(){
  int i,kazu,num[N],cnt=0;
  scanf("%d",&kazu);

  for(i=0;i<kazu;i++){
    scanf("%d",&num[i]);
    if(insprime(num[i])) ++cnt; 
}
  printf("%d\n",cnt);
  return 0;
}


int insprime(int x){
  int i;
  if(x == 2 || x == 3 )return 1;
  if(x<2 || x%2 == 0 )return 0;
  for(i = 3; i <= sqrt((double)x);i=i+2){
    if(x % i == 0) return 0;
  }
  return 1;
}

Measured memory_bytes: 628
#include <iostream>
#include <stdio.h>
#include <cmath>
using namespace std;

void solve()
{
	int rectCount = 0;
	int diamondCount = 0;
	int a, b, c;
	while(scanf("%d,%d,%d", &a, &b, &c) != EOF)
	{
		if(a * a + b * b == c * c)
		{
			++rectCount;
		}
		if(a == b)
		{
			++diamondCount;
		}
	}
	cout << rectCount << endl;
	cout << diamondCount << endl;
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1204
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	int N, A, B;
	cin >> N >> A >> B;
	cout << min(N * A, B) << endl;
}

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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

const ll INF = LLONG_MAX;
ll A, B, C, S;

ll solve(ll x)
{
	ll c = 0;
	while (true) {
		++c;
		ll nx = (S - x) / 2;
		if (nx == x) {
			return INF;
		}
		if (nx & 1) {
			break;
		}
		x = nx;
	}
	return c;
}

int main() {
	cin >> A >> B >> C;
	S = A + B + C;
	if (A % 2 || B % 2 || C % 2) {
		puts("0");
		return 0;
	}
	ll ans = min({solve(A), solve(B), solve(C)});
	if (ans == INF) {
		ans = -1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
function main() {
  var
  i = 0, j, flag,
  L, MN;
  for (;;) {
    L = Number(input[i++]);
    if (L === 0) break;
    
    flag = true;
    for (j = 0; j < 12; j++) {
      MN = input[i++].split(' ').map(Number);
      L -= MN[0] - MN[1];
      if (flag && L <= 0) {
        console.log(j + 1);
        flag = false;
      }
    }
    
    if (flag) console.log('NA');
  }
}

var
input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main();
});

Measured memory_bytes: 11832
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

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

    int N;
    ll T;
    cin >> N >> T;

    ll left = 0, right = T;
    ll sum = 0;
    for (int i = 0; i < N; ++i) {
        ll t;
        cin >> t;
        if (right < t) {
            sum += right - left;
            left = t;
        }
        right = t + T;
    }
    sum += right - left;

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, l;
  cin >> n >> l;
  
  vector<string> vec(n);
  for (int i = 0; i < n; i++) cin >> vec.at(i);
  
  sort(vec.begin(), vec.end());
  
  string ans;
  for (string x : vec) ans += x;
  
  cout << ans << endl;
}

Measured memory_bytes: 3664
import java.util.Scanner;

public class Main {
	
	static int n;
	static int[] preorder, inorder;
	//preorder(own, left, right)
	//inorder(left, own, right)
	//postorder(left, right, own)
	
	static void recover(int fp, int lp, int fi, int li) {
		int root=fi;
		for(int i=fi; i<li; i++) {
			if(preorder[fp]==inorder[i]) {
				root=i;
				break;
			}
		}
		if(fi<root) {//左側存在するなら表示
			recover(fp+1, fp+(root-fi)+1, fi, root);
		}
		if(root<li-1) {//右側存在するなら表示
			recover(fp+(root-fi)+1, lp, root+1, li);
		}
		if(inorder[root]==preorder[0]) {
			System.out.println(inorder[root]);
		}
		else {
			System.out.print(inorder[root]+" ");
		}
	}
	
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			n=sc.nextInt();
			preorder=new int[n];
			inorder=new int[n];
			for(int i=0; i<n; i++) {
				preorder[i]=sc.nextInt();
			}
			for(int i=0; i<n; i++) {
				inorder[i]=sc.nextInt();
			}
			recover(0, n, 0, n);

		}
	}
}


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

using namespace std;

template< class t>
long long int gcd( t g,t h )
{
    return ( h==0 ? g : gcd(h,g%h) );
}

int main() 
{
    ios_base::sync_with_stdio(false) ; cin.tie(0) ;
    
    long long int x,n,i,j,ans=0,neg=0,p[100005]={0},b[100005]={0},f[100005]={0},z[100005],mx=0;
    
    cin>>n;
    
    for(i=1;i<=n;i++)
    {
        cin>>p[i];
    }
    
    for(i=2;i<n;i++)
    {
        if(p[i-1]==i-1)
        {
            swap(p[i-1],p[i]);
            ans++;
        }
        else if(p[i]==i&&p[i+1]==i+1)
        {
            swap(p[i+1],p[i]);
            ans++;
        }
        else if(p[i]==i)
        {
            swap(p[i-1],p[i]);
            ans++;
        }
        
    }
    
    
        if(p[n]==n)
        {
            swap(p[n-1],p[n]);
            ans++;
        }
        
    cout<<ans;    
       
    
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    LL n;
    cin >> n;
    LL tmp = 1;
    for( int i = 1; i <= n; ++i ) {
        tmp = ( tmp * i ) % MOD;
    }

    cout << tmp << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>

#define FOR(i,a,b) for(long long int i = (a); i <(b);++i)
#define REP(i,n) FOR(i,0,n)
#define debug(x) cout << #x << " = " << x << endl;

using namespace std;

long long dp[100000];


int main(void){

    int N;
    cin >> N;
    dp[0] = 1;
    FOR(i,1,100000){
        dp[i] = dp[i-1] + (i+1);
    }

    REP(i,100000){
        if(dp[i] >= N){
            cout << i+1 << endl;
            return 0;
        }
    }
    
    return 0;
}


Measured memory_bytes: 1024
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

using namespace std;
#define f(i, n) for(int i = 0; i < n; ++i)
#define pb push_back
#define T int t = 0; cin >> t; while(t--)
#define b_e(a) a.begin(), a.end()
typedef long long ll;
typedef long double lld;
const ll mod = 1e9 + 7;
const ll mx = 2e6 + 5;

void input(){
   int n, k; 
   cin >> n >> k;
   int ans = 0;
   while(n > 0){
       ++ans;
       n /= k;
   }
   cout << ans << endl;

}
int main(){
    input();
    return 0;
}

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

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

int main(){
    int n,m;
    int cost[30][30];
    while(cin>>n>>m){
        if(n==0&&m==0)break;
        rep(i,30)rep(j,30)cost[i][j]=999999999;
        rep(i,m){
            int a,b,c,d;
            char ch;
            cin>>a>>ch>>b>>ch>>c>>ch>>d;
            a--,b--;
            cost[a][b] = c;
            cost[b][a] = d;
        }
        rep(l,n){
            rep(i,n){
                rep(j,n){
                    cost[i][j]=min(cost[i][j],cost[i][l]+cost[l][j]);
                }
            }
        }
        int a,b,c,d;
        char ch;
        cin>>a>>ch>>b>>ch>>c>>ch>>d;
        a--,b--;
        int sum=cost[a][b]+cost[b][a];
        cout<<c-d-sum<<endl;
    }
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <algorithm>
 
using namespace std;
 
int main(){
    int H,W;
    while(true){
        scanf("%d %d",&H,&W);
        if(H == 0 && W == 0) break;
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                if((i+j)%2 == 0) printf("#");
                else{
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
}


Measured memory_bytes: 2608
from subprocess import*
with open('Main.java','w')as f:f.write(r"""
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int c = Integer.parseInt(sc.next());
		int d = Integer.parseInt(sc.next());
		int e = Integer.parseInt(sc.next());
		int f = Integer.parseInt(sc.next());
		int water = 0;
		int sugar = 0;
		for (int i = 0; i <= f; i += 100 * a) {
			for (int j = 0; i + j <= f; j += 100 * b) {
				for (int k = 0; i + j + k <= f; k += c) {
					for (int l = 0; i + j + k + l <= f; l += d) {
						if ((k + l) * 100 <= e * (i + j)) {
							if ((water == 0 && sugar == 0)|| sugar * (i + j + k + l) < (k + l) * water) {
								water = i + j + k + l;
								sugar = k + l;
							}
						}
					}
				}
			}
		}
		System.out.println(water + " " + sugar);
	}
}
""")
call(('javac','Main.java'))
call(('java','Main'))

Measured memory_bytes: 106832
var i,n :integer;
    x,sum : real;
    t,u : char;
begin
  sum:=0;
  readln(n);
  for i := 1 to n do begin
    readln(x,t,u);
    if u = 'J' then sum:=sum+x else sum := sum + x*380000.0;
  end;
  writeln(sum)
end.

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a; i<b;i++)
#define N_MAX 100000
#define M_MAX 100000

int main() {
	int N, A[N_MAX], B[N_MAX], C[N_MAX], M;
	int P[M_MAX];
	int thcou[N_MAX+1]={0};
	
	scanf("%d%d" ,&N, &M);
	FOR(i, 0, M){
		scanf("%d", &P[i]);
	}
	FOR(i, 0, N-1){
		scanf("%d%d%d", &A[i], &B[i], &C[i]);
	}
	FOR(i, 0,M-1){
		int x=P[i], y=P[i+1];
		if(x>y)
			swap(x, y);
		x--;
		y--;
		thcou[x]++;
		thcou[y]--;
	}
	FOR(i,1,N){
		thcou[i] += thcou[i-1];
	}
	
	
	long long int ans=0;
	FOR(i, 0,N){
		ans += min((long long)A[i]*thcou[i], (long long)B[i]*thcou[i] + C[i]);
	}
	
	printf("%lld\n", ans);
	
	
	return 0;
}

Measured memory_bytes: 3148
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)
fun <T> Array<Array<T>>.print() {
    this.forEach {
        println(it.joinToString(" "))
    }
}

fun primeFactorization(_n: Long): List<Long> {
    var i = 2L
    var n = _n
    val table = mutableListOf<Long>()

    while (i * i <= n) {
        while (n % i == 0L) {
            n /= i
            table.add(i)
        }
        i++
    }

    if (n > 1) {
        table.add(n)
    }

    return table
}

fun calc(_n: Int): Int {
    var n = _n
    var i = 1
    var res = 0
    while (n > 0) {
        n -= i
        i++
        if (n >= 0) res++
    }
    return res
}

fun main() {
    val n = readLong()
    val factors = primeFactorization(n)

    factors.toSet().fold(0) { acc, num ->
        acc + calc(factors.count { it == num })
    }.let { println(it) }
}

Measured memory_bytes: 35608
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
struct FIO{FIO(){std::cin.tie(0);std::cout.tie(0);std::ios_base::sync_with_stdio(0);std::cout<<std::setprecision(15);}}fIO;
template<typename T> using V = std::vector<T>;
template<typename T> void fill(V<T>&v) { for(T&e:v) std::cin >> e; }
/*-*/

int main() {
	int n;
	std::cin >> n;
	V<lnt> l(n),r(n);
	rep(i,n) std::cin >> l[i] >> r[i];
	std::sort(l.rbegin(),l.rend());
	std::sort(all(r));
	lnt ans=0;
	lnt max=0;
	rep(i,n) {
		if(l[i]-r[i]>0) {
			ans+=2*l[i]-2*r[i];
			max=std::max({max,ans,ans+2*r[i],ans-2*l[i]});
		} else {
			ans+=2*l[i]-2*r[i];
			max=std::max({max,ans,ans+2*r[i],ans-2*l[i]});
			break;
		}
	}
	print(max);
}


Measured memory_bytes: 4752
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

int gcd(int m, int n)
{
	if(n == 0) return m;
	return gcd(n, m % n);
}

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	int gcd_ab = gcd(a, b);
	if(c % gcd_ab == 0) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

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

using namespace std;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define debug(x) cout << #x << ":" << x << endl;
#define debug2(x) for(auto a : x) cout << a << " "; cout << endl;
#define debug3(x) rep(i, sizeof(x)) cout << x[i] << " "; cout << endl;

vector<pii> around = {MP(1, 0), MP(-1, 0), MP(0, 1), MP(0, -1)};

//------------------------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    ll k;
    cin >> k;

    rep(i, k) {
        if (s[i] != '1') {
            cout << s[i] << endl;
            return 0;
        }
    }
    cout << 1 << endl;
    return 0;
}



Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import itertools
import numpy as np

N = int(readline())
XY = [[] for _ in range(N)]
for i in range(N):
    A = int(readline())
    for _ in range(A):
        x,y = map(int,readline().split())
        XY[i].append((x-1,y))

A = np.array(list(itertools.product([0,1],repeat=N)),np.bool)

for i in range(N):
    for x,y in XY[i]:
        bl = (~A[:,i]) | ((A[:,x]) == bool(y))
        A = A[bl]

answer = A.sum(axis = 1).max()
print(answer)


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

int gcd(int a, int b){
    int _gcd;

    if(a%b != 0){
        gcd(b, a%b);
    }

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

int main(){
    int N;
    int ans;
    std::cin >> N;

    std::vector<int> A(N);
    
    for(auto& e : A){
        std::cin >> e;
    }

    ans = A[0];

    for(int i = 0; i < N-1; ++i ){
        ans = gcd(ans, A[i+1]);
    }

    std::cout << ans << std::endl;;

    return 0;
}

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

using namespace std;

#define all(x) x.begin(), x.end()
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long ll;

const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;

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

  	int a,b,c;
    cin >> a >> b >> c;
    int sol = a-b;
    c-=sol;
    cout << max(c, 0);
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int n;
  cin >> n;
  vi32 a(n);
  cin >> a;
  vi32 sa = a;
  sort(all(sa));
  int diff = 0;
  rep(i, n) {
    int x = a[i];
    int j = lower_bound(all(sa), x) - sa.begin();
    if (abs(i - j) & 1) diff++;
  }
  cout << diff / 2 << endl;
}


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

#define FOR(i, m, n) for(int (i) = (m); (i) < (n); (i)++)
#define FORN(i, m, n) for(int (i) = (m); (i) <= (n); (i)++)
#define FORR(i, m, n) for(int (i) = (m); (i) >= (n); (i)--)
#define rep(i, n) FOR(i, 0, n)
#define repn(i, n) FORN(i, 1, n)
#define repr(i, n) FORR(i, n, 0)
#define repnr(i, n) FORR(i, n, 1)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define setp(n) cout << fixed << setprecision(n);
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> Vec;

const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

int main(void){
	int h, w, k;
	cin >> h >> w >> k;

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

	vector<Vec> ans(h, Vec(w));
	ll cnt = 0;
	rep(i, h){
		bool flg = true;
		rep(j, w) if(board[i][j] == '#') flg = false;
		if(flg){
			if(!i) rep(j, w) ans[i][j] = 0;
			else rep(j, w) ans[i][j] = ans[i-1][j];
		}else{
			cnt++;
			bool mono = true;
			rep(j, w){
				if(board[i][j] == '#'){
					if(mono) mono = false;
					else cnt++;
				}
				ans[i][j] = cnt;
			}
		}
	}

	repr(i, h-1) rep(j, w) if(!ans[i][j]) ans[i][j] = ans[i+1][j];

	rep(i, h){
		rep(j, w) cosp(ans[i][j]);
		cout << endl;
	}

	return 0;
}


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

using namespace std;

const int N = 1234567;

char s[N], t[N];
int ss[N], tt[N];
int q;

int main() {
  scanf("%s %s %d", s, t, &q);
  for (int i = 0; s[i]; i++) ss[i + 1] = ss[i] + s[i] - 'A' + 1;
  for (int i = 0; t[i]; i++) tt[i + 1] = tt[i] + t[i] - 'A' + 1;
  while (q--) {
    int a, b, c, d; scanf("%d %d %d %d", &a, &b, &c, &d);
    int sss = ss[b] - ss[a - 1];
    int ttt = tt[d] - tt[c - 1];
    sss %= 3;
    ttt %= 3;
    printf("%s\n", sss == ttt ? "YES" : "NO");
  }
  return 0;
}

Measured memory_bytes: 5120
#include <iostream>

using namespace std;

int main() {
  string a, b, c;
  cin >> a >> b >> c;
  if (a[a.length() - 1] == b[0] && b[b.length() - 1] == c[0]) cout << "YES";
  else cout << "NO";
  cout << '\n';
  return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;
const int N=200000;
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	long long b,maxis=-1e9,a,n,i,j,dp[N],slot;
	cin>>n>>slot;
	for(i=0;i<n;++i){
		cin>>a>>b;
		for(j=slot;j>=a;--j){
			dp[j]=max(dp[j],dp[j-a]+b);
		}
	}
	for(i=0;i<=slot;++i) maxis=max(maxis,dp[i]);
	cout<<maxis;
}

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

using namespace std;

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;


int main()
{

	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n,k;
	cin >>n >>k;
	VI x(n), y(n);
	rep(i,n) cin >> x[i] >>y[i];
	vector<pii> xy(n);
	rep(i,n) xy[i] = pii(x[i],y[i]);
	sort(all(xy));
	
	vector<ll> xx(n), yy(n);
	rep(i,n) xx[i] = x[i];
	rep(i,n) yy[i] =y[i];
	sort(all(xx));
	sort(all(yy));
	xx.erase(unique(all(xx)), xx.end());
	yy.erase(unique(all(yy)), yy.end());
	ll ans =1LL<<62;
	rep(i,sz(xx)) rep2(j,i, sz(xx)){
		rep(iy,sz(yy)) rep2(jy,iy,sz(yy)){
			int sm =0;
			rep(k,n){
				if(xx[i] <= xy[k].first && xy[k].first <= xx[j] &&
				   yy[iy] <= xy[k].second && xy[k].second <= yy[jy]) sm++;
			}
			if(sm >=k){
				ans = min(ans, ((ll)xx[j]-xx[i])*((ll)yy[jy]-yy[iy]));
				//printf("%d:%d:%d:%d  \n",xx[i],xx[j],yy[iy],yy[jy]);
			} 
		}
	}
	
	cout << ans <<"\n";
	return 0;

}


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

using i64 = long long;
using P   = pair<i64, i64>;

#define overload3(_1, _2, _3, name, ...) name
#define rep1(i, n) for(i64 i = 0LL; i < (n); ++i)
#define rep2(i, a, b) for(i64 i = (a); i < (b); ++i)
#define rep(...) overload3(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define all(v) v.begin(), v.end()

const long long mod = 1000000007;

// N! - !9 - !0 + !09

void solve(long long N) {
    i64 ans              = 1;
    rep(i, 1, N + 1) ans = (ans * 10) % mod;
    i64 s                = 1;
    rep(i, 1, N + 1) s   = (s * 9) % mod;
    ans                  = (ans - 2 * s + 2 * mod) % mod;
    s                    = 1;
    rep(i, 1, N + 1) s   = s * 8 % mod;
    ans                  = (ans + s) % mod;
    cout << ans << endl;
}

struct IoSetup {
    IoSetup() {
        // cin.tie(nullptr);
        // ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

int main() {
    long long N;
    scanf("%lld", &N);
    solve(N);
    return 0;
}


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

int N;
string S;

int main() {
    cin >> N >> S;
    vector<bool> animal(N + 1); //true: 羊, false: 狼
    for (int i = 0; i < 4; i++) {
        animal[0] = i & 1; animal[1] = (i >> 1) & 1;
        for (int j = 1; j < N; j++) {
            bool tmp = animal[j];
            if ((tmp && S[j] == 'o') || (!tmp && S[j] == 'x')) {
                animal[j + 1] = animal[j - 1];
            } else {
                animal[j + 1] = !animal[j - 1];
            }
        }
        if (animal[N] != animal[0]) {
            continue;
        }
        
        bool last;
        if ((animal[0] && S[0] == 'o') || (!animal[0] && S[0] == 'x')) {
            last = animal[1];
        } else {
            last = !animal[1];
        }
        if (last == animal[N - 1]) {
            for (int k = 0; k < N; k++) {
                cout << (animal[k]? 'S': 'W');
            }
            cout << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}



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

int main(){
    int N,M;
    int foods[40] = {0};
    cin >> N >> M;
    for(int i=0;i<N;++i){
        int K,A;
        cin >> K;
        for(int j=0;j<K;++j){
            cin >> A;
            foods[A]++;
        }
    }

    int ans = 0;
    for(int i=0;i<M+1;++i){
        if(foods[i]==N) ans++;
    }
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 256
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll rr, cc, k;
    cin >> rr >> cc >> k;
    vector<vector<ll>> m(rr, vector<ll>(cc, 0));
    rep(i, k)
    {
        ll temp, temp1, temp2;
        cin >> temp >> temp1 >> temp2;
        temp--;
        temp1--;
        m[temp][temp1] = temp2;
    }
    vector<vector<vector<ll>>> dp(rr, vector<vector<ll>>(cc, vector<ll>(4, 0)));
    rep(i, rr)
    {
        rep(j, cc)
        {
            rep(h, 4)
            {
                if (i + 1 < rr)
                {
                    if (h != 3)
                        chmax(dp[i + 1][j][0], dp[i][j][h] + m[i][j]);
                    else
                        chmax(dp[i + 1][j][0], dp[i][j][h]);
                }
                if (j + 1 < cc)
                {
                    chmax(dp[i][j + 1][h], dp[i][j][h]);
                    if (h != 3&&m[i][j]!=0)
                        chmax(dp[i][j + 1][h + 1], dp[i][j][h] + m[i][j]);
                }
            }
        }
    }
    ll ans = 0;
    rep(i, 4)
    {
        if(i==3)
        chmax(ans, dp[rr - 1][cc - 1][i]);
        else{
            chmax(ans, dp[rr - 1][cc - 1][i]+m[rr-1][cc-1]);
        }
    }
    cout << ans << "\n";
}


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

int main(){
	string s;
	cin >> s;
	char a[3];
	int sum = 0;
	for(int bit = 0; bit < (1<<3); bit++){
		sum =(s[0] - '0');
		for(int i = 0; i <3; i++){
			if(bit & (1<<i)){
				sum -= (s[i+1]-'0');
				a[i] = '-';
			}
			else{
				sum += (s[i+1]-'0');
				a[i] = '+';
			}
		}
		if(sum == 7){
			cout << s[0] << a[0] << s[1] << a[1] << s[2] << a[2] << s[3] << "=7" << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 256
#include<stdio.h>

int ans;

void swap_(int *f, int *b) {
    int temp;
    temp = *f;
    *f = *b;
    *b = temp;
    ans++;
}

void bSort(int arr[], int n) {

    for(int i = 0; i < n-1; i++) {
        for(int j = 0; j < n-i-1; j++) {
            if ( arr[j] > arr[j+1])
                swap_(&arr[j], &arr[j+1]);
        }
    }
    return;
}


int main() {

    int n;
    int arr[100+5];
    scanf("%d", &n);
    for(int i = 0; i < n; i++) scanf("%d", &arr[i]);
    bSort(arr, n);
    for(int i = 0; i < n ; i++) {
        if( i > 0 ) printf(" ");
        printf("%d", arr[i]);
    }
    printf("\n%d\n", ans);
    return 0;
}



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

using namespace std;

#define pb push_back
#define F first
#define S second
#define ALL(v) v.begin(),v.end()
#define fast_cin() ios_base::sync_with_stdio(0)


typedef long long ll;
typedef long double ld;
typedef pair <ll,ll> pll;
typedef pair <int,int> pii;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

bool bit(int n, int i) { return (n >> i) & 1; }
int faltu;

const int mod = 1e9+7;
const ll MAX = 4e18;
const ll MIN = -MAX;
const int imax = 2e9 + 100;


int main()
{
	time_t t1, t2;
	t1 = clock();

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

	ll ans = 0;
	for(auto &x: mp) {
		if(x.F > x.S) {
			ans += x.S;
		} else if(x.F < x.S) {
			ans += x.S - x.F;
		}
	}
	cout << ans << endl;

	t2 = clock();
	cerr << "time taken: " << t2 - t1 << endl;
	return 0;
}

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

signed main(){
	int N;cin>>N;
	bool pro=true;
	for(int i=0;i<N;i++){
		int a ;cin>>a;
		if(a%2==0){
			if(a%3!=0 && a%5!=0){
				pro=false;
				break;
			}
		}
	}
	cout<<( (pro) ? "APPROVED" : "DENIED")<<endl;

}


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

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

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

# define EPS (1e-7)
# define INF (1e9)
# define PI (acos(-1))
//const ll mod = 1000000007;

int N;
unordered_map<string, int> mp;

int main() {
    cin >> N;
    ll ans = 0;
    for (int i = 0; i < N; ++i) {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        if (mp.find(s) != mp.end()) {
            ans += mp[s];
            mp[s]++;
        } else {
            mp[s] = 1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10660
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

vector<string> split_naive(const string &s, char delim) {
    vector<string> elems;
    string item;
    for (char ch: s) {
        if (ch == delim) {
            if (!item.empty())
                elems.push_back(item);
            item.clear();
        }
        else {
            item += ch;
        }
    }
    if (!item.empty())
        elems.push_back(item);
    return elems;
}

int main() {
	string s;
	cin >> s;
	
	int num = pow(2, s.length() - 1);
	unsigned long long ans = stoull(s.c_str());
	
	for(int i = 1; i < num; i++){
		int tmp = i;
		int count = 1;
		int len = s.length();
		string sTmp = s;
		do{
			if(tmp % 2 == 1){
				sTmp.insert(len - count, "+");
			}
			tmp /= 2;
			count++;
		}while(tmp > 0);
		vector<string> plus = split_naive(sTmp, '+');
		for(int i = 0; i < plus.size(); i++){
			ans += stoull(plus[i].c_str());
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

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

int main(){
  int n,k;
  cin >> n >> k;
  int max = n-k+1;
  int min = 1;
  if(k == 1){
    cout << 0 << endl;
  }
  else{
    cout << max - min << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>

typedef long double ld;
typedef long long ll;

using namespace std;

#define MAXN (1 << 10)

int n;
int a[MAXN];

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int best = MAXN * MAXN * MAXN;
	for (int i = 0; i <= 100; i++) {
		int cur = 0;
		for (int j = 0; j < n; j++) {
			cur += (i - a[j]) * (i - a[j]);
		}
		best = min(best, cur);
	}
	cout << best << endl;

	return 0;
}


Measured memory_bytes: 3132
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

int main()
{
	int n;
	cin >> n;
	cout << n * 800 - (n / 15) * 200 << endl;
	return 0;
}




Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int main(){
	long a,b;
	cin>>a>>b;
	if((a+b)%2==0){
		cout<<(a+b)/2;
	}else{
		cout<<"IMPOSSIBLE";
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}

ll mpow(ll x, ll n){//nCrにmodをかけるやり方
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x%mod;
        x = x*x%mod;
        n = n>>1;
    }
    return ans;
}

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

    vector<ll> a(K-1+1), comb_a(K-1+1), b(N-K+1+1), comb_b(N-K+1+1);
    comb_a[0] = 1;
    comb_b[0] = 1;
    for (ll j=1;j<=K-1;j++){
        a[j] = mpow(j, mod-2);//(n!)^(-1)=(n!)^(p-2)mod(1e9);
        comb_a[j] = (comb_a[j-1]*(K-1-j+1)%mod)*a[j]%mod;//K-1Ci-1
    }
    for (ll j=1;j<=N-K+1;j++){
        b[j] = mpow(j, mod-2);//(n!)^(-1)=(n!)^(p-2)mod(1e9);
        comb_b[j] = (comb_b[j-1]*(N-K+1-j+1)%mod)*b[j]%mod;//N-K+1Ci
    }

    for (ll i=1;i<=K;i++){
        ll ans = comb_a[i-1];
        if (i <= N-K+1){
            ans *= comb_b[i];
            ans %= mod;
        }
      else{
        ans = 0;
      }
        cout << ans << endl;
    }

}

Measured memory_bytes: 256