akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
    public static void Main()
    {
        var n = ReadLine().Split().Select(int.Parse).ToArray();
        var h = ReadLine().Split().Select(int.Parse).ToArray();
        List<int>[] tower = new List<int>[n[0]];
        for(int i = 0; i < n[0]; i++)
        {
            tower[i] = new List<int>();
        }
        for(int i = 0; i < n[1]; i++)
        {
            var b = ReadLine().Split().Select(int.Parse).ToArray();
            tower[b[0] - 1].Add(b[1] - 1);
            tower[b[1] - 1].Add(b[0] - 1);
        }
        int count = 0;
        for(int i = 0; i < n[0]; i++)
        {
            int c = 0;
            for(int j = 0; j < tower[i].Count; j++)
            {
                if(h[i] > h[tower[i][j]])
                {
                    c++;
                }
                else
                {
                    break;
                }
            }
            if(c == tower[i].Count)
            {
                count++;
            }
        }
        WriteLine($"{count}");
    }
}


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

int main() {
	//初期化
	int H, W; cin >> H; cin >> W;
	vector<string> D(H);
	for (int i = 0; i < H; i++) {
		cin >> D[i];
	}
	vector<vector<int>> time(H, vector<int>(W));
	vector<vector<int>> visit(H, vector<int>(W));
	queue<pair<int, int>> Q;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (D[i][j] == '#') {
				Q.push(pair<int, int>(i, j));
				visit[i][j] = 1;
			}
		}
	}

	//BFS
	while (!Q.empty()) {
		int x = Q.front().first;
		int y = Q.front().second;
		Q.pop();
		if (x > 0) {
			if (visit[x - 1][y] != 1) {
				Q.push(pair<int, int>(x - 1, y));
				time[x - 1][y] = time[x][y] + 1;
				visit[x - 1][y] = 1;
			}
		}
		if (x < H - 1) {
			if (visit[x + 1][y] != 1) {
				Q.push(pair<int, int>(x + 1, y));
				time[x + 1][y] = time[x][y] + 1;
				visit[x + 1][y] = 1;
			}
		}
		if (y > 0) {
			if (visit[x][y - 1] != 1) {
				Q.push(pair<int, int>(x, y - 1));
				time[x][y - 1] = time[x][y] + 1;
				visit[x][y - 1] = 1;
			}
		}
		if (y < W - 1) {
			if (visit[x][y + 1] != 1) {
				Q.push(pair<int, int>(x, y + 1));
				time[x][y + 1] = time[x][y] + 1;
				visit[x][y + 1] = 1;
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			ans = max(ans, time[i][j]);
		}
	}

	cout << ans << endl;

}

Measured memory_bytes: 17424
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>

using namespace std;

int w[3];

int main()
{
    int cnt = 0;
    for(int i = 0; i < 3; i ++)
    {
        scanf("%d", &w[i]);
        if(w[i] % 2)  cnt ++;
    }
    sort(w, w + 3);
    
    int t = 0, res = 0;
    if(cnt == 1)  res ++,  t = 1;       //  如果有1个奇数，就把3个数都化为奇数
    else if(cnt == 2)  res ++,  t = 2;  //  如果有2个奇数，就把3个数都化为偶数
    
    for(int i = 0; i < 3; i ++)
        if(t == 1 && w[i] % 2 == 0)  w[i] ++;
        else if(t == 2 && w[i] % 2)  w[i] ++;
        
    res += (w[2] - w[0]) / 2;
    res += (w[2] - w[1]) / 2;
    printf("%d", res);
	return 0;
}

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

using namespace std;

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

  int s[m];

  for (int i = 0; i < m; i++) {
    s[i] = 0;
  }

  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    for(int j = 0; j < k; j++) {
      int l;
      cin >> l;
      s[i] += (1 << (n-l));
    }
  }

  int p[m];
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }

  int ans = 0;
  for(int i = 0; i < (1 << n); i++) {
    bool f = true;
    for(int j = 0; j < m; j++) {
      int andb = s[j] & i;
      int cnt = 0;
      for(int k = 0; k < n; k++) {
        if ((andb) & 1) {
          cnt++;
        }
        andb = andb >> 1;
      }
      if (cnt % 2 != p[j]) {
        f = false;
        break;
      }
    }
    if (f) {
      ans++;
    }
  }

  cout << ans << "\n";
}


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

int main() {
    ios_base :: sync_with_stdio(0);
    int n ; cin >> n;
    int arr [n];
    int dp [n];
    for (int i = 0 ; i < n ; i++){
        cin >> arr[i];}
    dp[0]= 0;
    dp [1]= abs(arr[1]-arr[0]);
    for (int i =2 ; i < n; i++){
        dp[i] = min (dp[i-1]+abs(arr[i]-arr[i-1]) , dp[i-2]+abs(arr[i]-arr[i-2]));
    }
    cout << dp[n-1];
}


Measured memory_bytes: 1024
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($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)*}
    };
}

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

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:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

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

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input!(x: i64, y: i64);
    if x % y == 0 {
        puts!("-1\n");
    } else {
        puts!("{}\n", x);
    }
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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

int gcd(int i,int j){
	if(j==0) return i;
	if(i < j) swap(i,j);
	return gcd(j,i%j);
}

int main(void){
	int i,j;
	while(cin >> i >> j) cout << gcd(i,j) << endl;
}

Measured memory_bytes: 0
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator


inf = float('inf')


# globals
N, M = 0, 0
P, Y = [], []


