akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

public class Main {
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    static FastReader s = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);

    private static int[] rai(int n) {
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = s.nextInt();
        }
        return arr;
    }

    private static int[][] rai(int n, int m) {
        int[][] arr = new int[n][m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                arr[i][j] = s.nextInt();
            }
        }
        return arr;
    }

    private static long[] ral(int n) {
        long[] arr = new long[n];
        for (int i = 0; i < n; i++) {
            arr[i] = s.nextLong();
        }
        return arr;
    }

    private static long[][] ral(int n, int m) {
        long[][] arr = new long[n][m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                arr[i][j] = s.nextLong();
            }
        }
        return arr;
    }

    private static int ri() {
        return s.nextInt();
    }

    private static long rl() {
        return s.nextLong();
    }

    private static String rs() {
        return s.next();
    }
    static int gcd(int a,int b)
    {
        if(b==0)
        {
            return a;
        }
        return gcd(b,a%b);
    }


    public static void main(String[] args) {
        StringBuilder ans = new StringBuilder();
//        int t = ri();
        int t=1;
        while (t-- > 0) {
            char[] arr=rs().toCharArray();
            long sum=0;
            for(char c:arr)
            {
                sum+=c-'0';
            }
            if(sum%9==0)
            {
                ans.append("Yes\n");
            }
            else
            {
                ans.append("No\n");
            }
        }
        out.print(ans.toString());
        out.flush();

    }

}


Measured memory_bytes: 29920
NN = 18
N = int(input())
A = [int(a) for a in input().split()]

def chk(k):
    s = 0
    c = 0
    BIT=[0]*(2**NN+1)
    def add(i, x=1):
        i += 1 << NN - 1
        while i <= 2**NN:
            BIT[i] += x
            i += i & (-i)

    def getsum(i):
        ret = 0
        i += 1 << NN - 1
        while i != 0:
            ret += BIT[i]
            i -= i&(-i)
        return ret
    add(0)
    for i in range(N):
        if A[i] >= k:
            s += 1
        else:
            s -= 1
        c += getsum(s)
        add(s)
    if 4 * c >= N * (N+1):
        return 1
    return 0

l, r = 0, 1<<30
while r - l > 1:
    m = (l+r) // 2
    if chk(m):
        l = m
    else:
        r = m
print(l)


