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

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

typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second　   //pairの二つ目の要素

map<int,int> M;
int m,n;
vector<vector<int>> to(200005);
vector<int> y;

int main(){
    cin >>n>>m;
    y.resize(n+1, 0);
    rep(i,m){
        int a,b;
        cin>>a>>b;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    queue<int> q;
    q.push(1);
    y[1]==1;
    while(!q.empty()){
        int now=q.front();
        q.pop();
        for(int ne : to[now]){
            if(y[ne]!=0) continue;
            y[ne]=now;
            q.push(ne);
        }
    }
    for(int i=1;i<=n;i++) if(y[i]==0){
        cout<<"No";
        return 0;
    }
    cout<<"Yes"<<endl;
    for(int i=2;i<=n;i++){
        cout<<y[i]<<endl;
    }
    return 0;
}

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

#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define fo(i, a, b, k) for(int i = a; i <= b; i += k)
#define _fo(i, a, b, k) for(int i = a; i >= b; i -= k)
#define foa(i, a) for (auto &i : a)
#define fod(i, a) for(int i = 1; i*i <= a; i++)
#define sz(a) ((int) a.size())
#define all(a) begin(a), end(a)
#define fi first
#define se second
#define pb(x) push_back(x)
#define mk(x, y) make_pair(x, y)  
#define log2i(x) (31-__builtin_clz(x))
#define log2ll(x) (63-__builtin_clzll(x)) 
#define msz(x) __builtin_popcount(x) 
#define mszll(x) __builtin_popcountll(x) 
#define fom(i, a, b) for(int i = a; i < (1<<b); i++)
#define ifon(i, mask) if(mask&(1<<i))
#define ss(i, mask) while(i=(i-mask)&mask)
#define ifss(i, mask) if(i > (mask^i)) 

typedef int64_t ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int MAX = 1e2+1;
const int MOD = 1e9+7;
const ll INF = INT_MAX;
const ll _INF = INT_MIN;

int w, h, n, c = 1;
int a[MAX*MAX], ans[MAX][MAX];

bool check(int x, int y) {
	if(x < 1 || y < 1 || x > w || y > h || ans[x][y] != 0) return true;
	return false;
}

void dfs(int x, int y) { 
	if(check(x, y)) return;
	
	if(a[c] == 0) c++;
	ans[x][y] = c;
	a[c]--;
	
	dfs(x+1, y);
	dfs(x, y+1);
	dfs(x-1, y);
	dfs(x, y-1);
}

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	cin >> w >> h >> n;
	fo(i, 1, n, 1) cin >> a[i];
	
	dfs(1, 1);
	
	fo(i, 1, w, 1) {
		fo(j, 1, h, 1) cout << ans[i][j] << " ";
		cout << "\n";	
	}
}

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

const int mod = 1e9 + 7;

int main() {
	int n, b; long long ans; string s1, s2;
	cin >> n >> s1 >> s2;

	if (s1[0] == s2[0])ans = 3;
	else ans = 6;
	for (int i = 0; i < n - 1; i++) {
		if (i < n - 1 && s1[i] == s1[i + 1])continue;
		if (s1[i] == s2[i]) {
			if (s1[i + 1] == s2[i + 1])b = 2;
			else if (s1[i + 1] != s2[i + 1])b = 2;
		}
		if (s1[i] != s2[i]) {
			if (s1[i + 1] == s2[i + 1])b = 1;
			else if(s1[i + 1] != s2[i + 1]) b = 3;
		}
		ans = (ans * b) % mod;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int maxn=1e6+5;
vector<ll> V;
int pre[maxn];
int main() {
    ll n,d;
    cin>>n>>d;
    ll ans=0;
    for(int i=1;i<=n;i++) {
    	ll x,y;cin>>x>>y;
    	if(x*x+y*y<=d*d) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
#define MAX 100005
#define pb push_back
#define INF 2147483647
using namespace std;

typedef long long ll;

void test(ll x1, ll y1, ll x2, ll y2, ll x3, ll y3)
{
    ll ans = x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2);
    cout<<ans<<endl;

}

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    #ifdef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ll s;

    cin>>s;
    ll low = 1, high = 1e9, mid, sq;
    while(low <= high){
        mid = (low + high + 1) / 2;
        if(mid * mid >= s){
            sq = mid;
            high = mid - 1;
        }
        else
            low = mid + 1;
    }
    //cout<<y3<<endl;

    ll rem = ((sq * sq) - s);
    //test(0, 0, sq, 1, rem, sq);
    cout<<0<<" "<<0<<" "<<sq<<" "<<1<<" "<<rem<<" "<<sq<<endl;

    return 0;
}

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

const int N = 1e5 + 10;
typedef long long ll;
typedef pair <ll, ll> pii;

vector <int> res, vec, adj[N];
int a[N], vis[N];

void dfs (int v) {
	res.push_back(v);
	vec.push_back(a[v]);
	vis[v] = 1;
	for (auto u : adj[v])
		if(!vis[u])	dfs(u);
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++)	{
		cin >> a[i]; a[i]--;
	}
	for (int i = 0; i < m; i++) {
		int v, u;
		cin >> v >> u;
		v--, u--;
		adj[v].push_back(u), adj[u].push_back(v);
	}
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		if(!vis[i]) {
			vec.clear(), res.clear();
			dfs(i);
			sort(vec.begin(), vec.end()), sort(res.begin(), res.end());
			for (int j = 0; j < res.size(); j++) {
				if(binary_search(vec.begin(), vec.end(), res[j]))
					ans++;
			}
		}
	}
	cout << ans << "\n";
}

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