def set_inputs():
    global N, M, P, Y
    N, M = get_li()
    P, Y = get_data(M, [int, int])
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    prefecture = defaultdict(list)
    lst = [""] * M
    for i, (p, y) in enumerate(zip(P, Y)):
        prefecture[p].append((i, y))
    for k in prefecture.keys():
        prefecture[k].sort(key=operator.itemgetter(1))
        for i, (n, y) in enumerate(prefecture[k]):
            lst[n] = "{:06d}{:06d}".format(k, i + 1)
    for v in lst:
        print(v)
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types):
    if len(types) == 1:
        return [types[0](input()) for _ in range(n)]
    return zip(*(
        [t(x) for t, x in zip(types, input().split())]
        for _ in range(n)
    ))


if __name__ == '__main__':
    main()


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

int main(){
  
  ll X,Y,count=0,z,i=0;
  cin >> X >> Y;
  
  while(X<=Y){
    X*=2;
    count++;
  }
  
 /* z=Y/X;
  
  
  while(pow(2,i)<=z){
    i++;
    count++;
  }*/
  
  cout << count<< endl;
 
}




Measured memory_bytes: 256
#include <math.h>
#include <bits/stdc++.h>
#include <deque>
#define ll long long
#define l long double
#define pi 3.14159265358979323846
#define mod 1000000007
#define vali 1000000000000000000
using namespace std;
int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
} 
  
// Returns LCM of array elements 
ll findlcm(ll arr[], ll n) 
{ 
    // Initialize result 
    ll ans = arr[0]; 
  
    // ans contains LCM of arr[0], ..arr[i] 
    // after i'th iteration, 
    for (int i = 1; i < n; i++) 
        ans = (((arr[i] * ans)) / 
                (gcd(arr[i], ans))); 
  
    return ans; 
} 
int main()
{
    ll n;
    l sum=0.0;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++)
    cin>>a[i];
    ll lcm=findlcm(a,n);
    for(int i=0;i<n;i++)
    {
        sum+=(l)(lcm/a[i]);
    }
    cout<<fixed<<setprecision(7)<<(l)(lcm/sum)<<endl;
}

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

using namespace std;
const int N = 110;
int a[N];
bitset<10010> f[N];

int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) scanf("%d", a + i);
    f[0][0] = 1;
    for (int i = 1; i <= n; i++) {
        f[i] = f[i - 1] | (f[i - 1] << a[i]);
    }
    int ans = 0;
    for (int i = 10000; i >= 0; i--)
        if (i % 10&&f[n][i])
            ans = max(ans, i);
    cout << ans << endl;
    return 0;
}

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

using ll = long long;
using ull = unsigned long long;
#define repi(n) for (long long i = 0; i < (n); ++i)
#define repj(n) for (long long j = 0; j < (n); ++j)
#define repk(n) for (long long k = 0; k < (n); ++k)
#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(itr) for (auto&& v : (itr))
#define updatemax(t, v) (t = std::max(t, (v)))
#define updatemin(t, v) (t = std::min(t, (v)))

#include <boost/operators.hpp>

class modint : private boost::operators<modint>, private boost::equivalent<modint> {
  modint(const long long x, const bool y)
      : x(x) {}

 public:
  static long long M;
  long long x;
  modint(const long long x = 0)
      : x((x % M + M) % M) {}
  modint operator-() const { return modint(x ? M - x : 0, true); }
  modint& operator+=(const modint& b) { return ((x += b.x) >= M ? x -= M : 0), *this; }
  modint& operator++() { return (++x >= M ? x -= M : 0), *this; }
  modint& operator-=(const modint& b) { return ((x -= b.x) < 0 ? x += M : 0), *this; }
  modint& operator--() { return (--x < 0 ? x += M : 0), *this; }
  modint& operator*=(const modint& b) { return x = x * b.x % M, *this; }
  modint& operator/=(const modint& b) { return *this *= b.pow(-1); }
  modint pow(long long b) const {
    long long r = 1, a = x;
    b = (b % (M - 1) + (M - 1)) % (M - 1);
    while (b) {
      if (b & 1) r = r * a % M;
      b = b >> 1;
      a = a * a % M;
    }
    return modint(r, true);
  }
  friend bool operator<(const modint& a, const modint& b) { return a.x < b.x; }
  friend std::istream& operator>>(std::istream& s, modint& a) { return s >> a.x, a = a.x, s; }
  friend std::ostream& operator<<(std::ostream& s, const modint& a) { return s << a.x; }
};
long long modint::M = 1e9 + 7;

int main() {
  int n, k;
  cin >> n >> k;
  vector<modint> xs(k + 1);
  for (int i = k; i > 0; --i) {
    xs[i] += modint(k / i).pow(n);
    if (i > 1) {
      for (int j = 1; j * j <= i; ++j) {
        if (i % j == 0) {
          xs[j] -= xs[i];
          if (j != 1 && j * j != i) xs[i / j] -= xs[i];
        }
      }
    }
  }
  modint re(0);
  rep(i, 1, k + 1) re += xs[i] * i;
  cout << re << endl;
}


Measured memory_bytes: 4052
#include <iostream>
#include <ios>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>

using namespace std;

using i64 = long long int;

int main() {
    i64 n;
    string s;
    cin >> n >> s;
    if(n % 2 == 1 || s.substr(0, n / 2) != s.substr(n / 2)) cout << "No" << endl;
    else cout << "Yes" << endl;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0;i < n;i++){
        cin >> a[i];
    }
    int ans = 0;
    for(int i = 0;i < n;i++){
        if((i+1)%2 != 0){
            if(a[i]%2 != 0){
                ans++;
            }
            
        }
    }
    cout << ans << endl;
}

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

