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

//update 2020/1/1 23:01

public class Main{

  static Scanner sc = new Scanner(System.in);
  static StringBuilder sb = new StringBuilder();

  public static void main(String[] args) {

    String s = next();
    String t = next();
    String[] ss = splitString(s);
    String[] tt = splitString(t);

    boolean ok = true;

    for(int i=0;i<ss.length;i++){
      if(!(ss[i].equals(tt[i]))){
        ok = false;
      }
    }



    if(ok){
      System.out.println("Yes");
    }
    else{
      System.out.println("No");
    }

  }

  static int lcm(int a,int b){
    return a*b*gcd(a,b);
  }

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

  /*
    static String toSmall(String s){
      char c = s.charAt(0);
      //if(Character.isUpperCase(c)){
      if(c<=90){
        c += 32;
      }
      return String.valueOf(c);
    }
    static String toBig(String s){
      char c = s.charAt(0);
      //if(Character.isLowerCase(c)){
      if(c>=97){
        c -= 32;
      }
      return String.valueOf(c);
    }
  */

  static String toSmall(String s){
    return s.toLowerCase();
  }

  static String toBig(String s){
    return s.toUpperCase();
  }

  static String next(){
    return sc.next();
  }

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

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

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

  static String[] splitString(String s){
    return s.split("");
  }

  static char[] splitChar(String s){
    return s.toCharArray();
  }

