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

int main(){
    long N, W; cin >> N >> W;
    vector<vector<long>> dp(N+1, vector<long>(W+1, 0));
    for(int i=0; i<N; i++){
        int w, v; cin >> w >> v;
        for(int j=0; j<W+1; j++){
            if( j-w >=0 ) dp[i+1][j] = max(dp[i+1][j], dp[i][j-w]+v);
            dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
        }
    }
    cout << dp[N][W] << endl;
}

Measured memory_bytes: 80256
//include
//------------------------------------------
#include <bits/stdc++.h>
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();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//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())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
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; }

int main(void){

    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    REP(i, tx-sx) cout << 'R';
    REP(i, ty-sy) cout << 'U';
    REP(i, tx-sx) cout << 'L';
    REP(i, ty-sy) cout << 'D';
    cout << 'D';
    REP(i, tx-sx+1) cout << 'R';
    REP(i, ty-sy+1) cout << 'U';
    cout << 'L';
    cout << 'U';
    REP(i, tx-sx+1) cout << 'L';
    REP(i, ty-sy+1) cout << 'D';
    cout << 'R' << endl;

    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mii map <int, int>
#define mll map <ll, ll>
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vd vector <double>
#define vll vector <ll>
#define fi first
#define se second
#define si set <int>
#define sll set <ll>
#define spii set <pii>
#define vs vector <string>
#define vpii vector <pair <int,int> >
#define vpll vector <pair <long long,long long> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pii > >
#define mp make_pair
#define vvll vector <vll>
#define vsi vector <si>
#define forn(i, n) for (int i = 0; i < (n); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define for1(i, n) for (int i = 1; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()


const ll INFLL = 1e18;
const int MAXN = 2e5+100;
const ll INF = 1e9;
const ll mod1=1e9+7;
const ll mod2=2e9+11;
int n;
ll a[MAXN];
ll ans[MAXN];
vi dp;
vvi g;
void dfs(int s,int p)
{
    ans[s]=dp.size();
    for (auto to:g[s])
    {
        if (to==p)
            continue;
        int x=a[to];
        auto t=lower_bound(all(dp),x);
        int i=t-dp.begin();
        int was=dp[i];
        bool ok=false;
        if (t==dp.end())
            dp.pb(x),ok=true;
        else
            *t=x;
        dfs(to,s);
        if (ok)
            dp.pop_back();
        else
            dp[i]=was;
    }
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifdef LOCAL
    freopen("a.in","r",stdin);
#endif
    cin>>n;
    g=vvi(n);
    for (int i=0;i<n;i++)
        cin>>a[i];
    for (int i=0;i<n-1;i++)
    {
        int u,v;
        cin>>u>>v;
        u--,v--;
        g[u].pb(v);
        g[v].pb(u);
    }
    dp.pb(a[0]);
    dfs(0,0);
    for (int i=0;i<n;i++)
        cout<<ans[i]<<'\n';



}

Measured memory_bytes: 34492
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<double,double> pdd;
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) ll(i.size())
#define FOR(i, j, k, in) for (ll i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (ll i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif

template<class T> inline bool cmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool cmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MOD=1000000007;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll MAXN=1e5+5;
const ll MAXLG=__lg(MAXN)+2;

ll n,k,h[MAXN];
ll dp[MAXN];
/********** Good Luck :) **********/
int main()
{
    IOS();
    cin >> n >> k;
    REP (i,n) {
        cin >> h[i];
    }

    MEM(dp,INF);
    dp[0] = 0;
    for (ll i=1;i<n;i++) {
        for (ll j=1;j<=k;j++) {
            if (i - j >= 0) {
                dp[i] = min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
            }
        }
    }

    cout << dp[n-1] << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#define ll long long
#define fr(i,l,r) for(i=(l);i<(r);i++)
#define min(p,q)((p)<(q)?(p):(q))

int main(void)
{
	//変数の宣言
	char s[20];
	int n[20];
	
	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	int temp,temp1,temp2;
	int max,min;
	int len;
	//データの読み込み
	
	scanf("%s",&s);
	
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	len=strlen(s);
	for(i=0;i<len;i++){
		n[i]=(int)s[i]-48;
	}
	
//	for(i=0;i<len;i++){
//		printf("n[i]=%d\n",n[i]);
//	}
	
	ans=1000;
	for(i=0;i<len-2;i++){
		temp=n[i]*100+n[i+1]*10+n[i+2];
		if(ans>abs(753-temp)) ans=abs(753-temp);
	}
	
//	printf("計算部分終了\n");
	//出力
	
	printf("%d",ans);
	
//	printf("結果の出力終了\n");
	
	return 0;
	
}



Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
#define MAX 100005
int num[MAX];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&num[i]);
    ll sum,ans,cnt;
    sum=0;
    ans=0;
    for(int i=1;i<=n;i++)
    {
        sum+=num[i];
        if(sum<=0&&i%2)
        {
            ans+=1-sum;
            sum=1;
        }
        else if(sum>=0&&!(i%2))
        {
            ans+=sum+1;
            sum=-1;
        }
    }
    sum=0;
    cnt=0;
    for(int i=1;i<=n;i++)
    {
        sum+=num[i];
        if(sum>=0&&i%2)
        {
            cnt+=sum+1;
            sum=-1;
        }
        else if(sum<=0&&!(i%2))
        {
            cnt+=1-sum;
            sum=1;
        }
    }
    printf("%lld\n",min(ans,cnt));
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void) {
	char s[13];
	char ans[13];
	fgets(s,13, stdin);
	for(int i = 0; i < 12; i++){
		if(i == 4){
			ans[i] = ' ';
		}
		if(i >= 4){
			ans[i+1] = s[i];
		}
		else{
			ans[i] = s[i];
		}
	}
	
	printf("%s\n", ans);
	
	return 0;
}

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

