akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
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; }
 
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
template< typename T >
T mod_pow(T x, T n, const T &p) {
  T ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= p;
    (x *= x) %= p;
    n >>= 1;
  }
  return ret;
}
 
#define mod 1000000007LL
#define INF 10000000000000000LL
 
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (ll i = 1; i <= n; ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
#define mp make_pair
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
//
//
//
 

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  string s,t,u;
  ll a,b;
  cin >> s >> t >> a >> b >> u;
  if(s==u) a--;
  else b--;
  pri2(a,b);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <tuple>
#include <utility>
#include <functional>
#include <sys/time.h>
#include <iomanip>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(i, m, n) for(int i = (m); i < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
void setp(const int n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
//constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

constexpr int BEAM_SIZE = 800;
constexpr int SZ = 26;
constexpr int D = 365;
array<int, SZ> C;
array<array<int, SZ>, D> S;

struct State {
	array<int, SZ> last = {};
	array<int, D> ans;
	int score = 0;

	void update_score(int d, int t) {
		score += S[d][t];
		rep(i, SZ) score -= C[i] * (d + 1 - last[i]);
	}

	int eval() const {
		return score;
	}

	State place(int d, int t) {
		State res = *this;
		res.ans[d] = t;
		res.last[t] = d + 1;
		res.update_score(d, t);
		return res;
	}

	array<int, D> answer() {
		return ans;
	}
};

array<int, D> solve() {
	State initial_state;
	using f = function<bool(State&, State&)>;
	priority_queue<State, vector<State>, f> cur([](State& a, State& b){return a.eval() > b.eval();});
	cur.push(initial_state);
	priority_queue<State, vector<State>, f> nxt([](State& a, State& b){return a.eval() > b.eval();});
	rep(d, D){
		while(!nxt.empty()) nxt.pop();
		while(!cur.empty()){
			State now = cur.top(); cur.pop();
			rep(t, SZ){
				if(nxt.size() < BEAM_SIZE || now.place(d, t).eval() > nxt.top().eval()) nxt.push(now.place(d, t));
				if(nxt.size() > BEAM_SIZE) nxt.pop();
			}
		}
		swap(cur, nxt);
	}

	State res;
	while(!cur.empty()){
		if(cur.size() == 1) res = cur.top();
		cur.pop();
	}
	cerr << res.eval() << endl;
	return res.answer();
}

int main(void){
	int tmp;
	cin >> tmp;
	rep(i, SZ) cin >> C[i];
	rep(i, D) rep(j, SZ) cin >> S[i][j];

	auto ans = solve();
	for (int i : ans) cout << i + 1 << endl;

	return 0;
}


Measured memory_bytes: 6836
S = input()

seed = [3,5,7]
nums = [3,5,7]
next = []

for i in range(8):
    next = nums[:]
    for n in nums:
        for s in seed:
            next.append(n*10+s)
    nums = next[:]
    next = []

cnt = 0
nums = list(set(nums))
for n in nums:
    s = str(n)
    if '3' in s and '7' in s and '5' in s and n <= int(S):
        cnt += 1

print(cnt)


Measured memory_bytes: 58032
x = list(map(int, input().split()))
k = [list(map(int, input().split())) for i in range(x[0])]
f = 0
for i in k:
  i.pop(0)
  if f == 0:
    tmp = i
    f = 1
    s = i
  else:
    s = set(tmp) & set(i)
    tmp = s
print(len(s))

Measured memory_bytes: 9188
#include<bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(int)(b);++i)
#define rep(i,n) REP(i,0,n)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

using namespace std;
typedef long long ll;

int main() {
    string s;
    int k;
    cin >> s >> k;
    rep(i, s.length()) {
        if (s[i] != '1') {
            cout << s[i] << endl;
            return 0;
        }
        if (i + 1 >= k) {
            cout << 1 << endl;
            return 0;
        }
    }
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  double a, b, x_double, x_dec;
  int x_int, x;
  cin >> a >> b;
  
  x_double = (a + b) / 2;
  x_int = x_double;
  x_dec = x_double - x_int;
  x = x_double + x_dec;
  
  cout << x << endl;
}

Measured memory_bytes: 256
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val N = nextInt()
    val A = nextLongList()
    val ans = A.groupBy { it }.map { if (it.key <= it.value.size) it.value.size - it.key else it.value.size.toLong() }.sum()
    println(ans)
}

Measured memory_bytes: 60952
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	string S=in<string>(),T=in<string>();
	int NS=S.size(),NT=T.size();

	int last = -1;
	REP(i,NS-NT+1){
		bool able=true;
		REP(j,NT){
			if(S[i+j]!='?' && S[i+j]!=T[j]){
				able = false;
				break;
			}
		}
		if(able) last = i;
	}

	if(last==-1){
		out("UNRESTORABLE");
		return 0;
	}

	REP(i,NT){
		S[i+last] = T[i];
	}
	REP(i,NS){
		cout << ((S[i]=='?')?'a':S[i]);
	}
	out();
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
#include<string.h>
#include <numeric> 
#include<unordered_map>
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 pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define pp1(...) "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg(x) debug() << pp1(x)
#define dg1(x) debug() << pp(x)
#define dg2(x,y) debug() << pp(x) pp(y)
#define dg3(x,y,z) debug() << pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << pp(w) pp(x) pp(y) pp(z)
#define int long long
#define all(x) x.begin() , x.end()
#define clr(x) memset(x , 0 , sizeof x);
#define sz(x) (int)x.size()
template<typename T> void db(T x ){ debug() <<">>> " <<  x; }
template<typename T> void db(T x , T y){ debug() <<">>> " <<  x <<" , "<< y; }
template<typename T> void db(T x , T y , T z){ debug() <<">>> "<< x <<" , "<< y <<" , "<< z; }
template<typename T> void db(T x , T y , T z , T a){ debug() <<">>> "<< x <<" , " << y <<" , "<< z <<" , "<< a; }
const int xx = 2e5;
const int Mod = 1e9 + 7;
const int inf = 1e18;
const int Maxn = 20010;

vector<int> g[10];
signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);

  int N;
  cin >> N;
  string s;
  cin >> s;
  for(int i = 0; i < N; i++) {
    g[s[i] - '0'].push_back(i);
  }
  for(int i = 0; i < 10; i++) {
    sort(g[i].begin() , g[i].end());
    dg2(i, g[i]);
  }
  int ans = 0;
  for(int i = 0;i < 10;i++) {
    for(int j = 0; j < 10;j++) {
      for(int k = 0; k < 10;k++) {
        if(g[i].empty() || g[j].empty() || g[k].empty()) continue;
        dg3(i , j , k);
        int x = g[i][0];
        int y = lower_bound(g[j].begin() , g[j].end() , x + 1) - g[j].begin();
        if(y == sz(g[j])) continue;
        int z = g[j][y];
        dg3(x , y , z);
        if(z <= x) continue;
        int last = g[k].back();
        dg1(last);
        if(last > z) {
          db("incremented");
          ans++;
        }
      }
    }
  }
  cout << ans << '\n';
}

