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

class Main {
    static Scanner scanner = new Scanner();
    static int mod = 1000000007;
    static long inf = 0xfffffffffffffffL;

    void solve() {
        int n = scanner.nextInt();
        char[] s = scanner.next().toCharArray();
        boolean[] has = new boolean[10];
        Set<Integer> set1 = new HashSet<>();
        Set<Integer> set = new HashSet<>();
        for (int i = 0; i < n; i++) {
            int j = s[i] - '0';
            if (0 < i) {
                for (int k : set1) {
                    set.add(k * 10 + j);
                }
            }
            for (int k = 0; k < 10; k++) {
                if (has[k]) {
                    set1.add(k * 10 + j);
                }
            }
            has[j] = true;
        }
        System.out.println(set.size());
    }

    public static void main(String[]$) {
        try {
            new Main().solve();
            System.out.flush();
        } catch (Throwable t) {
            System.out.flush();
            t.printStackTrace();
        }
    }
}

class System {
    static PrintWriter out = new PrintWriter(java.lang.System.out);

    static void exit() {
        java.lang.System.exit(0);
    }
}

class Scanner {
    private BufferedReader reader = new BufferedReader(new InputStreamReader(java.lang.System.in), 0x10000);
    private StringTokenizer tokenizer;

    String next() {
        try {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(reader.readLine());
            }
        } catch (IOException ignored) {
        }
        return tokenizer.nextToken();
    }

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

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

    char[][] nextCharArray(int n, int m) {
        char[][] a = new char[n][m];
        for (int i = 0; i < n; i++) {
            a[i] = next().toCharArray();
        }
        return a;
    }

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

    int[] nextIntArray(int n, IntUnaryOperator op) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        }
        return a;
    }

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

    long[] nextLongArray(int n, LongUnaryOperator op) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        }
        return a;
    }
}


Measured memory_bytes: 46632
def alsd12b
    n = gets.chomp.to_i
    an = gets.chomp.split(/\s/).map{|x| x.to_i}

    cnt = 0
    for i in 0..(n-1)
        minj = i
        for j in i..(n-1)
            if an[j] < an[minj]
                minj = j
            end
        end

        unless i == minj
            tmp = an[i]
            an[i] = an[minj]
            an[minj] = tmp
            cnt += 1
        end
    end

    puts an.join(' ')
    puts cnt
end

alsd12b


Measured memory_bytes: 6868
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;


void minimization()
{
  int n, k;
  cin >> n >> k;

  cout << ceil((float)(n - 1) / (float)(k - 1)) << "\n";
}


void linear_approximation()
{
  int n;
  cin >> n;
  vector<int> b(n);
  for (int i = 0; i < n; ++i)
  {
    int a;
    cin >> a;
    b[i] = a - (i + 1);
  }

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

  int mid = b[n / 2];
  long long int ans = 0;
  for (int i = 0; i < n; ++i) ans += abs(mid - b[i]);
  cout << ans << "\n";

}


void modulo_summation()
{
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    ans += a - 1;
  }

  cout << ans << "\n";
}


int main()
{
  //minimization();
  //linear_approximation();
  modulo_summation();
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;

ll p[51] = {};
int main() {
	ll n; cin >> n;
	ll cnt = 0;
	rep(i, 0, n) {
		cin >> p[i];
		if (p[i] != i+1)cnt++;
	}
	if (cnt <= 2) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}




	return 0;
}

Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))
ans = 0
m = 0
tmp_max = l[0]
check = False
for i in range(1, n):
    if l[i - 1] > l[i]:
        check = True
    elif check and l[i - 1] < l[i]:
        ans = ans + tmp_max - m
        tmp_max = l[i]
        m = l[i - 1]
        check = False
    elif not(check):
        tmp_max = l[i]
ans = ans + tmp_max - m
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

int main() {
  int n, sum = 0;
  cin >> n;
  int d[n];
  REP(i, n) cin >> d[i];
  REP(i, n - 1) for (int j = i + 1; j < n; ++j) {
    sum += d[i] * d[j];
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

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

    void run() {

        int sum = 0;

        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] arr = new int[n];
        for (int i=0; i<n; i++) arr[i] = sc.nextInt();

        for (int i=0; i<n; i++) sum += arr[i];

        double compare = (double)sum/(double)(4*m);

//        System.out.println(compare);

        int cnt = 0;

        for (int i=0; i<n; i++) {
            if ((double)arr[i]>=compare) cnt++;
        }

        if (cnt>=m) {
            System.out.println("Yes");
        } else {
            System.out.println("No");

        }


    }

}


Measured memory_bytes: 21844
import Data.List
--condition:decendent order sorted
pt::[Int]->(Int,Int)->(Int,Int)
pt [] (x,y) = (x,y)
pt (i:[]) (x,y) = (x+i,y)
pt (i:j:rest) (x,y) = pt rest (x+i,y+j)

solver::[Int]->Int
solver xs = let dec_std = sortBy (\ x -> \ y -> compare y x ) xs in
            let (a,b) = pt dec_std (0,0) in
            a-b

main::IO()
main=do
  _<-getLine
  dat<-getLine
  let ls = map read (words dat)
  print (solver ls) 

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main () {
	int h, w; cin >> h >> w;
	vector<string> c(h);
	rep(i, h) cin >> c[i];
	rep(i, h) {
		cout << c[i] << endl;
		cout << c[i] << endl;
	}
}


Measured memory_bytes: 256
import copy
from collections import deque

H,W=map(int,input().split())
S=[list(input()) for _ in range(H)]


def check(tup):
    global H
    global W
    global S

    tup_x=tup[0]
    tup_y=tup[1]
    if 0<=tup_x<H and 0<=tup_y<W:
        if S[tup_x][tup_y]=='.':
            return True
    else:
        return False