int main()
{
	int N;
	scanf("%d", &N);
	std::map<int, int> cards;
	for (int i{}; i < N; i++)
	{
		int A;
		scanf("%d", &A);
		cards[A]++;
	}
	int size{(int)cards.size()};
	std::vector<int64_t> table(size + 1);
	{
		int index{};
		for (auto iter{cards.begin()}; iter != cards.end(); iter++, index++)
			table[index] = iter->second;
	}
	table.back() = 1ll << 60;
	std::sort(table.rbegin(), table.rend());
	std::vector<int64_t> sum(table);
	sum.front() = 0;
	for (int i{1}; i <= size; i++)
		sum[i] += sum[i - 1];
	
	// for (auto& e: table) std::cout << e << ' ';
	// std::cout << std::endl;
	// for (auto& e: sum) std::cout << e << ' ';
	// std::cout << std::endl;

	for (int K{1}; K <= N; K++)
	{
		if (K > size)
		{
			puts("0");
			continue;
		}
		int64_t rest{sum[size] - sum[K]};
		int ok{}, ng{K};
		while (ng - ok > 1)
		{
			int mid{(ok + ng) >> 1};
			if ((sum[K] - sum[mid] + rest) / (K - mid) <= table[mid])
				ok = mid;
			else
				ng = mid;
		}
		printf("%lld\n", (sum[size] - sum[ok]) / (K - ok));
	}

	return 0;
}

Measured memory_bytes: 18944
n, k = map(int, input().split())
dat_h = list(map(int, input().split()))
dp = [100000000000] * (n + 1)
dp[0] = 0
for i in range(1, n):
    #print("i:{0}", i)
    for j in range(1, k + 1):
        #print("j:{0}", j)
        if (i - j) >= 0:
            dp[i] = min(dp[i], dp[i-j] + abs(dat_h[i] - dat_h[i-j]))
#print(dp)
print(dp[n-1])


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

typedef long long int ll;
typedef vector<int> vi;			typedef vector<ll> vl;
typedef vector<vi> vvi; 		typedef vector<vl> vvl;
typedef pair<int, int> 	pii;	typedef pair<ll, ll> pll;
typedef vector<pii> vii; 		typedef vector<pll> vll;
typedef map<int,int> mii;
typedef vector<char> vc;
typedef vector<bool> vb;
#define endl '\n'
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(int i=1;i<=n;i++)
#define rforne(i,n) for(int i=n;i>=1;i--)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define pf push_front
#define rb pop_back
#define rf pop_front
#define in insert
#define mp make_pair
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define min3(a, b, c) min(min(a, b), c)
#define min4(a, b, c, d) min(min(a, b), min(c, d))
#define max3(a, b, c) max(max(a, b), c)
#define max4(a, b, c, d) max(max(a, b), max(c, d))
const ll INFL = 1e18;
const int INFI = 1e9;
#ifdef KARAN
	#include "../../trace.h"
#else
    #define trace(args...)
#endif

ll div_floor(const ll &a,const ll &b) { return a / b - (((a ^ b) < 0) and a % b);}
ll div_ceil(const ll &a,const ll &b) { return a / b + (((a ^ b) >= 0) and a % b);}
ll modpow(ll a, ll b, ll m = MOD){a %= m; ll res = 1; 
	while (b) {if (b & 1)res = (res * a) % m; a = (a * a) % m; b >>= 1;} return res;}
ll bpow(ll a, ll b){ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a, ll m = MOD) {return modpow(a, m - 2, m);}
void graph(vvi &adj, int m) {int x, y; forn(i, m){cin>>x>>y; adj[--x].pb(--y); adj[y].pb(x);}}

void solve(){
	string s, t;
	cin>>s>>t;
	int ans = 0;
	forn(i, s.size()) ans += s[i]!=t[i];
	cout<<ans<<endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	#ifdef KARAN
		freopen("inp.txt", "r", stdin);
    	freopen("out.txt", "w", stdout);
    	freopen("err.txt", "w", stderr);
	#endif
	int t=1;
	// cin>>t;
	while(t--)
		solve();
}

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

int main()
{
  int n;
  cin >> n;
  int a[n];
  M mp;
  rep(i, n) {
    cin >> a[i];
    mp[a[i]]++;
    mp[a[i] - 1]++;
    mp[a[i] + 1]++;
  }
  int ans = 0;
  rep(i, 1000005) ans = max(ans, mp[i]);
  cout << ans << endl;
    
    

  return 0;
}

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

using namespace std;

vector<int> ans;

void solve(string &s, vector<int> ops, int i);

void solve(string &s, vector<int> ops, int i){
  if(i == 3){
    int ret = s[0] - '0';
    for(int j = 0; j < 3; j++)
      ret += ops[j] * (s[j+1] - '0');
    if(ret == 7)
      ans = ops;
    return;
  }  
  vector<int> ops2 = ops;
  vector<int> ops3 = ops;
  ops3[i] = true;
  solve(s, ops2, i+1);
  solve(s, ops3, i+1);
    return;
}

void solve(string &s, bool op1, bool op2, bool op3);