Measured memory_bytes: 3416
#template
def inputlist(): return [int(k) for k in input().split()]
#template
N = int(input())
A = inputlist()
from fractions import gcd
L = [0]*N
R = [0]*N
for i in range(1,N):
    L[i] = gcd(L[i-1],A[i-1])
for i in range(1,N):
    j = (N-1)-i
    R[j] = gcd(R[j+1],A[j+1])
ans = 0
for i in range(N):
    k = gcd(L[i],R[i])
    ans = max(k,ans)
print(ans)

Measured memory_bytes: 85088
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<string.h>
#include<functional>
#include<set>
using namespace std;

#define INF 1<<21
#define DIV 1000000007
#define MAX 100005


int main(){
  int n;
  while (cin >> n,n) {
	int meet[55][35];
	int have[55][55];
	memset(meet, 0, sizeof(meet));
	memset(have, 0, sizeof(have));
	for (int i = 1; i <= n; i++) {
	  int f;
	  cin >> f;
	  int m;
	  for (int j = 0; j < f; j++) {
		cin >> m;
		meet[i][m] = 1;
	  }
	}
	for (int i = 1; i <= n; i++) {
	  have[i][i] = 1;
	}
	int flag = 0;
	for (int t = 1; t <= 30; t++) {
	  set<int> S;
	  for (int i = 1; i <= n; i++) {
		if (!meet[i][t])continue;

		for (int j = 1; j <= n; j++) {
		  if (have[i][j])S.insert(j);
		}
	  }

	  for (int i = 1; i <= n; i++) {
		if (!meet[i][t])continue;

		for (auto s = S.begin(); s != S.end(); s++) {
		  have[i][*s] = 1;
		}
	  }

	  if (S.size() == n) {
		cout << t << endl;
		break;
	  }
	  if (S.size() < n&&t == 30)flag = 1;
	}
	if (flag)cout << -1 << endl;
  }
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define pb(a) push_back(a)
#define pr(a) cout<<(a)<<endl
#define PR(a,b) cout<<(a)<<" "<<(b)<<endl
#define R cin>>
#define F first
#define S second
#define ll long long
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

int a,n;

int solve(int p, int q, int k, int M, int x) {
  if(!p) return 1;
  int ans=0;
  for(int i=M; i*x<=a; i++) {
    if((n-k)*q<p*i) break;
    if(p*i<q) continue;
    ans+=solve(p*i-q,q*i,k+1,i,x*i);
  }
  return ans;
}
  
int main() {
  int p,q;
  while(cin >> p >> q >> a >> n && p) pr(solve(p,q,0,1,1));
  return 0;
}


Measured memory_bytes: 1160
#if 1

#include <bits/stdc++.h>
using namespace std;
int a[100005],d[100005];

int main()
{
    int n;
    scanf("%d",&n);
    for(int i = 1;i <= n;i++)
    {
        scanf("%d",&a[i]);
    }
    d[1] = 0;
    d[2] = abs(a[2]-a[1]);
    for(int i = 3;i <= n;i++)
    {
        d[i] = min(d[i-1]+abs(a[i-1]-a[i]),d[i-2]+abs(a[i-2]-a[i]));
        //cout << d[i] << " ";
    }
    printf("%d",d[n]);
}

#endif // 1++

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#define maxsize (int)(1e5 + 2)

int plus(char c){
	if(c == 'A'){
		return 1;
	}
	else{
		return 2;
	}
}

int main(){
	char *S = (char *)malloc(sizeof(char) * maxsize);
	char *T = (char *)malloc(sizeof(char) * maxsize);
	scanf("%s", &S[1]);
	scanf("%s", &T[1]);
	int *sumS = (int *)malloc(sizeof(int) * maxsize);
	int *sumT = (int *)malloc(sizeof(int) * maxsize);
	sumS[0] = 0;
	sumT[0] = 0;
	int i;
	for(i = 1; S[i] != '\0'; i++){
		sumS[i] = sumS[i - 1] + plus(S[i]);
	}
	for(i = 1; T[i] != '\0'; i++){
		sumT[i] = sumT[i - 1] + plus(T[i]);
	}
	int q, a, b, c, d;
	scanf("%d", &q);
	int *ans = (int *)malloc(sizeof(int) * q);
	for(i = 0; i < q; i++){
		scanf("%d%d%d%d", &a, &b, &c, &d);
		if((sumS[b] - sumS[a - 1]) % 3 == (sumT[d] - sumT[c - 1]) % 3){
			ans[i] = 1;
		}
		else{
			ans[i] = 0;
		}
	}
	for(i = 0; i < q; i++){
		if(ans[i] == 1){
			printf("YES\n");
		}
		else{
			printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
bool check(int n,int m,int x,int y) {return x>=0&&x<n&&y>=0&&y<m;}

int dp[401][401][401],dx[2]={0,1},dy[2]={1,0};
int main() {
  int n,m;
  cin >> n >> m;
  int a[n][m];
  for(int i=0; i<n; i++)for(int j=0; j<m; j++) cin >> a[i][j];
  for(int i=0;i<401;i++)for(int j=0;j<401;j++)for(int k=0;k<401;k++)dp[i][j][k]=-(1<<29);
  dp[0][0][0]=a[0][0];
  for(int i=0; i<n+m-2; i++) {
    for(int j=0; j<n+m; j++) {
      int x1,y1,x2,y2;
      if(i<m) x1=0,y1=i;
      else x1=i-m+1,y1=m-1;
      x1+=j,y1-=j;
      if(!check(n,m,x1,y1)) break;
      for(int k=j; k<n+m; k++) {
        if(i<m) x2=0,y2=i;
        else x2=i-m+1,y2=m-1;
        x2+=k,y2-=k;
        if(!check(n,m,x2,y2)) break;
        if(dp[i][j][k]==-(1<<29)) continue;
        for(int l=0; l<2; l++) {
          int xx1=x1+dx[l],yy1=y1+dy[l];
          if(!check(n,m,xx1,yy1)) continue;
          for(int l2=0; l2<2; l2++) {
            int xx2=x2+dx[l2],yy2=y2+dy[l2];
            if(!check(n,m,xx2,yy2)) continue;
            int c=a[xx1][yy1]+a[xx2][yy2];
            if(xx1==xx2&&yy1==yy2) c/=2;
            int x=xx1,y=xx2;
            if(i+1>=m) x-=i-m+2,y-=i-m+2;
            dp[i+1][x][y]=max(dp[i+1][x][y],dp[i][j][k]+c);
          }
        }
      }
    } 
  }
  cout << dp[n+m-2][0][0] << endl;
  return 0;
}


Measured memory_bytes: 252288
//  RAKSHIT KADAM
//ALWAYS USE &IT FOR ITERATING USING AUTO ...
//USE COUNT(STARTING ADDRESS, ENDING ADRESS ,VALUE) FOR FINDING THE COUNT IN THE RESPECTIVE DATA STRUCTURE
//NOTE THAT MEMSET CANT FILL THE DOUBLE VALUES;
//ACCUMULATE DOES NOT WORK PROPERLY IF VALUES START SUMMING BEYOND 1E9...
 #include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update>
#warning !!!check the size of arrayss!!!
 
// NUMERIC DEFINITIONS :
    #define INF 100000000000000005
    #define inf 1000000000
    #define MOD  1000000007
    #define newMOD  998244353
    #define MAX 300006
    #define pi 3.1415926535897932384626433832795
#define ld long double
 #define ll long long
 #define int long long
 
 #define P(gg) for(auto rax:gg){cout<<rax<<" ";}cout<<endl;
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define endl "\n"
 #define x first
 #define y second
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define forci(i,n) for(ll i=0;i<n;i++)
 #define vi vector<ll>
 #define Endl endl
 #define lb lower_bound
 #define ub upper_bound
#define pii pair<ll,ll>
 
 #define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout)
 #define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;
 
ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
int power(int x, unsigned int y, unsigned int m){ if (y == 0) return 1;int p = power(x, y/2, m) % m;  p = (p * p) % m;return (y%2 == 0)? p : (x * p) % m;}
ll modInverse(int a, int m){{ return power(a, m-2, m);}}
const int maxn = 500003;
//use it by DSU d(N) where n is the number upto which it is supposed to constructed...

void solve()
{
    ll n,m;cin>>n>>m;multiset<ll>ms;
    ll a[n];for(ll i=0;i<n;i++)cin>>a[i],ms.insert(a[i]);
    ll ans = 0;
    while(m--)
    {
        ll x = *ms.rbegin();
        auto it = ms.end();it--;
        ms.erase(it);
        ms.insert(x/2);
    }
    for(auto it:ms)ans+=it;
    cout<<ans<<endl;
   
    
}
 
signed main()
{
   Need_for_speed(activated);
//
//satisy
//    {
//  solve();
//   }
 
    solve();
    
    return 0;
}
 


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

bool is_prime(ll N) {
    if (N <= 1) {
        return false;
    } else {
        for (ll i = 2; i * i <= N; ++i) {
            if (N % i == 0) {
                return false;
            }
        }
    }
    return true;
}

ll is_prime2(ll N) {
    ll res = 2;
    for (ll i = 2; i * i <= N; ++i) {
        if (N % i == 0) {
            res = i;
        }
    }
    return res;
}

void Main() {
    ll N;
    cin >> N;
    if (is_prime(N)) {
        cout << N - 1 << '\n';
    } else {
        ll r = is_prime2(N);
        cout << r + N / r - 2 << '\n';
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

    static int zeroc=0;
    public static void main(String[] args)  {
        try{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String line;
            while((line=br.readLine())!=null){if(line.isEmpty())break;
            String[] spl = line.split(" ");
            int a = Integer.parseInt(spl[0]);
            int b = Integer.parseInt(spl[1]);
            int s = a*b;
            double tubo = (double)s/3.305785;
            System.out.println(tubo);


            }
        }catch(Exception e){}

    }
}

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

int main(void) {
    string s,t;
    cin >> s >> t;
    vector<int>a(26,0);
    vector<int>b(26,0);
    for(int i = 0;i<s.size();i++){
        int d = s.at(i) - 'a';
        a[d] += 1;
    }
    for(int i = 0;i<t.size();i++){
        int d = t.at(i) - 'a';
        b[d] += 1;
    }
    
    sort(a.begin(),a.end());sort(b.begin(),b.end());
    
    string frag = "Yes";
    for(int i = 0;i<26;i++){
        if(a[i] != b[i]){
            frag = "No";
        }
    }
    cout << frag << endl;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int val,even=0,cnt=0;
    for(int i=0;i<n;i++){
         cin>>val;
         if(val%2==0){
             even++;
             if(val%3==0||val%5==0){
                 cnt++;
             }
         }
    }
    if(cnt==even){
        cout<<"APPROVED"<<endl;
    }else{
        cout<<"DENIED"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int H= sc.nextInt();
		int W=sc.nextInt();
		int h=sc.nextInt();
		int w=sc.nextInt();
		int amount=H*W;
		int yoko = h*W;
		int tate = (H-h)*w;
		System.out.println(amount-yoko-tate);
	}
}


Measured memory_bytes: 21716
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define endl "\n"
#define fcout cout<<fixed<<setprecision(15)
typedef pair<int, int> P;
//struct edge { int to, cost; };

template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

bool prime(int n) {
    for (int i = 2; i <= sqrt(n); i++) {
        if (n % i == 0)return false;
    }
    return n != 1;
}
int gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
int lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
    if (p == 0) return 1;
    if (p % 2 == 0) {
        int t = mod_pow(n, p / 2, m);
        return (t * t) % m;
    }
    return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a % b, y, x);
    y -= a / b * x;
    return d;
}
int modinv(int a, int m) {
    int b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int modinv2(int a, int mod) {
    return mod_pow(a, mod - 2, mod);
}
int digit(int x) {
    int cnt = 0;
    while (x > 0) {
        cnt += x % 10;
        x /= 10;
    }
    return cnt;
}
int read() {
    int tmp;
    cin >> tmp;
    return tmp;
}
int xor128() {
    static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    int t = (x xor (x << 11));
    x = y; y = z; z = w;
    return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
    map<int, int>ans;
    int now = 2;
    while (now * now <= x) {
        if (x % now == 0) {
            x /= now;
            ans[now]++;
        }
        else now++;
    }
    if (x != 1) ans[x]++;
    return ans;
}
int comb(int n, int k, int mod) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    k = min(k, n - k);
    int x = 1, y = 1;
    rep(i, k) {
        y *= i + 1;
        y %= mod;
    }
    for (int i = n - k + 1; i <= n; i++) {
        x *= i;
        x %= mod;
    }
    return x * modinv(y, mod) % mod;
}

signed main() {
    //srand((unsigned)time(NULL));

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

    string s;
    cin >> s;
    if (s == "ARC") {
        cout << "ABC" << endl;
    }
    else {
        cout << "ARC" << endl;
    }

    return 0;
}


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

int main() {
  int K, N, Max=0;
  cin >> K >> N;
  vector<int> A(N+1);
  A.at(0)=0;
  for(int i=1; i<=N; i++){ 
    cin >> A.at(i);
    Max=max(Max, A.at(i)-A.at(i-1));
  }
  Max=max(Max, A.at(1)+K-A.at(N));
  cout << K-Max << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int, int> pi;
 
int n, a[100005];
lint q, k;
int spt[66][100005];
 
int main(){
	cin >> n;
	for(int i=1; i<=n; i++){
		scanf("%d",&a[i]);
		spt[0][i] = i;
	}
	spt[0][n] = 0;
	cin >> q >> k;
	for(int i=0; i<q; i++){
		int x;
		scanf("%d",&x);
		swap(spt[0][x-1], spt[0][x]);
	}
	for(int i=1; i<60; i++){
		for(int j=1; j<n; j++){
			spt[i][j] = spt[i-1][spt[i-1][j]];
		}
	}
	lint cur = a[1];
	printf("%lld\n", cur);
	for(int i=1; i<n; i++){
		int pos = i;
		for(int j=0; j<60; j++){
			if((k >> j) & 1) pos = spt[j][pos];
		}
		cur += a[pos+1] - a[pos];
		printf("%lld\n", cur);
	}
}

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

using namespace std;

#define int long long
#define double long double
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define fi first
#define se second
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CCIN(...)                                                              \
    char __VA_ARGS__;                                                          \
    CIN(__VA_ARGS__)
#define DCIN(...)                                                              \
    double __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Printv(v)                                                              \
    {                                                                          \
        REP(x, v.size()) { cout << v[x] << (x == v.size() - 1 ? "\n" : " "); } \
    }
template <typename T = string> inline void eputs(T s) {
    cout << s << "\n";
    exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}
template <typename T> using PQG = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using PQ = priority_queue<T>;

typedef long long ll;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<ll, ll> PL;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const double PI = atan(1.0) * 4.0;
const ll LINF = 1e18;
const ll dx[] = {1, 0, -1, 0};
const ll dy[] = {0, 1, 0, -1};

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

ll N;
ll w[4000], sum[4001];
ll dp[4001][4001], k[4001][4001];

signed main() {
    cin >> N;
    REP(i, N) cin >> w[i];
    REP(i, N) sum[i + 1] = sum[i] + w[i];
    Fill(dp, LINF);
    REP(i, N) {
        dp[i][i] = 0;
        k[i][i] = i;
    }
    FOR(d, 1, N) REP(l,N-d) {
        ll r = l + d;
        FOR(s, k[l][r - 1], k[l + 1][r] + 1) {
            ll tmp = dp[l][s] + dp[s + 1][r] + sum[r + 1] - sum[l];
            if(tmp < dp[l][r]) {
                dp[l][r] = tmp;
                k[l][r] = s;
            }
        }
    }
    cout << dp[0][N - 1] << "\n";
}



Measured memory_bytes: 205700
import collections as c
 
n = int(input())
alist = [input() for i in range(n)]
 
clist = c.Counter(alist)
anlist = clist.most_common()
anslist = []
for i in range(0,len(anlist)):
    if anlist[0][1] == anlist[i][1]:
        anslist.append(anlist[i][0])
anslistt = sorted(anslist)
 
for i in (anslistt):
    print(i)

Measured memory_bytes: 49204
package main

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

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func warshallFloyd(n int, d [][]int) {
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			for k := 0; k < n; k++ {
				d[j][k] = min(d[j][k], d[j][i] + d[i][k])
			}
		}
	}
}

func main() {
	H := readInt()
	W := readInt()

	S := make([]string, H)
	for i := 0; i < H; i++ {
		S[i] = readString()
	}

	n := H * W
	d := make([][]int, n)
	for i := 0; i < n; i++ {
		d[i] = make([]int, n)
		fillInts(d[i], math.MaxInt32)
		d[i][i] = 0
	}

	for y := 0; y < H; y++ {
		for x := 0; x < W; x++ {
			if S[y][x] == '#' {
				continue
			}
			if y-1 >= 0 && S[y-1][x] != '#' {
				d[y*W+x][(y-1)*W+x] = 1
			}
			if y+1 < H && S[y+1][x] != '#' {
				d[y*W+x][(y+1)*W+x] = 1
			}
			if x-1 >= 0 && S[y][x-1] != '#' {
				d[y*W+x][y*W+x-1] = 1
			}
			if x+1 < W && S[y][x+1] != '#' {
				d[y*W+x][y*W+x+1] = 1
			}
		}
	}

	warshallFloyd(n, d)

	result := 0
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if d[i][j] < math.MaxInt32 && d[i][j] > result {
				result = d[i][j]
			}
		}
	}

	fmt.Println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

func fillInts(a []int, x int) {
	for i := 0; i < len(a); i++ {
		a[i] = x
	}
}


Measured memory_bytes: 2048
#!/usr/bin/env python3
import itertools
import sys
sys.setrecursionlimit(10**6)

a, b, c, d = [int(i) for i in str(input())]

for i, j, k in itertools.product([1, -1], repeat=3):
    if a+b*i+c*j+d*k == 7:
        break

if i == 1:
    i = "+"
else:
    i = "-"
if j == 1:
    j = "+"
else:
    j = "-"
if k == 1:
    k = "+"
else:
    k = "-"

print("{}{}{}{}{}{}{}=7".format(a, i, b, j, c, k, d))


Measured memory_bytes: 9072
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	static class Edge{
		int dst;
		long dist;
		long cost;
		Edge(int dst , long d ,long c){
			this.dst = dst;
			dist = d;
			cost = c;
		}
	}
	static class Vertex{
		List<Edge> adj;
		public Vertex() {
			adj = new ArrayList<Edge>();
		}
	}
	static class State implements Comparable<State>{
		int cur;
		int silver;
		long dist;
		public State(int c , int s , long d) {
			cur = c;
			silver = s;
			dist = d;
		}
		@Override
		public int compareTo(State o) {
			return Long.compare(dist, o.dist);
		}
	}
	static int SMax = 2500;
	static long solve(Vertex vs[] , int[] C , int[] D, int S, int target){
		PriorityQueue<State> pq = new PriorityQueue<State>();
		pq.add(new State(0 , S , 0));
		long dp[][] = new long[vs.length][SMax + 1];
		for(int i = 0 ; i < dp.length ; ++i){
			Arrays.fill(dp[i], -1);
		}
		dp[0][S] = 0;
		while(!pq.isEmpty()){
			State cur = pq.poll();
//			System.out.println(cur.cur+" "+cur.silver+" "+cur.dist);
			if(cur.cur == target){
				return cur.dist;
			}
			long changeCost = D[cur.cur];
			int nchange = cur.silver + C[cur.cur];
			if(nchange > SMax){
				nchange = SMax;
			}
			if(dp[cur.cur][nchange] == -1 || dp[cur.cur][nchange] > cur.dist + changeCost){
				pq.add(new State(cur.cur , nchange , cur.dist + changeCost));
				dp[cur.cur][nchange] = cur.dist + changeCost;
			}
			for(Edge e : vs[cur.cur].adj){
				if(e.cost <= cur.silver){
					State ns = new State(e.dst, (int)(cur.silver - e.cost), cur.dist + e.dist);					
					if(dp[ns.cur][ns.silver] == -1 || dp[ns.cur][ns.silver] > ns.dist){
						pq.add(ns);
						dp[ns.cur][ns.silver] = ns.dist;
					}
				}
			}
		}
		
		return -1;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int S = sc.nextInt();
		if(S > SMax){
			S = SMax;
		}
		Vertex vs[] = new Vertex[N];
		for(int i = 0 ; i < N ; ++i){
			vs[i] = new Vertex();
		}

		for(int i = 0 ; i < M ; ++i){
			int U = sc.nextInt() - 1;
			int V = sc.nextInt() - 1;
			int A = sc.nextInt();
			int B = sc.nextInt();
			vs[U].adj.add(new Edge(V , B , A));
			vs[V].adj.add(new Edge(U , B , A));
		}
		int C[] = new int[N];
		int D[] = new int[N];
		for(int i = 0 ; i < N ; ++i){
			C[i] = sc.nextInt();
			D[i] = sc.nextInt();
		}
		for(int i = 1 ; i < N ; ++i){
			System.out.println(solve(vs , C , D, S , i));
		}
	}
}


