akhauriyash/Code-Regression huggingface dataset:
import java.util.LinkedList;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	static final int INF = 2000000;
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int w = sc.nextInt();
			int h = sc.nextInt();
			if(w == 0 && h == 0){
				break;
			}

			TreeMap<Integer, LinkedList<Point>> map = new TreeMap<Integer, LinkedList<Point>>();
			
			Point start = null, goal = null;
			int max = 0;
			for(int i = 0; i < h; i++){
				for(int j = 0; j < w; j++){
					String s = sc.next();
					if(s.equals("S")){
						start = new Point(0, i, j);
						LinkedList<Point> temp = new LinkedList<Point>();
						temp.add(start);
						map.put(0, temp);
					}else if(s.equals("G")){
						goal = new Point(INF, i, j);
					}else if(s.matches("[0-9]+")){
						int num = Integer.parseInt(s);
						max = max < num ? num : max;
						if(map.containsKey(num)){
							map.get(num).add(new Point(INF, i, j));
						}else{
							LinkedList<Point> temp = new LinkedList<Point>();
							temp.add(new Point(INF, i, j));
							map.put(num, temp);
						}
					}
				}
			}
			LinkedList<Point> temp = new LinkedList<Point>();
			temp.add(goal);
			map.put(max + 1, temp);
			System.out.println(fm(map));
		}
		sc.close();
	}
	static int fm(TreeMap<Integer, LinkedList<Point>> map){
		int m = 1;
		LinkedList<Point> from = map.get(0);
		LinkedList<Point> to = null;
		while(true){
			if(!map.containsKey(m)){
				break;
			}
			to = map.get(m);
//			System.out.print(m+":");
			for(Point p : to){
				for(Point s : from){
					int temp = Math.abs(p.x - s.x) + Math.abs(p.y - s.y);
					p.c = p.c > temp + s.c ? temp + s.c : p.c;
				}
//				System.out.print("[" + p.c + "]");
			}
//			System.out.println();
			from = to;
			m++;
		}		
		return map.get(m - 1).get(0).c;
	}
}
class Point{
	int c;
	int x;
	int y;
	Point(int c, int y, int x){
		this.c = c;
		this.x = x;
		this.y = y;
	}
}

Measured memory_bytes: 70624
#include <iostream>
#include<algorithm>
#include<iomanip>
#include<vector>
using namespace std;
#define c(v) cout << fixed << setprecision(10) << v << endl;
#define rep(i,n) for(int i = 0; i < n; i++)
int x[1100]; vector<double> v;
int main()
{
    int n; 
    cin >> n;
    rep(i, n) {
        cin >> x[i];
    }
    rep(i, n - 1) {
        cout << x[i] << " ";
    }
    cout << x[ n - 1] << endl;
    for (int i = 1; i < n; i++) {
        int v = x[i]; int j = i - 1;
        while (j >= 0 && x[j] > v) {
            x[j + 1] = x[j];
            j--;
            x[j + 1] = v;
        }
        rep(i, n - 1)
            cout << x[i] << " ";
        cout <<  x[n - 1] << endl;
    } 
}


Measured memory_bytes: 3096
// Aizu Vol-2 0278: Admission Fee
// 2017.8.6

#include <stdio.h>

int main()
{
	int N, x, y, b, p, k, sm;

	scanf("%d", &N);
	while (N-- > 0) {
		scanf("%d%d%d%d", &x, &y, &b, &p);
		sm = x*b + y*p;
		if (b < 5) b = 5;
		if (p < 2) p = 2;
		k = ((x * b + y * p) * 4) / 5;
		if (sm > k) sm = k;
		printf("%d\n", sm);
	}
	return 0;
}

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

using namespace std;
using ll = long long;

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

const int mod = 1e9 + 7;