  static int charToInt(char a){
    return a - 48;
  }

////////////////////////////////////////////
  public static int max(int[] a){
    int lng = a.length;
    int max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
  public static long max(long[] a){
    int lng = a.length;
    long max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
////////////////////////////////////////////

////////////////////////////////////////////
  public static int min(int[] a){
    int lng = a.length;
    int min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
  public static long min(long[] a){
    int lng = a.length;
    long min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
////////////////////////////////////////////

}


Measured memory_bytes: 35732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    int n; cin >> n;
    int a[30], b[30], c[30];
    a[0] = -1;
    rep(i, n) {
        cin >> a[i+1];
    }
    rep(i, n) {
        cin >> b[i+1];
    }
    rep(i, n-1) {
        cin >> c[i+1];
    }
    int score = 0;
    for(int i=1; i<=n; i++){
        int tmp = a[i];
        score += b[tmp];
        if(a[i] - a[i-1] == 1) {
            score += c[a[i-1]];
        }
    }
    cout << score <<endl;
}

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

using namespace std;

const int MAXN=100100;

struct data
{
	int num,ord;
	char c;
};

int split(data* A,int s,int t)
{
	int x=A[t].num;
	int i=s-1;
	for(int j=s;j<t;j++)
		if(A[j].num<=x)
			swap(A[j],A[++i]);
	swap(A[++i],A[t]);
	return i;
}

void Quick_Sort(data* A,int s,int t)
{
	if(s>=t) return ;
	int w=split(A,s,t);
	//printf("%d %d %d\n",s,w,t);
	Quick_Sort(A,s,w-1);
	Quick_Sort(A,w+1,t);
}

int cmp(const void* ta,const void* tb)
{
	data a=*(data*)ta,b=*(data*)tb;
	if(a.num!=b.num) return a.num-b.num;
	return a.ord-b.ord;
}

int main()
{
	int n;
	static data A[MAXN],B[MAXN];
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%s%d",&A[i].c,&A[i].num);
		B[i]=A[i];
		B[i].ord=i;
	}
	qsort(B,n,sizeof(data),cmp);
	Quick_Sort(A,0,n-1);
	bool flag=true;
	for(int i=0;i<n;i++)
		if(B[i].c!=A[i].c)
		{
			flag=false;
			break;
		}
	if(flag)
		printf("Stable\n");
	else
		printf("Not stable\n");
	for(int i=0;i<n;i++)
		printf("%c %d\n",A[i].c,A[i].num); 
	return 0;
}

Measured memory_bytes: 6312
s = gets.chomp.split("").map(&:to_i)
n = s.size
 
def base10(arr)
  n = arr.size - 1
  return n.downto(0).map{|x| arr[n - x]*10**x}.inject(:+)
end
 
if n == 1 then
  puts s[0]
else
  ans = [base10(s)]
  idxar = (1..(n-1)).to_a
  (1..(n-1)).each do |i|
    idxar.combination(i).each do |x|
      x = [0] + x + [n]
      ans << x.each_cons(2).map{|from, to| s.slice(from, (to - from))}.map{|arr| base10(arr)}.inject(:+)
    end
  end
  puts ans.inject(:+)
end


Measured memory_bytes: 1916
N = int(input())
A = list(map(int,input().split()))

count = [0]*(N+1)

for i in range(N):
  count[A[i]] += 1

#print(count)

total = 0
for j in range(1,N+1):
  cj = count[j]*(count[j]-1)//2
  #print(cj)
  total = total + cj

ans = total
for k in range(N):
  ans = total - (count[A[k]] - 1)
  print(ans)

Measured memory_bytes: 32248
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
int main()
{
   int n;
   scanf("%d", &n);
   if   (n>=400 && n<=599) printf("8");
   else if(n>=600 && n<=799) printf("7");
   else if(n>=800 && n<=999) printf("6");
   else if(n>=1000 && n<=1199) printf("5");
   else if(n>=1200 && n<=1399) printf("4");
   else if(n>=1400 && n<=1599) printf("3");
   else if(n>=1600 && n<=1799) printf("2");
   else if(n>=1800 && n<=1999) printf("1");
}


Measured memory_bytes: 1584
N = int(input())
s = [input() for _ in range(N)]
M = int(input())
t = [input() for _ in range(M)]

ans_list = []
for i in range(N):
    say_word = s[i]
    ans_list.append(s.count(say_word) - t.count(say_word))

print(max(max(ans_list),0))

Measured memory_bytes: 3064
#include <stdio.h>

int main(void){

  int a, b;
  scanf("%d %d", &a, &b);

  int fuyashitai = b-1;
  int fueru = a-1;
  int kosuu = fuyashitai / fueru;
  if (fuyashitai % fueru != 0) {
    kosuu++;
  }
  printf("%d\n", kosuu);

  return 0;
}

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

def compress(L):
    L2 = list(set(L))
    L2.sort()
    C = {v : k for k, v in enumerate(L2, 1)}
    return L2, C

def order(a, b, c, d):
    if a == b == c == d:
        return 4
    if a == c and b == d:
        return 2
    return 1


limit = 5
calc = [[None]*limit for _ in range(limit*400)]
for i in range(limit*400):
    calc[i][1] = i
    for j in range(2, limit):
        calc[i][j] = calc[i][j-1]*(i-j+1)
pp = [[pow(i, j) for j in range(10)] for i in range(10)]

N = int(readline())
C = [tuple(map(int, readline().split())) for _ in range(N)]
D = Counter()



Rot = []
for i in range(N):
    a, b, c, d = C[i]
    Rot.append((a, b, c, d))
    Rot.append((d, a, b, c))
    Rot.append((c, d, a, b))
    Rot.append((b, c, d, a))
Lc, Cr = compress(Rot)
Lc = [None] + Lc
Cc = []

Od = Counter()
Base = Counter()
D = Counter()
for i in range(N):
    a, b, c, d = C[i]
    a, b, c, d = min((a, b, c, d), (b, c, d, a), (c, d, a, b), (d, a, b, c))
    od = order(a, b, c, d)
    r1 = Cr[(a, b, c, d)]
    r2 = Cr[(b, c, d, a)]
    r3 = Cr[(c, d, a, b)]
    r4 = Cr[(d, a, b, c)]
    Base[r1] = r1
    Base[r2] = r1
    Base[r3] = r1
    Base[r4] = r1
    Od[r1] = od
    Od[r2] = od
    Od[r3] = od
    Od[r4] = od
    Cc.append((r1, r2, r3, r4))
    D[r1] += 1


ans = 0
for i in range(N):
    D[Cc[i][0]] -= 1
    a, b, c, d = Lc[Cc[i][0]]
    for j in range(i+1, N):
        D[Cc[j][0]] -= 1
        for idx in range(4):
            e, f, g, h = Lc[Cc[j][idx]]
            E = Counter()
            r1 = (b, e, h, c)
            if r1 not in Cr:
                continue
            r1 = Base[Cr[r1]]
            r2 = (a, f, e, b)
            if r2 not in Cr:
                continue
            r2 = Base[Cr[r2]]
            r3 = (d, g, f, a)
            if r3 not in Cr:
                continue
            r3 = Base[Cr[r3]]
            r4 = (c, h, g, d)
            if r4 not in Cr:
                continue
            r4 = Base[Cr[r4]]
            
            E[r1] += 1
            E[r2] += 1
            E[r3] += 1
            E[r4] += 1            
            res = 1
            for k, n in E.items():
                res *= calc[D[k]][n] * pp[Od[k]][n]
            ans += res
        
        D[Cc[j][0]] += 1

print(ans)


Measured memory_bytes: 58840
s = input()
P = ""
if(len(s)%2 == 0):
    P = s[:(len(s)//2)]+s[(len(s)//2-1)::-1]
else:
    P = s[:len(s)//2]+s[len(s)//2]+s[(len(s)//2-1)::-1]
cnt = 0

for j in range(len(s)):
    if(s[j] != P[j]):
        cnt += 1
print(cnt)

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

int main(){
  int n, m, k;
  cin >> n >> m >> k;

  for(int l=0; l<=n; l++){
    int tb = m * l;
    for(int c=0; c<=m; c++){
      int b = tb + (n-2*l) * c ;
      if(b == k){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import re

def enc(s):
    repatter = re.compile(r"[aiueo]")
    ans = s[0]
    for i in range(len(s)):
        if i < len(s)-1 and repatter.match(s[i]):
            ans += s[i+1]
    return ans

def max_str(s):
    ans = len(s[0])
    for i in s:
        ans = max(ans, len(i))
    return ans

def func(s, mn, k):
    if mn < k:
        return -1
    ss = []
    for i in s:
        ss.append(i[:k])
    for i in range(len(ss)-1):
        pp = ss.pop(0)
        if pp in ss:
            return func(s, mn, k+1)
    return k

if __name__ == "__main__":
    while True:
        n = int(input())
        if n is 0:
            break
        s = []
        for i in range(n):
            s.append(enc(input()))
        print(func(s, max_str(s), 1))

Measured memory_bytes: 7972
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int main()
{
	int a,b,x;
	while(cin>>a>>b>>x)
	{
		if(a+b>=x && a<=x) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
}

Measured memory_bytes: 256
w,h,n = map(int,input().split())
lists = [list(map(int,input().split())) for i in range(n)]
x1 = 0
x2 = w
y1 = 0
y2 = h
for x,y,a in lists:
    if a == 1:
        x1 = max(x1,x)
    elif a == 2:
        x2 = min(x2,x)
    elif a == 3:
        y1 = max(y1,y)
    elif a == 4:
        y2 = min(y2,y)
x = max(0,(x2 - x1))
y = max(0,(y2 - y1))
ans = max(0,x*y)
print(ans)

Measured memory_bytes: 9156
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

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

    int n; string s;
    cin >> n >> s;

    int ans = 0;
    rep(i, 10) rep(j, 10) rep(k, 10) {
        int now = 0;
        rep(l, n) {
            if (now == 0) {
                if (s[l] == '0' + i) now = 1;
            } else if (now == 1) {
                if (s[l] == '0' + j) now = 2;
            } else if (now == 2) {
                if (s[l] == '0' + k) {
                    now = 3;
                    break;
                }
            }
        }
        if (now == 3) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3680
import sys
input = sys.stdin.readline
N = int(input())
X = [[] for i in range(N)]
for i in range(N-1):
    a, b, c = map(int, input().split())
    X[a-1].append((b-1, c))
    X[b-1].append((a-1, c))

P = [-1] * N
DE = [0] * N
F = [0] * N
Q = [0]
while Q:
    i = Q.pop()
    for a, d in X[i][::-1]:
        if a != P[i]:
            P[a] = i
            DE[a] = DE[i] + 1
            F[a] = F[i] + d
            X[a].remove((i, d))
            Q.append(a)
KK = 17
D = [[P[i] for i in range(N)]] + [[-1]*N for _ in range(KK - 1)]
for k in range(1, KK):
    for i in range(N):
        a = D[k-1][i]
        if a > 0:
            D[k][i] = D[k-1][a]

def lca(u, v):
    if DE[u] < DE[v]:
        u, v = v, u
    while DE[u] > DE[v]:
        d = DE[u] - DE[v]
        dd = d.bit_length() - 1
        u = D[dd][u]
    if u == v:
        return u
    for i in range(KK)[::-1]:
        if D[i][u] != D[i][v]:
            u = D[i][u]
            v = D[i][v]
    return D[0][u]

def dist(u, v):
    w = lca(u, v)
    return F[u] + F[v] - F[w] * 2

T, K = map(int, input().split())
K -= 1
for _ in range(T):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    print(dist(a, K) + dist(b, K))

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

bool isExp(int x) {
	if(x == 1) return true;
	for(int i = 2; i <= sqrt(x); i++) {
		if(x % i != 0) continue;
		int n = x;
		for(int j = 0; n > 1; j++) {
			n /= i;
			if(n == 1) return true;
			if(n % i != 0) break;
		}
	}
	return false;
}
int main() {
	int x;
	cin >> x;
	// cout << isExp(x);
	for(int i = x; i > 0; i--) {
		if(isExp(i)) {
			cout << i << endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 256
n = int(input())
a =[[[0 for i in range(10)]for j in range(3)]for k in range(4)]

for i in range(n):
    b, f, r, v = map(int, input().split())

    a[b-1][f-1][r-1] += v

for i in range(4):
    for j in range(3):
        for k in range(10):
            print("", a[i][j][k], end='')
        print()
    if i != 3:
        print("#" * 20) 

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

typedef long long ll;
typedef unsigned long long ull;

int main(){
    pair<ll,ll> dt[100000];
    int N, K;
    cin >> N >> K;
    for(int i=0;i<N;i++){
        ll t, d;
        cin >> t >> d;
        dt[i] = {d, t};
    }
    sort(dt,dt+N,[&](pair<ll,ll> a, pair<ll,ll> b){return a.first>b.first;});
    ll ans = 0;
    unordered_set<ll> t_used;
    priority_queue<ll,vector<ll>,greater<ll>> use;
    queue<ll> unuse;
    ll count = 0, t_count = 0;
    for(int i=0;i<N;i++){
        if(t_used.count(dt[i].second) > 0){
            unuse.push(dt[i].first);
        }else{
            t_used.insert(dt[i].second);
            ans += dt[i].first;
            use.push(dt[i].first);
            t_count++;
            count++;
        }
        if(count >= K) break;
    }
    while(count < K){
        count++;
        ll t = unuse.front();
        use.push(t);
        ans += t;
        unuse.pop();
    }
    
    while(!unuse.empty() && use.top()+t_count*t_count < unuse.front()+(t_count-1)*(t_count-1)){
        ll t = unuse.front(), tt = use.top();
        unuse.pop();
        use.pop();
        ans += t-tt;
        t_count--;
        use.push(t);
    }

    cout << ans+t_count*t_count << endl;
    
    return 0;
}

Measured memory_bytes: 6048
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
#include <list>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    string N;
    cin >> N;
    int S = 0;
    for (int i = 0; i < N.size(); ++i) {
        S += N[i] - '0';
    }
    cout << (stoi(N) % S == 0 ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
t = int(input())
for i in range(t):
    n,k = map(int,input().strip().split(' '))#入力
    x = []
    x = list(map(int,input().strip().split(' ')))
    x.sort()

    I = []
    for j in range(n-1):
        I.append(x[j+1]-x[j])
    I.sort()
    # print(I)

    L = x[n-1] - x[0]
    if k != 0:
        if k <= n:
            for j in range(k-1):
                L = L - I[n-2-j]
                del I[n-2-j]
        else:
            L = 0
    print(L)



Measured memory_bytes: 18024
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long ;

int main(){
	ll w , h , x , y ;
	cin >> w >> h >> x >> y ;
	if ( w % 2 == 0 && h % 2 == 0 && w/2 == x && h/2 == y ){
		cout << fixed << setprecision(9) << w*h/2.0 << ' ' << 1 << endl;
	}
	else
		cout << fixed << setprecision(9) << w*h/2.0 << ' ' << 0 << endl;
	return 0 ;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int b[999999];

int prime(int x) {
	for (int i = 2; i < sqrt(x) + 1; i++) {
		if (x%i == 0) {
			return 0;
		}
	}
	return 1;
}
int main(){
	int n;
	b[0] = 0;
	b[1] = 0;
	b[2] = 1;
	int count = 1;
	for (int i = 3; i <= 999999; i++) {
		if (prime(i))count++;
		b[i] = count;
	}
	while (scanf("%d", &n) != EOF){
		printf("%d\n", b[n]);
	}
	return 0;
}

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

using namespace std;

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

  long long ans = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] <= b[i]) {
      ans += a[i];
      b[i] -= a[i];
      if (a[i+1] <= b[i]) {
        ans += a[i+1];
        a[i+1] = 0;
      } else {
        ans += b[i];
        a[i+1] -= b[i];
      }
    } else {
      ans += b[i];
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1024
S = input()
c = "keyence"
if S[-7:] == c or S[:7] == c:
    print("YES")
else:
    for i in range(1, 7):
        c_, _c = c[:i], c[i:]
        if S[:i] == c_ and S[-(7-i):] == _c:
            print("YES")
            break
    else:
        print("NO")

Measured memory_bytes: 61956
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <iomanip>
int main()
{
    int A,B;
    std::cin >> A >> B;
    double temp=(double)(B-1)/(double)(A-1);
    int c =std::ceil(temp);
    std::cout << c << std::endl;
    return 0;
}

Measured memory_bytes: 256
def resolve():
    import sys
    input = lambda: sys.stdin.readline().rstrip() 
    INF = 10**12

    sq_diff = tuple(tuple((i-j)**2 for j in range(256)) for i in range(256))
    while True:
        N, M = map(int, input().split())
        C = tuple(int(input()) for _ in range(M))
        x = tuple(int(input()) for _ in range(N))
        if N==M==0:
            break
        else:
            normalize = tuple(tuple(255 if i+c>255 else 0 if i+c<0
                    else i+c for c in C) for i in range(256))
            dp_cur = [INF]*256
            dp_cur[128] = 0
            dp_next = [INF]*256
            for i in x:
                sq_diff_x = sq_diff[i]
                for j, cost_cur in enumerate(dp_cur):
                    normalize_j = normalize[j]
                    for l in normalize_j:
                        cost_next = cost_cur + sq_diff_x[l]
                        if cost_next < dp_next[l]:
                            dp_next[l] = cost_next

                dp_cur = dp_next[:]
                dp_next = [INF]*256

            print(min(dp_cur))

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 8912
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <limits>
#include <unordered_map>
#include <unordered_set>
#include <math.h>
#include <fstream>
#include <iterator>
#include <random>
#include <chrono>


#define forr(i,start,count) for (int i = (start); i < (start)+(count); ++i)
#define set_map_includes(set, elt) (set.find((elt)) != set.end())
#define readint(i) int i; cin >> i
#define readll(i) ll i; cin >> i
#define readdouble(i) double i; cin >> i
#define readstring(s) string s; cin >> s

typedef long long ll;

using namespace std;

int main()   {
    cout.precision(17);
    ll modd = 1000 * 1000 * 1000 + 7;
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    uniform_int_distribution<int> rand_gen(0, modd);   // rand_gen(rng) gets the rand no
    ll infinit = 10000000000000000;


//    readint(test_cases);
    int test_cases = 1;
    forr(t, 1, test_cases) {
        readll(n);

        ll ret = 0;
        forr(i,1,n) {
            if ((i%3!=0) && (i%5!=0)) {
                ret += i;
            }
        }
        cout << ret << endl;
    }
    return 0;
}


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

int main() {
  vector<int> fib(100, 0);
  fib[0]=fib[1]=1;
  for (int i=2; i<100; i++) fib[i]=fib[i-1]+fib[i-2];
  int n; cin>>n;
  cout<<fib[n]<<endl;
}



Measured memory_bytes: 3116
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

pdd operator-(pdd a, pdd b) { return pdd(a.first - b.first, a.second - b.second); }
pdd operator+(pdd a, pdd b) { return pdd(a.first + b.first, a.second + b.second); }
pdd operator*(pdd a, double b) { return pdd(a.first * b, a.second * b); }
double operator/(pdd a, pdd b) { return a.first * b.second - a.second * b.first; }
double len(pdd a) { return hypot(a.first, a.second); }
pdd norm(pdd a) {
	double l = len(a);
	return pdd(a.first / l, a.second / l);
}
int isame(pdd a, pdd b) { return len(a - b) < ERR; }
double is_par(pdd a, pdd b) { return fabs(norm(a) / norm(b)) < 1e-13; }

pdd get_p(pdd a, pdd b, pdd c, pdd d) {
	double u = ((a - c) / b) / (d / b);
	return c + d * u;
}

int Do(vector <pdd> A, vector <pdd> B, int f) {
	int c = 0;
	rep(i, 3) rep(j, 3) c += isame(A[i], B[j]);
	if (c == 3) return 1;
	if (f < 3 - c) return 0;
	rep(i, 3) rep(j, 3) if (!isame(A[i], B[j])) {
		int a = (i + 1) % 3, b = (i + 2) % 3;
		if (is_par(A[a] - A[b], A[i] - B[j])) {
			vector <pdd> C = A;
			C[i] = B[j];
			if (Do(C, B, f - 1)) return 1;
		}
	}
	if (f == 3 - c) return 0;
	rep(i, 3) {
		rep(j, 3) if (i != j) rep(k, 3) {
			int u = 3 - i - j;
			if (is_par(A[j] - B[k], A[j] - A[u])) continue;
			pdd in = get_p(A[i], A[u] - A[j], A[u], A[j] - B[k]);
			vector <pdd> C = A;
			C[i] = in;
			if (Do(C, B, f - 1)) return 1;
		}
	}
	return 0;
}

int main() {
	while (1) {
		vector <pdd> A, B;
		A.resize(3); B.resize(3);
		rep(i, 3) {
			if (scanf("%lf%lf", &A[i].first, &A[i].second) == EOF) return 0;
		}
		rep(i, 3) {
			if (scanf("%lf%lf", &B[i].first, &B[i].second) == EOF) return 0;
		}
		if (Do(A, B, 3)) puts("3");
		else if (Do(A, B, 4)) puts("4");
		else puts("Many");
	}

	return 0;
}

Measured memory_bytes: 3264
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main() {
  int N, M;
  cin >> N;
  vector<string> U;
  string s;
  bool open, f;
  for (int i = 0; i < N; ++i) {
    cin >> s;
    U.push_back(s);
  }
  cin >> M;
  open = false;
  for (int i = 0; i < M; ++i) {
    cin >> s;
    f = true;
    for (int j = 0; j < N; ++j) {
      if (U[j] == s) {
	f = false;
	if (open) {
	  cout << "Closed by " << s << endl;
	  open = false;
	} else {
 	  cout << "Opened by " << s << endl;
	  open = true;
	}
      }
    }
    if (f) cout << "Unknown " << s << endl;
  }
}

Measured memory_bytes: 3240
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <sstream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <complex>
#include <vector>
#include <cstdio>
#include <cmath>
#include <utility>
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
using namespace std;

template<class T>inline string toString(T x){
        ostringstream sout; sout<<x; return sout.str();
}
const ll MOD=1e9+7;
const int inf=(ll)1e9;
const double PI=acos(-1.0);



int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.precision(10);
    cout<<fixed;
    int n,m;
    while(cin>>n>>m,n){
    	int ldp[201][201];
    	int sdp[201][201];
    	for(int i=0;i<n;i++){
    		for(int j=0;j<n;j++){
    			ldp[i][j]=inf;
    			sdp[i][j]=inf;
    		}
    	}
    	for(int i=0;i<n;i++){
    		ldp[i][i]=0;
    		sdp[i][i]=0;
    	}
    	for(int i=0;i<m;i++){
    		int a,b,c;
    		char d;
    		cin>>a>>b>>c>>d;
    		a--;b--;
    		if(d=='L'){
    			ldp[a][b]=c;
    			ldp[b][a]=c;
    		}else{
    			sdp[a][b]=c;
    			sdp[b][a]=c;
    		}
    	}
    	for(int k=0;k<n;k++){
    		for(int i=0;i<n;i++){
    			for(int j=0;j<n;j++){
    				ldp[i][j]=min(ldp[i][k]+ldp[k][j],ldp[i][j]);
    				sdp[i][j]=min(sdp[i][k]+sdp[k][j],sdp[i][j]);
    			}
    		}
    	}
    	int r;cin>>r;
    	int a[1002];
    	for(int i=0;i<r;i++){
    		cin>>a[i];
    		a[i]--;
    	}
    	int dp[1001][201];
    	for(int i=0;i<1001;i++)for(int j=0;j<201;j++)dp[i][j]=inf;
    	dp[0][a[0]]=0;
    	for(int i=0;i<r-1;i++){
    		for(int j=0;j<n;j++){
    			if(dp[i][j]==inf)continue;
    			for(int k=0;k<n;k++){
	    			dp[i+1][k]=min(dp[i+1][k],dp[i][j]+ldp[a[i]][j]+sdp[j][k]+ldp[k][a[i+1]]);
	    			if(j==k)dp[i+1][k]=min(dp[i+1][k],dp[i][j]+ldp[a[i]][a[i+1]]);
    			}
    		}
    	}
    	/*for(int i=0;i<r;i++){
    		for(int j=0;j<n;j++){
    			cerr<<dp[i][j]<<" ";
    		}
    		cerr<<"\n";
    	}*/
    	int ans=inf;
    	for(int i=0;i<201;i++){
    		ans=min(ans,dp[r-1][i]);
    	}
    	cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 4272
from heapq import heappush,heappop
n,m=map(int,input().split())
lrc=[list(map(int,input().split())) for i in range(m)]
data=[[] for i in range(n+1)]
for i in range(2,n+1):
    data[i].append([i-1,0])
for u in lrc:
    l,r,c=u
    data[l].append([r,c])
lst=[]
flag=[-1]*(n+1)
flag[1]=0
for u in data[1]:
    heappush(lst,[u[1],u[0]])
while lst:
    c,r=heappop(lst)
    if r==n:
        print(c)
        break
    if flag[r]==-1:
        flag[r]=c
        for u in data[r]:
            if flag[u[0]]==-1:
                heappush(lst,[c+u[1],u[0]])
else:
    print(-1)

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

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

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

    cout << N << endl;
    return 0;
}


Measured memory_bytes: 3644
from collections import deque
import sys
input = sys.stdin.readline

H, W = map(int, input().split())
Ch, Cw = map(lambda x: int(x) - 1, input().split())
Dh, Dw = map(lambda x: int(x) - 1, input().split())
S = [input().rstrip() for _ in range(H)]
visited = [[False] * W for _ in range(H)]
dq = deque([(0, Ch, Cw)])
while dq:
    d, i, j = dq.popleft()
    if (i, j) == (Dh, Dw):
        print(d)
        exit()
    if visited[i][j]:
        continue
    visited[i][j] = True
    for di, dj in [(1, 0), (0, 1), (-1, 0), (0, -1)]:
        ni, nj = i + di, j + dj
        if 0 <= ni < H and 0 <= nj < W and S[ni][nj] == '.':
            dq.appendleft((d, ni, nj))
    for di in range(-2, 3):
        for dj in range(-2, 3):
            if di == dj == 0:
                continue
            ni, nj = i + di, j + dj
            if 0 <= ni < H and 0 <= nj < W and S[ni][nj] == '.' and not visited[ni][nj]:
                dq.append((d + 1, ni, nj))
print(-1)


Measured memory_bytes: 235988
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>


using namespace std;

int main() {
    long long a, b, n;
    cin >> a >> b >> n;

    int ans;
    if (n >= b) {
        ans = floor(a * (b - 1) / b);
    }
    else {
        ans = floor(a * n / b);
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
n,k=map(int,input().split())
x=list(map(int,input().split()))
ans=10**10
for i in range(n-k+1):
    if x[i+k-1]<=0:
        if ans>abs(x[i]):
            ans=abs(x[i])
    elif x[i]>=0:
        if ans>abs(x[i+k-1]):
            ans=abs(x[i+k-1])
    else:
        if ans>min(abs(x[i]),abs(x[i+k-1]))*2+max(abs(x[i]),abs(x[i+k-1])):
            ans=min(abs(x[i]),abs(x[i+k-1]))*2+max(abs(x[i]),abs(x[i+k-1]))
print(ans)


Measured memory_bytes: 14480
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int SQRT_N = 317;
const int MAX_N = SQRT_N*SQRT_N;
int dat[MAX_N] = {};
int bucket_min[SQRT_N] = {};
int lazy_bucket_update[SQRT_N] = {};
bool lazy_flag_update[SQRT_N] = {};

void init() {
	rep(i, 0, MAX_N) {
		dat[i] = 0;
	}
	rep(k, 0, SQRT_N) {
		bucket_min[k] = 0;
	}
}

void update(int l, int r, int val) {
	for (int k = 0; k < SQRT_N; k++) {
		int bl = k * SQRT_N, br = (k + 1) * SQRT_N;
		if (r <= bl || br <= l)
			continue;
		if (l <= bl && br <= r) {
			lazy_bucket_update[k] = val;
			lazy_flag_update[k] = true;
			bucket_min[k] = val;
		}
		else {
			if (lazy_flag_update[k]) {
				for (int i = bl; i < br; i++) {
					dat[i] = lazy_bucket_update[k];
				}
				lazy_flag_update[k] = false;
			}
			for (int i = max(l, bl); i < min(r, br); i++) {
				dat[i] = val;
			}
			int mini = dat[bl];
			for (int i = bl; i < br; i++) {
				chmin(mini, dat[i]);
			}
			bucket_min[k] = mini;
		}
	}
}

int find(int l, int r) {
	int mini = 1;
	for (int k = 0; k < SQRT_N; k++) {
		int bl = k * SQRT_N, br = (k + 1) * SQRT_N;
		if (r <= bl || br <= l)
			continue;
		if (l <= bl && br <= r) {
			chmin(mini, bucket_min[k]);
		}
		else {
			if (lazy_flag_update[k]) {
				for (int i = bl; i < br; i++) {
					dat[i] = lazy_bucket_update[k];
				}
				lazy_flag_update[k] = false;
			}
			for (int i = max(l, bl); i < min(r, br); i++) {
				chmin(mini, dat[i]);
			}
		}
	}
	return mini;
}

template<class T, class ...Tail>
void tiedSort(vector<T> &a, vector<Tail>&... tail) {
	int n = a.size();
	using S = tuple<T, Tail...>;
	vector<S> s(n);
	for (int i = 0; i < n; i++)
		s[i] = make_tuple(a[i], tail[i]...);
	sort(s.begin(), s.end());
	for (int i = 0; i < n; i++)
		tie(a[i], tail[i]...) = s[i];
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M, Q; cin >> N >> M >> Q;
	vector<int> D(M), A(M), B(M); rep(i, 0, M) {
		cin >> D[i] >> A[i] >> B[i];
		A[i]--, B[i]--;
	}
	tiedSort(D, A, B);
	dump(D, A, B);
	vector<int> idx(Q); iota(all(idx), 0);
	vector<int> E(Q), S(Q), T(Q); rep(i, 0, Q) {
		cin >> E[i] >> S[i] >> T[i];
		S[i]--, T[i]--;
	}
	tiedSort(E, S, T, idx);
	dump(E, S, T,idx);
	init();
	vector<string> ans(Q);
	int m = 0;
	rep(q, 0, Q) {
		while (m < M&&D[m] < E[q]) {
			update(A[m], B[m], 1);
			m++;
		}
		if (S[q] >= T[q]) {
			ans[idx[q]] = "Yes";
		}
		else {
			if (find(S[q], T[q]) == 1) {
				ans[idx[q]] = "Yes";
			}
			else {
				ans[idx[q]] = "No";
			}
		}
		//cout << dat[0]; rep(i, 1, N) { cout << " " << dat[i]; } cout << endl;
	}
	rep(i, 0, ans.size()) { cout << ans[i] << endl; }
	return 0;
}


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

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            string str;
            for (int i = 0; i < input[0]; ++i)
            {
                str = Console.ReadLine();
                Console.Write("{0}\n{0}\n", str);
            }
        }
    }
}


Measured memory_bytes: 3032
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

//ll dx[4] = {1, 0, -1, 0};
//ll dy[4] = {0, 1, 0, -1};

ll fact[214514];
ll inv[214514];

ll nCr(int n, int r) {
	ll ans = mod(mod(fact[n] * inv[n - r], MOD) * inv[r], MOD);
	return ans;
}

int main() {
	IOS();
	ll n, m, k;
	cin >> n >> m >> k;
	fact[0] = inv[0] = 1;
	for (int i = 1; i <= 200000; i++) {
		fact[i] = (fact[i - 1] * i) % MOD;
		inv[i]  = powm(fact[i], MOD - 2, MOD);
	}
	ll ans = 0;
	for (int i = 1; i <= n - 1; i++) {
		ll tmp = (n - i) * m * m;
		tmp	= (tmp * i) % MOD;
		ans += tmp;
		ans %= MOD;
	}
	for (int i = 1; i <= m - 1; i++) {
		ll tmp = (m - i) * n * n;
		tmp	= (tmp * i) % MOD;
		ans += tmp;
		ans %= MOD;
	}
	ans *= nCr(n * m - 2, k - 2);
	ans %= MOD;
	//dump(nCr(10, 0));
	dump(ans);
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> a(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    vector<ll> rui(n + 1, 0);
    for (ll i = 0; i < n; i++)
    {
        rui[i + 1] = rui[i] + a[i];
    }
    map<ll, ll> mp;
    for (ll i = 1; i <= n; i++)
    {
        mp[rui[i]]++;
    }
    ll ans = 0;
    for (auto p : mp)
    {
        if (p.first == 0)
        {
            ans += (1 + p.second) * p.second / 2;
        }
        else
        {
            ans += (p.second - 1) * p.second / 2;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 15872
package main

import (
  "bufio"
  "fmt"
  "os"
  "sort"
  "strconv"
)

//============================================================
var sc = bufio.NewScanner(os.Stdin)

func cout(out string) { fmt.Println(out) }
func setScSplit()     { sc.Split(bufio.ScanWords) }
func stoi(str string) int {
  num, _ := strconv.Atoi(str)
  return num
}
func itos(num int) string {
  str := strconv.Itoa(num)
  return str
}
func gsf() string {
  sc.Scan()
  return sc.Text()
}
func gif() int {
  i := stoi(gsf())
  return i
}
func gff() float64 {
  f, _ := strconv.ParseFloat(gsf(), 64)
  return f
}
func uniq(list []int) []int {
  m := make(map[int]struct{}) // 空のstructを使う
  for _, ele := range list {
    m[ele] = struct{}{} // m["a"] = struct{}{} が二度目は同じものとみなされて重複が消える。
  }
  uni := []int{}
  for i := range m {
    uni = append(uni, i)
  }
  return uni
}
func usort(list []int) []int {
  sort.Sort(sort.IntSlice(list))
  return list
}
func dsort(list []int) []int {
  sort.Sort(sort.Reverse(sort.IntSlice(list)))
  return list
}
func push(t *[]int, x int) {
  tmp := *t
  *t = append(tmp, x)
}
func pop(t *[]int) int {
  tmp := *t
  x := tmp[len(tmp)-1]
  *t = tmp[:len(tmp)-1]
  return x
}
func deq(t *[]int) int {
  tmp := *t
  x := tmp[0]
  *t = tmp[1:]
  return x
}

//=============================================================

func main() {
  setScSplit()
  x, a, b := gif(), gif(), gif()
  x -= a
  x -= (x / b) * b
  cout(itos(x))
}


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

int main() {
	int a,b;
  	cin >> a >> b;
  
  	int ans = a * b;
  
  	if(ans % 2 == 0) {
      cout << "Even" << endl;
    }else {
      cout << "Odd" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
const int maxn = 3000010;
const int inf = 0x7f7f7f7f;

int n;
int mp1[maxn], mp2[maxn], max = -1;

int main() {
	memset(mp1, 0, sizeof(mp1));
	memset(mp2, 0, sizeof(mp2));
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) {
		int x;
		scanf("%d", &x);
		max = std::max(max, x);
		if(i & 1) mp1[x]++;
		else mp2[x]++;
	}
	int max_num1 = 0, max_num2 = 0;
	int ci_num1 = 0, ci_num2 = 0;
	for(int i = 0; i <= max; ++i) {
		if(mp1[max_num1] <= mp1[i]) {
			ci_num1 = max_num1;
			max_num1 = i;
		} else if(mp1[ci_num1] <= mp1[i]) {
			ci_num1 = i;
		}
		if(mp2[max_num2] <= mp2[i]) {
			ci_num2 = max_num2;
			max_num2 = i;
		} else if(mp2[ci_num2] <= mp2[i]) {
			ci_num2 = i;
		}
	}
	if(max_num1 != max_num2) {
		printf("%d", n - mp1[max_num1] - mp2[max_num2]);
	} else {
		printf("%d", std::min(n - mp1[max_num1] - mp2[ci_num2], n - mp1[ci_num1] - mp2[max_num2]));
	}
	return 0;
}

Measured memory_bytes: 23680
from sys import stdin


def input():
    return stdin.readline()[:-1]


def intput():
    return int(input())


def sinput():
    return input().split()


def intsput():
    return map(int, sinput())


n = intput()

ff = 100000000000

i = 1
while i * i <= n:
    if n % i == 0:
        x, y = i, n // i
        dist = x + y - 2
        if dist < ff:
            ff = dist
    i += 1

print(dist)


Measured memory_bytes: 3188
n,k,c = map(int,input().split())
s = list(input())

a = set()
cnt = 0
for i,x in enumerate(s[::-1]):
    j = n - i
    if cnt > 0:
        cnt -= 1
    elif x == 'o':
        cnt += c
        a.add(j)

b = set()
cnt = 0
for i,x in enumerate(s):
    if cnt > 0:
        cnt -= 1
    elif x == 'o':
        cnt += c
        b.add(i+1)

if len(a)==k:
	print(*sorted(list(a&b)),sep="\n")
else:
	exit()


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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) 
    cin >> a.at(i);
    vector<int> b(n);
    for(int i = 0; i < n; i++) 
    b.at(a.at(i)-1) = i+1; 
    for(int i : b) cout << i << " ";
    cout << endl;
}

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

int main() {
	int a,b,c;cin>>a>>b>>c;
  a*c>b?cout<<b/a:cout<<c;
}

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

using namespace std;
#define int long long int
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define vi vector <int>
#define sz(s) (int)s.size()
#define pii pair<int,int>
#define piii pair< int,pair<int,int> >
#define tiii tuple <int,int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define rall(v) v.rbegin(),v.rend()
#define endl '\n'
#define matrix vector <vector <int> >
#define boost ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define NAYAN freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define N 500006
#define mod 1000000007
#define mod2 998244353
#define inf 1e17

int dp[100001][4];
int a[N],b[N],c[N];
int n,k;

int solve(int id,int p)
{
    if(id==n)
    {
        return 0;
    }
    
    int &ans=dp[id][p];
    if(ans!=-1)
        return ans;

    ans=0;
    int x=0,y=0,z=0;
    if(p!=0)
    {
        x=a[id]+solve(id+1,0);
    }
    if(p!=1)
    {
        y=b[id]+solve(id+1,1);
    }
    if(p!=2)
    {
        z=c[id]+solve(id+1,2);
    }

    ans=max(x,max(y,z));
   
    return ans;
}

int32_t main()  
{
    boost
    // #ifndef ONLINE_JUDGE 
    // NAYAN
    // #endif
    
    

    cin >> n;

    
    memset(dp,-1,sizeof dp);
    int i;
    
    for(i=0;i<n;i++)
    {
        cin >> a[i] >> b[i] >> c[i]; 
    }

    int ans=solve(0,3);

    cout << ans;



   


}

Measured memory_bytes: 20096
object Main {
  def main(args: Array[String]): Unit = {
    solve2
  }

  def solve2(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    val as = new Array[Long](n)
    for (i <- 0 until n) {
      as(i) = sc.nextLong
    }

    val l = new Array[Long](n + 1)
    l(0) = 0
    for (i <- 0 until n) {
      l(i + 1) = gcd(l(i), as(i))
    }
    var r = new Array[Long](n + 1)
    val asReverse = as.reverse
    r(0) = 0
    for (i <- 0 until n) {
      r(i + 1) = gcd(r(i), asReverse(i))
    }
    r = r.reverse

    var maxGCD = -1L
    for (i <- 0 until n) {
      maxGCD = math.max(maxGCD, gcd(l(i), r(i + 1)))
    }

    println(maxGCD)
  }


  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    val as = new Array[Long](n)
    for (i <- 0 until n) {
      as(i) = sc.nextLong
    }

    var skipIndex = 0
    var maxGCD = -1L
    for (i <- 0 until n) {
      var tmpGCD = -1L

      for (j <- 0 until n) {
        if (j != skipIndex) {
          if (tmpGCD == -1) {
            tmpGCD = as(j)
          }
          else {
            tmpGCD = gcd(tmpGCD, as(j))
          }
        }
      }
      maxGCD = math.max(maxGCD, tmpGCD)
      skipIndex += 1
    }

    println(maxGCD)
  }

  def gcd(x: Long, y: Long): Long = {
    if (x == 0) y
    else gcd(y % x, x)
  }

}


Measured memory_bytes: 60356
#include<bits/stdc++.h>
using namespace std;
int main (){
  int a,b,c;
  cin >> a >> b >> c;
  int ans = 3;
  if(a == b)ans--;
  if(b == c)ans--;
  if(c == a)ans--;
  if(ans == 0)cout << 1 << endl;
  else cout << ans << endl;
}

Measured memory_bytes: 256
import std.stdio, std.math, std.algorithm, std.array, std.string, std.conv, std.container, std.range;
pragma(inline, true) T[] Reads(T)() { return readln.split.to!(T[]); }
alias reads = Reads!int;
pragma(inline, true) void scan(Args...)(ref Args args) {
    string[] ss = readln.split;
    foreach (i, ref arg ; args) arg = ss[i].parse!int;
}

void main() {
    int m, d; scan(m,d);
    int ans;
    foreach (i; 1..m+1) {
        foreach (j; 1..d+1) {
            int d1 = j%10, d2 = (j/10) % 10;
            if (d1>=2 && d2>=2 && d1*d2 == i) ans++;
        }
    }
    writeln(ans);
}


Measured memory_bytes: 256
N=int(input())
S=input()

LtoR=[0]
RtoL=[0]
tmpLtoR=0
tmpRtoL=0
for i in range(N):
    #逆向きの人の累積和
    if S[i]=='W':
        tmpLtoR+=1
    LtoR.append(tmpLtoR)
    if S[N-1-i]=='E':
        tmpRtoL+=1
    RtoL.append(tmpRtoL)
LtoR.append(0)
RtoL.append(0)
RtoL.reverse()

total=N
for i in range(1,N+1):
    #print(i,LtoR[i-1]+RtoL[i+1])
    total=min(total,LtoR[i-1]+RtoL[i+1])
print(total)


Measured memory_bytes: 17792
import sys
from collections import deque

def solve():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    Ans = 0
    if K == 0: print(N ** 2)
    else:
        for b in range(K + 1, N + 1):
            Ans += (b - K) * (N // b)
            mod = N % b
            if mod >= K and mod > 0: Ans += mod - K + 1
        
        print(Ans)

    return 0

if __name__ == "__main__":
    solve()

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

using namespace std;

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed << setprecision(20);

string s, t;
vint idx[33];

signed main() {
    cin >> s >> t;
    for (int i = 0; i < s.size(); i++) {
        idx[s[i] - 'a'].push_back(i + 1);
    }
    int ans = 0, prev = 0;
    for (int i = 0; i < t.size(); i++) {
        if (idx[t[i] - 'a'].size() == 0) {
            cout << -1 << endl;
            return 0;
        }
        auto next = upper_bound(idx[t[i] - 'a'].begin(), idx[t[i] - 'a'].end(), prev);
        if (next == idx[t[i] - 'a'].end()) {
            ans += s.size() - prev;
            prev = idx[t[i] - 'a'][0];
            ans += prev;
        } else {
            ans += *next - prev;
            prev = *next;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1724
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
        Scanner sc = new Scanner(System.in);
        
		String s = sc.next();
		String[] sArray = s.split("");
		if( sArray.length == 2 ) {
			System.out.println(s);
		} else if (sArray.length == 3) {
			String s3ans = sArray[2] + sArray[1] + sArray[0];
			System.out.println(s3ans);
		}	
	}
}


Measured memory_bytes: 23508
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,A,B,C,D;
    cin >> N >> A >> B >> C >> D;
    string s;
    cin >> s;
    for(int i=A;i<max(C,D);i++){
        if(s[i]=='#'&&s[i+1]=='#'){
            if((A<i&&i<C)||(B<i&&i<D)){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    if(C<D){
        cout << "Yes" << endl;
    }else{
        bool flag = false;
        for(int i=B;i<=D;i++){
            if(s[i]=='.'&&s[i-1]=='.'&&s[i-2]=='.'){
                flag = true;
            }
        }
        if(flag){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 640