akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int dx[] = {0,1,0,-1};
int dy[] = {1,0,-1,0};
int main() {
  int n,m;
  cin >> n >> m;
  int a,b,c;

  vector<tuple<int,int,int>> hs,vs;
  map<int,int> ix,iy;
  ix[0] = iy[0] = 0;
  rep(i,n){
    cin >> a >> b >> c;
    ix[a] = ix[b] = iy[c] = 0;
    hs.emplace_back(a,b,c);
  }
  rep(i,m){
    cin >> a >> b >> c;
    ix[a] = iy[b] = iy[c] = 0;
    vs.emplace_back(a,b,c);
  }
  vector<int> xs,ys;
  for(auto& i:ix){
    i.second = xs.size();
    xs.push_back(i.first);
  }
  for(auto& i:iy){
    i.second = ys.size();
    ys.push_back(i.first);
  }
  int h = xs.size()*2, w = ys.size()*2;
  vector<vector<int>> d(h,vector<int>(w));
  rep(i,n){
    int a,b,c; tie(a,b,c) = hs[i];
    a = ix[a]*2; 
    b = ix[b]*2;
    c = iy[c]*2;
    for(int x = a; x<=b; ++x) d[x][c] = -1;
  }
  rep(i,m){
    int a,b,c; tie(a,b,c) = vs[i];
    a = ix[a]*2; 
    b = iy[b]*2;
    c = iy[c]*2;
    for(int y = b; y<=c; ++y) d[a][y] = -1;
  }
  queue<P> q;
  auto push = [&](int x,int y){
    if(x<0||h<=x||y<0||w<=y) return;
    if(d[x][y]!=0) return;
    d[x][y] = 1;
    q.emplace(x,y);
  };
  push(ix[0]*2,iy[0]*2);
  while(!q.empty()) {
    P p = q.front(); q.pop();
    int x = p.first, y = p.second;
    rep(i,4) push(x+dx[i],y+dy[i]);
  }

  ll ans = 0;
  rep(x,h)rep(y,w){
    if(d[x][y]!=1) continue;
    if(x==0||h-1==x||y==0||w-1==y) {
      cout << "INF" << endl;
      return 0;
    }
    if(x%2==0||y%2==0) continue;
    ans += ll(xs[x/2+1]-xs[x/2])*ll(ys[y/2+1]-ys[y/2]);
  }
  cout << ans << endl;
}


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

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("input.txt","r",stdin);
    int h,w,k,ans=0;
    cin>>h>>w>>k;
    char ch[h][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++) cin>>ch[i][j];
    }
    for(int maskR=0;maskR<(1<<h);maskR++){
        for(int maskC=0;maskC<(1<<w);maskC++){
            int black=0;
            for(int i=0;i<h;i++){
                for(int j=0;j<w;j++){
                    if(((maskR>>i)&1)!=1 && ((maskC>>j)&1)!=1 && ch[i][j]=='#') black++;
                }
            }
            if(black==k) ans++;
        }
    }

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



Measured memory_bytes: 3632
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

typedef long long ll;

using namespace std;

int mato[1001],n,m,ans;

void nibun(){
    
}

void solve(){
    vector<int> v;
    ans=0;
    
    for(int i=0;i<n;i++)
        scanf("%d",&mato[i]);
    
    mato[n]=0;
    
    sort(mato,mato+n+1);
    
    for(int i=0;i<=n;i++)
        for(int j=i;j<=n;j++)
            if(mato[i]+mato[j]<=m)
                v.push_back(mato[i]+mato[j]);
    
    sort(v.begin(),v.end());
    
    v.push_back(200000010);
    
    for(int i=0;i<v.size();i++){
        
        int l=0,r=(int)v.size()-1,s=m-v[i];
        
        if(s<=0) continue;
        
        while(1){
            if(l==r-1 || v[l]==v[r])
                break;
            
            if(v[(l+r)/2]>s)
                r=(l+r)/2;
            else
                l=(l+r)/2;
        }
        
        ans=max(ans,v[l]+v[i]);
    }
    
    printf("%d\n",ans);
    
    return;
}

int main(){
    
    while(1){
        scanf("%d%d",&n,&m);
        if(n+m==0)
            break;
        solve();
    }
    
    return 0;
}

Measured memory_bytes: 5008
#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>

using namespace std;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

const int OO = (int) 2e9;
const double eps = 1e-9;

const int N = 100005;

int n, mod;
vi adj[N];
int down[N];
int up[N];

int dfsDown(int cur, int par = -1) {
	ll res = 1;
	for (int to : adj[cur]) {
		if (to == par)
			continue;
		(res *= dfsDown(to, cur) + 1) %= mod;
	}
	return down[cur] = res;
}

void dfsUp(int cur, int par = -1, ll prv = 1) {
	up[cur] = prv;
	vi suf(SZ(adj[cur]), 1);
	ll val = 1;
	for (int i = SZ(adj[cur]) - 1; i >= 0; i--) {
		int to = adj[cur][i];
		suf[i] = val;
		if (to == par)
			continue;
		(val *= down[to] + 1) %= mod;
	}
	val = 1;
	for (int i = 0; i < SZ(adj[cur]); i++) {
		int to = adj[cur][i];
		if (to == par)
			continue;
		dfsUp(to, cur, (val * prv % mod * suf[i] + 1) % mod);
		(val *= down[to] + 1) %= mod;
	}
}

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	cin >> n >> mod;
	for (int i = 1; i < n; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	dfsDown(0);
	dfsUp(0);
	for (int i = 0; i < n; i++) {
		cout << (up[i] * 1LL * down[i]) % mod << "\n";
	}
	return 0;
}