Measured memory_bytes: 62416
#include <bits/stdc++.h>
 using namespace std;
 int N, A[3][3], b[10];
 bool appear[3][3];
 int main() {
 for(int i = 0; i < 3; i++) {
 for(int j = 0; j < 3; j++) cin >> A[i][j];
 }
 cin >> N;
 for(int i = 0; i < N; i++) cin >> b[i];
 for(int i = 0; i < N; i++) {
 for(int j = 0; j < N; j++) {
 appear[i][j] = false;
 for(int k = 0; k < N; k++) {
 if(A[i][j] == b[k]) appear[i][j] = true;
 }
 }
 }
 string ANS = "No";
 for(int i = 0; i < 3; i++) {
 if(appear[i][0] and appear[i][1] and appear[i][2]) ANS = "Yes";
 }
 for(int i = 0; i < 3; i++) {
 if(appear[0][i] and appear[1][i] and appear[2][i]) ANS = "Yes";
 }
 if(appear[0][0] and appear[1][1] and appear[2][2]) ANS = "Yes";
 if(appear[0][2] and appear[1][1] and appear[2][0]) ANS = "Yes";
 cout << ANS << endl;
 return 0;
 }

Measured memory_bytes: 256
S = input()
n = len(S)
maxs = ""

for left in range(n):
    right = left
    while (right < n and S[right] in {'A', 'T', 'G', 'C'}):
        maxs = max(maxs, S[left:right+1], key=len)
        right += 1