int main(void){
  string s;
  cin >> s;
  vector<int> ops(3, -1);
  solve(s, ops, 0);
  cout << s[0];
  for(int i=0; i < 3; i++){
    cout <<(ans[i] == 1 ? "+" : "-");
    cout << s[i+1];
  }
  cout << "=7" << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

if sum(a) < sum(b):
    ans = -1
else:
    d = [a[i]-b[i] for i in range(n)]
    d.sort()
    
    i = 0
    s = 0
    while d[i] < 0:
        s -= d[i]
        i += 1
    
    j = 0
    tmp = 0
    while s > tmp:
        tmp += d[j-1]
        j -= 1
    ans = i-j
print(ans)

Measured memory_bytes: 18356
#include <bits/stdc++.h>
typedef long long ll;
ll n, s;
bool check(ll base) {
    ll ret = 0, tmp = n;
    while (tmp) ret += tmp % base, tmp /= base;
    return ret == s;
}
bool check(ll a0, ll a1, ll b) {
        return a0 >= 0 && a0 < b && a1 < b;
}
int main() {
//    freopen("in.txt", "r", stdin);
    scanf("%lld%lld", &n, &s);
    ll up = ll(sqrt(n)) + 1;
    for (ll b = 2; b <= up; b++) if (check(b)) return 0 * printf("%lld\n", b);
        if (n == s) return 0 * printf("%lld\n", n + 1);
        if (n < s) return 0 * puts("-1");
        for (ll a1 = ll(sqrt(n - s)) + 1, tmp = n - s; a1 >= 1; a1--) if (tmp % a1 == 0 && check(s - a1, a1, tmp / a1 + 1)) return 0 * printf("%lld\n", tmp / a1 + 1);
    return 0 * puts("-1");
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;

long a[21][21];

int main(int argc, char* argv[])
{
    long n, m;
    scanf("%ld%ld", &n, &m);

    vector<pair<long, long> > zz;
    long i;
    for(i=0; i<n; i++) {
        long a, b;
        scanf("%ld%ld", &a, &b);
        zz.push_back(make_pair(a, b) );
    }
    sort(zz.begin(), zz.end());

    long cnt=0;
    ll sum=0;
    for(i=0; i<n; i++) {
        if(cnt + zz[i].second >= m) {
            printf("%lld\n", sum + (ll)zz[i].first * (m-cnt) );
            break;
        }
        cnt += zz[i].second;
        sum += (ll)zz[i].first * zz[i].second;
    }


    return 0;
}



Measured memory_bytes: 2420
#include <iostream>
#include <vector>
using namespace std;
bool chmin(long long &a, long long b) { if (a > b) {a = b; return true;} return false;}
const long long INF = 1LL<<60;

using Edge = pair<int, long long>;
int N, M,P;
vector<vector<Edge> > G;
                                 
int main() {
    cin >> N >> M>>P;
    G.clear(); G.resize(N);
    for (int i = 0; i < M; ++i) {
        int a, b; long long w;
        cin >> a >> b >> w; --a, --b;
        G[a].push_back(Edge(b, -(w-P)));
    }

    vector<long long> dist(N, INF);
    bool negative = false;
    dist[0] = 0;
    for (int iter = 0; iter <= N*2; ++iter) {
        for (int v = 0; v < N; ++v) {
            if (dist[v] >= INF/2) continue;
            for (auto e : G[v]) {
                if (chmin(dist[e.first], dist[v] + e.second)) {
                    if (e.first == N-1 && iter >= N-1) negative = true;
                }
            }
        }
    }
    if (!negative) cout << max(0ll,-dist[N-1]) << endl;
    else cout << -1 << endl;
}


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

int N;
string s, t;

int solve() {
    for (int i = 0; i < N; ++i) {
        if (s.substr(i) == t.substr(0, N-i)) return i + N;
    }
    return N*2;
}
int main() {
    cin >> N >> s >> t;
    cout << solve() << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[100005],mod_4=0,mod_2=0,sth=0,cnt;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]%4==0)
		{
			++mod_4;
		}else if(a[i]%2==0)
		{
			++mod_2;
		}else
		{
			++sth;
		}
	}
	if(mod_4>=n/2)
	{
		printf("Yes");
	}else
	{
		if(mod_4==0)
		{
			if(sth>0)
			{
				printf("No");
			}else
			{
				printf("Yes");
			}
		}else if(mod_2>=0)
		{
			mod_4-=1;
			cnt=mod_4+sth;
			if(mod_4>=(cnt/2))
			{
				printf("Yes");
			}else
			{
				printf("No");
			}
		}else
		{
			printf("No");	
		}	
	}
}

Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <cmath>
using namespace std;
int main(void){
    // Your code here!
    int r,c,n,cnt,ans;
    scanf("%d %d",&r,&c);
    int arr[r+1][c+1];
    for (int i=0;i<r;i++){
        cnt=0;
        for (int j=0;j<c;j++){
            scanf("%d",&n);
            arr[i][j]=n;
            printf("%d ",n);
            cnt+=n;
        }
        printf("%d\n",cnt);
        arr[i][c]=cnt;
    }
    for (int k=0;k<c+1;k++){
        ans=0;
        for (int l=0;l<r;l++){
            ans+=arr[l][k];
        }
        if (k<c){printf("%d ",ans);}
        if (k==c){printf("%d\n",ans);}
    }
    return 0;
}



