akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstring>

typedef long long ll;
constexpr double PI = 3.141592653589793;
constexpr ll INF = 1e18 + 10;
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;
}

using namespace std;
//    cout << setprecision(20) << ans << "\n";

vector<pair<ll, ll>> primeFactorize(ll N)
{
    vector<pair<ll, ll>> res;
    for (ll a = 2; a * a <= N; ++a)
    {
        if (N % a != 0)
            continue;
        ll ex = 0;

        while (N % a == 0)
        {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }

    if (N != 1)
        res.push_back({N, 1});
    return res;
}

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

    int n;
    cin >> n;
    int min = 40;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        int count = 0;
        while (a % 2 == 0)
        {
            count++;
            a /= 2;
        }
        if (min > count)
        {
            min = count;
        }
        if (min == 0)
        {
            break;
        }
    }
    cout << min << "\n";

    return 0;
}


Measured memory_bytes: 3628
def main():
    N, M = [int(i) for i in input().split()]
    A = [int(i) for i in input().split()]

    A.sort()


    bc = [[int(i) for i in input().split()] for _ in range(M)]
    bc.sort(key=lambda x: x[1])


    ai = N - 1
    mi = M - 1
    pos = 0
    ans = 0
    for _ in range(N):
        if (A[ai] > bc[mi][1]) | (mi < 0):
            pos += 1
            ans += A[ai]
            ai -= 1
        elif pos + bc[mi][0] >= N:
            ans += bc[mi][1] * (N - pos)
            break
        else:
            ans += bc[mi][0] * bc[mi][1]
            pos += bc[mi][0]
            mi -= 1
        if pos >= N:
            break

    print(ans)



if __name__ == "__main__":
    main()


Measured memory_bytes: 31072
#include <bits/stdc++.h>
 
using std::pair;
using std::vector;
using std::string;

typedef long long ll;
typedef pair<int, int> pii;
 
#define fst first
#define snd second
#define pb(a) push_back(a)
#define mp(a, b) std::make_pair(a, b)
#define debug(...) fprintf(stderr, __VA_ARGS__)
 
template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }
 
const int oo = 0x3f3f3f3f;
 