print(len(maxs))

Measured memory_bytes: 3060
// #pragma GCC optimize("O3", "unroll-loops")
// #pragma GCC target("avx2")

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

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
// #define ost tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

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

int power(int x, int y, int p)  
{  
    int res = 1;    
    x = x % p; 
    if (x == 0) return 0; 
    while (y > 0)  
    {     
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res; 
}

int32_t main()
{
    speed upp
    int n;
    cin>>n;
    ld r=2*n;
    r=r*((ld)3.141592653589793238);
    cout<<fixed<<sp(10)<<r;
}

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

int a1, a2, a3;

int main() {
    int cost = 0;
    std::cin >> a1 >> a2 >> a3;
    std::vector<int> vec = {a1, a2, a3};
    std::sort(vec.begin(), vec.end());
    int pre_work = vec[0];
    for (int i = 1; i <= 2; i++) {
        cost += std::abs(pre_work - vec[i]);
        pre_work = vec[i];
    }
    std::cout << cost << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int r=0,c=0,A[150][150]={0};
    scanf("%d%d",&r,&c);
    REP(i,r){
        REP(j,c){
            
            scanf("%d",&A[i][j]);
            A[r][j]+=A[i][j];
            A[i][c]+=A[i][j];
            A[r][c]+=A[i][j];
            
        }
    }
    REP(i,r+1){
        REP(j,c+1){
            if(j==0)printf("%d",A[i][j]);
            else printf(" %d",A[i][j]);
        }
        printf("\n");
    }
}


Measured memory_bytes: 3332
N, M = map(int, input().split())
A = []
B = []

for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

A, B = zip(*sorted(zip(A, B)))
cost = 0
for i in range(N):
    if M > B[i]:
        cost += A[i] * B[i]
        M -= B[i]
    else:
        cost += A[i] * M
        break

print(cost)

Measured memory_bytes: 25960
import sys
input = sys.stdin.readline
from collections import defaultdict
N = int(input())

# ax + by = d
# d,x,y
def gcd(a,b):
    if b == 0:
        return a, 1, 0
    s = a % b
    t = a // b
    d, x, y = gcd(b, s)
    x,y = y, x -  t * y
    if d < 0:
        d,x,y = -d,-x,-y
    return d, x, y 

if N == 1:
    print(1)
    exit()

def divisors(n):
    ls = []
    for i in range(1,int(n**0.5)+1):
        if n % i == 0:
            ls.append(i)
            ls.append(n//i)
    ls = sorted(list(set(ls)))
    return ls

M = 2*N
divs = divisors(M)

if len(divs) == 2:
    pass

ans = 10**20
for m1 in divs:
    m2 = M // m1 
    d,t1,t2 = gcd(-m1,m2)
    if d > 1:
        continue
    if t1 > 0:
        ans = min(ans, m1*t1)

print(ans)

    
    
    




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

using namespace std;
using ll = long long;
#define rep(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define REP(i, n) for(ll i = n-1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << " = " << x << endl
#define mp make_pair
#define pb push_back

const long long MOD = 1000000007;
const long long INF = 1LL<<60;


int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    cout << fixed << setprecision(12);

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

    return 0;
}


Measured memory_bytes: 3652
#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>;
const int INF = 1e9;
int c[10][1001];

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> s(h);
  rep(i, h) cin >> s[i];

  int ans = INF;
  rep(div, 1 << (h - 1)) {
    int g = 0;          // group ID iterator
    vector<int> id(h);  // group ID
    rep(i, h) {
      id[i] = g;
      if (div >> i & 1) g++;
    }
    g++;

    rep(i, g) rep(j, w) c[i][j] = 0;
    rep(i, h) rep(j, w) c[id[i]][j] += (s[i][j] - '0');

    int num = g - 1;
    vector<int> now(g);
    auto add = [&](int j) {
      rep(i, g) now[i] += c[i][j];
      rep(i, g) if (now[i] > k) return false;
      return true;
    };

    rep(j, w) {
      if (!add(j)) {
        num++;
        now = vector<int>(g);
        if (!add(j)) {
          num = INF;
          break;
        }
      }
    }
    ans = min(num, ans);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)

#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))

#define endl "\n"
#define pb push_back
#define rtn return
#define elif else if

#define MOD 1000000007
 
const int dx_4[]={1,0,-1,0}, dy_4[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};

typedef long long ll;
typedef unsigned long long ull;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	int a, b;
	cin >> a >> b;
	if(a % 2 == 1 and b % 2 == 1) cout << "Yes" << endl;
	else cout << "No" << endl;

	rtn 0;
}

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

