akhauriyash/Code-Regression huggingface dataset:
while 1
	sdytime = gets.to_i

	if sdytime == 0
		break
	end

	sdycount = gets.to_i

	set = Array.new()
	times = 0
	1.upto(sdycount) do |i|
		num = gets
		set = num.split(" ")
		times = times + set[1].to_i - set[0].to_i
	end

	if times >= sdytime
		puts "OK"
	else
		puts (sdytime - times)
	end

end

Measured memory_bytes: 6104
// ------------------------------------
// Date:2018/ 3/ 8
// Problem:ABC 061 CountingRoads b.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

// static const int MOD = 1000000007;

// line[from][to]
int line[55][55];

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

  memset(line, 0, sizeof(line));
  int N, M;
  cin >> N >> M;
  int from, to;
  REP(i, M) {
    cin >> from >> to;
    --from;
    --to;
    ++line[from][to];
    ++line[to][from];
  }

  int cnt;
  REP(from, N) {
    cnt = 0;
    REP(to, N) {
      cnt += line[from][to];
    }
    cout << cnt << endl;
  }
  
  return 0;
}



Measured memory_bytes: 256
from functools import reduce

def main():
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    sx, sy, tx, ty = (int(_) for _ in input().split())
    tx = tx - sx
    ty = ty - sy
    print('R'*tx+'U'*ty + 'L'*tx+'D'*ty + 'L'+'U'*(ty+1)+'R'*(tx+1)+'D' + 'R'+'D'*(ty+1)+'L'*(tx+1)+'U')
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
double dp[303][303][303];
int n, a;

double calc(int x, int y, int z){
	if(dp[x][y][z] > 0)return dp[x][y][z];
	int sum = x + y + z;
	if(sum == 0)return 0;
	double res = 0;
	res = 1.0 * n / sum;
	if(x > 0)res += calc(x - 1, y, z) * x / sum;
	if(y > 0)res += calc(x + 1, y - 1, z) * y / sum;
	if(z > 0)res += calc(x, y + 1, z - 1) * z / sum;
   	return dp[x][y][z] = res;
}
int main(){
	cin>>n;
	vector<int> piece(4, 0);
	for(int i = 0; i < n; ++i){cin>>a;piece[a - 1]++;}
	double ans = calc(piece[0], piece[1], piece[2]);
	cout<<fixed<<setprecision(12)<<ans<<endl;
	return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
template <class Key, class T>
using gp_hash_table = __gnu_pbds::gp_hash_table<Key, T>;

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());
  gp_hash_table<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: 70312
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
using namespace std;

int main(){
    int n,m,x,c=0,d=0;
    cin>>n>>m>>x;
    vector<int> a(m);
    rep(i,m) cin>>a[i];
    for(int j=x;j<n;j++){
        rep(i,m) if(j==a[i]) c++;
    }
    for(int j=x;j>0;j--){
        rep(i,m) if(j==a[i]) d++;
    }
    cout<<min(c,d)<<endl;
    return 0;
}

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