int main() {
  double n, m, d;
  cin >> n >> m >> d;
  double ans=0.0;
  if (d == 0)
    ans = 1.0 /  n;
  else
    ans = 2.0 * (n - d) / ( n * n);
  ans *= m - 1;
  cout << setprecision(10) << ans << endl;
}


Measured memory_bytes: 256
/* 
chirag11032000
Chirag Thakur
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;

template < typename T > using OrderedSet = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std :: 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...);
}
#else
#define trace(...)
#endif

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

const db PI = acos(-1);
const ll LINF = LLONG_MAX;
const int INF = INT_MAX, MOD = 1e9 + 7, N = 1e5 + 10;

vector < pii > g[N];
bool seen[N];
ll dis[N];

void testCase();
void dfs(int u, ll d);

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	testCase();
	cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
	return 0;
}

void testCase() {
	int n;
	cin >> n;
	for (int i = 1; i < n; ++i)	{
		int u, v, w;
		cin >> u >> v >> w;
		g[u].eb(v, w);
		g[v].eb(u, w);
	}
	dfs(1, 0);
	for (int i = 1; i <= n; ++i) {
		cout << (dis[i] & 1) << "\n";
	}
}

void dfs(int u, ll d) {
	seen[u] = true;
	dis[u] = d;
	for (auto &v: g[u]) {
		if (!seen[v.first]) {
			dfs(v.first, d + v.second);
		}
	}
}

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

int main(){
  int n, m; cin >> n >> m;
  pair<int, int> x[100000];

  for(int i=0; i<n; ++i){
    cin >> x[i].first >> x[i].second;
  }

  sort(x, x + n);

  long long ans=0;
  for(int i=0, l=0; l<m; ++i){
    if(l + x[i].second > m){
      ans += (long long)x[i].first*(m - l);
    }else{
      ans += (long long)x[i].first*x[i].second;
    }
      l += x[i].second;
  }

  cout << ans << endl;
}


Measured memory_bytes: 1024
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
input = sys.stdin.readline
INF = float("inf")


# 処理内容
def main():
    S = input()[:-1]

    if S[-1:] == "s":
        print(S + "es")
    else:
        print(S + "s")


if __name__ == '__main__':
    main()

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

int main() {

  long long int n, m;
  cin >> n >> m;

  long long int v[1001] = {};

  for ( long long int i = 0; i < m; i++ ) {

    long long int in_c, in_d;
    cin >> in_c >> in_d;

    v[ in_c ]++;
    v[ in_d ]--;

  }

  for ( long long int i = 1; i <= n; i++ ) {
    v[i] += v[i-1];
  }

  long long int ans = 0;

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

    if ( v[i] == 0 ) {
      ans += 1;
    }else {
      ans += 3;
    }

  }

  cout << ans << endl;

  return 0;

}

Measured memory_bytes: 1164
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);

		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int ab = a * b;

		if(ab % 2 == 0) {
			System.out.println("Even");
		}else {
			System.out.println("Odd");
		}

		sc.close();
	}
}


Measured memory_bytes: 23252
#include<iostream>
#include<string>

using namespace std;

int N, M;

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

	long long ans;
	if (N == 2 || M == 2)
	{
		ans = 0;
	}
	else
	{
		int n, m;
		n = N == 1 ? 1 : N - 2;
		m = M == 1 ? 1 : M - 2;
		ans = 1LL * n * m;
	}

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

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
#include <utility>
#include <stack>
#include <numeric>
#include <random>
#include <algorithm>
#include <queue>
#include <functional>
#include <iterator>
#include <list>
#include <unordered_map>
#include <deque>
#include <math.h>
#include <tgmath.h>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define rep(i, b, e) for(i = b; i < e; ++i)
#define repr(i, b, e) for (i = b; i >= e; --i)
#define ull unsigned long long int
#define ll long long int
#define pint pair<int, int>

#define M_DEBUG 1
#define PI 3.141592653589793

#define E '\n'

#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << "\n";}
#define INF (1e18)

const ll MAX = 1000000000;
const ll MOD = 1e9 + 7;

ll a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z;

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;
}

ll aabs(ll a) {
    if (a < 0) return -a;
    return a;
}

//fast power
ll calc(ll a, ll b) {
    if (b == 0) return 1;
    else if (b % 2 == 0) {
        ll d = calc(a, b / 2);
        return (d * d) % MOD;
    }
    else return (a * calc(a, b - 1)) % MOD;
}

//fast combination
ll comb(ll n, ll a) {
    ll b = 1, c = 1;
    for (ll i = 1; i <= a; ++i) {
        b = b * i % MOD;
        c = c * (n - i + 1) % MOD;
    }

    return c * calc(b, MOD - 2) % MOD;
}

ll comb2(ll a) {
    ll b = a / 2;
    if (a % 2) {
        b = (a - 1) / 2;
        return (b * a);
    }
    return (b * (a - 1));
}

int dfs(int x, int y, int z) {
    if (x == a && y == b && z == c) return 1;
    
    int ans = 0;
    if (x != a) ans += dfs(x + 1, y, z);
    if (x >= y + 1/* && y != b*/) ans += dfs(x, y + 1, z);
    if (y >= z + 1/* && z != c*/) ans += dfs(x, y, z + 1); 

    return ans;
}

