akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

deque<int> a(200000,0);
deque<int> b;

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

    for( int i = 0; i < n; i++){
        cin >> a[i];
    }

    for( int i = 0; i < n; i++){
        if( (n-1) % 2 == i % 2 ){
            b.push_front(a[i]);
        }else{
            b.push_back(a[i]);
        }
    }
    for( int i = 0; i < n; i++){
        cout << b[i] << " ";
    }

    return 0;
}

Measured memory_bytes: 3840
// Words are flowing out like endless rain into a paper cup
// They slither while they pass they slip away across the universe
// Pools of sorrow, waves of joy are drifting through my open mind
// Possessing and caressing me

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

using LL = long long;

namespace _buff {

const size_t BUFF = 1 << 19;
char ibuf[BUFF], *ib = ibuf, *ie = ibuf;
char getc() {
    if (ib == ie) {
        ib = ibuf;
        ie = ibuf + fread(ibuf, 1, BUFF, stdin);
    }
    return ib == ie ? -1 : *ib++;
}

}

LL read() {
    using namespace _buff;
    LL ret = 0;
    bool pos = true;
    char c = getc();
    for (; (c < '0' || c > '9') && c != '-'; c = getc()) {
        assert(~c);
    }
    if (c == '-') {
        pos = false;
        c = getc();
    }
    for (; c >= '0' && c <= '9'; c = getc()) {
        ret = (ret << 3) + (ret << 1) + (c ^ 48);
    }
    return pos ? ret : -ret;
}

template <typename T>
void chkmin(T &dp, const T &val) {
    if (val < dp) dp = val;
}

const size_t N = 500 + 5;

LL a[N][N], dp[N][N];

