akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

lint solve(string s) {
  
  int n = s.size();
  string t = s;
  reverse(ALL(t));

  // next[i][c] := s[i] 以降で最初に出現する c の位置
  vector<vector<int>> ns(n + 1, vector<int>(26, n));
  for (int i = n - 1; i >= 0; i--) {
    for (int j = 0; j < 26; j++) {
      ns[i][j] = ns[i + 1][j];
    }
    ns[i][s[i] - 'a'] = i;
  }

  vector<vector<int>> nt(n + 1, vector<int>(26, n));
  for (int i = n - 1; i >= 0; i--) {
    for (int j = 0; j < 26; j++) {
      nt[i][j] = nt[i + 1][j];
    }
    nt[i][t[i] - 'a'] = i;
  }

  vector<vector<lint>> dp(n + 1, vector<lint>(n + 1, 0));
  dp[0][0] = 1;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < 26; k++) {
        int ni = ns[i][k];
        int nj = nt[j][k];
        if (ni + nj + 2 > n) continue;
        dp[ni + 1][nj + 1] += dp[i][j];
        dp[ni + 1][nj + 1] %= MOD;
      }
    }
  }

  lint ret = 0;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; i + j <= n; j++) {
      int num = 1;
      for (int k = 0; k < 26; k++) {
        if (ns[i][k] + 1 + j <= n) {
          num++;
        }
      }
      ret = (ret + dp[i][j] * num % MOD) % MOD;
    }
  }

  return (ret - 1) % MOD;
}

int main() {
  
  string s; cin >> s;
  cout << solve(s) << endl;

  return 0;
}



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

using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
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;
}

/**
 * func: (long long) -> boolean
 * binary_search() returns the minimum element x which satisfies f(-∞) != f(x)
 * e.g.
 * i:    1 2 3 4 5 6 7 8 9
 * f(i): 0 0 0 0 0 0 1 1 1
 *                   ^
 *                   x
 */
template<class F>
ll binary_search(F func) {
    ll l = -1, r = 1;
    while (func(l) == func(r)) {
        l *= 2;
        r *= 2;
    }
    bool l_value = func(l);

    while (l != r) {
        ll m = (l + r);
        if (m % 2 == 0) m /= 2;
        else m = (m - 1) / 2;
        if (func(m) != l_value) {
            r = m;
        } else {
            l = m + 1;
        }
    }
    return l;
}

void solve(long long N, long long K, std::vector<long long> A) {

    auto f = [&](long long v) {
        if( v <= 0 ) return false;
        long long c = 0;
        for (auto i : A) {
            c += (i+v-1) / v - 1;
        }
        return c <= K;
    };
    auto ans = binary_search(f);




    cout << ans << endl;

}

int main() {
    long long N;
    scanf("%lld", &N);
    long long K;
    scanf("%lld", &K);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &A[i]);
    }
    solve(N, K, std::move(A));
    return 0;
}


Measured memory_bytes: 4752
#include <sstream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cassert>
#include <ctime>
#include <map>
#include <math.h>
#include <cstdio>
#include <set>
#include <deque>
#include <memory.h>
#include <queue>

#pragma comment(linker, "/STACK:64000000")
typedef long long ll;

using namespace std;

const int MAXN = 1 << 18;
const int MOD = 1; // 1000 * 1000 * 1000 + 7;
const int INF = 2e9;

int main() {
#ifdef _MSC_VER
	freopen("input.txt", "r", stdin);
#endif

	string s;
	int k;
	while (cin >> s >> k) {
		int n = s.length();
		for (int i = 0; i < n; i++) {
			int need = 'z' - s[i] + 1;
			if (need == 26) need = 0;
			if (need <= k) {
				s[i] = 'a';
				k -= need;
			}
		}

		s[n - 1] = 'a' + (s[n - 1] - 'a' + k) % 26;
		cout << s << endl;
	}

	return 0;
}

Measured memory_bytes: 512
m=[]
cnt=0
for i in range(5):
    x=int(input())
    m.append(x)
m10=[i % 10 for i in m if i %10 >=1]
if m10:
    t=min(m10)
    for i in m:
        if i %10==0:
            cnt += i
        else:
            cnt += ((i//10)+1)*10
    print(cnt-10+t)
else:
    print(sum(m))

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] ar = br.readLine().split(" ");
        int x = Integer.parseInt(ar[0]);
        int y = Integer.parseInt(ar[1]);
        int[][] list = new int[x+1][y+1];
        for(int i = 0; i < x; i++){
            ar = br.readLine().split(" ");
            for(int j = 0; j < y; j++){
                list[i][j] = Integer.parseInt(ar[j]);
            }
        }
        for(int i = 0; i < list.length; i++){
            for(int j = 0; j < list[i].length; j++){
                if(j == list[i].length-1){
                    System.out.println(list[i][j]);
                }else if(i == list.length-1){
                    list[i][y] += list[i][j];
                    System.out.print(list[i][j]+" ");
                }else{
                    list[i][y] += list[i][j];
                    list[x][j] += list[i][j];
                    System.out.print(list[i][j]+" ");
                }
            }
        }
    }
}