uint64_t gcd_impl( uint64_t n, uint64_t m ) {
        for( int i = 0; i < 10; ++i ) {
                uint64_t t = n - m;
                bool q = m > t;
                n = q ? m : t;
                m = q ? t : m;
                if( m == 0 ) { return n; }
        }
        return gcd_impl( m, n % m );
}

uint64_t gcd( uint64_t n, uint64_t m ) {
        return n > m ? gcd_impl( n, m ) : gcd_impl( m, n );
}

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> m;

    if (m >= n)
    cout << "unsafe" << endl;    
    else cout << "safe" << endl;

    return 0;
}



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

#define F first
#define S second
#define pii pair<int, int>
#define pb push_back

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 1e5 + 10;

ll x[N], p[N];
ll ans;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n, S; cin >> n >> S;
	int pos = -1;
	for (int i=0; i<n; i++)
	{
		cin >> x[i] >> p[i];
		if(x[i] < S) pos = i;
	}

	int st = 0, en = n - 1, dir = -1;
	while(true)
	{
		if(st > pos){ ans += x[en] - S; break ;}
		else if(en <= pos){ ans += S - x[st]; break; }
		if(p[st] >= p[en])
		{
			if(dir != 0) ans += x[en] - x[st];
			dir = 0;
			p[st] += p[en];
			en --;
		}else 
		{
			if(dir != 1) ans += x[en] - x[st];
			dir = 1;
			p[en] += p[st];
			st ++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int x = Integer.parseInt(sa[0]);
		int y = Integer.parseInt(sa[1]);
		int a = Integer.parseInt(sa[2]);
		int b = Integer.parseInt(sa[3]);
		int c = Integer.parseInt(sa[4]);

		sa = br.readLine().split(" ");
		List<Integer> p = new ArrayList<>(a);
		for (int i = 0; i < a; i++) {
			p.add(Integer.parseInt(sa[i]));
		}
		sa = br.readLine().split(" ");
		List<Integer> q = new ArrayList<>(a);
		for (int i = 0; i < b; i++) {
			q.add(Integer.parseInt(sa[i]));
		}
		sa = br.readLine().split(" ");
		List<Integer> r = new ArrayList<>(a);
		for (int i = 0; i < c; i++) {
			r.add(Integer.parseInt(sa[i]));
		}
		br.close();

		Collections.sort(p, Collections.reverseOrder());
		Collections.sort(q, Collections.reverseOrder());
		Collections.sort(r, Collections.reverseOrder());

		long ans = 0;
		for (int i = 0; i < x; i++) {
			ans += p.get(i);
		}
		for (int i = 0; i < y; i++) {
			ans += q.get(i);
		}

		int pi = x - 1;
		int qi = y - 1;
		for (int i = 0; i < c; i++) {
			int alt = r.get(i);
			int v1 = Integer.MAX_VALUE;
			if (pi >= 0) {
				v1 = p.get(pi);
			}
			int v2 = Integer.MAX_VALUE;
			if (qi >= 0) {
				v2 = q.get(qi);
			}
			if (v1 < v2) {
				if (v1 < alt) {
					ans -= v1;
					ans += alt;
					pi--;
				} else {
					break;
				}
			} else {
				if (v2 < alt) {
					ans -= v2;
					ans += alt;
					qi--;
				} else {
					break;
				}
			}
		}
		System.out.println(ans);
	}
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll r, D, x;
    cin >> r >> D >> x;
    ll tmp = x;
    REP(i, 10){
    	tmp = r*tmp - D;
    	cout << tmp << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> v(n);
    int temp;
    for(int i=0;i<n;i++){
        cin>>temp;
        v[i]=temp-1;
    }
    
    int index=0;
    int iter=0;
    vector<int> checked(n,0);
    while(index!=1){
        index=v[index];
        if(checked[index]==1){
            cout<<-1<<endl;
            return 0;
        }
        checked[index]=1;
        iter++;
    }
    cout<<iter<<endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String str = sc.next();
		char stamps[] = new char[n];
		sc.close();
		stamps = str.toCharArray();
		int count = 0;
		int point = 1;
		while (point < n) {
			if (stamps[point] != stamps[point - 1]) {
				count++;
				point += 2;
			} else {
				point++;
			}
			if (point > n) {
				break;
			}

		}
		System.out.println(count);
	}
}