using namespace std;
typedef long long ll;

struct edge {
  int to, cost;
  edge() {}
  edge(int t, int c) : to(t), cost(c) {}
};

int n;
double p;
vector<edge> G[100010];
double dp1[100010], dp2[100010];

void f(int v, int pv) {
  for (int i = 0; i < G[v].size(); i++) {
    int ch = G[v][i].to;
    if (ch == pv) continue;
    f(ch, v);
    dp1[v] += G[v][i].cost + dp1[ch];
  }
  dp1[v] *= p;
}

void g(int v, int pv) {
  for (int i = 0; i < G[v].size(); i++) {
    int ch = G[v][i].to;
    if (ch == pv) continue;
    g(ch, v);
    dp2[v] += G[v][i].cost + dp2[ch];
  }
  dp2[v] *= p;
  dp2[v] += dp1[0];
}

int main() {
  cin >> p >> n;
  for (int i = 0; i < n - 1; i++) {
    int x, y, c;
    cin >> x >> y >> c;
    x--, y--;
    G[x].push_back(edge(y, c));
    G[y].push_back(edge(x, c));
  }
  f(0, -1);
  g(0, -1);
  printf("%.10f\n", dp2[0]);

  return 0;
}


Measured memory_bytes: 18048
N, M = map(int, input().split())
A = set([int(input()) for i in range(M)])
t = 10**9+7
import sys
sys.setrecursionlimit(500000)
from functools import lru_cache
@lru_cache(maxsize=None)
def fibo(n):
    if n in A:
        return 0
    elif n == 0 or n == 1:
        return 1
    return (fibo(n-2) + fibo(n-1)) % t
print(fibo(N) % t)

Measured memory_bytes: 153816
#include <iostream>
#include <vector>
#include <queue>
#include <tuple>
#include <limits>

using namespace std;

template< typename T >
struct edge {
    int src, to;
    T cost;

    edge(int to, T cost) : src(-1), to(to), cost(cost) {}

    edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

    edge &operator=(const int &x) {
        to = x;
        return *this;
    }

    operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;

template< typename T >
vector< T > dijkstra(WeightedGraph< T > &g, int s) {
    vector< T > dist(g.size(), numeric_limits< T >::max());
    dist[s] = 0;

    using Pi = pair< T, int >;
    priority_queue< Pi, vector< Pi >, greater< Pi > > que;
    que.emplace(dist[s], s);

    while(!que.empty()) {
        auto cost = que.top().first;
        auto idx = que.top().second;
        que.pop();
        if(dist[idx] < cost) continue;
        for(auto &e : g[idx]) {
            auto next_cost = cost + e.cost;
            if(dist[e.to] <= next_cost) continue;
            dist[e.to] = next_cost;
            que.emplace(dist[e.to], e.to);
        }
    }
    return dist;
}

int main(void) {
    int N, M;
    cin >> N >> M;
    WeightedGraph<int> g(3*N);
    while(M--) {
        int u, v;
        cin >> u >> v;
        --u; --v;
        g[3*u].emplace_back(3*v+1, 1);
        g[3*u+1].emplace_back(3*v+2, 1);
        g[3*u+2].emplace_back(3*v, 1);
    }

    int S, T;
    cin >> S >> T;
    --S; --T;

    int dist = dijkstra(g, 3*S)[3*T];
    if(dist == numeric_limits<int>::max()) {
        cout << -1 << endl;
    } else {
        cout << dist/3 << endl;
    }
    return 0;
}


Measured memory_bytes: 17792
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),* $(,)*) => {
        #[cfg(debug_assertions)]
        eprintln!(concat!($("| ", stringify!($a), "={:?} "),*, "|"), $(&$a),*);
    };
}