def neighbor(tup):
    x=tup[0]
    y=tup[1]
    cand=[(x-1,y),(x+1,y),(x,y-1),(x,y+1)]
    List=[]
    for c in cand:
        if check(c):
            List.append(c)
    return List

def bfs(start):#startはtuple型
    global H
    global W

    if check(start):
        deq=deque()#as queue
        Dict=[]
        component=[]
        for i in range(W):
            component.append(-1)
        for j in range(H):
            Dict.append(copy.copy(component))

        deq.append(start)
        Dict[start[0]][start[1]]=0
        while deq:
            now=deq.popleft()
            nexts=neighbor(now)
            for next in nexts:
                next_x=next[0]
                next_y=next[1]
                if Dict[next_x][next_y]>=0:
                    continue
                #if next in deq:
                    #continue
                deq.append(next)
                Dict[next_x][next_y]=Dict[now[0]][now[1]]+1

        M=[]
        for d in Dict:
            M.append(max(d))
        return max(M)
    
    else:
        return 0

Ans=[]
for k in range(H):
    for l in range(W):
        Ans.append(bfs((k,l)))

print(max(Ans))




Measured memory_bytes: 3424
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;

int main(){
    int n;
    cin >> n;
    long double x[n],y[n],ans=0;
    for(int i=0;i<n;i++){
        cin >> x[i] >> y[i];
    }
    
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i==j) continue;
            ans += sqrt((x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]));
            //cout << ans << endl;
        }
    }
    
    cout << fixed << setprecision(8) << ans/(double)n << endl;
}

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

int gcd(int a, int b){
    return (b == 0) ? a : gcd(b, a%b);
}

int main(){
    int a, b, c;
    cin >> a >> b >> c;

    int g = gcd(a,b);

    if(c%g == 0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
/*
    Author : manu_sy
*/
#include "bits/stdc++.h"
using namespace std;

/** Template Begins **/

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

#define IOS         ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl        '\n'
#define pb          push_back
#define F           first
#define S           second
#define mp          make_pair
#define all(a)      (a).begin(), (a).end()
#define FOR(i,a,b)  for(int i=a;i<=b;i++)
#define LP(i,n)     for(int i=0;i< n;i++)

/* Debug */

template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.F << "," << P.S << ")";
} 

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}

template<class TH> void _dbg(const char *sdbg, TH h){ cerr << sdbg << '=' << h << endl; }

template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',') cerr << *sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

/* Debug Ends */

const int N = 18+2;

/** Template Ends **/
int n;
char a[N], b[N];


signed main() {

    IOS;
    cin >> n;
    LP(i,n) cin >> a[i];
    LP(i,n) cin >> b[i];
    map<string, int> m;
    LP(mask,(1 << n)) {
        string r1 = "", b2 = "";
        LP(bit,n) ((mask>>bit)&1) ? r1 += a[bit] : b2 += a[bit];
        reverse(all(b2));
        // debug(r1, b2, r1+b2);
        m[r1+"#"+b2]++;
    }
    ll ans = 0;
    LP(mask,(1<<n)) {
        string b1 = "", r2 = "";
        LP(bit,n) ((mask>>bit)&1) ? r2 += b[bit] : b1 += b[bit];
        reverse(all(b1));
        ans += m[b1+"#"+r2];
        // debug(b1,r2,b1+r2);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 67968
import java.lang.reflect.Array;
import java.util.Scanner;

@FunctionalInterface
interface ObjIntPredicate<T> {
	boolean test(T t, int value);
}

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Scanner sc) {
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] X = new int[N];
		for (int i = 0; i < N; i++) {
			X[i] = sc.nextInt();
		}
		int nonNeg = binarySearch(X, (a, i) -> a[i] >= 0);
		if (nonNeg == 0) {
			System.out.println(X[K - 1]);
			return;
		} else if (nonNeg == N) {
			System.out.println(-X[N - K]);
			return;
		} else if (X[nonNeg] == 0 && nonNeg == N - 1) {
			System.out.println(-X[N - K + 1]);
			return;
		}
		int minCost = Integer.MAX_VALUE;
		for (int offset = 0; offset <= nonNeg; offset++) {
			int to = offset + K - 1;
			if (to >= N) break;
			if (X[nonNeg] == 0 ? to < nonNeg : to < nonNeg - 1) continue;
			int plusCost = X[to];
			int minusCost = Math.abs(X[offset]);
			int twicePlus = plusCost * 2 + minusCost;
			int twiceMinus = minusCost * 2 + plusCost;
			int cost = Math.min(twiceMinus, twicePlus);
			minCost = Math.min(cost, minCost);
		}
		System.out.println(minCost);
	}

	<T> int binarySearch(T array, ObjIntPredicate<T> predicate) {
		int l = -1;
		int r = Array.getLength(array);
		while (r - l > 1) {
			int bound = l + (r - l) / 2;
			if (predicate.test(array, bound)) r = bound;
			else l = bound;
		}
		return r;
	}
}

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

		Solver.INSTANCE.solve(in);

		in.close();
	}
}

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

#define ALL(a)  (a).begin(),(a).end()