Measured memory_bytes: 16512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f
#define endl '\n'
#define ll long long
#define int long long
#define f first
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << endl
#define debug2(x, y) cout << "DEBUG " << x << " " << y << endl
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< endl
#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << endl
using namespace std;
typedef pair<ll, ll> pii;
typedef vector<vector<ll>> mat;
const ll mod = 1e9+7;
const int MAXN = 1e6+5;



int32_t main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	int ans = 0;
	for(int i = 1; i < n; i++)
		if(s[i] != s[i-1]) ans++;
	if(s[n] != s[n-1]) ans++;
	cout << ans << endl;
	
}


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

int main(){
  int k,ans=0;
  string s;cin>>k>>s;
  if(s.size()<=k) cout<<s;
  else{
    REP(i,k) cout<<s.at(i);
    cout<<"...";
  }

}

Measured memory_bytes: 3636
y,x = map(int,raw_input().split())
list =[]
last = [ 0 for a in range(x+1)]

for a in range(y):
    tmp = map(int,raw_input().split())
    list.append(tmp + [sum(tmp)])
    for i,b in enumerate(list[a]):
        last[i] = last[i] + b

for c in list:
    print " ".join(map(str,c))
print " ".join(map(str,last))

Measured memory_bytes: 4296
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		
		int[] a = new int[M];
		int[] b = new int[M];
		int[] count = new int[N+1];
		for(int j=1; j<=N; j++){
			count[j] = 0;
		}
		for(int i=0; i<M; i++){
			a[i]  = sc.nextInt();
			b[i]  = sc.nextInt();
			count[a[i]]++;
			count[b[i]]++;
		}
		
		boolean ans = true;
		for(int j=1; j<=N; j++){
			if(count[j]%2 != 0){
				ans = false;
				break;
			}
		}

		if(ans==true){
			System.out.print("YES");
		}else{
			System.out.print("NO");
		}
		
	}

}


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

const bool DEBUG = false;

int K, X;

void input() { cin >> K >> X; }

int main(int argc, char const *argv[]) {
  input();
  int leftmost = X - K + 1;
  int rightmost = X + K - 1;
  for (int i = leftmost; i <= rightmost; i++) {
    cout << i << " ";
  }
  cout << endl;

  return 0;
}


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

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

    double D, T, S;
    cin >> D >> T >> S;

    if(D / S <= T){
        cout << "Yes";
    }
    else{
        cout << "No";
    }

    


}

Measured memory_bytes: 3728
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int a[3];
  REP(i,3) cin >> a[i];
  sort(a,a+3);
  if(a[0]+a[1]==a[2]) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ss second
#define ff first
#define Mem(x,val) memset(x,val,sizeof x)
#define pb push_back
#define all(v) v.begin(),v.end()
#define unik(v)  v.erase(unique(v.begin(),v.end()),v.end())
#define cerr(x) cerr << __LINE__ << " th Line : " << #x << " = " << x << "\n"
#define endl '\n'
#define SZ(a) ((int)a.size())
using namespace std;
typedef pair<int, int> pi32;
typedef pair<ll, ll> pi64;
typedef vector<int> vi32;
typedef vector<ll> vi64;
typedef vector<pi32> vp32;
typedef vector<pi64> vp64;
const ll mod = 1e9 + 7;
const ll MX = 100, inf = 1e9 + 7;

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

	string s;
	cin >> s;
	if (s == "ABC")cout << "ARC\n";
	else cout << "ABC\n";

	return 0;
}

Measured memory_bytes: 3652
a,b,c,d = list(map(int,input().split()))
if (a<=0 and 0<=b) or (c<=0 and 0<= d):
    ls = [0]
else:
    ls = []

ls.append(a*c)
ls.append(a*d)
ls.append(b*c)
ls.append(b*d)

ans = max(ls)
print(ans)

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

using namespace std;
using ll = long long;

#pragma region Macros
#define FOR(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) FOR(i, 0, n)

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

template <class T> string join(const T &v, const string delim = ",")
{
    if (v.empty())
        return "";

    ostringstream res;
    res << v[0];
    for (int i = 1; i < v.size(); i++)
    {
        res << delim << v[i];
    }
    return res.str();
}

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << ":" << #x << " = " << (x) << endl;
#else
#define dbg
#endif

#pragma endregion Macros

int main()
{
    string S;
    cin >> S;

    vector<ll> c(3);
    for(int i=0;i<S.size();i++){
        c[S[i] - 'a']++;
    }

    sort(c.begin(), c.end());

    string ans;
    if (c[2] - c[0] > 1) {
        ans = "NO";
    }else{
        ans = "YES";
    }

    cout << ans << endl;
}


Measured memory_bytes: 3752
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors



n = int(input())
a=make_divisors(n)
if len(a)%2==0:
    print(a[-1]+a[-2]-2)
else:
    print(a[-1]*2-2)