Measured memory_bytes: 30032
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  sort(a.begin(), a.end());
  int l = -1, r = n;
  while (r - l > 1) {
    int m = (l + r) / 2;
    if (a[m] >= k) r = m;
    else {
      vector<bool> dp(k, false);
      dp[0] = true;
      rep(i, n) {
        if (i == m) continue;
        repr(j, k - 1) {
          if (dp[j] && j + a[i] < k) {
            dp[j + a[i]] = true;
          }
        }
      }
      bool flag = false;
      FOR(i, k - a[m], k) {
        if (dp[i]) {
          flag = true;
          break;
        }
      }
      if (flag) r = m;
      else l = m;
    }
  }
  cout << r << 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 ) * } };
}
#[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 , usize1 ) => { read_value ! ( $ next , usize ) - 1 };
    ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) };
}

#[allow(unused_macros)]
macro_rules! vec_md {
    ( $ init : expr ; $ ( $ dim : expr ) ;* ) => { vec_md ! ( $ ( $ dim ) ;* => $ init ) };
    ( $ head : expr ; $ ( $ tail : expr ) ;* => $ init : expr ) => { vec ! [ vec_md ! ( $ ( $ tail ) ;* => $ init ) ; $ head ] };
    ( $ head : expr => $ init : expr ) => { vec ! [ $ init ; $ head ] };
}

fn main() {
    input! {
        n: usize,
        a: [i64; n]
    }
    let mut dp = vec_md![None;n+1;n+1];
    println!("{}", rec(&mut dp, &a, 0, n));
}

fn rec(dp: &mut Vec<Vec<Option<i64>>>, a: &[i64], l: usize, r: usize) -> i64 {
    if let Some(src) = dp[l][r] {
        return src;
    }
    if l == r {
        return 0;
    }
    let ret = if (r - l) % 2 == a.len() % 2 {
        std::cmp::max(
            a[l] + rec(dp,a,l+1,r),
            rec(dp,a,l,r-1) + a[r-1]
        )
    } else {
        std::cmp::min(
            rec(dp,a,l+1,r) - a[l],
            rec(dp,a,l,r-1) - a[r-1]
        )
    };
    dp[l][r] = Some(ret);
    ret
}

Measured memory_bytes: 166396
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	char c = sc.next().charAt(0);
      
      	if(c=='a' || c=='i' || c=='u' || c=='e' || c=='o'){
        	System.out.println("vowel");
        }else{
        	System.out.println("consonant");
        }
    }
}

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