int main(){
    int n;
    while(cin >> n, n != 0){
        int data[n];
        int value;
        for(int i=0; i<n; i++){
            cin >> data[i];
        }
        cin >> value;
        int left = 0;
        int right = n-1;
        int mid = 0;
        int cnt = 0;
        while(left <= right){
            mid = (left+right) / 2;
            if(value > data[mid]){
                cnt++;
                left = mid+1;
            }else if(value < data[mid]){
                cnt++;
                right = mid-1;
            }else{
                cnt++;
                break;
            }
        }
        cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<stack>
using namespace std;
char s;stack<int> S1;
stack<pair<int,int> > S2; //前一个变量表示积水处左边\的位置，后一个表示积水处的面积
int sum,a;
int main()
{
    //freopen("xx.txt","r",stdin);
    for(int i=1;cin>>s;i++)
    {
        if(s=='\\') S1.push(i);
        else if(s=='/'&&S1.size()>0)
        {
            int j=S1.top(); S1.pop();
            sum+=i-j;a=i-j;
            while(S2.size()>0&&S2.top().first>j)
            {
                a+=S2.top().second;S2.pop();
            }
            S2.push(make_pair(j,a));
        }
    }
    stack<int> ans;
    while(S2.size()!=0) //因为栈是先进后出，所以要改变顺序
    {
        int j=S2.top().second;
        S2.pop();
        ans.push(j);
    }
    cout<<sum<<endl<<ans.size();
    while(ans.size()!=0)
    {
        cout<<" ";
        cout<<ans.top();
        ans.pop();
    }
    cout<<endl;
    return 0;
}


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

using namespace std;
typedef long long ll;

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

    // Default é max heap.
    // Min heap: priority_queue <int, vector<int>, greater<int> > pq;
    priority_queue<int> tickets;
    for(int i = 0; i < n; i++) {
        cin >> value;
        tickets.push(value);
    }
    while(m--) {
        int value = tickets.top()/2;
        tickets.pop();
        tickets.push(value);
    }
    ll ans = 0;
    while(!tickets.empty()) {
        ans += tickets.top();
        tickets.pop();
    }
    cout << ans << '\n';

    return 0;
}

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

int main(){
	int n;
	cin>>n;
	int a[n+1],b[n+1],c[n+1];
	for(int i=1;i<=n;i++)
		cin>>a[i]>>b[i]>>c[i];
	int dp1[n+1],dp2[n+1],dp3[n+1];
	dp1[1]=a[1];
	dp2[1]=b[1];
	dp3[1]=c[1];
	for(int i=2;i<=n;i++){
		dp1[i]=a[i]+max(dp2[i-1],dp3[i-1]);
		dp2[i]=b[i]+max(dp1[i-1],dp3[i-1]);
		dp3[i]=c[i]+max(dp2[i-1],dp1[i-1]);
	}
	cout<<max(dp1[n],max(dp2[n],dp3[n]))<<endl;
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
int main() {
    long long n,t;
    long long a1=0;
    cin >> n;
    long long b[n];
    long long ans[n];

    for(long long i=0;i<n;i++){
        cin >> t;
        b[i] = t*2;
        if(i%2==0) a1 += t;
        else a1 -= t;
    }

    ans[0] = a1;
    cout << a1 << " ";
    for(long long i=0;i<n-1;i++) {
        long long p=b[i] - ans[i];
        ans[i+1] = p;
        cout << p;
        if(i==n-2) cout << endl;
        else cout << " ";
    }
}

Measured memory_bytes: 5136
a=[int(i) for i in input()]
b=""
for i in range(len(a)):
	b=b+str(a[i])
	int(b)
c=int(sum(a))
b=int(b)
#print(c)
#print(b)
if b%c==0:
	print("Yes")
else:
	print('No')


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

int main() {
  vector<string> s(3);
  for (int i = 0; i < 3; ++i) {
    string t;
    cin >> t;
    s[i] = t;
  }
/*
  cout << s[0].size() << endl;
  cout << s[1].size() << endl;
  cout << s[2].size() << endl;
*/
  char t = 'a';
  
  vector<int> cnt(3,0);
  while (true) {
    int c = t - 'a';
	  int target = cnt[c];
    if (target >= s[c].size()) {
      cout << (char)toupper(t) << endl;
      return 0;
    }
    char tt = s[c][target];
    cnt[c] += 1;
    t = tt;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(c)       int(c.size())
#define FOR(i,a,b)  for (int i=a; i<(b); ++i)
#define DOWN(i,a,b) for (int i=(a)-1; i>=(b); --i)
using namespace std;
using i64 = long long;



int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout<<fixed<<setprecision(10);

  int n;
  cin>>n;
  map<int,int> cnt;
  FOR(i,0,n) {
    int x;
    cin>>x;
    cnt[x]+=1;
  }
  i64 res=0;
  for (auto p:cnt) {
    if (p.first<p.second) res+=p.second-p.first;
    if (p.first>p.second) res+=p.second;
  }
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 4736
from collections import defaultdict as dd
def main():
    N, K = map(int, input().split())

    d = dd(int)
    for n in range(N):
        a,b = map(int, input().split())
        d[a] += b

    count = 0
    A = sorted(d.keys())
    for k in A:
        # print(k,v)
        count += d[k]
        if count >= K:
            print(k)
            break

if __name__ == "__main__":
    # global stime
    # stime = time.clock()
    main()



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

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

  vector<int> A(N);
  for (int i = 0; i < N; i++)
    cin >> A.at(i);
  for (int i = 0; i < N; i++)
    A.at(i)--;

  vector<int> cnt(N);
  for (int i = 0; i < N; i++){
    cnt.at(A.at(i))++;
  }
  
  int ans = 0;
  int res = N - count(cnt.begin(), cnt.end(), 0);
  sort(cnt.begin(), cnt.end());
  for (int i = 0; i < N; i++)
  {
    if (cnt.at(i) != 0)
    {
      ans += cnt.at(i);
      res--;
    }
    if ( K >= res)
      break;
  }

  cout << ans << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
string a,b;
int main(){
    getline(cin,a);
    getline(cin,b);
    sort(a.begin(),a.end());
    sort(b.begin(),b.end(),greater<char>());
    if(a<b) cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 256
# Aさんは a[m] 地点、Bさんは b[m] 地点、Cさんは c [m] 地点にいます。
# 二人の人間は、距離が d [m] 以内のとき直接会話が出来ます。
# AさんとCさんが直接的、あるいは間接的に会話ができるか判定してください。
# ただしAさんとCさんが間接的に会話ができるとは、AさんとBさんが直接会話でき、かつBさんとCさんが直接会話できることを指します。

# 標準入力から a, b, c, d を取得する
a, b, c, d = map(int, input().split())

# 会話ができる（直接or間接）かを判定し、結果を出力する
result = 'No'

if abs(a - c) <= d: # 直接会話可能
    result = 'Yes'
elif (abs(a - b) <= d) and (abs(b - c) <= d):
    result = 'Yes'

print(result)


Measured memory_bytes: 9144
A=[]
for i in range(0,6):
  A.append(int(input()))
end=1
for i in range(0,5):
  for j in range(i,5):
    if A[j]-A[i]>A[5]:
      end=0
      break
if end==0:
    print(":(")
else:
	print("Yay!")

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

int main(){
  int a,b,k;
  cin >> a >> b >> k;
  vector<int> r(0);
  for (int i = 1; i < 101; i++)
  {
    if (a%i==0 && b%i==0) r.push_back(i);
  }
  cout << r[r.size()-k] << endl;
  
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())





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

	int n;
	unordered_map<string, int> mp;
	cin >> n;
	rep(i,n) {
		string s;
		cin >> s;
		sort(all(s));
		++mp[s];
	}

	long long ans = 0;
	for (const auto p : mp) {
		long long c = p.second;

		ans += c * (c - 1) / 2;
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 10660
x ,y = map(int,input().split())

a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
c = [2]

if x in a and y in a:
    print('Yes')
elif x in b and y in b:
    print('Yes')
elif a in c and y in c:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
import std.stdio, std.conv, std.string, std.range, std.algorithm, std.array,
  std.functional, std.container, std.typecons;

void main() {
  auto input = readln.split.to!(int[]);
  if(input.all!"1 <= a && a <= 9"()) {
    writeln(input[0] * input[1]);
  } else {
    writeln(-1);
  }
}


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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    ll N,M;
    bool flg[100010];
    ll cnt[100010];
    mem0(cnt);
    mem0(flg);
    ll ACcnt = 0,WAcnt = 0;
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        ll p; string s;
        cin >> p >> s;
        p--;
        if(s == "AC"){
            if(flg[p] == false){
                flg[p] = true;
                ACcnt++;
                WAcnt += cnt[p];
            }
        } else {
            if(flg[p] == false){
                cnt[p]++;
            }
        }
    }
    cout << ACcnt << " " << WAcnt << endl;
}

Measured memory_bytes: 4512
($H,$W)=glob<>;
@a=map[glob],<>;
for$y(1..$H){
	for$x(1..$W){
		if($a[$y-1][$x-1]%2){
			if($x<$W){
				++$a[$y-1][$x];
				push@_,[$y,$x,$y,$x+1];
			}elsif($y<$H){
				++$a[$y][$x-1];
				push@_,[$y,$x,$y+1,$x];
			}
		}
	}
}
print@_+0,$/,map"@$_\n",@_


Measured memory_bytes: 95488
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;

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

int main() {
    ll out = 0;
    rep(i,5){
        ll x;
        cin >> x;
        if(x==0){
            out = i+1;
            break;
        }
    }
    cout << out << endl;
    return 0;
}


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

int main() {
 ll n,i,j,k=0;
 cin>>n;
 
 
 for(i=1;i<=n;i++)
 {
     cin>>j;
     if(i&1&&j&1)k++;
 }cout<<k;
}

Measured memory_bytes: 3536
#include <iostream>
using namespace std;
 
int main(){
  int a[3],l, i=0, x;
  while(cin >>l){
  	a[i]=l;
    i++;
  }
  if(a[2]<a[0]){
  	x=0;
  }else{
    x= (int)(a[2]/a[0]) *a[1];
  }
  
  cout << x << endl;
}

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

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

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

constexpr lnt MOD = 1e9+7;
struct mint
{
	lnt v;
	mint():v(0){}
	mint(lnt v):v((v+MOD)%MOD){}
	mint operator-()const{ return mint(0) - *this; }
	mint& operator+=(const mint& a){ if((v+=a.v)>=MOD) v-=MOD; return *this; }
	mint& operator-=(const mint& a){ if((v+=MOD-a.v)>=MOD) v-=MOD; return *this; }
	mint& operator*=(const mint& a){ (v*=a.v)%=MOD; return *this; }
	mint& operator/=(const mint& a){ (*this) *= a.inv(); 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 operator/(const mint& a)const{ return mint(*this) /= a; }
	bool operator<(const mint& a)const{ return v < a.v; }
	bool operator==(const mint& a)const{ return v == a.v; }
	mint pow(lnt k)const{ mint r(1),t(v); while(k){ if(k&1) r*=t; t*=t; k>>=1; } return r; }
	mint inv()const{ return pow(MOD-2); }
	static mint comb(lnt n, lnt k) { if(n-k<k) k=n-k; mint num(1), dom(1); for(int i=0;i<k;i++) { num*=n-i; dom*=i+1; } return num/dom; }
	static std::vector<mint> construct_comb(int n) {
		std::vector<mint> c(n+1); mint a = 1; c[0] = a; for(int i=1;i<=n;i++) { a = a*mint(n+1-i)/i; c[i] = a; } return c;
	}
	static std::vector<mint> construct_fact(int n) { std::vector<mint> f(n+1,1); for(int i=2;i<=n;i++) f[i]=f[i-1]*i; return f; }
};
std::istream& operator>>(std::istream&i,mint&a){ lnt t; i>>t; a=mint(t); return i; }
std::ostream& operator<<(std::ostream&o,const mint&a){ o<<a.v; return o; }

std::vector<mint> mul(std::vector<mint>& a, std::vector<mint>&b) {
	int n=a.size();
	std::vector<mint> c(n,0);
	rep(i,n) rep(j,n) c[(i+j)%n]+=a[i]*b[j];
	return c;
}
std::vector<mint> pow(std::vector<mint>&a, lnt k) { int n=a.size(); std::vector<mint> r(n,0),t=a;r[0]=1; while(k){ if(k&1) r=mul(r,t); t=mul(t,t); k>>=1; } return r; }

int main() {
	int n,m,k;
	std::cin >> n >> m >> k;
	std::vector<mint> a(n,0);
	a[0]=1;
	rep(i,m) {
		int p;
		std::cin >> p;
		a[p%n]+=mint(1);
	}
	debug(a);
	auto c=pow(a,k);
	debug(c);
	rep(i,n) print(c[i]);
}



Measured memory_bytes: 3236
N=int(input())
L=list(map(int,input().split()))
ans=0
for i in range(N-2):
  for j in range(i+1,N-1):
    for k in range(j+1,N):
      if L[i]+L[j] > L[k] and L[i]+L[k] > L[j] and L[k]+L[j] > L[i]:
        if L[i] != L[j] and L[j] != L[k] and L[k]!=L[i]:
          ans+=1
print(ans)
        


Measured memory_bytes: 9076
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main()
{
  int N, K; cin >> N >> K;
  vector<ll> l(N); REP(i, N) cin >> l[i];

  sort(ALL(l));

  ll ans = 1<<30;
  for (int i = K-1; i < N; ++i) {
    ans = min(ans, l[i]-l[i-K+1]);
  }

  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,i,e,f,g,n,m,k,l;
pair <long long,long long> A[200005];
long long B[200005],maxx;
int main() {
           cin>>n>>m;
           cout<<(m*(m-1))/2+(n*(n-1))/2;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int A = in.nextInt();
            int B = in.nextInt();
            if (A > B) {
                System.out.println(0);
                return;
            }
            if (N == 1 && A != B) {
                System.out.println(0);
                return;
            }
            if (N <= 2) {
                System.out.println(1);
                return;
            }
            long res = (B - A) * (N - 2L) + 1L;
            System.out.println(res);
        }
    }
}


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  LL X, K;
  cin >> X >> K;
  VL rs(K+2);
  REP(k,K)
	cin >> rs[k+1];
  rs[0] = 0;
  rs[K+1] = 1e15;
  LL Q;
  cin >> Q;

  LL lb = 0, ub = X;
  LL btm = 0, top = X;
  int it = 1;
  while(Q--){
	LL t, a;
	cin >> t >> a;
	while(rs[it] < t){
	  LL dl = rs[it] - rs[it-1];
	  if(it%2 == 1){ // down
		if(lb < dl){
		  maxi(btm, min(top, btm + dl - lb));
		}
		ub = max(0ll, ub - dl);
		lb = max(0ll, lb - dl);
	  }
	  else{ // up
		if(ub+dl > X){
		  mini(top, max(btm, top - (ub + dl - X)));
		}
		ub = min(X, ub + dl);
		lb = min(X, lb + dl);
	  }
	  
	  ++it;
	}

	LL dl = t - rs[it-1];
	LL ans = 1e15;
	if(a <= btm){
	  if(it % 2 == 1)
		ans = max(0ll, lb - dl);
	  else
		ans = min(X, lb + dl);
	}
	else if(top <= a){
	  if(it % 2 == 1)
		ans = max(0ll, ub - dl);
	  else
		ans = min(X, ub + dl);
	}
	else{
	  if(it % 2 == 1)
		ans = max(0ll, a - btm + lb - dl);
	  else
		ans = min(X, a - btm + lb + dl);
	}
	cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 2048
import java.util.*;
import java.util.Map.Entry;
 
class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
	 static int[] ans;
//	 static int mod = 998244353;
   public static void main(String[] args) {
	   
       Scanner sc = new Scanner(System.in);
       int  N = sc.nextInt();
       int  M = sc.nextInt();
       int  K = sc.nextInt();
       
       Unionfind uf = new Unionfind(N);
       
       ans=new int[N];
       
       int [][]like = new int [M][2];
       for (int i=0 ; i<M; i++) {
    	   like[i][0] = Integer.parseInt(sc.next())-1;
    	   like[i][1] = Integer.parseInt(sc.next())-1;
    	   uf.union(like[i][0], like[i][1]);
       }
       
       int [][]dislike = new int [K][2];
       for (int i=0 ; i<K; i++) {
    	   dislike[i][0] = Integer.parseInt(sc.next())-1;
    	   dislike[i][1] = Integer.parseInt(sc.next())-1;
       }
       for(int i=0;i<N;i++) {
    	   ans[i]=uf.getSize(i)-1;
       }
       
       for(int i=0;i<M;i++) {
    	   ans[like[i][0]]--;
    	   ans[like[i][1]]--;
       }
       
       for(int i=0;i<K;i++) {
    	   if(uf.same(dislike[i][0],dislike[i][1])){
        	   ans[dislike[i][0]]--;
        	   ans[dislike[i][1]]--;
    	   }
       }
		for(int i = 0;i<N;i++) {
			System.out.println(ans[i]);
		}
   }
   

}

class Unionfind {
	   
		private int[] data;
		private int []size;
		
		public Unionfind(int size) {
			this.data = new int [size];
			this.size = new int [size];
			for(int i = 0 ;i < size ;i++) {
				initnode(i);
			}
			clear();
		}
		
		public void initnode(int i) {
			size[i] = 1;
		}
		
		public void clear() {
			Arrays.fill(data, -1);
		}
		
		public void union(int x , int y ) {
			if((x = root(x)) != (y = root(y))) {
				if(data[y] < data[x]) {
					final int t = x;
					x = y;
					y = t;
				}
				data[x] += data[y];
				size[root(x)] += size[root(y)];
				data[y] = x;
			}
		}
		
		public int getSize(int i) {
			return size[root(i)];
		}
		
		public int root(int x) {
			if(data[x] < 0) {
				return x;
			}
			else {
				return data[x] = root(data[x]);
			}
		}
		
		public boolean same(int x, int y) {
			return root(x) == root(y);
		}
		
	}

Measured memory_bytes: 94364
//***********************
    //*** writer : Alan Hu **
    //***********************
    #include<iostream>
    #include<vector>
    #include<string>
    #include<set>
    #include<map>
    #include<algorithm>
    #include<queue>
    #include<list>
    #include<stack>
    #include<cstdio>
    #include<fstream>
    #include<numeric>
    #include<functional>
    #include<utility>
    #include<memory>
    #include<cstring>
    #include<cmath>
    using namespace std;
         
    #define CLEAN(a,b) memset(a,b,sizeof(a))
    #define mp make_pair
    #define pb push_back
    #define sz(a) a.size()
    #define rept(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
         
    typedef long long ll;
    typedef pair<int, int> pii;
     
    int w;
    string s;
     
    int main()
    {
    	cin>>s>>w;
    	for (int i=0;i<s.size();i+=w)
    	{
    		cout<<s[i];
    	}
        return 0;
    }


Measured memory_bytes: 256
/* HARE KRSNA HARE KRSNA KRSNA KRSNA HARE HARE
    HARE RAMA HARE RAMA RAMA RAMA HARE HARE  */

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

#define nl "\n"
#define ff first
#define ss second
#define pp pop_back
#define pf pop_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define all(x) x.begin(),x.end()
#define test ll t; cin>>t; while(t--)
#define loop(i,s,n) for(ll i=s;i<n;i++)
#define rloop(i,s,n) for(ll i=s;i>=n;i--)
#define fill(a,value) memset(a,value,sizeof(a))

#define debug2(a)  for(auto x : a)  cout<<x<<" ";  cout<<nl;
#define debug4(a)  for(auto x : a)  cout<<x.ff<<" "<<x.ss<<nl;
#define debug1(a,n) loop(i,0,n)  cout<<a[i]<<" ";  cout<<nl;
#define debug3(a,n,m)  loop(i,0,n){ loop(j,0,m)	cout<<a[i][j]<<" ";	cout<<nl; }

typedef long long ll;
typedef long double ld;

typedef stack<ll> sll;
typedef queue<ll> qll;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef pair<ll, pll> ppll;
typedef vector<vector<ll>> vvll;
typedef priority_queue<ll> pqll;

const ll mod = 1000000007;	//998244353;
const ld pi =  acos((ld) - 1);	//3.1415926535;

ll num_generator()		{   return rand() % 1000;	}
void array_generator(ll a[], ll n)		{   loop(i, 0, n)	a[i] = rand() % 100;	}

void solve()
{
	string s, p;		cin >> s >> p;
	ll cnt = 0;
	loop(i, 0, s.length())	if (s[i] != p[i])		cnt++;
	cout << cnt;
}

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

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	// test
	solve();
	return 0;
}

Measured memory_bytes: 3808
#include<bits/stdc++.h>
using namespace std;
unsigned long long Get2N(int a){
	unsigned long long ans=1;
	for(int i=0;i<a;i++)ans*=2;
	return ans;
}
unsigned long long Get10N(int a){
	unsigned long long ans=1;
	for(int i=0;i<a;i++)ans*=10;
	return ans;
}
int main(){
	string s;
	cin>>s;
	unsigned long long len=s.length(),p[len],pos=len,time[len+1],ans=0;
	time[0]=1;
	for(int i=1;i<len;i++){
		time[i]=Get2N(i-1);
	}
	reverse(time,time+len);
	for(int i=0;i<len;i++)p[i]=s[i]-'0';
//	cout<<"PreW suc! Now time:";
//	for(int i=0;i<len;i++)cout<<time[i]<<' ';
//	cout<<endl;
	time[len]=0;
	for(int i=0;i<len;i++){
//		cout<<endl;
		pos--;
		time[pos]+=time[pos+1];
		for(int j=0;j<=pos;j++){
			ans+=p[i]*time[j]*Get10N(j);
//			cout<<"ans+="<<p[i]*time[j]*Get10N(j)<<endl;
		}
//		cout<<"Loop0:"<<i<<endl;
		
//		time[pos]+=time[pos+1];
		time[pos+1]=0;
//		cout<<"Pos:"<<pos<<endl<<"Ans:"<<ans<<endl;
//		for(int i=0;i<len;i++)cout<<time[i]<<' ';
//		cout<<endl;
	}
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 256
#include<stdio.h>
#include<memory.h>
int main()
{
	int NO, W, N, vt[1000], wt[1000], i, w, ct, C0[1001], C1[1001], w1;
	for (NO = 1; scanf("%d", &W), W; NO ++) {
		scanf("%d", &N);
		for (i = 0; i < N; i ++)
			scanf("%d,%d", vt+i, wt+i);
		memset (C0, 0, sizeof(C0));
		for (i = 1; i <= N; i ++) {
			for (w = W; w >= 0; w --) {
				C1[w] = C0[w];
				if (w >= wt[i-1]) {
					ct = C0[w-wt[i-1]]+vt[i-1];
					if (C1[w] < ct)
						C1[w] = ct;
				}
				if (C1[w] == C1[W])
					w1 = w;
			}
			memcpy(C0, C1, sizeof(C0));
		}
		printf("Case %d:\n%d\n%d\n", NO, C0[W], w1);
	}
	return 0;
}

Measured memory_bytes: 0
from math import sqrt
def d(x1,x2,y1,y2):
	return sqrt((x2-x1)**2+(y2-y1)**2)
	
n=int(input())
res=0
Z=[]
for i in range(n):
	xy = list(map(int,input().split()))
	Z.append(xy)
for i in range(n):
	for j in range(i+1,n):
		res += d(Z[i][0],Z[j][0],Z[i][1],Z[j][1])
print(res*2/n)

Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))


int main(void){
	int a,b;
	cin>>a>>b;
	cout<<(a*b%2==1?"Odd":"Even")<<endl;
	return 0;
}


Measured memory_bytes: 764
#include<iostream>
#include<climits>
#include<numeric>
#include<algorithm>
#include <sstream>
#include<cstring>
#include<cmath>
#include<iterator>
#include<utility>
#include<array>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<forward_list>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vlli vector<long long int>
#define vvi vector<vector<int>>
#define vpii vector<pair<int,int>>
#define vs vector<string>
#define pa(a) cout<<a<<endl;
#define lin1(x) ll int x; x = scan();
#define lin2(x,y) ll int x, y; x = scan(), y = scan();
#define lin3(x,y,z) ll int x, y, z; x = scan(), y = scan(), z = scan();
#define pb(x) push_back(x)
#define makep(x,y) make_pair(x,y)
#define mx(a,b) (a)>(b)?(a):(b)
#define mn(a,b) (a)<(b)?(a):(b)
#define fori(s,e) for(i=s;i<=e;i++)
#define forj(s,e) for(j=s;j<=e;j++)
#define fork(s,e) for(k=s;k<=e;k++)
#define rep(i,s,e) for(int i=s;i<=e;i++)
#define brep(i,s,e) for(int i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x));
#define bits1(x) __builtin_popcount(x)
#define pi 3.14159265358979323846264338327950
#define MOD7 1000000007
#define MOD9 1000000009
#define fast std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;

int main()
{
#ifdef RAHUL
    freopen("input.txt","r",stdin);
#endif

ll a,b;
cin>>a>>b;

if(a>=13){
    cout<<b<<endl;
}
else if(a>=6 and a<=12){
    cout<<b/2<<endl;
}
else
{
    cout<<"0"<<endl;
}
}

Measured memory_bytes: 256
N = int(input())
S = [list(input()) for i in range(N)]

for i in range(N):
    S[i] = sorted(S[i])

S = sorted(S)
count = 0

a = [1]
for i in range(N-1):
    if S[i] == S[i+1]:
        a[-1] += 1
    else:
        a.append(1)
    
for i in range(len(a)):
    count += a[i]*(a[i]-1)/2
        
count = int(count)
        
print(count)

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

int x,a,b,c;

int main()
{
	cin>>a>>b>>c>>x;
	int ans=0;
	for(int i=0;i<=a;++i)
		for(int j=0;j<=b;++j)
		{
			if(x<500*i+100*j) break;
			if((x-500*i-100*j)/50<=c) ans++;
		}
		cout<<ans;
}

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

int main() {
  int n, n1;
  cin >> n;
  n1 = n % 10;

  if (n1 == 3)
    cout << "bon" << endl;
  else if (n1 == 0 || n1 == 1 || n1 == 6 || n1 == 8)
    cout << "pon" << endl;
  else
    cout << "hon" << endl;
  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const int maxm = 1e6 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x < 2) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
ll n,k,a[maxn],fac[maxn];
ll C(int n,int m){
	if(m > n) return 0;
	return fac[n] * poww(fac[m],mod-2,mod) % mod * poww(fac[n-m],mod-2,mod) % mod;
}
int main(){
 	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	fac[0] = 1;
	for(int i = 1;i < maxn;i++) fac[i] = (fac[i-1] * i) % mod;
	cin >> n >> k;
	for(int i = 1;i <= n;i++) cin >> a[i];
	sort(a+1,a+n+1);
	ll ans = 0;
	for(int i = 1;i <= n;i++){
		ans = ((ans + a[i] * (C(i-1,k-1) - C(n-i,k-1) + mod) + mod) % mod) % mod;
	}
	cout << ans << endl;
	return 0;
}
//do smt instead of nothing! never give up!
//take care of long long!
//take care of upper or lower case e.g "yes" or "YES"?
//boundary condition! e.g. n = 0?
//brute force is always the first choice!
// print the ans to look for patterns in the data!

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/

int main()
{
	cin >> n;
	cnt++;
	while (ans <= n) {
		ans = pow(2, cnt);
		cnt++;
	}
	cout << ans / 2 << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
long int n;
int main()
{
    cin >> n;
    long int a[n],i;
    for(i=0;i<n;i++)
        cin >> a[i];
    long int dp[n][2];
    dp[0][0]=0;
    dp[0][1]=0;
    dp[1][0]=abs(a[1]-a[0]);
    dp[1][1]=dp[1][0];
    for(i=2;i<n;i++)
    {
        dp[i][0]=abs(a[i]-a[i-1])+min(dp[i-1][0],dp[i-1][1]);
        dp[i][1]=abs(a[i]-a[i-2])+min(dp[i-2][0],dp[i-2][1]);
    }
    cout << min(dp[n-1][0],dp[n-1][1]);
    return 0;


}


Measured memory_bytes: 2560
n,c,k = map(int,input().split())
t = []
for i in range(n):
  t.append(int(input()))
t = sorted(t)
count = 1
first = t[0]
first_j = 0
for j in range(n):
  if t[j] - first > k:
    count += 1
    first = t[j]
    first_j = j
  elif j - first_j > c - 1:
    count += 1
    first = t[j]
    first_j = j
print(count)

Measured memory_bytes: 8280
#include <iostream>
#include <queue>
using namespace std;
int main() {
	int N, M;
	cin >> N >> M;
	priority_queue<int> q;
	for (int i = 0, A; i < N; i++) {
		cin >> A;
		q.push(A);
	}
	for (int i = 0; i < M; i++) {
		int discount = q.top() / 2;
		q.pop();
		q.push(discount);
	}
	long long ans = 0;
	while (!q.empty()) {
		ans += q.top();
		q.pop();
	}
	cout << ans << endl;
}

Measured memory_bytes: 892
#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);
     
  	int odd = 0;
    for(int i = 0; i < N; i++){ 
      if(A.at(i) % 2 == 1) odd += 1;
    }      
      
    if (odd % 2 == 0) cout << "YES" << endl;
  	else cout << "NO" << endl;
}

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

_dict = {}
max_cnt = 0
for n in range(N):
  _ = input()
  if _ not in _dict:
    _dict[_] = 1
  else:
    _dict[_] += 1
    
  if _dict[_] > max_cnt:
    max_cnt = _dict[_]


ans = [k for k, v in _dict.items() if v == max_cnt]
ans.sort()
for _ in ans:
  print(_)

Measured memory_bytes: 32096
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
dif_pos, dif_neg = 0, 0
for a, b in zip(A,B):
  if a<b:dif_neg +=(b-a)//2
  elif b<a:dif_pos +=a-b
print('Yes' if dif_neg>=dif_pos else 'No')

Measured memory_bytes: 40560
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define MOD 1000000007
#define INF 1000000000000000007LL

const int N = 100005;
 
// it's swapnil07 ;)
 
#ifdef SWAPNIL07
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif


void solve(){
    int k; string s; cin>>k>>s;
    if(sz(s)<=k){
        cout<<s;
    }
    else{
        cout<<s.substr(0, k);
        cout<<"...";
    }
}

signed main()
{
    fast
    #ifdef SWAPNIL07
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int t=1; 
    // cin>>t;
    while(t--){
        solve();
        cout<<"\n";
    }
    return 0;
}



Measured memory_bytes: 3656
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

// {{{
// clang-format off
#define all(a) (a).begin(), (a).end()
#define sz(a) static_cast<int>((a).size())
#define fillchar(a, x) memset(a, x, sizeof(a))
#define rep(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define irep(i, a, b) for (int i = int(a); i >= int(b); --i)
#define replr(i, a, b) rep(i, a, (b)-1)
#define reprl(i, a, b) irep(i, (b)-1, a)
#define repn(i, n) rep(i, 0, (n)-1)
#define irepn(i, n) irep(i, (n)-1, 0)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define popcount __builtin_popcount
typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<double> VD;
typedef vector<bool> VB;
typedef vector<string> VS;
typedef vector<PII> VPI;
typedef vector<PLL> VPL;
typedef vector<PDD> VPD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef vector<VB> VVB;
typedef vector<VS> VVS;
typedef vector<VPI> VVPI;
typedef vector<VPL> VVPL;
template <class T, class S> ostream& operator<<(ostream& os, const pair<T, S>& v) { return os << "(" << v.first << ", " << v.second << ")"; }
template <class T> ostream& operator<<(ostream& os, const vector<T>& v) { os << "["; repn(i, sz(v)) { if(i) os << ", "; os << v[i]; } return os << "]"; }
template <class T> bool setmax(T& _a, T _b) { if(_a < _b) { _a = _b; return true; } return false; }
template <class T> bool setmin(T& _a, T _b) { if(_b < _a) { _a = _b; return true; } return false; }
template <class T> T gcd(T _a, T _b) { return _b == 0 ? _a : gcd(_b, _a % _b); }
VI read_vi(int n = -1) { if (n < 0) scanf("%d", &n); VI a(n); repn(i, n) scanf("%d", &a[i]); return a; }
VL read_vl(int n = -1) { if (n < 0) scanf("%d", &n); VL a(n); repn(i, n) scanf("%lld", &a[i]); return a; }
VD read_vd(int n = -1) { if (n < 0) scanf("%d", &n); VD a(n); repn(i, n) scanf("%lf", &a[i]); return a; }
VPI read_vpi(int n = -1) { if (n < 0) scanf("%d", &n); VPI a(n); repn(i, n) scanf("%d%d", &a[i].fi,&a[i].se); return a; }
VPL read_vpl(int n = -1) { if (n < 0) scanf("%d", &n); VPL a(n); repn(i, n) scanf("%lld%lld", &a[i].fi,&a[i].se); return a; }
VPD read_vpd(int n = -1) { if (n < 0) scanf("%d", &n); VPD a(n); repn(i, n) scanf("%lf%lf", &a[i].fi,&a[i].se); return a; }
inline LL powmod(LL a, LL b, LL m) { LL r = 1; for(; b > 0; b >>= 1, a = a * a % m) { if(b & 1) r = r * a % m; } return r; }
// clang-format on
// }}}

LL solve() {
    LL n, a, b;
    cin >> n >> a >> b;
    if(a > b) return 0;
    if(n == 1) {
        if(a == b) return 1;
        return 0;
    }
    LL l = a * (n - 1) + b;
    LL r = a + b * (n - 1);
    return r - l + 1;
}

int main() {
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed
#define endl '\n'

const ll MOD = 1e9 + 7;
struct mint {
    ll x;
    mint() : x(0) {}
    mint(ll x) : x((x % MOD + MOD) % MOD) {}
    mint& operator+=(const mint& r) { if ((x += r.x) >= MOD) { x -= MOD; } return *this; }
    mint& operator-=(const mint& r) { if ((x -= r.x) < 0) { x += MOD; } return *this; }
    mint& operator*=(const mint& r) { if ((x *= r.x) > MOD) { x %= MOD; } return *this; }
    mint& operator++() { if ((++x) >= MOD) { x -= MOD; } return *this; }
    mint operator++(int) { mint ret = x; if ((++x) >= MOD) { x-= MOD; } return ret; }
    mint& operator--() { if ((--x) < 0) { x += MOD; } return *this; }
    mint operator--(int) { mint ret = x; if ((--x) < 0) { x += MOD; } return ret; }
    mint operator+(const mint& r) { mint ret; return ret = x + r.x; }
    mint operator-(const mint& r) { mint ret; return ret = x - r.x; }
    mint operator*(const mint& r) { mint ret; return ret = x * r.x; }
    mint operator-() { return mint() - *this; }
    bool operator<(const mint& a) { return x < a.x; }
    bool operator>(const mint& a) { return x > a.x; }
    bool operator<=(const mint& a) { return x <= a.x; }
    bool operator>=(const mint& a) { return x >= a.x; }
    bool operator==(const mint& a) { return x == a.x; }
    bool operator!=(const mint& a) { return x != a.x; }
};
ostream& operator<<(ostream& os, const mint& r) { os << r.x; return os; }
ostream& operator>>(ostream& os, const mint& r) { os >> r.x; return os; }

void solve(istream& cin, ostream& cout) {
  int n;
  int input;
  cin >> n;
  REP(i, n) {
    cin >> input;
    if (input % 2 == 0 && input % 3 != 0 && input % 5 != 0) {
      cout << "DENIED" << endl;
      return;
    }
  }
  cout << "APPROVED" << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
}
#endif


Measured memory_bytes: 256
/* ****TCIITB**** */

#include<bits/stdc++.h>
#define io          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

#define N  100005

int main()
{
	
	io

	ll x,y,a,b,c;
	cin>>x>>y>>a>>b>>c;
	std::vector<ll> r(a),g(b),cl(c);
	priority_queue<pii> pq;
	rep(i,0,a)
	{
		cin>>r[i];
		pq.push({r[i],0});
	}
	rep(i,0,b)
	{
		cin>>g[i];
		pq.push({g[i],1});
	}
	rep(i,0,c)
	{
		cin>>cl[i];
		pq.push({cl[i],2});
	}
	
	std::vector<pii> fin;
	ll cx=0,cy=0;
	while(!pq.empty())
	{
		pii t1=pq.top();
		pq.pop();
		if(t1.S==0)
		{
			if(cx!=x)
				{
					fin.pb(t1);
					cx++;

				}
				// continue;
		}
		if(t1.S==1)
		{
			if(cy!=y)
				{
					fin.pb(t1);
					cy++;

				}
				// continue;
		}
		if(cx==x && cy==y)
			break;
		if(t1.S==2)
		fin.pb(t1);
	}
	ll ts=0;
	ll cp=fin.size()-1;
	cx=0,cy=0;
	for(auto i:fin)
	{
		if(cx==x && cy==y)
				break;
		if(i.S==0)
		{
			if(cx!=x)
			{
				ts+=i.F;
				cx++;
			}
		}
		if(i.S==1)
		{
			if(cy!=y)
			{
				ts+=i.F;
				cy++;
			}
		}
		if(i.S==2)
		{
			if(cx==x && cy!=y)
			{
				cy++;
				ts+=i.F;
				continue;
			}
			if(cx!=x && cy==y)
			{
				cx++;
				ts+=i.F;
				continue;
			}
			if(cx==x && cy==y)
			{
				break;
			}
			while(cp>=0)
			{
				if(fin[cp].S==0)
				{
					cp--;
					cx++;
					ts+=i.F;
					break;
				}
				if(fin[cp].S==1)
				{
					cp--;
					cy++;
					ts+=i.F;
					break;
				}
				cp--;
			}
			if(cx==x && cy==y)
				break;
		}


	}
	cout<<ts;	
	
}

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

int main()
{
    long long l,r;
    cin >> l >> r;
    if(r/2019-l/2019){
        cout << 0 << endl;
        return 0;
    }
    long long i,j;
    long long min = l*r%2019;
    long long temp;
    for(i = l;i <= r-1;++i){
        for(j = i+1;j <= r;++j){
            temp = i*j%2019;
            if(temp < min){
                min = temp;
            }
        }
    }
    cout << min << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int a,b,c;
  cin>>a>>b>>c;
  int s=a+b,t=b+c,l=a+c;
  if(s<t && s<l)
    cout<<s;
  else if(t<s && t<l)
    cout<<t;
  else
    cout<<l;
  return 0;
}

Measured memory_bytes: 256