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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)


void func(long long N, long long K){
    lli ans = K;
    REP(i,1,N)ans *= (K-1);

    cout<<ans<<endl;
}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    func(N, K);
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict

N, M = [int(el) for el in input().split()]
paths = defaultdict(lambda: set())

for _ in range(M):
    S, D = [int(el) for el in input().split()]
    paths[S].add(D)
    paths[D].add(S)

post = [0 for _ in range(N + 1)]
post[0] = post[1] = 1
queue = [1, ]
while queue:
    s = queue.pop(0)
    for d in paths[s]:
        if post[d] == 0:
            post[d] = s
            queue.append(d)

if post.count(0) != 0:
    print("No")
else:
    print("Yes")
    for item in post[2:]:
        print(item)

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

using namespace std;

int a[200005], ok[200005];

main() {
#ifdef HOME
    freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    vector < int > ans;
    for (int i = n; i >= 1; --i) {
        int sum = 0;
        for (int j = 2 * i; j <= n; j += i) {
            sum += ok[j];
        }
        sum %= 2;
        if (sum == a[i]) continue;
        ans.push_back(i);
        ok[i] = 1;
    }
    cout << ans.size() << '\n';
    for (auto key : ans) cout << key << " ";
    return 0;
}



Measured memory_bytes: 2936
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>
using namespace std;
#define All(v) (v).begin(),(v).end()
const long long mod = 1000000007;
const long long inf = mod*mod;
const int MAXS = 114514;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
signed main(){
    int n;
    cin>>n;
    vector<string> s(n);
    for(int i=0;i<n;i++)cin>>s[i];
    string res = "";
    for(char c='a';c<='z';c++){
        int m = 10000;
        for(auto str:s){
            int cnt = 0;
            for(int i=0;i<str.size();i++){
                if(str[i]==c)cnt++;
            }
            m=min(cnt,m);
        }
        for(int i=0;i<m;i++){
            res+=c;
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
N = int(input())
A = [0]*N
B = [0]*N
i = 0
for i in range(N):
    A[i], B[i] = map(int, input().split())
sA = sorted(A)
sB = sorted(B)
if N % 2 == 0:
    ans = ((sB[(N//2)-1]+sB[(N//2)]) - (sA[(N//2)-1]+sA[(N//2)])) + 1
else:
    ans = (sB[(N-1)//2]-sA[(N-1)//2]) + 1
print(ans)


Measured memory_bytes: 28508
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

int t[100000], a[100000], minh[100000], maxh[100000];
int main() {
	int n;
	cin >> n;
	REP(i,0,n) cin >> t[i];
	REP(i,0,n) cin >> a[i];
	minh[0] = maxh[0] = t[0];
	//minh[n-1] = maxh[n-1] = t[n-1];
	REP(i,1,n) {
		if (t[i] > t[i-1]) minh[i] = maxh[i] = t[i];
		else {
			minh[i] = 1;
			maxh[i] = t[i-1];
		}
		//cout << i << " " << minh[i] << " " << maxh[i] << endl;
	}
	if (maxh[n-1] < a[n-1] || minh[n-1] > a[n-1]) {
		cout << 0 << endl;
		return 0;
	} else {
		minh[n-1] = maxh[n-1] = a[n-1];
	}
	int mint, maxt;
	for (int i = n - 2; i >= 0; --i) {
		if (a[i] > a[i+1]) mint = maxt = a[i];
		else {
			mint = 1;
			maxt = maxh[i+1];
		}
		if (mint <= maxh[i] && maxt >= minh[i]) {
			minh[i] = max(minh[i], mint);
			maxh[i] = min(maxh[i], maxt);
		} else {
			cout << 0 << endl;
			return 0;
		}
		//cout << i << " " << minh[i] << " " << maxh[i] << endl;
	}
	LL ans = 1;
	REP(i,0,n) {
		//cout << minh[i] << ", " << maxh[i] << endl;
		ans = (ans * (maxh[i] - minh[i] + 1)) % 1000000007;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1920
package main

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

func main() {
	scanner.Split(bufio.ScanWords)
	N := readInt()
	A := readInt()
	B := readInt()
	fmt.Println(min(A*N, B))
}

/*-----------------------------------------*/

func checkError(err error) {
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
}

var scanner = bufio.NewScanner(os.Stdin)

func read() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	res, err := strconv.Atoi(read())
	checkError(err)
	return res
}

func min(a int, b int) int {
	return int(math.Min(float64(a), float64(b)))
}

func max(a int, b int) int {
	return int(math.Max(float64(a), float64(b)))
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
#define out(a) cout<<(a)<<endl;
const int INF=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;
ll roundd(ll x,ll n){
  if(x>n){return x%n;}
  else if(x<0){return x%n+n;}
  else return x;
}
int main(){
  ll k;cin>>k;
  ll ans=0;
  queue<ll> q;
  rep(i,1,10)q.push(i);
  rep(i,0,k){
    ll tmp=q.front();
    q.pop();
    if(tmp%10!=0){q.push(tmp*10+(tmp%10)-1);}
    q.push(tmp*10+(tmp%10));
    if(tmp%10!=9){q.push(tmp*10+(tmp%10)+1);}
    ans=tmp;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 5116
//by kcz 1552920354@qq.com
//if you find any bug in my code
//please tell me
#include<bits/stdc++.h>
using namespace std;

template <typename T> void chmin(T &x,const T &y)
{
	if(x>y)x=y;
}
template <typename T> void chmax(T &x,const T &y)
{
	if(x<y)x=y;
}
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define per(i,r,l) for(int i=r;i>=l;--i)
#define pb push_back
#define mp make_pair
#define gc (c=getchar())
char readc()
{
	char c;
	while(gc<'-');
	return c;
}
int read()
{
    char c;
    while(gc<'-');
    if(c=='-')
    {
        int x=gc-'0';
        while(gc>='0')x=x*10+c-'0';
        return -x;
    }
    int x=c-'0';
    while(gc>='0')x=x*10+c-'0';
    return x;
}
#undef gc

const int N=1e5+5;
int a[N];

int main()
{
	//freopen("1.in","r",stdin);//freopen("1.out","w",stdout);
	ll ans=0;
	int n=read();
	rep(i,1,n)a[i]=read();
	rep(i,1,n+1)ans+=abs(a[i]-a[i-1]);
	rep(i,1,n)printf("%lld\n",ans-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1]));
}



Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cerr<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
int getInt(){int x;scanf("%d",&x);return x;}
template<typename T>istream& operator>>(istream&i,v(T)&v){rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v){stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const v(T)&v){if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v){return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v){return o<<v.fi<<","<<v.se;}
template<typename T>bool mins(T& x,const T&y){if(x>y){x=y;return true;}else return false;}
template<typename T>bool maxs(T& x,const T&y){if(x<y){x=y;return true;}else return false;}
template<typename T>ll suma(const v(T)&a){ll res(0);for(auto&&x:a)res+=x;return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;


int main() {
  int n,w;
  scanf("%d%d",&n,&w);
  vi a(n);
  cin>>a;
  rep(i,n) a[i]--;
  fenwick_tree<int> ts(n);
  fenwick_tree<mint> t(n);
  mint e, es, x = 1;
  mint p = mint(w-1)/w;
  rep(i,n) {
    if (i >= w) {
      x *= p;
      e += ts.sum(a[i],n) - x*t.sum(a[i],n);
      es += ts.sum(0,n) - x*t.sum(0,n);
    }

    ts.add(a[i],1);
    t.add(a[i],1/x);
  }

  mint ans = mint(n)*(n-1)/2;
  ans -= es;
  ans = ans/2 + e;
  cout<<ans.val()<<endl;
  return 0;
}






















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

long N=0;
char S[100010];
long l[26];
long A=1;

int main(){
  for(int i=0;i<26;i++){
    l[i]=1;
  }
  cin >> N >> S;
  for(int i=0;i<N;i++){
    l[S[i]-'a']++;
  }

  for(int i=0;i<26;i++){
    A*=l[i];
    A%=1000000007;
  }
  A+=1000000006;
  A%=1000000007;
  cout << A << endl;
  return 0;
}


Measured memory_bytes: 1016
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
vector<ll>to[100005];
int main(void) {
	ll n, m;
	cin >> n >> m;
	int a, b;
	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		a--; b--;
		to[a].push_back(b);
		to[b].push_back(a);
	}

	queue<ll>que;
	vector<ll>dist(n, inf);
	vector<ll>pre(n, -1);
	dist[0] = 0;
	que.push(0);
	while (!que.empty()) {
		int x = que.front();
		que.pop();
		for (auto v : to[x]) {
			if (dist[v] != inf) {
				continue;
			}
			dist[v] = dist[x] + 1;
			pre[v] = x + 1;
			que.push(v);
		}
	}
	cout << "Yes" << endl;
	for (int i = 1; i < n; i++) {
		cout << pre[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 13564
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define F first
#define S second
#define mod 1000000007
#define pb push_back
#define FOR(i,a,n) for(int i=a;i<n;i++)
#define REV(i,a,n) for(int i=a;i>=n;i--)
#define all(a) a.begin(),a.end()
#define UB upper_bound
#define LB lower_bound
const int NUM = 2e5 + 5;
const int N = 301;
double dp[N][N][N];
// dp[x][y][z] = x 3s, y 2s, z 1s and (n - x - y - z) zeros
int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int num_tests=1; 
    //cin >> num_tests;
    while(num_tests-->0){
        int n; cin >> n;
        int cnt[4] = {0};
        FOR(i,0,n){
            int x; cin >> x;
            cnt[x]++;
        }
        dp[0][0][0] = 0.0;
        FOR(x,0,n+1){
            FOR(y,0,n+1){
                FOR(z,0,n+1){
                    int zeros = n - (x+y+z);
                    if(zeros == n) continue;
                    if(zeros < 0) continue;
                    double res = 1.0;
                    // if I pick 3
                    if(x > 0) res += (1.0 * x/n) * dp[x-1][y+1][z];
                    // if I pick 2
                    if(y > 0) res += (1.0 * y/n) * dp[x][y-1][z+1];
                    // if I pick 1
                    if(z > 0) res += (1.0 * z/n) * dp[x][y][z-1];
                    res = res/(1 - 1.0*zeros/n);
                    dp[x][y][z] = res;
                }
            }
        }
        cout << fixed << setprecision(10);
        cout << dp[cnt[3]][cnt[2]][cnt[1]];
    }   
}

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

using namespace std;

int main()
{
    int n;
    scanf("%d",&n);
    vector<int> pos,neg;
    int zero=0;
    for(int i=0;i<n;i++)
    {
        int temp;
        scanf("%d",&temp);
        if(temp>0) pos.push_back(temp);
        else if(temp<0) neg.push_back(temp);
        else zero++;
    }
    int a=pos.size(),b=neg.size();
    int res=0;
    vector<pair<int,int> > v;
    if(a==0&&b==0)
    {
        for(int i=0;i<n-1;i++) v.push_back(make_pair(0,0));
    }
    else if(b==0)
    {
        for(int i=0;i<zero;i++) pos.push_back(0);
        sort(pos.begin(),pos.end());
        int now=pos[0];
        for(int i=1;i<(int)pos.size()-1;i++)
        {
            v.push_back(make_pair(now,pos[i]));
            now-=pos[i];
        }
        v.push_back(make_pair(pos.back(),now));
        res=pos.back()-now;
    }
    else if(a==0)
    {
        for(int i=0;i<zero;i++) neg.push_back(0);
        sort(neg.begin(),neg.end(),greater<int>());
        int now=neg[0];
        for(int i=1;i<(int)neg.size();i++)
        {
            v.push_back(make_pair(now,neg[i]));
            now-=neg[i];
        }
        res=now;
    }
    else
    {
        int tp=pos.back(),tn=neg.back();
        pos.pop_back();
        neg.pop_back();
        pos.push_back(tn);
        neg.push_back(tp);
        for(int i=0;i<zero;i++) pos.push_back(0);
        sort(pos.begin(),pos.end());
        sort(neg.begin(),neg.end(),greater<int>());
        int one=pos[0];
        for(int i=1;i<(int)pos.size();i++)
        {
            v.push_back(make_pair(one,pos[i]));
            one-=pos[i];
        }
        int two=neg[0];
        for(int i=1;i<(int)neg.size();i++)
        {
            v.push_back(make_pair(two,neg[i]));
            two-=neg[i];
        }
        v.push_back(make_pair(two,one));
        res=two-one;
    }
    printf("%d\n",res);
    for(int i=0;i<n-1;i++) printf("%d %d\n",v[i].first,v[i].second);
    return 0;
}


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

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

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

#define ll long long

void swap (int *x, int *y) {
  int temp;

  temp = *x;
  *x = *y;
  *y = temp;

  return;
}


int gcd(int a, int b){
  int c;

  while (b > 0){
    c = a % b;
    a = b;
    b = c;
  }

  return a;
}

int upll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;
}

int downll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;
}

void sortup(ll*a,int n){
  qsort(a,n,sizeof(ll),upll);
}

void sortdown(ll*a,int n){
  qsort(a,n,sizeof(ll),downll);
}

long int modpow(long int a,long int n,long int mod){
  long int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}

long int modinv(long int a,long int mod){
  return modpow(a,mod-2,mod);
}

int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}

int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}

void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }

  return;
}

void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }

  return;
}


int main(void){
  int k;
  scanf("%d",&k);
  int ans=0;
  for(int i=1;i<k+1;i++){
    for(int j=1;j<k+1;j++){
      if(i%2==1&&j%2==0){
        ans++;
      }
    }
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 1704
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;

const int N = 100 + 10;
int dp[N][5 * N];

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<int> w(n), v(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", &w[i], &v[i]);
  }
  int base = w[0];
  for (int i = 0; i < n; ++i) w[i] -= base;
  int ret = 0;
  for (int k = 1; k <= n && base * k <= m; ++k) {
    memset(dp, 255, sizeof(dp));
    dp[0][0] = 0;
    int sum = 0;
    for (int i = 0; i < n; ++i) {
      sum += w[i];
      for (int j = k; j >= 1; --j) {
        for (int u = w[i]; u <= sum; ++u) {
          if (dp[j - 1][u - w[i]] >= 0) {
            dp[j][u] = max(dp[j][u], dp[j - 1][u - w[i]] + v[i]);
          }
        }
      }
    }
    for (int i = 0; i <= m - k * base && i <= sum; ++i) {
      if (dp[k][i] >= 0) {
        ret = max(ret, dp[k][i]);
      }
    }
  }
  printf("%d\n", ret);
  return 0;
}


Measured memory_bytes: 512
//C
#include <cassert>
//#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//ここまで標準include

using namespace std;

long aCb(long a, long b) {
	long out = 1;
	for (long i = 1; i <= b; i++) {
		out = out * (a + 1 - i) / i;
	}
	return out;
}

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a + b > c + d) {
		cout << "Left" << endl;
	}
	else if (a + b < c + d) {
		cout << "Right" << endl;
	}
	else {
		cout << "Balanced" << endl;
	}
}

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

using namespace std;
 
using ll = long long;
using ull = unsigned long long;
using ldouble = long double;
 
const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s) cout << fixed << setprecision(10) << s << endl;

ll res;

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

    ll res = 1;
    for (ll i = 1; ; i++)
    {
        
        if (i * i > n)
        {
            break;
        }
        res = i * i;
    }

    println(res)
}


Measured memory_bytes: 3620
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>  // assert(x>=10), 部分点問題
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <set>

#define repl(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(), (x).end()
#define SORT(v,n) sort(v,v+n)
#define VSORT(v) sort(all(x))
#define FILL(v, value) (v+(sizeof(v) / sizeof *(v)), value);
#define inf 999999999
#define dbg(x) cout<<#x<<":"<<x<<endl;
#define pb(a) push_back((a))
#define mp(a) make_pair((a))
#define pi 2*acos(0.0)
#define in scanf
#define out printf
#define fi first
#define se second
#define bit(n) (1LL<<(n))

using namespace std;

typedef long long llong;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;
typedef pair<llong, pll> plp;

const int MOD=1000000007; // 10^9 + 7
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};  // 右下左上


int main(int argc, char**argv){
  int nx, ny;
  cin >> nx >> ny;
  long x[nx];
  long y[ny];
  rep(i, nx){
    long tmp;
    cin >> tmp;
    x[i] = tmp;
  }
  rep(i, ny){
    long tmp;
    cin >> tmp;
    y[i] = tmp;
  }

  llong sum_x = 0, sum_y = 0;
  rep(i, nx){
    sum_x += (2*i - nx + 1) * x[i];
    sum_x %= MOD;
  }
  rep(i, ny){
    sum_y += (2*i - ny + 1) * y[i];
    sum_y %= MOD;
  }

  cout << (sum_x * sum_y) % MOD << endl;


	return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<bitset>
#include<iostream>
#include<set>
#include<string.h>
#include<stack>
#include<queue>
#include<map>
#include<unordered_map>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<limits>
#include<math.h>
#include<string.h>

using namespace std;
  
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
 
#define pb push_back
#define ii pair<int, int> 
#define iii pair<int, ii > 
#define vai freopen("in","r",stdin);
#define inf 0x3f3f3f3f
#define f first
#define s second	

const ll INF = 1e18;
const double dinf = 12345678;       
const int mod = 1000000007;
const int maxn = 1e5 + 10;
const int MAX = 1e4 + 10;
 
int dist[maxn];
vi mov;

int exp( int n, int e ){
	int r = 1;
	while(e){
		if(e&1){r*=n;}
		n*=n;
		e>>=1;
	}
	return r;
}

void f( int n , int cnt){
	
	if ( dist[0] < cnt)return;
	for(auto x: mov){
		if ( x <= n and dist[n - x] > cnt + 1){
			dist[n - x] = cnt + 1;
			f(n - x ,cnt + 1);
		}
	}
}

int n ;	
int main (){
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
	
	for(int i = 0 ;i < maxn;i++)dist[i] = inf;
	mov.pb(1);
	cin >> n;
	if( n  < 9){
		if(n>=6) {n-=6;
			cout << 1 + n << '\n'; return 0;
		}else return cout<<n, 0;
	}
	int val = 1, pot = 1;
	while( val <= n){
		val  = exp(9, pot++);
		mov.pb(val);
	}
	sort( mov.rbegin(), mov.rend());
	val = 1, pot = 1;
	while( val <= n){
		val  = exp(6, pot++);
		mov.pb(val);
	}
	
	f(n,0);
 
	cout << dist[0] << '\n';
 
	return 0;
	
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream &operator << (ostream& out,const pair<S,T>& o){
    out << "(" << o.first << "," << o.second << ")"; return out;
}
/*
<url:>
問題文============================================================

=================================================================

解説=============================================================

================================================================
*/
ll solve(){
    ll res = 0;
    ll N,M; cin >> N >> M;
    if(N >= 2 && M >= 2) res = (N-2)*(M-2);
    else if(N >= 2 && M == 1) res = N - 2;
    else if(M >= 2 && N == 1) res = M - 2;
    else if(N == 1 && M == 1) res = 1;
    return res;
}
int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    cout << solve() << endl;
    return 0;
}



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

bool is_palindrome(string w){
    size_t b=0, e=w.size()-1;
    bool flag = 1;
    for(size_t i=0; i<w.size()/2; i++){
        if(w[b] != w[e]){
            flag = 0;
            break;
        }
        b++;
        e--;    
    }
    return flag;
}

int main(){
    string in;
    cin >> in; 
    string in_1 = in.substr(0,in.length()-((in.length()-1)/2)-1); 
    string in_2 = in.substr(((in.length()+3)/2)-1); 
    if(is_palindrome(in) && is_palindrome(in_1) && is_palindrome(in_2)){
        cout << "Yes";
    }
    else cout << "No";
}

Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
int n,m;
const int M = 2e5+5;
char s[M];
 
struct Node{
	int swp,ch[3],ed;
}t[2000010];
int cnt=1;
 
inline void ins(int sum){
	int fir=1;
	int s=sum;
	for(int i=0;i<n;i++){
		int q=sum%3;
		sum/=3;
		if(!t[fir].ch[q])t[fir].ch[q]=++cnt;
		fir=t[fir].ch[q];
	}
	t[fir].ed=s;
}
 
void add(){
	int fir=1;
	for(int i=0;i<n;i++){
		if(t[fir].swp){
			swap(t[fir].ch[1],t[fir].ch[2]);
			for(int j=0;j<3;j++)t[t[fir].ch[j]].swp^=1;
			t[fir].swp=0;
		}
		int q=t[fir].ch[2];t[fir].ch[2]=t[fir].ch[1],t[fir].ch[1]=t[fir].ch[0];
		t[fir].ch[0]=q;
		fir=q;
	}
}
int ans[2000010];
void dfs(int fir,int d,int quan,int s){
	if(t[fir].swp){
		swap(t[fir].ch[1],t[fir].ch[2]);
		for(int j=0;j<3;j++)t[t[fir].ch[j]].swp^=1;
		t[fir].swp=0;
	}
	if(d==n){
		ans[t[fir].ed]=s;return;
	}
	for(int j=0;j<3;j++){
		dfs(t[fir].ch[j],d+1,quan*3,s+quan*j);
	}
}
int tot=0;
int main()
{
	cin >> n;
	tot=1;for(int i=1;i<=n;i++)tot*=3;
	scanf("%s",s+1);
	m=strlen(s+1);
	for(int i=0;i<tot;i++){
		ins(i);
	}
	// cerr << "?" << endl;
	for(int j=1;j<=m;j++){
		if(s[j]=='S')t[1].swp^=1;
		else add();
		// dfs(1,0,1,0);
		// for(int i=0;i<tot;i++)printf("%d ",ans[i]);puts("");
	}
	dfs(1,0,1,0);
	for(int i=0;i<tot;i++)printf("%d ",ans[i]);puts("");
}

Measured memory_bytes: 21824
#include<stdio.h>
#include<string.h>
#define max(a,b) (a>b?a:b)
char B[15005][5];
int N,d,p,q,res;


int cnt(int y,int x,int c)
{
	int t=0;
	for(int i=0;i<c;i++)
		t+=B[y][x+i];
	return t;
}

void dbg()
{
	for(int i=0;;i++,puts(""))
	{
		int f=cnt(i,0,5);
		if(!f)break;
		for(int j=0;j<5;j++)
			putchar(B[i][j]?'x':'o');
	}
	puts("");
}


int sch(int h,int w,int p,int y)
{
	int i;
	for(i=y;i>=0;)
	{
		int l=cnt(i,p,w);
		if(!l)
		{
			if(i&&cnt(i-1,p,w)==0)
				i--;
			else
				return i;
		}
		else
		{
			if(cnt(i+1,p,w)==0)
				i++;
			else
				return i;
		}
	}
	return i;
}

void Tset(int y,int x,int h,int w)
{
	for(int i=0;i<h;i++)
		for(int j=0;j<w;j++)
			B[y+i][x+j]=1;
}

void flsh()
{
	for(int i=0;;)
	{
		int j,f=cnt(i,0,5);
		if(!f)break;
		if(f==5)
		{
			int tmp=sizeof(char)*(6000*5-i*(5+1));
			memmove(B[i],B[i+1],sizeof(char)*25000);
		}
		else
			i++;
	}
}

int r()
{
	int res=0;
	for(int i=0;;i++)
	{
		int t=cnt(i,0,5);
		if(t==0)break;
		else if(t==5)continue;
		else res+=t;
	}
	return res;
}

int main()
{
	for(;scanf("%d",&N),N;)
	{
		int h=0,t;
		res=0;
		memset(B,0,sizeof(B));
		for(int i=0;i<N;i++)
		{
			scanf("%d%d%d",&d,&p,&q);
			res+=p;
			q--;
			t=sch(d==1?1:p,d==1?p:1,q,h);
			Tset(t,q,d==1?1:p,d==1?p:1);
			if(d==2)t+=p;
			else t++;
			h=max(t,h);
			flsh();
		}
		printf("%d\n",r());
	}
}

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

using namespace std;

int main(){
	int n; cin>>n;
	int a[n];
	for(int i = 0; i < n; i++) cin>>a[i];
	
	int MAX = INT_MAX;
	int dp[n];
	for(int i = 1; i < n; i++) dp[i] = MAX;
	dp[0] = 0;
	
	for(int i = 1; i < n; i++){
		if((i-1) >= 0) dp[i] = min(dp[i-1]+abs(a[i] - a[i-1]), dp[i]);
		if((i-2) >= 0) dp[i] = min(dp[i-2]+abs(a[i] - a[i-2]), dp[i]);
	}
	
	cout<<dp[n-1]<<"\n";
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <climits>
using namespace std;

int main(){
  int n, m; cin >> n >> m; //n:金額, m:コインの種類
  int c[m+1];
  for(int i=1; i<=m; i++) cin >> c[i];

  int dp[m+1][n+1]; //dp[調査した種類][円]
  for(int i=0; i<=m; i++){
    for(int j=0; j<=n; j++){
      if(i==0) dp[i][j]=INT_MAX>>3;
      else if(j==0) dp[i][j]=0;
      else dp[i][j] = 0;
    }
  }

  for(int i=1; i<=m; i++){
    for(int j=1; j<=n; j++){
      if(j<c[i]) dp[i][j] = dp[i-1][j];
      else dp[i][j] = min(dp[i-1][j], dp[i][j-c[i]]+1);
    }
  }

  cout << dp[m][n] << endl;

  return 0;
}



Measured memory_bytes: 7184
#define _GLIBCXX_DEBUG
#include <iostream>
#include <string>
#include <set>
#include <vector>
#include <utility>
#include <algorithm>

int main(int argc, char* argv[])
{
  int n;
  std::set< char > sc;

  std::cin >> n;
  for (int i = 0; i < n; i++) {
    char tmp;
    std::cin >> tmp;
    sc.insert(tmp);
  }

  //std::sort(vc.begin(), vc.end());
  //vc.erase(std::unique(vc.begin(), vc.end()), vc.end());

  if (sc.size() == 4) {
    std::cout << "Four" << std::endl;
  } else {
    std::cout << "Three" << std::endl;
  }

  return 0;
}


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

typedef long long ll;

int main() {

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

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    ll a = 0, b = 0, c = 0;
    cin >> a >> b >> c; 

    if(c - a - b > 0 && (c - a - b) * (c - a- b) > 4 * a * b) cout << "Yes\n";
    else cout << "No\n";
    
    return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    int N, A;
    cin>>N;
    bool denied=false;
    rep(i, N){
        cin>>A;
        if(A%2==0){
            if(A%3!=0 && A%5!=0) denied=true;
        }
    }
    cout<<(denied==true ? "DENIED" : "APPROVED")<<endl;
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        mut s: chars,
    }
    s.sort();
    if s[0] == s[1] && s[2] == s[3] && s[0] != s[3] {
        println!("Yes");
    } else {
        println!("No");
    }
}

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

int main() {
  int N, ans;
  cin >> N;
  ans = 0;
  rep (i,N+1){
  if(i<= 9 && 1<=i)
    ans++;
      if(i<= 999 && 100<=i)
    ans++;  
    if(i<= 99999 && 10000<=i)
    ans++;
  }
cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<unistd.h>
#include<string>
#include<cstring>
#include<stack>
#include<queue>
#include<utility>
#include<cmath>
#include<set>
#include<unordered_map>
#include<cstdio>
#include<map>
#include<numeric>
using namespace std;
#define F first
#define S second
typedef long long ll;
const int MAXN = 200000 + 5;
const int MAX = 1e7;
double pi = 3.1415926535897932384626433832795;
struct Query{
    int x,L,R ;
} ;
int main(){
    int N ;
    cin >>N;
    int a[2*N+1];
    for(int i=1;i<=2*N;i++)
        cin>>a[i];
    sort(a+1,a+2*N+1);
    
    //for(int i=1;i<=2*N;i++)
      //  cout<<a[i]<<" ";
    //cout<<endl;
    int sum=0;
    for(int i=1;i<2*N;i+=2)
        sum+=min(a[i],a[i+1]);
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>

typedef struct {
    char name;
    int Val;
    int index;
}Dat;
/*
 * 
 */
int main(int argc, char** argv) {
    
    int Num;
    scanf("%d",&Num);
    Dat Card[Num];
    Dat Card2[Num];
    
    for(int a = 0; a < Num; a++){
        Card[a].index = a;
        scanf(" %c%d",&Card[a].name,&Card[a].Val);
        Card2[a].name = Card[a].name;
        Card2[a].Val = Card[a].Val;
        Card2[a].index = Card[a].index;
    }
    
    int swap = 0;
    Dat temp;
    for(int i = 0; i < Num - 1; i++){
       for(int j = 0; j <  Num - i - 1 ; j++){
          if(Card[j].Val > Card[j+1].Val){
              swap++;
              temp = Card[j+1];
              Card[j+1] = Card[j];
              Card[j] = temp;
              
          } 
       }   
    }
    
    
    for(int a = 0; a < Num; a++){
        
            printf("%c%d",Card[a].name,Card[a].Val);
            if(a < Num - 1){
                printf(" ");
            } 
    }
    
    int stable = 1;
    for(int a = 0; a < Num - 1; a++){
        if(stable == 0)break;
        if(Card[a].Val == Card[a + 1].Val){
           if(Card[a].index > Card[a + 1].index)stable = 0;
        }
    }
    
    if(stable == 1)printf("\nStable\n");
    if(stable == 0)printf("\nNot stable\n");
    
    Dat temp1;
    int min, k, exe;
    
    for(int i = 0; i < Num - 1; i++){
        min = i;
        exe = i;
       for(int j = i + 1; j <  Num; j++){
              if(Card2[exe].Val > Card2[j].Val){
                  exe = j;
              }
       }
        if(Card2[i].Val > Card2[exe].Val){
           temp1 = Card2[i];
           Card2[i] = Card2[exe];
           Card2[exe] = temp1;
        }
    }
    
    for(int a = 0; a < Num; a++){
        
            printf("%c%d",Card2[a].name,Card2[a].Val);
            if(a < Num - 1){
                printf(" ");
            } 
    }
    
    int stable2 = 1;
    for(int a = 0; a < Num - 1; a++){
        if(stable2 == 0)break;
        if(Card2[a].Val == Card2[a + 1].Val){
           if(Card2[a].index > Card2[a + 1].index)stable2 = 0;
        }
    }
    
    if(stable2 == 1)printf("\nStable\n");
    if(stable2 == 0)printf("\nNot stable\n");
    return (0);
}



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

typedef long long ll;
const int N = 100;

ll dp[N][2];
int n, p;

int main(){
	scanf("%d%d", &n, &p);
	dp[0][0] = 1;
	for (int i = 1, x; i <= n; ++ i){
		scanf("%d", &x);
		dp[i][0] = dp[i - 1][0] + dp[i - 1][x & 1];
		dp[i][1] = dp[i - 1][1] + dp[i - 1][x & 1 ^ 1];
	}
	return printf("%lld\n", dp[n][p]), 0;
}

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

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

Measured memory_bytes: 512
'use strict'

const main = (INPUT) => {
  const input = INPUT.split('\n')[0]
  const [X, A, B] = input.split(' ').map(n => Number(n))
  if (A - B >= 0) {
    console.log('delicious')
  } else if (A - B < 0 && Math.abs(A - B) <= X) {
    console.log('safe')
  } else {
    console.log('dangerous')
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


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

int main() {
  string s;
  cin >> s;
  string tmp;
  string s1 = "maerd";
  string s2 = "remaerd";
  string s3 = "esare";
  string s4 = "resare";
  string empty = "";
  int ss = s.size();
  int count = 0;
  for (int i = 0; i < ss; i++) {
    tmp = tmp + s.at(ss - i - 1) ;
    count++;
    if (tmp == s1) {
      tmp = empty;
      count = 0;
    }
    else if (tmp == s2) {
      tmp = empty;
      count = 0;
    }
    else if (tmp == s3) {
      tmp = empty;
      count = 0;
    }
    else if (tmp == s4) {
      tmp = empty;
      count = 0;
    }
  }
  if (tmp == empty) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}
    
    
  

Measured memory_bytes: 640
#include <iostream>
using namespace std;
 
int main(){
  string S,T,U;
  int A,B;
  
  cin >> S >> T;
  cin >> A >> B;
  cin >> U;
  
  if (U == S) {
    cout << A-1 << " " << B << endl;
  }
  else if (U == T) {
    cout << A << " " << B-1 << endl;
  }
}


Measured memory_bytes: 3576
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
 
public class Main {
	
	public static void main(String[] args) throws Exception{	
		FastScanner sc = new FastScanner();
		int i, j;
			//code
		
		int n = sc.nextInt();
		int k = sc.nextInt();
		
		if(n <= 2){
			pl(0);
			return;
		}
		
		int c=0;
		int l = (n-2)%11;
		
		c = (n-2) / 11 * 5;
		
		for(i=1; i<=5; i++){
			long b = 9+9*i;
			for(j=1; j<=l; j++)
				if((b = b+63) % 11 == k)
					c++;
		}
		
		pl(c);
	
	}
	
	
	
	static void func(){
 
	}
	
	static void p(String s){ System.out.print(s); }
	static void pl(String s){ System.out.println(s); }
	static void p(int s){ System.out.print(s); }
	static void pl(int s){ System.out.println(s); }
	static void p(long s){ System.out.print(s); }
	static void pl(long s){ System.out.println(s); }
	static void p(double s){ System.out.print(s); }
	static void pl(double s){ System.out.println(s); }
	static void p(boolean s){ System.out.print(s); }
	static void pl(boolean s){ System.out.println(s); }
	
 
}
 
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

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

#define ll long long
#define ar array

void solve() {
	int n;
	cin >> n;
	string s;
	cin>>s;

	if(n>=s.length())
    {
        cout<<s<<endl;
    }

        else
    {
           for(int i=0;i<n;i++)
           {
               cout<<s[i];
           }
           cout<<"..."<<endl;

    }
}

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

	int t;
	//cin >> t;
	//while(t--)
		solve();
}


Measured memory_bytes: 3620
import math

K = int(input())

gcd = [[[0]* K for _ in range(K)] for _ in range(K)]

ans = 0
for a in range(K):
    for b in range(K):
        for c in range(K):
            if gcd[a][b][c] == 0:
                res = math.gcd(math.gcd(a+1,b+1),c+1)
                gcd[a][b][c] = res
                gcd[b][c][a] = res
                gcd[c][a][b] = res
                gcd[b][a][c] = res
                gcd[c][b][a] = res
                gcd[a][c][b] = res
                ans += res
            else:
                ans += gcd[a][b][c]

print(ans)

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

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = Integer.parseInt(in.next());
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(in.next());
		}
		
		Arrays.sort(a);
		int min = a[0];
		int max = a[n - 1];
		long total = 0;
		for (int x : a) {
			total += (long)x;
		}
		
		System.out.println(min + " " + max + " " + total);
	}
}	


Measured memory_bytes: 40560
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
struct uf {
	int siz;
	vector<int> r, p;
	uf(){};
	uf(int n):siz(n), r(n, 1), p(n, 0) {
		iota(p.begin(), p.end(), 0);
	}
	int root(int x) {
		return x == p[x] ? x : p[x] = root(p[x]);
	}
	void unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y) return;
		siz--;
		if (r[x] < r[y]) swap(x, y);
		r[x] += r[y];
		p[y] = x;
	}
};
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector<vector<int>> l(m);
	for (int i = 0; i < n; i++) {
		int k;
		cin >> k;
		for (int j = 0; j < k; j++) {
			int x;
			cin >> x;
			x--;
			l[x].push_back(i);
		}
	}
	uf u(n);
	for (int i = 0; i < m; i++) {
		for (int j = 1; j < (int) l[i].size(); j++) {
			u.unite(l[i][j], l[i][j - 1]);
		}
	}
	cout << (u.siz == 1 ? "YES\n" : "NO\n");
	return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl;
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int a, b, count = 0;
    char c;
    int sum = 0;
    double ave = 0;
    while (cin >> a >> c >> b)
    {
        sum += a * b;
        ave += b;
        count++;
    }

    OP(sum)
    OP(round(ave / count))

    return 0;
}


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

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

  vector<vector<ll>> A(3, vector<ll>(3, 0));
  for (ll i = 0; i < 3; i++) {
    for (ll j = 0; j < 3; j++) {
      cin >> A[i][j];
    }
  }
  ll N; cin >> N;
  for (ll k = 0; k < N; k++) {
    ll temp; cin >> temp;
    for (ll i = 0; i < 3; i++) {
      for (ll j = 0; j < 3; j++) {
        if (A[i][j] == temp) {
          A[i][j] = 0;
        }
      }
    }
  }

  string ans = "No";
  for (ll i = 0; i < 3; i++) {
    if (A[0][i] == 0 && A[1][i] == 0 && A[2][i] == 0) ans ="Yes";
    if (A[i][0] == 0 && A[i][1] == 0 && A[i][2] == 0) ans ="Yes";
  }
  if (A[0][0] == 0 && A[1][1] == 0 && A[2][2] == 0) ans ="Yes";
  if (A[2][0] == 0 && A[1][1] == 0 && A[0][2] == 0) ans ="Yes";
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<queue>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAXN 500010
int a[MAXN],n,k,ans[MAXN];
int t[MAXN*4];
int Query(int i,int l,int r,int L,int R)
{
	if(L>R) return t[0];
	if(L<=l&&r<=R) return t[i];
	int mid=(l+r)/2;
	if(R<=mid) return Query(i<<1,l,mid,L,R);
	if(L>mid) return Query(i<<1|1,mid+1,r,L,R);
	return min(Query(i<<1,l,mid,L,R),Query(i<<1|1,mid+1,r,L,R));
}
void Change(int i,int l,int r,int p,int w)
{
	if(l==r)
	{
		t[i]=w;
		return;
	}
	int mid=(l+r)/2;
	if(p<=mid) Change(i<<1,l,mid,p,w);
	else Change(i<<1|1,mid+1,r,p,w);
	t[i]=min(t[i<<1|1],t[i<<1]);
}
int Adj[MAXN],V[MAXN*2],nxt[MAXN*2],c,d[MAXN];
void AddEdge(int u,int v)
{
	d[v]++;c++;V[c]=v,nxt[c]=Adj[u];Adj[u]=c;
}
priority_queue<int ,vector<int>,greater<int> >Q;
void TopSort()
{
	for(int i=1;i<=n;i++) if(!d[i]) Q.push(i);
	int tot=0;
	while(!Q.empty())
	{
		int u=Q.top();Q.pop();
		ans[u]=++tot;
		for(int i=Adj[u];i;i=nxt[i])
			if(!--d[V[i]])
				Q.push(V[i]);
	}
}
int main()
{
//	freopen("swap.in","r",stdin);
//	freopen("swap.out","w",stdout);
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		int x;
		scanf("%d",&x);
		a[x]=i;
	}
	if(k<=1)
	{
		for(int i=1;i<=n;i++)
			printf("%d\n",i);
		return 0;
	}
	memset(t,0x3f3f3f3f,sizeof t);
	for(int i=n;i;i--)
	{
		int x=Query(1,1,n,a[i]+1,min(a[i]+k-1,n));
		if(x<1e9) AddEdge(a[i],a[x]);
		x=Query(1,1,n,max(a[i]-k+1,1),a[i]-1);
		if(x<1e9) AddEdge(a[i],a[x]);
		Change(1,1,n,a[i],i);
	}
	TopSort();
	for(int i=1;i<=n;i++)
		printf("%d\n",ans[i]);
}

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

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    int N;
    cin >> N;

    multiset<int> mapA;
    for (int i = 0; i < N; i++) {
        int A;
        cin >> A;
        auto itr = mapA.lower_bound(A);
        if (itr != mapA.begin()) {
            --itr;
            mapA.erase(itr);
        }
        mapA.emplace(A);
    }

    cout << mapA.size() << endl;
    return 0;
}


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

int main()
{
    int n;
    cin >> n;
    int arr[n];
    for (int i = 0; i < n ; i++){
        cin >> arr[i];
    }
    sort(arr, arr+n);


        double temp = arr[0];
        for (int i = 1; i < n; i++){
            temp += arr[i];
            temp /= 2;
        }
        cout << temp;

    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 s = sc.nextInt();
        int k = s + 1000;
        k = k % 1000;
        System.out.println((1000 - k) % 1000);
    }
}


Measured memory_bytes: 35772