int main() {
    int n = read();
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            if (i != j) {
                a[i][j] = read();
            }
        }
    }

    memset(dp, 0x3f, sizeof dp);
    dp[0][0] = 0;
    for (int i = 1; i < n; ++i) {
        static LL fr_i[N], to_i[N];
        for (int j = 1; j <= i; ++j) {
            fr_i[j] = fr_i[j - 1] + a[i + 1][j];
            to_i[j] = to_i[j - 1] + a[j][i + 1];
        }
        for (int a = 0; a < i; ++a) {
            for (int b = (a ? a + 1 : 0); b < i; ++b) {
                chkmin(dp[b][i], dp[a][b]);
            }
        }
        for (int a = 0; a < i; ++a) {
            for (int b = (a ? a + 1 : 0); b <= i; ++b) {
                dp[a][b] += fr_i[a] + to_i[i] - to_i[b];
            }
        }
    }

    LL ans = 1e18;
    for (int a = 0; a < n; ++a) {
        for (int b = 0; b < n; ++b) {
            ans = min(ans, dp[a][b]);
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 4736
{-# LANGUAGE PartialTypeSignatures #-}
module Main (main) where

import Control.Monad
import qualified Data.ByteString.Char8 as C8
import qualified Data.Char as C
import qualified Data.List as L

main :: IO ()
main = do
  [d] <- readInts
  scoreTable <- readInts
  replicateM d readInts >>= output d . solve

solve :: [[Int]] -> _
solve xs = xs

output :: Int -> _ -> IO ()
output d _ = mapM_ print $ take d $ cycle [26,25..1]

-- utils
readInts :: IO [Int]
readInts = L.unfoldr (C8.readInt . C8.dropWhile C.isSpace) <$> C8.getLine


Measured memory_bytes: 4396
#include<cstdio>

int main(){
    int a,b,c;
    int s = 0;
    scanf("%d %d %d",&a,&b,&c);
    for(int i = a; i <= b; i++){
        if(c % i == 0){
            s++;
        }
    }
    printf("%d\n",s);
    return 0;
}


Measured memory_bytes: 2756
import sys,os
from collections import defaultdict, deque
from math import ceil, floor
if sys.version_info[1] >= 5:
    from math import gcd
else:
    from fractions import gcd
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    MOD = 10**9+7

    H,W = LMIIS()
    N = II()
    A = LMIIS()
    ai = 0
    for i in range(H):
        
        line = []

        # from left to right
        if i % 2 == 0:
            j = 0
            while j < W:
                while j < W and A[ai] > 0:
                    # line += str(ai+1)
                    line.append(ai+1)
                    A[ai] -= 1
                    j += 1
                if A[ai] == 0 and ai < N-1:
                    ai += 1

            print(*line)
        # from right to left
        else:
            j = W-1
            while 0 <= j:
                while 0 <= j and A[ai] > 0:
                    # line += str(ai+1)
                    line.append(ai+1)
                    A[ai] -= 1
                    j -= 1
                if A[ai] == 0 and ai < N-1:
                    ai += 1
            # print(line[::-1])
            print(*line[::-1])




    

if __name__ == '__main__':
    main()

Measured memory_bytes: 68460
import sys
input = sys.stdin.readline


def pack(C):
    bitmask = 0
    for c in C:
        d = 1 << (c-1)
        bitmask |= d
    return bitmask


def read():
    N, M = list(map(int, input().strip().split()))
    A = list()
    C = list()
    for i in range(M):
        a, b = list(map(int, input().strip().split()))
        A.append(a)
        c = map(int, input().strip().split())
        C.append(pack(c))
    return N, M, A, C


def solve(N, M, A, C, INF=10**9):
    # dp[state][i]: i本の鍵[0, i)を使って状態stateにするための最小コスト
    n_states = 1 << N
    end_state = n_states - 1
    dp = [[INF for j in range(2)] for state in range(n_states)]
    dp[0][0] = 0
    dp[0][1] = 0

    for j in range(M):
        m0 = j & 1
        m1 = 1 - m0
        for state in range(n_states):
            next_state = state | C[j]
            dp[state][m1] = min(dp[state][m1], dp[state][m0])
            if next_state > state:
                dp[next_state][m1] = min(dp[next_state][m1], dp[state][m0] + A[j])
    
    m0 = M & 1
    return dp[end_state][m0] if dp[end_state][m0] != INF else -1


if __name__ == "__main__":
    inputs = read()
    print("%s" % solve(*inputs))


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

#define step(i, s, n, d) for(int i=s; i<n; i+=d)
#define FOR(i,s,n) step(i,s,n,1)
#define rep(i,n) FOR(i,0,n)
#define gets(x) x; cin >> x;
#define puts(x) x; cout << x << endl;
#define list_input(x, n) x[n]; rep(i,n){ gets(x[i]);}
#define ll long long
typedef pair<int, int> P;

int main(){
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a+3);
  int ans = (a[1] - a[0]) + (a[2] - a[1]);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <assert.h>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <memory.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
typedef long long ll;
int n, v[200];
int main()
{
	scanf("%d", &n);
	n <<= 1;
	for (int i = 0; i < n; ++i)
		scanf("%d", &v[i]);
	sort(v, v + n);
	int res = 0;
	for (int i = 0; i + 1< n; i += 2)
		res += min(v[i], v[i + 1]);
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int X = in.nextInt();
            int max = 0;
            for (int b = 1; b <= X; b++) {
                if (b > 1) {
                    for (int p = 2;; p++) {
                        int n = (int) (1e-9 + Math.pow(b, p));
                        if (n > X) {
                            break;
                        }
                        max = Math.max(max, n);
                    }
                } else {
                    int n = b;
                    max = Math.max(max, n);
                }
            }
            System.out.println(max);
        }
    }
}


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

Measured memory_bytes: 3060
s = str(input())
words = ["dream","erase","eraser","dreamer"]
i = len(s)
while i>0:
    if s[-5:] in words:
        s = s[:-5]
        i -= 5
    elif s[-6:] in words:
        s = s[:-6]
        i -= 6
    elif s[-7:] in words:
        s = s[:-7]
        i -= 7
    else:
        break
if i==0:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>
#include<bitset>
#include<tuple>
#include<time.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;

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


string s;

int main(){
	cin >> s;
	
	for(int i = 0; i < s.size(); i++) cout << "x";
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

/**
 *
 * @author Administrator
 */
public class Main {
    public static int numDigits(long num){
        int res = 0;
        while(num != 0){
            num /= 10;
            res += 1;
        }
        return res;
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
//        boolean[] sieve = new boolean[100001];
//        Arrays.fill(sieve, true);
//        sieve[0] = false;
//        sieve[1] = false;
//        int index = 2;
//        while(index * index <= 100000){
//            if(sieve[index]){
//                for (int i = index * index; i <= 100000; i += index) {
//                    sieve[i] = false;
//                }
//            }
//            index += 1;
//        }
//        ArrayList<Integer> prime = new ArrayList<>();
//        for(int i = 2; i <= 100000; i++){
//            if(sieve[i])
//                prime.add(i);
//        }
        long bound = (int) Math.sqrt(n);
        int res = numDigits(n);
        for(long i = 2; i <= bound; i++){
            if(n % i == 0){
                res = Math.min(res, Math.max(numDigits(i), numDigits(n/i)));
            }
        }
        System.out.println(res);
        
    }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<ll> arr_a(a, 0);
    vector<ll> arr_b(b, 0);
    vector<ll> arr_c(c, 0);
    for(auto& val: arr_a)
        cin >> val;
    for(auto& val: arr_b)
        cin >> val;
    for(auto& val: arr_c)
        cin >> val;
    sort(arr_a.begin(), arr_a.end());
    sort(arr_b.begin(), arr_b.end());
    sort(arr_c.begin(), arr_c.end());
    priority_queue<ll, vector<ll>, greater<ll>> pq;
    ll acc = 0;
    for(int i = 1; i <= x; i++) {
        pq.push(arr_a[a-i]);
        acc += arr_a[a-i];
    }
    for(int i = 1; i <= y; i++) {
        pq.push(arr_b[b-i]);
        acc += arr_b[b-i];
    }
    for(int i = c-1; i >= 0; i--) {
        if (arr_c[i] > pq.top()) {
            acc -= pq.top();
            acc += arr_c[i];
            pq.pop();
            pq.push(arr_c[i]);
        } else {
            break;
        }
    }
    cout << acc << endl;
    return 0;
}




Measured memory_bytes: 4852
#include<iostream>
using namespace std;
int main()
{
  int l,r,d,count=0;
  cin>>l>>r>>d;
  for(int i=l;i<=r;i++)
  {
    if(i%d==0)
    {
      count++;
    }
  }
  cout<<count<<"\n";
  return 0;
}
    

Measured memory_bytes: 3164
#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    cin >> s;
    s[3] = '8';
    
    rep(i, 10){
        cout << s[i];
        if(i == 9)  cout << endl;
    }
    return 0;
}

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

char a[100010];
int ans;

int main()
{
	cin>>a;
	int len=strlen(a);
	for(int i=0;i<len-1;i++) if(a[i]!=a[i+1]) ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
import java.math.BigInteger;
import java.util.Scanner;

class Main {
    public static void main(final String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        StringBuffer str = new StringBuffer(s);
        String r = str.reverse().toString();
        int size = r.length();
        int ans = 0;
        int[] count = new int[2019];
        BigInteger total = BigInteger.ZERO;
        BigInteger mod = new BigInteger("2019");
        BigInteger exp = BigInteger.ONE;
        for (int i = 0; i < size; i++) {
            count[total.intValue()]++;
            total = total.add(new BigInteger(r.substring(i, i + 1)).multiply(exp)).remainder(mod);
            ans += count[total.intValue()];
            exp = exp.multiply(BigInteger.TEN).remainder(mod);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 58080
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define co(x) cout << (x) << "\n"
#define ll long long
#define pb push_back
#define Never
#define To

using namespace std;

int main(){

	cin.tie(0);
	ios::sync_with_stdio(false);

	ll N;

	cin >> N;

	ll A[N], B[N], C[N];
	ll ans = 0;

	for(ll n = 0; n < N; n++){
		cin >> A[n];
	}

	for(ll n = 0; n < N; n++){
		cin >> B[n];
	}

	for(ll n = 0; n < N; n++){
		cin >> C[n];
	}

	sort(A, A+N);
	sort(B, B+N);
	sort(C, C+N);

	for(ll b = 0; b < N; b++){
		ll ok = -1;
		ll ng = N;
		ll mid;
		while(ng - ok > 1){
			mid = (ng + ok)/ 2;
			if(A[mid] < B[b]){
				ok = mid;
			} else {
				ng = mid;
			}
		};
		ll a = ok + 1;

		ok = N;
		ng = -1;
		while(ok - ng > 1){
			mid = (ok + ng)/ 2;
			if(C[mid] > B[b]){
				ok = mid;
			} else {
				ng = mid;
			}
		}
		ll c = N - ok;

		ans += a * c;
	}

	cout << ans << endl;

	Never To return 0;
}


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

ll N;
vector<ll> A;

int main() { 
    cin >>N;
    A.resize(N);
    for (int i = 0; i<N; i++) cin >> A[i];
    set<ll> st;
    for (int i = 0; i < N; i++) st.insert(A[i]);
    if(A.size()==st.size())cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 18868
loop do
	n, m = gets.split.map(&:to_i)
	break if n == 0
	points = []
	n.times do
		points << [*gets.split.map(&:to_i), 1]
	end
	m.times do
		points << [*gets.split.map(&:to_i), -1]
	end
	points.sort!
	
	ok = false
	catch(:exit1) do
		points.combination(2) do |(x1, y1, _), (x2, y2, _)|
			catch(:exit2) do
				a = y1 - y2
				b = x2 - x1
				c = a * x1 + b * y1
				on_line = []

				prev_sign = nil
				points.each do |x, y, color|
					sign = (a * x + b * y - c) * color
					if sign == 0
						on_line << color
					else
						if prev_sign
							throw :exit2 if prev_sign * sign < 0
						else
							prev_sign = sign
						end
					end
				end

				on_line.reverse! if on_line.size > 0 && on_line[0] > 0		
				if on_line == on_line.sort
					ok = true
					throw :exit1
				end
			end
		end
	end

	puts ok ? 'YES' : 'NO'
end

Measured memory_bytes: 8736
#!/usr/bin/env python3
import sys
import math

def solve(N: int, X: int, T: int):
    print(math.ceil(N / X) * T)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    T = int(next(tokens))  # type: int
    solve(N, X, T)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9208
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1e9+7

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int i;
    string s;
    cin>>s;
    for(i=0;i<4;i++)cout<<s[i];
    cout<<" ";
    for(;i<s.length();i++)cout<<s[i];
    cout<<endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
	int n;
	cin >> n;
	
	cout << n * n * n << endl;
}


Measured memory_bytes: 3568
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int A = int.Parse(Console.ReadLine());
            int B = int.Parse(Console.ReadLine());
            int C = int.Parse(Console.ReadLine());
            int D = int.Parse(Console.ReadLine());

            int ans = Math.Min(A, B) + Math.Min(C, D);
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
signed main(){
    int n;
    cin>>n;
    vector<int> a(n);
    for(auto& ai:a)cin>>ai;
    int ans = 1;
    for(int i=0;i<n-1;++i){
        if(a[i]>=a[i+1])ans++;
    }
    cout<< ans <<endl;
    cout<< n <<endl;
}


Measured memory_bytes: 3108
#include <iostream>
#include <cstdio>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
using namespace std;
int main()
{
    int n,i,j,x,c;
    int s=0;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d",&j);
        if(j%2)s++;
    }
    if(s%2)printf("NO\n");
    else printf("YES\n");
    return 0;
}


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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

#define mod 1e9+7;
#define inf 1e18+7;

typedef long long ll;


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

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

    rep(i,n){
        if(x[i]<y[n/2]){
            cout<<y[n/2]<<endl;
        }
        else {
            cout<<y[n/2-1]<<endl;
        }
    }
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n,m,x,ans=2e9+7;
int c[15],a[15][15],post[15];
int main()
{
cin>>n>>m>>x;
for(int i=1;i<=n;i++)
{
	cin>>c[i];
	for(int j=1;j<=m;j++)
	cin>>a[i][j];
}
while(post[0]==0)
{
	int in[15]={0},money=0;
	for(int i=1;i<=n;i++)
	{
		if(post[i]==1)
		{
			money+=c[i];
			for(int j=1;j<=m;j++)
			in[j]+=a[i][j];
		}
	}
	int flag=1;
	for(int i=1;i<=m;i++)
	{
		if(in[i]<x)
		{
			
			flag=0;
			break;
		}
	}
	if(flag)
	ans=min(ans,money);
	for(int i=n;i>=0;i--)
	{
		if(post[i]==1)
		post[i]=0;
		else
		{
			post[i]=1;
			break;
		}
		
	}
}
if(ans!=2e9+7)
cout<<ans;
else
cout<<-1;
return 0;

}

Measured memory_bytes: 3640
#include <stdio.h>
int main(void){
    int a[20000],b[20000],i;
    char op[20000];
    for(i=0;i<=20000;i++){
            scanf("%d %c %d",&a[i],&op[i],&b[i]);
   if(op[i] == '+'){
       printf("%d\n",a[i]+b[i]);
   }
    else if(op[i] == '-'){
       printf("%d\n",a[i]-b[i]);
    }
     else if(op[i] == '*'){
       printf("%d\n",a[i]*b[i]);
     }
     else if(op[i] == '/'){
       printf("%d\n",a[i]/b[i]);
     }
   else if(op[i]=='?')break;
}
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define ii pair<int,int>
#define INF 1000000000
#define M 1000000007ll
#define INFLL 1000000000000000010ll
#define UQ(x) (x).resize(distance((x).begin(),unique(all((x)))))
#define mid(x,y) (((x)+(y))>>1)

int n;
char g[505][505];
int a[505][505],row[505],cnt[505],col[505];
int main() {
	scanf("%d",&n);
	for (int i=0;i<n;i++) {
		scanf("%s",g[i]);
	}
	bool die=1;
	for (int i=0;i<n;i++) {
		for (int j=0;j<n;j++) {
			a[i][j]=!!(g[i][j]=='#');
			if (a[i][j]) die=0,col[j]=1;
			cnt[i]+=a[i][j];
		}
	}
	if (die) {
		printf("-1\n");
		return 0;
	}
	for (int i=0;i<n;i++) {
		for (int j=0;j<n;j++) {
			if (a[i][j]) {
				bool has=0;
				for (int k=0;k<n;k++) {
					if (!a[k][j]) {
						has=1;
						break;
					}
				}
				if (has) row[i]++;
			} else row[i]++;
		}
	}
	int ans=INF;
	for (int i=0;i<n;i++) {
		if (col[i]) ans=min(ans,n-cnt[i]+row[i]);
		else ans=min(ans,n-cnt[i]+row[i]+1);
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 1536
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define INF 1000000000
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));

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

	int N;
	cin>>N;
	vector<string>st(N);
	map<string,int>ans;
	REP(i,N){
		string s;
		cin>>s;
		st[i]=s;
		ans[s]++;
	}
	int M;
	cin>>M;
	REP(i,M){
		string s;
		cin>>s;
		ans[s]--;
	}
	int anser=0;
	REP(i,N)
		anser=max(anser,ans[st[i]]);
	
	cout<<anser<<endl;
	return 0;
}

Measured memory_bytes: 256
object Main {
    def main(args: Array[String]): Unit = {
        val n = readInt;
        for (i <- (0 until n)) {
            println(lcs(readLine, readLine));
        }
    }

    def lcs(a: String, b: String): Int = {
        val lenA = a.length;
        val lenB = b.length;
        val matrix = Array.ofDim[Int](lenA + 1, lenB + 1);
        for (y <- (1 to lenA); x <- (1 to lenB)) {matrix(y)(x) = -1;}
        def _lcs(y: Int, x: Int): Int = {
            if (matrix(y)(x) == -1) {
                val lcs1 = _lcs(y - 1, x - 1);
                val lcs2 = _lcs(y, x - 1);
                val lcs3 = _lcs(y - 1, x);
                if (a(y - 1) == b(x - 1)) {
                    matrix(y)(x) = max(lcs1 + 1, lcs2, lcs3);
                } else {
                    matrix(y)(x) = max(lcs1, lcs2, lcs3);
                }
            }
            matrix(y)(x)
        }
        _lcs(lenA, lenB);
    }

    def max(a: Int, b: Int, c: Int): Int = {
        if (b > c) {
            if (a > b) a else b;
        } else {
            if (a > c) a else c;
        }
    }
}


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

int main() {
    int N;
    cin >> N;
    vector<int> L(N);
    for(int i = 0; i < N; i++){
        cin >> L.at(i);
    }
    int cnt = 0;
    for(int i = 0; i < N - 2; i++){
        for(int j = i + 1; j < N - 1; j++){
            for(int k = j + 1; k < N; k++){
                if((L.at(i) != L.at(j) && L.at(i) != L.at(k) && L.at(j) != L.at(k)) && ((L.at(i) + L.at(j) > L.at(k)) && (L.at(j) + L.at(k) > L.at(i)) && (L.at(k) + L.at(i) > L.at(j)))){
                    cnt++;
                }
            }
        }
    }
    cout << cnt << endl;
}

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

using namespace std;

int main() {
    int n, q, tmp, cnt = 0;
    vector<int> s;
    vector<int> t;

    cin >> n;
    for ( int i = 0 ; i< n ; i++ ) {
        cin >> tmp;
        s.push_back(tmp);
    }

    cin >> q;
    vector<int>::iterator it;
    vector<int>::iterator pos;
    for ( int i = 0 ; i < q ; i++ ) {
        it = s.begin();
        cin >> tmp;
        pos = lower_bound(it, it+s.size(), tmp );
    if ( pos != s.end() && *pos == tmp ) {
            cnt++;
        }
    }

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3548
#include <stdio.h>
         
        int main(void){
        int N;
        scanf("%d", &N);
        int A[N];
        for(int i = 0;i<N;i++){
        scanf("%d", &A[i]);
        }
        int max = A[0];
        int min = A[0];
        for(int j = 0;j<N;j++){
        if(A[j]>max){
        max = A[j];
        }
        if(A[j]<min){
        min = A[j];
        }
        }
        printf("%d",max-min);
         
        return 0;
    }

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include<iomanip>

int main() {

	int N,D;
	std::cin >> N >> D;
	
	int result = N / (2*D+1);
	if (N % (2*D+1) != 0) result++;

	std::cout << result << std::endl;

	return 0;
}

Measured memory_bytes: 256
//----------------------------------------------------------------------
#include <algorithm>
#include <bits/stdc++.h>
#include <iomanip>
#include <ios>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
//----------------------------------------------------------------------

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    int n;
    cin >> n;
    vector<pair<double, double>> xy(n);
    rep(i, n) {
        cin >> xy[i].first >> xy[i].second;
    }
    vector<int> keiro;
    rep(i, n)
        keiro.push_back(i);

    double ans = 0.0;
    double sum = 0.0;
    do {
        for(int i = 0; i < n - 1; ++i) {
            double dx = xy[keiro[i+1]].first - xy[keiro[i]].first;
            double dy = xy[keiro[i+1]].second- xy[keiro[i]].second;
            ans += sqrt(dx * dx + dy * dy);
        }
        sum++;
    }while(next_permutation(keiro.begin(), keiro.end()));
    ans /= sum;

    cout << fixed << setprecision(16) <<
        ans << endl;
    return 0;
}


Measured memory_bytes: 3772
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
#include <string>
using namespace std;
typedef long long ll;

char s_mt[100], s[100], t[100];
    
bool same(void) {
    for (int i = 0; s[i + 1] != '\0'; i++) {
        if (s[i] != s[i + 1]) return false;
    }
    return true;
}

int main(void){
    cin >> s_mt;
    
    int mn = 200;
    for (int i = 'a'; i <= 'z'; i++) {
        int len = 0, ope = 0;
        for (len = 0; s_mt[len] != '\0'; len++) s[len] = s_mt[len];
        
        while (!same()) {
            len--;
            for (int j = 0; j < len; j++) {
                if (s[j] == char(i) || s[j + 1] == char(i)) {
                    t[j] = char(i);
                }
                else t[j] = s[j];
            }
            ope++;
            for (int j = 0; j < len; j++) s[j] = t[j];
            s[len] = '\0';
        }
        mn = min(mn, ope);
    }
    
    cout << mn << endl;
    
    
}


Measured memory_bytes: 256
from math import log2, ceil

N,K = map(int,input().split())

ans = 0

def cal(n):
    l = ceil(log2(K/n))
    if n >= K:
        return 1/N
    return pow(2,-l)/N

for i in range(1,N+1):
    ans += cal(i)

print(ans)

Measured memory_bytes: 3060
l = int(input())
v = 0

r = l/3
vr = r ** (3)

for i in range(0,l+1):
    for j in range(0,l-i+1):
       if v < i*j*(l-i-j):
           v = i*j*(l-i-j)
    
if vr >= v:
    print(vr)
else:
    print(v)

Measured memory_bytes: 3060
import java.util.*;
class Main{
    void solve(){
        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt();
        int f = sc.nextInt();
        int b = sc.nextInt();
        if ( m  + f < b ) System.out.println("NA");
        else if ( m >= b ) System.out.println(0);
        else System.out.println(b - m);
    }

    public static void main(String[] args){ new Main().solve(); }
}



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

#define dlog(str) cout << "====" << str << endl;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s; i <= e; i++)
#define LLI long long int
#define _min(a, b) ((a < b) ? a : b)
#define _max(a, b) ((a < b) ? b : a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

int main() {
    int N, D;
    cin >> N >> D;
    vector<vector<LLI>> v;
    REP(i, N) {
        vector<LLI> v2(D);
        REP(j, D) { cin >> v2[j]; }
        v.push_back(v2);
    }
    int cnt = 0;
    REP(i, N) {
        FOR(j, i + 1, N - 1) {
            double sum = 0;
            REP(k, D) { sum += (v[i][k] - v[j][k]) * (v[i][k] - v[j][k]); }
            double a = sqrt(sum);
            if(a == (int)a) {
                cnt++;
            }
        }
    }
    cout << cnt;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define mp  make_pair
#define pb  push_back
#define endl "\n"
#define rep(i,a,n) for(int i=a;i<n;i++)
const int mod = 1e9 + 7;
void solve() {
	int n, x, t;
	cin >> n >> x >> t;
	int s = 0, c = 0;
	while (s < n) {
		s += x;
		c++;
	}
	cout << c*t;
}
int32_t main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	int t;
	t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 3580
#include<iostream>
using namespace std;
int n;
int p[33];
int temp;
int ans;
int mn,sakuya;
void saiki();
int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    mn=8;
    sakuya=0;
    for(int j=1;j<31;j++){
      cin>>p[j];
    }
 
    saiki();
    cout<<mn<<endl;
  }
}
 
void saiki(){
  if(p[9]==p[1] && p[9]==p[2] && p[9]==p[3] && p[9]==p[4] &&
     p[9]==p[5] && p[9]==p[6] && p[9]==p[7] && p[9]==p[8]){
    if(p[28]==p[29] && p[28]==p[30] && p[28]==p[25] && p[28]==p[26] &&
       p[28]==p[27] && p[28]==p[22] && p[28]==p[23] && p[28]==p[24]){
      if(p[10]==p[11] && p[10]==p[12]){
    if(p[13]==p[14] && p[13]==p[15]){
      if(p[16]==p[17] && p[16]==p[18]){
        if(p[19]==p[20] && p[19]==p[21]){
          if(mn>sakuya){
        mn=sakuya;
          }
        }
      }
    }
      }
    }
  }
   
  if(sakuya<8){
    for(int i=0;i<4;i++){
 
      if(i==0){
    temp=p[13];
    p[13]=p[18];
    p[18]=temp;
     
    temp=p[24];
    p[24]=p[9];
    p[9]=temp;
    temp=p[23];
    p[23]=p[8];
    p[8]=temp;
    temp=p[22];
    p[22]=p[7];
    p[7]=temp;
 
    temp=p[10];
    p[10]=p[12];
    p[12]=temp;
      }
 
      if(i==1){
    temp=p[12];
    p[12]=p[19];
    p[19]=temp;
     
    temp=p[22];
    p[22]=p[3];
    p[3]=temp;
    temp=p[25];
    p[25]=p[6];
    p[6]=temp;
    temp=p[28];
    p[28]=p[9];
    p[9]=temp;
 
    temp=p[13];
    p[13]=p[15];
    p[15]=temp;
      }
 
      if(i==2){
    temp=p[15];
    p[15]=p[16];
    p[16]=temp;
     
    temp=p[28];
    p[28]=p[1];
    p[1]=temp;
    temp=p[29];
    p[29]=p[2];
    p[2]=temp;
    temp=p[30];
    p[30]=p[3];
    p[3]=temp;
 
    temp=p[19];
    p[19]=p[21];
    p[21]=temp;
      }
 
      if(i==3){
    temp=p[21];
    p[21]=p[10];
    p[10]=temp;
     
    temp=p[30];
    p[30]=p[7];
    p[7]=temp;
    temp=p[27];
    p[27]=p[4];
    p[4]=temp;
    temp=p[24];
    p[24]=p[1];
    p[1]=temp;
 
    temp=p[16];
    p[16]=p[18];
    p[18]=temp;
      }
       
      sakuya++;
      saiki();
      sakuya--;
 
      if(i==0){
    temp=p[13];
    p[13]=p[18];
    p[18]=temp;
     
    temp=p[24];
    p[24]=p[9];
    p[9]=temp;
    temp=p[23];
    p[23]=p[8];
    p[8]=temp;
    temp=p[22];
    p[22]=p[7];
    p[7]=temp;
     
    temp=p[10];
    p[10]=p[12];
    p[12]=temp;
      }
       
      if(i==1){
    temp=p[12];
    p[12]=p[19];
    p[19]=temp;
     
    temp=p[22];
    p[22]=p[3];
    p[3]=temp;
    temp=p[25];
    p[25]=p[6];
    p[6]=temp;
    temp=p[28];
    p[28]=p[9];
    p[9]=temp;
     
    temp=p[13];
    p[13]=p[15];
    p[15]=temp;
      }
       
      if(i==2){
    temp=p[15];
    p[15]=p[16];
    p[16]=temp;
     
    temp=p[28];
    p[28]=p[1];
    p[1]=temp;
    temp=p[29];
    p[29]=p[2];
    p[2]=temp;
    temp=p[30];
    p[30]=p[3];
    p[3]=temp;
     
    temp=p[19];
    p[19]=p[21];
    p[21]=temp;
      }
       
      if(i==3){
    temp=p[21];
    p[21]=p[10];
    p[10]=temp;
     
    temp=p[30];
    p[30]=p[7];
    p[7]=temp;
    temp=p[27];
    p[27]=p[4];
    p[4]=temp;
    temp=p[24];
    p[24]=p[1];
    p[1]=temp;
     
    temp=p[16];
    p[16]=p[18];
    p[18]=temp;
      }
    }
  }
}

Measured memory_bytes: 1164
#ifdef DBG1
  #define LOCAL
#endif

#ifdef LOCAL
  #define _GLIBCXX_DEBUG
#endif

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#ifdef DBG1
    #define dbg(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dbg(...)
#endif

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;

bool solve() {
  int n, m;
  if (scanf("%d%d", &n, &m) != 2) { return false; }
  static char s[200][200];
  for (int i = 0; i < n; ++i) {
    scanf("%s", s[i]);
  }
  vector<vector<int>> d(n, vector<int>(m, n + m + 100));
  d[0][0] = (s[0][0] == '.' ? 0 : 1);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (i > 0) {
        d[i][j] = min(d[i][j], d[i - 1][j] + (s[i][j] == s[i - 1][j] ? 0 : 1));
      }
      if (j > 0) {
        d[i][j] = min(d[i][j], d[i][j - 1] + (s[i][j] == s[i][j - 1] ? 0 : 1));
      }
    }
  }
  int ans = d[n - 1][m - 1] + (s[n - 1][m - 1] == '.' ? 0 : 1);
  printf("%d\n", ans / 2);
  return true;
}

int main() {
  int tt = -1;
  //scanf("%d", &tt);
  while (tt-- && solve());
  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 h,a;
    cin >> h >> a;
    if(h%a > 0)cout << (h/a) + 1 << endl;
    else cout << h/a << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
pnt=sum(B)
for i in range(N-1):
  if A[i+1]==A[i]+1:
    pnt+=C[A[i]-1]

print(pnt)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> ii;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, t;
    priority_queue<int> pq;
    cin >> n >> m;
    for (int ctr1 = 0; ctr1 < n; ++ctr1)
        cin >> t, pq.push(t);
    for (int ctr1 = 0; ctr1 < m; ++ctr1) {
        t = pq.top();
        pq.pop();
        pq.push(t >> 1);
    }
    ll rez = 0;
    while(!pq.empty())
        rez += pq.top(), pq.pop();
    cout << rez << "\n";
    return 0;
}

Measured memory_bytes: 892
#include <stdio.h>
#define mod 1000000007 //10^9+7

long long calc(long long a,long long b){
	if(b==0)return 1;
	if(b%2==0){
		long long d = calc(a,b/2);
		return (d*d)%mod;
	}return (a*calc(a,b-1))%mod;
}

long long comb(long long n,long long m){
	long long tmp=1,tmp2=1;
	for(int i=n;i>=n-m+1;i--)tmp=(tmp*i)%mod;
	for(int i=1;i<=m;i++)tmp2 = (tmp2*i)%mod;
	return (tmp*calc(tmp2,mod-2))%mod;
}

int main(void){
	int N,i,p[100000]={0};
	long long M,m,ans=1,k=0;
	scanf("%d%lld",&N,&M);
	m=M;
	for(i=2;i*i<=M;i++){
		while(m%i==0){
			m/=i;
			p[k]++;
		}
		k++;
	}
	if(m>1)p[k]++;
	
	for(i=0;i<=k;i++){
		if(p[i]!=0)
		ans *= comb(p[i]+N-1,p[i]);
		ans %= mod;
	}
	
	printf("%lld",ans);
	
	return 0;
}

Measured memory_bytes: 512
N = int(input())
A = list(map(int, input().split()))
a = A.count(1)
b = A.count(2)
c = A.count(3)
"""
dp[i][j][k]: 残り１貫の皿がi, ２貫j, ３貫kの状態から全部食べ切るまでの期待値
"""
dp = [[[0.0] * (N+1) for _ in range(N+1)] for _ in range(N+1)]
 
# 先にiについて更新することで、dp[i""+1""][j-1][k]を可能にしている。
# 先にjについて更新することで、dp[i][j""+1""][k-1]を可能にしている。
for k in range(c + 1):
    for j in range(b + c + 1 - k): # ２貫の皿の数の最大値(a = 0のとき) - 3枚の皿の数
        for i in range(a + b + c + 1 - k - j):
            if i == 0 and j == 0 and k == 0:
                continue
            tmp = N * 1.0
            if i > 0:
                tmp += i * dp[i-1][j][k]
            if j > 0:
                tmp += j * dp[i+1][j-1][k]
            if k > 0:
                tmp += k * dp[i][j+1][k-1]
            dp[i][j][k] = tmp / (i + j + k)
print(dp[i][j][k])

Measured memory_bytes: 255752
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void) {
	long a, b;
	scanf("%ld %ld", &a, &b);
	long k = 1;
	int cnt = 0;
	while (1) {
		cnt++;
		k = k * b;
		if (k > a) break;
	}
	printf("%d", cnt);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int n;
    int ans;
    string s;
    cin >> n >> s;
    int countw=0;
    int counte=0;
    for(int i=1;i<n;i++){
        if(s.substr(i,1)=="E"){
            counte++;
        }
    }
    ans = counte;
    if(s.substr(0,1)=="W"){
        countw=1;
    }
     for(int i=1;i<n;i++){
         if(s.substr(i,1)=="E"){
             counte--;
             if(counte+countw<ans){
                 ans = counte+countw;
             }
         }else{
             countw++;
         }
    }
    cout << ans << endl;
}