Measured memory_bytes: 31936
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<ctime>
#include<vector>
#include<set>
#include<map>
#include<stack>
using namespace std;
int main()
{     string s;
      int n,i;
      cin>>s;
      n=s.length();
      cout<<s[0]<<n-2<<s[n-1]<<endl;
	  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>
#include <set>
#include <list>
#include <cmath>
#include <map>

using namespace std;
typedef long long ll;


int main()
{
	int N;
	int p[20000];
	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> p[i];
	}
	int inv_p[20000];
	for(int i = 0; i < N; i++){
		inv_p[p[i]-1] = i+1;
	}
	
	for(int i = 0; i < N; i++){
		cout << i * N + inv_p[i];
		if(i < N-1){
			cout << " ";
		}else{
			cout << endl;
		}
	}
	for(int i = 0; i < N; i++){
		cout << (N-i) * N + inv_p[i];
		if(i < N-1){
			cout << " ";
		}else{
			cout << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <functional>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <queue>
#include <cstring>

//#define INF 1000000000;
#define MOD 1000000007;
#define LIMIT 1000000000000000000;
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define int long long
typedef pair<int, int> P;

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} SETUP;

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

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

const ll INF = 1LL << 60;

signed main() {
    int x; cin >> x;
    cout << (x < 1200 ? "ABC" : "ARC") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    string s; cin >> s;
    bool ans = 1;
    if(s[0] != 'A') ans = 0;
    int count = 0;
    for(int i = 2; i < s.size() - 1; i++){
        if(s[i] == 'C') count++;
        else if(isupper(s[i])) ans = 0;
    }
    if(count != 1) ans = 0;
    if(isupper(s[s.size() - 1]) or isupper(s[1])) ans = 0;
    cout << (ans ? "AC" : "WA") << endl;
}

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

#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define INF  (1<<30)
#define INFL (1LL<<60)
#define MOD 1000000007
#define EPS ((ld)(1e-9))

#define sz(x) ((int)(x).size())
#define setz(x) memset(x, 0, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define rep(i, x)  for (int i = 0, _##i = (x); i < _##i; i++)
#define repp(i, s, e) for (int i = (s), _##i = (e); i < _##i; i++)
#define repr(i, s, e) for (int i = (s)-1, _##i = (e); i >= _##i; i--)
#define repi(i, x) for (auto &i : (x))


using namespace std;

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

template<typename T, typename V>
ostream &operator<<(ostream &os, const pair<T, V> pai) { 
    return os << '(' << pai.first << ' ' << pai.second << ')';
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> v) {
    cout << '[';
    rep(i, sz(v)) cout << v[i] << ",";
    cout << "]";
    return os;
}

template<typename T>
ostream &operator<<(ostream &os, const set<T> v) {
    cout << "{";
    for (auto p : v) cout << p << ",";
    cout << "}";
    return os;
}

template<typename T, typename V>
ostream &operator<<(ostream &os, const map<T, V> v) {
    cout << "{";
    for (auto p : v) cout << p << ",";
    cout << "}";
    return os;
}

#ifndef __SOULTCH
#define debug(...) 0
#define endl '\n'
#else
#define debug(...) cout << " [-] ", _dbg(#__VA_ARGS__, __VA_ARGS__)
template<class TH> void _dbg(const char *sdbg, TH h){ cout << sdbg << '=' << h << endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
    while(*sdbg != ',') cout << *sdbg++;
    cout << '=' << (h) << ','; 
    _dbg(sdbg+1, a...);
}
#endif

template<typename T> void get_max(T &a, T b) {a = max(a, b);}
template<typename T> void get_min(T &a, T b) {a = min(a, b);}

int N;
int A[100000];
struct OP{
    bool end;
    int val;
    OP *l, *r;

    OP(bool pend, int pval, OP *pl, OP *pr) : end(pend), val(pval), l(pl), r(pr) { }
};
OP *B[100000];

void build(OP *t) {
    if (t->end) return;
    build(t->l);
    build(t->r);
    t->val = t->l->val-t->r->val;
}

void print(OP *t) {
    if (t->end) return;
    print(t->l);
    print(t->r);
    cout << t->l->val << ' ' << t->r->val << endl;
}

int main(void) {
    iostream::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);

    cin >> N;
    rep(i, N) cin >> A[i];
    sort(A, A+N);
    rep(i, N) B[i] = new OP(true, A[i], nullptr, nullptr);
    
    OP *l = new OP(false, 0, B[N-1], B[0]);
    repp(i, 1, N-1) {
        if (A[i] > 0) {
            swap(l->l, l->r);
            l = new OP(false, 0, B[i], l);
        } else {
            l = new OP(false, 0, l, B[i]);
        }
    }
    build(l);
    cout << l->val << endl;
    print(l);
}


Measured memory_bytes: 14080
n = int(input())
s = input()

ans = 0
b_l = [0] * n
g_l = [0] * n
r_l = [0] * n
for i in range(n):
    if s[i] == 'B':
        b_l[i] = 1
    if s[i] == 'G':
        g_l[i] = 1
    if s[i] == 'R':
        r_l[i] = 1
# print(b_l)
# print(g_l)
b_s = [0] * n
g_s = [0] * n
r_s = [0] * n
b_s[0] = b_l[0]
g_s[0] = g_l[0]
r_s[0] = r_l[0]
for i in range(1, n):
    b_s[i] = b_s[i-1] + b_l[i]
for i in range(1, n):
    g_s[i] = g_s[i-1] + g_l[i]
for i in range(1, n):
    r_s[i] = r_s[i-1] + r_l[i]
# print(b_s)
# print(g_s)
for i in range(n):
    # print(b_s[n-1] - b_s[i])
    # print(g_s[n-1] - g_s[i])
    # print((b_s[n-1] - b_s[i]) * (g_s[n-1] - g_s[i]))
    if s[i] == 'R':
        ans += (b_s[n-1] - b_s[i]) * (g_s[n-1] - g_s[i])
    if s[i] == 'B':
        ans += (r_s[n-1] - r_s[i]) * (g_s[n-1] - g_s[i])
    if s[i] == 'G':
        ans += (b_s[n-1] - b_s[i]) * (r_s[n-1] - r_s[i])
# print('ans', ans)

for i in range(n):
    for j in range(n):
        if i - j >= 0 and i + j < n:
            letters = {s[i-j], s[i], s[i+j]}
            if len(letters) == 3:
                ans -= 1
                # print(i, j)
# print('ans', ans)
print(ans)

Measured memory_bytes: 68724
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
vector<vector<vector<ll>>> dp(3005,vector<vector<ll>>(3005,vector<ll>(4,-INT_MAX)));
ll dfs(vector<vector<ll>>& g,ll i,ll j,ll k,ll r,ll c){
//	cout<<i<<" "<<j<<" "<<k<<endl;
	if(i<0||i>=r||j<0||j>=c||k>3)
	return -INT_MAX;
	if((i==r-1)&&(j==c-1)){
		if(k<3)
		return g[i][j];
		else return 0;
	}
	if(dp[i][j][k]!=-INT_MAX)
	return dp[i][j][k];
	dp[i][j][k]=max(g[i][j]+dfs(g,i,j+1,k+1,r,c),max(dfs(g,i+1,j,0,r,c),dfs(g,i,j+1,k,r,c)));
	if(k<3)
	dp[i][j][k]=max(dp[i][j][k],g[i][j]+dfs(g,i+1,j,0,r,c));
	return dp[i][j][k];
}
int main(){
	ll r,c,k,x,y,z;
	cin>>r>>c>>k;
	vector<vector<ll>> g(r,vector<ll>(c,0));
	for(int i=0;i<k;i++){
		cin>>x>>y>>z;
		g[x-1][y-1]=z;
	}
	ll ans=0;
	ans=dfs(g,0,0,0,r,c);
	cout<<ans<<endl;
}

Measured memory_bytes: 709432
Scanf.scanf "%d %d" (fun k t ->
    let a = Array.init t (fun i -> Scanf.scanf " %d" (fun a -> a, i)) in
    let rec loop rest prev acc =
        if rest = 0 then acc else (
            Array.sort (fun a b -> compare b a) a;
            let ma, mi = a.(0) in
            if mi <> prev then (
                a.(0) <- ma - 1, mi;
                loop (rest - 1) mi acc
            ) else (
                if t = 1 ||
                    let na, ni = a.(1) in
                    na = 0 then (
                        a.(0) <- ma - 1, mi;
                        loop (rest - 1) mi (acc + 1)
                    ) else (
                        let na, ni = a.(1) in
                        a.(1) <- na - 1, ni;
                        loop (rest - 1) ni acc
                    )
            )
        )
    in
    loop k (-1) 0 |> Printf.printf "%d\n"
)

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


int main(int argc, char const* argv[])
{
  int n;
  string s;
  cin >> n >> s;
  for (int i = 0; i < s.size(); i++) {
    int uni = (int)s[i] + n;
    if (uni > 90) {
      uni -= 26;
    }
    int *ptr = &uni;
    cout << (char)*ptr;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    n,a,b = inpm()
    if n%(a+b) == 0:
        print((n//(a+b))*a)
        return
    print( (n//(a+b)) * a + min(a,n%(a+b)) )
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 40796
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define FOR(i, a, b) for(ll i=(a); i < (ll)(b); ++i)
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;}

const int MAX = 200000;
const ll MOD = 998244353;
ll fac[MAX+1],finv[MAX+1],inv[MAX+1];

void COMinit(){
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(int i=2; i<=MAX; i++){
		fac[i] = fac[i-1]*i%MOD;
		inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
		finv[i] = finv[i-1]*inv[i]%MOD;
	}
}

ll COM(ll n, ll k){
	if(n < k) return 0;
	if(n < 0 || k < 0) return 0;
	return fac[n] * (finv[k]*finv[n-k]%MOD) %MOD;
}

ll calc_pow(ll x, ll n){
	ll ret = 1;
	while(n>0){
		if(n & 1) ret = ret*x%MOD;
		x = x*x%MOD;
		n >>= 1;
	}
	return ret;
}

int main(){
	ll n,m,k;
	cin >> n >> m >> k;
	
	COMinit();
	
	ll ans = 0;
	for(int pr=0; pr<=k; pr++){
		// num = n-pr;
		// a=m * (m-1)^(num-1);
		// a *= num_C_pr;
		ll num = n-pr;
		ll a = m;
		//REP(i,num-1) a *= m-1;
		a = a*calc_pow(m-1, num-1)%MOD;
		
		a = a*COM(n-1,pr)%MOD;
		ans = (ans+a)%MOD;
	}
	
	cout << ans << endl;
	
	
	return 0;
}

Measured memory_bytes: 8292
#include <stdio.h>
int z[9999],r[9999];
int f(int a,int b){
	printf("? %d %d\n",a,b);
	fflush(stdout);
	char c[2];
	scanf("%s",c);
	return *c=='Y';
}
int main(){
	int a,b,c=0,h,i=0;
	scanf("%d%d",&a,&b);
	if(a<=b){puts("Impossible");return 0;}
	for(a+=b;i<a;i++)if(!c||f(i,z[c-1]))z[c++]=i;else c--;
	h=z[0];
	for(i=0;i<a;i++)r[i]=h==i||f(h,i);
	printf("! ");
	for(i=0;i<a;i++)printf("%d",r[i]);
	puts("");
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

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

  cout << s.replace(3, 1, "8") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }

inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }



int main()
{
    int a,b,c,k;
    scanf("%d %d %d %d",&a,&b,&c,&k);
    int ans=0;
    ans+=min(k,a);
    k-=min(k,a);
    k-=min(k,b);
    ans-=min(k,c);

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

    return 0;
}

Measured memory_bytes: 3828
#include <iostream>
//#include <iomanip>
#include <string>
//#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <bitset>
//#include <math.h>
using namespace std ;
//using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

string yorn(bool a){if(a) return"Yes" ; return "No" ;}
//string YorN(bool a){if(a) return"YES" ; return "NO" ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	string s ; cin >> s ;
	for(int i=0;i<s.size()-8;i++) cout << s.at(i) ;
	cout << endl ;
}


Measured memory_bytes: 256
n, c, k = map(int, input().split())
T = list(int(input()) for _ in range(n))
T.sort()

lmt = 0
flg = True
tmp_c = c
bus_cnt = 0
for i in range(len(T)-1):
    if flg:
        lmt = T[i] + k
        flg = False
        bus_cnt += 1
    if tmp_c >= 0 or lmt >= T[i]:
        tmp_c -= 1
    if tmp_c <= 0 or lmt < T[i+1]:
        flg = True
        tmp_c = c
else:
    if tmp_c <= 0 or lmt < T[-1]:
        bus_cnt += 1

print(bus_cnt)

Measured memory_bytes: 81420
sx,sy,tx,ty = map(int,input().split())

ans = ""
ans+="L"
for i in range(ty - sy + 1):
    ans+="U"
for i in range(tx - sx + 1):
    ans+="R"
ans+="D"
ans+="R"
for i in range(ty - sy + 1):
    ans+="D"
for i in range(tx - sx + 1):
    ans+="L"
for i in range(ty - sy + 1):
    ans+="U"
for i in range(tx - sx):
    ans+="R"
for i in range(ty - sy):
    ans+="D"
for i in range(tx - sx):
    ans+="L"

print(ans)


Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>

typedef long long int int64;

int root(int *u,int x){
  if(u[x]==x) return x;
  return u[x]=root(u,u[x]);
}

int same(int *u,int x,int y){
  return root(u,x)==root(u,y);
}

void unite(int *u,int x,int y){
  x=root(u,x);
  y=root(u,y);
  if(x==y) return;
  u[x]=y;
}

void run(void){
  int n,m;
  scanf("%d%d",&n,&m);
  int *u=(int *)calloc(n+1,sizeof(int));
  int i;
  for(i=0;i<=n;i++) u[i]=i;
  for(i=0;i<m;i++){
    int a,b;
    scanf("%d%d",&a,&b);
    unite(u,a,b);
  }
  int a,b,c;
  a=b=c=0;
  for(i=1;i<=n;i++){
    if(same(u,1,i)){
      a++;
    } else if(same(u,2,i)){
      b++;
    } else {
      c++;
    }
  }
  if(a<=b){
    b+=c;
  } else {
    a+=c;
  }
  int64 ans=(int64)a*(a-1)/2+(int64)b*(b-1)/2-m;
  printf("%lld\n",ans);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353,INF=1e18;



int main() {
    int N;
    cin>>N;
    vector<int> A(N);
    rep(i,N)cin>>A.at(i);
    vector<int> v(0);
    rep(i,N){
        v.pb(A.at(i)-i);
    }
    sort(v.begin(),v.end());
    ll ans=0;
    rep(i,N){
        int x=-i-A.at(i);
        ll count=upper_bound(v.begin(),v.end(),x)-lower_bound(v.begin(),v.end(),x);
        ans+=count;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 5104
#include <bits/stdc++.h>
using namespace std;
#define ull unsigned long long

int main(){
  int N;
  cin >> N;
  vector<ull> A(N+1);
  ull B, ans = 0;
  
  for (int i = 0; i < N + 1; i++) cin >> A.at(i);
  for (int i = 0; i < N; i++) {
    cin >> B;
    if (B > A.at(i)) {
      ans += A.at(i);
      B -= A.at(i);
      ans +=  B > A.at(i + 1) ? A.at(i + 1) : B;
      A.at(i + 1) =  B > A.at(i + 1) ? 0 : A.at(i + 1) - B;
      A.at(i) = 0;
    } else {
      A.at(i) -= B;
      ans += B;
    }
  }
  
  cout << ans;
  
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using namespace std;
typedef pair<int, int> P;
#define N 100000
int main() {
    int n;
    long long k;
    cin >> n >> k;
    int a[n], b[n];
    P p[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
        p[i] = {a[i], b[i]};
    }
    sort(p, p + n);
    long long sum = 0;
    for (int i = 0; i < n; i++) {
        sum += p[i].second;
        if (sum >= k) {
            cout << p[i].first << endl;
            return 0;
        }
    }
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
int main(){
  string s;cin >> s;
  ll K,n = s.size(),i,j,k,l;cin >> K;
  ll dp[n+1][2][K+2];
  memset(dp,0,sizeof(dp));dp[0][0][0] = 1;
  ll z;
  for(i=0;i<n;i++){
    z = s[i]-'0';
    for(j=0;j<2;j++){
      for(k=0;k<=K;k++){
        dp[i+1][j|(z!=0)][k] += dp[i][j][k];
        for(l=1;l<=(j ? 9:z);l++){
          dp[i+1][j|(l<z)][k+1] += dp[i][j][k];
        }
      }
    }
  }
  printf("%lld\n",dp[n][0][K]+dp[n][1][K]);
}

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

#define ARG4(_1, _2, _3, _4, ...) _4
#define rep(...) ARG4(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define REP(i, a) FOR(i, 0, a)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(...) ARG4(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define RREP(i, a) RFOR(i, 0, a)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (int)(a); --i)
#define ALL(c) (c).begin(), (c).end()
#define TEN(n) ((ll)(1e##n))
#define pb emplace_back
#define mp make_pair
#define fi first
#define se second
#define let const auto
#define USE_T template <typename T>
#define USE_Ti template <typename T = int>
#define USE_TU template <typename T, typename U>

USE_Ti using duo = std::pair<T, T>;
USE_Ti using vec = std::vector<T>;
using ll = long long;
// clang-format off
USE_TU inline bool chmax(T&x,U a){return x<a&&(x=a,1);}
USE_TU inline bool chmin(T&x,U a){return a<x&&(x=a,1);}
USE_Ti inline T in(){T x;std::cin>>x;return x;}
USE_Ti inline vec<T> in(int n){vec<T> v;v.reserve(n);rep(i,n)v.pb(in<T>());return v;}
USE_T inline void in(T*x,int n){rep(i,n)x[i]=in<T>();}
struct IoSetup {
  IoSetup(){
    using namespace std;
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<setprecision(10);
    cerr<<setprecision(10);
  }
} iosetup;
// clang-format on
// }}}
using namespace std;
const int inf = 1001001001;
const ll infll = 1001001001001001001ll;
const int dd[] = {0, 1, 0, -1, 0};

signed main() {
  int A = in(), B = in(), C = in(), D = in(), P = in();
  cout << min(A * P, B + max(P - C, 0) * D) << endl;
  return 0;
}

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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)

#define irrep(i,n) for(int i = (int)(n); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<v_char > v2_char;
typedef std::vector<double> v_double;
typedef std::vector<v_double > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<v_int > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<v_ll > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<v_string > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<v_bool > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std; 

int main(void)
{
    int n, k;
    cin >> n >> k;

    v_int x(n);
    irep(i, n) {
        cin >> x[i];
    }

    int ans = 0;
    irep(i, n) {
        ans += 2 * min(x[i], abs(x[i]-k));
    }
    cout << ans << endl;
    return 0;
}   
/** atcoder **/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int  main(){
    string s; cin >> s;
    for (int i = 0; i < s.size() - 1; ++i){
        for (int j = i; j < s.size(); ++j){
            if (s[i] == 'C' && s[j] == 'F'){
                cout << "Yes" << endl;
                exit(0);
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <utility>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
using namespace std;
int main() {
	int K, N;
	int ans = INF;
	int sum = 0;
	cin >> K >> N;
	vector<int> a(N);

	vector<int> b(N) ;
	for (int i = 0; i < N; i++)cin >> a.at(i);
	for (int i = 0; i < N-1; i++)b.at(i) = a.at(i + 1) - a.at(i);
	b.at(N - 1) = K - a.at(N - 1) + a.at(0);
	for (int i = 0; i < N; i++)sum += b.at(i);
	for (int i = 0; i < N; i++) {
		if (ans> sum - b.at(i))ans = sum - b.at(i);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4856
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var Instance = new Question();
			Instance.Exec();
		}
	}

	public class Question
	{
		public void Exec()
		{
			var array = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
			long a = array[0];
			long b = array[1];
			long c = array[2];
			string result = "No";
			if (a < b && b < c) {
				result = "Yes";
			}

			Console.WriteLine($"{result}");
			Console.Out.Flush();
			Console.ReadKey();
		}
	}
}


Measured memory_bytes: 18300
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

W, H, N = MAP()
xya = [LIST() for _ in range(N)]

right = W
left = 0
top = H
bottom = 0

for x, y, a in xya:
	if a == 1 and left < x < right:
		left = x
	elif a == 1 and right <= x:
		S = 0
		break
	elif a == 2 and left < x < right:
		right = x
	elif a == 2 and x <= left:
		S = 0
		break
	elif a == 3 and bottom < y < top:
		bottom = y
	elif a == 3 and top <= y:
		S = 0
		break
	elif a == 4 and bottom < y < top:
		top = y
	elif a == 4 and y <= bottom:
		S = 0
		break
	else:
		pass
	# print(left, right, top, bottom)
	S = (right-left)*(top-bottom)
if S <= 0:
	S = 0
print(S)

Measured memory_bytes: 3896
n, m = [int(x) for x in input().split()]

count_set = set(range(1, m + 1))
for _ in range(n):
    temp_list = [int(x) for x in input().split()]
    temp_list[0] = 0
    count_set &= set(temp_list)
print(len(count_set))

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  lint N;
  cin>>N;
  for(int i=(sqrt(N)+0.001);i>=1;i--){
    if(N%i==0){
      cerr<<i<<" "<<N/i<<endl;
      cout<<i+N/i-2<<endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
N, K = gets.split.map(&:to_i)

res = 0
(K+1 .. N).each do |b|
  p, q = N.divmod(b)
  res += p * [0, b - K].max
  res += [0, q + 1 - K].max
end
res -= N if K == 0
puts res

Measured memory_bytes: 1788
let rec take n = function
  | [] -> []
  | x :: xs ->
      if n <= 0 then []
      else x :: take (n - 1) xs

module IntMap = Map.Make (struct
  type t = int
  let compare = compare
end)

let () = Scanf.scanf "%d %d\n" @@ fun n k ->
  let as_ = Array.init n @@ fun _ ->
    Scanf.scanf "%d " @@ fun a -> a in
  Array.fold_left (fun m a ->
    IntMap.add a (1 + try IntMap.find a m with Not_found -> 0) m) IntMap.empty as_
  |> IntMap.bindings
  |> List.sort (fun (_, n) (_, m) -> compare n m)
  |> (fun xs -> take (List.length xs - k) xs)
  |> List.map snd
  |> List.fold_left ( + ) 0
  |> Printf.printf "%d\n"




Measured memory_bytes: 32552
N = int(input())

ans = True
cx = 0
cy = 0
ct = 0
for _ in range(N):
    t, x, y = map(int, input().split())
    d = abs(cx - x) + abs(cy - y)
    dt = t - (ct + d)
    if dt % 2 == 0 and dt >= 0:
        cx = x
        cy = y
        ct = t
    else:
        ans = False
        break

if ans:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 45672
#include<bits/stdc++.h>
#define fastio 	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define unmap  	unordered_map<int,int>
#define	unset	unordered_set<int>
#define maxpq  	priority_queue<int>
#define minpq  	priority_queue<int, vector<int>, greater<int>>
#define pb 		push_back		
#define ll 		long long
#define ull     unsigned ll
#define ff 		first
#define ss 		second//typedef second ss;
#define foton(i,n) for(int i=0;i<n;i++)
#define	faton(i,a,n)	for(int i=a;i<=n;i++)
ll const mod = 1000000007ll;
int const inf = 10000007;
#define endl "\n"
using namespace std;

int main(){
	fastio;
	int n;cin>>n;
    if(n<2){
        cout<<0<<endl;
        return 0;
    }
    ll a1=1,a2=1,a3=1;
    faton(i,1,n){
        a1 = (10*a1);
        a1 %= mod;// all filled by 10 way 0 to 9(union)
        a2 = (9*a2)%mod;
        a2 %= mod; // all filled by 9 way excluding 0 or excluding 1
        a3 = (8*a3)%mod; // all filled by 8 way excluding 0 and 1 both
        a3 %= mod;
    } 
    ll ans = a1-(2*a2)+a3;
    
    if(ans<0)cout<<(ans%mod)+mod<<endl;
    else{
        cout<<ans%mod<<endl;
    }
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

vector<int> vx,vy;
bool dp1[8001][16002],dp2[8001][16002];
int main(){
    string s;
    int x,y;
    cin>>s>>x>>y;
    int cnt=0;
    bool flag=true;
    rep(i,s.size()){
        if(s[i]=='F') ++cnt;
        else if(flag){
            vx.pb(cnt);
            cnt=0;flag=false;
        }
        else{
            vy.pb(cnt);
            cnt=0;flag=true;
        }
    }
    if(flag) vx.pb(cnt);
    else vy.pb(cnt);
    if(vx.size()>0) dp1[0][8000+vx[0]]=true;
    else dp1[0][8000]=true;
    FOR(i,1,vx.size()){
        int tx=vx[i];
        rep(j,16000){
            if(dp1[i-1][j]){
                if(j+tx<=16001)dp1[i][j+tx]=true;
                if(j-tx>=0)dp1[i][j-tx]=true;
            }
        }
    }
    if(vy.size()>0){
        dp2[0][8000+vy[0]]=true;
        dp2[0][8000-vy[0]]=true;
    }
    else dp2[0][8000]=true;
    FOR(i,1,vy.size()){
        int tx=vy[i];
        rep(j,16000){
            if(dp2[i-1][j]){
                if(j+tx<=16001)dp2[i][j+tx]=true;
                if(j-tx>=0)dp2[i][j-tx]=true;
            }
        }
    }
    int xs=max((int)vx.size(),1);
    int ys=max((int)vy.size(),1);
    if(dp1[xs-1][x+8000]&&dp2[ys-1][y+8000]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 125696
#!/usr/bin/env python3


def main():
    h, w = (int(x) for x in input().split())
    passed = sum(input().count("#") for _ in range(h))
    if passed == h + w - 1:
        print("Possible")
    else:
        print("Impossible")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3192
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<algorithm>
#include<cmath>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include<sstream>
#include<numeric>
#include<queue>
#include<cstdio>
#include<iterator>
#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
using ull = unsigned long long;

#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb(x) push_back(x)
ll mod = 1e9 + 7;
ll inf = 1e9 + 7;
template<typename T, typename U>
T binpow(T a, U n) {
    if (n == 0)
        return 1;
    if (n % 2 == 1)
        return (binpow(a, n - 1) * a) % mod;
    else {
        ll b = binpow(a, n / 2) % mod;
        return (b * b) % mod;
    }
}
template<typename T>
T gcd(T a, T b) {
    if (b == 0)
        return a;
    else
        return gcd(b, a % b);
}
template<typename T>
istream& operator>>(istream& str, vector<T>& vec) {
    for (auto& w : vec) str >> w;
    return str;
}
template<typename T>
ostream& operator<<(ostream& str, vector<T>& vec) {
    for (auto& w : vec) str << w << ' ';
    return str;
}





int main() {
    ll h, w, ch, cw, dh, dw, m;
    cin >> h >> w >> m;
    /*vector<vector<ll>>vec(h, vector<ll>(w, inf));
    vector<vector<bool>> mapp(h, vector<bool>(w));
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            char c;
            cin >> c;
            if (c == '.')mapp[i][j] = 1;
        }
    }
    for(int i )*/
    vector<int> cols(w), rows(h);
    vector <pair<int, int>>tg(m);
    set<pair<int, int>>mn;
    for (int i = 0; i < m; ++i) {
        cin >> tg[i].first >> tg[i].second;
        mn.insert(tg[i]);
        rows[tg[i].first - 1]++;
        cols[tg[i].second - 1]++;
    }
    int maxcol = max_element(all(cols)) - cols.begin();
    int maxrow = max_element(all(rows)) - rows.begin();
    vector<int>irow, icol;
    for (int i = 0; i < rows.size(); ++i) {
        if (rows[i] == rows[maxrow])irow.push_back(i);
    }
    for (int i = 0; i < cols.size(); ++i) {
        if (cols[i] == cols[maxcol])icol.push_back(i);
    }
    bool flag = false;
    for (int i = 0; i < irow.size(); ++i) {
        for (int j = 0; j < icol.size(); ++j) {
            if (mn.count({ irow[i] + 1 ,icol[j] + 1 }) == 0) {
                flag = true;
                break;
            }
        }
    }
    if (!flag) {
        cout << cols[maxcol] + rows[maxrow] - 1;
    }
    else {
        cout << cols[maxcol] + rows[maxrow];
    }

}

Measured memory_bytes: 25712
import Control.Monad
  import Control.Monad.ST
  import qualified Data.Array as A
  import qualified Data.Array.ST as ST
  import qualified Data.Array.Unboxed as AU
  import Data.Bits
  import qualified Data.ByteString.Char8 as BS
  import Data.Char
  import Data.Int
  import qualified Data.IntMap as IM
  import Data.List
  import qualified Data.Map as M
  import Data.Maybe
  import Data.Ord
  import qualified Data.Set as S
  import Data.Time
  import qualified Data.Vector as V
  import qualified Data.Vector.Mutable as VM
  import qualified Data.Vector.Unboxed as VU
  import qualified Data.Vector.Unboxed.Mutable as VUM
  
  readInt :: IO [Int]
  readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine
  
  readInts :: Int -> IO [[Int]]
  readInts n = replicateM n readInt
  
  readInteger :: IO [Integer]
  readInteger = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine
  
  readIntegers :: Int -> IO [[Integer]]
  readIntegers n = replicateM n readInteger
  
  readString :: IO [String]
  readString = map BS.unpack . BS.words <$> BS.getLine
  
  readStrings :: Int -> IO [[String]]
  readStrings n = replicateM n <$> readString
  
  toPair :: [a] -> (a, a)
  toPair [x, y] = (x, y)
  
  main = do
    [n, a, b, c, d] <- readInt
    s <- getLine
    putStrLn $ solve a b c d s
  
  solve a b c d s
    | x && y = "Yes"
    | otherwise = "No"
    where
      x =
        (< 2) $
        maximum $
        map
          (\ss ->
             if head ss == '#'
               then length ss
               else 0) $
        group $ drop (a - 1) $ take (max c d) s
      y =
        c < d ||
        ((> 2) $
         maximum $
         map
           (\ss ->
              if head ss /= '#'
                then length ss
                else 0) $
         group $ drop (b - 2) $ take (min c d + 1) s)

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

bool isInclude3(int x) {
    string s = to_string(x);
    for (char i : s) if (i == '3') return true;
    return false;
};

int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) if (i % 3 == 0 || isInclude3(i)) cout << " " << i;
    cout << endl;
}



Measured memory_bytes: 3288
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main()
{
  long long int N,W;
  cin >> N >> W;
  vector<vector<long long int> >V(4);
  long long int a0,a,b;
  cin >> a0 >> b;
  V[0].push_back(b);
  for(int i=1; i < N; i++){
    cin >> a >> b;
    if(a == a0)
      V[0].push_back(b);
    else if(a == a0+1)
      V[1].push_back(b);
    else if(a == a0+2)
      V[2].push_back(b);
    else if(a == a0+3)
      V[3].push_back(b);
  }
  for(int i=0; i < 4; i++)
    sort(V[i].begin(), V[i].end(),greater<long long int>());

  long long int sum=0;
  long long int max=0;
  for(int i=0; i < V[0].size()+1; i++){
    for(int j=0; j < V[1].size()+1; j++){
      for(int k=0; k < V[2].size()+1; k++){
	for(int l=0; l < V[3].size()+1; l++){
	  if(i < V[0].size())
	    for(int n=0; n <= i; n++)
	      sum += V[0][n];
	  if(j < V[1].size())
	    for(int n=0; n <= j; n++)
	      sum += V[1][n];
	  if(k < V[2].size())
	    for(int n=0; n <= k; n++)
	      sum += V[2][n];
	  if(l < V[3].size())
	    for(int n=0; n <= l; n++)
	      sum += V[3][n];
	  long long int x0,x1,x2,x3;
	  if(i == V[0].size())
	    x0 = 0;
	  else
            x0 = a0*(i+1);
	  if(j == V[1].size())
	    x1 = 0;
	  else
            x1 = (a0+1)*(j+1);
	  if(k == V[2].size())
	    x2 = 0;
	  else
            x2 = (a0+2)*(k+1);
	  if(l == V[3].size())
	    x3 = 0;
	  else
            x3 = (a0+3)*(l+1);
	  if(x0+x1+x2+x3 <= W && sum >= max)
	    max = sum;
	  sum = 0;
	}
      }
    }
  }
  cout << max << endl;
  return 0;
}


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

int n,P,Q,c[1114514],s,ans,x[1114514];

signed main(){
	cin>>n>>P>>Q;
	r(i,n){
		scanf("%ld",&c[i]);
		x[i]=(Q-i)*P-c[i];
		s+=c[i];
	}
	sort(x,x+n,greater<int>());
	ans=s;
	r(i,n){
		s+=x[i];
		s+=2*i*P;
		ans=max(ans,s);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 11064
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>

using namespace std;

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef vector<LL> VLL;
typedef complex<double> P;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define MT(a,b,c) MP(a, MP(b, c))
#define T1 first
#define T2 second.first
#define T3 second.second

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EPS 1.0e-9

//AOJ1305
set<string> ss;
multimap<string, string> mss;
set<string> vis;

int main(){
	int n;
	char buf[1024];
	while(cin>>n,n){
		ss.clear();
		mss.clear();
		vis.clear();
		cin>>buf;
		char *_c = strtok(buf, ":");
		while((_c=strtok(NULL, ",."))!=NULL)ss.insert(_c);
		REP(i,n-1){
			cin>>buf;
			char *c = strtok(buf, ":");
			string tstr(c);
			mss.insert(MP(tstr,"0"));
			while((c=strtok(NULL, ",."))!=NULL)mss.insert(MP(tstr, c));
		}
		int flag = 1;
		do{
			flag = 0;
			for(set<string>::iterator it=ss.begin(); it!=ss.end(); it++){
				pair<multimap<string, string>::iterator,multimap<string, string>::iterator> its=mss.equal_range(*it);
				if(its.first == its.second)continue;
				its.first++;
				ss.erase(it);
				for(multimap<string, string>::iterator it2=its.first; it2!=its.second; it2++){
					ss.insert(it2->second);
					flag = 1;
				}
				mss.erase(its.first, its.second);
				if(flag)break;
			}
		}while(flag);
		cout << ss.size() << endl;
	}
	return 0;
}

Measured memory_bytes: 1348
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
	
	int N = 100000;
	
	bool a[100000];
	
	for(int i = 0; i < N; i++){
		a[i] = true;
	}
	
	a[0] = false;
	a[1] = false;
	
	for(int i = 2; i < N; i++){
		if(a[i]){
			for(int j = i * 2; j < N; j += i){
				a[j] = false;
			}
		}
	}
	
	int n;
	
	while(true){
		cin >> n;
		if(n == 0){
			break;
		}else if(n < 5 || n > 10000){
			printf("NA\n");
			continue;
		}else{
			for(int i = n; i > 2; i--){
				if(a[i] && a[i - 2]){
					printf("%d %d\n", i - 2, i);
					break;
				}
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 1240
#include <iostream>
#include <math.h>
using namespace std;

long long N, A, B;
long long * X;
long long res = 0;
int main()
{
	cin >> N >> A >> B;
	X = new long long [N];
	for (int i = 0; i < N; i++)
		cin >> X[i];

	for (int i = 0; i < N - 1; i++)
	{
		long long a = A * (X[i + 1] - X[i]);
		res += (a >= B) ? B : a;			
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
#include<functional>
#include<stack>
using namespace std;
int main(void)
{
	int q,x,d,p,i,n,t,a;
	stack<int> s[1000];

	scanf("%d %d",&n,&q);
	for(i=0;i<q;i++)	{
		scanf("%d",&a);
		if(a==0)	{
			scanf("%d %d",&t,&x);
			s[t].push(x);
		}
		else if(a==1)	{
			scanf("%d",&t);
			if(s[t].size()!=0)	printf("%d\n",s[t].top());
		}
		else {
			scanf("%d",&t);
			if(s[t].size()!=0)	s[t].pop();
		}
	}
	return 0;
}


Measured memory_bytes: 3884
#include<iostream>
#include<cstdio>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<map>
#include<numeric>
#include<stack>
#include<queue>
#include<functional>
#include<cassert>
#include<set>
#define rep(a,b) for(int a=0;a<b;++a)
#define REP(a,b,c,d) for(int a=b;a<c;a+=d)
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define mod 1000000007
using namespace std;
using ll = long long;
using p_i = pair<int, int>;
int main() {
	int N; cin >> N;
	vector<int> h(N);
	vector<int> dp(N);
	rep(i, N)cin >> h[i];
	REP(i, 1, N, 1) {
		dp[i] = dp[i - 1] + abs(h[i - 1] - h[i]);
		if (i > 1)dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
	}
	cout << dp[N - 1] << endl;
	cin >> N;
}

Measured memory_bytes: 1024
#include <cmath>
#include<iostream>
#include <functional>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <iomanip>
using namespace std;
 
int main(){    
  long long N,count=0;
  string I;
  cin >> N;
  
  string S[N];
  long long T[N];
  
  for(int i=0;i<N;i++){
    cin >> S[i] >> T[i];
  }
  cin >> I;
  
  for(int i=0;i<N;i++){
    if(S[i] == I){
      for(int j=i+1;j<N;j++){
      count += T[j];
      }
    } 
  }
  cout << count <<endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline


n = int(input())
L = [int(input()) for _ in range(n)]
L.sort()
n_2 =n // 2

ans = 0
if n % 2 == 1:
    ans = 2*sum(L[n_2+1:])-2*sum(L[:n_2-1])-L[n_2-1]-L[n_2]
    ans_2 = 2*sum(L[n_2+2:])-2*sum(L[:n_2])+L[n_2+1]+L[n_2]
    ans = max(ans,ans_2)
else:
    ans = 2*sum(L[n_2+1:])-2*sum(L[:n_2-1])+L[n_2]-L[n_2-1]
    

print(ans)


Measured memory_bytes: 7516