akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define tag "spoj"
#define maxn 100007
#define oo 1000000007LL
#define mid (((long long)l+r)>>1)
#define meset(a,x) memset(a,x,sizeof(a))
#define loop(x) for(int LoOpEr=1;LoOpEr<=x;LoOpEr++)
#define bug true
#define debug(x) if(bug) cerr<<#x<<" = "<<x<<"\n"
#define runtime(stime) ((clock() - stime) / CLOCKS_PER_SEC * 1000)
#define checkfile(FiLeNaMe) { if(fopen(FiLeNaMe".inp","r")) freopen(FiLeNaMe".inp","r",stdin),freopen(FiLeNaMe".out","w",stdout); }
//// my data:
#define lim 26
#define key(c) (c-'a')
///>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
int n,q;
int low[maxn];
int cnt[maxn][lim][lim];
string s[maxn];

struct trie{
    int con,fin;
    trie* nxt[lim];
} *root = new trie();

void add(int i){

    auto cur = root;

    for(auto c: s[i]){

        int x=c-'a';

        if(!cur->nxt[x]) cur->nxt[x]=new trie();

        cur=cur->nxt[x];

        cur->con++;
    }
    cur->fin++;

}

void precalc(int i){

    auto cur = root;

    for(auto c: s[i]){

        int x=c-'a';

        for(int y=0;y<lim;y++){
            if(!cur->nxt[y]) continue;

            cnt[i][x][y]+=cur->nxt[y]->con;
        }

        low[i]+=cur->fin;

        cur=cur->nxt[x];
    }
}

void sol(){
    static int k;
    static string order;
    static int rep;

    cin>>k;
    cin>>order;

    rep=low[k];
    for(int i=0,x,y;i<lim;i++){

        for(int j=0;j<i;j++){

            x=order[i]-'a';
            y=order[j]-'a';

            rep+=cnt[k][x][y];
        }

    }

    cout<<rep+1<<"\n";

    return;
}
int main()
{
    checkfile(tag);
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    cin>>n;

    for(int i=1;i<=n;i++) cin>>s[i],add(i);

    for(int i=1;i<=n;i++) precalc(i);

    cin>>q;
    loop(q) sol();

    return 0;
}


Measured memory_bytes: 296704
// #include <bits/stdc++.h>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)
#define exf(x)	 for(auto&& tmp : x) { cout << tmp << endl; }	// 拡張for
#define testP	 cout << "------------------ test ------------------" << endl;	// 動作確認テスト
#define testX(x) cout << "testout : " << x << endl;	// テストアウト
typedef long long ll;
using namespace std;
const int MOD{ int(1e9 + 7) };	// int 1000000007
const int inf{ int(1e9) };	// inf = 1000000000

// ------------------ ベクター表示 ------------------ //
void printVec(vector<int> & vec) {
	cout << "";
	for (auto it = vec.begin(); it != vec.end(); it++) cout << *it << " ";
	cout << endl;
}

// ------------------ ベクター合計 ------------------ //
int sumVec(vector<int> v) {
	int sum = 0;
	for (size_t i = 0; i < v.size(); i++) sum += v[i];
	return sum;
}

// ------------------ int -> Vector 変換 ------------------ //
vector<int> ItoVec(int x) {

	vector<int> xVec;

	while (x > 0) {
		int tmp = x % 10;
		xVec.insert(xVec.begin(), tmp);
		x /= 10;
	}

	return xVec;
}

// ------------------ 最大公約数関数 ------------------ //
int GCD(int x, int y) {
	if (x == 0) return y;
	else GCD(y % x, x);
}


// -------------------------------------------------- //
// ------------------ ここから本編 ------------------ //
// -------------------------------------------------- //

int main(void) {

	int N, K;
	cin >> N >> K;
	vector<int> d(K);
	vector<int> A(N);
	vector<int> ans(N, 1);

	rep(i, K) {
		cin >> d[i];
		rep(j, d[i]) {
			cin >> A[j];
			ans[A[j] - 1] = 0;
		}
	}

	cout << sumVec(ans) << endl;

	return 0;
}

Measured memory_bytes: 3592
#include <iostream>
using namespace std;
const int MAX =100;
int main(){
    int h,w;
    string s[MAX];
    cin>>h>>w;
    for(int i=0;i<h;i++){
        cin>>s[i];
    }
    for(int i=0;i<w+2;i++){
        cout<<'#';
    }
    cout<<endl;
    
    for(int i=0;i<h;i++){
        cout<<'#'<<s[i]<<'#'<<endl;
    }
    
    for(int i=0;i<w+2;i++){
        cout<<'#';
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<iostream>
#include<string>

using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int a[200000];

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;cin>>n;
    REP(i,n)cin>>a[i];
    int b=0;REP(i,n)b^=a[i];
    REP(i,n){cout<<(a[i]^b)<<"\n";}
    return 0;
}


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

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

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<P> v(n);
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    v[i] = make_pair(a, b);
  }

  sort(v.begin(), v.end());
  ll sum = 0, ans = 0;
  rep(i, n) {
    rep(j, v[i].second) {
      if (sum >= m) break;
      ++sum;
      ans += v[i].first;
    }
  }

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


Measured memory_bytes: 4044
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;
 