Measured memory_bytes: 3228
code = """

# distutils: language=c++
# distutils: include_dirs=[/home/USERNAME/.local/lib/python3.8/site-packages/numpy/core/include, /opt/atcoder-stl]
# cython: boundscheck=False
# cython: wraparound=False

from libc.stdio cimport getchar, printf
from libcpp.vector cimport vector

cdef extern from *:
    ctypedef int MOD_t "998244353"
    ctypedef long long ll "long long"

cdef extern from "<atcoder/convolution>" namespace "atcoder":
    vector[int] convolution[M](vector[int] a, vector[int] b)
    vector[ll] convolution_ll(vector[ll] a, vector[ll] b)

cpdef vector[int] Conv(vector[int] a, vector[int] b):
    return convolution[MOD_t](a, b)

cpdef vector[ll] ConvL(vector[ll] a, vector[ll] b):
    return convolution_ll(a, b)

cdef inline vector[int] readint(int n) nogil:
    cdef int b, c
    cdef vector[int] *v = new vector[int]()
    for i in range(n):
        c = 0
        while 1:
            b = getchar() - 48
            if b < 0: break
            c = c * 10 + b
        v.push_back(c)
    return v[0]

cpdef vector[int] readInt(int n):
    return readint(n)

cdef inline void printlongn(vector[long] l, int n):
    for i in range(n): printf("%ld\\n", l[i])

cpdef void printLongN(vector[long] l, int n):
    printlongn(l, n)

cdef inline void printlong(vector[long] l, int n):
    for i in range(n): printf("%ld ", l[i])

cpdef void printLong(vector[long] l, int n):
    printlong(l, n)
"""


import os, sys, getpass

if sys.argv[-1] == 'ONLINE_JUDGE':
    code.replace("USERNAME", getpass.getuser())
    open('atcoder.pyx','w').write(code)
    os.system('cythonize -i -3 -b atcoder.pyx')
    sys.exit(0)


from atcoder import Conv, readInt, printLong

N,M = readInt(2)

A = readInt(N)
B = readInt(M)

C = Conv(A,B)

printLong(C, len(C))

Measured memory_bytes: 136232
#include <bits/stdc++.h>
#define r(i, n) for (ll i=0;i<n;i++)
#define ll long long
#define llc(n) ll n; cin >> n;
using namespace std;
int main() {
  llc(n);
  string s,t,x;
  cin >> s >> t;
  r(i,n) x=x+s.at(i)+t.at(i);
  cout << x << endl;
  return 0;
}

Measured memory_bytes: 256
//
//  111_a.cpp
//  test
//
//  Created by liuyuhan on 21/10/2018.
//  Copyright © 2018 liuyuhan. All rights reserved.
//

#include <stdio.h>
#include <iostream>

using namespace std;

int main() {
    char num[4];
    int n, num_i=0;
    cin >> n;
    while (n != 0) {
        int cur_n = n % 10;
        if (cur_n == 1) num[num_i] = '9';
        else if (cur_n == 9) num[num_i] = '1';
        else num[num_i] = '0' + cur_n;
        num_i++;
        n = n / 10;
    }
    for (int i = num_i - 1; i >= 0; i--) cout << num[i];
    cout << endl;
    return 0;
}


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

int main() {
  int a,b;
  cin >> a >> b;
  if((a == 1 && b == 2)||(a == 2 && b == 1)){
    cout << 3 << endl;
  }
  else if((a == 2 && b == 3)||(a == 3 && b == 2)){
    cout << 1 << endl;
  }
  else{
    cout << 2 << endl;
  }
}