ll modpow(ll k, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * k % mod;
    k = k * k % mod;
    n /= 2;
  }
  return res;
}

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

  int n = s.size();

  ll f[n + k + 1];
  f[0] = 1;
  rep(i, n + k) { f[i + 1] = (i + 1) * f[i] % mod; }

  ll fi[n + k + 1];
  rep(i, n + k + 1) fi[i] = modpow(f[i], mod - 2);

  auto choose = [&](ll x, ll y) {
    return (f[x] * fi[y] % mod) * fi[x - y] % mod;
  };

  ll ans = 0;
  for (int i = 0; i <= k; ++i) {
    ll now = modpow(26, k - i);
    now = now * modpow(25, i) % mod;
    now = now * choose(n - 1 + i, n - 1) % mod;
    ans = (ans + now) % mod;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 35656
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (decltype(beg) i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (decltype(beg) i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (decltype(beg) i = beg; end <= i; i--)
#define REP(n)              for (decltype(n) repeat_index = 0; repeat_index < n; repeat_index++)

using namespace std;

struct N {
    int64_t c;
    uint64_t sum;
};

int64_t solve()
{

    uint64_t n, x, m;
    cin >> n >> x >> m;

    vector<N> ns(m + 100, { -1, 0 });
    uint64_t sum = 0;
    int64_t c = 0;
    bool has_loop = false;

    REP(n) {
        if (ns[x].c != -1) {
            has_loop = true;
            break;
        }
        ns[x].c = c;
        ns[x].sum = sum;

        c++;
        sum += x;
        x = x * x % m;
    }
    if (!has_loop) {
        return sum;
    }

    uint64_t ans = sum;
    uint64_t r = n - c;
    uint64_t rr = (c - ns[x].c);
    //cout << ans << " " << r << endl;
    //cout << (sum - ns[x].sum) << " " << (r / (c - ns[x].c)) << endl;
    ans += (sum - ns[x].sum) * (r / rr);
    r %= rr;
    REP(r) {
        ans += x;
        x = (x * x);
        x %= m;
    }
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout << fixed << setprecision(20);
    cout << solve() << endl;
    return 0;
}



Measured memory_bytes: 4776
n = int(input())
a = list(map(int, input().split()))
a = sorted(a, reverse=True)
if n == 2:
  print(a[0])
  exit()

idx = 1
s = a[0]

for i in range(2,n):
  s += a[idx]
  if i % 2 == 1:
    idx += 1
print(s)

Measured memory_bytes: 105344
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
use proconio::fastout;
use proconio::input;
//use proconio::marker::Usize1;
use proconio::marker::Chars;
//use std::collections::HashSet;
// use std::cmp::*;
//use std::collections::VecDeque;

#[fastout]
fn main() {
    input! {
       n: Chars
    }
    for c in n {
        if c == '7' {
            println!("Yes");
            return;
        }
    }
    println!("No");
}


Measured memory_bytes: 2172
#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;
#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);

	int N;
	string S, T;
	cin >> N >> S >> T;

	int cnt[26] = { 0 };
	cnt[S[0] - 'a']++;
	REP(i, N-1) {
		//cout << cnt[T[i] - 'a'] << endl;
		if(i!=0)cnt[S[i] - 'a'] += cnt[T[i] - 'a'];
		cnt[S[i] - 'a'] %= mod;
	}
	cout << cnt[T[N - 1] - 'a'] << endl;

	return 0;
}




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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;cin >> s;
	string t="keyence";
	rep(i,8){
		if(s.substr(0,i)+s.substr(s.size()-(7-i),7-i)==t){
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
}

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

int main()
{
    string s;
    cin >> s;
    for (char c : s) {
        if (c == '9') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 764
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MAXSIZE 10000000;

bool comp(const pair<int,int> a, const pair<int,int> b) {
    return a.second < b.second;
}

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
    int N;
    string s;
    long long int ans = 0;
    map<string, int> map{};

    cin >>N;
    for(int i = 0; i < N;i++){
        cin >>s;
        sort(s.begin(), s.end());
        ans += map[s];
        map[s]++;
    }

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

/*Syakutori
while(cin >>b && b)){
      ll t = 1;
      long long int ansS = 1,ansT=0;
      long long int sum = 0;

      for(ll s = 1;s < 50000000;s++){

        while(t <  50000000 && sum+Rsum[t] < b){
          sum += Rsum[t];
          t++;
        }
        if(b == sum+Rsum[t]){
          if(ansT - ansS < t-s){
            ansS = s;
            ansT = t;
          }
          cout <<ansS<<" "<<ansT-ansS + 1<<endl;
          break;
        }
        if(t == s)++t;
        else sum -= Rsum[s];
        }
    }

//priority_queue<long long int,vector<long long int>, greater<long long int>> PQ;
//priority_queue<long long int> PQ1;

*/

Measured memory_bytes: 11136
N,H = gets.chomp.split(" ").map(&:to_i)
a, b = N.times.map{gets.split.map(&:to_i)}.transpose
max_a = a.max
b = b.sort.reverse
cnt = 0
damage = 0
b.each do |x|
  if x > max_a && damage < H
    damage += x
    cnt += 1
  end
end
if damage < H
  cnt += (H - damage + max_a - 1) / max_a
end
puts cnt

Measured memory_bytes: 24168
def c():
    S = input()
    S = list(S)
    K = int(input())
    one = 0
    if K == 1:
        print(S[0])
        return 0
    else:
        for k in S:
            if k!="1":
                print(k)
                return 0
            else:
                one+=1
                if one == K:
                    print(1)
                    return 0
    print(1)
    return 0
if __name__ == '__main__':
    c()

Measured memory_bytes: 3060
# include <bits/stdc++.h>
using namespace std;
# define lli long long int
# define MOD 1000000007
# define INF 10000000000009
# define MAX 1000000


lli arr[3001];
lli dp[3001][3001][2];

lli findRes(lli i, lli j, lli ch){
    if(i > j)
        return 0;

    if(dp[i][j][ch] != -1)
        return dp[i][j][ch];

    if(ch == 0)
        return dp[i][j][ch] = max(arr[i] + findRes(i + 1, j, 1), arr[j] +
            findRes(i, j - 1, 1));
    return dp[i][j][ch] = min(findRes(i + 1, j, 0), findRes(i, j - 1, 0));

}

void solve(){
    lli n;
    cin >> n;

    lli sum = 0;
    for(lli i = 0; i < n; i++){
        cin >> arr[i];
        sum += arr[i];
    }

    memset(dp, -1, sizeof(dp));
    cout << 2*findRes(0, n - 1, 0) - sum;

}

int main(){
    int t;
    t = 1;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 144440
from collections import defaultdict
N=int(input())
A=list(map(int,input().split()))

MOD=10**9+7

inv=[1]*(10**6+1)
for i in range(2,10**6+1):
    inv[i]=MOD-inv[MOD%i]*(MOD//i)%MOD

LCM=defaultdict(int)
def f(n):
    tmp=0
    p=2
    while n%p==0:
        tmp+=1
        n//=p
    LCM[p]=max(LCM[p],tmp)
    p=3
    while p*p<=n:
        tmp=0
        while n%p==0:
            tmp+=1
            n//=p
        LCM[p]=max(LCM[p],tmp)
        p+=2
    if n>1:
        LCM[n]=max(LCM[n],1)

for a in A: f(a)

l=1
for p,n in LCM.items():
    l=l*pow(p,n,MOD)%MOD

ans=0
for a in A:
    ans+=l*inv[a]%MOD

print(ans%MOD)

Measured memory_bytes: 56412
import java.util.Scanner;
public class Main
{
	public static void main( String args[] )
	{
		Scanner input = new Scanner(System.in);
		int h, w;
		while(true)
		{
			h=input.nextInt();
			w=input.nextInt();
			if(h == 0 && w == 0)
				break;
			else {
				for(int i = 0; i < h; i++)
				{
					for(int k = 0; k < w; k++)
					{
						if(i == 0 || i == h-1 || k == 0 || k == w-1)
							System.out.print("#");
						else
							System.out.print(".");
					}
					System.out.println();
				}
			}
			System.out.println();
		}
	}
}

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

using namespace std;

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

typedef long long ll;
typedef pair<ll,ll> p;


int main()
{
  int n;
  cin >> n;
  int res = 0;
  for (int i = 1; i <= n; i += 2)
  {
    int count = 0;
    for (int j = 1; j <= n; j++)
    {
      count += (i % j == 0);
    }
    if(count == 8) res++;
  }
  cout << res << endl;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <stack>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	//入力
	long A[100001], B[100001], x[100001] = {};
	long N, K, T = 0, M = 1000000000, ans = 0, l = 0, r = 0, sum = 0, a = 0, b = 0, c = 0;
	cin >> N >> T;
	ans = 1001;
	for (int i = 0; i < N; i++) {
		cin >> a >>b;
		if (T >= b) ans = min(ans, a);
	}
	//処理
	//出力
	if (ans != 1001) cout << ans << endl;
	else cout << "TLE" << endl;
}

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

int main(){
  int H,W;
  cin >> H >> W;
  
vector<vector<char>> pic(H,vector<char>(W));
  for(int i = 0;i < H;i++){
    for(int j = 0;j < W;j++){
      cin >> pic.at(i).at(j);
    }
  }
   for(int k;k < W + 2;k++){
    cout << "#";
  }
  cout << endl;
  for(int i = 0;i < H;i++){
    cout << "#";
      for(int j = 0;j < W;j++){
        cout << pic.at(i).at(j);
      }
    cout << "#" << endl;
  }
  for(int i = 0; i < W + 2;i++){
    cout << "#";
  }
}

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

int main(){
  vector<pair<int,int>> T(5);
  int k,ans=0;
  for(int i=0; i<5; i++){
    cin >> k;
    T.at(i)=make_pair(k%10,k);
  }
  sort(T.begin(),T.end());
  for(int i=0; i<5&&T.at(i).first==0; i++){
    ans+=T.at(i).second;
  }
  for(int i=4; i>=0&&T.at(i).first!=0; i--){
    ans+=(T.at(i).second/10+1)*10;
  }
  k=1;
  for(int i=0; i<5&&k; i++){
    if(T.at(i).first!=0){
      ans=ans-(T.at(i).second/10+1)*10+T.at(i).second;
      k=0;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int n, t;
vector<int> ct;

int main() {
    cin >> n >> t;
    for (int i = 0; i < n; i++) {
        int ci, ti;
        cin >> ci >> ti;
        if (ti <= t) {
            ct.push_back(ci);
        }
    }
    sort(ct.begin(), ct.end());

    if (ct.empty()) {
        cout << "TLE" << endl;
    } else {
        cout << ct.front() << endl;
    }

    return 0;
}


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




int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t;
    string a,b;
    cin>>t>>a>>b;


    for(int i=0; i<a.size(); i++)cout<<a[i]<<b[i];
    return 0;
}


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

using namespace std;

int main() {
    int n, x;
    cin >> n >> x;
    int temp;
    vector<int> l;
    for (int i = 0; i < n; i++) {
        cin >> temp;
        l.push_back(temp);
    }
    int c = 0;
    int mass = 0;
    for (int i = 0; i < n; i++) {
        mass += l[i];
        c++;
        if (mass > x) {
            if (i == 0)break;
            c--;
            break;
        }
    }
    cout << c + 1;

    return 0;
}

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

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

  int n;
  cin >> n;
  unordered_set<int> ok = {4, 7, 8, 11, 12, 14, 15, 16};
  string ans = (n >= 18 || ok.find(n) != ok.end()) ? "Yes" : "No";
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

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

    int n;
    cin >> n;
    vector<vector<int>> cnt(10, vector<int>(10, 0));
    for(int i = 1; i <= n; ++i){
        string s = to_string(i);
        int a = s[0] - '0', b = s.back() - '0';
        ++cnt[a][b];
    }
    ll ans = 0;
    for(int i = 1; i < 10; ++i){
        for(int j = 1; j < 10; ++j){
            ans += (ll)cnt[i][j] * cnt[j][i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>
using namespace std;
using ll=long long;
const ll MOD = 1000000007;
int n,k;
vector<ll> a;
ll dp[110][100010];

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

    a.resize(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    for (int i = 0; i <= n; ++i)
    {
       dp[i][0] = 1;
    }
    for (int i = 1; i <= n; ++i)
    {
        for (int j = 1; j <= k; ++j)
        {
            dp[i][j] = ( dp[i-1][j] + dp[i][j-1] )%MOD;
            if(j-a[i-1]-1>=0) dp[i][j] = (dp[i][j] + MOD - dp[i - 1][j - a[i - 1] - 1])%MOD;
           
        }
    }


cout << dp[n][k];

return 0;
}




Measured memory_bytes: 79360
#include<stdio.h>
int main()
{
	int N;
	double p=0,ans=0;
	scanf("%d",&N);
	for(int i=1;i<=N;i++)
	{
		if(i%2==1)
			ans++;
	}
	p=ans/N;
	printf("%.10lf",p);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main(){
    int a,b,c,x,count=0;
    cin >> a >> b >> c >> x;
    for(int i=0; i<=a; i++){
        for (int j=0;j<=b;j++){
            int Q= 500 * i + 100 * j;
            if(Q <= x && (x - Q) / 50 <= c ){
                count++;
            }
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 504
n,h=map(int,input().split())
a=[0]*n
b=[0]*n
for i in range(n):
    a[i],b[i]=map(int,input().split())
a_max=max(a)
b.sort()
ans=0
for bi in b[::-1]:
    if bi>a_max and h>0:
        h-=bi
        ans+=1
    else:
        break
if h>0:
    ans+=-(-h//a_max)
print(ans)

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

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

int main() {
    int N;
    cin >> N;
    vector<int> L(N);

    for (int &i : L)
        cin >> i;

    int sum = 0, maxv;
    maxv = L.at(0);

    for (int &i : L) {
        sum += i;
        maxv = max(maxv, i);
    }

    cout << (maxv < (sum - maxv) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
x_max = max(x)
y_min = min(y)
result = False
if y_min <= x_max:
    result = True
if x_max >= Y or y_min <= X:
    result = True
if result:
    print("War")
else:
    print("No War")

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

int main(){
  int N;
  cin >> N;
  
  vector<vector<int>> A(2, vector<int>(N));
  for(int i = 0; i < 2; i++){
    for(int j = 0; j < N; j++){
      cin >> A.at(i).at(j);
    }
  }
  
  vector<int> Y1(N+1);
  for(int i = 0; i < N; i++){
    Y1.at(i+1) = Y1.at(i) + A.at(0).at(i);
  }
  vector<int> Y2(N+1);
  for(int i = 0; i < N; i++){
    Y2.at(i+1) = Y2.at(i) + A.at(1).at(i);
  }
  int sum = 0;
  int M = 0;
  for(int i = 1; i <= N; i++){
    sum = Y1.at(i) + Y2.at(N) - Y2.at(i-1);
    if(sum > M){
      M = sum;
    }
  }
  
  cout << M << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N;
    cin >> N;
    string t;
    cin >> t;
    string s[N];
    for (int i = 0; i < N; i++) {
        cin >> s[i];
    }
    int ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= s[i].length() - t.length(); j++) {
            for (int k = 1; k < 100; k++) {
                for (int l = 0; l < t.length(); l++) {
                    int idx = j + k * l;
                    if (idx >= s[i].length()) break;
                    if (s[i][idx] != t[l]) break;
                    if (l == t.length() - 1) {
                        ans++;
                        goto loop;
                    }
                }
            }
        }
        loop:{}
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define foreach(i,n) for(auto &&i:n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define GSORT(x) sort(all(x), greater<int>())
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x) int x;cin >> x
#define cill(x) LL x;cin >> x
#define cis(x) string x;cin >> x
#define co(x) cout << x << endl
#define dump(x)  cout << #x << " = " << (x) << endl
#define truecheck assert
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef long long int64;
template<class T,class U>bool chmax(T &a, const U &b) { if (a<b) { a=b; return true; } return false; }
template<class T,class U>bool chmin(T &a, const U &b) { if (b<a) { a=b; return true; } return false; }
const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;

int main() {
    fastcin();
    cout << fixed << setprecision(10);
    cii(a);
    cii(b);
    cii(c);
    auto ans = "No";
    if (a == b && a != c){
        ans = "Yes";
    }
    if (b == c && b != a){
        ans = "Yes";
    }
    if (c == a && c != b){
        ans = "Yes";
    }
    co(ans);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    long N;
    cin>>N;
    for(long h=1L;h<=3500L;h++){
        for(long n=1L;n<=3500L;n++){
            if((4*h*n-N*n-N*h)>0L&&N*h*n%(4*h*n-N*n-N*h)==0L){
                cout<<n<<" "<<h<<" "<<N*h*n/(4*h*n-N*n-N*h)<<endl;
                return 0;
            }
        }
    }
}

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

int main(){
  int h, w, k;
  cin >> h >> w >> k;
  vector<vector<char>> c(h, vector<char>(w));
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cin >> c.at(i).at(j);
    }
  }
  
  int ans = 0;
  for(int bith = 0; bith < (1<<h); bith++){
    for(int bitw = 0; bitw < (1<<w); bitw++){
      int count = 0;
      for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
          if((bith & (1<<i)) && (bitw & (1<<j))){
            if(c.at(i).at(j) == '#') count++;
          }
        }
      }
      if(count == k) ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3536
from collections import deque

h,w = map(int,input().split())

table = [ list(input()) for _ in range(h) ]

search = [[1, 0], [0, 1], [-1, 0], [0, -1]] 
# right, up, left, down

maxlength = 0
for si in range(h):
    for sj in range(w):
        if table[si][sj]=="#":
            pass
        else:
            table_past_flag = [ [0]*w for _ in range(h) ]
            q = deque([[si,sj,0]])
            table_past_flag[si][sj] = 1
            while(q):
                tmp = q.popleft()
                maxlength = max(maxlength,tmp[2])
                for di,dj in search:
                    ni = tmp[0] + di
                    nj = tmp[1] + dj
                    if 0 <= ni < h and 0<= nj < w:
                        if table_past_flag[ni][nj]!=1 and table[ni][nj]!="#":
                            q.append([ni,nj,tmp[2]+1])
                            table_past_flag[ni][nj] = 1
                        else:
                            pass
print(maxlength)

Measured memory_bytes: 3316
import java.util.Scanner;
class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int a=0,b=0;
		int c=0,d=0;
		boolean e = true;
		for(;e;) {
			if(!e) break;
			a++;
			b++;
			for(int i = 0;i<a;i++) {
				
				if(!e)break;
				if(i%2 == 0) c=i/2;
				else c=-i/2;
				for(int j = 0;j<b; j++) {
					if(j%2 == 0)d=j/2;
					else d=-j/2;
					if(Math.pow(c, 5)-Math.pow(d, 5)==x) e =false;
					if(!e) break;
				}
			}
		}
		System.out.println(c+" "+d);
	}
}

Measured memory_bytes: 39172
N,M=map(int,input().split())
A=list(map(int,input().split()))
Change=True
round=1
while Change:
    Change=False
    for i in range(N-1):
        if A[i+1]>A[i]:
            temp=A[i+1]
            A[i+1]=A[i]
            A[i]=temp
            Change=True
    round+=1
popular=A[0:M]
SUM=sum(A)
count=True
for j in range(M):
    if SUM*(1/(4*M))>popular[j]:
        count=False
if(count):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

ll prvNum(ll now, ll n) {
	ll sum = (1LL << n) -1;
	ll sum2 = sum / 2;
	if(sum2 < now) return now - sum2 - 1;
	return sum2 - now;
}
char lastOpe(ll now, ll idx, ll n) {
	ll sum = (1LL << n) - 1LL;
	ll nxt = sum - now, prv = prvNum(now, n);
	bool f = now > nxt;
	return (f^(prv&1LL)^(idx&1LL) ? 'L' : 'R');
}

int main(){
	ll n, now, idx;
	while(cin >> n >> now >> idx) {
		if(n == 0 && now == 0 && idx == 0) break;
		now--; idx--;
		string s;
		while(n > 1) {
			s += lastOpe(now, idx, n);
			now = prvNum(now, n);
			n--;
			idx /= 2;
		}
		s += (now^idx ? 'R':'L');
		reverse(all(s));
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 3160
#include <stdio.h>

int main(void)
{
	int a,b,c[7],d;
	for(d=0;d<7;d++){
		scanf("%d %d",&a,&b);
		c[d]=a-b;
	}
	for(d=0;d<7;d++){
		printf("%d\n",c[d]);
	}
	return 0;
}



Measured memory_bytes: 2052
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {


    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner();
        PrintWriter out = new PrintWriter(System.out);
        int n = sc.nextInt();
        int ans = 0;
        int[] a = sc.nextIntArray(n);
        for (int i = 0; i < n; i++) {
            int j = i + 1;
            while (j < n && a[j] <= a[j-1])
                j++;
            ans = Math.max(ans, j - i - 1);
            i = j - 1;
        }
        out.println(ans);
        out.flush();
        out.close();
    }

    static class Scanner {
        BufferedReader br;
        StringTokenizer st;

        Scanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

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

        long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        Integer[] nextIntegerArray(int n) throws IOException {
            Integer[] ans = new Integer[n];
            for (int i = 0; i < n; i++)
                ans[i] = nextInt();
            return ans;
        }

        double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        int[] nextIntArray(int n) throws IOException {
            int[] ans = new int[n];
            for (int i = 0; i < n; i++)
                ans[i] = nextInt() - 1;
            return ans;
        }

    }


}

Measured memory_bytes: 41460
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a), i##_max = (b); i < i##_max; ++i)
#define RFOR(i, a, b) for (int i = (b)-1, i##_min = (a); i >= i##_min; --i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()

#define pb push_back
#define mp make_pair
#define fst first
#define snd second

using namespace std;
using i64 = int64_t;
using u64 = uint64_t;
using vb = vector<bool>;
using vi = vector<int>;
using vl = vector<i64>;
using vd = vector<double>;
using pi = pair<int, int>;
using pl = pair<i64, i64>;
using pd = pair<double, double>;

constexpr int INF = 1 << 30;
constexpr int MOD = 1000000007;

template <typename T>
void print(vector<T> &v) {
  for (auto it = v.begin(); it != v.end(); ++it) {
    if (it == v.begin()) cout << " ";
    cout << *it;
  }
  cout << endl;
}

int main() {
  int n, m;
  cin >> n >> m;
  vi C(m), T(n + 1, INF);
  REP(i, m) cin >> C[i];
  T[0] = 0;
  REP(i, m) {
    for (int j = 0; j + C[i] <= n; ++j) {
      T[j + C[i]] = min(T[j + C[i]], T[j] + 1);
    }
  }

  cout << T[n] << endl;
}


Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <functional>
#include <utility>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>
using namespace std;

#define rep(i,end)          rep2(i,0,(end))
#define rep2(i,beg,end)   for (int i=(beg);i<(end);i++)
#define all(cont)           begin(cont), end(cont)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll, ll> pii;
typedef pair<ll, string> pis;
typedef pair<string, ll> psi;

string gets(bool skipnewline);
vi get_n_array(int n);

void func(const int N, ll next[], ll dp[], const int k);

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, d;
    cin >> n >> d;
    double c = d * 2 + 1;
    cout << ll(ceil(n/c)) << endl;
    return 0;
}

string gets(bool skipToNextline)
{
    if (skipToNextline) gets(false);
    const int LINE_MAX = 1024;
    char buf[LINE_MAX];
    cin.getline(buf, sizeof(buf));
    return buf;
}

vi get_n_array(int n)
{
    vi v;
    while (n-- > 0) {
        int x;
        cin >> x;
        v.push_back(x);
    }
    return v;
}

Measured memory_bytes: 256
#define TEST_MODE true

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; --i)
#define rrep2(i, a, b) for (int i = (a)-1; i >= (int)b; --i)
#define range(i, a, b, c) for (int i = a;             \
                               c > 0 ? i < b : i > b; \
                               i += c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a), end(a)
#define ifnot(a) if (not(a))
#define int long long

#ifdef LOCAL_ENV

#if TEST_MODE == true
const bool test = true;
#define dump(x) cerr << #x << " = " << (x) << endl
#else
const bool test = false;
#define dump(x) 
#endif

#else
const bool test = false;
#define dump(x) 
#endif

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
const int INF = (int)1 << 60;
const ll INFL = (ll)1 << 60;
ll mod_n = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real &r) { return (r > eps) - (r < -eps); }
int sgn(const Real &a, const Real &b) { return sgn(a - b); }

//.....................
const int MAX = (int)2e5 + 5;

vector<string> split(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while (getline(ss, buffer, sep))
    {
        v.push_back(buffer);
    }
    return v;
}

template <class InputIterator>
int sum(InputIterator begin, InputIterator end)
{
    return accumulate(begin, end, 0ll);
}

void solve();

class Solver {
public:
    int n, m;
    void solve() {
        cin >> n >> m;
        cout << (n-1) * (m-1) << endl;
    }
};

signed main()
{
    cout << fixed << setprecision(20);
    auto ptr = new Solver();
    ptr->solve();
    delete ptr;
    // while (true) {    
    //     auto ptr = new Solver();
    //     ptr->solve();
    //     delete ptr;
    // }
    return 0;
}

// class Mycin {
// 	bool flag = true;
// public:
// 	Mycin& operator >> (int& a) {flag = scanf("%lld", &a) != EOF; return *this;}
// 	Mycin& operator >> (char& a) {flag = scanf("%c", &a) != EOF; return *this;}
// 	Mycin& operator >> (string& s) {flag = (bool)(cin >> s); return *this;}
// 	operator bool() {return flag;}
// } mycin;
 
// class Mycout {
// public:
// 	Mycout& operator << (const int& a) {printf("%lld", a); return *this;}
// 	Mycout& operator << (const char c) {printf("%c", c); return *this;}
// 	Mycout& operator << (const string& s) {printf("%s", s.c_str()); return *this;}
// } mycout;
 
// #define cin mycin
// #define cout mycout
// #define endl '\n'




Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,a,c,p[100],i,sum;
	sum=0;
	scanf("%d %d",&n,&c);
	for(i=0;i<c;i++){
		scanf("%d",&p[i]);
		sum+=p[i];
	}
	n+=1;
	a=sum/n;
	if(sum%n!=0){
		a+=1;
	}
	printf("%d\n",a);
	return 0;
}
	


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;

int main() {
    int A, B, C, D; cin >> A >> B >> C >> D;
    if ((A + B) > (C + D)) {
        cout << "Left" << endl;
    } else if ((A + B) < (C + D)) {
        cout << "Right" << endl;
    } else {
        cout << "Balanced" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
x, y, _a, _b, _c = gets.chomp.split(' ').map(&:to_i)
pp = gets.chomp.split(' ').map(&:to_i).sort
qq = gets.chomp.split(' ').map(&:to_i).sort
rr = gets.chomp.split(' ').map(&:to_i).sort
red_count, green_count, colorless_count = 0, 0, 0
value = 0
while red_count + green_count + colorless_count < x + y
  p, q, r = pp.last || 0, qq.last || 0, rr.last || 0
  p = 0 if red_count >= x
  q = 0 if green_count >= y
  if p >= q && p >= r
    pp.pop
    red_count += 1
    value += p
  elsif q >= p && q >= r
    qq.pop
    green_count += 1
    value += q
  else
    rr.pop
    colorless_count += 1
    value += r
  end
end
puts value

Measured memory_bytes: 26812
#include<bits/stdc++.h>
using namespace  std ;
typedef long long  ll;
typedef pair<ll, ll> Pll;
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define rad(X) cout << (X) << endl
#define ASH(X) cout << (X) << " "
#define debug(x) cout << #x << " " << x << endl;
#define debug2(x,y) cout << #x << " " << x << " " << #y << " " << y << endl;
#define FOR(I,A,B) for(ll I = (A); I <= (B); I++)
#define cir(I,B,A) for(ll I = (A); I >=(B); I--)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define SORT(c) (sort(c.begin(),c.end()))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASES int ___T; cin >> ___T; for(int cs=1;cs<=___T;cs++)
#define FAST()  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll fx[] = {1, 1, 0, -1, -1, -1, 0, 1};
ll fy[] = {0, 1, 1, 1, 0, -1, -1, -1};
vector<ll>a,b,c;
map<ll,ll>m1,m2,m3;

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

void Execute()
{
      ll N,NB,VAL,A,B,C,G,INC,DEC,L,R,D;
      cin >> N;
      cout<<3*N*N<<endl;


}

int32_t main()
{
    //freopen("atomm.txt", "r", stdin);
    FAST();
    //CASES

        Execute();

}


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


int main() {
	lli n,p=1;
	cin >> n ;
	lli a[n];
	for(lli i=0;i<n;++i)
	{
	    cin >> a[i];
	    if(a[i]==p) p++;
	}
	if(p==1) cout << -1;
	else cout << n-p+1;
	return 0;
}


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

#define debug(x) (cerr << #x << " = " << x << endl;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
#define MSET(c, v) memset(c, v, sizeof(c))

const int INF = 0x3F3F3F3F;
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const double EPS = 1e-10;

inline int cmp(double x, double y = 0)
{
  if (fabs(x - y) < EPS)
    return 0;
  return x > y ? 1 : -1;
}

const int maxn = 2e5 + 100;

ll a[maxn];
int n;

bool check(ll val, ll k)
{
  ll cnt = 0;
  for(int i = 0; i < n ; i++)
  {
    ll x = (a[i] + val - 1) / val;
    cnt += x - 1;
  }
  return cnt <= k;
}

int main()
{
  ios::sync_with_stdio(false);
  int k;
  cin >> n >> k;
  for(int i = 0; i < n ; i++)
    cin >> a[i];

  ll lo = 1;
  ll hi = 2e18;
  ll ans = 1;
  while(lo <= hi)
  {
    ll mid = (lo + hi) >> 1;
    if(check(mid, k))
    {
      ans = mid;
      hi = mid - 1;
    }
    else
      lo = mid + 1;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 5176
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 6 ;
int isPalindrome(int n)
{
    int temp  = 0;
    for (int i = n; i > 0; i /= 10)
        temp = temp * 10 + i % 10 ;
    return (n == temp);
}
int cnt ;
int main()
{
  int a , b ;
  cin >> a >> b ;
  for(int i = a ; i <= b ; ++i)
    if(isPalindrome( i ))  ++cnt ;
  cout << cnt << "\n";


    return 0;
}


Measured memory_bytes: 256
N, W = map(int, input().split())
wv = [[0, 0]]
for _ in range(N):
    w, v = map(int, input().split())
    wv.append([w, v])

# dp[i][j]=(i番目までの品物を、価値がj以上になるように選んだときの最小重さ)
dp = [[10**12 for _ in range(100001)] for _ in range(N+1)]
dp[0][0] = 0
# print(dp)
for i in range(1, N + 1):
    for j in range(0, 100001):
        # i番目のアイテムを入れることができる場合
        if j - wv[i][1] >= 0:
            # 実際にアイテムを入れる場合、入れない場合
            dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - wv[i][1]] + wv[i][0])
        # i番目のアイテムを入れることができない場合
        else:
            dp[i][j] = dp[i - 1][j]

ans = 100000
while(dp[N][ans] > W):
    ans -= 1

# print(dp)
print(ans)


Measured memory_bytes: 218104
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(abs(a-c)<=d)
	{
		cout<<"Yes"<<endl;
		return 0;
	}
	else if(abs(a-b)<=d&&abs(b-c)<=d)
	{
		cout<<"Yes"<<endl;
		return 0;
	}
	cout<<"No"<<endl;
	return 0;
}


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

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

  vector<int64_t> a(n);

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

  int best_l = 0, best_r = 1;
  int64_t best_sum = -(1LL << 50);

  for (int l = 0; l < n; l++) {
    int64_t sum = 0;
    for (int r = l + 1; r <= n; r += 2) {
      if (r > l + 1 and a[r - 1] <= 0) continue;
      sum += a[r - 1];

      if (sum > best_sum) {
        best_l = l;
        best_r = r;
        best_sum = sum;
      }
    }
  }

  cout << best_sum << endl;

  vector<int> seq;

  for (int i = 0; i < best_l; i++) {
    seq.push_back(1);
    a.erase(begin(a));
  }

  for (int i = 0; i < n - best_r; i++) {
    seq.push_back(a.size());
    a.pop_back();
  }

  while (a.size() > 1) {
    int idx;
    int64_t new_elem;

    for (int i = 1; i < a.size() - 1; i++) {
      if ((i % 2 == 1 and a[i - 1] > 0 and a[i + 1] > 0) or
          (i % 2 == 0 and a[i] <= 0)) {
        idx = i;
        new_elem = a[i - 1] + a[i + 1];
        break;
      }
    }
    seq.push_back(idx + 1);
    a.erase(a.begin() + (idx - 1), a.begin() + (idx + 2));
    a.insert(a.begin() + (idx - 1), new_elem);
  }

  cout << seq.size() << endl;
  for (int idx : seq) {
    cout << idx << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#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> a(n);
    set<int> s;
    rep(i,n){
        cin>>a[i];
        s.insert(a[i]);
    }
    

    cout<< s.size() << endl;
    
    return 0;
}


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

int main()
{   
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int i;
  string str;
  cin>>str;
  int n=str.length();
  stack<char>s;
  i=0;
  int count=0;
  while(i<n)
  {
    if(s.size()==0)
      s.push(str[i]);
    else
    {
      if(str[i]=='0' && s.top()=='1' )
      {
        count+=2;
        s.pop();
      }
      else if(str[i]=='1' && s.top()=='0' )
      {
        count+=2;
        s.pop();
      }
      else
        s.push(str[i]);
    }
    i++;
  }
  cout<<count;

    return 0;
}

Measured memory_bytes: 3852
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793
 
 
   
int main(){
 int n;
 cin >> n;
 int ans=-1;
 for(int i=1;i<=50000;i++){
   int v=i*108/100;
   if(v==n){
     ans=i;
     break;
   }
 }
 if(ans<0)cout << ":(" << endl;
 else cout << ans << endl;
} 
    

Measured memory_bytes: 3572
#include<iostream>
#include<string>
#include <vector>
#include<queue>
#include<map>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<bitset>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define vsort(v) sort(v.begin(), v.end())
#define rv(v) reverse(v.begin(), v.end())
#define ll long long
using vll = vector<ll>;
using Graph = vii;
const ll MOD = 1e9 + 7;

int main() {
	int a, b;
	cin >> a >> b;
	if (1 <= a && a <= 9 && 1 <= b && b <= 9) cout << a * b << endl;
	else cout << -1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

typedef long long ll;

const int INF = 2e9 + 5;
const int alength=100100;

int main() {
	int n,i;
	cin>>n>>i;
	cout<<n-i+1;
}

Measured memory_bytes: 256
function Main(input){
    input = input.split("\n");
    var mem = input[0].split(" ").map(Number);
    var dp = new Array(20020);
    dp[0] = 0;
    input.shift();
    for(var i=0;i<input.length;i++){
        input[i] = input[i].split(" ").map(Number);
    }
    for(var i=1;i<dp.length;i++){
        var min = Number.MAX_SAFE_INTEGER;
        for(var j=0;j<input.length;j++){
         //   console.log(i,input[j][0])
            if(i-input[j][0]<0) continue;
            else min = Math.min(min,dp[i-input[j][0]]+input[j][1]);
        }
        dp[i] = min
       // console.log(dp)
    }
    var max = 0;
    for(var i=0;i<input.length;i++){
        if(max<input[i][0]) max = input[i][0]
    }
    var ans = Number.MAX_SAFE_INTEGER;
    for(var i=mem[0]-0;i<mem[0]-0+1+max;i++){
        //console.log(dp[i])
        if(ans>dp[i]) ans = dp[i];
    }
    console.log(ans)
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


Measured memory_bytes: 33684
#include "bits/stdc++.h"
#define sz(x) ((int)(x).size())
#define rep(i,b,c) for(int i=b;i<=c;i++)
#define rev(i,b,c) for(int i=b;i>=c;i--)
#define all(v) v.begin(),v.end()
#define clr(a,b) memset((a), (b), sizeof(a))
#define mp make_pair
using namespace std;
typedef long long ll; typedef pair<int, int> ii; typedef vector<int> vi; typedef vector<ii> vii;
const ll inf = (int)1e9 - 1;//2^18 = 262144 , 2^20 ~ 1e7, //262143 -- 1e5 + 1
const int N = ((int)1e5 + 10), K = 70000, mod = int(1e9) + 7;
const double eps = 1e-9;
inline void in(){
	ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef Srinu73
	freopen("input.txt", "r", stdin);
#endif
}
template <class T> T modexp(T a, T b, T c){ T ans = 1; while (b){ if (b & 1)ans = (ans*a) % c; a = (a*a) % c; b >>= 1; }return ans; }
template <class T> T C(T n, T r){ r = min(r, n - r); T ans = 1; for (T i = 1; i <= r; i++){ ans *= (n - r + i); ans /= i; }return ans; }
map<int,int>ma;
vector<int>v;
int main()
{
	in();
	int n, m;
	cin >> n>>m;
	rep(i, 0, m - 1){
		int x; cin >> x;
		v.push_back(x);
	}
	reverse(all(v));
	for (int x : v){
		if (ma[x]) continue;
		else ma[x]++, cout << x << endl;
	}
	rep(i, 1, n) if (ma[i] == 0) cout << i << endl;
}

Measured memory_bytes: 12696
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007
int main(){
	fast;
	ll a,b,c;
	cin>>a>>b>>c;
	if(a!=b&&a!=c&&b!=c)
		cout<<3;
	else if(a==b and b==c)
		cout<<1;
	else
		cout<<2;
	return 0;
}



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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

int main(int argc, char *argv[])
{
  int n, k;
  while (cin >> n >> k) {
    const int N = n + 10;
    int a[N];
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
    }

    lli b[N];
    b[0] = max(0, a[0]);
    for (int i = 1; i < n; ++i) {
      b[i] = b[i - 1] + max(0, a[i]);
    }

    lli c[N];
    c[n - 1] = max(0, a[n - 1]);
    for (int i = n - 2; 0 <= i; --i) {
      c[i] = c[i + 1] + max(0, a[i]);
    }

    // for (int i = 0; i < n; ++i) cout << b[i] << ' '; cout << endl;
    // for (int i = 0; i < n; ++i) cout << c[i] << ' '; cout << endl;
    
    lli sum = 0;
    for (int i = 0; i < k; ++i) {
      sum += a[i];
    }

    lli mx = 0;
    int i;
    for (i = 0; i + k < n; ++i) {
      lli x = max<lli>(sum, 0);
      lli y = 0;
      lli z = 0;
      
      if (i) y = b[i - 1];
      if (i + k < n) z = c[i + k];

      mx = max(mx, x + y + z);
      sum += a[i + k];
      sum -= a[i];
    }
    {
      lli x = max<lli>(sum, 0);
      lli y = 0;
      lli z = 0;
      
      if (i) y = b[i - 1];
      if (i + k < n) z = c[i + k];

      mx = max(mx, x + y + z);

    }
    
    cout << mx << endl;
  }
  
  return 0;
}


Measured memory_bytes: 2176
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        double[] P = new double[N+1];
        for(int i = 1; i <= N; i++) P[i] = sc.nextDouble();
        double[][] dp = new double[N+1][N/2 +1];
        dp[0][0] = 1;
        for(int i = 1; i <= N; i++){
            for(int j = 0; j <= N/2; j++){
                dp[i][j] += dp[i-1][j] * P[i];
                if(j > 0) dp[i][j] += dp[i-1][j-1] * (1 - P[i]);
            }
        }
        double ans = 0;
        for(int j = 0; j <= N/2; j++){
            ans += dp[N][j];
        }
        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 70276