int main(void){
    // Your code here!
    int N;
    
    cin >> N;
    vector<long> u(N), m(N), d(N);
    for(int i=0; i<N; i++) cin >> u[i];
    for(int i=0; i<N; i++) cin >> m[i];
    for(int i=0; i<N; i++) cin >> d[i];

    sort(ALL(u));
    sort(ALL(m));
    sort(ALL(d));

    long sum = 0;
    for(int i=0; i<N; i++) {
        long mi = m[i];
        long unum = lower_bound(ALL(u), mi) - u.begin();
        long dnum = d.end() - upper_bound(ALL(d), mi);
        
        sum += unum * dnum;
    }
    cout << sum;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
template <typename T>
using V = std::vector<T>;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

const u64 B = 100'000'007ULL;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  V<pair<size_t, string>> S(N);
  REP(i, N) {
    string s;
    cin >> s;
    S[i] = {s.size(), s};
  }
  sort(S.begin(), S.end());
  map<u64, V<int>> mp;
  i64 ans = 0;
  REP(i, N) {
    int len = S[i].first;
    const string& ss = S[i].second;
    V<int> char_cnt(26);
    REP(j, len) {
      int ch = ss[j] - 'a';
      char_cnt[ch]++;
    }
    u64 shash = 0;
    u64 base = B;
    if (len > 1) {
      for (int j = len - 1; j >= 1; --j) {
        REP(c, 26) {
          if (char_cnt[c] > 0) {
            auto it = mp.find(shash);
            if (it == mp.end()) continue;
            if (c < it->second.size()) ans += it->second[c];
          }
        }
        shash += base * ss[j];
        base *= B;
        --char_cnt[ss[j] - 'a'];
      }
    }
    int prefix = ss[0] - 'a';
    auto& v = mp[shash];
    if (v.empty()) v.resize(26);
    v[prefix]++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 36932
#include<bits/stdc++.h>
using namespace std;
inline long long read();
const int N=2e6+5;
long long a[N],b[N],c[N];
int main()
{
	int n,m;
	long long k,ans;
	cin>>n>>m;
	k=read();
	ans=0;
	for (int i=1;i<=n;i++)
	{
		a[i]=read();
	}
	for (int i=1;i<=m;i++)
	{
		b[i]=read();
		c[i]=c[i-1]+b[i];
	}
	long long temp=0,num;
	for (int i=0;i<=n;i++)
	{
		temp+=a[i];
		num=i;
		if (temp>k)   break;
		int l=1,r=m,t=-1;
		while (l<=r)
		{
			int mid=(l+r)/2;
			if (c[mid]>k-temp)
			{
				r=mid-1;
			}
			else
			{
				l=mid+1;
				t=mid;
			}   
		}
		if (t==-1)   ans=max(ans,num);
		else  ans=max(ans,num+t); 
	}
	cout<<ans;
	return 0;
}
inline long long read()
{
	long long x=0,f=1;
	char ch=getchar();
	while (!isdigit(ch))
	{
		if (ch=='-')   f=-1;
		ch=getchar();
	}
	while (isdigit(ch))
	{
		x=(x<<1)+(x<<3)+ch-'0';
		ch=getchar();
	}
	return x*f;
}

Measured memory_bytes: 8328
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
class Point {
public:
	long double px, py;
	Point() : px(0), py(0) {};
	Point(long double px_, long double py_) : px(px_), py(py_) {};
	bool operator==(const Point& p) const { return px == p.px && py == p.py; }
	bool operator!=(const Point& p) const { return px != p.px || py != p.py; }
	bool operator<(const Point& p) const { return px < p.px ? true : (px == p.px && py < p.py); }
	Point operator-(const Point& p) const { return Point(px - p.px, py - p.py); }
};
long double norm(const Point& a) { return a.px * a.px + a.py * a.py; }
long double dot(const Point& a, const Point& b) { return a.px * b.px + a.py * b.py; }
long double crs(const Point& a, const Point& b) { return a.px * b.py - a.py * b.px; }
int ccw(const Point& p0, const Point& p1, const Point& p2) {
	Point a = p1 - p0, b = p2 - p0;
	if (crs(a, b) > 1e-10) return 1;
	if (crs(a, b) < -1e-10) return -1;
	if (dot(a, b) < -1e-10) return 2;
	if (norm(a) < norm(b)) return -2;
	return 0;
}
vector<Point> convex_hull(vector<Point> v) {
	if (v.size() < 3) return v;
	sort(v.begin(), v.end());
	vector<Point> u = { v[0], v[1] }, l = { v[v.size() - 1], v[v.size() - 2] };
	for (int i = 2; i < v.size(); i++) {
		for (int n = u.size(); n >= 2 && ccw(u[n - 2], u[n - 1], v[i]) >= 0; n--) u.pop_back();
		u.push_back(v[i]);
	}
	for (int i = v.size() - 3; i >= 0; i--) {
		for (int n = l.size(); n >= 2 && ccw(l[n - 2], l[n - 1], v[i]) >= 0; n--) l.pop_back();
		l.push_back(v[i]);
	}
	reverse(l.begin(), l.end());
	for (int i = u.size() - 2; i >= 1; i--) l.push_back(u[i]);
	return l;
}
int main() {
	vector<Point>vec; Point p; char c;
	while (true) {
		int n; cin >> n;
		vec.clear();
		if (n == 0) { break; }
		for (int i = 0; i < n; i++) {
			cin >> p.px >> c >> p.py;
			vec.push_back(p);
		}
		cout << n - convex_hull(vec).size() << endl;
	}
}

Measured memory_bytes: 3148
#include <iostream>
#include <cmath>
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
 
int main() {
	double a, b, x;
	cin >> a >> b >> x;
	
	double c, ans;
	if (x == a*a*b) {
		ans = 0;
	} else if (x >= a*a*b / 2) {
		c = (b - x / a / a) * 2;
		ans = M_PI / 2 - atan(a / c);
	} else {
		c = x / a / b * 2;
		ans = M_PI / 2 - atan(c / b);
	}
	
	ans = ans * (double)180 / (double)M_PI;
	cout << std::setprecision(10) << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

const int mod = 998244353;
struct mint {
    ll x;
    mint (ll x = 0) : x((x%mod+mod)%mod) {}
    mint operator -() const {return mint(-x);}
    mint& operator +=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator -=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator *=(const mint a) {(x *= a.x) %= mod; return *this;}
    mint operator +(const mint a) const {return mint(*this) += a;}
    mint operator -(const mint a) const {return mint(*this) -= a;}
    mint operator *(const mint a) const {return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const {return pow(mod-2);}
    mint operator /=(const mint a) {return *this *= a.inv();}
    mint operator /(const mint a) {return mint(*this) /= a;}
};
istream& operator >>(istream &is, const mint &a) {return is >> a.x;}
ostream& operator <<(ostream &os, const mint &a) {return os << a.x;}

int main() {
    int n, s; cin >> n >> s;
    vint a(n);
    rep(i,n) cin >> a[i];
    vector<mint> dp(s+1,0);
    dp[0] = 1;
    rep(i,n) {
        for (int j = s; j >= 0; j--) {
            dp[j] *= 2;
            if (j - a[i] >= 0) dp[j] += dp[j-a[i]];
        }
    }
    mint ans = dp[s];
    cout << ans << endl;
}

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

int main()
{
    int H,W;
    
    while(1){
        cin>>H>>W;
        if(H==0&&W==0)break;

        for(int i=1;i<=H;i++){
            for(int j=1;j<=W;j++){
                char c;
                if(i%2==1){
                    if(j%2==1){
                        c='#';
                    }else{
                        c='.';
                    }
                }else{
                    if(j%2==1){
                        c='.';
                    }else{
                        c='#';
                    }
                }
                cout<<c;
            }
            cout<<endl;
        }
        cout<<endl;
    }


    return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<cmath>
#include<queue>
#include<string>
#include<set>
#include<map>
#include<bitset>
#include<stack>
#include<string>
#define UP(i,l,h) for(int i=l;i<h;i++)
#define DOWN(i,h,l) for(int i=h-1;i>=l;i--)
#define W(a) while(a)
#define MEM(a,b) memset(a,b,sizeof(a))
#define LL long long
#define INF 0x3f3f3f3f
#define MAXN 50050
#define MOD 1000000007
#define EPS 1e-3
#define int LL
using namespace std;
char s[200010];
map<char,int> mp;

main(){
    scanf("%s",s);
    int len=strlen(s);
    UP(i,0,len){
        mp[s[i]]++;
    }
    int ans=(len)*(len-1)/2;
    UP(i,'a','z'+1){
        if(mp[i])
            ans-=(mp[i]*(mp[i]-1))/2;
    }
    printf("%lld\n",ans+1);

}


Measured memory_bytes: 384
package main

import (
	"fmt"
	"log"
)

func main() {

	var N ,h int
//	var H []int //array or slice
	var base,count = 0,0

	_, err := fmt.Scan(&N)
	if err != nil {
		log.Fatal(err)
	}

	//
	for i := 0; i < N; i++ {
		_, err := fmt.Scan(&h)
		if err != nil {
			log.Fatal(err)
		}

		if h >= base{
			count++
			base = h
		}
		}

	//
	fmt.Println(count)
}


Measured memory_bytes: 512
N = int(input())

a = int(N**0.5)
b = a+1

res = []
for i in range(1,a+1):
  if N%i == 0:
    res.append([i, int(N/i)])
    
ans = 10**12 + 10
for i in range(len(res)):
  ans = min(ans, sum(res[i]))
  
print(ans-2)


Measured memory_bytes: 3544
my_max=0
my_sec=0
cnt=0
n=int(input())
a=[0]*n
r_n =range(n)
for i in r_n:
  a[i]=int(input())
  if my_max<a[i]:
    my_max=a[i]
  elif my_sec<a[i]:
    my_sec=a[i]
    
for i in r_n:
  if my_max==a[i]:
    cnt+=1
    
for i in r_n:
  if my_sec!=0:
    if my_max!=a[i]:
      print(my_max)
    elif cnt>1:
      print(my_max)
    else:
      print(my_sec)
  else:
    print(my_max)
  
  
 

Measured memory_bytes: 12604
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
typedef long long ll;

int main() {
  string s;
  cin >> s;
  if(s.at(2)==s.at(3)&&s.at(4)==s.at(5)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
import math

n = int(input())
folia = list(map(int, input().split()))
#print(n, folia)

seq = [[folia[-1], folia[-1]]]

for i in range(n): # 深さ'n'分
    tmp = folia[-(i+2)]
    sml = math.ceil(seq[i][0] / 2) + tmp 
    big = seq[i][1] + tmp
    seq += [[sml, big]]
#print(seq)

if not (seq[-1][0] <= 1 <= seq[-1][1]):
    print(-1)
    exit()

ans =[1]
for j in range(n): # 深さ'n'分
    tmp = min((ans[j] - folia[j]) * 2, seq[-(j+2)][1])
    ans.append(tmp)
print(sum(ans))


Measured memory_bytes: 33572
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
			int N = sc.nextInt();
			int[] n = new int[3];
				for(int i=0; i<N; i++)
				{
					n[0] = sc.nextInt();
					n[1] = sc.nextInt();
					n[2] = sc.nextInt();
					Arrays.sort(n);
						if(n[2]*n[2] == n[0]*n[0] + n[1]*n[1])
						{
							System.out.println("YES");
						} else {
							System.out.println("NO");
						}
				}
		}
}

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

using namespace std;

int main(){
	int a, b;
	char op;
	while(true){
	cin >> a >> op >> b;
	if(op == '?') break;
	else if(op == '+') cout << a + b;
	else if(op == '-') cout << a - b;
	else if(op == '*') cout << a * b;
	else if(op == '/') cout << a / b;
	cout << endl;
	}
}

Measured memory_bytes: 1160
// C++ code to find maximum possible product of
// sub-sequence of size k from given array of n
// integers
#include <algorithm> // for sorting
#include <iostream>
using namespace std;
typedef long long ll;
const int mod = 1e9+7;

// Required function
ll maxProductSubarrayOfSizeK(ll A[], int n, int k)
{
	// sorting given input array
	sort(A, A + n);

	// variable to store final product of all element
	// of sub-sequence of size k
	ll product = 1;

	// CASE I
	// If max element is 0 and
	// k is odd then max product will be 0
	if (A[n - 1] == 0 && (k & 1))
		return 0;

	// CASE II
	// If all elements are negative and
	// k is odd then max product will be
	// product of rightmost-subarray of size k
	if (A[n - 1] <= 0 && (k & 1)) {
		for (int i = n - 1; i >= n - k; i--)
			product *= A[i], product %= mod;
		return product;
	}

	// else
	// i is current left pointer index
	int i = 0;

	// j is current right pointer index
	int j = n - 1;

	// CASE III
	// if k is odd and rightmost element in
	// sorted array is positive then it
	// must come in subsequence
	// Multiplying A[j] with product and
	// correspondingly changing j
	if (k & 1) {
		product *= A[j], product %= mod;
		j--;
		k--;
	}

	// CASE IV
	// Now k is even
	// Now we deal with pairs
	// Each time a pair is multiplied to product
	// ie.. two elements are added to subsequence each time
	// Effectively k becomes half
	// Hence, k >>= 1 means k /= 2
	k >>= 1;

	// Now finding k corresponding pairs
	// to get maximum possible value of product
	for (int itr = 0; itr < k; itr++) {

		// product from left pointers
		ll left_product = A[i] * A[i + 1];

		// product from right pointers
		ll right_product = A[j] * A[j - 1];

		// Taking the max product from two choices
		// Correspondingly changing the pointer's position
		if (left_product > right_product) {
			product *= left_product % mod, product %= mod;
			i += 2;
		}
		else {
			product *= right_product % mod, product %= mod;
			j -= 2;
		}
	}

	// Finally return product
	return product;
}

// Driver Code to test above function
int main()
{
	int n, k;
	cin >> n >> k;
	ll a[n];
	for(int i=0; i<n; i++) scanf("%lld", &a[i]);
	ll ans = maxProductSubarrayOfSizeK(a, n, k);
   if(ans < 0) ans += mod;
   cout << ans;
}


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

#define    int               long long int
 #define    bp(x)         __builtin_popcount(x)
#define  ld         long double
 #define  f(i,j,n)            for(int i = j; i <= n; i++)
#define  r(i,n,j)       for(int i = n; i >= j; i--)
 #define  all(container)       container.begin() , container.end()
#define  sz(container)   (int)container.size()
 #define  ff             first
#define  ss             second
 #define  pii      pair <int , int>
#define  sp(x)       setprecision(x)
#define  mod  1000000007
#define  endl  "\n"
 #define  pb    push_back
#define  mp    make_pair
 #define  T     int ttt; cin >> ttt; while(ttt--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);

int b[100005][2],n,a[105];
int solve(int rem,int prev){
    int &x=b[rem][prev];
    if(x!=-1)   return x;
    x=1;
    f(i,1,n)
        if(rem-a[i]>=0)
            x&=solve(rem-a[i],prev^1);
    x=x^1;
    return x;
}

int32_t main()
{
    fast
    int k;    cin>>n>>k;
    f(i,0,k+1)  b[i][0]=b[i][1]=-1;
    f(i,1,n)    cin>>a[i];
    if(solve(k,0)==0)   cout<<"Second";
    else      cout<<"First";
}

Measured memory_bytes: 12912
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define INF 1000000007
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2)*pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int jo(int n) {
	int ans = 1;
	rep(i, n) {
		ans *= 2;
	}
	return ans;
}
int a[100010], b[100010];
signed main() {
	int n, k,ans=0;
	cin >> n >> k;
	rep(i, n) {
		cin >> a[i] >> b[i];
	}
	sort(a, a + n);
	int sum = a[n - 1];
	sort(b, b + n);
	reverse(b, b + n);
	rep(i, n) {
		if (k <= 0) { cout << ans << endl; ggr; }
		else if (b[i] >sum) {
			ans++;
			k -= b[i];
		}
	}
	if (k <= 0) { cout << ans << endl; }
	else if (k%sum == 0) {
		cout << k / sum + ans << endl;
	}
	else {
		cout << k / sum + ans + 1 << endl;
	}
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>

using namespace std;
typedef long long int ll;

int main()
{
	int n;
	int a[200000];
	scanf("%d", &n);
	for(int i=0; i<n; i++){
		scanf("%d", &a[i]);
	}
	int d[200000][20];
	int p[20];
	p[0]=1;
	for(int i=1; i<20; i++){
		p[i]=p[i-1]*2;
	}
	vector<int> v[20];
	for(int i=0; i<n; i++){
		for(int j=19; j>=0; j--){
			d[i][j]=a[i]/p[j];
			a[i]%=p[j];
		}
	}
	for(int i=0; i<20; i++){
		for(int k=0; k<n; k++){
			if(d[k][i]==1) v[i].push_back(k);
		}
	}
	ll ans=0;
	for(int l=0; l<n; l++){
		int rmax=n;
		for(int i=0; i<20; i++){
			if(v[i].empty()) continue;
			auto itr=lower_bound(v[i].begin(), v[i].end(), l);
			if(itr==v[i].end()) continue;
			itr++;
			if(itr==v[i].end()) continue;
			if(rmax>*itr) rmax=*itr;
		}
		ans+=((ll)(rmax-l));
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 24824
#include <iostream>
#include <string>
#include <vector>

using namespace std;
using int_vec = vector<int>;


int_vec kmp_table(const string& p) {
    auto m = p.size();
    int_vec A(m + 1);

    A[0] = -1;
    int j = -1;
    for (int i = 0; i < m; ++i) {
        while (j >= 0 && p[i] != p[j])
            j = A[j];
        j++;
        A[i + 1] = j;
    }
    return A;
}


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

    string text, p;
    cin >> text >> p;

    auto A = kmp_table(p);
    auto m = p.size();
    auto n = text.size();
    int i = 0;
    int j = 0;
    while (i < n) {
        while (j >= 0 && text[i] != p[j]) {
            j = A[j];
        }
        ++i; ++j;
        if (j == m) {
            auto k = i - m;
            cout << k << endl;
            j = A[j];
        }
    }

    return 0;
}

Measured memory_bytes: 4528
W, H, x, y, r = input().split()

if int(r) <= int(x) and int(x) <= int(W) - int(r):
    if int(r) <= int(y) and int(y) <= int(H) - int(r):
        print("Yes")
    else:
        print("No")

else:
    print("No")

Measured memory_bytes: 7716
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 5e5 + 10;
#define fi first
#define se second
#define pb push_back
int t[26][N];
int n,q;
char a[N];
void add(int x,int p,int d){
  for(;p<N;p+=p&-p)t[x][p]+=d;
}
int get(int x,int p){
  int d=0;
  for(;p;p-=p&-p)d+=t[x][p];
  return d;
}
int main() {
  ios::sync_with_stdio(false);
  cin>>n>>a+1>>q;
  for(int i=1;i<=n;i++){
    add(a[i]-'a',i,1);
  }
  for(int i=1;i<=q;i++){
    int o;
    cin>>o;
    if(o==1){
      int p;char d;
      cin>>p>>d;
      add(a[p]-'a',p,-1);
      a[p]=d;
      add(a[p]-'a',p,1);
    }else{
      int l,r,ans=0;
      cin>>l>>r;
      for(int j=0;j<26;j++){
        if(get(j,r)-get(j,l-1))ans++;
      }
      cout<<ans<<'\n';
    }
  }
  return 0;
}

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

namespace ConsoleApp11
{
    class Class62
    {
        static void Main()
        {
            var I = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var N = I[0];
            var A = I[1];
            var B = I[2];
            long ans = (N - 2)*(B - A);
            if (N == 1) { Console.WriteLine(B == A ? 1 : 0);return; }
            Console.WriteLine(ans >= 0 ? ans + 1 : 0);
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
 
int main() { 
  int N;
  int A;
  int B;
 
    
  cin >> N >> A >> B;
  
  if (((A * N) < B) || ((A * N) == B)) {
    cout << A * N << endl;
  }
  else if ((A * N) > B) {
    cout << B << endl;
  } 
}



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

int main(){
    int N;
    cin>>N;
    vector<int> C(N),V(N);
    for(int i=0;i<N;i++){
        cin>>V[i];
    }
    for(int i=0;i<N;i++){
        cin>>C[i];
    }
    int value=0;
    for(int i=0;i<N;i++){
        if(V[i]-C[i]>0){
            value+=V[i]-C[i];
        }
    }
    cout<<value<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define input freopen("1.txt","r",stdin);
#define output freopen("output.txt","w",stdout);
#define ll long long int
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define vi vector<int>
#define vii vector<vi>
#define vl vector<ll>
#define vll vector<vl>
#define pii pair<int, int>
#define pll pair<ll,ll>
#define mp make_pair
#define vpi vector<pii>
#define vpl vector<pll> 
using namespace std;
 
const int p = 1e9 + 7;
const int maxn = 1e5 + 2;

bool doesitexceed (vi a, int mid, int K) {
    int total_cuts = 0;
    for(int i : a) {
        total_cuts += (i <= mid) ? 0 : ((i % mid != 0) ? i/mid : i/mid -1); 
    }
    return total_cuts > K;
}

void solve() {
    int N, K; cin>>N>>K;
    vi a; a.resize(N);
    for(int i=0; i<N; i++) cin>>a[i]; 
    int beg = 1, end = p, mid;
    while(beg != end) {
        mid = beg + (end - beg)/2;
        if(doesitexceed(a, mid, K)) beg = mid + 1;
        else end = mid;
    }
    cout<<beg<<"\n";
}

int main() {
    fast 
    // input output
    int t=1; 
    // cin>>t; 
    while(t--) solve();
    return 0;
}


Measured memory_bytes: 4752
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int[][] a;
		a = new int[13][11];
		int n = scan.nextInt();
		int i;
		for(i = 1; i <= n; ++i){
			int b = scan.nextInt();
			int f = scan.nextInt();
			int r = scan.nextInt();
			int v = scan.nextInt();
			a[(b - 1) * 3 + f][r] = a[(b - 1) * 3 + f][r] + v;
		}
		int q;
		for(i = 1; i <= 12; ++i){
			for(q = 1; q <= 10; ++q){
				System.out.print(" "+a[i][q]);
				}
			if(i % 3 == 0){
				if(i == 12)
					break;
				System.out.println();
				for(int v = 1;v <= 20; ++v)
				System.out.print("#");
			}
			if(i == 12)
				break;
			System.out.println();
		}
		System.out.println();
	}
}

Measured memory_bytes: 29100
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int INF=1e9;
const long double eps=1e-9;
const int maxn=1e5+10;
const int maxk=2e3+10;
int Blk[maxk][maxk],Wht[maxk][maxk];
inline int read(){
	int x=0,flag=1;
	char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')flag=-1,ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return x*flag;
}
int main(){
	int i,j,k,m,n;
	n=read();k=read();
	for(i=1;i<=n;i++){
		int x=read(),y=read(),z;
		x%=2*k;y%=2*k;
		if(x==0)x=2*k;
		if(y==0)y=2*k;
		char ch=getchar();
		while(!isalpha(ch))ch=getchar();
		if(ch=='W')Wht[x][y]++;
		else Blk[x][y]++;
	}
	for(i=1;i<=2*k;i++)
		for(j=1;j<=2*k;j++){
			Wht[i][j]=Wht[i][j-1]+Wht[i-1][j]-Wht[i-1][j-1]+Wht[i][j];
			Blk[i][j]=Blk[i][j-1]+Blk[i-1][j]-Blk[i-1][j-1]+Blk[i][j];
		}
	int ans=0;
	for(i=1;i<=k;i++)
		for(j=1;j<=k;j++){
			int curans;
			curans=0;
			curans+=Wht[i-1][j-1]+Wht[i+k-1][j+k-1]-Wht[i+k-1][j-1]-Wht[i-1][j+k-1]+Wht[i-1][j-1]
					+Wht[2*k][2*k]-Wht[i+k-1][2*k]-Wht[2*k][j+k-1]+Wht[i+k-1][j+k-1]
					+Wht[2*k][j-1]-Wht[i+k-1][j-1]+Wht[i-1][2*k]-Wht[i-1][j+k-1];
			curans+=Blk[2*k][2*k]-(Blk[i-1][j-1]+Blk[i+k-1][j+k-1]-Blk[i+k-1][j-1]-Blk[i-1][j+k-1]
					+Blk[i-1][j-1]+Blk[2*k][2*k]-Blk[i+k-1][2*k]-Blk[2*k][j+k-1]+Blk[i+k-1][j+k-1]
					+Blk[2*k][j-1]-Blk[i+k-1][j-1]+Blk[i-1][2*k]-Blk[i-1][j+k-1]);
			curans=max(curans,n-curans);
			if(curans==5)printf("%d %d\n",i,j);
			ans=max(ans,curans);
		}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 31744
import collections
N, M = map(int, input().split())
A = list(map(int, input().split()))

# 普通の累積和
cumsum = [0]
for i in range(N):
    cumsum.append(cumsum[-1] + A[i])

# 上で作った累積和のmodMを計算
cumsum_2 = []
for i in range(N + 1):
    cumsum_2.append(cumsum[i] % M)

c = collections.Counter(cumsum_2)

ans = 0
for v in c.values():
    ans += v * (v - 1) // 2

print(ans)


Measured memory_bytes: 105388
/*
 * @Date         : 2020-08-09 01:21:15
 * @Author       : ssyze
 * @Description  :
 */
#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 5;

int a[maxn << 1], tree[maxn << 1], vis[maxn], ans[maxn], n, q;
struct point {
    int l, r, id;
} qs[maxn];

inline int lowbit(int x) { return x & -x; }

void add(int pos, int val)
{
    while (pos <= n) tree[pos] += val, pos += lowbit(pos);
}

int query(int pos)
{
    int res = 0;
    while (pos > 0) res += tree[pos], pos -= lowbit(pos);
    return res;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> q;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= q; i++) {
        cin >> qs[i].l >> qs[i].r;
        qs[i].id = i;
    }
    sort(qs + 1, qs + q + 1, [&](point a, point b) { return a.r < b.r; });
    int st = 1;
    for (int i = 1; i <= q; i++) {
        for (int j = st; j <= qs[i].r; j++) {
            if (!vis[a[j]]) {
                vis[a[j]] = j;
                add(j, 1);
            }
            else if (vis[a[j]]) {
                add(vis[a[j]], -1);
                vis[a[j]] = j;
                add(j, 1);
            }
        }
        st = qs[i].r + 1;
        ans[qs[i].id] = query(qs[i].r) - query(qs[i].l - 1);
    }
    for (int i = 1; i <= q; i++) cout << ans[i] << endl;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> w(N);
  for(int i = 0; i < N; i++) {
    cin >> w[i];
  }

  int S1 = 0, S2 = 0;
  int i = 0, j = N-1;
  while (i <= j) {
    if(S1 <= S2) {
      S1 += w[i];
      i++;
    }
    else{
      S2 += w[j];
      j--;
    }
  }

  int ans = abs(S1-S2);
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
count = 0

def merge(a, left, mid, right):
    global count

    l = a[left:mid]
    r = a[mid:right]
    l.append(10**9+1)
    r.append(10**9+1)

    i = 0
    j = 0
    for k in range(left, right):
        count += 1
        if l[i] <= r[j]:
            a[k] = l[i]
            i += 1
        else:
            a[k] = r[j]
            j += 1


def mergeSort(a, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        mergeSort(a, left, mid)
        mergeSort(a, mid, right)
        merge(a, left, mid, right)


if __name__ == '__main__':
    n = int(input())
    a = [int(x) for x in input().split()]

    mergeSort(a, 0, n)

    print(*a)
    print(count)


Measured memory_bytes: 61656
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define endl "\n"
#define fr(i, n) for (int i = 0; i < n; i++)
#define frf(i, j, n) for (int i = j; i <= n; i++)
#define frd(i, n) for (int i = n; i >= 0; i--)
#define mp(i, j) make_pair(i, j)
#define pb(x) push_back(x)
#define PRIME 1000000007
#define max 200006
// bool a[max];
using namespace std;
typedef vector<vector<ll>> matrix;
// ll e[max], f[max];
int main()
{
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    // int t;
    // cin >> t;
    // while (t--)
    // {

    // }
    int k;
    string s;
    cin >> k;
    cin >> s;
    int l = s.length();
    if (l <= k)
        cout << s;
    else
    {
        //int i=0;
        for (int i = 0; i < k; i++)
        {
            cout << s[i];
        }
        cout << "...";
    }
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <string.h>
#define SIZE 21

int main(void){
	char str[SIZE] = {};
	char ch;
	int i = 0;

	i = 0;
	while ((ch = getchar()) != '\n') {
		str[i] = ch;
		i++;
		if (i >= SIZE - 1){
			break;
		}
	}

	for (i = strlen(str) - 1; i >= 0; i--){
		printf("%c", str[i]);
	}

	printf("\n");

	return 0;
}

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


int main() {
  double x1, y1, x2, y2, x3, y3, x4, y4, x, y;
  cin >> x1 >> y1 >> x2 >> y2;
  x = x2-x1; 
  y = y2-y1;
  x3 = x2-y;
  y3 = y2+x;
  x4 = x1-y;
  y4 = y1+x;
  cout << x3 << " " << y3 << " "<< x4 << " " << y4 << endl;
}


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

using namespace std;

bitset <4000010> bs;

int main() {
  int n;
  scanf("%d", &n);
  bs.reset();
  bs.set(0);
  int ans = 0;
  while (n--) {
    int foo;
    scanf("%d", &foo);
    bs |= bs << foo;
    ans += foo;
  }
  ++ans;
  ans /= 2;
  while (bs[ans] == 0) {
    ++ans;
  }
  printf("%d\n", ans);
}


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

#define MAX 50

int N, M;
int a[MAX];
int b[MAX];
int c[MAX];
int d[MAX];

int main() {
	cin >> N >> M;
	for( int i = 0; i < N; i++ ) {
		cin >> a[i] >> b[i];
	}
	for( int i = 0; i < M; i++ ) {
		cin >> c[i] >> d[i];
	}

	for( int i = 0; i < N; i++ ) {
		int aa = a[i];
		int bb = b[i];
		int mi = INT32_MAX;
		int ans = 0;
		for( int j = 0; j < M; j++ ) {
			int dist = abs(c[j] - aa) + abs(d[j] -bb);
			if( dist < mi ) {
				mi = dist;
				ans = j + 1;
			}
		}
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
using namespace std;
int main(){
	register int T, x, y;
	register long long ans, p;
	scanf("%d", &T);
	while (T--) {
		scanf("%d %d", &x, &y);
		ans = sqrt(1ll * x * y - 1);
		if (1ll * ans * ans > 1ll * x * y - 1) --ans;
		p = ans * 2 - 1;
		if (ans * ans + ans > 1ll * x * y - 1) --p;
		if (x == y) ++p;
		printf("%lld\n", p);
	}
	return 0;
}

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

int main(){
  string s,t; cin >> s>> t;
  bool flag = true;
  if(s.size() + 1 == t.size()) {
    rep(i,s.size()) {
      if(s.at(i) != t.at(i)) flag = false;
    }
    if(flag) {
      cout << " Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


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

using namespace std;
string s;

int main(){
    getline(cin, s);
    for(long long i = 0 ; i <= 25; i++){
        char t1 = (char)(i + (int)'a');
        for(long long j = 0; j < s.size() - 1; j++){
            if(s[j] == t1 && s[j + 1] == t1){
                cout << j + 1 << " " << j + 2;
                return 0;
            }
        }
        for(long long j = 0; j < s.size() - 2; j++){
            if(s[j] == t1 && s[j + 2] == t1){
                cout << j + 1 <<" " << j + 3;
                return 0;
            }
        }
    }
    cout << "-1 -1";
}


Measured memory_bytes: 512
//
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
//
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

// solution 
use std::collections::HashSet;
#[allow(unused_mut)]
#[allow(non_snake_case)]
fn main() {
    input!{
        c: [[i64; 3]; 3]
    }

    let mut a = [0; 3];
    let mut b = [0; 3];
    a[0] = 0;
    b[0] = c[0][0];
    b[1] = c[0][1] - a[0];
    b[2] = c[0][2] - a[0];
    a[1] = c[1][0] - b[0];
    a[2] = c[2][0] - b[0]; 

    for i in 1..3 {
        for j in 1..3 {
            if c[i][j] != a[i] + b[j] {
                println!("No");
                return
            }
        }
    }

    println!("Yes");
}


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

using namespace std;

int h,w;
int n;

bool solve(){
    int i,j;
    int sr,sc;
    string s,t;
    cin >> h >> w >> n;
    cin >> sr >> sc;
    cin >> s;
    cin >> t;
    int l = 0,r = w,u = 0,d = h;
    for(i = n-1;i >= 0;i--){
        if(t[i] == 'L' && r < w) r++;
        if(t[i] == 'R' && l > 0) l--;
        if(t[i] == 'U' && d < h) d++;
        if(t[i] == 'D' && u > 0) u--;
        if(s[i] == 'L'){ l++; if(r==l) return false; }
        if(s[i] == 'R'){ r--; if(r==l) return false; }
        if(s[i] == 'U'){ u++; if(u==d) return false; }
        if(s[i] == 'D'){ d--; if(u==d) return false; }
    }
    return (u<sr && sr<=d && l<sc && sc<=r);
}

int main(){
    if(solve()) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 776
import sys
input=sys.stdin.readline
from collections import Counter

def main():
    n=int(input())
    A=list(map(int,input().split()))
    q=int(input())
    BC=[list(map(int,input().split())) for _ in range(q)]
    C=Counter(A)
    ans=sum(A)
    for b,c in BC:
        cnt=C[b]
        ans+=(c-b)*cnt
        C[b]=0
        C[c]+=cnt
        print(ans)
    
if __name__=='__main__':
    main()

Measured memory_bytes: 102924
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    long k = sc.nextLong();
    int count = 0;
    while(n > 0){
      n = n/k;
      count++;
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 21588