Measured memory_bytes: 900
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    int N;cin>>N;
    vector<int> qu(N,0);
    REP(i,N)cin>>qu[i];
    sort(qu.begin(),qu.end());
    cout<<qu[N/2]-qu[N/2-1]<<endl;
}

Measured memory_bytes: 640
import java.util.*;
import java.math.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();

    String[] a = new String[n];
    String b = "";

    for (int i = 0; i < n; i++) {
      a[i] = sc.next();
    }

    for (int i = 0; i < m; i++) {
      b += sc.next();
    }

    if (n == m) {
      if (a[0].equals(b)) {
        System.out.println("Yes");
        return;
      }
    }

    for (int i = 0; i < n-m; i++) {
      for (int j = 0; j < n-m; j++) {
        if (solve(i,j,a,b,m)) {
          System.out.println("Yes");
          return;
        }
      }
    }

    System.out.println("No");

  }

  public static boolean solve (int i, int j, String[] a, String b, int m) {
    String k = "";
    for (int l = 0; l < m; l++) {
      k += a[j+l].substring(i,i+m);
    }

    if (k.equals(b)) {
      return true;
    }

    return false;

  }

}


Measured memory_bytes: 39636
#include<cstdio>
#include<iostream>

using namespace std;

int main(void) {

	int n, yen, x, y, z, mai, sum, kx, ky, kz;
	bool endswc;

	x = 10000;
	y = 5000;
	z = 1000;
	endswc = false;

	cin >> n >> yen;

	for (kx = 0; kx <= n; kx++) {
		if (endswc == true)break;
		for (ky = 0; ky <= n; ky++) {
			if (endswc == true)break;
			kz = n - kx - ky;
			sum = x * kx + y * ky + z * kz;
			if (kz >= 0 && sum == yen) {
				printf("%d %d %d\n", kx, ky, kz);
				endswc = true;
				break;
			}
			else if (kx == n && ky == n) {
				printf("-1 -1 -1\n");
			}
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <numeric>
#include <string>
#include <stdio.h>
#include <set>
#include <iomanip>
using namespace std;
 
 
int main(){
    int H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;
    cout << H2 * 60 + M2 - H1 * 60 - M1 - K << endl;
    return 0;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
using ll = long long;
using ld = long double;

void solve() {
    ll k;
    cin >> k;
    string s;
    cin >> s;
    if(s.size() <= k) {cout << s; return;}
    else {
        for(ll i = 0; i < k; i++) cout << s[i];
    }
    cout << "...";
}

int main() {
    ios_base :: sync_with_stdio(false); 
    cin.tie(NULL);
    ll t = 1;
    //cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>

using namespace std;

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

  int n, x;
  cin >> n >> x;
  int ans = 1;
  int prev = 0;
  int l = 0;
  for (int i = 0; i < n; i++) {
    cin >> l;
    int next = prev + l;
    if (next > x) break;
    ++ans;
    prev = next;
  }
  cout << ans << endl;
  return 0;
}


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

#define rep(i, l, r) for (ll i = (l); i <= (r); i++)
#define irep(i, r, l) for (ll i = (r); i >= (l); i--)
#define vec(t) vector<t>

using namespace std;
using ll = long long;
using vecint = vec(int);
using vecll = vec(ll);

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    map<int, int> m;

    int N, L;
    cin >> N >> L;

    vector<string> vs(N);
    rep(i,0,N-1) cin >> vs[i];

    sort(vs.begin(), vs.end());
    rep(i,0,N-1) cout << vs[i];
    cout << endl;


}

Measured memory_bytes: 256
def solve():
    H, W = map(int, input().split())
    S = [list(input()) for i in range(H)]
    org = [[0] * W for i in range(H)]
    # 縦ループ
    for i in range(H):
        #　横ループ
        for j in range(W):
            org[i][j] = S[i][j]
            if S[i][j] == '#':
                if canPaint(i, j, S, H, W) == True:
                    continue
                else:
                    return False
            else:
                continue
    return True


def canPaint(i, j, S, H, W):
    for x in range(-1, 2):
        for y in range(-1, 2):
            # その場と斜め以外の場合
            if (x == 0 or y == 0) and (x != 0 or y != 0):
                dx = x + j
                dy = y + i
                # 移動不可能
                if dx < 0 or dx > W - 1 or dy < 0 or dy > H - 1:
                    continue
                else:
                    if S[dy][dx] == '#':
                        return True
    return False
def main():
    if solve() == True:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()



Measured memory_bytes: 3064
L=list(map(int, input().split()))
A=L[0]
B=L[1]
C=L[2]

L[0]=B
L[1]=A
A=L[0]
B=L[1]

L[0]=C
L[2]=A
A=L[0]
C=L[2]

print(' '.join(map(str, L)))

Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		// 入力
		Scanner sc = new Scanner(System.in);
		double xp1 = sc.nextDouble();
		double yp1 = sc.nextDouble();
		Vector2d p1 = new Vector2d(xp1, yp1);
		double xp2 = sc.nextDouble();
		double yp2 = sc.nextDouble();
		Vector2d p2 = new Vector2d(xp2, yp2);
		int q = sc.nextInt();
		ArrayList<Vector2d> p = new ArrayList<>();
		for (int i=0; i<q; i++) {
			double x = sc.nextDouble();
			double y = sc.nextDouble();
			p.add(new Vector2d(x, y));
		}
		sc.close();

		for (int i=0; i<q; i++) {
			System.out.println(solve(p.get(i), p1, p2));
		}

	}

	static class Vector2d {

		Vector2d(Double x, Double y){
			this.x = x;
			this.y = y;
		}

		Double x;
		Double y;

		public String toString() {
			return String.format("%1$.10f %2$.10f", x, y);
		}
	}

	public static Vector2d add(Vector2d v1, Vector2d v2){
		return new Vector2d(v1.x + v2.x, v1.y + v2.y);
	}

	public static Vector2d sub(Vector2d v1, Vector2d v2){
		return new Vector2d(v2.x - v1.x, v2.y - v1.y);
	}

	public static Double sqNorm(Vector2d v){
		return v.x * v.x + v.y * v.y;
	}

	public static Double product(Vector2d v1, Vector2d v2){
		return v1.x * v2.x + v1.y * v2.y;
	}

	public static Vector2d extend(double s, Vector2d v){
		return new Vector2d(s * v.x, s * v.y);
	}

	public static Vector2d solve(Vector2d p, Vector2d p1, Vector2d p2) {
		Vector2d a = sub(p1, p2);
		Vector2d b = sub(p1, p);
		return add(p1, extend(product(a, b) / sqNorm(a), a));
	}
}



Measured memory_bytes: 45512
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using ll = unsigned long long;
using namespace std;

int main(void) {
    int r;
    cin >> r;

    string msg = "AGC";

    if ( r < 1200 ) {
        msg = "ABC";
    } else if ( r < 2800 ) {
        msg = "ARC";
    }

    cout << msg << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(long long i=0; i<(int)n; i++)
#define rep2(i,a,n) for(long long i=(a); i<(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using psi = pair<string, int>;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};
const int mod = 1e9+7;
int gcd(int a, int b){if(a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a * b / gcd(a, b);}

int N, M, K, H, W, L, R, X;
string S, T;
signed main(){
  cin >> N >> M;
  vi yaku;
  for(int i = 1; i*i <= M; i++){ 
    if(M%i==0){
      yaku.push_back(i);
      yaku.push_back(M/i);
    }
  }
  sort(all(yaku), greater<int>());
  rep(i,yaku.size()){
    if(M/yaku[i]>=N){
      cout << yaku[i] << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 3612
#include <stdio.h>
#include <iostream>
#include <cctype>
using namespace std;
int main(){
  char se[1199],alp='a',ch;
  int count[26]={},i=0,i2;

  while(cin>>ch){
    se[i]=ch;
    i++;
  }

  for(i2=0; i2<=i; i2++)if(isupper(se[i2]))se[i2]=tolower(se[i2]);
  
  for(i2=0; i2<=i; i2++)if(se[i2]-'a'>=0 && se[i2]-'a'<26)
			  count[se[i2]-'a']++;

  for(i=0; i<26; i++){
    printf("%c",alp+i);
    cout<<" : "<<count[i]<<"\n";
  }
  
}

Measured memory_bytes: 1148
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const ll MOD = 1e9+7;


#define REP(i, N) for (ll i = 0; i < (N); i++)
#define REPP(i, a, b) for (ll i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((ll)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<ll>>

using namespace std;


int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A[3][3],B[3][3];
    for(ll i = 0; i < 3;i++){
        for(ll l = 0; l < 3;l++){
            cin >> A[i][l];
            B[i][l] = 0;
        }
    }

    int n;
    cin >> n;
    for(ll i = 0; i < n;i++){
        int t;
        cin >> t;
        for(ll i = 0; i < 3;i++){
            for(ll l = 0; l < 3;l++){
                if(A[i][l] == t){
                    B[i][l] = 1;
                }
            }
        }
    }
    if(B[0][0] == 1 && B[1][1] == 1 && B[2][2] == 1){
        cout << "Yes" << endl;
        return 0;
    }
    if(B[2][0] == 1 && B[1][1] == 1 && B[0][2] == 1){
        cout << "Yes" << endl;
        return 0;
    }

    for(ll i = 0; i < 3;i++){
        if(B[i][0] == 1 && B[i][1] == 1 && B[i][2] == 1){
            cout << "Yes" << endl;
        return 0;
        }
    }
    for(ll i = 0; i < 3;i++){
        if(B[0][i] == 1 && B[1][i] == 1 && B[2][i] == 1){
            cout << "Yes" << endl;
        return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int N,K,p[1001];
	int sum = 0;
	cin>>N>>K;
	for(int i=0;i<N;i++) cin>>p[i];
	sort(p,p+N);
	for(int i=0;i<K;i++) sum += p[i];
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 3548