fn main() {
    input! {
        n: usize,
    }
    for _ in 0..n {
        print!("ACL");
    }
    println!("");
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define dame {cout<< "0" <<"\n"; return;}
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N; cin>>N;
    vector<ll> A(N);
    rep(i,N) cin>>A[i];
    ll D[13]={};
    rep(i,N) ++D[A[i]];
    ++D[0];
    rep(i,13){
        if(D[i]>=3) dame;
        if(D[i]>=2 and (i==0 or i==12)) dame;
    }
    ll mi=0,ma=0,ans=24;
    reps(i,1,13){
        if(D[i]==2){
            mini(ans,i-ma);
            mini(ans,24-i-i);
            ma=i,mi=i;
        }
        if(D[i]==1){
            mini(ans,i-mi);
            mini(ans,24-ma-i);
            mi=ma,ma=i;
        }
    }
    cout<< ans <<"\n";
}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int i, n, ans = 1;
    scanf("%d\n", &n);
    char s[n];
    scanf("%s", s);
    for(i = 1; i < n; ++i){
        if(s[i-1] != s[i]){ ans++; }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main { 
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int[] numCount = new int[200001];
    Set<Integer> setA = new HashSet<Integer>();
    int ans =0;
    for (int i =0; i<N; i++) {
      int A = sc.nextInt();
      numCount[A]++;
      setA.add(A);
    }
    int[] countList = new int[setA.size()];
    int a=0,b=0;
    while (a<= 200000 && b <setA.size()) {
      if (numCount[a] == 0) {
        a++;
        continue;
      }
      countList[b] = numCount[a];
      a++;
      b++;
    }
    Arrays.sort(countList);
    for (int i =0; i<setA.size() - K; i++) {
      ans += countList[i];
    }
    System.out.println(ans);
  }
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x, n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair< int, int > P;   
typedef pair< int, P > PP;

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

int h, w;
string s[50];
int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};

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

    cin >> h >> w;
    REP(i, h) cin >> s[i];

    REP(i, h) {
        REP(j, w) {
            if (s[i][j] != '#') continue;
            int cnt = 0;
            REP(d, 4) {
                int nx = j + dx[d], ny = i + dy[d];
                if (nx < 0 || nx >= w || ny < 0 || ny >= h || s[ny][nx] == '.') continue;
                cnt++;
            }
            if (cnt == 0) {
                cout << "No" << endl;
                return 0;
            }
        }             
    }
    cout << "Yes" << endl;

    return 0;
}


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

using namespace std;

int main(void){
    
    
    string s;
    cin >> s;
    
    int len =s.length();
    //cout << len <<endl;
    int i;
    string ans;
    for(i=0;i<len;i+=2){
        ans+=s[i];
    }
    
    cout << ans;
    
    
    
    
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,a[105];
int total(int k){
	int sum=0;
	for(int i=0;i<n;i++)sum+=(a[i]-k)*(a[i]-k);
	return sum;
}
int main(){
	cin>>n;
	int l=1000,r=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		l=l<a[i]?l:a[i];
		r=r>a[i]?r:a[i];
	}
	ll minn=1e9;
	for(int i=l;i<=r;i++){
		int tmp=total(i);
		minn=minn<tmp?minn:tmp;
	}
	cout<<minn;
	return 0;
}

Measured memory_bytes: 256
import copy
def divisors(n):
    divisors=[]
    for i in range(1,int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    divisors=sorted(divisors)
    return divisors
n=int(input())

ans=0
ans+=(len(divisors(n-1))-1)
D=divisors(n)
for d in D:
    tmp=copy.deepcopy(n)
    k=tmp/d
    while tmp%k==0:
        tmp=tmp//k
        if tmp==n:
            break
    if tmp%k==1:
        ans+=1
print(ans)

Measured memory_bytes: 3784
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	string S;
	cin >> S;
	if (S == "Sunny")cout << "Cloudy" << endl;
	if (S == "Cloudy")cout << "Rainy" << endl;
	if (S == "Rainy")cout << "Sunny" << endl;
	return 0;
}



Measured memory_bytes: 256
n = int(input())

a0 = [int(x) for x in input().split()]
a1 = [int(x) for x in input().split()]

ans = 0
s = sum(a1)

for i in range(n):
    s += a0[i]
    if i == 0:
        pass
    else:
        s -= a1[i-1]
    if s > ans:
        ans = s

print(ans)

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