template<typename T> T read(T& x) {
    int f = 1; x = 0;
    char ch = getchar();
    for(;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48; 
    return x *= f;
}

int n, t, x, y, la, lb;

int main() {
#ifdef Wearry
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif 

    read(n);
    for(int i = 1; i <= n; ++i) {
        read(t); read(x), read(y);

        int a = x + y, b = x - y;

        if((a&1) == (t&1) && (b&1) == (t&1)) {}
        else return !puts("No");

        a = (a + t) >> 1;
        b = (b + t) >> 1;

        if(a <= t && a >= la && b <= t && b >= lb) {
            la = a, lb = b;
        }
        else return !puts("No");
    }
    puts("Yes");

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s,t;
bool flag=false;
int main(){
 cin>>s>>t;
 for(int i=0;i<s.size();i++){
    if(s[i]!=t[i]){
        flag=true;
        break;
    }
}
if(flag==true)cout<<"No";
else cout<<"Yes";


    return 0;}




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

int main() {
    int N, A, B; cin >> N >> A >> B;
    int ans = 0;
    for (int i = 1; i <= N; i++) {
        string s = to_string(i);
        int t = 0;
        for (int j = 0; j < s.length(); j++) {
            t += s[j]-'0';
        }
        if (A <= t && t <= B) ans += i;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>
int a[100005];

int main(){
    int n;
    scanf("%d",&n);
    for(int i = 1; i <= n; i++) scanf("%d",&a[i]);
    int p = 1, ans = 0;
    while(p<=n){
        if(a[p]!=p) p++;
        else{
            int np = p;
            while(np+1<=n && a[np+1]==np+1) np++;
            int len = np-p+1;
            ans += len/2+len%2;
            p = np+1;
        }
    }
    printf("%d\n",ans);
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using v = vector<T>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
void dump_debug(T list) {
#ifdef MY_DEBUG
    each(e, list) cout << e << " ";
    printf("\n");
#endif
}

inline ll inl() {
    ll x;
    cin >> x;
    return x;
}

inline string ins() {
    string x;
    cin >> x;
    return x;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        string s = ins();
        ll n = s.size();

        ump<char, ll> mp;
        rep(i, n) {
            mp[s[i]]++;
        }
        each(e, mp) {
            if (e.S > 1) {
                cout << "no" << endl;
                return 0;
            }
        }
        cout << "yes" << endl;
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';

int gcd(int a,int b) {
    while (b) {
        a %= b;
        swap(a,b);
    }
    return a;
}

int main() {
    int n,k;
    cin >> n >> k;
    int g = 0;
    vector<int> a(n);
    for (int i = 0;i < n;++i) cin >> a[i];
    for (int i = 0;i < n;++i) g = gcd(a[i],g);
    bool ans = false;
    for (int i = 0;i < n;++i) if (a[i] >= k && (a[i]-k)%g == 0) ans = true;
    cout << (ans ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/5

int n,m,r;
int dl[222][222];
int ds[222][222];
int dp[1111][222];
int rs[1111];

int main(){
	cin.sync_with_stdio(false);
  while(1){
    cin>>n>>m;
    if(n==0)break;
    rep(i,222)rep(j,222){
      dl[i][j]=i==j?0:INF;
      ds[i][j]=i==j?0:INF;
    }
    rep(i,1111)rep(j,222)dp[i][j]=INF;
    rep(i,m){
      int x,y,t; string sl;
      cin>>x>>y>>t>>sl; x--; y--;
      if(sl=="L"){
        dl[x][y]=dl[y][x]=t;
      }else{
        ds[x][y]=ds[y][x]=t;
      }
    }
    rep(k,n)rep(i,n)rep(j,n){
      minch(dl[i][j],dl[i][k]+dl[k][j]);
      minch(ds[i][j],ds[i][k]+ds[k][j]);
    }
    cin>>r;
    rep(i,r){
      cin>>rs[i];
      rs[i]--;
    }
    dp[0][rs[0]]=0;
    rep(i,r-1){
      int crt=rs[i],nxt=rs[i+1];
      rep(j,n){
        minch(dp[i+1][j],dp[i][j]+dl[crt][nxt]);
        if(crt==j){
          rep(k,n)minch(dp[i+1][k],dp[i][j]+ds[crt][k]+dl[k][nxt]);
        }
        rep(k,n)minch(dp[i+1][k],dp[i][j]+dl[crt][j]+ds[j][k]+dl[k][nxt]);
      }
    }
    int res=INF;
    rep(j,n)minch(res,dp[r-1][j]);
    cout<<res<<endl;
  }
	return 0;
}

Measured memory_bytes: 4340
#include<bits/stdc++.h>
#define endl '\n'
#define fastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
using namespace std;

int gcd(int a, int b){
    return b == 0 ? a : gcd(b, a%b);
}
int lcm(int a, int b){
    return (a*b)/gcd(a,b);
}
int ncr(int n, int k){
    int res = 1;
    if ( k > n - k )
        k = n - k;

    for (int i = 0; i < k; ++i){
        res *= (n - i);
        res /= (i + 1);
    }
    return res;
}

int fibonacci(int n){
    double phi = (1 + sqrt(5))/(double)2;
    int nth_fib = round(pow(phi,n)/sqrt(5));
    return nth_fib;
}
signed main(){

#ifndef ONLINE_JUDGE
   // freopen("input.txt","r", stdin);
#endif

    fastIO
    int n;
    cin >> n;
    int temp,minimum;
    cin >> temp;
    minimum = temp;
    int count = 1;
    for(int i = 1; i < n; i++){
        cin >> temp;
        if(temp < minimum) {
            minimum = temp;
            count++;
        }
    }
    cout << count;


    return 0;
}


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

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

Measured memory_bytes: 4852
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
#include <cassert>
#define int int64_t
using namespace std;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;

vi oddplus;
vi evenplus;

signed main() {
    int n;
    cin >> n;
    vi as;
    int m = -1e18, mi = -1;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        as.push_back(a);
        if (i % 2 && a >= 0) {
            oddplus.push_back(i);
        }
        if (i % 2 == 0 && a >= 0) {
            evenplus.push_back(i);
        }
        if (a > m) {
            m = a;
            mi = i;
        }
    }
    
    if (oddplus.empty() && evenplus.empty()) {
        cout << m << endl;
        cout << n - 1 << endl;
        for (int i = n; i >= mi + 2; i--) {
            cout << i << endl;
        }
        for (int i = 0; i < mi; i++) {
            cout << 1 << endl;
        }
        return 0;
    }
    
    int oddsum = 0, evensum = 0;
    for (int i: oddplus) oddsum += as[i];
    for (int i: evenplus) evensum += as[i];
    
    vi ans;
    cout << max(oddsum, evensum) << endl;
    if (oddsum > evensum) {
        for (int i = n; i >= oddplus.back() + 2; i--) {
            ans.push_back(i);
        }
        for (int i = 0; i < oddplus.front(); i++) {
            ans.push_back(1);
        }
        for (int i = 1; i < oddplus.size(); i++) {
            for (int j = 0; j < (oddplus[i] - oddplus[i - 1]) / 2 - 1; j++) {
                ans.push_back(3);
            }
            ans.push_back(2);
        }
    } else {
        for (int i = n; i >= evenplus.back() + 2; i--) {
            ans.push_back(i);
        }
        for (int i = 0; i < evenplus.front(); i++) {
            ans.push_back(1);
        }
        for (int i = 1; i < evenplus.size(); i++) {
            for (int j = 0; j < (evenplus[i] - evenplus[i - 1]) / 2 - 1; j++) {
                ans.push_back(3);
            }
            ans.push_back(2);
        }
    }
    cout << ans.size() << endl;
    for (int i: ans) {
        cout << i << endl;
    }
}


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

using namespace std;

const int MAXN = 100005;
const int LOG = 20;

int n, len, q;
int a[MAXN];
int par[LOG][MAXN];
set <int> st;
map <int, int> mp;

void gen () {
    for (int i=n; i>=1; i--) {
        auto it = st.upper_bound(a[i] + len);
        if (it == st.begin()) {
            st.insert(a[i]);
            continue;
        }
        it--;
        par[0][i] = mp[*it];
        st.insert(a[i]);
    }
    for (int i=1; i<LOG; i++) {
        for (int j=1; j<=n; j++) {
            par[i][j] = par[i-1][par[i-1][j]];
        }
    }
}

int kth (int x, int k) {
    int pot = 0;
    while (k > 0) {
        if (k & 1) x = par[pot][x];
        pot++;
        k /= 2;
    }
    if (x == 0) return n + 1;
    return x;
}

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for (int i=1; i<=n; i++) {
        cin >> a[i];
        mp[a[i]] = i;
    }
    cin >> len;
    gen();
    cin >> q;
    for (int i=0; i<q; i++) {
        int a, b;
        cin >> a >> b;
        if (a > b) swap(a, b);
        int low = 1, high = n;
        while (low < high) {
            int mid = (low + high) / 2;
            if (kth(a, mid) >= b) {
                high = mid;
            } else {
                low = mid + 1;
            }
        }
        cout << low << '\n';
    }
    return 0;
}


Measured memory_bytes: 18432
#include<cstdio>
#include<cstring>
#include<map>
#include<algorithm>
using namespace std;
map<long long int, int> mp;
long long int rem[100100];
int cnt;
int main(){
    int n,x;
    scanf("%d",&n);
    for(int i = 1; i <= n; i ++){
        scanf("%lld",&x);
        if(!mp[x])
            rem[++cnt] = x;
        mp[x] ++;
    }
    long long int a = 0, ans = 0;
    sort(rem+1, rem+1+cnt);
    for(int i = cnt; i >= 1; i --){
        if(mp[rem[i]] > 1 && a){
            ans = rem[i] * a;
            break;
        }
        else if(mp[rem[i]] >= 4){
            ans = rem[i] * rem[i];
            break;
        }
        
        else if(mp[rem[i]] > 1){
            a = rem[i];
            continue;
        }
    }
    printf("%lld",ans);
    return 0;
}

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

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

using namespace std;

typedef long long int lli;

int main () {
    int N;
    string s;
    cin >> N;
    cin >> s;
    vector<int> r(N);
    vector<int> ans;
    bool isAns = false;
    REP (i, 0, N) r[i] = (s[i] == 'o' ? 1 : -1);
    REP (i, 0, 2) {
        REP (j, 0, 2) {
            vector<int> v(N);
            v[0] = (i == 0 ? 1 : -1);
            v[N - 1] = (j == 0 ? 1 : -1);
            REP (k, 0, N - 2) {
                v[k + 1] = r[k] * v[k] * v[(k - 1 + N) % N];
            }
            int check1 = r[N - 2] * v[N - 2] * v[N - 3];
            int check2 = r[N - 1] * v[N - 1] * v[N - 2];
            if (check1 == v[N - 1] && check2 == v[0]) {
                ans = v;
                isAns = true;
                break;
            }
        }
        if (isAns) break;
    }

    if (isAns) {
        REP (i, 0, N) {
            cout << (ans[i] == 1 ? 'S' : 'W');
        }
        cout << endl;
    } else {
        cout << -1 << endl;
    }

    return 0;
}


Measured memory_bytes: 1784
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
	ll N,D,A;
	cin >> N >> D >> A;
	ll i;
	queue< pair<ll,ll> > que;
	ll X,H;
	pair <ll , ll > enemy[N];
	ll tmp=0;
	ll ans=0;
	ll num;
	for(i=0;i<N;i++){
		cin >> X >>H;
		enemy[i]=make_pair(X,H);
	}
	sort(enemy,enemy+N);
	for(i=0;i<N;i++){
		while(!que.empty() && que.front().first < enemy[i].first){
			tmp-=que.front().second;
			que.pop();
		}
		if(enemy[i].second-tmp>0)num=(enemy[i].second-tmp-1)/A+1;else num=0;
		que.push(make_pair(enemy[i].first+2*D,num*A));
		tmp+=num*A;
		ans+=num;
	}
	cout << ans;
    return 0;
}


Measured memory_bytes: 6656
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 1LL << 60;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


// 入力
int N;
ll a[100010], b[100010], c[100010];

// DP テーブル
ll dp[100010][3];

int main() {
    int N; cin >> N;
    rep1(i, N) cin >> a[i] >> b[i] >> c[i];

    // 初期化 (最小化問題なので INF に初期化)
    rep1(i, 100010){
        rep1(j,3) dp[i][j] = 0;
    }
    // ループ
    rep1(i, N) {
        chmax(dp[i+1][0], dp[i][1] + a[i]);
        chmax(dp[i+1][0], dp[i][2] + a[i]);
        chmax(dp[i+1][1], dp[i][0] + b[i]);
        chmax(dp[i+1][1], dp[i][2] + b[i]);
        chmax(dp[i+1][2], dp[i][0] + c[i]);
        chmax(dp[i+1][2], dp[i][1] + c[i]);
    }
    ll ans = 0;
    rep1(i,3) chmax(ans, dp[N][i]);
    // 答え
    cout << ans << endl;
}


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

using namespace std;

#define FOR(i,l,r) for( int i = l; i < r; i++ )
#define vi vector<int>
#define pb push_back
#define li long long int
#define st string

int mod = 1e9+7;

void addMod( li & a, li b ) {
    a = (a+b);
    while( a >= mod ) a -= mod;
}

int main() {
    st s; cin>>s;
    int d; cin>>d;
    li dp[s.length()+2][d+2][10];
    FOR(i,0,s.length()+2) FOR(j,0,d+2) FOR(k,0,10) dp[i][j][k] = 0;
    FOR(i,0,10) addMod(dp[1][i%d][i],1);
    FOR(i,2,s.length()+2) {
        FOR(j,0,10) {
            FOR(k,0,d) {
                FOR(h,0,10) addMod(dp[i][(j+k)%d][j],dp[i-1][k][h]);
            }
        }
    }
    int dig = s.length();
    li ans = 0;
    li accum = 0;
    FOR(i,0,dig) {
        int num = s[i]-'0';
        FOR(k,0,num) addMod(ans,dp[dig-i][(d-accum)%d][k]);
        accum = (accum+num)%d;
    }
    if( accum%d == 0 ) ans++; 
    cout<<(ans-1+mod)%mod<<"\n";
    return 0;
}

Measured memory_bytes: 80000
#include<iostream>
#include<vector>
#include <cstdlib> 
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<long long> a(n);
    long long sm=0;
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    for(int i=0; i<n; i++){
        if(i>=1){
            long long dis = a[i] - a[i-1];
            if(dis < 0){
                sm = sm +  abs(dis);
                a[i] = a[i] + abs(dis);
                //cout << "dis=" <<dis;
            }
        }
        //cout << a[i] << " ";
    }
    cout << sm << endl;
    

}



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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

void Main(){
    ll n, d;
    cin >> n >> d;
    ll ans = 0;
    REP(i, n) {
        ll x, y;
        cin >> x >> y;
        if (x * x + y * y <= d * d) {
            ans++;
        }
    }
    cout << ans << en;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}


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

int main(void){
  int N;
  cin>>N;
  string S,T;
  cin>>S>>T;
  vector<char> ans;
  for(int i=0;i<N;i++){
    ans.push_back(S[i]);
    ans.push_back(T[i]);
  }
  for(int i=0;i<ans.size();i++){
    cout<<ans[i];
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vll vector<ll>
#define vvll vecror<vector<ll>> 
#define sz size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll fact(ll n){ll s=1; for(ll i=1;i<=n;i++)s*=i; return s;}
ll ceil1(ll n,ll m){if(n%m==0){return n/m;}return n/m +1;}
vll factor(ll n){
    vll ans;
    if(n>0)ans.pb(1);if(n==2)ans.pb(2);
    for(ll i=2;i*i<=n;i++){if(n%i==0){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}if(n>2)ans.pb(n);
    return ans;
}
 
 
 

void solve()
{
	ll n,x,y;
	
	cin>>n>>x>>y;
	
	vll ans(n,0);
	
	for(ll i=1;i<=n;i++)
	{
		for(ll j=i+1;j<=n;j++)
		{
			ll mi = min(j-i,abs(y-j)+1+abs(x-i));
			
			ans[mi]++;
		}
	}
	
	for(ll i=1;i<n;i++)
	{
		cout<<ans[i]<<endl;
	}
}
 
int main()
{
    ll q;
    q=1;
    // cin>>q;
    while(q--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
typedef long long ll;

int main() {
    int N,A,B;
    cin >> N;
    cin >> A;
    cin >> B;
    cout << min(A*N,B) << endl;

    return 0;
}


Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.range, std.algorithm, std.array, std.functional;

void main() {
  auto s = readln.chomp;
  auto t = readln.chomp;

  auto idx = new ulong[][256];
  foreach(i, c; s) {
    idx[c] ~= 1 + i;
  }

  long f() {
    ulong l,j;
    foreach(c; t) {
      if(idx[c].length == 0) return -1;
      auto a = assumeSorted(idx[c]).upperBound(j);
      if(!a.empty) {
        j = a.front;
      } else {
        l++;
        j = idx[c].front;
      }
    }
    return l * s.length + j;
  }

  f().writeln;
}


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

int H, W, N;

int main() {
    cin >> H >> W >> N;
    vector<vector<int>> c(H, vector<int>(W));
    int sum = 0;
    for (int i = 0; i < N; i++) {
        int a; cin >> a;
        for (int j = 0; j < a; j++) {
            int w = sum / H;
            int h = (w & 1? H - sum % H - 1: sum % H);
            c[h][w] = i + 1;
         	sum++;
        }
    }
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cout << c[i][j] << " ";
        }
        cout << endl;
    }
}




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

#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 foreach(it, v) for(typeof(v.begin()) it=v.begin(); it!=v.end(); ++it)
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second

typedef unsigned int uint;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef set<int> si;

int  N, M;
int A, B;

vi nexts[100010];
bool checked[100010];
bool fin[100010];

bool f(int n, int bef) {
  int cnt = 0;
  for (const auto& e : nexts[n]) {
    if (fin[e]) continue;
    if (!checked[e]) {
      checked[e] = true;
      if (f(e, n)) {
        cout << n << " " << e << "\n";
        cnt++;
      } else {
        cout << e << " " << n << "\n";
      }
      fin[e] = true;
    } else if (e!=bef) {
      cout << n << " " << e << "\n";
      cnt++;
    }
  }
  return (cnt%2==0);
}

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

  cin >> N >> M;
  rep(i,M) {
    cin >> A >> B;
    nexts[A].pb(B);
    nexts[B].pb(A);
  }
  if (M%2) {
    cout << "-1\n";
    return 0;
  }
  checked[1] = true;
  f(1,0);
  return 0;
}


Measured memory_bytes: 14848
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ull = long long unsigned;
using P = pair<int,int>;
const int INF=1001001;
const int NMAX=8;
const int mod = 1000000007;


int main()
{
	int n;
	cin>>n;
	vector<int>a(n);
	vector<int>m(n);
	rep(i,n)cin>>a[i];
	int m0=0;
	rep(i,n){
		if (i%2==0)m0+=a[i];
		else m0-=a[i];
	}
	m[0]=m0;
	rep(i,n-1){
		m[i+1]=2*a[i]-m[i];
	}
	rep(i,n){
		cout<<m[i]<<' ';
	}

}


Measured memory_bytes: 2048
#include<stdio.h>

int main(){
  int H,W,i,j;
 
  while( scanf("%d %d",&H,&W),!(H==0&&W==0)){
    for(i=0;i<H;i++){
      for(j=0;j<W;j++){
	printf("#");
      }
      printf("\n");
    }
    printf("\n");
  }
      
  return 0;
}

Measured memory_bytes: 572
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]
t = [int(input()) - 1 for _ in range(D)]

N = 26
scores = [0] * N
last = [-1] * N
ans = []
for d in range(D):
    last[t[d]] = d
    scores[t[d]] += s[d][t[d]]

    for i in range(N):
        if last[t[d]] != -1:
            scores[i] -= c[i] * (d - last[i])
    ans.append(sum(scores))

print(*ans, sep="\n")


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

using namespace std;

struct UF
{
	vector<int> par; // 親のインデックスを記憶する配列
	vector<int> sz; // サイズを記憶する。
	vector<int> rank;
	// 初期化
	UF(int n):par(n),sz(n),rank(n){
		for(int i = 0; i < n; i++){
			par[i] = i;sz[i] = 1;rank[i] = 0;
		}
	}
	// 親を求める
	int find(int x) {
		if (par[x] == x) return x;
		else return par[x] = find(par[x]);
	}
	// xとyの属する集合を併合
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y) return;
		if(rank[x] < rank[y]){
			par[x] = y;
			sz[y] += sz[x];
		}
		else{
			par[y] = x;
			sz[x] += sz[y];
			if(rank[x] == rank[y])rank[x]++;
		}
	}
	// xとyが同じ集合ならtrue
	bool same(int x, int y) { return find(x) == find(y); }
	// 素の集合のサイズを求める
	int size(int n){return sz[find(n)];}
};


int main()
{
  int N,M;

  cin >> N >> M;

  vector<int> v(N);

  UF uf(N);

  for(int i = 0;i < N;i++){
    cin >> v[i];v[i]--;
  }

  for(int i = 0;i < M;i++){
    int x,y;
    cin >> x >> y;
    x--; y--;
    uf.unite(x,y);
  }

  int ans = 0;

  for(int i = 0;i < N;i++){
    if(uf.same(i,v[i]))
       ans++;
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;
 
#define MAX_M 20
#define MAX_N 50000
#define INF 100000000

int n, m;
vector<int> c(MAX_M, 0);        //要素数MAX_M, すべての要素の値0
vector<int> dp(MAX_N + 1, INF); //要素数MAX_N+1, すべての要素の値INF
                                //※dp(INF) なら要素数INFの宣言
void solve() {
    dp[0] = 0;
    for(int i = 1; i <= n; i++) {
        for(int j = 0; j < m; j++) {
            if(i - c[j] >= 0) {
                if(dp[i] > dp[i - c[j]] + 1) {
                    dp[i] = dp[i - c[j]] + 1;
                }
            }
        }
    }
    printf("%d\n", dp[n]);
}

int main() {
    cin >> n >> m;
    for(int i = 0; i < m; i++) cin >> c[i];
    solve();
}


Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);


int main()
{
	

	fastio;
	ll t,n,m;
	cin>>n;
	if(n%1000!=0)
	cout<<1000-n%1000;
	else
	 cout<<0;
	
	
	return 0;
		

		
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using i64 = int_fast64_t;
#define repeat(i, a, b) for(int i = (a); (i) < (b); ++(i))
#define rep(i, n) repeat(i, 0, n)

void solve() {
    std::string s;
    std::cin >> s;
    std::map<char, int> mp;
    mp['a'] = 0, mp['b'] = 1, mp['c'] = 2;
    std::vector<int> sv(3);
    rep(i, s.size()) sv[mp[s[i]]]++;
    sort(begin(sv), end(sv));
    sv[2] -= sv[0], sv[1] -= sv[0], sv[0] = 0;
    if(sv[2] >= 2) {
        std::cout << "NO" << std::endl;
    } else {
        std::cout << "YES" << std::endl;
    }
}

int main() {
    // std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    solve();
    return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <algorithm>
#include <cstring> 

using namespace std;

int a[10100], lst[10100], cnt[10100], b[10100];
struct xxx{int id, x;}d[10100];

bool cmp(xxx a, xxx b) {return a.x < b.x;}

int main()
{
	int n, k, q; scanf("%d%d%d", &n, &k, &q);
	for(int i = 1; i <= n; i++)
	{
		scanf("%d", &a[i]); b[i] = a[i];
		d[i].id = i; d[i].x = a[i];
	}
	sort(d + 1, d + n + 1, cmp);
	sort(a + 1, a + n + 1); int N = unique(a + 1, a + n + 1) - a - 1;
	int ans = 2e9;
	for(int i = 0; i <= N; i++)
	{
		memset(cnt, 0, sizeof(cnt));
		for(int j = 1; j <= n; j++)
		{
			if(b[j] <= a[i]) lst[j] = j;
			else lst[j] = lst[j - 1];
			if(lst[j] != j) cnt[lst[j]]++;
		}
		int o = 0, Max = 0;
		for(int j = 1; j <= n; j++)
		{
			if(d[j].x > a[i] && cnt[lst[d[j].id]] - k + 1 > 0)
			{
				cnt[lst[d[j].id]]--;
				Max = max(Max, d[j].x);
				o++;
				if(o == q) break;
			}
		}
		if(o == q) ans = min(ans, Max - a[i + 1]);
	}
	printf("%d\n", ans);
	return 0;
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

struct Node
{
    int in = 0;
    vector<int> next;
    ll length = 0;
};

bool S[100005];
Node V[100005];

int main()
{
    int N, M;
    cin >> N >> M;
    REP(i, M)
    {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        V[x].next.push_back(y);
        V[y].in++;
        S[y] = true;
    }

    //priority_queue<Node, vector<Node>, function<bool(Node, Node)>> q([](Node a, Node b) { return a.length < b.length; });
    queue<Node> q;
    REP(i, N)
    {
        if (S[i])
            continue;
        q.push(V[i]);
    }

    while (!q.empty())
    {
        Node n = q.front();
        q.pop();
        REP(i, n.next.size())
        {
            if (--V[n.next[i]].in > 0)
                continue;
            if (V[n.next[i]].length >= n.length + 1)
                continue;
            V[n.next[i]].length = n.length + 1;
            q.push(V[n.next[i]]);
        }
    }
    ll max = 0;
    REP(i, N)
    {
        max = std::max(max, V[i].length);
    }
    cout << max << endl;
    return 0;
}

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

int main(){
  int a, b;
  int c = 0;
  
  cin >> a >> b;
  
  if(a > b){
    c += a;
    a--;
  }
  else{
    c += b;
    b--;
  }
  if(a > b){
      c += a;
      a--;
  }
  else{
    c += b;
    b--;
  }
  
  cout << c << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int N;
  scanf("%d", &N);
  
  if (N == 1) {
    printf("Hello World");
  } else {
    int A, B;
    scanf("%d", &A);
    scanf("%d", &B);
    printf("%d", A + B);
  }
  
  return 0;
}

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

int main() {
	int n; cin >> n;
	vector<int>s, p(n), q(n);
	for (int i = 1; i <= n; i++)s.push_back(i);
	for (auto&& x : p)cin >> x;for (auto&& x : q)cin >> x;
	int pcnt = 0, qcnt = 0, cnt = 0;
	do {
		bool pok = true, qok = true;
		for (int i = 0; i < n; i++) {
			if (s[i] != p[i])pok = false;
			if (s[i] != q[i])qok = false;
		}
		if (pok)pcnt = cnt + 1;
		if (qok)qcnt = cnt + 1;
		cnt++;
	} while (next_permutation(s.begin(),s.end()));
	cout << abs(pcnt - qcnt) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int A,B;
  cin>>A>>B;
  if(A==B)
    cout<<A+B;
  else
  if(A<B){
      B+=(B-1);
      cout<<B;}
  else
  {
    A+=(A-1);
   cout<<A;
  }
 return 0;
}

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

int main(){
    int N,K,ans=0;
    cin >> N >> K;
    int h[100000];
    for (int i = 0; i < N; i++)
    {
        cin >> h[i];
        if (h[i] >= K) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm> 
#include <cmath>
#include <cstdlib>
using namespace std;
#define ll long long 
#define gc getchar_unlocked
const int MOD = 1000000007;
const int MAXN = 1e5 + 10;
const int INF = 2*1e9;

int dp[MAXN],N,K,h[MAXN];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
	cin>>N;
	K = 2;
	for(int i = 1;i<=N;i++)
	{
		cin>>h[i];
	}
	for(int i = 2;i<=N;i++)
	{
		dp[i] = INF;
		for(int j = i-1;j>=max(i - K,1);j--)
		{
			dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]) );
		}
	}
	cout<<dp[N]<<"\n";
}

Measured memory_bytes: 4392
import java.util.*;

public class Main {
    public static void main(String[] args){
        //ArrayList<Integer> array = new ArrayList<Integer>();
        Scanner sc = new Scanner(System.in);
        while(true){
            int H = sc.nextInt();
            int W = sc.nextInt();
            if(H==0 && W==0){
                break;
            }
            for(int i=0;i<H;i++){
                for(int j=0;j<W;j++){
                    if(i == 0 || i == H-1 || j == 0 || j == W-1){
                        System.out.print("#");
                    }else{
                        System.out.print(".");
                    }
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}



Measured memory_bytes: 34228
#include <stdio.h>
#define MAX 100
#define INFTY 200000
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[MAX][MAX];

void dijkstra(void);

int main(){
  int i, j, u, k, v, c;

  scanf("%d", &n);
  for(i = 0;i < n;i++){
    for(j = 0;j < n;j++){
      M[i][j] = INFTY;
    }
  }
  for(i = 0;i < n;i++){
    scanf("%d%d", &u, &k);
    for(j = 0;j < k;j++){
      scanf("%d%d", &v, &c);
      M[u][v] = c;
    }
  }
  dijkstra();
  return 0;
}

void dijkstra(){
  int i, u, v, minv, d[MAX], color[MAX];

  for(i = 0;i < n;i++){
    d[i] = INFTY;
    color[i] = WHITE;
  }
  d[0] = 0;
  color[0] = GRAY;
  while(1){
    minv = INFTY;
    u = -1;
    for(i = 0;i < n;i++){
      if(minv > d[i] && color[i] != BLACK){
	u = i;
	minv = d[i];
      }
    }
    if(u == -1) break;
    color[u] = BLACK;
    for(v = 0;v < n;v++){
      if(color[v] != BLACK && M[u][v] != INFTY){
	if(d[v] > d[u] + M[u][v]){
	  d[v] = d[u] + M[u][v];
	  color[v] = GRAY;
	}
      }
    }
  }
  for(i = 0;i < n;i++){
    printf("%d ", i);
    if(d[i] == INFTY){
      printf("-1\n");
    }
    else printf("%d\n", d[i]);
  }
}

Measured memory_bytes: 636
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
s=sum(a)
for i in range(n):
    if a[i]>b[i]:a[i]-=b[i]
    else: a[i+1]=max(a[i+1]-b[i]+a[i],0);a[i]=0
print(s-sum(a))

Measured memory_bytes: 19244
#include <stdio.h>
#include <stdlib.h>
#define VMAX 10000

int main(){

  unsigned short *A, *B;

  int C[10001];

  int n,i,j;

  scanf("%d",&n);


  A=malloc(sizeof(short)*n+1);
  B=malloc(sizeof(short)*n+1);

  for(i=0;i<=10000;i++) C[i]=0;

  for(i=0;i<n;i++){

    scanf("%hu", &A[i+1]);
    C[A[i+1]]++;

  }

  for(i=1;i<=10001;i++){

    C[i]+=C[i-1];
  }
  
  for(j=1;j<=n;j++){
    
    B[C[A[j]]]=A[j];
    C[A[j]]=C[A[j]]-1;
  }

  for(i=0;i<n-1;i++){

    printf("%d ",B[i+1]);
  }

  printf("%d\n",B[i+1]);

  return 0;
}

  



Measured memory_bytes: 9556
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = ll(1e9) + 1;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()

ll gcd(ll a,ll b){
    if(a < b)swap(a, b);
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n){
        t *= i;
        t %= mod;
    }
    return t;
}

ll power(ll a, ll b){
    a %= mod;
    if(b == 0){
        return 1;
    }
    ll ans = power(a, b / 2);
    ans = ans * ans % mod;
    if(b % 2 == 1){
        ans = ans * a % mod;
    }
    return ans;
}

ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    ll ans = 1;
    for(ll i = 0; i < b; i++) {
        ans *= (a - i);
        ans /= (i + 1);
        ans %= mod;
    }
    return ans;
}

int main(){
    string s;
    cin >> s;
    if(s[2] == s[3] &&s[4] == s[5])pf("Yes");
    else pf("No");
    return 0;
}



Measured memory_bytes: 256
from collections import defaultdict as dd
from collections import Counter
from pprint import pprint as pp

YN = {True: 'Yes', False: 'No'}
ri = lambda: int(input())
ria = lambda: list(map(int, input().split()))
rian = lambda n: [ria() for _ in range(n)]
rs = lambda: input()
rsa = lambda: input().split()
rsn = lambda n: [rs() for _ in range(n)]

N = ri()
S = input()
ret = 0

for i in range(1, len(S)):
  a, b = S[:i], S[i:]
  ret = max(ret, len(set(a) & set(b)))
print(ret)

Measured memory_bytes: 3820
program main
implicit none
integer :: i, j, l, p
integer :: n, m
integer , allocatable :: k(:), a(:), b(:)

read(*,*) n, m
allocate( k(n), a(m), b(m) )
a = 1
do i = 1, n
   read(*,*) k(i), b(1:k(i))
   do j = 1, m
      p = 0
      do l = 1, k(i)
         if( b(l) == j ) then
            p = 1
         end if
      end do
      if( p == 0 ) then
         a(j) = 0
      end if
   end do
end do
write(*,'(i0)') sum(a)
   

end program main


Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<cmath>
#include<map>
#include<functional>
#include<queue>
#include<set>
#include<stack>
#include<iomanip>
#include<algorithm>
#include<unordered_map>
#include <numeric>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(n);i++)
template<typename T =ll> using v = vector<T>;
template<typename T =ll> using vv = v<v<T>>;
template<typename T =ll,typename U =ll> using p = pair<T,U>;
template<typename T> T chmin(T &a,T b) {return a=min(a,b);}
template<typename T> T chmax(T &a,T b) {return a=max(a,b);}
const ll INF = (ll)1e9;
template <int MOD>
struct ModInt {
    using lint = long long;
    int val;

    // constructor
    ModInt(lint v = 0) : val(v % MOD) {
        if (val < 0) val += MOD;
    };

    // unary operator
    ModInt operator+() const { return ModInt(val); }
    ModInt operator-() const { return ModInt(MOD - val); }
    ModInt inv() const { return this->pow(MOD - 2); }

    // arithmetic
    ModInt operator+(const ModInt& x) const { return ModInt(*this) += x; }
    ModInt operator-(const ModInt& x) const { return ModInt(*this) -= x; }
    ModInt operator*(const ModInt& x) const { return ModInt(*this) *= x; }
    ModInt operator/(const ModInt& x) const { return ModInt(*this) /= x; }
    ModInt pow(lint n) const {
        auto x = ModInt(1);
        auto b = *this;
        while (n > 0) {
            if (n & 1) x *= b;
            n >>= 1;
            b *= b;
        }
        return x;
    }

    // compound assignment
    ModInt& operator+=(const ModInt& x) {
        if ((val += x.val) >= MOD) val -= MOD;
        return *this;
    }
    ModInt& operator-=(const ModInt& x) {
        if ((val -= x.val) < 0) val += MOD;
        return *this;
    }
    ModInt& operator*=(const ModInt& x) {
        val = lint(val) * x.val % MOD;
        return *this;
    }
    ModInt& operator/=(const ModInt& x) { return *this *= x.inv(); }

    // compare
    bool operator==(const ModInt& b) const { return val == b.val; }
    bool operator!=(const ModInt& b) const { return val != b.val; }

    // I/O
    friend std::istream& operator>>(std::istream& is, ModInt& x) noexcept { return is >> x.val; }
    friend std::ostream& operator<<(std::ostream& os, const ModInt& x) noexcept { return os << x.val; }
};

constexpr int MOD = 1e9 + 7;
using mint = ModInt<MOD>;

void a(){
    ll N; cin >> N;
    if(N%10==2||N%10==4||N%10==5||N%10==7||N%10==9) cout << "hon" << endl;
    else if(N%10==0||N%10==1||N%10==6||N%10==8)cout << "pon"<<endl;
    else cout << "bon"<<endl;
}
void b(){
    ll K; cin >> K;
    string S; cin >> S;
    if(S.size()<=K) cout << S << endl;
    else{
        rep(i,K) cout << S[i];
        cout << "..."<<endl;
    }
}

void c(){
}

void d(){
}
void e(){
}
void f(){}
int main(){
    b();
    return 0;
}


Measured memory_bytes: 3628
import sys


n = int(input())

def calc(data1, data2):
    term = len(data1)+1
    table = [0]*term

    for i, d2 in enumerate(data2):
        tmp_table = table[:]
        for j, d1 in enumerate(data1):
            if d1 == d2:
                table[j + 1] = tmp_table[j] + 1
            elif table[j+1] < table[j]:
                table[j + 1] = table[j]

    print(table[term-1])
    return 

for _ in range(n):
    data1 = sys.stdin.readline().rstrip()
    data2 = sys.stdin.readline().rstrip()
    calc(data1, data2)


Measured memory_bytes: 5632
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''
N = int(input())
x, y = [0] * N, [0] * N

for i in range(N):
	x[i], y[i] = map(int, input().split())

pq = []
m = 1

if N == 1:
	print(1)
else:	
	for i in range(N):
		for j in range(N):
			if i == j:
				continue
				
			p, q = x[j] - x[i], y[j] - y[i]
			pq.append([p, q])
			
	for i in range(len(pq) - 1):
		n = 1
		for j in range(i + 1, len(pq)):
			if pq[i] == pq[j]:
				n += 1
				
		if n > m:
			m = n
			
	cost = N - m
	print(cost)


Measured memory_bytes: 41196
nm = list(map(int, input().split()))
N = nm[0]
M = nm[1]

p = [0] * M
s = [0] * M
for i in range(M):
    ps = list(map(str, input().split()))
    p[i] = int(ps[0])
    s[i] = ps[1]

acc = [0] * N
for i in range(M):
    if s[i] == "AC":
        acc[p[i]-1] = 1

point = 0
for i in range(N):
    point = point + acc[i]

penalty = 0
pnc =[ [0] * N for i in range(2)]
for i in range(M):
    if s[i] == "WA" and pnc[1][p[i]-1] == 0:
        pnc[0][p[i]-1] = pnc[0][p[i]-1] + 1
    elif s[i] == "AC":
        pnc[1][p[i]-1] = 1

for i in range(N):
    if pnc[1][i] == 1:
        penalty = penalty + pnc[0][i]

print(str(point)+" "+str(penalty))

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

long long f(std::vector<std::vector<long long>>& ss, long long i) {
    if (i <= 0) return 1;
    else return ss[i][0] + ss[i][1];
}

int main() {
    long long h, w, k;
    const auto mod = 1000000007ll;
    std::cin >> h >> w >> k;
    if (w == 1) {
        std::cout << 1 << std::endl;
        return 0;
    }
    std::vector<std::vector<long long>> ss(w + 10, std::vector<long long>(2));
    ss[1][0] = 1;
    ss[1][1] = 1;
    for (int i = 2; i < w; i++) {
        ss[i][0] = (ss[i - 1][0] + ss[i - 1][1]) % mod;
        ss[i][1] = ss[i - 1][0];
    }

    std::vector<std::vector<long long>> sw(w + 10, std::vector<long long>(2));
    for (int i = 0; i < w; i++) {
        sw[i][0] = f(ss, i) * f(ss, w - 2 - i) % mod;
        sw[i][1] = f(ss, i - 1) * f(ss, w - 3 - i) % mod;
    }

    // for (int i = 0; i < w; i++) std::cout << sw[i][0] << " " << sw[i][1] << std::endl;

    std::vector<long long> dp(w + 10);
    auto tmp(dp);

    dp[0] = 1;
    auto t = (sw[0][0] + sw[0][1]) % mod;

    for (int i = 1; i <= h; i++) {
        tmp[0] = (sw[0][0] * dp[0] % mod + sw[0][1] * dp[1] % mod) % mod;
        tmp[w - 1] = (sw[w - 2][0] * dp[w - 1] % mod + sw[w - 2][1] * dp[w - 2] % mod) % mod;
        for (int j = 1; j < w - 1; j++) {
            tmp[j] = sw[j - 1][1] * dp[j - 1] % mod;
            tmp[j] += sw[j][1] * dp[j + 1] % mod;
            tmp[j] += (mod + t - sw[j - 1][1] - sw[j][1]) * dp[j] % mod;
            tmp[j] %= mod;
        }
        tmp.swap(dp);
    }

    std::cout << dp[k - 1] << std::endl;

    return 0;
}

Measured memory_bytes: 256
#ifdef _DEBUG
#include ".vscode/debug_print.hpp"
#else
#include <bits/stdc++.h>
#define debug(...)
#endif

using ll = long long;
using ld = long double;
using namespace std;
constexpr int INF32 = 1050000000;
constexpr long long INF64 = 4000000000000000000;
constexpr int MOD7 = 1000000007;
constexpr int MOD53 = 998244353;
constexpr long double PI = 3.14159265358979323846;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T>
void print(H &&head, T &&... args)
{
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T>
void print(std::vector<T> &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T>
void print(std::vector<std::vector<T>> &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        for (int j = 0; j < v[i].size(); j++)
        {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T>
void scan(H &&head, T &&... args)
{
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T>
void scan(std::vector<T> &v)
{
    for (auto &&i : v)
    {
        scan(i);
    }
}

void vprint() { std::cout << '\n'; }
template <class H, class... T>
void vprint(H &&head, T &&... args)
{
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << '\n';
    vprint(std::forward<T>(args)...);
}
template <class T>
void vprint(std::vector<T> &v)
{
    for (auto &&i : v)
    {
        std::cout << i << '\n';
    }
}

int main()
{
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    double N;
    scan(N);
    int ans = ceil((N / 2.0));
    print(ans);

    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 x = sc.nextInt();
		int a = sc.nextInt();
		if (x >= a) {
			System.out.println(10);
		} else {
			System.out.println(0);
		}
	}

}


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

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;

void solve()
{
  int n,m; cin>>n>>m;
  vector<vector<int>> s(m);
  for (int i=0; i<m; i++) {
    int k; cin>>k;
    for (int j=0; j<k; j++) {
      int ss; cin>>ss;
      s[i].push_back(ss);
    }
  }
  vector<int> p(m, 0);
  for (int i=0; i<m; i++) {
    cin>>p[i];
  }
  int ans=0;
  for (int i=0; i<pow(2,n); i++) {
    vector<int> pa(m, 0);
    for (int j=0; j<m; j++) {
      for (int l=0; l<(int)(s[j].size()); l++) {
        if ((i>>(s[j][l]-1))&1) pa[j] = (pa[j]+1)%2;
      }
    }
    if (pa == p) ans++;
  }
  cout << ans << endl;
}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>
using namespace std;
int a,b,c;
int main() 
{
	scanf("%d%d%d",&a,&b,&c);
	if(a+b<c-1)printf("%d\n",b+a+b+1);
	else printf("%d\n",b+c);
	return 0;
}

Measured memory_bytes: 128