int main()
{
  int N, K;
  cin >> N >> K;
  vector<vector<int>> imos(K * 6, vector<int>(K * 6));
  while (N--) {
    int x, y;
    char c;
    cin >> x >> y >> c;
    if (c == 'B') y += K;
    x %= K * 2;
    y %= K * 2;
    if (x >= K and y >= K) x -= K, y -= K;
    FOR(i, -1, 4) FOR(j, -1, 4) if (abs(i + j) % 2 == 0) {
      int X = x + i * K, Y = y + j * K;
      if (X < 0 or Y < 0) continue;
      imos[X][Y]++;
      imos[X + K][Y]--;
      imos[X][Y + K]--;
      imos[X + K][Y + K]++;
    }
  }
    
  REP(i, imos.size()) REP(j, imos[0].size() - 1) imos[i][j + 1] += imos[i][j];
  REP(i, imos.size() - 1) REP(j, imos[0].size()) imos[i + 1][j] += imos[i][j];
  int ret = 0;
  for (auto v : imos) for (auto x : v) ret = max(ret, x);
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 141184
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;$n:expr) => {
        (0..$n).map(|_| scan!()).collect::<Vec<_>>()
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let s = scan!();
    let n = s.len();
    for i in 1..n {
        let (first, _) = s.split_at(s.len() - i);
        if first[0..first.len() / 2] == first[first.len() / 2..] {
            println!("{}", first.len());
            return;
        }
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <math.h>

int main(){
  int n;
  std::cin >> n;
  int a[100000];
  int end = sqrt(n);
  
  for(int x=1; x<end; x++){
    for(int y=1; y<=x; y++){
      if(x*x+y*y+x*y+x+y+1 <= n){
        for(int z=1; z<=y; z++){
          int result = x*x + y*y + z*z + x*y + y*z + z*x - 1;
          if(x==y || y==z || z==x){
            if(x==y && y==z){
              a[result] += 1;
            }
            else{ a[result] += 3; }
          }
          else{ a[result] += 6; }
        }
      }
    }
  }
  
  for(int i=0; i<n; i++){
    std::cout << a[i] << std::endl;
  }
  
  return 0;
}


Measured memory_bytes: 3624
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include <bits/stdc++.h>

using namespace std;

/**
 * main
 */
int main () {
  int A, B;
  cin >> A >> B;

  int ans = -1;
  for (size_t n = 1; n <= 1009; n++) {
    if (floor(n * 8 / 100) == A && floor(n * 10 / 100) == B) {
      ans = n;
      break;
    }
  }

  printf("%d\n", ans);
}


Measured memory_bytes: 256
function main(input) {

  let list = input.split("\n")[1].split(' ').map(x => parseInt(x));
  let swapCnt = 0; // AOJ 提出用

  // minj: 未ソート済み配列の位置
  for (i = 0; list.length - 1 > i; i++) {
    let minj = i;

    // 未ソート部から最小を取得
    for (j = i; list.length > j; j++) {
      if (list[minj] > list[j]) {
        minj = j;
      }
    }
    // 未ソート済み配列の先頭と未ソート部最小を比較して入れ替え
    if (i != minj) {
      const a = list[i];
      const b = list[minj];
      list[minj] = a;
      list[i] = b;

      swapCnt++; // AOJ 提出用
    }
  }

  // AOJ 提出用
  console.log(list.join(" "));
  console.log(swapCnt);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 15180
#include <iostream>
#include <algorithm>

int main()
{
    int n, a, b, max, min;

    std::cin >> n >> a >> b;

    max = std::min(a ,b);

    if (a + b <= n){
        min = 0;
    }
    else {
        min = a + b - n;
    }

    std::cout << max << " " << min;

    return 0;
}

Measured memory_bytes: 256
import itertools

cuisine = [int(input()) for i in range(5)]

cnt=[]

for i in range(5):
    cnt.append(0)

for i in range(len(cuisine)):
    while float(cuisine[i]/10).is_integer()==False:
        cuisine[i] += 1
        cnt[i] +=1


ALL = list(itertools.permutations(range(5)))

result=[]

for i in range(len(ALL)):
    
    sum=0
    last =0
    
    for j in range(5):
        
        index =ALL[i][j]
        
        sum += cuisine[index]
        last = index
        
    result.append(sum-cnt[last])
    
    
result.sort()


print(result[0])

Measured memory_bytes: 3064
n=int(input())
a=[0]*1000
for i in range(n+1):
    for j in range(2,int(i**.5)+1):
        while i%j==0:
            i//=j
            a[j]+=1
    if i>1:
        a[i]+=1
ans=1        
for i in a:
    if i>0:
        ans*=i+1
print(ans%(10**9+7))

Measured memory_bytes: 3060
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
#define INF int(1e9)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(int i = 1; i <= (int)(n); i++)
#define EACH(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(int i = m;i < n;i++)

ll N, K;

void solve() {
    ll ans = 0;
    REPONE(b, N) {
        ll p = N / b, r = N % b;
        ans += p * max(ll(0), b - K);
        ans += max(ll(0), r - K + 1);
    }
    if (K == 0) ans -= N;
    cout << ans << endl;
}

int main() {
    cin >> N >> K;
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

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

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
bool used[100]={false};
//int d[100][100]={{0}};
vector<int> d[100];
vector<int> ord;
bool in[100]={false};
void dfs(int v){
	used[v]=true;
	for(int i =0;i <d[v].size();i++){
		if(!used[d[v][i]])dfs(d[v][i]);
	}
	ord.push_back(v);
}

int main(){
	int m;
	int n;
	cin>>m>>n;
	for(int i =0;i <n;i++){
		int x,y;
		cin>>x>>y;
		d[--x].push_back(--y);
	
	}
	for(int i =0;i <m;i++){
		if(!used[i])dfs(i);
	}
	for(int i =m-1;i >=0;i--){
		cout <<ord[i]+1<<endl;
	}
	return 0;
}

Measured memory_bytes: 1216
#include <stdio.h>
#include <stdlib.h>
#define int long long

int ABS(int a){
	return a >= 0 ? a : -a;
}

signed main(){
	int H, W, D, A, Q, HW, i, j;
	scanf("%lld%lld%lld", &H, &W, &D);
	HW = H * W;
	int *h = (int *)malloc(sizeof(int) * HW);
	int *w = (int *)malloc(sizeof(int) * HW);
	int *d = (int *)malloc(sizeof(int) * HW);
	for(i = 0; i < H; i++){
		for(j = 0; j < W; j++){
			scanf("%lld", &A);
			A--;
			h[A] = i;
			w[A] = j;
		}
	}
	for(A = 0; A < HW; A++){
		if(A >= D){
			d[A] = d[A - D] + ABS(h[A] - h[A - D]) + ABS(w[A] - w[A - D]);
		}
		else{
			d[A] = 0;
		}
	}
	scanf("%lld", &Q);
	int *L = (int *)malloc(sizeof(int) * Q);
	int *R = (int *)malloc(sizeof(int) * Q);
	for(i = 0; i < Q; i++){
		scanf("%lld%lld", &L[i], &R[i]);
		L[i]--;
		R[i]--;
	}
/*	for(i = 0; i < HW; i++){
		printf("d[%d] = %d\n", i, d[i]);
	}
*/	for(i = 0; i < Q; i++){
		printf("%lld\n", d[R[i]] - d[L[i]]);
	}
	return 0;
}

Measured memory_bytes: 4736
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] h = new int[n];
    for (int i = 0; i < n; i++) {
      h[i] = sc.nextInt();
    }

    int min = 0;
    int count = 1;

    for (int i = 1; i < n; i++) {
      if (h[min] <= h[i]) {
        min = i;
        count++;
      }
    }
    System.out.println(count);
  }

}


Measured memory_bytes: 21712
/* ex4_3
   shu_t */

#include<stdio.h>

//prototype declaration
int sub(int a,int b);
int add(int c);

int main(void){
  int west_tower,east_tower,dif_tower,height,pile_up;
  //input no snow height 
  scanf("%d %d", &west_tower,&east_tower);
  //calculate difference of tower
  dif_tower = sub(west_tower, east_tower);
  //calculate true height of east_tower
  height = add(dif_tower);
  //calculate snow piled up tower
  pile_up = sub(east_tower,height);
  //output the answer
  printf("%d\n",pile_up);
  return 0;
}

int sub(int a,int b){//function of subtraction
  int dif;
  dif = b - a;
  return(dif);
}

int add(int c){//sum: from 1 to c
  int roop,sum;
  for(roop = 1; roop<=c; roop++){
    sum += roop;
  }
  return(sum);
}


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

typedef long long ll;

const ll MOD = 1000000007;

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> vec(M);

    for (int i = 0; i < M; i++) {
        int k;
        cin >> k;
        vec[i].resize(k);
        for (int j = 0; j < k; j++) {
            cin >> vec[i][j];
            --vec[i][j];
        }
    }

    vector<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 ok = true;
        for (int j = 0; j < M; j++) {
            int c = 0;
            for (int id : vec[j]) {
                if ((i >> id) & 1) {
                    ++c;
                }
            }
            c %= 2;
            if (c != p[j]) {
                ok = false;
            }
        }
        if (ok) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
# gets.to_i
# gets.split.map(&:to_i)
# N.times.map{gets.to_i}
# N.times.map{gets.split.map(&:to_i)}
# 

#N,M=gets.split.map(&:to_i)
s=gets.chomp
Q=gets.to_i
add1=[]
add2=[]

rev=0
Q.times do |i|
    q=gets.chomp
    if q[0]=="1"
        rev=1-rev
    else
        _,f,c=q.split
        f=f.to_i
        if rev==0
            if f==2
                add1 << c
            else
                add2 << c
            end
        else
            if f==2
                add2 << c
            else
                add1 << c
            end
        end
    end
end

if rev==0
    print add2.reverse!.join("")
    print s
    print add1.join("")
else
    print add1.reverse!.join("")
    print s.reverse!
    print add2.join("")
end
puts

Measured memory_bytes: 18684
from functools import reduce
import operator
def factor(a):
    b = 1
    d = []
    while b:
        if a == 2:
            d.append(a)
            break
        for i in range(2, a):
            if a % i == 0:
                b = a // i
                d.append(i)
                a = b
                break
            elif a == i+1:
                d.append(a)
                b = 0
    return d

x, y = map(int, input().split())

x_f = factor(x)
y_f = factor(y)

common = list(set(x_f) & set(y_f))
common_n = [min(x_f.count(common[i]),y_f.count(common[i])) for i in range(len(common))]


if common == []:
    print(1)
else:
    print(reduce(lambda x,y:x*y, list(map(lambda x,y:x ** y, common, common_n))))
        


Measured memory_bytes: 6288
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ 666666
int n,a[SZ];
map<int,int> g;
bool ok(int e)
{
	g.clear();
	for(int i=1;i<=n;++i)
	{
		if(a[i-1]>=a[i])
		{
			while(g.size())
			{
				auto w=g.end(); --w;
				if(w->fi<=a[i]) break;
				g.erase(w);
			}
			int s=a[i]; ++g[s];
			while(1)
			{
				int&p=g[s];
				if(p<e) break;
				p-=e; --s; ++g[s];
			}
			if(s<1) return 0;
		}
	}
	return 1;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
		scanf("%d",a+i);
	bool x=1;
	for(int i=1;i<n;++i)
		x&=a[i]<a[i+1];
	if(x)
	{
		puts("1");
		return 0;
	}
	int l=2,r=n;
	while(l<r)
	{
		int m=(l+r)>>1;
		if(ok(m)) r=m; else l=m+1;
	}
	printf("%d\n",l);
}


Measured memory_bytes: 1024
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

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

    ll X;
    cin >> X;
    for (ll h = 1; h <= 3500; h++) {
        for (ll n = 1; n <= 3500; n++) {
            ll waro = 4 * h * n - X * h - X * n;
            if (waro != 0 && (X * n * h) % waro == 0) {
                ll w = (X * n * h) / waro;
                if (w > 0) {
                    cout << h << " " << n << " " << w << endl;
                    return 0;
                }
            }
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define FORR(x, arr) for(auto& x:arr)
#define ITR(x, c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;
typedef pair<int, int> P;

string s;

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> s;
	int l = 0, r = s.size()-1, cnt = 0;
	while (l < r) {
		if (s[l] == s[r]) {
			l++;
			r--;
		}
		else if (s[l] == 'x') {
			cnt++;
			l++;
		}
		else if (s[r] == 'x') {
			cnt++;
			r--;
		}
		else {
			cout << -1 << endl;
			return 0;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 512
/******************************************************************************

                         بسم الله الرحمن الرحيم
                     Author: Mst: Mhamuda Khatun
                               RUCSE27

*******************************************************************************/

#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define ll long long
#define pi 2*acos(0.0)
#define f first
#define s second
#define pb push_back
#define gap ' '
#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define mod 1000000007
#define MAX 1000000000000
#define N 305

int main()
{
    fastio;
    ll n,p,i;
    cin>>n;

    vector<ll>v(n+1);

    v.assign(n+1,0);

    for(i=0;i<n-1;i++)
    {
        cin>>p;
        v[p]++;
    }

    for(i=1;i<=n;i++)
    {
        cout<<v[i];
        cout<<"\n";
    }

    return 0;   //:D
}




Measured memory_bytes: 4784
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define Sort(x) sort((x).begin(), (x).end())
#define Reverse(x) reverse((x).begin(), (x).end())
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define INF INT_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15) //15桁まで表示
#define str string
typedef std::pair<int,int> pii;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<ui,ui> puu;
typedef pair<int, int> P;
typedef vector<int> vi;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};
int floor(int a,int b){return (a+b-1)/b;};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
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;};
double dp[301][301][301];
int n;
double memo(int i,int j ,int k){
    if (dp[i][j][k]>=0) return dp[i][j][k];
    double ans=n;
    if (i>0) ans+=memo(i-1,j,k)*i;
    if (j>0) ans+=memo(i+1,j-1,k)*j;
    if (k>0) ans+=memo(i,j+1,k-1)*k;
    dp[i][j][k]=ans/(i+j+k);
    return ans/(i+j+k);
}
int main() {
    cin >> n;
    int a,x=0,y=0,z=0;
    rep(i,n){
        cin >> a;
        if (a==1) x++;
        else if (a==2) y++;
        else z++;
    }
    memset(dp, -1, sizeof(dp));
    dp[0][0][0]=0;
    cout <<fixed << setprecision(10)<< memo(x,y,z) <<endl;


}

Measured memory_bytes: 213376
N, K = map(int, input().split())
S = list(input()) + [-1]
bw = [0] * N
ind = 0
for i in range(N):
  bw[ind] += S[i] == S[i + 1]
  if S[i] != S[i + 1]:
    bw[ind] += 1
    ind += 1
ind = 0
res = 0
cumsumbw = [0] + [bw[0]] + [0] * (N - 1)
for i in range(1, N):
  cumsumbw[i + 1] = cumsumbw[i] + bw[i]
if N - 2 * K <= 0:
  print(N)
  exit(0)
for i in range(N - 2 * K):
  if S[cumsumbw[i]] == "1":
    res = max(res, cumsumbw[i + 2 * K + 1] - cumsumbw[i])
  else:
    res = max(res, cumsumbw[i + 2 * K] - cumsumbw[i])
  #print(res)
print(res)
#print(bw)
#print(cumsumbw)

Measured memory_bytes: 56688
fun main(args: Array<String>) {
    val N = readInputLine().toInt()
    
    for (i in 0..N / 4) {
        for (j in 0..N / 7) {
            if (i * 4 + j * 7 == N) {
                println("Yes")
                return
            }
        }
    }
    
    println("No")
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 31840
#include<cstdio>

int main()
{
    int n, m;
    scanf("%d %d", &n, &m);

    int t = 1;
    for (int i = 0; i < m; i++) t *= 2;

    int x = (1900 * m + 100 * (n - m)) * t;
    printf("%d", x);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define MP make_pair
#define F first
#define S second
#define sz(v) (ll)v.size()
#define inf 100000000000000
#define vll vector<ll>
#define pll pair<ll,ll>nnnn
using namespace std;
const int N=200004;

void solve()
{
	ll a;
	string s;
	cin>>a>>s;
	if(a<3200)	
		cout<<"red";
	else
		cout<<s;

}
int main() {
    
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
    ll t=1;
    //cin>>t;
    while(t--)
        solve();
 
    
    return 0;
}

Measured memory_bytes: 256
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    N,M,K = map(int,input().split())
    A = list(map(int,input().split()))
    B = list(map(int,input().split()))

    sumA = [0] * (N+1)
    sumB = [0] * (M+1)

    for i in range(1,N+1):
        sumA[i] = sumA[i-1] + A[i-1]

    for i in range(1,M+1):
        sumB[i] = sumB[i-1] + B[i-1]

    for i in range(M,-1,-1):
        if sumB[i] <= K:
            endB = i
            break

    for i in range(N,-1,-1):
        if sumA[i] <= K:
            endA = i
            break

    res = 0

    for i in range(0,endA+1):
        for j in range(endB,-1,-1):
            if sumA[i] + sumB[j] <= K:
                endB = j
                res = max(res,i+j)
                break

    print(res)



main()


Measured memory_bytes: 47760
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<int>wq1,wq2;
int main()
{
    int g,h,t,z,lo2,hi2,m2;
    ll q,x,sp,lo1,hi1,m1,ntz=0;
    scanf("%d %lld",&t,&q);
    for(g=0;g<t;g++){
        scanf("%d",&z);
        if(z>0)wq1.push_back(z);
        else if(z<0)wq2.push_back(z);
        else ntz++;
    }
    sort(wq1.begin(),wq1.end());
    sort(wq2.begin(),wq2.end());
    lo1=-1e18, hi1=1e18;
    while(lo1<hi1){
        m1=(lo1+hi1)>>1;
        if(m1<0)for(g=sp=0;g<wq2.size();g++){
            lo2=0, hi2=wq1.size()-1;
            while(lo2<=hi2){
                m2=(lo2+hi2)>>1;
                x=1LL*wq2[g]*wq1[m2];
                if(x<=m1)hi2=m2-1;
                else lo2=m2+1;
            }
            sp+=(wq1.size()-hi2-1);
        }
        else if(m1>0){
            sp=1LL*wq2.size()*wq1.size();
            sp+=ntz*(wq1.size()+wq2.size());
            sp+=(ntz*(ntz-1))>>1;
            for(g=0;g<wq1.size();g++){
                lo2=g+1, hi2=wq1.size()-1;
                while(lo2<=hi2){
                    m2=(lo2+hi2)>>1;
                    x=1LL*wq1[g]*wq1[m2];
                    if(x>m1)hi2=m2-1;
                    else lo2=m2+1;
                }
                sp+=(lo2-1-g);
            }
            for(g=0;g<wq2.size();g++){
                lo2=g+1, hi2=wq2.size()-1;
                while(lo2<=hi2){
                    m2=(lo2+hi2)>>1;
                    x=1LL*wq2[g]*wq2[m2];
                    if(x>m1)lo2=m2+1;
                    else hi2=m2-1;
                }
                sp+=(wq2.size()-hi2-1);
            }
        }
        else{
            sp=1LL*wq2.size()*wq1.size();
            sp+=ntz*(wq1.size()+wq2.size());
            sp+=(ntz*(ntz-1))>>1;
        }
        if(sp>=q)hi1=m1;
        else lo1=m1+1;
    }
    printf("%lld\n",hi1);
    return 0;
}


Measured memory_bytes: 4336
#include <stdio.h>
 int main(void)
 {
   int k, a, b,s;

   scanf("%d", &k);
   scanf("%d%d", &a, &b);

   s=(b / k) * k;
   if (a <= s) {
     puts("OK");
   } else {
     puts("NG");
   }

 return 0;
}


Measured memory_bytes: 1608
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<stdlib.h>
#define maxn 1005
using namespace std;
int n,tot;
int head[maxn],nex[maxn],to[maxn],v[maxn];
void add(int x,int y)
{
	to[++tot]=y; nex[tot]=head[x]; head[x]=tot;
}
int dp[maxn][maxn*5],temp[maxn*5];
int dfs(int now)
{
	dp[now][0]=0;
	for(int i=head[now];i;i=nex[i])
	{
		int w=dfs(to[i]),b=v[to[i]];

		memcpy(temp,dp[now],sizeof(temp));
		memset(dp[now],0x3f,sizeof(dp[now]));

		for(int j=0;j<=v[now];j++)
		{
			if(j+w<=v[now])
				dp[now][j+w]=min(dp[now][j+w],temp[j]+b);
			if(j+b<=v[now])
				dp[now][j+b]=min(dp[now][j+b],temp[j]+w);
		}

	}

	int ans=dp[0][0];

	for(int i=0;i<=v[now];i++)
		ans=min(ans,dp[now][i]);

//	cerr<<now<<" "<<ans<<endl;
	return ans;
}
int main()
{
	memset(dp,0x3f,sizeof(dp));

	scanf("%d",&n);
	for(int i=2;i<=n;i++)
	{
		int x;
		scanf("%d",&x);
		add(x,i);
	}
	for(int i=1;i<=n;i++)
		scanf("%d",&v[i]);
	int res=dfs(1);
//	cout<<res<<endl;
	if(res<dp[0][0])
		return printf("POSSIBLE\n"),0;
	printf("IMPOSSIBLE\n");
}


Measured memory_bytes: 19968
def dfs(graph, start):
    ans = 0
    stack = [[start, 2**start]]
    visited = {}
    while stack:
        d = stack.pop()
        if d[1] == 2 ** N - 1:
            ans += 1
            continue
        for node in graph[d[0]]:
            if not (d[1] & 2 ** node):
                stack.append([node, d[1] | 2 ** node])
    return ans


N, M = map(int, input().split())
g = {i: [] for i in range(N)}
for i in range(M):
    a, b = map(int, input().split())
    g[a - 1].append(b - 1)
    g[b - 1].append(a - 1)
print(dfs(g, 0))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
pair<int, int> edge(int x_1, int y_1, int x_2, int y_2) {
  int x= x_2 + y_1 - y_2;
  int y = y_2 - x_1 + x_2;
  pair<int, int> p = make_pair(x, y);
  return p;
}
int main() {
  int x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4;
  cin >> x_1 >> y_1 >> x_2 >> y_2;
  pair<int, int> p = edge(x_1, y_1, x_2, y_2);
  x_3 = p.first;
  y_3 = p.second;
  pair<int, int> q = edge(x_2, y_2, x_3, y_3);
  x_4 = q.first;
  y_4 = q.second;
  cout << x_3 << " " <<  y_3 << " " << x_4 << " " << y_4 << endl;
}

Measured memory_bytes: 3640
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

ll cnt(ll x){
  return x*(x-1)/2;
}

signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll n,m;cin>>n>>m;
  cout<<cnt(n)+cnt(m)<<ENDL;
}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <math.h>
#include <float.h>
using namespace std;

int main()
{
	char sa[51];
	char sb[51];
	cin >> sa;
	cin >> sb;

	char szTotal[200];
	memset(szTotal, NULL, sizeof(szTotal));


	int nLen = strlen(sa);
	for (int i = 0; i < nLen; i++)
	{
		int j = i * 2;
		szTotal[j] = sa[i];
	}

	int nLen2 = strlen(sb);
	for (int i = 0; i < nLen; i++)
	{
		int j = i * 2+1;
		szTotal[j] = sb[i];
	}
	cout << szTotal;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;

int main()
{
    int n,m;
    cin>>n>>m;
    if(n==m)
    {   
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
        
    }
    
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int k = K;
        int i = 1;
        while (N >= k) {
        		k *= K;
        		i++;
        }
        System.out.println(i);
    }
} 

Measured memory_bytes: 21844
fun longList() = readLine()?.split(" ")?.map(String::toLong) ?: TODO()
fun main() {
    val (a, b, c, d) = longList()
    listOf(
        a * c,
        b * c,
        a * d,
        b * d
    ).max()?.let {
        println(it.toString())
    }
}

Measured memory_bytes: 39056
#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;
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};
 
int main()
{
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	int ans = 0;

	while (a < 0){
		ans += c;
		a++;
	}

	if (a == 0){
		ans += d;
	}

	while (a < b){
		ans += e;
		a++;
	}

	cout << ans << endl;


}



Measured memory_bytes: 3124
#include<iostream>
using namespace std;
int main () {
    
    int build[4][3][10] = {{{}}};
    
    int b;
    int f;
    int r;
    int v;
    int n;
    
    cin >> n;
    
    for (int h = 0; h < n; h ++) {
        
        cin >> b >> f >> r >> v;
        
        build[b-1][f-1][r-1] = build[b-1][f-1][r-1] + v;
        
    }
    
    for (int i = 0; i < 4; i ++) {
        
        for (int j = 0; j < 3; j ++) {
            
            for (int k = 0; k < 10; k ++) {
                
                if (k == 9) {
                    
                    cout << ' ' << build[i][j][k] << endl;
                    
                } else {
                    
                    cout << ' ' << build[i][j][k];
                    
                }
                
            }
            
        }
        
        if (i != 3) {
            
            for (int l = 0; l < 20; l ++) {
            
                if (l == 19) {
                
                    cout << '#' << endl;
                
                } else {
                
                    cout << '#';
                
                }
            
            }
            
        }
        
        
    }
    
}


Measured memory_bytes: 3076
#include<stdio.h> 
#include<string.h>

int a;
int taroN,hanaN;
void card(int,int *,int *);

int main(void){
	int n;
	int taro[201],hana[201];
	while(1){
		for(a=0;a<=200;a++){
			 taro[a]=0;
			 hana[a]=0;
		}
		scanf("%d",&n);
		if(n==0)break;
		taroN=n,hanaN=n;
		for(a=0;a<n;a++){
			int b;
			scanf("%d",&b);
			taro[b]=1,hana[b]=0;
		}
		for(a=1;a<=n*2;a++){
			if(taro[a]==0)hana[a]=1;
		}
		card(n,taro,hana);
		printf("%d\n",hanaN);
		printf("%d\n",taroN);
	}
	return 0;
}

void card(int n,int taro[201],int hana[201]){
	int max=0;
	while(1){
		for(a=1;a<=n*2;a++){
			if(taro[a]==1 && a>max){
				max=a;
				taro[a]=0;
				taroN--;
				break;
			}
			if(a==n*2)max=0;
		}
		if(taroN==0)return;
		
		for(a=1;a<=n*2;a++){
			if(hana[a]==1 && a>max){
				max=a;
				hana[a]=0;
				hanaN--;
				break;
			}
			if(a==n*2)max=0;
		}
		if(hanaN==0)return;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
const long long INF = 1LL << 60;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  string S;
  cin >> S;
  int N = S.size();
  int n = 0;
  int s = 0;
  int e = 0;
  int w = 0;
  rep(i,N)
  {
    if(S[i]=='N') n++;
    if(S[i]=='S') s++;
    if(S[i]=='E') e++;
    if(S[i]=='W') w++;
  }
  if(n>0&&e>0&&w>0&&s>0)
  {
    cout << "Yes" << endl;
  }
  else if(n==0&&s==0&&e>0&&w>0)
  {
    cout << "Yes" << endl;
  }
  else if(e==0&&w==0&&n>0&&s>0)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3644
package main

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

func getNextLine(scanner *bufio.Reader) string {
	var buffer string
	for {
		line, isPrefix, _ := scanner.ReadLine()
		buffer += string(line)
		if isPrefix == false {
			break
		}
	}
	return buffer
}

func getIntList(scanner *bufio.Reader) []int {
	list := strings.Split(getNextLine(scanner), " ")
	l := len(list)
	result := make([]int, l)
	for i := 0; i < l; i++ {
		result[i], _ = strconv.Atoi(list[i])
	}
	return result
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := bufio.NewReader(fp)

	var n int
	fmt.Sscan(getNextLine(scanner), &n)
	s := getNextLine(scanner)
	sums := make([]int, n+1)
	for i := 0; i < n; i++ {
		sums[i+1] = sums[i]
		if s[i] == 'E' {
			sums[i+1]++
		}
	}
	min := n
	for i := 1; i <= n; i++ {
		sum := i - 1 - sums[i-1] + (sums[n] - sums[i])
		if min > sum {
			min = sum
		}
	}

	fmt.Println(min)
}


Measured memory_bytes: 8832
def inverse(n: int, mod: int) -> int:
    return pow(n, mod - 2, mod)

def cmb(n: int, m: int, mod) -> int:
    p, q = 1, 1
    for i in range(m):
        p = p * (n - i) % mod
        q = q * (i + 1) % mod
    return p * inverse(q, mod) % mod

n, a, b = map(int, input().split())
mod = 10 ** 9 + 7
ans = pow(2, n, mod) - 1
ans -= cmb(n, a, mod)
ans -= cmb(n, b, mod)
print(ans % mod) 

Measured memory_bytes: 3064
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		sc.nextInt();
		sc.nextInt();
		int n = sc.nextInt();
		int cost = 0;
		int sx = sc.nextInt();
		int sy = sc.nextInt();
		for(int i=1;i<n;i++){
			int px = sc.nextInt();
			int py = sc.nextInt();
			int gx = px-sx;
			int gy = py-sy;
			cost += Math.abs(gx-gy);
			if(gx*gy>=0) cost += Math.min(Math.abs(gx), Math.abs(gy));
			sx = px;
			sy = py;
		}
		System.out.println(cost);
	}

}

Measured memory_bytes: 25424
#include <iostream>
#include <algorithm>
#include <string>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main() {
	int k;
	string s;
	cin>>k>>s;
	if(k>=s.length()){
		cout<<s<<endl;
	}else{
		rep(i,k){
			cout<<s[i];
		}
		cout<<"..."<<endl;
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 3628
MOD = 998244353
n, a, b, k = [int(item) for item in input().split()]

fac = [1] + [0] * n
fac_inv = [1] + [0] * n
for i in range(1, n+1):
    fac[i] = fac[i-1] * (i) % MOD
    fac_inv[i] = fac_inv[i-1] * pow(i, MOD-2, MOD) % MOD

def mod_nCr(n, r):
    if n == 0 and r == 0:
        return 1
    if n < r or n < 0:
        return 0
    tmp = fac_inv[n-r] * fac_inv[r] % MOD
    return tmp * fac[n] % MOD 

if a < b:
    a, b = b, a
max_a_num = k // a + 1
ans = 0
for a_num in range(max_a_num):
    lest = k - (a_num * a)
    if lest % b != 0 or lest < 0:
        continue
    b_num = lest // b
    ans += mod_nCr(n, a_num) * mod_nCr(n, b_num)
    ans %= MOD
print(ans)

Measured memory_bytes: 48752
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	ll n,l;
	cin >> n;
	vector<ll> a(n);
	vector<ll> b(n);
	ll sum = 0;
	for(ll i = 0; i < n; i++) {
		cin >> l;
		a[i] = l;
		sum += l;
		b[i] = sum;
	}


	
	ll ans = LINF;
	for(ll i = 0; i < n; i++) {
		ans = min(ans,abs(2 * b[i] - b[n - 1]));
	}
	cout << ans << endl;

	return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int ti = clock();
    int d;
    cin >> d;
    vi c(26);
    rep(i, 26) cin >> c[i];
    vector<vi> s(d, vi(26));
    rep(i, d) rep(j, 26) cin >> s[i][j];
    vi last(26), t(d);
    ll sum = 0;
    rep1(i, d) {
        ll cm = 0;
        rep(j, 26) cm += c[j] * (i - last[j]);
        pii m(-INF, -1);
        rep(j, 26) {
            ll sat = s[i-1][j] - cm + c[j] * (i - last[j]);
            m = max(m, {sat, j});
        }
        sum += m.first;
        last[m.second] = i;
        t[i-1] = m.second;
        //cout << (m.second + 1) << endl;
    }
    srand((unsigned)time(NULL));
    while (clock()-ti < CLOCKS_PER_SEC*195/100) {
        int dr = rand() % d + 1, qr = rand() % 26;
        int fq = t[dr-1], tq = qr;
        int td = dr;
        int fl = dr-1, fr = dr+1, tl = dr, tr = dr;
        while (fl > 0) {
            if (t[fl-1] == fq) break;
            --fl;
        }
        while (fr <= d) {
            if (t[fr-1] == fq) break;
            ++fr;
        }
        while (tl > 0) {
            if (t[tl-1] == tq) break;
            --tl;
        }
        while (tr <= d) {
            if (t[tr-1] == tq) break;
            ++tr;
        }
        ll nsum = sum;
        nsum -= s[td-1][fq];
        nsum += (td-fl)*(td-fl-1)*c[fq]/2 + (fr-td)*(fr-td-1)*c[fq]/2;
        nsum -= (fr-fl)*(fr-fl-1)*c[fq]/2;
        nsum += s[td-1][tq];
        nsum -= (td-tl)*(td-tl-1)*c[tq]/2 + (tr-td)*(tr-td-1)*c[tq]/2;
        nsum += (tr-tl)*(tr-tl-1)*c[tq]/2;
        //cout << sum << endl;
        if (nsum >= sum*1.01) t[td-1] = tq;
    }
    rep(i, d) cout << (t[i] + 1) << endl;
    return 0;
}


Measured memory_bytes: 3708
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <utility>
using namespace std;

int main(){
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> v(m, 0);
  int cnt1 = 0;
  int cnt2 = 0;
  for(int i = 0; i < m; i++){
    cin >> v[i];
    if(v[i] > x){cnt1++;}
    if(v[i] < x){cnt2++;}
  }
  cout << min(cnt1, cnt2) << endl;

}

Measured memory_bytes: 256
n,m=map(int,input().split())
p=list(map(int,input().split()))
xy=[list(map(int,input().split())) for _ in range(m)]
l=[i for i in range(n)]
def root(x):
  if x==l[x]:
    return x
  l[x]=root(l[x])
  return l[x]
for x,y in xy:
  a=root(x-1)
  b=root(y-1)
  if a!=b:
    l[b]=a
cnt=0
for i in range(n):
  if root(p[i]-1)==root(i):
    cnt+=1
print(cnt)


Measured memory_bytes: 35272
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <vector>
#include <bitset>
#include <queue>
using namespace std;

int main(){
    string s;
    cin >> s;
    cout << s[0] << s.length() -2 << s[s.length()-1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <climits>
#include <map>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iterator>
#include <deque>
#include <bitset>
#include <list>
#include <queue>
#include <set>
#include <stack>
#include <functional>
#include <iterator>
#include <locale>
#include <memory>
#include <stdexcept>
#include <utility>
#include <fstream>
#include <ios>
#include <iosfwd>
#include <iomanip>
#include <istream>
#include <sstream>
#include <streambuf>
#include <complex>
#include <numeric>
#include <valarray>
#include <exception>
#include <limits>
#include <new>
#include <typeinfo>
#include <bitset>
#include <queue>
#define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace std;

int main() {
	long long a, b, ans = 0;
	cin >> a;
	vector<int>j;
	for (int i = 0; i < a; i++) {
		cin >> b;
		j.push_back(b);
	}
	for (int i = 0; i < a; i++) {
		for (int k = i + 1; k < a; k++) {
			for (int x = k + 1; x < a; x++) {
				if (j[k] + j[x] > j[i] and j[i] + j[k] > j[x] and j[i] + j[x] > j[k] and j[k]!=j[x] and j[k]!=j[i] and j[x]!=j[i]) {
					ans++;
				}				
			}
		}
	}
	cout << ans;
}

Measured memory_bytes: 3132
n,m,R=map(int,input().split())
r=list(map(int,input().split()))
g=[[float("inf")]*n for _ in range(n)]
def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

for i in range(m):
    a,b,c=map(int,input().split())
    g[a-1][b-1]=c
    g[b-1][a-1]=c
g=warshall_floyd(g)
#print(g)
from itertools import permutations
P=permutations(r)
P=list(P)
#print(P)
ans=float("inf")
for p in P:
    #print(p)
    l=0
    for i in range(1,R):
        s=p[i-1]-1
        f=p[i]-1
        l+=g[s][f]
    #print(l)
    ans=min(ans,l)
print(ans)


Measured memory_bytes: 65752
#include<stdio.h>
#define MAX 100000
struct queue {
	char name[11];
	int time;
};

int head;
int tail;

struct queue dequeue(struct queue p[])
{	
	int i;
	struct queue tmp = p[head];
	head = (head + 1) % (MAX + 1);
	return tmp;
}

void enqueue(struct queue p[], struct queue tmp, int tail)
{	
	p[tail] = tmp;
}

int main()
{	
	int i, idx;
	int n, q;
	int rem, timer;
	struct queue p[MAX+1];

	scanf("%d %d", &n, &q);

	struct queue ret[n];

	for(i = 0; i < n; i++)
		scanf("%s %d", p[i].name, &p[i].time);
	head = 0;
	tail = n - 1;
	rem = n;
	timer = 0;
	idx = 0;
	
	while(timer <= 1000000 && rem > 0) {
		struct queue tmp;
		if(p[head].time <= q) {
			timer += p[head].time;
			tmp = dequeue(p);
			tmp.time = timer;
			enqueue(ret, tmp, idx);
			idx++;
			rem--;
		}
		else {
			timer += q;
			p[head].time -= q;
			tail = (tail + 1) % (MAX + 1);
			tmp = dequeue(p);
			enqueue(p, tmp, tail);
		}
	}

	for(i = 0; i < n; i++)
		printf("%s %d\n", ret[i].name, ret[i].time);

    return 0;
}

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

int main() {
  string s;
  cin >> s;
  int ans = s.length();
  int i = 1;
  while (i < s.length()) {
    if (s[i - 1] == s[i]) {
      i += 3;
      ans--;
    } else {
      i += 1;
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 640