Measured memory_bytes: 256
/*
[dp] N - Slimes
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int MAX_N = 400;
const ll INF = 1e18;

int N;
int a[MAX_N];
ll s[MAX_N + 1];
ll dp[MAX_N + 1][MAX_N + 1];

ll solve() {
    s[0] = 0;
    for (int i = 0; i < N; i++) {
        s[i + 1] = s[i] + a[i];
    }

    for (int i = 2; i <= N; i++) {
        for (int l = 0; l + i <= N; l++) {
            int r = l + i;
            dp[l][r] = INF;
            for (int m = l + 1; m < r; m++) {
                dp[l][r] = min(dp[l][r], dp[l][m] + dp[m][r] + s[r] - s[l]);
            }
        }
    }

    return dp[0][N];
}

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

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 1536
# coding: utf-8

def erastosthenes_table(n)
  # 0,1は素数(false)
  checked = Array.new(n+1,false)
  is_prime = Array.new(n+1,true)

  is_prime[0] = false
  is_prime[1] = false

  for i in 2..(Math.sqrt(n).floor)
    next if checked[i]

    is_prime[i] = true
    checked[i] = true

    j = 2
    for j in 2..(n/i)
      checked[i*j] = true
      is_prime[i*j] = false
    end
  end

  is_prime
end

$pn_table = erastosthenes_table(10**5+1)
$table = Array.new(10**5+1,0)

def is_prime?(n)
  $pn_table[n]
end

def like_2017?(n)
  is_prime?(n) and is_prime?((n+1)/2)
end

1.step(10**5,1).each do |e|
  if like_2017?(e) and e.odd?
    $table[e] = $table[e-1] + 1
  else
    $table[e] = $table[e-1]
  end
end

#lines = <<'EOS'
#6
#1 53
#13 91
#37 55
#19 51
#73 91
#13 49
#EOS
lines = $stdin.read
array = lines.split("\n")

Q = array[0].to_i

array[1..Q].each do |str|
  l,r = str.split(" ").map(&:to_i)
  puts $table[r] - $table[l-1]
end


Measured memory_bytes: 12652
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <cstring>

using namespace std;

int n, m;
bool bad[20001];

int main(){
    while (cin >> n >> m && n | m){
        vector<vector<int>> record(m, vector<int>(3));
        for (int i = 0; i < m; i++)
        {
            for (int j = 0; j < 3; j++)
            {
                cin >> record[i][j];
            }
        }
        sort(record.begin(), record.end());
        memset(bad, 0, sizeof(bad));
        bad[1] = true;
        for (auto & r : record){
            bad[r[2]] |= bad[r[1]];
        }
        cout << count(bad + 1, bad + 1 + n, true) << endl;
    }
}

Measured memory_bytes: 2148
#include<stdio.h>
    #define 	ll 			long long
    #define 	w(t)		int t; cin>>t; while(t--)  
	#define 	AsmShuvo()  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
			
    int main()
    {
    //AsmShuvo()
    	
    	int a;
    	scanf("%d", &a);
    	int x = a+a*a+a*a*a;
    	printf("%d", x);
		
     	return 0;
	}
	


Measured memory_bytes: 2132
#include<iostream>

using namespace std;

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

bool issq(int z){
    for(int i = 0; i * i <= z; i++){
        if (i * i == z) {
            return true;
        }
    }
    return false;
}

int main(){
    int n, d;
    cin >> n >> d;
    int x[n][d];
    rep(i, n)rep(j, d) cin >> x[i][j];
    int ans = 0;
    for(int i = 0; i < n - 1; i++){
        for(int j = i + 1; j < n; j++){
            int l = 0;
            rep(k, d) l += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            if (issq(l)) {
                ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
# C - 100 to 105
# https://atcoder.jp/contests/sumitrust2019/tasks/sumitb2019_c

x = int(input())
d, m = divmod(x, 100)

D = [0] * 5

for i in range(4, -1, -1):
  D[i], m = divmod(m, i + 1)

if d >= sum(D):
  print(1)
else:
  print(0)

Measured memory_bytes: 3060
import math
abcde = [int(input()) for i in range(5)]

abcde.sort(key=lambda x: (x % 10))

flag = False
ans = 0
for x in abcde:
    if x % 10 == 0 or flag:
        if x % 10 == 0:
            ans += x
        else:
            ans += ((x//10)+1)*10
    else:
        ans += x
        flag = True
print(ans)


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

using ll=long long; 

void solve(){
	int n;
	cin>>n;
	vector<double>a(n);
	for(int i=0; i<n; i++)cin>>a[i];
	double sum=0;
	for(int i=0; i<n; i++){
		sum+=(1.0/a[i]);
	}
	printf("%.8f\n", 1/sum);
}

signed main(){
	//while(1)
	solve();
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    println(
    getInts().mapIndexed { i, v -> v to i + 1 }
            .first { it.first == 0 }
            .second
    )
}



fun getInt() = readLine()!!.toInt()
fun getInts() = readLine()!!.split(" ").map { it.toInt() }

Measured memory_bytes: 36264
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    int n;cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll res = 0;
    rep(i,n) {
        while (true){
            if (a[i] % 2 == 0){
                res++;
                a[i]/=2;
            }
            else break;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <sstream>
#include <array>
#include <cmath>

template <typename T, typename U>
inline std::ostream& operator<<(std::ostream& out, const std::pair<T, U>& p) {
    out << p.first << ' ' << p.second;
    return out;
}

template <typename T, typename U>
inline std::istream& operator>>(std::istream& in, std::pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

template <typename T>
inline std::ostream& operator<<(std::ostream& out, const std::vector<T>& v) {
    if (v.empty()) {
        return out;
    }
    if (v.begin() != v.end()) {
        out << v.front();
    }
    for (auto it = ++v.begin(); it != v.end(); ++it) {
        out << ' ' << *it;
    }
    return out;
}

template <typename T>
inline std::istream& operator>>(std::istream& in, std::vector<T>& v) {
    for (auto& i : v) {
        in >> i;
    }
    return in;
}

void Solve(std::istream& in, std::ostream& out) {
    int n, l;
    in >> n >> l;

    std::vector<std::string> input(n);
    in >> input;
    std::sort(input.begin(), input.end());
    for (const auto& s : input) {
        std::cout << s;
    }
}

int main() {
    std::ios_base::sync_with_stdio(0);
    std::cin.tie(0);
    Solve(std::cin, std::cout);
    return 0;
}


Measured memory_bytes: 256
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n;
    cin >> n;
    vll vec(n);
    REP(i, n) cin >> vec.at(i);
    vll ans(n);
    for (int i = n-1; i >= 0; i--) {
        ll total = 0;
        for (int j = i+1; j <= n; j+=i+1) {
            total += ans.at(j-1);
        }
        if (vec.at(i) != total % 2) ans.at(i) = 1;
    }
    cout << count(ALL(ans), 1) << endl;
    if (count(ALL(ans), 1) == 0) {
        return 0;
    }
    vll out;
    REP(i, n) {
        if (ans.at(i) == 1) out.push_back(i+1);
    }
    REP(i, out.size()-1) {
        cout << out.at(i) << " ";
    }
    cout << out.at(out.size()-1) << endl;
    return 0;
}

Measured memory_bytes: 4980
n, m, c = map(int, input().split())
b = [int(i) for i in input().split()]
a = [list(map(int, input().split())) for i in range(n)]

Sum = 0
count = 0
for i in range(n):
    for j in range(m):
        Sum += a[i][j]*b[j]
    if Sum+c > 0:
        count += 1
    Sum = 0

print(count)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
bool bo[100];
#define ll long long int
int main()
{
	char c;
	cin>>c;
	if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u')
	{
		cout<<"vowel"<<endl;
	}
	else
	{
		cout<<"consonant"<<endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    int H,W;
    int eight[8];
    string S[50];
    cin >> H >> W;
    for(int i=0;i<H;i++) cin >> S[i];

    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
        int around = 0;
            if(S[i][j]=='.'){
                for(int k=-1;k<2;k++){
                    for(int l=-1;l<2;l++){
                        int x = j+k;
                        int y = i+l;
                        if(x>=0&&y>=0&&x<W&&y<H){
                            if(S[y][x]=='#') around++;
                        }
                    }
                }
            //cout << around << endl;
            S[i][j] = char(around+'0');
            }
        }
    }
    for(int i=0;i<H;i++) cout << S[i] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

void solve(){
    array<double,4> x,y;
    rep(i,4) cin>>x[i]>>y[i];

    double x1 = x[1]-x[0], x2 = x[3]-x[2];
    double y1 = y[1]-y[0], y2 = y[3]-y[2];
    double c = x1 * y2 - x2 * y1;

    if(abs(c) < eps){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

int main(){
    int n;cin>>n;
    rep(i,n){
        solve();
    }
}

Measured memory_bytes: 3176
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define all(a)                      a.begin(), a.end()
#define pb                          push_back
#define ll							long long
#define index(a)            		order_of_key(a)
#define value(a)					find_by_order(a)
#define count_1 					__builtin_popcount
#define mod(x, m)					((((x) % (m)) + (m)) % (m))
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
vector<int> v[1000000];
bool visited[1000000];
int maxd[1000000];

int dfs(int u){
	visited[u]=true;
	if(v[u].size()==0)maxd[u]=0;
	for(int x:v[u]){
		if(!visited[x]){
			maxd[u]=max(maxd[u],dfs(x)+1);
		}
		else maxd[u]=max(maxd[u],1+maxd[x]);
	}
	return maxd[u];
}
int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);cout<<setprecision(12);
	int n,m,x,y;
	cin>>n>>m;
	fill(maxd+1,maxd+n+1,INT_MIN);
	for(int i=0;i<m;i++){
		cin>>x>>y;
		v[x].pb(y);
	}

	for(int i=1;i<=n;i++){
		if(!visited[i]){
			dfs(i);
		}
	}
	int ans=INT_MIN;
	for(int i=1;i<=n;i++)ans=max(ans,maxd[i]);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 31488
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define ll long long int
#define INF 1000000000 
#define fill(space,a) memset(space,a,sizeof(space))

#define optimize() ios_base::sync_with_stdio(0);
#define MAXW 100005
#define MAXN 105
int N, W;
vector <int> w, v;
ll dp[MAXN][MAXW];

int main()
{
	optimize();
	//freopen("input.txt", "r", stdin);
	cin >> N >> W;
	v.resize(N + 1); w.resize(N + 1);
	for (int i = 1; i <= N; i++) {
		cin >> w[i] >> v[i];
	}
	fill(dp, 0);
	
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= W; j++) {
			dp[i][j] = dp[i - 1][j];
			if (j - w[i] >= 0) dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i]] + v[i]);
		}
	}
	ll ans = 0LL;
	for (int i = 1; i <= W; i++) ans = max(ans, dp[N][i]);
	cout << ans << endl;
	

	return 0;
}

Measured memory_bytes: 82304
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

template <class T, class U>
inline bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

int main() {
  int K;
  std::string S;
  std::cin >> K >> S;
  if (S.size() <= K) {
    std::cout << S << '\n';
  }
  else {
    std::cout << S.substr(0, K) + "..." << '\n';
  }
  return 0;
}


Measured memory_bytes: 3632
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int X = sc.nextInt();
		int Y = sc.nextInt();

		sc.close();

		
		
		int b = 2 * X - Y;
//		if ((X+Y) % 3 != 0) {
		if ((b % 3 != 0)) {
			out.println(0);
			return;
		}
		b /= 3;

		int a = X - 2 * b;
//		int a = (2*Y - X)/3;

		if(a<0 || b<0) {
			out.println(0);
			return;
		}
		
		ModInteger bunshi = new ModInteger(a + b).factorial();
		ModInteger bunbo = new ModInteger(a).factorial().multiply(new ModInteger(b).factorial());

		out.println(bunshi.divide(bunbo));

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}
}

class ModInteger {
	public static long MOD = 1_000_000_007;
	private long x;

	public ModInteger(long n) {
		x = (n % MOD);
	}

	/** 和 */
	public ModInteger add(long augend) {
		return new ModInteger((x + augend) % MOD);
	}

	/** 和 */
	public ModInteger add(ModInteger augend) {
		return add(augend.x);
	}

	/** 逆元 */
	public ModInteger inv() {
		return pow(MOD - 2);
	}

	/** 商 */
	public ModInteger divide(long divisor) {
		return divide(new ModInteger(divisor));
	}

	/** 商 */
	public ModInteger divide(ModInteger divisor) {
		return multiply(divisor.inv());
	}

	/** 積 */
	public ModInteger multiply(long muultiplicand) {
		return new ModInteger((x * muultiplicand) % MOD);
	}

	/** 積 */
	public ModInteger multiply(ModInteger multiplicand) {
		return multiply(multiplicand.x);
	}

	/** 累乗 O(logN) */
	public ModInteger pow(long n) {
		// 繰り返し二乗法
		if (n == 0) {
			return new ModInteger(1);
		}
		ModInteger a = pow(n / 2);
		a = a.multiply(a);
		if (n % 2 == 1) {
			a = a.multiply(x);
		}
		return a;
	}

	/** 差 */
	public ModInteger subtract(long subtrahend) {
		return new ModInteger((x - subtrahend + MOD) % MOD);
	}

	/** 差 */
	public ModInteger subtract(ModInteger subtrahend) {
		return subtract(subtrahend.x);
	}

	/** 階乗 N!のときO(N) */
	public ModInteger factorial() {
		long ans = 1;
		for (long n = 2; n <= x; n++) {
			ans *= n;
			ans %= MOD;
		}
		return new ModInteger(ans);
	}

	@Override
	public boolean equals(Object o) {
		if (o instanceof ModInteger) {
			return x == ((ModInteger) o).x;
		}
		return false;
	}

	public boolean equals(long l) {
		return x == (l % MOD);
	}

	@Override
	public int hashCode() {
		return Long.hashCode(x);
	}

	public int compareTo(long val) {
		return Long.compare(x, val);
	}

	public int compareTo(ModInteger val) {
		return compareTo(val.x);
	}

	public long longValue() {
		return x;
	}

	@Override
	public String toString() {
		return Long.toString(x);
	}

	public static ModInteger valueOf(long x) {
		return new ModInteger(x);
	}

}