Measured memory_bytes: 3268
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define MAXH 1005
#define MAXW 1005
#define mod 1000000007
bool wall[MAXH][MAXW];
ll dp[MAXH][MAXW];
int main() {
    int h, w;
    cin >> h >> w;
    for (int i = 1; i <= h; i++) {
        string s; 
        cin >> s;
        for (int j = 1; j <= w; j++) {
            if (s[j - 1] == '#') {
                wall[i][j] = true;
            }
            else {
                wall[i][j] = false;
            }
        }
    }
    memset(dp, 0, sizeof(dp));
    dp[1][1] = 1;
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            if (!wall[i][j + 1]) {
                dp[i][j + 1] = (dp[i][j] + dp[i][j + 1]) % mod;
            }
            if (!wall[i + 1][j]) {
                dp[i + 1][j] = (dp[i][j] + dp[i + 1][j]) % mod;
            }
        }
    }
    cout << dp[h][w] << endl;
    return 0;
}

Measured memory_bytes: 12480
#include <bits/stdc++.h>
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> inline bool change(T& a, T b) { if (a != b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
int main(){
    ll n; cin >> n;
    vector<ll> a(n); 
    ll x=0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        x^=a[i];
    }
    for(int i=0;i<n;i++){
        cout << ((x)^a[i]);
        if(i!=n-1) cout << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 4844
s = list(input())
ew = []
sn = []
for i in s:
    if i == "E" or i == "W":
        ew.append(i)
    else:
        sn.append(i)
if len(set(ew)) == 1 or len(set(sn)) == 1:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 9036
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cstring>
#include <unordered_set>

#define NMAX 100001
#define MOD 1000000007
#define INF 2000000000

#define MIN(a, b) (a < b ? a : b)
#define MAX(a, b) (a > b ? a : b)

typedef unsigned long long ull;

using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;
	if (a >= 10 || b >= 10)
		cout << -1 << '\n';
	else
		cout << a * b << '\n';
	return 0;
}

Measured memory_bytes: 256
// ref. https://atcoder.jp/contests/dp/submissions/3937090

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define sz(x) (ll)(x).size()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;
typedef vector<ll> vl;
typedef vector<P> vp;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

const ll MAX_N = 1e5+5;
vector<ll> g[MAX_N];
ll dp[MAX_N];
ll in[MAX_N]; // indegree

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll n, m;
  cin >> n >> m;
  rep(iter, m) {
    ll x, y;
    cin >> x >> y;
    --x; --y;
    g[x].push_back(y);
    ++in[y];
  }
  queue<ll> q;
  rep(i, n) {
    if (in[i] == 0) { // starting nodes
      q.push(i);
    }
  }
  // Here, we calculate distance from starting nodes
  while (!q.empty()) {
    ll v = q.front(); q.pop();
    for (ll nv : g[v]) {
      chmax(dp[nv], dp[v]+1);
      --in[nv];
      if (in[nv] == 0) {
        q.push(nv);
      }
    }
  }
  ll ans = 0;
  rep(i, n) {
    chmax(ans, dp[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 7296
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;

void main()
{
    auto nk = readln.split.to!(int[]);
    auto N = nk[0];
    auto K = nk[1];
    auto as = readln.split.to!(long[]);

    auto cs = new long[](N);
    foreach (i, a; as) {
        if (i) cs[i] = cs[i-1];
        if (a > 0) cs[i] += a;
    }

    long max_r, sum_a;
    foreach (a; as[0..K]) sum_a += a;
    max_r = max(0, sum_a) + cs[$-1] - cs[K-1];
    foreach (i, a; as[K..$]) {
        sum_a += -as[i] + a;
        auto c = cs[$-1] + cs[i] - cs[i+K];
        max_r = max(max_r, c, sum_a + c);
    }
    writeln(max_r);
}

Measured memory_bytes: 7128
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>

using namespace std;

void solve()
{
	unsigned long long int N, M;
	cin >> N >> M;
	unsigned long long int ans = 0;
	if (M <= 2 * N)
	{
		ans += M / 2;
		cout << ans << endl;
	}
	else
	{
		ans += N;
		M -= 2 * N;
		ans += M / 4;
		cout << ans << endl;
	}
}

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

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        double a = inp.nextDouble();
        double b = inp.nextDouble();
        inp.close();
        double d = (a + b) / 2.0;
        System.out.println((int)Math.ceil(d));
    }
}

Measured memory_bytes: 22612
n=int(input())
count=0
countmax=0
for i in range(n):
  a,b = map(int,input().split())
  if a==b:
    count+=1
  else:
    countmax=max(countmax,count)
    count=0
countmax=max(countmax,count)    
if countmax>2:
  print("Yes")
else:
  print("No")


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

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

	int n = s.size(), l = 0, r = 0; bool ok = false;
	for (int i = 0; i < n; i++) {
		if (s[i] == s[i + 1]) {
			l = i + 1;
			r = i + 2;
			ok = true;
			break;
		}

		if (i < n - 2 && s[i] == s[i + 2]) {
			l = i + 1;
			r = i + 3;
			ok = true;
			break;
		}
	}
	if (ok)cout << l << ' ' << r << endl;
	else cout << -1 << ' ' << -1 << endl;

	return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
typedef long long int ll;
int main() {
	ll n;
	cin>>n;
	string s;
	cin>>s;
	ll red=0;
	for(char c: s){
		
		if(c=='R') red++;
	}
	ll white=n-red,op=0;
	for(ll i=0;i<red;i++){
		if(s[i]!='R')	op++;
	}
	cout<<op<<endl;
	return 0;
}


Measured memory_bytes: 3732
n,q=map(int,input().split())
s="0"+input()+"0"
a=[list(input().split())for i in range(q)]
l=0
r=n+1
for i in range(q-1,-1,-1):
    t,d=a[i]
    if t==s[l] and d=="R":
        l-=1
    elif t==s[l+1] and d=="L":
        l+=1
    if t==s[r] and d=="L":
        r+=1
    elif t==s[r-1] and d=="R":
        r-=1
print(max(0,r-l-1))

Measured memory_bytes: 26832
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;
 
int gcd(int x,int y){
    if(y==0)return x;

    return gcd(y,x%y);
}
int lcm(int x,int y){
    return x*y/gcd(x,y);
}

int main(){

    int N;
    cin>>N;
    cout<<(N-2)*180<<endl;
    return 0;
}

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

int main(){
	long long n, k, ans;
	cin >> n >> k;
	vector<int> h(n);
	
	for(int i=0; i<n; i++){
		cin >> h[i];
	}

	sort(h.begin(), h.end(), greater<int>());
	ans = 0;
	for(int i=k; i<n; i++){
		ans += h[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define vi vector<int>
#define vvi vector<vi>
#define pi pair<int, int>
#define rep(i,a,b) for (int i = a; i < b; i++)
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define endl "\n"
#define umap unordered_map<int, int>
#define uset unordered_set<int>
#define MOD 1000000007
using namespace std;

int main()
{
	FAST_IO;
	string n;
	cin >> n;
	ll len = n.length();
	ll sum = 0;
	for (ll i = len - 1 ; i >= 0 ; i--)
	{
		sum += (n[i] - '0');
	}
	if (sum % 9 == 0)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}

Measured memory_bytes: 3644
#include<stdio.h>

int na,nb,nc,mina,minb,ans,a[100001],b[100001],c,x,y;

int main(){
  mina=minb=0x7fffffff;
  scanf("%d%d%d",&na,&nb,&nc);
  for(int i=0;i<na;i++){
    scanf("%d",&a[i]);
    if(mina>a[i]){
      mina=a[i];
    }
  }
  for(int i=0;i<nb;i++){
    scanf("%d",&b[i]);
    if(minb>b[i])minb=b[i];
  }
  ans=mina+minb;
  for(int i=0;i<nc;i++){
    scanf("%d%d%d",&x,&y,&c);
    if(a[x-1]+b[y-1]-c<ans)ans=a[x-1]+b[y-1]-c;
  }
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
	int n;
	cin >> n;
	string s[n];
	REP(i,n) cin >> s[i];
	int cnt[n][26] = {};
	REP(i,n) REP(j,s[i].length()) cnt[i][s[i][j] - 'a']++;
	int ans[26];
	REP(i,26) ans[i] = INF;
	REP(i,n) REP(j,26) ans[j] = min(ans[j], cnt[i][j]);
	string res;
	REP(i,26) REP(j,ans[i]) res += 'a' + i;
	cout << res << endl;
}

Measured memory_bytes: 256
from heapq import heapify, heappop, heappush


def solve(n, aaa, bbb):
    q = [(-b, i) for i, b in enumerate(bbb) if b != aaa[i]]
    heapify(q)
    ans = 0
    while q:
        b, i = heappop(q)
        b = -b - aaa[i]
        d, b = divmod(b, bbb[(i - 1) % n] + bbb[(i + 1) % n])
        if d == 0:
            return -1
        b += aaa[i]
        bbb[i] = b
        ans += d
        if b != aaa[i]:
            heappush(q, (-b, i))
    return ans


n = int(input())
aaa = list(map(int, input().split()))
bbb = list(map(int, input().split()))
print(solve(n, aaa, bbb))


Measured memory_bytes: 124764
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<list>
#include<set>
#include<numeric>

#define MOD 1000000007

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int board[100010];

int main()
{
	int N;  
	while (1) {
		cin >> N;
		if (N == 0)break;
		int ans = 0;

		for (int i = 0; i < N; i++) {
			cin >> board[i];
			if (i % 2 == 1) {
				for (int j = i - 1; j >= 0; j--) {
					if (board[j] == board[i])break;
					board[j] = board[i];
				}
			}
		}
		for (int i = 0; i < N; i++) {
			if (board[i] == 0)ans++;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3380
import sys
input = sys.stdin.buffer.readline

N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]

AB.sort(key = lambda x: x[1])

sum_a = 0
for a, b in AB:
  sum_a += a
  if sum_a > b:
    print("No")
    exit()
print("Yes")

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

#define N 1000000007

int main(){
  int n, m;
  cin >> n >> m;
  vector<int>safe(n+1, true);
  for (int i=0; i<m; ++i){
    int a; cin >> a;
    safe[a]=false;
  }
  vector<long long int>dp(n+1);
  dp[0] = 1;
  for (int i=0; i<n; i++){
    for (int j=i+1; j<=min(n,i+2); ++j){
      if(safe[j]){
        dp[j]+=dp[i];
        dp[j]%=N;
      }
    }
  }
  cout << dp[n] << endl;
  return 0;
}

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

using namespace std;

int n;

string s;

set<string> st;
int main()
{
	cin >> n;
	for(int i = 0 ; i < n ; ++i)
	{
		cin >> s;
		st.insert(s);
	}
	cout << st.size() << endl;
	return 0;
}

Measured memory_bytes: 19180
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<double, long long> pdl;

const long double pi = 3.141592653589793;

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007

int main() {
  std::ios::sync_with_stdio(false);
  //freopen("input.in","r",stdin);
  //freopen("output.out","w",stdout);
  int n, x;cin>>n;
  vector<int> v;
  while (n--) {
      cin>>x;
      v.pb(x);
  }

  vector<int> B;
  int sum = 0;
  rep(i, v.size()) {
      sum += v[i];
  }

  if(sum%10 != 0) {
      cout<<sum<<endl;
      return 0;
  }

  rep(i, v.size()) {
      if(v[i]%10 != 0) B.pb(v[i]);
  }

  if(B.size() == 0) {
      cout<<"0"<<endl;
      return 0;
  }

  int minm = 1000;
  rep(i, B.size()) minm = min(minm, B[i]);

  cout<<sum-minm<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int main() {
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;


	int a_min = min(a, c*2);
	int b_min = min(b, c*2);
	int ab_min = min(a+b, c*2);

	int z = min(x, y);
	int total = ab_min * z + a_min * (x - z) + b_min * (y - z);
	cout << total << endl;

	return 0;
}


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

template<class T>
class UnionFindTree{
public:
    UnionFindTree(const T N){
        tree = std::vector<T>(N);
        for(T i=0; i<N; ++i){
            tree[i] = i;
        }
    }

    T root(const T idx){
        T tmp = idx;
        std::stack<T> stack;
        while(tree[tmp] != tmp){
            stack.push(tmp);
            tmp = tree[tmp];
        }
        while(!stack.empty()){
            tree[stack.top()] = tmp;
            stack.pop();
        }
        return tmp;
    }

    void merge(const T idx1, const T idx2){
        tree[root(idx1)] = root(idx2);
    }

    bool same(const T idx1, const T idx2){
        return root(idx1) == root(idx2);
    }

private:
    std::vector<T> tree;
};



int main(int argc, char *argv[]){
    int N, M;
    std::cin >> N >> M;
    UnionFindTree<int> tree(N);
    int X,Y,Z;
    for(int i=0; i<M; ++i){
        std::cin >> X >> Y >> Z;
        --X; --Y;
        tree.merge(X,Y);
    }
    std::vector<int> roots(N,0);
    for(int i=0; i<N; ++i){
        roots[tree.root(i)] = 1;
    }
    int cost = 0;
    for(auto &element : roots){
        cost += element;
    }
    std::cout << cost << std::endl;

    return 0;
}


Measured memory_bytes: 1152
/**
 *   author: Shubham Srivastava
 *   created: 31 May 2020  17:58:05
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define MOD 1000000007
#define INF 0x7fffffff
#define sorti(v) sort(v.begin(),v.end())
#define sortd(v) sort(v.rbegin(),v.rend())
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
ll parent[2000005];

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    long double a,b;cin>>a>>b;
    long double res = a*b;
    long long ans = res;
    cout<<ans;
return 0;
}

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

void solve(long long A, string op, long long B){
	if (op == "+") {
		cout << A + B << endl;
	}	else {
		cout << A - B << endl;
	}
}

int main(){	
	long long B;
	string op;
	long long A;
	scanf("%lld",&A);
	cin >> op;
	scanf("%lld",&B);
	solve(A, op, B);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N;
  cin >> N;
  
  vector<int> card(N);
  
  for (int i = 0; i < N ; i++) {
    cin >> card.at(i);
  }
  
  int M1 = 0;
  int M2 = 0;
  int M3 = 0;
  
  for (int i = 0; i < N ; i++) {
    for (int j = 0; j < N ; j++) {
      if (card.at(j) > M2) {
        M2 = card.at(j);
        M3 = j;
      }
    }
    
    card.at(M3) = 0;
    
    if (i % 2 == 0) {
      M1 += M2;
    }
    else {
      M1 -= M2;
    }
    
    M2 = 0;
    M3 = 0;
    
  }
  
  cout << M1 << endl;
  
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const int MOD = 1000000007;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

int calc_digit(long long N) {
    int res = 0;
    while (N) {
        ++res;
        N /= 10;
    }
    return res;
}

vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res.push_back(N/i);
        }
    }
    // 小さい順に並び替える
    sort(res.begin(), res.end());
    return res;
}



int main() {

    long long n; cin >> n;
    vector<long long> v = enum_divisors(n);

    cout << calc_digit(v[v.size()/2]);

    return 0;
}


Measured memory_bytes: 3652
N, M = map(int, input().split())
As = list(map(int, input().split()))

ans = 0
numSts, numEns, sumEns = [0]*(2*M), [0]*(2*M), [0]*(2*M)
for i in range(N-1):
    A, B = As[i]-1, As[i+1]-1
    if A > B:
        B += M
    ans += B-A
    if B-A > 1:
        numSts[A+2] += 1
        numEns[B+1] += 1
        sumEns[B+1] += B-A-1

nums = [0]*M
num = 0
k = 0
for i in range(2*M):
    k += numSts[i] - numEns[i]
    num += k
    num -= sumEns[i]
    nums[i%M] += num

print(ans - max(nums))


Measured memory_bytes: 19312
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

int main() {
    IOS
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    bool inc = false, dec = false, flag = true;
    int ans = 1;
    for (int i = 0; i < n-1; i++) {
        if (flag && a[i] < a[i+1]) inc = true, flag = false;
        else if (flag && a[i] > a[i+1]) dec = true, flag = false;
        else if (flag) continue;
        if (inc && a[i] > a[i+1]) {
            ans++;
            inc = false, flag = true;
        } else if (dec && a[i] < a[i+1]) {
            ans++;
            dec = false, flag = true;
        }
    }
    cout << ans << endl;
}

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

int main() {
  string S;
  cin >> S;
  if (S=="SSS"){
  cout<<0<<endl;
  }
  else if (S=="RRR"){
  cout<<3<<endl;
  }
  else if (S=="SRR"){
  cout<<2<<endl;
  }
  else if (S=="RRS"){
  cout<<2<<endl;
  }
  else{
    cout<<1<<endl;
  }
}


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

#define MAXN 212345
#define int long long
#define pb push_back
#define inf LLONG_MAX
#define mp make_pair
#define pii pair<int,int>
#define f first
#define s second

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

   int n,k;
   cin>>n>>k;
   vector<pii> v(n);
   k--;

   for(int i=0;i<n;i++)cin>>v[i].f>>v[i].s;
   sort(v.begin(),v.end());
	for(int i=0;i<n;i++){
		//cout<<v[i].f<<" "<<v[i].s<<" "<<k<<endl;
		if(v[i].s>k){
			cout<<v[i].f<<endl;
			return 0;
		}
		k-=v[i].s;
	}

    return 0;
 
}











Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define int   long long
#define N 666666
#define inf 999999999999999999
int arr[N];
signed main(){
	int f=0;
	int a,b,c;cin>>c>>a>>b;
	for(int i=a;i<=b;i++){
		if(i%c==0) f=1;
	}
	if(f) cout<<"OK";else cout<<"NG";
 	return 0;
}
/**/

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

int main(){
    int n; cin >> n;
    bool zeroExist = false;
    vector <int> neg, s(n);
    long long ans=0;
    for(int i = 0; i < n; i++){
        cin >> s[i];
        if(s[i] > 0) ans += s[i];
        else if(!s[i]) zeroExist = true;
        else{
            s[i] *= -1;
            neg.push_back(s[i]);
            ans += s[i];
        }
    }
    if((neg.size() % 2) && (!zeroExist)){
        sort(s.begin(), s.end());
        ans -= 2 * s[0];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1276
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int inf=0x3f3f3f3f;
const int MOD=1e9+7;
const int maxn=1e5+10;
ll gcd(ll a, ll b){return (b==0)?a:gcd(b, a%b);}
bool isPrime(ll n){
    if(n<=3){
        return n>1;
    }
    if(n%6!=1&&n%6!=5){
        return false;
    }
    ll sqr=sqrt(n);
    for(ll i=5;i<=sqr;i+=6){
        if(n%i==0||n%(i+2)==0){
            return false;
        }
    }
    return true;
}
int dis[4][2]={0,1,0,-1,1,0,-1,0};
int read(){
    int x=0,f=1;char c=getchar();
    while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
    while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
    return x*f;
}


int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int x;cin>>x;
		n-=x;
	}
	if(n>=0)
	cout<<n<<endl;
	else
	cout<<-1<<endl;
}
 

Measured memory_bytes: 3648
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

int main() {
    int N, M; cin >> N >> M;
    vector<vector<int>> data(M,vector<int>(N));
    vector<int> p(M),counter(M);
    int k = 0,answer=0;
    for (int i = 0; i < M; i++) {
        cin >> k;
        for (int j = 0; j < k; j++) {
            cin >> data.at(i).at(j);
        }
    }
    for (int i = 0; i < M; i++) {
        cin >> p.at(i);
    }

    for (int bit = 0; bit < (1 << N); ++bit) {
        
        fill(counter.begin(), counter.end(), 0);
        for (int i = 0; i < N; ++i) {
            if (bit & (1 << i)) { 
                for (int j = 0; j < M; j++) {
                    auto itr = find(data.at(j).begin(), data.at(j).end(), i+1);
                    if (itr != data.at(j).end())counter.at(j)++;
                }
            }
        }

        for (int i = 0; i < M; i++) {
            if (counter.at(i) % 2 != p.at(i))break;
            if (i == M-1)answer++;
        }
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 3644
import sys
input = lambda: sys.stdin.readline().rstrip()
inp = sys.stdin.buffer.readline                                
def I(): return list(map(int,inp().split()))
m=10**9+7

n,k=I()
ans=1 
for i in range(k,n+1):
    ans+=i*(n-i+1)+1
    ans%=m
print(ans)
    
    





Measured memory_bytes: 63336
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string sS = System.Console.ReadLine().Trim();
            int iN = int.Parse(sS);
            List<string> lstJug = new List<string>() { "AC", "WA", "TLE", "RE", };
            Dictionary<string, int> dicJug = new Dictionary<string, int>()
            { { lstJug[0], 0 }, { lstJug[1], 0 }, { lstJug[2], 0 }, { lstJug[3], 0 }, };
            for (int j = 0; j < iN; j++)
            {
                dicJug[System.Console.ReadLine().Trim()] += 1; 
            }

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析 // 出力
            for (int j = 0; j < lstJug.Count; j++)
            {
                string sOut = lstJug[j] + " x " + dicJug[lstJug[j]].ToString();
                System.Console.WriteLine("{0}", sOut.ToString().Trim());
            }

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


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

int main() {
  int n;
  string s,t;
  cin >> n >> s >> t;
  rep(i,n) cout << s[i] << t[i];
  cout << endl;
}


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


void getInput(std::vector<std::string> *v);
void dispV(std::vector<std::string> v);

int main(void)
{
	std::vector<std::string> v;
	int i = 0, num = 0;

	// get array length
	getInput(&v);

	while(v[0][i] != '\0') {
		//std::cout << v[0][i] << std::endl;
		if(v[0][i] == '+') num++;
		if(v[0][i] == '-') num--;
		i++;
	}

	std::cout << num << std::endl;




}

void getInput(std::vector<std::string> *v)
{
	std::string s, buf;
	std::getline(std::cin, s);
	std::stringstream ss(s);
	
	while(std::getline(ss, buf, ' ')) {
		(*v).push_back(buf);
	}
}

void dispV(std::vector<std::string> v)
{
	std::cout << "[";
	for(int i = 0; i < v.size(); i++) {
		//std::cout << i << ":" << v[i] << std::endl;
		std::cout << v[i] << ",";
	}
	std::cout << "]" << std::endl;
}















Measured memory_bytes: 256
N = int(input())
a = [input() for i in range(N)]
ac = a.count('AC')
wa = a.count('WA')
tle = a.count('TLE')
re = a.count('RE')


print('AC x '+ str(ac))
print('WA x '+ str(wa))
print('TLE x '+ str(tle))
print('RE x '+ str(re))

Measured memory_bytes: 16252
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <iterator>
#include <algorithm>
#include <string>
#include <cstring>
using namespace std;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

#define rep(i, n, m) for (int i = n; i <= m; i++)
#define Rep(i, n, m) for (int i = m; i >= 1; i--)

typedef long long ll;

int main() {
    vector<int> an(5);
    rep(i, 0, 4) cin >> an[i];
    int k;
    cin >> k;
    rep(i, 0, 3) {
        rep(j, i+1, 4) {
            if (k < an[j] - an[i]) {
                cout << ":(" << endl;
                return 0;
            }
        }
    }
    cout << "Yay!" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int f=0;
	string s;
	cin>>s;
	int n=s.length();
	if(s.find("keyence",0)!=-1||s.find("keyence",n-7)!=-1)f=1;
	else if(s.find("k",0)==0&&s.find("eyence",n-6)!=-1)f=1;
	else if(s.find("ke",0)==0&&s.find("yence",n-5)!=-1)f=1;
	else if(s.find("key",0)==0&&s.find("ence",n-4)!=-1)f=1;
	else if(s.find("keye",0)==0&&s.find("nce",n-3)!=-1)f=1;
	else if(s.find("keyen",0)==0&&s.find("ce",n-2)!=-1)f=1;
	else if(s.find("keyenc",0)==0&&s[n-1]=='e')f=1;
	if(f==1)cout<<"YES\n";
	else cout<<"NO\n"; 
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np
# from numpy import cumsum  # accumulate

def solve():
    K = II()
    S = input()

    if len(S) <= K:
        print(S)
    else:
        print(S[:K] + '...')

if __name__ == '__main__':
    solve()


Measured memory_bytes: 9208
#include<stdio.h>

int main(void)
{
	//char n[]={'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' };
	char m = 'n';
	int ans;
	scanf("%c",&m);
	/*for (int i = 0; i < 26; i++) {
		if (m == n[i])	ans = i;
	}*/
	m = m + 1;
	printf("%c",m);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define N 1000000010
#define M 200010
using namespace std;

int main(){
  long long int a[M];
  long long int b[M];
  long long int c[M * 2];
  int n,m,Acnt=0,Bcnt=0;
  cin >> n >> m;
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  a[n] = N+10;
  for(int i=0;i<m;i++){
    scanf("%d",&b[i]);
  }
  b[m] = N+11;
  int i=0,j=0,cnt=0;
  while(1){
    if(i == n && j == m)break;
    if(a[i] == b[j]){
      c[cnt++] = a[i];
      c[cnt++] = a[i];
      Acnt++;
      i++;
      j++;
    }else if(a[i] > b[j]){
      Bcnt++;
      c[cnt++] = b[j];
      j++;
    }else{
      Bcnt++;
      c[cnt++] = a[i];
      i++;
    }
  }
  cout << Acnt <<" " << Bcnt + Acnt << endl;
  i=0,j=0;
  /*
  while(1){
    if(i == n && j == m)break;
    if(a[i] == b[j]){
      printf("%d\n",a[i]);
      i++;
      j++;
    }
    if(a[i] > b[j])j++;
    else i++;
  }
  */
  i =0,j=0;
  sort(c,c + cnt);
  for(i=0;i<cnt;i++){
    if(c[i] == c[i+1]){
      printf("%d\n",c[i]);
    }
  }
  /*
  for(i=0;i<cnt;i++){
    printf("%d\n",c[i]);
  }
  */
  for(i=0;i<cnt;i++){
    if(c[i] == c[i+1])continue;
    else{
      printf("%d\n",c[i]);
    }
  }
  return 0;
}



Measured memory_bytes: 7100
#include <stdio.h>

/* 配列の要素を順番に出力 */
void trace(int A[],int N) {
    int i;
    for(i=0;i<N;i++) {
        /* 隣接する要素の間に1つの空白を出力 */
        if(i>0) printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
}

/* 挿入ソート(0オリジン配列) */
void insertionSort(int A[], int N) {
    int i,j,v;
    for(i=1;i<N;i++) {
        v=A[i];
        j=i-1;
        while(j>=0 && A[j] > v) {
            A[j+1] = A[j];
            j--;
        }
        A[j+1]=v;
        trace(A,N);
    }
}

int main(void)
{
    int N, i;
    int A[100];
    scanf("%d",&N);
    for(i=0;i<N;i++) scanf("%d",&A[i]);
    
    trace(A,N);
    insertionSort(A,N);
    return 0;
}



Measured memory_bytes: 2096
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;

class Graph {
    int n;
    vector<vector<pair<int, double>>> adj;
    vector<double> d;
    
public:
    Graph(int n) {
        this->n = n;
        adj = vector<vector<pair<int, double>>>(n, vector<pair<int, double>>());
    }
    void addArc(int a, int b, double w) {
        adj[a].push_back(make_pair(b, w));
    }
    
    void addEdge(int a, int b, double w) {
        adj[a].push_back(make_pair(b, w));
        adj[b].push_back(make_pair(a, w));
    }
    
    void dijkstra(int a) {
        d = vector<double>(n, INF);
        d[a] = 0;
        priority_queue<pair<double, int>, vector<pair<double, int>>, greater<pair<double, int>>> q;
        q.push(make_pair(0, a));
        
        while (!q.empty()) {
            int u = q.top().second;
            q.pop();
            
            for (auto i: adj[u]) {
                if (d[i.first] > d[u] + i.second) {
                    d[i.first] = d[u] + i.second;
                    q.push(make_pair(d[i.first], i.first));
                }
            }
        }
    }
    
    double dist(int a) {
        return d[a];
    }
};

typedef pair<int,int> P;

int main() {
    long xs, ys, xt, yt, n;
    cin >> xs >> ys >> xt >> yt >> n;
    vector<long> xn, yn, rn;
    long x, y, r;
    REP(i,n) {
        cin >> x >> y >> r;
        xn.push_back(x);
        yn.push_back(y);
        rn.push_back(r);
    }
    
    Graph g = Graph(n + 2);
    
    g.addEdge(n, n + 1, hypot(xs - xt, ys - yt));
    
    REP(i,n) {
        g.addEdge(n, i, max(0.0, hypot(xs - xn[i], ys - yn[i]) - rn[i]));
        g.addEdge(n + 1, i, max(0.0, hypot(xt - xn[i], yt - yn[i]) - rn[i]));
    }
    
    REP(i,n) {
        for (int j = i + 1; j < n; j++) {
            g.addEdge(i, j, max(0.0, hypot(xn[i] - xn[j], yn[i] - yn[j]) - rn[i] - rn[j]));
        }
    }
    
    g.dijkstra(n);
    double d = g.dist(n + 1);
    printf("%.10f\n", d);
}



Measured memory_bytes: 22512
/*

*/
#include<bits/stdc++.h>

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,a,n) for(int i=(a);i<(n);i++)
#define repe(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  int n;cin>>n;
  string s[n];
  int t[n];
  rep(i,n)cin>>s[i]>>t[i];
  string x;
  cin>>x;
  int hoge;
  rep(i,n){
    if(x==s[i]){
      hoge=i;
      break;
    }
  }
  int cnt=0;
  rep2(i,hoge+1,n)cnt+=t[i];
  cout<<cnt<<endl;
}

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

int main() {
  vector<int> v(4), a = {1, 4, 7, 9};
  for(int i = 0; i < 4; i++)
    cin >> v.at(i);
  sort(v.begin(), v.end());
  if(v == a)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <limits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <array>
#include <map>
#include <set>
#include <deque>
#include <list>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cstring>
#include <bitset>
#include <stack>
#include <queue>

#define MOD (1e9 + 7);
#define PI (3.14159265358979323846)

using ll = int64_t;
using ull = uint64_t;

using namespace std;

[[maybe_unused]] static auto __x = [](){ios_base::sync_with_stdio(0); cin.tie(0);};

int main() {
    vector<int> v(3);
    for (int& value : v) cin >> value;
    sort(v.begin(), v.end());
    cout << (v[0] + v[1]);
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;
typedef long long ll;
int n,m,k;
int main(void){
  cin >> n >> m >> k;
  for(int i = 0; i <= n; i++){
    for(int j = 0; j <= m; j++){
      if(i*m + j*n - 2*i*j == k){
	cout << "Yes" << endl;
	return 0;
      }     
    }
  }
  cout << "No" << endl;
}


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

int main() {
    int n; cin >> n;
    string s;
    vector<int> alpha(26);
    for (int i = 0; i < 26; i++) {
        alpha[i] = 50;
    }

    for (int i = 0; i < n; i++) {
        vector<int> tmp(26);
        cin >> s;
        for (int j = 0; j < s.length(); j++){
            tmp[s[j] - 97] = tmp[s[j] - 97] + 1;
        }
        for (int j = 0; j < 26; j++){
            alpha[j] = min(alpha[j], tmp[j]);
        }
    }
    for (int i = 0; i < 26; i++){
        for (int j = 0; j < alpha[i]; j++){
            printf("%c", 'a'+i);
        }
    }
    cout << endl;
}



Measured memory_bytes: 256