akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            long l = in.nextInt();
            long[] a = new long[n];
            for (int i = 0; i < n; ++i) {
                a[i] = in.nextInt();
            }
            for (int i = 0; i + 1 < n; ++i)
                if (a[i] + a[i + 1] >= l) {
                    out.println("Possible");
                    for (int j = 0; j < i; ++j) {
                        out.println(j + 1);
                    }
                    for (int j = n - 2; j >= i; --j) {
                        out.println(j + 1);
                    }
                    return;
                }
            out.println("Impossible");
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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

template <class T>
struct DelaySegmentTree{
  using F = function<T(T,T)>;
  F f;
  T inf;
  int n;
  vector<int> node,delay;
  vector<bool> delayflag;

  DelaySegmentTree(vector<T> v,T inf,F f):inf(inf),f(f){
    n = 1; while(n < v.size()) n *= 2;
    node.resize(2*n-1,inf);
    delay.resize(2*n-1,inf);
    delayflag.resize(2*n-1,false);
    for(int i = 0; i < v.size(); i++) node[i+n-1] = v[i];
    for(int i = n-2; i >= 0; i--) node[i] = f(node[2*i+1],node[2*i+2]);
  }

  void eval(int k,int l,int r){
    if(delayflag[k]){
      node[k] = delay[k];
      if(r-l > 1){
        delay[2*k+1] = delay[2*k+2] = delay[k];
        delayflag[2*k+1] = delayflag[2*k+2] = true;
      }
      delayflag[k] = false;
    }
  }

  void update(int a,int b,int x){ update(a,b,x,0,0,n); }
  void update(int a,int b,int x,int k,int l,int r){
    eval(k,l,r);
    if(b <= l || r <= a) return;
    if(a <= l && r <= b){
      delay[k] = x;
      delayflag[k] = true;
      eval(k,l,r);
    }
    else {
      update(a,b,x,2*k+1,l,(l+r)/2);
      update(a,b,x,2*k+2,(l+r)/2,r);
      node[k] = f(node[2*k+1],node[2*k+2]);
    }
  }

  T getval(int a,int b){ return getval(a,b,0,0,n); }
  T getval(int a,int b,int k,int l,int r){
    //区間[a, b)の値を返す
    eval(k,l,r);
    if(b <= l || r <= a) return inf;
    if(a <= l && r <= b) return node[k];
    T vl = getval(a, b, 2*k+1, l, (l+r)/2);
    T vr = getval(a, b, 2*k+2, (l+r)/2, r);
    return f(vl, vr);
  }
};

signed main(){

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

  auto f = [&](int x,int y){
    return __gcd(x,y);
  };
  DelaySegmentTree<int> seg(a,0,f);

  int ans = 0;
  for(int i = 0; i < n; i++){
    ans = max(ans,f(seg.getval(0,i),seg.getval(i+1,n)));
  }
  cout << ans << endl;

  return 0;
}


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