Measured memory_bytes: 118616
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(i, a) for (auto &i: (a))
#define sz(x) (int)(x).size()
#define all(v) (v).begin(), (v).end()
#define fr(i, a, b) for (int i = (a); i <= (b); ++i)
 

 
signed main () {
    clock_t beg = clock();
    cout << fixed << setprecision(15);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    #endif 
    int a;
    cin>>a;
    // int mod = 1000000000 +7;
    // at any state we have no ofheads
    vector<double> dp(a+1);
    dp[0]=1;//probability of o heads is 1;
    for(int i=0;i<a;i++){
        double phead;
        cin>>phead;
        for(int coin= i+1;coin>=0;coin--){
            dp[coin]= (coin==0? 0 :dp[coin-1]*(phead))+ dp[coin]*(1-phead);
        }
    }
    int number = a/2;
    double ans=0;
    for(int heads=0;heads<=a;heads++ ){
        int tails= a-heads;
        if( heads>tails){
            ans+=dp[heads];
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3784
#include <stdio.h>
int main(){
  int k,x;
  scanf("%d%d",&k,&x);
  for (int i=x-k+1;i<k+x;i++){
    printf("%d",i);
    if (i==k+x-1) printf("\n");
    else printf(" ");
  }
  return 0;
}


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

int main(){
  int n; cin >> n;
  vector<ll> ball(200005);
  vector<int> a(n);
  rep(i, n){
    cin >> a[i];
    ball[a[i]] ++;
  }
  
  ll sum = 0;
  rep(i, 200005){
    sum += ball[i]*(ball[i]-1)/2;
  }
  
  rep(i, n){
    ll ans = sum - ball[a[i]] + 1;
    cout << ans << endl;
  }

  return 0;
}


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

#define f first
#define s second
#define mp make_pair
#define all(x) x.begin(), x.end()

#define EPS 1e-9

#define X real()
#define Y imag()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using vi = vector<int>;
using ii = pair<int, int>;
using vii = vector<ii>;
using point = pair<double, double>;
using Vector = complex<double>;
int main() {

	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n, m;
	cin >> n >> m;
	vi wa(n + 1, 0), ac(n + 1, 0);
	for(int k = 0; k < m; ++k) {

		int p;
		string s;
		cin >> p >> s;
		if(s == "AC") ++ac[p];
		else if(!ac[p]) ++wa[p];
	}
	int ac_count = 0, penalty = 0;
	for(int k = 1; k <= n; ++k) {
		if(ac[k]) ++ac_count, penalty += wa[k];
	}
	cout << ac_count << ' ' << penalty << '\n';
    return 0;
}


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

namespace ABC_Training
{
    public class Program
    {
        static void Main(string[] args)
        {
            var a1 = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var a2 = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var a3 = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            int[][] a = new int[3][];

            a[0] = a1;
            a[1] = a2;
            a[2] = a3;

            var n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                var b = int.Parse(Console.ReadLine());
                for (int j = 0; j < 3; j++)
                {
                    for (int k = 0; k < 3; k++)
                    {
                        if (a[j][k] == b)
                        {
                            a[j][k] = 0;
                        }
                    }
                }
            }
            var ans = false;

            if (a[0][0] == 0 && a[0][1] == 0 && a[0][2] == 0)
            {
                ans = true;
            }
            if (a[1][0] == 0 && a[1][1] == 0 && a[1][2] == 0)
            {
                ans = true;
            }
            if (a[2][0] == 0 && a[2][1] == 0 && a[2][2] == 0)
            {
                ans = true;
            }
            if (a[0][0] == 0 && a[1][0] == 0 && a[2][0] == 0)
            {
                ans = true;
            }
            if (a[0][1] == 0 && a[1][1] == 0 && a[2][1] == 0)
            {
                ans = true;
            }
            if (a[0][2] == 0 && a[1][2] == 0 && a[2][2] == 0)
            {
                ans = true;
            }

            if (a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0)
            {
                ans = true;
            }

            if (a[2][0] == 0 && a[1][1] == 0 && a[0][2] == 0)
            {
                ans = true;
            }

            Console.WriteLine(ans ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 13396
using System;

namespace ABC056_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var X = int.Parse(Console.ReadLine());

            var i = 0;
            var sum = 0;
            while (sum < X)
            {
                i++;
                sum += i;
            }
            Console.WriteLine(i);
        }
    }
}


Measured memory_bytes: 13140
import qualified Data.ByteString.Char8 as BS

main :: IO ()
main = do
  [h,w] <- map (read . BS.unpack) . BS.words <$> BS.getLine :: IO [Int]
  lines <- sequenceA (replicate h BS.getLine)  :: IO [BS.ByteString]
  put lines
  
put :: [BS.ByteString] -> IO ()
put [] = return ()
put (b:bs) = do 
  sequenceA (replicate 2 (BS.putStrLn b))  
  put bs


Measured memory_bytes: 636
#include <iostream>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <vector>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstdio>
using namespace std;
int main(){
int a;
cin>>a;
int c=a;
int b=0;
for(int i=0;i<10;i++){
b+=a%10;
a=a/10;}
if(c%b==0)
cout<<"Yes";
else
cout<<"No";
system("pause");
return 0;
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define gcd __gcd
#define all(x) (x).begin(), (x).end()
template<class T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<class T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
const int INF = 1e18, MOD = 1e9 + 7;
signed main() {
    INCANT;
    int w, h, res = 0;
    cin>>w>>h;
    set<string> v;
    string s, c;
    bool f;
    rep(i, h){
        s = "";
        rep(j, w){
            cin>>c;
            s += c;
        }
        f = v.insert(s).second;
        if(f && v.size() == 3){
            cout<<"no"<<endl;
            return 0;
        }
    }
    if(v.size() == 1){
        cout<<"no"<<endl;
        return 0;
    }
    s = *v.begin();
    c = *++v.begin();
    if(count(all(s), '0') + count(all(c), '0') == w && (count(all(s), '0') == w / 2 || count(all(c), '0') == w / 2)) {
        rep(i, w){
            if(s[i] == c[i]){
                cout<<"no"<<endl;
                return 0;
            }
        }
        cout<<"yes"<<endl;
    }else{
        cout<<"no"<<endl;
    }
}



Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
#define ff        first
#define ss        second
#define ll        long long
#define int       long long
#define inf       ((ll)1e18)
#define mod       1000000007
#define double    long double
#define ull       unsigned long long
#define vi        vector<ll>
#define ppi       pair<int,int>
#define pii       pair<pair<int,int>,int>
#define pb        push_back
#define pi        2*acos(0.0)
#define rev       greater<int>()
#define pr(a,x,y) for(int i=x;i<y;i++){cout<<a[i]<<" ";}
#define ps(s)     for(auto i:s){cout<<i<<" ";}
#define sp(x,y)   fixed<<setprecision(y)<<x
#define w(x)      ll x; cin>>x; while(x--)
#define all(v)    v.begin(), v.end()
#define rall(v)   v.rbegin(), v.rend()
#define test      cout<<"This is test"<<endl;
#define str       string
#define endl      '\n'
#define e         cout<<'\n';
void kehsihba(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	/*#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif*/
}
void solve(){
	ll n;cin>>n;
	ll a[n];for(int i=0;i<n;i++){cin>>a[i];}
	ll b[n]={0};
	for(int i=1;i<n;i++){
		if(a[i-1]>=a[i]){b[i]=1;}
	}
	int ans=0,c=0;
	for(int i=0;i<n;i++){
		if(b[i]){c+=1;}
		else{ans=max(ans,c);c=0;}
		ans=max(ans,c);
	}
	ans=max(ans,c);
	cout<<ans;
}
int32_t main(){
	kehsihba();
	//init();
	ll t=1;
	//cin>>t;
	for(int k=1;k<=t;k++){
		//cout<<"Case "<<k<<": ";
		solve();
		//e;
	}
}

Measured memory_bytes: 5164
#include<bits/stdc++.h>
#include<stdio.h>
    
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define _USE_MATH_DEFINES
#define f first
//#define s second
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define INF 1000000000000000000
#define MAXN (int)(1e7)+1
#define MOD 1000000007
    
using namespace std;
    
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,int> pwi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vector<pair<ll,ll > > > wGraph;
typedef vector<vector<ll> > graph;
//typedef vector<vector<ll> > matrix;
    
    
    
int main(){
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout<<std::fixed;
    cout<<std::setprecision(2);
    
    int N, X, T;

    cin>>N>>X>>T;

    cout<<(N/X)*T + min(N%X, 1)*T<<endl;
    
    return 0;   
}

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

int main() {

  vector<long long int> num;
  long long int input;

  while( cin >> input ) {

    if ( input != 0 ) {

      num.push_back(input);

    }else {

      cout << num[ num.size()-1 ] << endl;
      num.pop_back();

    }

  }

  return 0;

}

Measured memory_bytes: 1212
#include <stdio.h>

int main()
{

 int H, W, i, j;
 while(1)
 {
     scanf("%d %d\n", &H, &W);
     if(H == 0 && W == 0)
     {
         break;
     }

     for(i = 0; i < H; i++)
     {
         for(j = 0; j < W; j++)
         {
             if(i == 0 || j == 0 || i == H - 1 || j == W -1)
             {
                 printf("#");
             }
             else
             {
                 printf(".");
             }
         }
         printf("\n");
     }
     printf("\n");
 }
 return 0;
}

Measured memory_bytes: 576
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a =sc.nextInt();
        int b = sc.nextInt();
        int c =sc.nextInt();
        int d = sc.nextInt();

        System.out.println(Math.max(a*b,c*d));

    }
}


Measured memory_bytes: 21588
#include<iostream>

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

using namespace std;

using ll = long long;
using P = pair<int , int>;
  
int main() {
  double r, p = 6.283185307179586232/2; cin >> r;
  cout << r * 2 * p << endl;
}


Measured memory_bytes: 3776
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>

using namespace std;

struct before_main{before_main(){cin.tie(0); ios::sync_with_stdio(false);}} before_main;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

int main() {

  int t; string num;
  for(; cin >> t >> num;) {
    if(t == 0 && num == "0") { break; }
    if(t == stoi(num)) {
      cout << t << " " << t << endl;
      continue;
    }

    int n = num.size();

    int asum = -1;
    int dcnt = 0;
    deque<int> part;
    std::function<void(int, int, deque<int>&)> divide = [&](int x, int idx, deque<int>& dl) {
      if(idx == n) {
        if(t >= x) {
          if(maximize(asum, x)) {
            dcnt = 0;
            part = dl;
          } else {
            if(asum == x) {
              dcnt ++;
            }
          }
        }
        return;
      }

      REP(i, idx, n) {
        dl.push_back(i+1);
        divide(x + stoi(string(num.begin() + idx, num.begin() + i+1)), i+1, dl);
        dl.pop_back();
      }
    };

    deque<int> dl = {0};
    divide(0, 0, dl);

    if(dcnt > 0) {
      cout << "rejected" << endl;
    }
    else if(asum == -1) {
      cout << "error" << endl;
    }
    else {
      cout << asum;
      rep(i, part.size()-1) {
        cout << " " << string(num.begin() + part[i], num.begin() + part[i+1]);
      }
      cout << endl;
    }

  }
  
  return 0;
}

Measured memory_bytes: 3164
from itertools import combinations
n, k = map(int, input().split())
xy = []
xx = []
yy = []
for _ in range(n):
    x, y = map(int, input().split())
    xy.append((x, y))
    xx.append(x)
    yy.append(y)
xx.sort()
yy.sort()
ans = 10**20
for x1, x2 in combinations(xx, 2):
    for y1, y2 in combinations(yy, 2):
        tmp = 0
        for x, y in xy:
            if x1<=x<=x2 and y1<=y<=y2:
                tmp += 1
        if tmp<k:
            continue
        ans = min(ans, (x2-x1)*(y2-y1))
print(ans)

Measured memory_bytes: 74140
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 200005

ll N,K;
ll A[SIZE];
ll F[SIZE];

int main(){

	scanf("%lld %lld",&N,&K);

	for(int i = 0; i < N; i++){

		scanf("%lld",&A[i]);
	}
	for(int i = 0; i < N; i++){

		scanf("%lld",&F[i]);
	}

	if(N == 1){

		printf("%lld\n",F[0]*max(0LL,A[0]-K));
		return 0;
	}

	sort(A,A+N);
	sort(F,F+N);

	ll left = 0,right = HUGE_NUM,mid = (left+right)/2;
	ll ans = HUGE_NUM;

	while(left <= right){

		ll tmp = 0;

		for(int i = 0; i < N; i++){

			ll a = A[i];
			ll f = F[N-1-i];

			if(a*f <= mid)continue;

			tmp += a-mid/f;
		}

		if(tmp <= K){

			ans = mid;
			right = mid-1;

		}else{

			left = mid+1;
		}
		mid = (left+right)/2;
	}

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

	return 0;
}


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

int main(){
  int N;
  cin >> N;
  int max,count=1;
  cin >> max;
  for(int i=1; i<N; i++){
    int h;
    cin >> h;
    if(max<=h){
      count++;
      max=h;
    }
  }
  cout << count << endl;
  return 0;
}

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

int n,m,goal,d;

int check(vector<int>line,vector<string>path)
{
  int i,j;
  for(i=0;i<d;i++)
    for(j=0;j<n-1;j++)
      if(path[i][j]=='1')swap(line[j],line[j+1]);
  return line[goal-1]==m;
}

int main()
{
  int f,i,j;
  vector<int> line;
  vector<string> path;
  while(cin>>n,n){
    cin>>m>>goal>>d;
    line.resize(n);
    path.resize(d);
    for(i=0;i<n;i++)line[i]=i+1;
    for(i=0;i<d;i++)cin>>path[i];
    f=check(line,path)*2;
    for(i=0;!f && i<d;i++){
      for(j=0;!f && j<n-1;j++){
	if(path[i][j]=='1')continue;
	if(0<j && path[i][j-1]=='1')continue;
	if(j<n-1 && path[i][j+1]=='1')continue;
	path[i][j]='1';
	f=check(line,path);
	path[i][j]='0';
      }
    }
    if(f==2)puts("0");
    else if(f==0)puts("1");
    else cout<<i<<" "<<j<<endl;
  }
}

Measured memory_bytes: 0
N = int(input())
sMap = {}
sList = []

for i in range(N):
    s = input()
    if s  not in sMap:
        sMap[s] = len(sList)
        sList.append([1, s])
    else:
        num = int(sMap[s])
        sList[num][0] = sList[num][0] + 1
    #print(sList)

sList.sort(reverse=True)
max = sList[0][0]
#print(sList)
ansList = []
for s in sList:
    if s[0] != max:
        break
    ansList.append(s[1])

#print(ansList)
ansList.sort()
ans = '\n'.join(ansList)
print(ans)

Measured memory_bytes: 61196
#include<stdio.h>                                                 
                                                                  
int main(void){                                                   
   int A,B,C;                                                     
   scanf("%d %d %d",&A,&B,&C);                                    
                                                                  
   int tmp = A;                                                   
   A = B;                                                         
   B = tmp;                                                       
                                                                  
   int tmp2 = A;                                                  
   A = C;                                                         
   C = tmp2;                                                      
                                                                  
   printf("%d %d %d",A,B,C);                                      
   return 0;                                                      
} 

Measured memory_bytes: 1700
x,y=map(int,input().split())
if x==y:
  result=0
elif y>x:
  if x<0 and y>0:
    result=abs(abs(y)-abs(x))+1
  else:
    result=y-x
elif x>y:
  if x<0:
    result=x-y+2
  else:
    if y>0:
      result=x-y+2
    else:
      result=abs(abs(x)-abs(y))+1
  
print(result)

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

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define lfs <<fixed<<setprecision(10)<<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
template<typename T>
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  map<ll,ll>mp;
  ll n;cin>>n;
  rep(i,0,n){
    ll x;cin>>x;mp[x]++;
  }
  ll m;cin>>m;
  rep(i,0,m){
    ll t;cin>>t;
    if(mp.count(t)){
      if(mp[t]<=0)judge=false;
      else mp[t]--;
    }
    else judge=false;
  }
  ans2(judge);
  return 0;
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
const ll inf = 1e16;
const ll md = 1000000007;

ll cs[100005];
int n,k;

bool ok(int m){
  ll tar=m;
  rep(_,k){
    auto it=upper_bound(cs,cs+n,tar);
    if(it==cs+n) return true;
    it--;
    tar=*it+m;
  }
  return false;
}

int main() {
  cin>>n>>k;
  ll s=0LL;
  rep(i,n){
    ll w;
    cin>>w;
    s+=w;
    cs[i]=s;
  }
  int l=s/k-1,r=s+1;
  while(l+1<r){
    int m=(l+r)/2;
    if(ok(m)) r=m;
    else l=m;
  }
  cout<<r<<endl;
  return 0;
}



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

int main() {
    cin.tie(0)->sync_with_stdio(false);

    int n, a, b;
    cin >> n >> a >> b;
    cout << min(a, b) << ' ' << max(0, a + b - n) << '\n';
    // cout << min(a, b) << ' ' << min(a - (n - b), b - (n -a)) << '\n';
    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>;

int main() {
    int s, w;
    cin >> s >> w;
    if (s <= w) cout << "unsafe" << endl;
    else cout << "safe" << endl;
    return 0;
}

Measured memory_bytes: 3632
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion

#pragma region BIT
struct BIT
{
	vector<int> bit;
	int n;
	//i-indexed
	BIT() { init(-1); }
	BIT(int n_) { init(n_); }
	void init(int n_)
	{
		n = n_;
		bit.clear();
		bit.resize(n + 1, 0);
	}
	int sum(int i)
	{
		int s = 0;
		while (i > 0)
		{
			s += bit[i];
			i -= i & -i;
		}
		return s;
	}
	void add(int i, int x)
	{
		if (i == 0)return;
		while (i <= n)
		{
			bit[i] += x;
			i += i & -i;
		}
	}
	int sum0(int i)
	{
		return sum(i + 1);
	}
	void add0(int i, int x)
	{
		add(i + 1, x);
	}
};
#pragma endregion

int main()
{
	int n; cin >> n;
	string s; cin >> s;
	vector<BIT> v(26);
	rep(i, 26)v[i].init(n + 1);
	rep(i, n)
	{
		v[s[i] - 'a'].add(i + 1, 1);
	}
	int q; cin >> q;
	while (q--)
	{
		int t; cin >> t;
		if (t == 1)
		{
			int i; cin >> i;
			char c; cin >> c;
			v[s[i - 1] - 'a'].add(i, -1);
			v[c - 'a'].add(i, 1);
			s[i - 1] = c;
		}
		else
		{
			int l, r; cin >> l >> r;
			int cnt = 0;
			rep(i, 26)cnt += (v[i].sum(r) - v[i].sum(l - 1)) ? 1 : 0;
			cout << cnt << endl;
		}
	}
}

Measured memory_bytes: 51716
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int x = sc.nextInt();
    int y = sc.nextInt();

    if(n>k){
      System.out.println(k*x+((n-k)*y));
    }else{
      System.out.println(n*x);
    }
  }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n) for (int i=1; i < (int)(n); i++)
#define rrep(i, n) for (int i=((int)(n)-1); i>=0; i--)
#define rreps(i, n) for (int i=((int)(n)-1); i>0; i--)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using lint = long long;
using p = pair<int, int>;
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; }