int main()
{
    int N;
    scanf("%d", &N);
    if(N<10)
    {
        printf("ABC");
    }
    else if (N<100)
    {
        printf("ABC");
    }
    else if (N<1000)
    {
        printf("ABC");
    }
    else 
    {
        printf("ABD");
    }
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	int n;
	cin>>n;
	ll a[n+1];
	for(int i=1; i<=n; i++)
	{
		if(i%3==0 || i%5==0)
		{
			a[i]=-1;
		}
		else a[i]=i;
	}
	ll sum=0;
	for(int i=1; i<=n; i++)
	{
		if(a[i]!=-1)
		{
			sum+=a[i];
		}
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 11336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int N,L;
    cin >> N >> L;
    vector<int> A(N);
    rep(i,N) cin >> A[i];
    int mid = -1;
    rep(i,N-1){
        if(A[i]+A[i+1]>=L){
            mid = i;
            break;
        }
    }
    if(mid<0){
        cout << "Impossible" << endl;
        return 0;
    }
    cout << "Possible" << endl;
    for(int i=0;i<mid;i++){
        cout << i+1 << endl;
    }
    for(int i=N-2;i>mid;i--){
        cout << i+1 << endl;
    }
    cout << mid+1 << endl;
    return 0;
}

Measured memory_bytes: 3776
s = list(input())
odd = ['R', 'U', 'D']
even = ['L', 'U', 'D']

for i in range(len(s)):
    if i % 2 == 0:
        if s[i] not in odd:
            print('No')
            exit()
    else:
        if s[i] not in even:
            print('No')
            exit()
print('Yes')


Measured memory_bytes: 2940
#include <iostream>
#include <bits/stdc++.h>
#define rep(i,l,r) for(int (i)=(l);(i)<(r);(i)++)
using namespace std;

int main(void){
    string s;
    cin >> s;
    
    int ans=0;
    char buf=s[0];
    rep(i,1,(int)s.length()){
        if(buf!=s[i])ans++;
        buf=s[i];
    }
    cout << ans <<endl;
}


Measured memory_bytes: 512
using static System.Math;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System;

namespace AtCoder
{
    class Program
    {
        private static long mod = 1000000007;
        static void Main(string[] args)
        {
            var n = int.Parse(ReadLine());
            //var line = ReadLine().Split(' ').Select(value => long.Parse(value)).ToArray();

            var array = new List<string[]>();
            for(var i = 0; i < n; i++)
            {
                array.Add(ReadLine().Split(' '));
            }

            var count = 0;
            foreach(var value in array)
            {
                if(value[0] == value[1])
                {
                    count++;
                    if(count == 3)
                    {
                        WriteLine("Yes");
                        return;
                    }
                }
                else
                {
                    count = 0;
                }
            }

            WriteLine("No");
        }
    }
}


Measured memory_bytes: 27824
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>

#define REP(i,n) for(int i=0;i<n;i++)
#define maxi(a,b) (((a) > (b)) ? (a) : (b))

using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    /********************************************************/
    int k,t;
    vector<pair<int, int>> a;
    int bef = -1;

    cin >> k >> t;
    pair<int, int> p;
    for(int i = 0; i < t; i++){
        p.second = i;
        cin >> p.first;

        a.push_back(p);
    }

    if(t == 1){
        cout << a[0].first - 1 << endl;
        return 0;
    }

    int cnt = 0;

    sort(a.begin(), a.end(), greater<pair<int, int>>());
    while(a.front().first != 0){
        if(a.front().second == bef && a[1].first != 0 ){
            a[1].first--;
            bef = a[1].second;
        }
        else{
            if (bef == a[0].second)
                cnt++;
            a[0].first--;
            bef = a[0].second;
        }
        sort(a.begin(), a.end(), greater<pair<int, int>>());
    }
    cout << cnt << endl;

    /********************************************************/
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

signed main(void)
{
	int a[5];
	REP(i, 5) cin >> a[i];
	sort(a, a+5, greater<int>());
	REP(i, 5) {
		cout << a[i];
		if(i != 4) cout << " ";
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i <=n;i++){
    num*=yakusu[i];
  }
  return num;
}
int main(){
  ll N;cin>>N;
  vl a(N);vl b(N);
  vector<pair<ll,ll>> p(N);
  rep(i,N){
    cin>>a[i]>>b[i];
    p[i]=make_pair(b[i],a[i]);
  }
  sort(all(p));
  ll t=0;
  bool ok =true;
  rep(i,N){
    t+=p[i].second;
    if(t>p[i].first){
      ok =false;break;
    }
  }
  if(ok){
    cout<<"Yes"<<endl;
  }
  else cout<<"No"<<endl;
}

Measured memory_bytes: 6528
n = int(input())
a = [int(i) for i in input().split()]

a.sort(reverse=True)


if a[-1] == 0:
    print(0)
else:
    m = 1

    for i in a:
        m *= i
        if m > 10 ** 18:
            break

    if m > 10 ** 18:
        print(-1)
    else:
        print(m)


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

const vector<int> dx = {0, 0, -1, 1};
const vector<int> dy = {-1, 1, 0, 0};
const int MAX_XY = 100000;
const int MAX_INT = 1<<30;

vector<vector<bool>> seen;

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

    vector<int> t(n), x(n), y(n);
    for (int i=0; i<n; i++){
        cin >> t.at(i) >> x.at(i) >> y.at(i);
    }

    bool b = true;
    for (int i=0; i<n; i++){
        if(x.at(i) + y.at(i) <= t.at(i) && (x.at(i) + y.at(i))%2 == t.at(i)%2){
            continue;
        }else{
            b = false;
            break;
        }
    }

    if(b) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N, M;
    cin >> N >> M;
    vector<int> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    sort(a.begin(), a.end());
    cout << accumulate(a.begin(), a.begin() + M, 0) << '\n';
}