using namespace std;

int main() {
	int N,x;
	int a[110];
	cin >> N>>x;
	for (int i = 0; i < N; ++i)cin >> a[i];

	int c = 0;
	int i = 0;
	sort(a, a + N);
	for (int i = 0; i < N; ++i){
		x -= a[i];
		if (x < 0)break;
		c++;
	}
	if (x > 0)c--;
	



	cout << c << endl;
	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
p = list(map(int, input().split()))
xy = [list(map(int, input().split())) for _ in range(m)]

# Union Find
class UnionFind():
    def __init__(self, size):
        self.par = [i for i in range(size)]
        self.rank = [0 for _ in range(size)]
        self.sizes = [1 for _ in range(size)]
    def root(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.root(self.par[x])
            return self.par[x]
    def same(self, x, y):
        return self.root(x) == self.root(y)
    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.sizes[y] += self.sizes[x]
        else:
            self.par[y] = x
            self.sizes[x] += self.sizes[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
    def size(self, x):
        return self.sizes[self.root(x)]

uf = UnionFind(n)
for x, y in xy:
    uf.unite(x-1, y-1)
mask = [0] * n
for i in range(n):
    mask[i] = uf.root(i)
res = 0
for i in range(n):
    if mask[i] == uf.par[p[i]-1]:
        res += 1
print(res)

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

int main()
{
  int n, a, b ;
  cin >> n >> a >> b ;
  if( (b - a - 1) % 2 == 0)
  {
    cout << "Borys" << endl ;
  }
  else
  {
    cout << "Alice" << endl ;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef tuple<ll, ll, ll> ti;
ll mod=1E9+7;
 
#define REP(a,b,c) for(ll a=(b);a<(c);a++)
#define PER(a,b,c) for(ll a=(b);a>=(c);a--)

ll ii(){ ll x; cin >> x; return x; }
string is(){ string x; cin >> x; return x; }
double id(){ double x; cin >> x; return x; }
void oi(ll x){ cout << x; }
void od(ld x){ cout << fixed << setprecision(10) << x; }
void os(string x){ cout << x; }
void oe(){ cout << endl; }
void oie(ll x){ oi(x); oe(); }
void ode(ld x){ od(x); oe(); }
void ose(string x){ os(x); oe(); }

short memo[202020][2020];

int main(){
    string S=is();
    ll ret=0;
    REP(i,0,S.length()) memo[i][0]++;
    
    REP(i,0,S.length()){
        ll a=(S[i]-'0');
        REP(j,0,2019){
            if(memo[i][j]>0){
                ll y = (j*10+a)%2019;
                if(y==0){
                    ret+=memo[i][j];
                }
                memo[i+1][y]+=memo[i][j];
            }
        }
    }
    oie(ret);

    return 0;
}

Measured memory_bytes: 792744
import java.util.*;
public class Main{
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();   
        System.out.print(s.charAt(0));
        System.out.print(s.length()-2);
        System.out.println(s.charAt(s.length()-1));
    }
}

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

using i64 = int64_t;

int main(){
    i64 n, k;
    cin >> n >> k;
    i64 ans = 0;
    for(int i=0;i<n-1;++i){
        ans += ans / (k-1) + 1;
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3064
a, b = map(int,input().split())
s = input()

if s.count("-") == 0 or s.count("-") > 1:
  print("No")
  exit()

if s[0] == "-" or s[-1] == "-":
  print("No")
  exit()

if len(s.split("-")[0]) != a:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 3060
function Main(input) {
    input = input[0].split(' ');
    const p = parseInt(input[0], 10), q = parseInt(input[1], 10), r = parseInt(input[2], 10);
    input[0] = p;
    input[1] = q;
    input[2] = r;
    // console.log(typeof input[0], typeof input[1], typeof input[2]);
    // input.sort(
    //     function(a,b) {
    //         return (a < b ? -1 : 1);
    //     }
    // );
    input.sort((a,b) => a < b ? -1 : 1);
    // console.log(input);
    console.log(input[0] + input[1]);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));

Measured memory_bytes: 21064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  int min = 10000;
  for(int i = 0;i<a;i++){
    int c;
    cin >> c;
    b -= c;
    if(c < min)
      min = c;
  }
  cout << a + b/min << endl;
}


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

typedef vector<int> vi;
typedef pair<int, int> pi;

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

#define pb push_back
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, b, e) for (int i = (b); i <= (int)(e); i++)
#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUGA(a) cout << #a << ": "; for (const auto& v: (a)) cout << v << endl

signed main() {
    int N;
    cin >> N;

    vi B(N-1);
    REP(i, N-1) {
        cin >> B[i];
    }

    int sum = B[0] + B[N-2];
    REP2(i, 1, N-2) {
        sum += min(B[i], B[i-1]);
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256