using namespace std;

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

    string s;
    cin >> s;
    int cnt = 0;
    string prev;
    string cur;
    for (char c : s) {
        cur += c;
        if (cur != prev) {
            cnt++;
            prev = cur;
            cur = "";
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define INF 1000000011
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
using namespace std;
typedef long long ll;
 
int main(){
  int n,x;
  cin>>n>>x;
  int l[n];
  rep(i, n){
    cin>>l[i];}
  
  int cnt=1;
  int d=0;
  
  for(int i=0;i<n;i++){
    d+=l[i];
    if(d<=x){
      cnt++;}
  }
  
  cout<<cnt<<endl;
  
 
 
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <array>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <deque>

#include <atcoder/all>

using namespace atcoder;
using namespace std;
typedef long long ll;

int op(int a, int b) {
    return max(a, b);
}

int e() {
    return (int) 0;
}

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

    int N, K;
    cin >> N >> K;

    vector<int> A(N);


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


    segtree<int, op, e> seg(300005);

    int cur;
    int len;
    int l, r;

    for (int i = 0; i < N; ++i) {
        cur = A[i];

        l = cur - K;
        r = cur + K;
        if (l < 0) {
            l = 0;
        }

        if (r > 300000) {
            r = 300000;
        }

        len = seg.prod(l, r + 1) + 1;
        seg.set(cur, len);
    }

    int ans = seg.all_prod();

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 9832
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define MMP(a, b, c) make_pair(make_pair(a, b), c)
#define MAX 1000000000
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

int main(){
    iostream::sync_with_stdio(false);
    
    int N;
    cin >> N;
    int ans = INT_MAX;
    for(int i=0; i<N; i++){
        int A;
        cin >> A;
        int tmp = 0;
        while(A % 2 == 0){
            A /= 2;
            tmp++;
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
    
    return 0;
}


/*

int main(){
    iostream::sync_with_stdio(false);
    
    
    
    return 0;
}
*/

/*

int main(){
    iostream::sync_with_stdio(false);
    
    
    
    return 0;
}
*/

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
import java.io.IOException;

public class Main {
    public static void main(String[] args) throws IOException {
        List<Map<String, Long>> dataset = new ArrayList<>();
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while (true){
            final int times = Integer.parseInt(br.readLine());
            if (times == 0) { break; }
            
            Map<String, Long> data = new LinkedHashMap<>();
            for (int i=1; i <= times; i++) {
                String[] col = br.readLine().split(" ");
                data.merge(col[0], Long.parseLong(col[1]) * Long.parseLong(col[2]), Long::sum);
            }
            dataset.add(data);
        }

         dataset.forEach(data -> {
            long count = data.entrySet().stream()
                .filter(e -> e.getValue() >= 1_000_000)
                .peek(e -> System.out.println(e.getKey()))
                .count();
            if (count == 0) { System.out.println("NA"); }
        });
   }
}

Measured memory_bytes: 31748
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mmax(a,b,c) max(a,max(b,c))
#define mmin(a,b,c) min(a,min(b,c))
#define M 1000000007
#define V vector
#define F(a,b,c) for (a=b;a<=c;++a)
#define I cin
#define O cout
#define pb push_back
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
const ll L=1e5+1;
V<bool> visited;
V<V<ll>>adj;
V<ll> in_degree, dist;
void dfs(ll a) {
    visited[a]=true;
    for (ll b: adj[a])
    {
        dist[b]=max(dist[b], dist[a]+1);
        --in_degree[b];
        if (!in_degree[b])
            dfs(b);
    }
}
int main() {
    I.sync_with_stdio(false);
    I.tie(0);
    ll n,m,q,i,j,k=0;
    I>>n>>m;
    visited.resize(n,false);
    adj.resize(n);
    in_degree.resize(n);
    dist.resize(n);
    F (q,0,m-1)
    {
        I>>i>>j;
        adj[i-1].pb(j-1);
        in_degree[j-1]++;
    }
    F (i,0,n-1)
        if (!visited[i] && !in_degree[i])
            dfs(i);
    F (i,0,n-1)
        k=max(k,dist[i]);
    O<<k<<'\n';
    return 0;
}

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


int main()
{
 

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

    vector<int> Ai(n);
    int vote_sum=0;
    for(int i=0;i<n;i++){
        cin>>Ai.at(i);
        vote_sum+=Ai.at(i);
    }

    sort(Ai.begin(),Ai.end(),greater<int>());
    
    bool flag=true;
    for(int i=0;i<m;i++){
        if(Ai.at(i)<(double)vote_sum/(4.0*(double)m)){
            flag=false;
            break;
        }
    }

    if(flag)
        cout<<"Yes"<<endl;
    else
    {
        cout<<"No"<<endl;
    }
    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define mod 1000000007
using namespace std;

int main(){
    int a,b,x;
    double h,ans;
    cin >> a >> b >> x;
    
    if(x<=a*a*b/2){
        h = (double)2*x/(double)(a*b);
        ans = atan(b/h)*(double)180/M_PI;
    }else{
        h = (double)2*(a*a*b-x)/(a*a);
        ans = atan(h/a)*(double)180/M_PI;
    } 

//    cout << ans << endl;
  printf("%.7f\n",ans);

    return 0;
}

Measured memory_bytes: 256
temp=input().split()
N=int(temp[0])
M=int(temp[1])
temp=[input().split() for i in range(M)]

x=[int(temp[i][0])-1 for i in range(M)]
y=[int(temp[i][1])-1 for i in range(M)]
flag=[False for i in range(N)]
lest=[1 for i in range(N)]

flag[0]=True

for i in range(M):
	if flag[x[i]]==True:
		if lest[x[i]]==1:
			flag[x[i]]=False
		flag[y[i]]=True
	lest[x[i]]-=1
	lest[y[i]]+=1

ans=0
for i in range(N):
	if flag[i]==True:
		ans+=1
print(ans)

Measured memory_bytes: 41696
#include<bits/stdc++.h>
using namespace std;
int n, m, q, a[55], b[55], c[55], d[55], A[15], ans;
void dfs( int now,  int lim) {
    if(now == n + 1) {
        int res = 0;
        for(int i = 1; i <= q; ++ i)
            if(A[b[i]] - A[a[i]] == c[i]) res += d[i];
        ans = max(ans, res);
        return;
    }
    for(int i = lim; i <= m; ++ i)
        A[now] = i, dfs(now + 1, i);
}
int main() {
    cin>>n>>m>>q;
    for(int i = 1; i <= q; ++ i) cin>>a[i]>>b[i]>>c[i]>>d[i];
    dfs(1, 1);
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 3756
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

void dout() { cerr << '\n'; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << " " << H;
    dout(T...);
}

#ifdef LOCAL
    #define dbg(...) cerr << #__VA_ARGS__, dout(__VA_ARGS__)
#else
    #define dbg(...) ;
#endif

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;

const int K = 102, N = 64000, MOD = 1e9 + 7;
int n, k, dp[K][N], p[K][N], cnt[N], m;
map <int, int> num;

void add(int & x, int y) {
    x += y;
    if (x >= MOD) {
        x -= MOD;
    }
}

void sub(int & x, int y) {
    x -= y;
    if (x < 0) {
        x += MOD;
    }
}

int main() {
    ios_base::sync_with_stdio(false), cin.tie(NULL);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif

    cin >> n >> k;
    int cur = 1;
    vector <int> vec;
    while (cur <= n) {
        int val = n / cur;
        int nxt = n / val;
        vec.pb(val);
        num[val] = nxt - cur + 1;
        cur = nxt + 1;
    }
    reverse(all(vec));
    vec.erase(unique(all(vec)), vec.end());
    m = vec.size();
    for (int i = 1; i <= m; i++) {
        cnt[i] = num[vec[i - 1]];
    }
    for (int i = 1; i <= m; i++) {
        dp[1][i] = cnt[i];
        p[1][i] = p[1][i - 1];
        add(p[1][i], dp[1][i]);
    }
    for (int i = 2; i <= k; i++) {
        for (int j = 1; j <= m; j++) {
            int x = n / vec[j - 1];
            int pos = lower_bound(all(vec), x) - vec.begin();
            int res = p[i - 1][m];
            sub(res, p[i - 1][pos]);
            dp[i][j] = (ll)res * cnt[j] % MOD;
            p[i][j] = p[i][j - 1];
            add(p[i][j], dp[i][j]);
        }
    }
    int ans = 0;
    for (int i = 1; i <= m; i++) {
        add(ans, dp[k][i]);
    }
    cout << ans;
}


Measured memory_bytes: 54396
#include <stdio.h>

main(void)
{
	int x,y;
	
	while(1){
		scanf("%d%d",&x,&y);
		if(x==0 && y==0){
			break;
		}
		if(x>y){
			printf("%d %d\n",y,x);
		}
		if(x==y){
			printf("%d %d\n",x,y);
		}
		if(x<y){
			printf("%d %d\n",x,y);
		}
	}
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    double a[n];
    ll sum = 0;
    vector<ll>dp(n);
    rep(i,n){
        cin >> a[i];
        sum+=a[i];
        dp[i] = sum;
    }
    ll ans = 1000000000000000000;
    rep(i,n){
        ll x = abs(dp[i]-(sum-dp[i]));
        ans = min(ans,x);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<map>
using namespace std;
map<string ,int >mp;
void init()
{
    mp["SUN"]=7;
    mp["MON"]=6;
    mp["TUE"]=5;
    mp["WED"]=4;
    mp["THU"]=3;
    mp["FRI"]=2;
    mp["SAT"]=1;
}
int main()
{
    init();
    string str;
    cin>>str;
    cout<<mp[str]<<endl;
}


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

int main(void){
    long long a,b,v,w,t;
    cin >> a >> v >> b >> w >> t;
    if(w>=v){
        cout << "NO" << endl;
        return 0;
    }
    if(t*(v-w)>=abs(a-b)){
        cout << "YES" << endl;
        return 0;
    }else{
        cout << "NO" << endl;
        return 0;
    }
}

Measured memory_bytes: 3604
N, X = map(int, input().split())
pcnt = [0] * (N+1)
fcnt = [0] * (N+1)
pcnt[0] = fcnt[0] = 1
for i in range(N):
	pcnt[i+1] = pcnt[i]*2+1
	fcnt[i+1] = fcnt[i]*2+3

def func(l=N, x=X):
	if (l == 0):
		if (x >= 1):
			return 1
		else:
			return 0
	if (x < fcnt[l-1]+2):
		return func(l-1, x-1)
	else:
		return pcnt[l-1]+1+func(l-1, x-fcnt[l-1]-2)

print(func())


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

using namespace std;

string S, T;

vector<int> S_cnt;
vector<int> T_cnt;

int main(){
	cin >> S >> T;
	sort(S.begin(), S.end());
	sort(T.begin(), T.end());
	int count = 1;
	for(int i = 0; i < S.size(); ++i){
		if(S[i] == S[i+1]) count++;
		else{
			S_cnt.push_back(count);
			count = 1;
		}
	}
	for(int i = 0; i < T.size(); ++i){
		if(T[i] == T[i+1]) count++;
		else{
			T_cnt.push_back(count);
			count = 1;
		}
	}
	sort(S_cnt.begin(), S_cnt.end());
	sort(T_cnt.begin(), T_cnt.end());
	bool ans = S_cnt == T_cnt;
	cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 776
s = str(input())
k = 1
a = 0
b = 0


for i in range(len(s)):
    if s[i] == 'A':
        a = i
        break
for i in range(len(s)-1,1,-1):
    if s[i] == 'Z':
        b = i
        break

print(b - a + 1)


Measured memory_bytes: 3512
import std.algorithm;
import std.array;
import std.stdio;
import std.conv;
import std.string;

void main(){
    int count;
    foreach(Unused; 0..readln.chomp.to!int){
        if(readln.chomp.to!int.isPrime){
            ++count;
        }
    }
    count.writeln;
}

bool isPrime(int n){
    if(n <= 1){
        return false;
    }
    if(n == 2){
        return true;
    }
    if(n % 2 == 0){
        return false;
    }
    for(int i = 3; i * i <= n; i += 2){
        if(n % i == 0){
            return false;
        }
    }
    return true;
}

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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;

int g[15][15];
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n;cin>>n;

	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			g[i][j] =-1;
		}
	}

	for(int i=0; i<n; i++){
		int a;cin>>a;

		int x,y;

		for(int j=0; j<a; j++){
			cin>>x>>y;
			--x;
			g[i][x] =y;
		}
	}

	int ans=0;
	for(int bit =0; bit<(1<<n); bit++){
		vector<int> d(n);
		int ct=0;
		for(int i=0; i<n; i++){

			if(bit & 1<<i){
				d[i] =1;
				ct++;
			}
		}

		bool ok =true;
		for(int j=0; j<n; j++){
			if(d[j]){
				for(int k=0; k<n; k++){
					if(g[j][k] ==-1)continue;
					if(g[j][k] != d[k]) ok =false;
				}
			}
		}
		if(ok) ans = max(ans, ct);
	}

	writeln(ans);


}




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

typedef long long ll;
typedef int64_t i6;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define Sort(x) sort(x.begin(), x.end())
#define Sort_rev(x) sort(x.begin(), x.end(), greater<int>())
#define ALL(v) (v).begin(), (v).end()

// π M_PI
// deg = rad*180/M_PI

int main() {
    int n, r;
    cin >> n >> r;
    if ( n < 10 ) {
        cout << r+100*(10-n) << endl;
    } else {
        cout << r << endl;
    }
    return 0;
}


Measured memory_bytes: 256
N,A,B,C = map(int,input().split())
l = [int(input()) for i in range(N)]
inf = 10**9
def dfs(cur,a,b,c):
    if cur == N:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else inf
    ret0 = dfs(cur+1,a,b,c)
    ret1 = dfs(cur+1,a+l[cur],b,c) + 10
    ret2 = dfs(cur+1,a,b+l[cur],c) + 10
    ret3 = dfs(cur+1,a,b,c+l[cur]) + 10
    
    return min(ret0,ret1,ret2,ret3)

print(dfs(0,0,0,0))

Measured memory_bytes: 3064
#include "iostream"
#include "algorithm"
#include "cstring"
#include "cstdio"
#include "cmath"
#include "vector"
#include "map"
#include "set"
#include "queue"
using namespace std;
#define MAXN 200006
//#define int long long
#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define all(x) (x).begin() , (x).end()
#define mem( a ) memset( a , 0 , sizeof a )
#define P 1000000007
typedef long long ll;
int n , m;
int a , b , c;
int A[MAXN];
void solve() {
    cin >> a >> b >> c;
    swap( a , b ) , swap( a , c );
    cout << a << ' '<< b << ' '  << c << endl;
}
signed main() {
//    freopen("2.in","r",stdin);
//    freopen("fuckout","w",stdout);
//    int T;cin >> T;while( T-- ) solve();
    solve();
}


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

#define int long long
#define mod 1000000007
#define maxN 100005

inline int add(int x,int y) { x+=y; if(x>=mod) x-=mod; return x; }

int dp[maxN][2][101];
vector<int> v;
int len;

void PUSH(string x)
{
    for(auto u:x) v.push_back(u-'0');
}

int sol(int index,int flag,int sum,int D)
{
    if(index==len)
    {
        if(sum%D==0) return 1;
        else return 0;
    }

    int &r=dp[index][flag][sum];
    if(r!=-1) return r;

    int res=0;
    if(flag) for(int i=0;i<10;i++) res=add(res,sol(index+1,1,(sum+i)%D,D));
    else
    {
        for(int i=0;i<=v[index];i++)
        {
            if(i<v[index]) res=add(res,sol(index+1,1,(sum+i)%D,D));
            else if(i==v[index]) res=add(res,sol(index+1,0,(sum+i)%D,D));
        }
    }

    return r=res;
}

int32_t main()
{
    ios_base::sync_with_stdio(false),cin.tie(nullptr);
    string s;
    cin>>s;

    PUSH(s);
    len=v.size();

    int d=0;
    cin>>d;

    memset(dp,-1,sizeof(dp));
    int ans=sol(0,0,0,d)-1;
    if(ans<0) ans+=mod;
    cout<<ans%mod<<"\n";
    return 0;
}

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int K;
    Scd(K);

    char s[1231];
    Scs(s);

    int N = strlen(s);

    if( N > K ){
        Rep(i,K) printf ("%c", s[i] );
        printf ("...\n");
    }else{
        printf ("%s\n", s );
    }

    return 0;
}



Measured memory_bytes: 3736
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a);i<(b);++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD 1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a:A) cin >> a;} 


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

string S; cin >> S;
//回文判定

bool stpali = true;
int N = S.size();
rep(i, 0, N/2) if (S[i] != S[N-1-i]){
    stpali = false;
    goto ANS;
}
rep(i, 0, (N-1)/4) if (S[i] != S[(N-1)/2-1-i]){
    stpali = false;
    goto ANS;
}
rep(i, (N+3)/2-1, 3 * (N+1)/4) if (S[i] != S[N-1-i]){
    stpali = false;
    goto ANS;
}
ANS:
if (stpali) cout << "Yes\n";
else cout << "No\n";

return 0;
}
// コンテスト前はtemplate振り返り。
// 書いて考える．場合分け．情報整理．
// 問題文から考える。自分ができることから考える。
// 単純に分かる量から．愚直解を実装して研究．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP(小さい問題から大きな問題)
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性→二分探索。逆から考える。
// 存在判定：構成方法，入力の特徴
// 構築問題。極端解を試す。
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// コーナーケース。境界値。数表出力プログラム作る
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
    int N, K;
    map<int, int> m;
    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        int A;
        cin >> A;
        m[A]++;
    }
    vector<int> v;
    for (auto x: m) v.push_back(x.second);
    sort(v.begin(), v.end());
    int ans = 0;
    int l = v.size();
    for (int i = 0; (l-i) > K; i++) {
        ans += v[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 10748
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <numeric>




typedef long long ll;
#define PI 3.14159265359
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define mp make_pair
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBAC
#include <functional>
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

ll gcd(ll a, ll b) {
	ll c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

ll lcm(ll a, ll b) {
	ll c;
	c = a * b / gcd(a, b);
	return c;
}

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t,sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

bool is_prime(int x) {
	if (x <= 1) return false;
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

const ll mod = 1000000007;


map<string, int> memo;

using P=pair<int, int>;




/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/
ll findIndex(int value,vector<ll> a)
{
	
	for (ll i = 0; i < a.size();i++) {
		if (a[i] == value) {
			return i;
		}
	}
	return -1;
}
ll nCr(ll n, ll r) {
	ll a = 1;
	for (ll i = n; i > n - r; --i) {
		a = a * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		a = a / i;
	}
	return a;
}
//E869120 
void comb(vector<vector <long long int> >& v) {
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}


int main() {
  int n;
  cin>>n;
  vector<ll> x(n+1),y(n+1),h(n+1);
  vector<tuple<ll,ll,ll>> a;
  tuple<ll,ll,ll>b=make_tuple(-1,-1,-1);
  for(int i=1;i<=n;i++){
      cin>>x[i]>>y[i]>>h[i];
      if(h[i]>0) b=make_tuple(x[i],y[i],h[i]);
  }
 
  rep(i,101){
    rep(j,101){
      ll z=get<2>(b)+abs(get<0>(b)-i)+abs(get<1>(b)-j);
      z=max(z,0ll);bool f=true;
      for(ll k=1;k<=n;k++){
        ll zz=z-abs(x[k]-i)-abs(y[k]-j);zz=max(zz,0ll);
        if(zz!=h[k])f=false;
      }
      if(f==true)a.push_back(make_tuple(i,j,z));
    }
  }
  if(a.size()==1)cout<<get<0>(a[0])<<" "<<get<1>(a[0])<<" "<<get<2>(a[0])<<endl;
	return 0;
}













Measured memory_bytes: 256
def main():
    S = input()
    odd_list=['R', 'U', 'D']
    eve_list=['L', 'U', 'D']
    odd = S[0::2]
    eve = S[1::2]
    for i in odd:
        if i not in odd_list:
            print('No')
            return
    for i in eve:
        if i not in eve_list:
            print('No')
            return
    print('Yes')

main()


Measured memory_bytes: 9120
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <stack> 
#include <sstream>
#include <set>

typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}

using namespace std;
// now

struct UnionFind {
    vector<int> d;
    UnionFind(int n=0) : d(n,-1){}
    int Find (int x){//根の番号を探す
        if(d[x] < 0) return x;
        return d[x] = Find(d[x]);
    }
    bool unite (int x, int y){
        x = Find(x); y = Find(y);
        if(x == y ) return false;
        if(d[x] < d[y]){
            swap(x,y);
        }
        d[x] += d[y];
        d[y] = x;
        return true;
    } 

    bool same(int x, int y){
        return Find(x) == Find(y);
    }
    int size(int x) {
        return (-d[Find(x)]);
    }
};


ll nCr (ll n, ll r){
    ll ans = 1;
    for(ll i = n ; i > n-r ; i --){
        ans *= i;
    }
    for(ll i = 1 ; i<= r; i ++){
        ans /= i;
    }
    return ans ;
}

int nPr (int n,int r){
    int ans = 1;
    for(int i = n ; i > n-r ; i --){
        ans *= i;
    }
    return ans ;
}
 ll modd = 1e9+ 7;
ll wa (ll n,ll mi, ll ma){
    ll ans  = n * (mi+ma) /2;
    return ans;
}
ll kw(ll k,ll n){
    
    ll ans  =0;
    ll mi,ma;
    mi= wa(k,0,k-1);
    
    ma = wa(k,n-k+1,n);
    
    return (ma-mi +1)%modd;
}

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

    string s = "";
    REP(i,n){
        s += ".";
    }

    REP(i,m){
        string  k,c;
        cin >> k >> c;
        if(k != to_string(n) && c == "0"){
            cout << -1 <<endl;
            return 0;
        }
        if(s[stoi(k)-1] == '.'){
            s[stoi(k)-1] = c[0];
        }else if (s[stoi(k)-1] == c[0]){
            continue;
        }else{
            cout << -1 << endl;
            return 0;
        }
    }
    if(s.size() == 1 && s[0] == '.'){
        cout << 0 << endl;
        return 0;
    }
    REP(i,s.size()){

        if(s[i] =='.'){
            if(i == 0){
                s[i] = '1';
            }else{
                s[i] = '0';
            }
        }
    }
    cout << s <<endl;
}





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

#define MOD 1000000007
typedef unsigned long long ull;

int main() {
  int n;
  cin >> n;
  vector<int> x(n);

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

  double avg = accumulate(x.begin(), x.end(), 0) / (double)x.size();
  int center = round(avg);

  int ans = 0;
  for (int i = 0; i < n; i++) {
      ans += pow(x[i] - center, 2);
  }

  cout << ans;
}


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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX1005

bool f(int a){
    if(a >= 1 && a <= 12)
        return true;
    return false;
}

int n , k;
string s;

int main()
{
    _FastIO;
    cin >> s;
    for(int i = 0; i < s.size(); i++){
        n *= 10;
        n += (int(s[i]) - 48);
    }
    int x = n / 100;
    int y = n % 100;
    bool r = f(x);
    bool t = f(y);
    if(r && t){
        cout << "AMBIGUOUS" << endl;
        return 0;
    }
    if(!r && !t){
        cout << "NA" << endl;
        return 0;
    }
    if(r)
        cout << "MMYY" << endl;
    else
        cout << "YYMM" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define  maxn 200005
#define pb push_back
#define forup(i,a,b) for(int i=(a);i<=(b);i++)  
#define fordown(i,a,b) for(int i=(a);i>=(b);i--)


int main()
{  int a,b; cin>>a>>b;
   if(a*b==15) {cout<<"*"<<endl;return 0;}
   if((a+b)==15) {cout<<"+"<<endl; return 0;}
   cout<<"x"<<endl;
	
	
	
	return 0;
 } 

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.Ia;
		var a=sc.Ia;
		Console.WriteLine("{0}",a[0]!=s[0]?1:0);
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 13140
#include <cctype>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cmath>
#define pk putchar(' ')
#define ph puts("")
typedef long long ll;
using namespace std;
template <class T>
void rd(T &x)
{
    x = 0;
    int f = 1;
    char c = getchar();
    while (!isdigit(c)) {if (c == '-') f = -1; c = getchar();}
    while (isdigit(c)) x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
    x *= f;
}
template <class T>
void pt(T x)
{
    if (x < 0)
        putchar('-'), x = (~x) + 1;
    if (x > 9)
        pt(x / 10);
    putchar(x % 10 ^ 48);
}
const int N = 1e5 + 5;
int n, m, h[N], ans;
vector<int> G[N];
int main() 
{
	rd(n), rd(m);
	ans = n;
	for (int i = 1; i <= n; i++)
		rd(h[i]);
	for (int i = 1, a, b; i <= m; i++)
		rd(a), rd(b), G[a].push_back(b), G[b].push_back(a);
    for (int i = 1; i <= n; i++)
    	for (int j = 0; j < G[i].size(); j++)
    		if (h[i] <= h[G[i][j]])
    		{
    			ans--;
    			break;
    		}
    pt(ans);
    return 0;
}

Measured memory_bytes: 8572
H, W = map(int, input().split())

grid = [0] * H
for h in range(H):
    grid[h] = [int(_) for _ in input().split()]

cnt = 0
ans_lis = []
for h in range(H):
    for w in range(W):
        if grid[h][w] % 2:
            if h == H - 1:
                if w == W - 1:
                    break
                else:
                    cnt += 1
                    grid[h][w + 1] += 1
                    grid[h][w] -= 1
                    ans_lis.append((h + 1, w + 1, h + 1, w + 2))
            else:
                cnt += 1
                grid[h + 1][w] += 1
                grid[h][w] -= 1
                ans_lis.append((h + 1, w + 1, h + 2, w + 1))

print(cnt)
for item in ans_lis:
    print(' '.join(list(map(str, item))))

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

int main() {
  int a1, a2, a3;
  cin>>a1>>a2>>a3;
  if (a1 + a2 + a3 >= 22) {
    cout<<"bust"<<endl;
  } else {
    cout<<"win"<<endl;
  }
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define debug(x) cout << #x << " = " << x << '\n'
#define debug_arr(a , n) for(int i = 0 ; i < n ; i++)cout << a[i] << " "
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define vll vector<ll> 
#define inf 1000000000
#define mod 1000000007

const int max_n = 3e3 + 9;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a , ll b)
{
    ll prod = 1;
    while(b)
    {
        if(b&1)
        prod = (prod*a)%mod;
        a = (a*a)%mod;
        b >>= 1;
    }
    return prod;
}
int dp[max_n][max_n];

void add(int &a , int b){
    a = (a + b)%mod;
}
int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;

    dp[1][1] = 1;
    for(int i = 2 ; i <= n ; i++){
        int pref[i+1] = {0};
        for(int j = 1 ; j <= i-1 ; j++){
            pref[j] = (pref[j-1] + dp[i-1][j])%mod;
        }
        for(int last = 1 ; last <= i ; last++){
            // for(int j = 1 ; j <= i-1 ; j++){
            //     int num = j;
            //     if(j >= last){
            //         num++;
            //     }
            //     assert(num != last);
            //     if(s[i-2] == '<' && num < last){
            //         add(dp[i][last] , dp[i-1][j]);
            //     }
            //     if(s[i-2] == '>' && num > last){
            //         add(dp[i][last] , dp[i-1][j]);
            //     }
            // }

            int l , r;
            if(s[i-2] == '<'){
                l = 1 , r = last - 1;
            }
            else {
                l = last , r = i-1;
            }
            add(dp[i][last] , (pref[r] - pref[l-1] + mod)%mod);
        }
    }

    int ans = 0;
    for(int i = 1 ; i <= n ; i++){
        add(ans , dp[n][i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 34304
N = int(input())
A = list(map(int,input().split(" ")))

A.insert(0,0)
A.append(0)
N += 2

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

for i in range(1,N-1):
    print(s-abs(A[i-1]-A[i])-abs(A[i]-A[i+1])+abs(A[i-1]-A[i+1]))

Measured memory_bytes: 14048
N = int(input())
S = [str(input()) for _ in range(N)]

M = 0
A = 0
R = 0
C = 0
H = 0
for i in range(N):
    tmp = S[i][0]
    if tmp == 'M':
        M += 1
    elif tmp == 'A':
        A += 1
    elif tmp == 'R':
        R += 1
    elif tmp == 'C':
        C += 1
    elif tmp == 'H':
        H += 1
P = [M, A, R, C, H]
ans = 0
for i in range(3):
    for j in range(i+1, 4):
        for k in range(j+1, 5):
            ans += P[i]*P[j]*P[k]
print(ans)


Measured memory_bytes: 9772
import java.util.Scanner; // 文字列を標準入力からscanする

public class Main{ 

  static int return_smaller(int a, int b){
    if(a > b){
      return b;
    }
      return a;
  }
    
  public static void main(final String[] args) {
    Scanner scan = new Scanner(System.in);
		String str = "";
		str = scan.nextLine();
    int N = Integer.parseInt(str);

    int[] hi = new int[N];
    int[] dp = new int[N];

    str = scan.nextLine();
    String[] strs2 = str.split(" ");
    for(int i=0; i<strs2.length; i++) {
      hi[i] = Integer.parseInt(strs2[i]);
    }
    scan.close();

    dp[0] = 0;
    for (int i = 1; i < N; ++i) {
      if(i > 1){
        dp[i] = return_smaller(dp[i - 1] + Math.abs(hi[i] - hi[i - 1]), 
                                  dp[i - 2] + Math.abs(hi[i] - hi[i - 2]));
      }
      else{
        dp[1] = dp[0] + Math.abs(hi[1] - hi[0]);
      }
    }

    System.out.println(dp[N-1]);

  }
}

Measured memory_bytes: 50912
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
const int INF = (1<<30);
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; }

ll dp[110][100010];

int main() {
    int N, W;
    cin >> N >> W;
    ll w[N], v[N];
    rep(i, N) cin >> w[i] >> v[i];
    rep(i, N) {
        rep(j, W+1) {
            if(j >= w[i]) chmax(dp[i+1][j], dp[i][j-w[i]] + v[i]);
            chmax(dp[i+1][j], dp[i][j]);
        }
    }
    cout << dp[N][W] << endl;
    return 0;
}

Measured memory_bytes: 79360
#include<bits/stdc++.h>
using namespace std;
 
map<long long, long long> prime_map;

long long  cal_gcd(long long A,long long B){
  if(B==0){return A;}
  return cal_gcd(B,A%B);
}
 
void prime_factor(int64_t bak){
	for(long long i = 2; i*i <= bak; ++i){
		while(bak % i == 0){
			++prime_map[i];
			bak /= i;
		}
	}
	if(bak > 1){
		++prime_map[bak];
	}
}

void prime_list(int64_t n){
	for(int64_t i=2;i*i<=n;++i){
		while(n%i==0){
			++prime_map[i];
			n=n/i;
		}
	}
	if(n!=1){
		++prime_map[n];
	}
}

 
int main(){
	long long  A, B;
	cin >> A >> B;
	long long gcd = cal_gcd(A, B);
	prime_factor(gcd);
	//prime_list(gcd);
 
	cout << prime_map.size() + 1 << endl;
}

Measured memory_bytes: 256
# これは嘘解法　以下のケースでWAになる
# 4 2
# 1 2 3 4
# 1 2
# 1 3
# 2-1-3, 4の2つのグループに分かれるが回答は3になる
n, m = gets.split.map(&:to_i)
arr = [0] + gets.split.map(&:to_i)

flag = Array.new(n+1, true)
flag[0] = false
m.times do
  a, b = gets.split.map(&:to_i)
  ind = arr[a] < arr[b] ? a : b
  flag[ind] = false
  flag[a] = false if arr[a] == arr[b]
end
puts flag.select{|a| a}.count

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

// balancing load


int main(){

	/*#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output1.txt","w",stdout);
	#endif*/

	long long int n,a,b;
	cin>>n>>a>>b;

	long long int q=n/(a+b);
	long long int r=n%(a+b);

	if(r>=a) cout<<(q+1)*a;
	else cout<<q*a + r; 

	}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n+1;i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a<=c && c<=b) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main(){
	int i, j, N, A[110] = {}, s = 0, a = 0;
	cin>>N;
	for(i = 1; i <= N; i++){
		cin>>A[i];
	}
	
	for(i = 1; i <= N + 1; i++){
		if(A[i] == 1){
			s++;
		} else {
			if(s > a)a = s;
			s = 0;
		}
	}
	cout<<a + 1<<endl;
	return 0;
}



Measured memory_bytes: 3120
# C - Bugged
N = int(input())
s = [int(input()) for i in range(N)]
s.sort()

ans = sum(s)
if ans % 10 != 0:
    print(ans)
else:

    for i in range(len(s)):
        if s[i] % 10 != 0:
            print(ans -s[i])
            exit()
        else:
            pass
    print(0)    

Measured memory_bytes: 3060
def main():
    n=int(input())
    H=tuple(map(int,input().split()))
    ans=0
    c=0
    for i in range(n-1):
        if H[i]>=H[i+1]:
            c += 1
        else:
            ans=max(ans,c)
            c=0
    print(max(ans,c))       
    return
main()

Measured memory_bytes: 14352
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int n, x;
    cin >> n >> x;
    vector<int> m(n);
    rep(i, n) cin >> m[i];
    
    int sum = 0;
    rep(i, n) sum += m[i];
    int minM = 1e8;
    rep(i, n) minM = min(minM, m[i]);
    int r = x - sum;

    int ans = n + r / minM;
    put(ans)

    return 0;
}

Measured memory_bytes: 3584
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanln(&n)
	a := make([]int, n)
	max1, max2 := 0, 0
	for i := 0; i < n; i++ {
		fmt.Scanln(&a[i])
		if a[i] >= max1 {
			max1, max2 = a[i], max1
		} else if a[i] >= max2 {
			max2 = a[i]
		}
	}
	for _, v := range a {
		if v == max1 {
			fmt.Println(max2)
		} else {
			fmt.Println(max1)
		}

	}

}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(int, a, b, c);
  out(max({a, b, c}) * 9 + a + b + c);
}


Measured memory_bytes: 3540
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#define int long long
#define rep(i,n)for(long long i=0;i<n;i++)
#define ll getchar();getchar();return 0;
using namespace std;
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n%i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x,int y) {
	int ans;
	for (int i = (min(x, y)); i >= 1; i--) {
		if (x%i == 0 && y%i == 0) {
			ans = i;
			break;
		}
	}
		return ans;
}
int yakusuunowa(int n) {
	int ans=0;
	for (int i = 1; i <= n; i++) {
		if (n%i == 0)ans += i;
	}
	return ans;
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int ketanowa(int n) {
	int cnt = 0, sum = 0;
	for (int i = 10; i <= n * 10; i *= 10) {
		if (i == 10)cnt += n % i;
		else sum += (n%i - n % (i / 10)) / (i / 10);
	}
	return cnt + sum;
}
signed main() {
	int n,x=0,inf=0;
	string s;
	cin >> n >> s;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'I')x++;
		if (s[i] == 'D')x--;
		if (x > inf)inf = x;
	}
	cout << inf << endl;
	ll
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
  double n;
  cin>>n;
  ll res=0;
  for(double k=1;k<=n;k++)
  res+=(((double)k/2.0F) * floor(n/(double)k) * floor(1.0F + (n/(double)k)));
  cout<<res<<endl;
}

Measured memory_bytes: 3728