Measured memory_bytes: 3632
<?php

fscanf(STDIN, '%d %d %d', $a, $b, $C);
$rad = deg2rad($C);
$S = $a * $b / 2 * sin($rad);
$c = sqrt(pow($a, 2) + pow($b, 2) - 2 * $a * $b * cos($rad));
$L = $a + $b + $c;
$h = 2 * $S / $a;
printf("%f\n%f\n%f\n", $S, $L, $h);

Measured memory_bytes: 6588
#pragma GCC optimize("Ofast")

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

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;

typedef
tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> orderedSet;

#define pb push_back
#define F first
#define S second
#define all(a) (a).begin(), (a).end()

#define for1(i0, l0, r0) for (int i0 = l0; i0 < r0; ++i0)
#define for2(i0, l0, r0) for (int i0 = l0; i0 <= r0; ++i0)
#define forn(i0, n0) for (int i0 = 0; i0 < n0; ++i0)
#define forn1(i0, n0) for (int i0 = 1; i0 < n0; ++i0)
#define forr(i0, n0) for (int i0 = n0; i0 >= 0; --i0)
#define forr1(i0, r0, l0) for (int i0 = r0; i0 > l0; --i0)
#define forr2(i0, r0, l0) for (int i0 = r0; i0 >= l0; --i0)

#define Sort(a) sort(all(a))
#define Reverse(a) reverse(all(a))
#define relaxMax(a, b) a = max(a, b)
#define relaxMin(a, b) a = min(a, b)

typedef long double ld;
#define ui unsigned int
#define ull unsigned long long

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;

typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pdd> vpdd;

typedef vector<vi> vvi;
typedef vector<vd> vvd;
typedef vector<vll> vvll;
typedef vector<vb> vvb;

#define vpss vector<pss>
#define vvs vector<vs>
#define vvpii vector<vpii>
#define vvpll vector<vpll>
#define vpt vector<pt>
#define vvvi vector<vvi>
#define vsi vector<set<int>>
#define ss second
#define ff first

#define printvi(arr) for (int x0 : arr) cout << x0 << ' '; cout << '\n';
#define printvll(arr) for (ll x0 : arr) cout << x0 << ' '; cout << '\n';
#define printpair(pair0) cout << pair0.F << ' ' << pair0.S << '\n';
#define printvp(arr) for (auto pair0 : arr) printpair(pair0);
#define initArray(arr, N0, X0) memset(arr, X0, N0 * sizeof(int))
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void init() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout.precision(16);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
}

void solve() {
    int n;
    cin >> n;
    int ans = 0;
    vi a(n);
    forn(i, n){
        cin >> a[i];
        a[i]--;
    }
    forn(i, n){
        int j = a[i];
        if (j > i && a[j] == i) ans++;
    }
    cout << ans << '\n';
}

bool multitest = false;

int main() {
    init();
    int t = 1;
    if (multitest) cin >> t;
    forn(i, t) solve();
}

Measured memory_bytes: 3684
#include <stdio.h>
int main(void){
	int a,b;
	scanf("%d%d",&a,&b);
	if(b==1)b=14;
	if(a==1)a=14;
	if(a>b){
		printf("Alice");
	}else if(b>a){
		printf("Bob");
	}else printf("Draw");
	return 0;
}

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

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  long long int a,b,c,k;
  cin>>a>>b>>c>>k;
  if(k%2==1){
    cout<<b-a;
  }else{
    cout<<a-b;
  }
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-


import sys
# sys.setrecursionlimit(10**6)
# readline = sys.stdin.buffer.readline
readline = sys.stdin.readline

INF = 1 << 50


def read_int():
    return int(readline())


def read_int_n():
    return list(map(int, readline().split()))


def read_float():
    return float(readline())