Measured memory_bytes: 23636
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
public class Main {
	public static void main(String[] args){
		int i, q, order, x;
		Set<Integer> set = new HashSet<Integer>();
		try (Scanner sc = new Scanner(System.in)) {
			q = sc.nextInt();
			for(i = 0; i < q; i++) {
				order = sc.nextInt();
				x = sc.nextInt();
				if(order == 0) {
					set.add(x);
					System.out.println(set.size());
				}else if(order == 1) {
					if(set.contains(x)) {
						System.out.println(1);
					}else {
						System.out.println(0);
					}
				}else {
					set.remove(x);
				}
			}
		}
	}
}


Measured memory_bytes: 162464
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define SORT(i) sort((i).begin(), (i).end())
#define INF 2000000000
constexpr ll mod = 1e9 + 7;
 
int main(){
    int H, W;
    cin >> H >> W;
    vector<vector<char>> trout(H, vector<char>(W));
    vector<int> width(W,0);
    vector<int> height(H,0);
    for (int i = 0; i < H;++i){
        for (int j = 0; j < W;++j){
            cin >> trout[i][j];
        }
    }
    for (int i = 0; i < H;++i){
        int a = 0;
        for (int j = 0; j < W;++j){
            if(trout[i][j]=='.'){
                ++a;
            }
        }
        if(a != W){
            ++height[i];
        }
    }

    for (int i = 0; i < W;++i){
        int b = 0;
        for (int j = 0; j < H;++j){
            if(trout[j][i] == '.'){
                ++b;
            }
        }
        if(b != H){
            ++width[i];
        }
    }

        for (int i = 0; i < H; ++i){
            if (!height[i]) continue;
            for (int j = 0; j < W; ++j){
                if(j == W-1){
                    if(width[j]){
                        cout << trout[i][j] << "\n";
                    }
                    else {
                        cout << "\n";
                        continue;
                    }
                }
                else {
                    if(width[j]){
                        cout << trout[i][j];
                    }
                    else {
                        continue;
                    }
                }
            }
        }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int h[2],k[2],a,b,c,d;
	int kou,kennzirou;
	scanf("%d %d",&h[0],&h[1]);
	scanf("%d %d",&k[0],&k[1]);
	scanf("%d %d %d %d",&a,&b,&c,&d);
	
	kou=(a*h[0])+(b*h[1])+(h[0]/10*c)+(h[1]/20*d);
	kennzirou=(a*k[0])+(b*k[1])+(k[0]/10*c)+(k[1]/20*d);
	
		if(kou>kennzirou){printf("hiroshi\n");
		}else if(kou<kennzirou){printf("kenjiro\n");
	}else if(kou==kennzirou){printf("even\n");}
	
	
	return 0;
}

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