int main() {
  int N; cin >> N;
  vector<int> h(N);
  int ans = 0;
  int prev = -1;
  int cnt = 0;
  rep (i, N) {
    cin >> h[i];
    
    if (prev >= h[i]) {
      cnt ++;
      
      chmax(ans, cnt);
    }
    else {
      cnt = 0;
      
    }
    prev = h[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <stdio.h>

using namespace std;

#define LL long long
#define FOR(i,l,r) for(int i = l; i <= r; ++i)
#define REP(i,l,r) for(int i = l; i < r; ++i)

int N;
string s;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie();
    cout.tie();
    //
    cin >> N;
    cin >> s;
    int r = 1;
    for(int i = 1; i < s.size(); ++i){
        if(s[i] != s[i - 1]) ++r;
    }

    cout << r;

    return 0;

}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
inline bool chmax (long long& a, long long b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
int main() {
	int x, y, z;
	cin >> x >> y >> z;
	int n = x + y + z;
	vector<int> a(n), b(n), c(n);
	for (int i = 0; i < n; i++) cin >> a[i] >> b[i] >> c[i];
	vector<pair<int, int>> cai(n);
	vector<int> ba(n), bc(n);
	for (int i = 0; i < n; i++) {
		cai[i] = {c[i] - a[i], i};
		ba[i] = b[i] - a[i];
		bc[i] = b[i] - c[i];
	}
	sort(cai.begin(), cai.end());
	vector<long long> left(y + 1, 0), right(y + 1, 0);
	priority_queue<pair<int, int>> que;
	auto lit = left.begin();
	for (int i = 0; i < x + y; i++) {
		int cri = cai[i].second;
		que.emplace(ba[cri], cri);
		if (i < x) {
			*lit += a[cri];
		} else {
			*next(lit) = *lit + a[cri] + que.top().first, que.pop();
			lit++;
		}
	}
	priority_queue<pair<int, int>> rue;
	auto rit = right.begin();
	for (int i = n - 1; i >= x; i--) {
		int cri = cai[i].second;
		rue.emplace(bc[cri], cri);
		if (x + y <= i) {
			*rit += c[cri];
		} else {
			*next(rit) = *rit + c[cri] + rue.top().first, rue.pop();
			rit++;
		}
	}
	long long ret = 0;
	for (int i = 0; i <= y; i++) {
		chmax(ret, left[i] + right[y - i]);
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 4608
n=int(input())
S=[list(input()) for i in range(n)]
s1=S.pop(0)
A=[]
#s1を一文字ずつ確かめていく
for s in s1:
    flag=0
    #残ったSを一列ずつ確かめていく
    for t in S:
        #もしtにsが含まれていなければflagをonにする(操作をしない)
        if s not in t:
            flag=1
    #tにsが含まれていれば(Sの中にsが含まれているものが一つでもあれば)
    if flag==0:
        #Aにsを格納する
        A.append(s)
        #全てのSからsを取り除く
        for i in range(len(S)):
            S[i].remove(s)

A.sort()
print("".join(A))

Measured memory_bytes: 3064
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(time(NULL));

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

ll k;
string st;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	cin >> st >> k;

	vector<ll> vc;
	ll ans = 0;
	for(int i = 0, j = 0; i < st.size(); i = j) {
		for(; j < st.size() && st[i] == st[j]; j++);
		vc.push_back(j - i);
		ans += (j - i) / 2;
	}

	if(vc.size() == 1) {
		cout << k * st.size() / 2 << '\n';
	} else {
		ans *= k;
		if(st[0] == st.back() && vc[0] % 2 && vc.back() % 2) ans += k - 1;
		cout << ans << '\n';
	}
}


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

int main() {
    int r,c;
    std::cin >> r >> c;

    std::vector<std::vector<int> > table(r, std::vector<int>(c));

    for (int i = 0; i < r; i++) {
        for (int j = 0; j < c; j++) {
            std::cin >> table.at(i).at(j);
        }
    }

    std::vector<int> sum_column(c+1, 0);

    for (int i = 0; i < r; i++) {
        int sum_row = 0;
        for (int j = 0; j < c; j++){
            sum_column.at(j) += table.at(i).at(j);
            sum_row += table.at(i).at(j);
            std::cout << table.at(i).at(j) << " ";
        }
        std::cout << sum_row << std::endl;
        sum_column.at(c) += sum_row;
    }
    for (int i = 0; i < c; i++) std::cout << sum_column.at(i) << " ";
    std::cout << sum_column.at(c) << std::endl;
}


Measured memory_bytes: 3200
#include <iostream>
#include <algorithm>
#include<vector>

using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	int a, b, c, d = 0;
	cin >> a >> b >> c;
	for (int i = a; i < b+1; i++)
	{
		if (c % i == 0) d++;
	}
	cout << d << endl;
	return 0;
}

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

#define ll long long

using namespace std;

vector<ll> pdiv(ll x) {
    vector<ll> result;
    ll x_tmp = x;
    for(ll q = 2; q * q <= x; q++)
        if(x_tmp % q == 0) {
            result.push_back(q);
            while(x_tmp % q == 0) x_tmp /= q;
        }
    if(x_tmp != 1)
        result.push_back(x_tmp);
    return result;
}

int main() {
    std::ios::sync_with_stdio(false);
    ll a, b;
    cin >> a >> b;
    map<ll, int> A;
    auto process = [&A](ll n) {
        for(ll x : pdiv(n))
            A[x] += 1;
    };
    A[1] = 2;
    process(a);
    process(b);
    int result = 0;
    for(auto it : A)
        if(it.second >= 2)
            result += 1;
    cout << result << "\n";
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define intt int64_t
#define all(vec) vec.begin(), vec.end()
#define INF 2000000000
#define MOD 1000000007

int gcd(int x, int y) {
    if (x%y == 0) return y;
    return gcd(y, x%y);
}

int lcm(int x, int y) {
    return x*y/gcd(x, y);
}

int main() {
    int w, h, c;
    scanf("%d %d %d", &w, &h, &c);
    int gcd_w_h = gcd(w, h),
        ans = (w/gcd_w_h) * (h/gcd_w_h) * c;
    printf("%d\n", ans);
}


Measured memory_bytes: 3220
/*
    Author - Param Kothari
    Ah shit, here we go again
*/

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

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mk make_pair

typedef long long ll;
typedef long double ld;

void solve(){
    ll x, k, d;
    cin >> x >> k >> d;
    x = abs(x);
    ll no1 = x / d;
    if(k < no1){
        cout << x - (k * d) << "\n";
        return;
    }
    ll k1 = k - no1;
    ll curr1 = x - (no1 * d);
    ll k2 = k - no1 - 1;
    ll curr2 = curr1 - d;
    // cout << k << " " << curr << "\n";
    ll res = 1e18;
    if(k1 % 2 == 0){
        res = min(res, abs(curr1));
    }
    else{
        res = min({res, abs(curr1 - d), abs(curr1 + d)});
    }
    if(k2 % 2 == 0){
        res = min(res, abs(curr2));
    }
    else{
        res = min({res, abs(curr2 - d), abs(curr2 + d)});
    }
    cout << res << "\n";
    return;
}

int main(){
    IOS;
    int t = 1;
    // cin >> t;
    for(int i = 1; i <= t; i++){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define ll long long
#define fr(i,x,y) for(int i=(x);i<=(y);i++)
#define rf(i,x,y) for(int i=(x);i>=(y);i--)
#define frl(i,x,y) for(int i=(x);i<(y);i++)
using namespace std;
const int N=200002;
const int M=1000002;
const int p=998244353;
const int inv2=(p+1)/2;
int n,a[N],s[M];
int mu[M];
ll sum[M],f[M];

void read(int &x){
	char ch=getchar();x=0;
	for(;ch<'0'||ch>'9';ch=getchar());
	for(;ch>='0'&&ch<='9';ch=getchar()) x=(x<<3)+(x<<1)+ch-'0';
}

void Add(ll &x,ll y){
	x+=y;
	while(x>=p) x-=p;
	while(x<0) x+=p;
}

int b[M],pri[M],L;
void init(){
	mu[1]=1;
	frl(i,2,M){
		if (!b[i]) pri[++L]=i,mu[i]=-1;
		for(int j=1;j<=L&&i*pri[j]<M;j++){
			b[i*pri[j]]=1;
			if (i%pri[j]==0) break;
			 else mu[i*pri[j]]=-mu[i];
		}
	}
}

ll qpow(ll sum,ll n){
	ll ans=1;
	for(;n;n>>=1,sum=sum*sum%p) if (n&1) ans=ans*sum%p;
	return ans;
}

int main(){
	read(n);
	fr(i,1,n) read(a[i]),s[a[i]]++;
	init();
	frl(i,1,M){
		for(int j=i;j<M;j+=i)
		 Add(sum[i],1LL*s[j]*j);
		sum[i]=sum[i]*sum[i]%p;
	}
	frl(i,1,M){
		for(int j=i;j<M;j+=i)
		 Add(f[i],sum[j]*mu[j/i]);
	}
	ll ans=0;
	frl(i,1,M){
		if (f[i]) Add(ans,f[i]*qpow(i,p-2)%p);
	}
	fr(i,1,n) Add(ans,-a[i]);
	cout<<ans*inv2%p<<endl;
	return 0;
}

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

int main(){
  string S;
  cin>>S;
  int a[4];
  for(int i=0;i<4;++i) a[i]=S[i]-'0';

  int y=10*a[0]+a[1],m=10*a[2]+a[3];
  int cnt1=0,cnt2=0;
  if(y>=1 && y<=12) ++cnt1;
  if(m>=1 && m<=12) ++cnt2;

  if(cnt1==0 && cnt2==0) cout<<"NA"<<endl;
  else if(cnt1>0 && cnt2>0) cout<<"AMBIGUOUS"<<endl;
  else if(cnt1>0) cout<<"MMYY"<<endl;
  else if(cnt2>0) cout<<"YYMM"<<endl;
}


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

int main(){
	int A, B;
	cin >> A >> B;
	if((A + B) % 2 == 0){
		cout << (A + B) / 2 << endl;
	}
	else{
		cout << "IMPOSSIBLE" << endl;
	}
	return 0;
}


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

int main(void)
{
    int A, B, C, K, flag=0, i=0, j=0, k=0;

    scanf("%d %d %d", &A, &B, &C);
    scanf("%d", &K);

    for(i=0; i<=K; i++) {
        for(j=0; j<=K-i; j++) {
            for(k=0; k<=K-(i+j); k++) {
                if(A*pow(2,i) < B*pow(2,j) && B*pow(2,j) < C*pow(2,k)) {
                    printf("Yes\n");
                    flag = 1;
                    break;
                }
            }
            if(flag == 1) {
                break;
            }
        }
        if(flag == 1) {
            break;
        }
    }

    if(flag == 0) {
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 2492
import sys
from io import StringIO
import unittest


def resolve():
    # s = input()
    # n = int(input())
    n, d = map(int, input().split())

    ans = 0

    for _ in range(n):
        x, y = map(int, input().split())

        if (x ** 2 + y ** 2) ** 0.5 <= d:
            ans += 1

    print(ans)


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """4 5
0 5
-2 4
3 4
4 -4"""
        output = """3"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """12 3
1 1
1 1
1 1
1 1
1 2
1 3
2 1
2 2
2 3
3 1
3 2
3 3"""
        output = """7"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """20 100000
14309 -32939
-56855 100340
151364 25430
103789 -113141
147404 -136977
-37006 -30929
188810 -49557
13419 70401
-88280 165170
-196399 137941
-176527 -61904
46659 115261
-153551 114185
98784 -6820
94111 -86268
-30401 61477
-55056 7872
5901 -163796
138819 -185986
-69848 -96669"""
        output = """6"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 16792
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int n;

int main(){
	cin>>n;
	cout<<a[n-1]<<endl;
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define INF LONG_LONG_MAX
#define yn(f) cout << (f ? "Yes" : "No") << endl;

int x,y,a,b,c,ans;
vector<int> va,vb,vc,v;


signed main() {
    cin >> x >> y >> a >> b >> c;
    rep(i,a) {
        int tmp;
        cin >> tmp;
        va.pb(tmp);
    }
    rep(i,b) {
        int tmp;
        cin >> tmp;
        vb.pb(tmp);
    }
    rep(i,c) {
        int tmp;
        cin >> tmp;
        vc.pb(tmp);
    }
    sort(rall(va));
    sort(rall(vb));
    sort(rall(vc));
    rep(i,x) v.pb(va[i]);
    rep(i,y) v.pb(vb[i]);
    sort(all(v));
    int b = min((int)vc.size(), (int)v.size());
    rep(i,b) {
        if (v[i] < vc[i]) v[i] = vc[i];
        else break;
    }
    for(auto i : v) ans += i;
    cout << ans << endl;
}

Measured memory_bytes: 4724
using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            var s = consoleReader.Int32();
            var a = new List<int>();
            a.Add(s);

            for (int i = 1; i < 1000000; i++)
            {
                var num = F(a[i - 1]);
                if (a.Contains(num))
                    return i + 1;
                a.Add(num);
            }
            return 0;
        }
        int F(int n) => n % 2 == 0 ? n / 2 : 3 * n + 1;

        const int mod = 1000000007;
        private readonly ConsoleReader consoleReader;
        public Program() : this(new ConsoleReader()) { }
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program().Calc());
        public static string MultiLine<T>(IEnumerable<T> source) => string.Join("\n", source);
    }

    public class ConsoleReader
    {
        public virtual string String() => Console.ReadLine();
        public int Int32() => int.Parse(String());
        public long Int64() => long.Parse(String());
        public ulong UInt64() => ulong.Parse(String());
        public double Double() => double.Parse(String());
        public string[] Split() => String().Split().ToArray();
        public int[] SplitInt32() => String().Split().Select(int.Parse).ToArray();
        public long[] SplitInt64() => String().Split().Select(long.Parse).ToArray();
        public ulong[] SplitUInt64() => String().Split().Select(ulong.Parse).ToArray();
        public double[] SplitDouble() => String().Split().Select(double.Parse).ToArray();

        public IEnumerable<string> Repeat(int count)
        {
            for (int i = 0; i < count; i++)
                yield return String();
        }
        public IEnumerable<int> RepeatInt32(int count)
        {
            for (int i = 0; i < count; i++)
                yield return Int32();
        }
        public IEnumerable<long> RepeatInt64(int count)
        {
            for (int i = 0; i < count; i++)
                yield return Int64();
        }
        public IEnumerable<string[]> RepeatSplit(int count)
        {
            for (int i = 0; i < count; i++)
                yield return Split();
        }
        public IEnumerable<int[]> RepeatSplitInt32(int count)
        {
            for (int i = 0; i < count; i++)
                yield return SplitInt32();
        }
    }
}


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

int main() {
	long long int n;
 cin>>n;
 long long int s=0;
 for(int i=1;i<n+1;i++)
 {if(i%3!=0&&i%5!=0)
  s+=i;     
 }
 cout<<s;
 
	return 0;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int main()
{
	int sum = 0, num = 0, i = 0;

	int s, n;
	char k;
	while(cin >> s >> k >> n)
	{
		sum += s * n;
		num += n;
		i++;
	}

	cout << sum << endl << int((float)num / i + 0.5 + EPS) << endl;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main(void)
{
    int n, cnt = 0;
    string s;
    cin >> n >> s;
    rep(i,1000){
        int c[3] = {i/100, (i/10)%10, i%10};
        int e = 0;
        rep(i,n){
            if(c[e]+'0' == s[i]) e++;
        	if(e == 3) break;
        }
        if(e == 3) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3652
#include<iostream>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1 << 21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];


void dijkstra(){
  int minv;
  int d[MAX], color[MAX];

  for(int i = 0 ; i < n ; i++){
    d[i] = INFTY;
    color[i] = WHITE;
  }

  d[0] = 0;
  color[0] = INFTY;
  while(1){
    minv = INFTY;
    int u = -1;
    for(int i = 0 ; i < n ; i++){
      if(minv > d[i] && color[i] != BLACK){
        u = i;
        minv = d[i];
      }
    }
    if(u == -1) break;
    color[u] = BLACK;
    for(int v = 0 ; v < n ; v++){
      if(color[v] != BLACK && M[u][v] != INFTY){
        if(d[v] > d[u] + M[u][v]){
          d[v] = d[u] + M[u][v];
          color[v] = GRAY;
        }
      }
    }
  }
  for(int i = 0 ; i < n ; i++){
    cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
  }
}

int main(){
  cin >> n;
  for(int i = 0 ; i < n ; i++){
    for(int j = 0 ; j < n ; j++){
      M[i][j] = INFTY;
    }
  }

  int k, c, u, v;
  for(int i = 0 ; i < n ; i++){
    cin >> u >> k;
    for(int j = 0 ; j < k ; j++){
      cin >> v >> c;
      M[u][v] = c;
    }
  }

  dijkstra();

  return 0;
}

Measured memory_bytes: 3120