int main() {
  int x, y, a, b, c, t, ka(0), kb(0), k(0);
  cin >> x >> y >> a >> b >> c;
  long long ans(0);
  priority_queue<pair<int, int>> pq;
  while (a + b + c) {
    cin >> t;
    pq.push({t, a && a-- ? 1 : b && b-- ? -1 : c-- ? 0 : 0});
  }
  while (x + y - k) {
    if (pq.top().second == 1 && x - ka || pq.top().second == -1 && y - kb || !pq.top().second) {
      ans += pq.top().first;
      k++;
      if (pq.top().second == 1) ka++;
      if (pq.top().second == -1) kb++;
    }
    pq.pop();
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 6512
//https://atcoder.jp/contests/abc086/tasks/abc086_a

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

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


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <vector>
#include <string>
#define Size 20000000010
#define mod 1000000007
#define INF INT_MAX
#define loop(i,x,n) for(int i = x; i < n; i++)
#define pb push_back
using namespace std;

int main() 
{ 
 
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	cin >> n;
	
	int A[n+1];
	int B[n+1];
	int C[n+1];
	A[0] = 0;
	B[0] = 0;
	C[0] = 0;
	
	for(int i=1;i<=n;i++){
		cin >> A[i] >> B[i] >> C[i];
		A[i] += max(B[i-1], C[i-1]);
		B[i] += max(A[i-1], C[i-1]);
		C[i] += max(A[i-1], B[i-1]);
	}
	
	cout << max(A[n], max(B[n], C[n])) << "\n";
	 
	return 0;
}


Measured memory_bytes: 1408
#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; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */
string solveA(){
    ll R; cin >> R;
    return R < 1200 ? "ABC": R < 2800?"ARC":"AGC";
}
string solveB(){
    string S; cin >> S;
    vector<int> flag(S.length());
    if(*S.begin() != 'A') return "WA";
    bool a = false;
    for(int i = 2; i < S.length()-1;i++){
        if(S[i] == 'C'){
            if(a) return "WA";
            a = true;
            flag[i] = true;
        }
    }
    flag[0] = true;
    if(!a) return "WA";
    
    for(int i = 0; i < S.length();i++){
        if(flag[i])continue;
        if(islower(S[i])) continue;
        return "WA";
    }
    return "AC";
}

ll solveC(){
    ll res = LINF;
    int D,G; cin >> D >> G;
    vector<ll> p(D),c(D);
    for(int i = 0; i < D;i++) cin >> p[i] >> c[i];
    
    G/= 100;
    for(auto& v:c) v/=100;
    
    for(int i = 0; i < (1<<D);i++){
        ll L = G;
        ll cnt = 0;
        for(int j = 0; j < D;j++){
            if((i>>j)&1){
                L -= (j+1)*p[j]+c[j];
                cnt += p[j];
            }
        }
        if(L <= 0){
            res = min(res,cnt);
            continue;
        }
        for(int j = D-1;j>=0;j--){
            if((i>>j)&1) continue;
            ll num = min(p[j],(L+j)/(j+1));
            L -= num*(j+1);
            cnt += num;
            if(L <= 0) break;
        }
        if(L <= 0) res = min(res,cnt);
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    //cout << solveA() << endl;
    //cout << solveB() << endl;
    cout << solveC() << endl;
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i,n) cin >> d[i];
    sort(d.begin(),d.end());
    int l = d[n/2-1];
    int r = d[n/2];
    int ans = r - l;;
    cout << ans << endl;
}

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

int main(){
    int a, b;
    cin >> a >> b;
    int min, max;
    if (a>b) {
        min = b;
        max = a;
    }
    else {
        min = a;
        max = b;
    }
    int ans = 0;
    for (int i=0; i<max; i++) {
        ans += min * pow(10, i);
    }
    
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
  public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

ll gcd(ll a, ll 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 mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

void solve(std::string s)
{
    int p = 0;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == 'p')
        {
            p++;
        }
    }

    cout << s.size() / 2 - p << endl;
}

int main()
{
    std::string s;
    std::cin >> s;
    solve(s);
    return 0;
}


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

#define sz(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;++i)
#define per(i,a,b) for(int i=a-1;i>=b;--i)
#define mp make_pair
#define pb push_back
typedef pair<int, int> pii;
/////

int n;
vector<int> p, v;

int getMean(int a, int b, int c){
	vector<int> abc;
	abc.pb(a);
	abc.pb(b);
	abc.pb(c);
	sort(abc.begin(), abc.end());
	return abc[1];
}

pii zigzag(vector<int> v){
	pii ret = mp(1, 0);
	rep(i, 1, sz(v)) if(v[i] == v[i-1]) ret.first = false;
	if(!ret.first) return ret;
	int change = ((n / 2) & 1);
	ret.second = (v[n/2] ^ change);
	return ret;
}

int check(int val){
	v.clear();
	rep(i, 0, n){
		int value;
		if(p[i] >= val) value = 1;
		else value = 0;
		v.pb(value);
	}
	pii ret = zigzag(v);
	if(ret.first) return ret.second;

	int lp = -1;
	int rp = -1;
	per(i, n/2 + 1, 1) if(v[i] == v[i-1]){
		lp = i;
		break;
	}
	rep(i, n/2, n-1) if(v[i] == v[i+1]){
		rp = i;
		break;
	}
	int addLp = 0, addRp = 0;
	if(lp == -1 || rp == -1){
		if(lp == -1) return v[rp];
		else return v[lp];
	}else{
		if(v[lp] == v[rp]) return v[lp];
		rep(i, lp+1, rp) if(v[i] == v[lp]) ++addLp;
		else --addRp;
	}
	if(lp + addLp >= n/2) return v[lp];
	else return v[rp];
}

int brute(vector<int> a){
	vector<int> na;
	while(sz(a) > 1){
		na.clear();
		rep(i, 1, sz(a) - 1){
			na.pb(getMean(a[i-1], a[i], a[i+1]));
		}
		a = na;
	}
	return a[0];
}

void solve(){
	cin >> n;
	n = n * 2 - 1;
	rep(i,0,n){
		int v;
		cin >> v;
		p.pb(v);
	}

	int l = 0;
	int r = n + 1;
	while(r-l>1){
		int m = (l+r)/2;
		if(check(m)) l = m;
		else r = m;
	}
	cout << l << endl;
	//cout << brute(p) << endl;
	//assert(l == brute(p));
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	solve();



	return 0;
}

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

char t[][5] = {
    {},
    {'.', ',', '!', '?', ' '},
    {'a', 'b', 'c'},
    {'d', 'e', 'f'},
    {'g', 'h', 'i'},
    {'j', 'k', 'l'},
    {'m', 'n', 'o'},
    {'p', 'q', 'r', 's'},
    {'t', 'u', 'v'},
    {'w', 'x', 'y', 'z'}};

int main()
{
  int n;
  cin >> n;
  vector<string> ans;
  for (int i = 0; i < n; ++i)
  {
    string s;
    cin >> s;
    string sum = "";
    int cnt = 0;
    char c = '0';
    for (int j = 0; j < s.size(); ++j)
    {
      if (s[j] == '0')
      {
        if (c == '0')
          continue;
        if ((c - '0') == 1)
          sum += t[c - '0'][(cnt - 1) % 5];
        else if ((c - '0') == 7 || (c - '0') == 9)
          sum += t[c - '0'][(cnt - 1) % 4];
        else
          sum += t[c - '0'][(cnt - 1) % 3];
        cnt = 0;
        c = '0';
      }
      else
      {
        c = s[j];
        cnt++;
      }
    }
    ans.push_back(sum);
  }
  for (auto &e : ans)
    cout << e << endl;

  return 0;
}



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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FORE(i, a, b) for(int i=(a);i<=(b);++i)
#define rep(i, n) for(int i=0;i<(n);++i)
#define repe(i, n) for(int i=0;i<=(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)
typedef pair<int, int> P;
const int INF = (int) 1e9;
const int MOD = (int) 1e9 + 7;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	ll a[n];
	rep(i, n) cin >> a[i];
	
	sort(a, a + n);
	
	ll sum = a[0];
	int x = 0;
	FOR(i, 1, n) {
		if (2 * sum < a[i]) {
			x = i;
		}
		sum += a[i];
	}
	
	cout << n - x << endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using lint         = long long;
constexpr lint inf = 1LL << 60;
constexpr lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<pair<lint, lint>> edges;
    for (int i = 0; i < n - 1; ++i) {
        int u, v;
        cin >> u >> v;
        if (u > v)
            swap(u, v);
        edges.emplace_back(u, v);
    }
    lint ret = 0;
    for (lint i = 1; i <= n; ++i) {
        ret += i * (n + 1 - i);
    }
    for (auto &p : edges) {
        ret -= p.first * (n + 1 - p.second);
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 7384
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long int;
using ULL = unsigned long long;

int main() {
    int a, b;
    cin >> a >> b;
    cout << max({a + b, a - b, a * b}) << endl;
    return 0;
}


Measured memory_bytes: 888
# walking takahashi

def walk(X, K, D):
  abX = abs(X)
  if abX >= K*D:
    return abX - K*D
  itr = round(abX/D)
  ret = K - itr
  res = abs(abX - D*itr)
  if (ret % 2) == 0:
    return res
  return abs(res - D)

if __name__ == "__main__":
  inputs = list(map(int, input().split()))
  print(walk(inputs[0], inputs[1], inputs[2]))


Measured memory_bytes: 9136
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <vector>
#include <climits>
using namespace std;

int main()
{
	int N, W;

	cin >> N >> W;
	vector<int> w(N);
	vector<int> v(N);
	auto sumV = 0;
	for (auto i = 0; i < N; ++i)
	{
		cin >> w[i] >> v[i];
		sumV += v[i];
	}

	vector<unsigned long long> prev(sumV + 1, ULLONG_MAX);
	vector<unsigned long long> next(sumV + 1, ULLONG_MAX);
	prev[0] = 0;
	next[0] = 0;
	for (auto i = 0; i < N; ++i)
	{
		auto wi = w[i];
		auto vi = v[i];
		for (auto j = 1; j <= sumV; ++j)
		{
			if (vi <= j && prev[j - vi] < ULLONG_MAX)
			{
				next[j] = min(prev[j - vi] + wi, prev[j]);
			}
			else
			{
				next[j] = prev[j];
			}
		}

		swap(prev, next);
	}

	for (auto i = sumV; i >= 0; --i)
	{
		if (prev[i] <= W)
		{
			cout << i << endl;
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 1792
N = int(input())
S = list(input())
dc = S.count(".")
sc = S.count("#")
dcn = 0
scn = 0
c = 0
count = dc
ans = dc
for i, s in enumerate(S):
    if s == ".":
        dcn += 1
        count -= 1
    if s == "#":
        scn += 1
        count += 1
    ans = min(ans, count)
print(ans)

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

#define ll long long

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	string s;
	cin >> s;
	if(s[2]==s[3] && s[4]==s[5])
		cout << "Yes";
	else
		cout << "No";
}

Measured memory_bytes: 384
n = int(input())
 
otoshidamas = []
kingaku = 0
for i in range(n):
  otoshidamas.append(input().split())
  
for item in otoshidamas:
  if item[1] == "JPY":
    kingaku += float(item[0])
  else:
    kingaku += float(item[0]) * 380000.0
 
print(kingaku)


Measured memory_bytes: 2940
use std::io::{self, Read};

fn main() {
    let mut s = String::new();
    let stdin = io::stdin();
    let mut stdin = stdin.lock();
    stdin.read_to_string(&mut s).unwrap();

    let mut args = s.split_whitespace();
    let a: isize = args.next().unwrap().parse().unwrap();
    let b: isize = args.next().unwrap().parse().unwrap();

    if (a * b) % 2 == 0 {
        println!("Even");
    } else {
        println!("Odd");
    }
}


Measured memory_bytes: 4352
#include <iostream>

using namespace std;

int main() {
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    
    cout << (char)(s1[0]-'a'+'A') << (char)(s2[0]-'a'+'A') << (char)(s3[0]-'a'+'A') << endl;


    return 0;
    
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
char ca[100007];
char cb[100007];
int main(){
	int n;
	int i,j,k;
	int a,b,c;
	int s=0;
	cin>>ca;
	for(i=0,j=0;i<strlen(ca);i++){
		if(ca[i]=='x')continue;
		cb[j]=ca[i],j++;
	}
	cb[j]='\0';
	n=strlen(cb);
	for(i=0;i<n/2;i++){
		if(cb[i]!=cb[n-i-1]){
			cout<<"-1"<<endl;
			return 0;
		}
	}
	for(i=0,j=strlen(ca)-1;i<j;i++){
		if(ca[i]=='x'){
			if(ca[j]=='x')j--;
			else s++;
		}else{
			if(ca[j]!='x')j--;
			else{
				while(ca[j]=='x'){j--,s++;}
				j--;
			}
		}
	}
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 384
import sys
n=int(input())
l=list(map(int,input().split()))
dp=[sys.maxsize]*n
dp[0]=0
for i in range(n):
    for j in [i+1,i+2]:
        if j<n:
            dp[j]=min(dp[j], dp[i]+ abs(l[i]-l[j]))


print(dp[-1])
    
    


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

int main() {
  int N,K,result;
  cin >> N >> K;
  result = 0;
  for (int i=0;i<N;i++){
    int x;
    cin >> x;
    result += (x*2<=K)*2*x+(x*2>K)*2*(K-x);
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
(h, w) = map(int, input().split())
D = '.'
sw = []
sw.append([D for i in range(w + 2)])
for i in range(h):
    sw.append([D] + list(input()) + [D])
sw.append([D for i in range(w + 2)])

for i in range(1, h + 1):
    for j in range(1, w + 1):
        if sw[i][j] == D:
            continue
        ok = False
        for dir in [[1, 0], [-1, 0], [0, 1], [0, -1]]:
            if sw[i + dir[0]][j + dir[1]] == '#':
                ok = True
                break
        if ok == False:
            print('No')
            sys.exit(0)
print('Yes')

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

int main() {
  string s; cin >> s;
  int sn = s.size();
  string ans = "AC";
  if (s[0] != 'A') {
    ans = "WA";
  } else {
    int cc = 0, j = 0;
    for (int i = 1; i<sn; i++) {
      if (isupper(s[i])) {
        if (2 <= i && i < sn - 1 && s[i] == 'C') {
          cc++;
        } else {
          ans = "WA";
        }
      }
    }
    if (cc != 1) ans = "WA";
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int main() {
	int n, m;

	while (cin >> n >> m, n && m) {
		vector<int> point(n + 1);
		vector<int> sum;
		for (int i = 0; i < n; i++) {
			cin >> point[i];
		}
		for (int i = 0; i < n + 1; i++) {
			for (int j = i; j < n + 1; j++) {
				sum.push_back(point[i] + point[j]);
			}
		}
		sort(sum.begin(), sum.end());

		int ans = 0;
		for (int i = 0; i < sum.size(); i++) {
			int t = m - sum[i];
			vector<int>::iterator it = upper_bound(sum.begin(), sum.end(), t);
			if (it != sum.begin()) {
				ans = max(ans, sum[i] + * (it - 1));
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 5032
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int k = Integer.parseInt(br.readLine());

		String str = br.readLine();
		if (str.length() <= k) {
			System.out.println(str);
		} else {
			String s = str.substring(0, k);
			System.out.println(s + "...");
		}
	}
}


Measured memory_bytes: 36456
use std::collections::VecDeque;
use std::io::Read;
fn main() {
    let mut buf = String::new();

    std::io::stdin().read_to_string(&mut buf).unwrap();

    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let m: usize = iter.next().unwrap().parse().unwrap();
    let mut a: Vec<i32> = (0..n)
        .map(|_| iter.next().unwrap().parse().unwrap())
        .collect();
    a.sort();
    a.reverse();
    let total: i32 = a.iter().sum();
    let mut ans = true;
    for i in 0..m {
        if a[i] * (4 * (m as i32)) < total {
            ans = false;
        }
    }
    println!("{}", if ans { "Yes" } else { "No" });
}


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

using namespace std;
using ll = long long;

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

int main() {
  ll l, r;
  cin >> l >> r;

  const int mod = 2019;
  ll ans = mod;
  r = min(r, l + mod);
  for (ll i = l; i <= r; ++i) {
    for (ll j = i + 1; j <= r; ++j) {
      ans = min(ans, i * j % mod);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3568
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
// #pragma GCC optimize ("Ofast,unroll-loops,-ffloat-store")
// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")

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

string to_string(const string& s) { return '"' + s + '"'; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
    #define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 3
#endif
 
#define cin_exception cin.exceptions(cin.failbit);
#define cout_precision cout.setf(ios::fixed); cout.precision(15);
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
using ld = long double; using vi = vector<int>;
using ll = int_fast64_t; using ull = uint_fast64_t;
using vl = vector<ll>; using vul = vector<ull>;

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

const int N = 3e3 + 5, S = N;
const int MOD = 998244353;
int n, s;
int dp[N][S][3];

void solve() {
    cin >> n >> s;
    dp[0][0][0] = 1;
    for (int i = 1; i <= n; ++i) {
        int a; cin >> a;
        int pi = i - 1;
        for (int j = 0; j <= s; ++j) {
            dp[i][j][0] = (ll(0) + dp[i][j][0] + dp[pi][j][0]) % MOD;
            dp[i][j][1] = (ll(0) + dp[i][j][1] + dp[pi][j][0] + dp[pi][j][1]) % MOD;
            dp[i][j][2] = (ll(0) + dp[i][j][2] + dp[pi][j][0] + dp[pi][j][1] + dp[pi][j][2]) % MOD;
            if (j + a > s) continue;
            dp[i][j + a][1] = (ll(0) + dp[i][j + a][1] + dp[pi][j][0] + dp[pi][j][1]) % MOD;
            dp[i][j + a][2] = (ll(0) + dp[i][j + a][2] + dp[pi][j][0] + dp[pi][j][1]) % MOD;
        }
    }
    cout << dp[n][s][2] << '\n';
}

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

int main() {
    fast_io;
#ifdef LOCAL
    cin_exception;
#endif
    int t = 1;
    // cin >> t;
    // preprocess();
    for (int i = 1; i <= t; ++i) {
        solve();
    }
}


Measured memory_bytes: 105856
K,A,B = map(int, input().split())

if B-A < 2 or K < A+1:
    ans = 1+K
else:
    K -= A+1
    if K%2 == 0:
        ans = B + (B-A) * (K//2)
    else:
        ans = B + ((B-A) * (K//2)) + 1

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int i=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int i=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

int solve(int N, int K, int Q, vector<int> &A, int x){
    priority_queue<int, vector<int>, greater<int>> pq_all;
    priority_queue<int, vector<int>, greater<int>> pq;
    REP(i, N+1){
        if(A[i] < x){
            while(!pq.empty()){
                if(pq.size() >= K){
                    pq_all.push(pq.top());
                }
                pq.pop();
            }
        }else{
            pq.push(A[i]);
        }
    }
    if(pq_all.size() < Q) return 1<<30;
    int mx = 0;
    int mn = 1<<30;
    REP(i, Q){
        int tp = pq_all.top();
        pq_all.pop();
        mx = max(mx, tp);
        mn = min(mn, tp);
    }
    return mx - mn;
}

int main(){
    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> A(N);
    REP(i, N) cin >> A[i];
    A.push_back(0);

    int ans = 1<<30;
    REP(i, N)
        ans = min(ans, solve(N, K, Q, A, A[i]));
    cout << ans << endl;
    return 0;
}

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

#define ll long long
#define vi vector<int> 
#define pb push_back	
 
string s;
int g, d;
 
int main(){
	cin >> s;
	for(int i = 0; i < s.size(); i++){
		if(s[i] == 'A'){
			g = i;
			break;
		}
	}
	for(int i = 0; i < s.size(); i++){
		if(s[i] == 'Z'){
			d = i;
		}
	}
	cout << d - g + 1;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (long long i = 0; i < (long long)(n); ++i)
#define sz(x) (int)(x).size()

using ll = long long;
using P = pair<long long, long long>;
using MATRIX = vector< vector<ll> >;
template <class T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <class T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}

const long long INF = 200000;

string s, t;


constexpr ll base1 = 1007, base2 = 2009, mod1 = 1000000007, mod2 = 1000000009;
 
struct RollingHash {
    vector<ll> hash1, hash2, pow1, pow2;
    RollingHash (const string &S) {
        int length = sz(S);
        hash1.assign(length + 1, 0);
        hash2.assign(length + 1, 0);
        pow1.assign(length + 1, 1);
        pow2.assign(length + 1, 1);
        rep(i, length) {
            hash1[i + 1] = (hash1[i] * base1 + S[i]) % mod1;
            hash2[i + 1] = (hash2[i] * base2 + S[i]) % mod2;
            pow1[i + 1] = pow1[i] * base1 % mod1;
            pow2[i + 1] = pow2[i] * base2 % mod2;
        }
    }
    pair<ll, ll> find(int l, int r) const {
        ll res1 = hash1[r] - hash1[l] * pow1[r - l] % mod1;
        if (res1 < 0) res1 += mod1;
        ll res2 = hash2[r] - hash2[l] * pow2[r - l] % mod2;
        if (res2 < 0) res2 += mod2;
        return pair<ll, ll>{res1, res2};
    }
};

int main() {
  cin >> s >> t;

  int k = (sz(s) + sz(t) - 2) / sz(s) + 1;
  string r;
  rep(i, k) r += s;
  RollingHash rs_(r), rt(t);

  vector<bool> judge(s.size(), false);
  vector<bool> searched(s.size(), false);

  rep(i, s.size()) {
    if(rs_.find(i, i + t.size()) == rt.find(0, t.size())) {
      judge[i] = true;
    }
  }

  int ans = 0;
  rep(i, s.size()) {
    if(searched[i]) continue;
    if(!judge[i]) continue;
    int now = i, cnt = 0;
    do {
      now = (now + t.size()) % s.size();
      cnt++;
      searched[now] = true;
    } while (now != i && judge[now]);
    if(now == i) ans = INF;
    else chmax(ans, cnt);
  }

  if(ans == INF) cout << -1 << endl;
  else cout << ans << endl;
  return 0;
}

Measured memory_bytes: 68200