def read_float_n():
    return list(map(float, readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()


def ep(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.perf_counter()
        ret = f(*args, **kwargs)
        e = time.perf_counter()

        ep(e - s, 'sec')
        return ret

    return wrap


def divisor(n):
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            yield i
            if i != n // i:
                yield n // i


def exEuclid(a, mod):
    b = mod
    s, u = 1, 0
    while b:
        q = a // b
        a, b = b, a % b
        s, u = u, s - q * u
    return a, s % mod

def crt(R, M):
    assert len(R) == len(M)
    N = len(R)
    r0, m0 = 0, 1
    for r, m in zip(R, M):
        assert m >= 1
        r %= m
        if m0 < m:
            r0, r = r, r0
            m0, m = m, m0
        if m0 % m == 0:
            if r0 % m != r:
                return (0, 0)
            continue
        g, im = exEuclid(m0, m)
        u = m // g
        if (r - r0) % g:
            return (0, 0)
        x = (r - r0) // g % u * im % u
        r0 += x * m0
        m0 *= u
        if r0 < 0:
            r0 += m0
    return (r0, m0)

@mt
def slv(N):
    ans = INF
    for x in divisor(2*N):
        kc, _ = crt([0, -1], (x, 2*N//x))
        if kc != 0:
            ans = min(ans, kc)
    return ans


def main():
    N = read_int()
    print(slv(N))


if __name__ == '__main__':
    main()


Measured memory_bytes: 74852
n = int(input())
h = list(map(int, input().split()))

cnt = 0
maxi = 0
for i in range(1, len(h)):
    if h[i] <= h[i-1]:
        cnt += 1
    else:
        if maxi < cnt: maxi = cnt
        cnt = 0
print(max(maxi, cnt))


Measured memory_bytes: 14224
#include<iostream>
#include<vector>
#include<algorithm>
#include<climits>

using namespace std;

int main(void){

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

  vector<int>v(m);
  for(int i=0;i<m;i++)cin >> v[i];

  int dp[n+1];
  fill(dp,dp+n+1,INT_MAX-1);

  dp[0]=0;

    for(int i=0;i<m;i++){
      for(int j=0;j<=n;j++){
        if(v[i]+j<=n)dp[v[i]+j]=min(dp[v[i]+j],dp[j]+1);
      }
    }

  cout << dp[n] << endl;

  return 0;
}

Measured memory_bytes: 1388
n,y = map(int, input().split())

y //= 1000
a,b,c = -1,-1,-1


fit = False
for ai in range(n+1):

    if ai*10> y or fit:
        break

    remain = n-ai
    for bi in range(remain+1):
        ci = remain - bi
        
        if y == ai *10  + bi * 5 + ci :
            a,b,c = ai,bi,ci
            fit = True

print('{} {} {}'.format(a,b,c))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long int x,y,l=0;
  cin>>x>>y;
  if(x==1)
    l+=300000;
  else if(x==2)
     l+=200000;
  else if(x==3)
     l+=100000;
  else l=0;
  if(y==1)
    l+=300000;
  else if(y==2)
     l+=200000;
  else if(y==3)
     l+=100000;
  else l=l+0;
  if(x==1 and y==1)
    l=l+400000;
  cout<<l;
}


Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

//long mod = 10^^9 + 7;
long mod = 998_244_353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { y.modpow(mod - 2); x.modm(y); }

void main()
{
	auto N = RD;
	auto A = RDA;
	
	long ans;
	foreach (i; 0..N-1)
	{
		auto d = A[i] - A[i+1];
		if (d > 0)
		{
			ans += d;
			A[i+1] += d;
		}
	}

	writeln(ans);
	stdout.flush;
	debug readln;
}


Measured memory_bytes: 11668
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;


bool solve(){
    int m, n, k, d;
    cin >> m >> n >> k >> d;
    if(!m) return 0;
    map<string, int> a;
    a["H"] = 0;
    for (int i = 0; i < m; ++i) a[string("C")+to_string(i+1)] = i+1;
    for (int i = 0; i < n; ++i) a[string("L")+to_string(i+1)] = i+m+1;
    a["D"] = n+m+1;
    vector<int> C(m);
    for (auto &&j : C) scanf("%d", &j);
    vector<vector<pair<int, int>>> G(n+m+2);
    for (int i = 0; i < d; ++i) {
        string S, T; int x;
        cin >> S >> T >> x;
        int s = a[S], t = a[T];
        G[s].emplace_back(t, x*k);
        G[t].emplace_back(s, x*k);
    }
    vector<int> dp((n+m+2) << m, INF<int>);
    priority_queue<pair<int, int>,vector<pair<int, int>>,greater<>> Q;
    dp[0] = 0;
    Q.emplace(0, 0);
    int mask = (1 << m)-1;
    while(!Q.empty()){
        int cost; int i;
        tie(cost, i) = Q.top(); Q.pop();
        int down = i & mask, up = i >> m;
        if(dp[i] < cost) continue;
        for (auto &&e : G[up]) {
            auto cost2 = cost + e.second;
            if(1 <= e.first && e.first <= m){
                if((1 << (e.first-1)) & i) continue;;
                int to = down | (1 << (e.first-1)) | (e.first << m);
                if(dp[to] <= cost2) continue;
                dp[to] = cost2;
                Q.emplace(dp[to], to);
            }else {
                int to = down | (e.first << m);
                if(dp[to] <= cost2) continue;
                dp[to] = cost2;
                Q.emplace(dp[to], to);
            }
        }
    }
    int ans = INF<int>;
    for (int i = 0; i < (1 << m); ++i) {
        int val = dp[(n+m+1) << m | i];
        for (int j = 0; j < m; ++j) {
            if(i & (1 << j)){
                val -= C[j];
            }
        }
        ans = min(ans, val);
    }
    cout << ans << "\n";
    return 1;
}

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


Measured memory_bytes: 3360
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    int N; cin >> N;
    string S; cin >> S;
    // i(0 <= i < N)をリーダーにしたとき，向く方向を変える人数は
    // Sj = W (0 <= j < i) と Sj = E (i < j < N) の和に等しい
    // 各地点における振り返る人数の累積和を計算していく：O(N)
    vector<int> frontWNum(N), backENum(N);
    int fW = 0, bE = 0;
    frontWNum[0] = backENum[N - 1] = 0;
    for (int i = 1; i < N; ++i)
    {
        if (S[i - 1] == 'W') ++fW;
        if (S[N - i] == 'E') ++bE;
        frontWNum[i] = fW;
        backENum[N - i - 1] = bE;
    }
    int ans = N;
    for (int i = 0; i < N; ++i)
    {
        ans = min(ans, frontWNum[i] + backENum[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3076
#include<stdio.h>

int main(){
static char S[100005],*p;
static int K,res,t;
  fgets(S,100005,stdin);
  scanf("%d",&K);
  p=S;
  while(*(p+2)){
    if(*p-'a'){
      t='{'-*p;
      if(K>=t){
        K-=t;
        res+=t;
        *p='a';
      }
    }
    ++p;
  }
  *p=(*p-'a'+K)%26+'a';
  *++p^=10;
  puts(S);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <cmath>
using namespace std;
#define pi M_PI
#include <vector>

int main(){
    int a, b;
    cin >> a >> b;
    bool c;
    if(a%3 == 0){
        c = true;
    }
    else if(b%3 == 0){
        c = true;
    }
    else if((a + b)%3 == 0){
        c = true;
    }
    else c = false;

    if(c == true){
        cout << "Possible" << endl;
    }
    else if(c == false){
        cout << "Impossible" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		int n = scan.nextInt();
		int i = 1;
		while(i <= n){
			int x = i;
			if(x % 3 == 0){
				System.out.printf(" %d", i);
			} else{
				while(x != 0){
					if(x % 10 == 3){
						System.out.printf(" %d", i);
						break;
					}
					x /= 10;
				}
			}
			i++;
		}
		System.out.println("");
	}
}

Measured memory_bytes: 41176
using System;

class Program
{
	static void Main(string[] args)
	{
		string[] input = Console.ReadLine().Split(' ');

		// 整数の入力
		int Health = int.Parse(input[0]);
		int Attack = int.Parse(input[1]);

		int cnt = Health / Attack;
		int amari = Health % Attack;

        if (amari > 0)
        {
			cnt += 1;
        }
		Console.WriteLine(cnt);
	}
}

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

int main() {
  int n;
  cin >> n;
  vector<int[3]> dp(n + 1);
  rep(i, n) {
    rep(j, 3) {
      int h;
      cin >> h;
      rep(k, 3) if (j != k) dp[i + 1][j] = max(dp[i + 1][j], dp[i][k] + h);
    }
  }
  cout << *max_element(begin(dp[n]), end(dp[n])) << endl;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define ll long int 

int  main()
{  

    string s;
    cin>>s;
    int n=s.length();
    int l1=(n-1)/2;
    int l2=(n+3)/2;
    bool pahla=true;
    bool dusra=true;
    for(int i=0, j=l1-1;i<=j;i++, j--)
    {
        if(s[i]!=s[j])
        {
         pahla=false;
         break;
        }
    }
    if(l2<=n)
    {
    for(int i=l2-1, j=n-1;i<=j;i++, j--)
    {
        if(s[i]!=s[j])
        {
            dusra=false;
            break;
        }
    }
    }
    else{
        dusra=false;
    }
    bool thisra=true;
    for(int i=0,j=n-1;i<=j;i++, j--)
    {
        if(s[i]!=s[j])
        {
            thisra=false;
        }
    }
    if(pahla&&dusra&&thisra)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }




    return 0;
}

Measured memory_bytes: 3536
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

int main(){
  int N;
  cin >> N;
  vector<ll> A(N+1),B(N+1);
  ll a=N+1,b=(N+1)*N;
  for(int i=1; i<=N; i++){
    A[i] = a;
    B[i] = b;
    a += N+1;
    b -= N+1;
  }
  int cnt = 0;
  for(int i=0; i<N; i++){
    int p;
    cin >> p;
    A[p] += cnt;
    cnt++;
  }
  for(int i=1; i<=N; i++){
    cout << A[i];
    if(i != N){
      cout << " ";
    }else{
      printf("\n");
    }
  }
  for(int i=1; i<=N; i++){
    cout << B[i];
    if(i != N){
      cout << " ";
    }else{
      cout << '\n';
    }
  }
  return 0;
}


Measured memory_bytes: 896
/**
*    author:  souzai32
*    created: 02.08.2020 13:52:13
**/

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

int main() {

    int n;
    cin >> n;
    int count=0;
    vector<int> a(n);
    rep(i,n) cin >> a.at(i);

    int i=0;
    while(1){
        if(a.at(i)==i+1){
            count++;
            i++;
        }
        i++;
        if(i>=n) break;
    }
    cout << count << endl;

    return 0;
}

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

using namespace std;

int h,w,a[205][205],c[15][15],cnt[15],f[15][15];

int main()
{
	cin >> h >> w;
	for(int i=0;i<=9;i++)
		for(int j=0;j<=9;j++)
		{
			cin >> c[i][j];
			if(!f[i][j] || f[i][j]>c[i][j]) f[i][j]=c[i][j];
		}
	
	for(int k=0;k<=9;k++)
		for(int i=0;i<=9;i++)
			for(int j=0;j<=9;j++)
				if(f[i][k]+f[k][j]<f[i][j])
					f[i][j]=f[i][k]+f[k][j];
	
	int res=0;
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++)
		{
			int x;cin >> x;
			if(x!=1 && x!=-1) cnt[x]++;
		}
	
	for(int i=0;i<=9;i++)
		if(i!=1)
		{
			res+=cnt[i]*f[i][1];
		}
	
	cout << res;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int n,i,f=0;
cin>>n;
int p[n];
  for( i=1;i<=n;i++){
    cin>>p[i];
  }
  i=0;
   for(i=1;i<=n;i++){
if(p[i]!=i){f++;}
    }
    if(f<=2){
    cout<<"YES"<<endl;
}
else{
    cout<<"NO"<<endl;
}



}


Measured memory_bytes: 3632
#include <stdio.h>
#include <string.h>
#include <vector>
#include <queue>
using namespace std;

struct edge
{
    int from,to;
    long long cost;
};

struct heapnode
{
    long long d;
    int u;

    bool operator < (const heapnode& rhs) const{

        return d > rhs.d;
    }
};

vector<edge> edges;
vector<int> v[100005];

void adde(int from,int to,long long cost)
{
    edge tmp;

    tmp.from = from;
    tmp.to = to;
    tmp.cost = cost;

    edges.push_back(tmp);

    int m = edges.size() - 1;

    v[from].push_back(m);
}

long long d[100005];
bool vis[100005];

void dij(int s,int n)
{
    for (int i = 0;i <= n;i++) d[i] = 10000000000000000;
    memset(vis,0,sizeof(vis));

    d[s] = 0;

    priority_queue<heapnode> q;

    heapnode t;
    t.d = 0;t.u = s;

    q.push(t);

    while (!q.empty())
    {
        heapnode x = q.top();q.pop();

        int u = x.u;

        if (vis[u]) continue;

        vis[u] = true;

        for (int i = 0;i < v[u].size();i++)
        {
            edge e = edges[v[u][i]];

            if (d[e.to] > d[u] + e.cost)
            {
                d[e.to] = d[u] + e.cost;

                heapnode tt;
                tt.u = e.to;t.d = d[e.to];

                q.push(tt);
            }
        }
    }
}

int main()
{
    int n;

    scanf("%d",&n);

    for (int i = 0;i < n - 1;i++)
    {
        int a,b;
        long long c;

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

        scanf("%lld",&c);

        adde(a,b,c);
        adde(b,a,c);
    }

    int q,k;

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

    dij(k,n);

    for (int i = 0;i < q;i++)
    {
        long long ans = 0;
        int a,b;

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

        ans += d[a];
        ans += d[b];

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

    return 0;
}


Measured memory_bytes: 14572
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#define MN 200000
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
int n,a[MN+5];
long long ans=1e18,s[MN+5];
inline long long Abs(long long x){return x<0?-x:x;}
int main()
{
    n=read();
    for(int i=1;i<=n;++i) s[i]=s[i-1]+(a[i]=read());
    for(int i=1;i<n;++i) ans=min(ans,Abs(s[i]-(s[n]-s[i])));
    cout<<ans;
    return 0;
}


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

int main() {
	int n;
	cin >> n;
	int a[25];
	int b[25];
	int c [25];
	int ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
		ans += b[i];
	}
	for (int i = 0; i < n-1; i++) {
		cin >> c[i];
	}
	for (int i = 0; i < n-1; i++) {
		if (a[i] == a[i + 1] - 1) {
			ans += c[a[i]-1];
		}
	}
	cout << ans;
}

Measured memory_bytes: 256