int main() {
    int n; cin >> n;
    vector<int> a(n+2);
    rep(i, n+1){
        if (i == 0) {
            a[i] = 0;
            continue;
        }
        cin >> a[i];
    } 
    a[n+1] = 0;
    int sum = 0;
    for (int i = 1; i < n+2; i++) {
        sum += abs(a[i]-a[i-1]);
    }
    for (int i = 1; i < n+1; i++) {
        cout << (sum + abs(a[i+1]-a[i-1]) - (abs(a[i]-a[i-1]) + abs(a[i+1]-a[i]))) << endl;
    }
}

Measured memory_bytes: 3728
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main(){
    double r;
    cin >> r;
    cout << fixed;
    cout << setprecision(6);
    cout << r*r*M_PI << " " << 2*r*M_PI << endl;
    return 0;
}


Measured memory_bytes: 3268
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
	string s, S = "AKIHABARA";
	cin >> s;
	int i = 0;
	auto Check = [&](string s) {
		for (auto c : S) {
			if (i < s.size() && s[i] == c) {
				i++;
			}
			else if (c == 'A') {
				continue;
			}
			else {
				return false;
			}
		}
		if (i != s.size()) return false;
		return true;
	};
	cout << (Check(s) ? "YES" : "NO") << endl;
	return 0;
}

Measured memory_bytes: 256