akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        long[] h = new long[N];
        for (int i = 0; i < N; i++) {
            h[N-i-1] = scan.nextLong();
        }
        long[] s = new long[N];
        s[0] = 0;
        for (int i = 1; i < N; i++) {
            if (h[i-1] <= h[i]) {
                s[i] = s[i-1] + 1;
            } else {
                s[i] = 0;
            }
        }
        long answer = Arrays.stream(s).max().getAsLong();
        System.out.println(answer);
    }
}


Measured memory_bytes: 53424
n = int(input())
a = [int(input()) for i in range(n)]
a.sort()

if n%2 == 0:
  ans = 2*sum(a[n//2+1:]) - 2*sum(a[:n//2-1]) + a[n//2] - a[n//2-1]
  print (ans)
else:
  b = 2*sum(a[n//2+1:]) - 2*sum(a[:n//2-1]) - a[n//2] - a[n//2-1]
  c = 2*sum(a[n//2+2:]) - 2*sum(a[:n//2]) + a[n//2] + a[n//2+1]
  print (max(b,c))

Measured memory_bytes: 13352
#include<iostream>
#include<cstdio>

using namespace std;

int main() {
  int n, high, low, sum, tmp;
  cin>>n;
  while(n>0) {
    high = 0;
    low = 1000;
    sum = 0;
    for(int i=0; i<n; i++) {
      cin>>tmp;
      sum += tmp;
      if(tmp<low)
	low = tmp;
      if(high<tmp)
	high = tmp;
    }
    sum -= (low+high);
    sum /= (n-2);
    cout<<sum<<endl;
    cin>>n;
  }
}

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

int ans[100001];
int n;

int main(){
    int a;
    int length=0;
    int num[100001];
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>num[i];
    }
    ans[0]=num[0];
    length=1;
    for(int i=1;i<n;i++){
        if(num[i]>ans[length-1]){
            ans[length++]=num[i];
        }else{
            *lower_bound(ans,ans+length,num[i])=num[i];
        }
    }
    cout<<length<<endl;
}



Measured memory_bytes: 3860
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")


S =sys.stdin.readline().rstrip()
print(S[:-8])


Measured memory_bytes: 13584
'use strict'
const Main = input => {
  input = input.split(' ')
  const createTime = Number(input[0]) // 1ターンあたりの製造時間
  const biscuitCount = Number(input[1]) // 1ターンあたりの製造枚数
  const totalTime =  Number(input[2]) + 0.5 // トータル製造時間
  let result = 0
  for (
    let nowTime = createTime; 
    nowTime < totalTime; 
    nowTime = nowTime + createTime) {
      result = result + biscuitCount
    }
  console.log(result)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8").trim())

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define per(i,n) for(int i = (n)-1; i >= 0; --i)
#define rng(i,a,b) for(int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
const int mod = 1e9+7;
struct mint {
    ll x;
    mint(ll x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (t == 0) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};
istream& operator>>(istream& i, mint& var) {
    ll tmp; i >> tmp;
    var.x = tmp;
    return i;
}
ostream& operator<<(ostream& o, const mint& var) {
    o << var.x;
    return o;
}
    
int main() {
    ll n, k; cin >> n >> k;
    mint ans(0);
    ll l = 0, r = 0;
    rep(i,n+2) {
        l += i;
        r += n-i;
        if (l > r) break;
        // cerr << l << ", " << r << endl;
        if (i >= k-1) ans += mint(r - l + 1);
    }
    // cerr << ans << endl;
    cout << ans << endl;
    return 0;
}


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

int main() {
    //freopen( "C:\\Users\\ehab\\Desktop\\problems\\in.txt" , "r" , stdin );

    string s;
    cin >> s;

    int lcounter = 0; bool flag = false;
    for ( int i = 0; i < s.length(); i++ ){
        if ( islower(s[i]) ) lcounter++;
        if ( i > 1 && i < s.length() - 1 && s[i] == 'C' )
            flag = true;
    }

    if ( s.front() == 'A' && flag == true && lcounter == s.length() - 2 )
        cout << "AC";
    else
        cout << "WA";
    return 0;
}

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

int main(void) {
    char c[2];
    for (int i = 0; i < 2; i++) {
        cin >> c[i];
        if (c[i] == '9') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>

int main(){
	int money;
	int dat[] = {500,100,50,10,5,1};

	while(1){
		scanf("%d",&money);
		if(money == 0)break;
		int fishing = 1000-money;
		int cnt = 0;
		
		for(int i=0;i<6;++i){
			if(fishing < 0)break;
			int tmp = fishing/dat[i];
			fishing -= tmp * dat[i];
			cnt += tmp;
		}

		printf("%d\n",cnt);
	}
	return 0;
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;
const int maxn = 8+5;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

int n;
int mem[maxn];
int p[maxn];
int q[maxn];

int check_p()
{
	for(int i = 0; i < n; i++)
	{
		if(mem[i] != p[i]) return 0;
	}
	return 1;
}

int check_q()
{
	for(int i = 0; i < n; i++)
	{
		if(mem[i] != q[i]) return 0;
	}
	return 1;
}

int main() 
{
	cin >> n;
	rep(i,n) cin >> p[i];
	rep(i,n) cin >> q[i];
	rep(i,n) mem[i] = i+1;
	int ans_p, ans_q;
	int cnt = 0;
    do 
    {
    	cnt++;
        if(check_p()) ans_p = cnt;
        if(check_q()) ans_q = cnt;
        //for (int i = 0; i < n; i++) {
        //     std::cout << mem[i] << " ";
        // }
        // std::cout << std::endl;
    }
    while (std::next_permutation(mem, mem+n));
    printf("%d\n", abs(ans_p-ans_q));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define endl "\n"
#define int ll
#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define all( x ) x.begin(), x.end()
#define fast ios::sync_with_stdio(0);cin.tie(0);

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef unsigned long long ull;

const int inf = 1e9 + 5;
const long double PI = 3.141592653589793;

void solve(){
  int n;
  cin>>n;
  int ans = 0;
  int k, j;
  for(int i=2;i*i<=n;i++){
    if(n%i==0){
      k = 0;
      while(n%i==0){
        n/=i;
        k++;
      }
      j = int(sqrt(1+8*k) + 0.1);
      j = (j-1)/2;
      ans+=j;
    }
  }
  if(n!=1){
    ans++;
  }
  cout<<ans<<endl;
}  
signed main(){
  fast;
  int t;
  //cin>>t;
  t = 1;
  while(t--){
    solve();
  }
}
/*
░░░░░░░░░░▄▄░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░██▀█▄░░▄██▀░░░░▄██▄░░░░░░░░░░░
░░░░░░░░██▄▄▄████████▄▄█▀░▀█░░░░░░░░░░░
░░░░░░░▄██████████████████▄█░░░░░░░░░░░
░░░░░░▄██████████████████████░░░░░░░░░░
░░░░░▄████████▀░▀█████████████░░░░░░░░░
░░░░░███████▀░░░░▀████████████▄░░░░░░░░
░░░░██████▀░░░░░░░░▀███████████▄▄▄▀▀▄░░
░▄▀▀████▀░░░▄▄░░░░░░░░░████████░░░░░█░░
█░░░▀█▀█░░░░▀▀░░░░░░██░░███░██▀░░░░▄▀░░
█░░░░▀██▄░░░▄░░░▀░░░▄░░░███░██▄▄▄▀▀░░░░
░▀▄▄▄▄███▄░░▀▄▄▄▀▄▄▄▀░░░███░█░░░░░░░░░░
░░░░░░████▄░░░░░░░░░░░░▄██░█░░░░░░░░▄▀▀
░░░░░░███▀▀█▀▄▄▄▄▄▄▄▄▄▀█████░░░░░░▄▀░░▄
░░░░░░█▀░░█░▀▄▄▄▄▄▄▄▄▄▀░███░█▀▀▀▄▀░░▄▀░
░░░░░░░░░▄▀░░░░░░░░░░░░░▀█▀░░█░░░░█▀░░░
░░░░░░░░░█░░░█░░░░░░░░░░░░░░░█░░░░░█░░░
░░░░░░░░░█▄▄█░▀▄░░█▄░░░░░░░░█░░▄█░░█░░░
░░░░░░░░░▀▄▄▀░░█▀▀█░▀▀▀▀█▀▀█▀▀▀▀█░█░░░░
hOi!!
I'm TemMie
*/

Measured memory_bytes: 3660
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define rank Rank
//#define MXN 300000
#define N 100005
int main(){
    int n;
    scanf("%d",&n);
    int a[100005];
    for(int i = 0;i<n;i++)
        scanf("%d",&a[i]);
    sort(a,a+n);
    reverse(a,a+n);
    a[n]=0;
    for(int i = 0;i<n;i++){
        if(a[i+1]-i-1<=0){
            int x=a[i]-i-1;
            int y=0;
            for(int j=i+1;j<n;j++){
                if(a[j]-i<=0)break;
                y++;
            }
          //  printf("%d %d %d\n",i,x,y);
            if((x&1)||(y&1)){
                printf("First\n");
            }
            else{
                printf("Second\n");
            }
            return 0;
        }
    }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int head[100001],to[200002],nxt[200002],tot=0;
long long f[100001][2];
void addedge(int u,int v)
{
	tot++;
	nxt[tot]=head[u];
	to[tot]=v;
	head[u]=tot;
}
long long dfs(int index,int u,int tmp)
{
	if(f[index][tmp]!=-1)
		return f[index][tmp];
	int i,v;
	f[index][tmp]=1;
	for(i=head[index];i;i=nxt[i])
	{
		v=to[i];
		if(v==u)
			continue;
		if(tmp==0)
			f[index][tmp]*=(dfs(v,index,0)+dfs(v,index,1));
		else
			f[index][tmp]*=dfs(v,index,0);
		f[index][tmp]%=1000000007;
	}
	return f[index][tmp];
}
int main()
{
	int i,j,n,x,y;
	scanf("%d",&n);
	for(i=1;i<n;i++)
	{
		scanf("%d %d",&x,&y);
		addedge(x,y);
		addedge(y,x);
	}
	for(i=0;i<=n;i++)
		f[i][0]=f[i][1]=-1;
	printf("%lld",(dfs(1,0,0)+dfs(1,0,1))%1000000007);
	return 0;
}

Measured memory_bytes: 12160
N,K=map(int,input().split())
x=list(map(int,input().split()))
ans=0
j=0
for i in range(N):
  if i==K-1:
    ans=min(abs(x[K-1]-x[0])+abs(x[K-1]),abs(x[K-1]-x[0])+abs(x[0]))
  elif i>=K:
    bns=min(abs(x[i]-x[i-K+1])+abs(x[i]),abs(x[i]-x[i-K+1])+abs(x[i-K+1]))
    ans=min(ans,bns)
print(ans)

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

using namespace std;

int main() {
  int N, sum = 0, p_max = 0;
  
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    int in;
    
    cin >> in;
    
    sum += in;
    
    p_max = max(p_max, in);
  }
  
  sum -= p_max / 2;
  
  cout << sum << endl;
  
  return 0;
}

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

int main(){
    int a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    if(x < y){
        swap(x,y);
        swap(a,b);
    }
    int ans = 0;
    if(a+b < 2*c) ans += (a+b)*y;
    else  ans += 2*c*y;
    int z = x-y;
    if(a < 2*c) ans += a*z;
    else ans += 2*c*z;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)

using namespace std;

void solve() {
	int n, k;
	cin >> n >> k;
	vi a(n);
	rep(i, 0, n) cin >> a[i];
	vi dp(k + 1);
	//dp[i] is 1 when first player wins if there are i stones

	rep(i, 0, k + 1) {
		rep(j, 0, n) {
			if(i >= a[j] && (!dp[i - a[j]])) {
				dp[i] = 1;
				break;
			}
		}
	}

	if(dp[k]) cout << "First" << endl;
	else
		cout << "Second" << endl;
	return;
}

int main() {
	int t = 1;
	//cin >> t;
	while(t--)
		solve();

	return 0;
}


Measured memory_bytes: 640
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
	int D, G;
	cin >> D >> G;
	G /= 100;
	vector<P> pc(D);
	rep(i, D) {
	    int p, c;
	    cin >> p >> c;
	    c /= 100;
	    pc[i] = P(p,c);
	}

	// bit全探索, 1 <= D <= 10
	ll ans = LLONG_MAX;

	rep(bit, (1<<D)){
	    ll tot = 0;
	    ll num = 0;
	    vector<bool> flag(D, false);
	    
	    rep(i, D) {
	        if(bit & (1<<i)){
	            // i 番目の問題を全完してコンプリートボーナスをもらう
	            // i 番目の問題の基本点 = (i+1) 点
	            tot += (i+1) * pc[i].fi + pc[i].se;
	            num += pc[i].fi;
	            flag[i] = true;
	        }
	    }
	    
	    bool pos = true;
	    while(tot < G && pos){
	        // 点数の高い問題から貪欲
	        // i = D-1 -> 0; 点数は D 点 -> 1 点
	        // flag[i] = true のときはスルー
	        // flag[i] = false のときは pc[i].fi-1 問まで解いて良い
	        rep3rev(i, D-1, 0){
	            if(flag[i]) continue;
	            if(tot + (i+1) * (pc[i].fi-1) < G){
	                tot += (i+1) * (pc[i].fi-1);
	                num += pc[i].fi-1;
	            }
	            else{
	                // (G-tot)/(i+1) を切り上げた問題数を解いて終了
	                int cnt = (G-tot+i)/(i+1);
	                tot += (i+1) * cnt;
	                num += cnt;
	                break;
	            }  
	            if(i == 0 && tot < G) pos = false;
	        }
	    }
	    
	    // cout << "bit = " << bit << ", num = " << num << ", tot = " << tot << endl;
	    if(pos) ans = min(ans, num);
	}
	
	cout << ans << endl;
	return;
}

int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#define LL long long 
#define INF 0X7FFFFFFF
using namespace std;
int N,C,K;
int f[100005]; 
int main()
{
	scanf("%d%d%d",&N,&C,&K);
	for(int i=1;i<=N;i++)
		scanf("%d",&f[i]);
	sort(f+1,f+N+1);
	int cnt=0;int pre=f[1];
	int ans=0;
	for(int i=1;i<=N;i++)
	{
		cnt++;
		int l=f[i]-pre;
		if(l>K)
		{
			cnt=1;pre=f[i];
			ans++;continue;
		}
		if(cnt==C)
		{
			cnt=0;pre=f[i+1];
			ans++;continue;
		}
	}
	if(cnt!=0) ans++;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#include <iomanip>
#include <queue>
#include <stack>

using namespace std;

typedef long long ll;

int main() {
    string s, t;    cin >> s >> t;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] != t[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3628
a, b, c, x = [int(input()) for _ in range(4)]
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500 * i + 100 * j + 50 * k == x:
                ans += 1
print(ans)

Measured memory_bytes: 2940
//
//  B - Card Game for Two.cpp
//  AtCoder Beginner Contest 088
//
//  Created by Huang,Zhiqiang on 2018/2/18.
//  Copyright © 2018年 Huang,Zhiqiang. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

bool cmp(const int& a, const int& b) {
    return a > b;
}

int main() {
    int N;
    cin >> N;
    vector<int> nums(N, 0);
    for (int i = 0; i < N; i++) {
        cin >> nums[i];
    }
    sort(nums.begin(), nums.end(), cmp);
    int sum1 = 0, sum2 = 0;
    for (int i = 0; i < N; i++) {
        if (i % 2 == 0) {
            sum1 += nums[i];
        } else {
            sum2 += nums[i];
        }
    }
    cout << sum1 - sum2 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <set>

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
typedef long long ll;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    rep(i,n) {
        cin >> p[i];
    }

    ll ans = 0;
    sort(p.begin(), p.end());

    rep(i, k) {
        ans += p[i];
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3592
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] NAB = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            List<long> list = new List<long>();
            for(int j = 1; j <= NAB[0]; j++)
            {
                long len = j.ToString().Length;
                string num = j.ToString();
                long sum = 0;
                for(int z = 0; z < len; z++)
                {
                    sum += int.Parse(num.Substring(z, 1));
                }
                if (NAB[1] <= sum && sum <= NAB[2])
                {
                    list.Add(j);
                }
            }
            Console.WriteLine(list.Sum());
        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();


//Console.WriteLine(ans);


Measured memory_bytes: 29940
fn main() {
    let v = read_vec::<u32>();
    let x = v[0];
    let y = v[1];
    let z = v[2];
    let w = (x - z) / (y + z);
    println!("{}", w);
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

int main()
{
    int n, k, l[50];
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> l[i];
    }

    int hako;

    for (int j = 0; j < n; j++) {
        for (int u = j + 1; u < n; u++) {
            if (l[j] < l[u]) {
                hako = l[j];
                l[j] = l[u];
                l[u] = hako;
            }
        }
    }

    int sum = 0;

    for (int y = 0; y < k; y++) {
        sum += l[y];
    }

    cout << sum << endl;

    return 0;
}

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

int main() {
  LL n;
  cin >> n;
  /*vector<LL> a(n+2), b(n), c(n+2);
  for (int i = 1; i <= n; i ++) cin >> a.at(i);
  for (int i = 0; i < n; i ++)  cin >> b.at(i);
  for (int i = 1; i <= n; i ++) cin >> c.at(i);
  a[n+1] = 1000000001, c[n+1] = 1000000001;
  sort(a.begin(), a.end());
  sort(c.begin(), c.end());

  LL ans = 0, top, bottom;
  LL left, right, mid;
  for (int i = 0; i < n; i ++) {
    top = 0, left = 1, right = n+2;
    while (left < right) {
      mid = (left + right) / 2;
      if (a[mid] < b[i] && b[i] <= a[mid+1]) {
        top = mid;
        break;
      }
      if (a[mid] <= b[i]) left = mid + 1;
      else right = mid;
    }

    bottom = 0, left = 0, right = n+1;
    while (left < right) {
      mid = (left + right) / 2;
      if (c[mid] <= b[i] && b[i] < c[mid+1]) {
        bottom = n - mid;
        break;
      }
      if (c[mid] <= b[i]) left = mid + 1;
      else right = mid;
    }

    ans += top * bottom;
  }*/

  vector<LL> a(n), b(n), c(n);
  for (int i = 0; i < n; i ++) cin >> a[i];
  for (int i = 0; i < n; i ++) cin >> b[i];
  for (int i = 0; i < n; i ++) cin >> c[i];
  sort(a.begin(), a.end());
  sort(c.begin(), c.end());

  LL ans = 0, x, y;
  for (int i = 0; i < n; i ++) {
    x = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
    y = c.end() - upper_bound(c.begin(), c.end(), b[i]);
    ans += x * y;
  }

  cout << ans << endl;
}


Measured memory_bytes: 2560
import java.util.*;


public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        List<Long> list = new ArrayList<Long>();
        for (int i = 0; i < 9; i++) {
            list.add(sc.nextLong());
        }

        for (int a1 = 0; a1 <= list.get(0); a1++) {
            List<Long> list2 = new ArrayList<Long>();
            long b1 = list.get(0) - a1;
            long b2 = list.get(1) - a1;
            long b3 = list.get(2) - a1;
            long a2 = list.get(4) - b2;
            long a3 = list.get(8) - b3;

            list2.add(a1 + b1);
            list2.add(a1 + b2);
            list2.add(a1 + b3);
            list2.add(a2 + b1);
            list2.add(a2 + b2);
            list2.add(a2 + b3);
            list2.add(a3 + b1);
            list2.add(a3 + b2);
            list2.add(a3 + b3);

            boolean flag = true;
            for (int i = 0; i < 9; i++) {
                if(list.get(i) < 0 || list2.get(i) < 0){
                    flag = false;
                    break;
                }
                if(! list.get(i).equals(list2.get(i))){
                    flag = false;
                    break;
                }
            }

            if(flag){
                System.out.println("Yes");
                return;
            }
        }

        System.out.println("No");
        return;
    }
}


Measured memory_bytes: 22100
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  int n,k;
  cin >> n >> k;
  int tmp;
  vector<int>v;
  map<int,int>m;
  rep(i,n){
    cin >> tmp;
    m[tmp]++;
  }
  for(auto kk : m){
    v.push_back(kk.second);
  }
  sort(v.begin(),v.end());
  int ans = 0;
  int now = v.size();
  int l = 0;
  while(k < now){
    ans += v[l];
    now--;
    l++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 10748
#include <bits/stdc++.h>
using namespace std;
#define int lint
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};

int x[110],y[110],h[110];

signed main(){
  int N,M;cin>>N>>M;
  int max=M/N;

  int ans;
  for(int t=max;1<=t;t--){
    if(M%t==0){
      ans=t;
      break;
    }
  }

  cout<<ans<<"\n";
}


Measured memory_bytes: 256
# coding: utf-8
import queue
n,m,s,t=map(int,input().split())
table=[[] for i in range(n)]
inf=300001
dist_s=[inf for i in range(n)]
dist_t=[inf for i in range(n)]
s_list=[0 for i in range(inf+1)]
t_list=[0 for i in range(inf+1)]
s-=1;t-=1
for i in range(m):
    a,b=map(int,input().split())
    a-=1;b-=1
    table[a].append(b)
    table[b].append(a)
dist_s[s]=0
q=queue.Queue()
q.put(s)
while not q.empty():
    p=q.get()
    for e in table[p]:
        if dist_s[e]>dist_s[p]+1:
            dist_s[e]=dist_s[p]+1
            q.put(e)
dist_t[t]=0
q=queue.Queue()
q.put(t)
while not q.empty():
    p=q.get()
    for e in table[p]:
        if dist_t[e]>dist_t[p]+1:
            dist_t[e]=dist_t[p]+1
            q.put(e)
for i in range(n):
    s_list[dist_s[i]]+=1
    t_list[dist_t[i]]+=1
mindist=dist_s[t]
ans=0
for i in range(mindist-1):
    ans+=s_list[i]*t_list[(mindist-2)-i]
print(ans)





Measured memory_bytes: 38168
import java.util.*;

public class Main {

	public static int solve(String s) {
		int ans = 0;
		int n = s.length();
		for(int i = 0; i < n / 2; ++i){
			char f = s.charAt(i);
			char g = s.charAt(n - i - 1);
			if(f != g)ans++;
		}
		return ans;
	}
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int ans = solve(s);
		sc.close();

		System.out.println(ans);
	}
}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
#define speedup ios_base::sync_with_stdio(false)

using namespace std;

double cnt, a, b, t;

int main()
{
    speedup;
    cin >> a >> b >> t;
    t += 0.5;
    while (t >= a) {
        t -= a;
        cnt += b;
    }
    cout << cnt;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stack>
#include <math.h>
 
using namespace std;
 
 
int main(){
 
    int n,checkTable[6];
 
    double height;
    scanf("%d",&n);
 
    for(int i=0; i < 6; i++)checkTable[i] = 0;
 
    for(int i=0; i < n; i++){
        scanf("%lf",&height);
 
        if(height >= 185){
            checkTable[5]++;
        }else if(height >= 180){
            checkTable[4]++;
        }else if(height >= 175){
            checkTable[3]++;
        }else if(height >= 170){
            checkTable[2]++;
        }else if(height >= 165){
            checkTable[1]++;
        }else{
            checkTable[0]++;
        }
    }
 
    for(int i=0; i < 6; i++){
        printf("%d:",i+1);
        for(int k=0; k < checkTable[i]; k++){
            printf("*");
        }
        printf("\n");
    }
 
    return 0;
}


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

int main()
{
    ll n,ans=0;
    cin>>n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++)
    {
        cin>>a[i];
    }
    multiset<ll> ms;
    for (int i = 0; i < n; i++)
    {
        auto it = ms.lower_bound(a[i]);
        if(it==ms.begin())
        {
            ms.insert(a[i]);
        }
        else
        {
            it--;
            ms.erase(it);
            ms.insert(a[i]);
        }
    }
    cout<<ms.size()<<endl;
    
    return 0;
}

Measured memory_bytes: 5760
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        List<Integer> kuku = new ArrayList<>();
        for(int i = 1;i<=9;i++){
            for(int j = 1;j<=9;j++){
                kuku.add(i*j);
            }
        }
        if(kuku.contains(n)){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }        
    }
}

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

int main(){
    int n,s1=0,s2=0,m,m0;
    cin>>n;
    vector<int> v(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
        s2+=v[i];
    }
    m=s2;
    for(int i=0;i<n-1;i++){
        s1+=v[i];
        s2-=v[i];
        m0=fabs(s1-s2);
        m=min(m,m0);
    }
    cout<<m<<endl;
    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
x = gets.chomp
xs = x.to_i(2)
xc = x.count('1')
def mpow(n, p, mod)
  return 0 if mod.zero?
  r = 1
  while p > 0
    r = r * n % mod if p & 1 == 1
    n = n * n % mod
    p >>= 1
  end
  r
end
@h = {0=>0, 1=>1, 2=>1}
def popcount(u)
  return @h[u] if @h[u]
  a = u % u.to_s(2).count('1')
  @h[u] = 1 + popcount(a)
end
xsp = xs % (xc + 1)
if xc == 1
  xsm = 0
else
  xsm = xs % (xc - 1)
end
n.times do |i|
  if x[i] == '0'
    y = xsp + mpow(2, n - i - 1, xc + 1)
    y = mpow(y, 1, xc + 1)
  elsif xc == 1
    puts '0'
    next
  else
    y = xsm - mpow(2, n - i - 1, xc - 1)
    y += xc - 1 if y < 0
    y = mpow(y, 1, xc - 1)
  end
  puts popcount(y) + 1
end

Measured memory_bytes: 15880
#include <bits/stdc++.h>
using namespace std;
#define ll long long
bool is_square(int n)
{
    for (int i = 0; i <= n; i++)
    {
        if (i * i == n)
        {
            return true;
        }
    }
    return false;
}

int main()
{
    ll n, a, b;
    cin >> n >> a >> b;
    if ((b - a) % 2 == 0)
    {
        cout << (b - a) / 2 << endl;
    }
    else
    {
        cout << min(a + (b - a - 1) / 2, n - b + 1 + (b - a - 1) / 2) << endl;
    }

    return 0;
}

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

int main(void){
    long a, b, c;
    cin >> a >> b >> c;
    long d = c-(a+b+1);
    if(d<=0){
        cout << b+c << endl;
    }else{
        cout << b+c-d <<  endl;
    }
    return 0;
}


Measured memory_bytes: 256
s = [i for i in input()]
len_s = len(s)

def reverse(s):
  rev = [j for j in s[::-1]]
  return rev

if s == reverse(s):
  if reverse(s[:(len_s - 1)//2]) == s[:(len_s - 1)//2] and reverse(s[(len_s + 3)//2 - 1:]) == s[(len_s + 3)//2 - 1:]:
    print("Yes")
  else:
    print("No")
else:
  print("No")

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

void Main()
{
    int t;
    cin >> t;
    for (int i = 0; i < t; i++)
    {
        int n, m, a, b;
        cin >> n >> m >> a >> b;
        cout << atcoder::floor_sum(n, m, a, b) << endl;
    }
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


Measured memory_bytes: 3708
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <limits>
#include <type_traits>

using namespace std;
int main()
{
    int s, w;
    cin >> s >> w;
    if (s > w) {
        cout << "safe" << endl;
    } else {
        cout << "unsafe" << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
import random
class Dice:
    def __init__(self,surfaceNum):
        self.surface = surfaceNum
        
    def east(self):
        self.surface[0], self.surface[2], self.surface[5], self.surface[3] = self.surface[3], self.surface[0], self.surface[2], self.surface[5]
    def west(self):
        self.surface[0], self.surface[2], self.surface[5], self.surface[3] = self.surface[2], self.surface[5], self.surface[3], self.surface[0]
    def south(self):
        self.surface[0], self.surface[1], self.surface[5], self.surface[4] = self.surface[4], self.surface[0], self.surface[1], self.surface[5]
    def north(self):
        self.surface[0], self.surface[1], self.surface[5], self.surface[4] = self.surface[1], self.surface[5], self.surface[4], self.surface[0]
        
    def printTopSurface(self):
        print(self.surface[0])  
    def printRight(self):
        print(self.surface[2])

diceNum = int(input())
rollCommandList = ["E", "W", "S", "N"]
counter = 1
answer = [0]
surfaceNum = list()
dice = list()
for i in range(diceNum):
    surfaceNum = [int(i) for i in input().split()]
    dice.append(Dice(surfaceNum))
for i in range(diceNum-1):
    for j in range(i+1,diceNum):
        counter = 0
        while True:    
            rollCommand = random.choice(rollCommandList)
            if rollCommand == "E":
                dice[j].east()
            if rollCommand == "W":
                dice[j].west()
            if rollCommand == "S":
                dice[j].south()
            if rollCommand == "N":
                dice[j].north()
            if counter == 100:
                answer.append('Yes')
                #print('{}, {}'.format(i, j))
                break        
            if dice[i].surface == dice[j].surface:
                answer.append('No')
                #print('{}, {}'.format(i, j))
                break
            counter += 1
if answer.count('No') > 0:
    print('No')
else:
    print('Yes')



Measured memory_bytes: 8268
#!/usr/bin/env python3
import sys

YES = "YES"  # type: str
NO = "NO"  # type: str


def solve(X: int):
    print(YES) if(X in (3,5,7)) else print(NO)
    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <utility>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define fore(i, init, n) for(int i = init; i < n; i++)
#define FIN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int MAXN = 1e3+5, MOD = 1e9+7;

long long dp[MAXN][MAXN], h, w;
string grid[MAXN];

int main() {
    FIN;
    cin >> h >> w;
    fore(i, 0, h) cin >> grid[i];
    
    fore(i,0,h) fore(j,0, w) dp[i][j] = 0;
    
    fore(i,0,h) {
        if (grid[i][0] == '#') break;
        else dp[i][0] = 1;
    }
    fore(j,0,w) {
        if (grid[0][j] == '#') break;
        else dp[0][j] = 1;
    }
    
    fore(i,1,h) {
        fore(j,1, w) {
            dp[i][j] = ((grid[i-1][j] != '#'? dp[i-1][j] : 0) + (grid[i][j-1] != '#'? dp[i][j-1] : 0))%MOD;
        }   
    } 
    cout << dp[h-1][w-1] << endl;

}


Measured memory_bytes: 9216
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private int N;
    private int A;
    private int B;
    private int[] h;

    private void solve(Scanner sc) {
        N = sc.nextInt();
        A = sc.nextInt();
        B = sc.nextInt();
        h = new int[N];
        for (int i = 0; i < N; ++i) {
            h[i] = sc.nextInt();
        }

        int max = Arrays.stream(h).max().getAsInt();

        int left = 0;
        int right = 1_000_000_000;
        int ans = (int)Math.ceil(1d * max / B);
        while (left < right) {
            int c = (left + right) / 2;
            if (enough(c)) {
                right = c;
                ans = c;
            } else {
                left = c + 1;
            }
        }

        _out.println(ans);
    }
    private boolean enough(int t) {
        int total = 0;
        for (int i = 0; i < N; ++i) {
            if (h[i] > (long)B * t) {
                total += Math.ceil(((double)h[i] - B * t) / (A - B));
            }
        }
        return total <= t;
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 53688
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int n=s.length();
    int ans=0;
    for(int i=0;i<n/2;i++)
    {
        if(s[i]!=s[n-i-1])
        {
            ans++;
            
        }
        
    }
    cout<<ans<<"\n";
}

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

int main()
{
    int H, N;
    cin >> H >> N;

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

    const int init = 1e8;
    vector<vector<int>> dp(N + 1, vector<int>(H + 1, init));
    dp[0][0] = 0;
    for (int i = 1; i <= N; i++)
    {
        for (int j = 0; j - A[i] <= H; j++)
        {
            if (j <= H)
            {
                dp[i][j] = min(dp[i][j], dp[i - 1][j]);
            }
            if (j - A[i] >= 0)
            {
                dp[i][min(H, j)] = min(dp[i][min(H, j)], dp[i][j - A[i]] + B[i]);
            }
        }
    }
    cout << dp[N][H] << endl;
}


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

int main(void){
    long n;
    cin >> n;
    vector<long> a(n+1);
    a[0] = -1;
    for(long i=1; i<=n; i++){
        cin >> a[i];
    }
    long count=-1;
    for(long i=n; i>=1; i--){
        long d = a[i]-a[i-1];
        if(d>=2){
            cout << -1 << endl;
            return 0;
        }else if(d<0){
            count += a[i];
        }else if(d==1){
            count++;
        }else{
            count += a[i];
        }
    }
    cout << count << endl;
    return 0;
}


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

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

using namespace std;

int gcd(int a,int b){ return b?gcd(b,a%b):a; }

int main(){
	int a,b,c; cin>>a>>b>>c;
	cout<<(c%gcd(a,b)==0?"YES":"NO")<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        int n = Integer.parseInt(line);
        String linex = sc.nextLine();
        String liney = sc.nextLine();
        String[] linexsp = linex.split(" ");
        String[] lineysp = liney.split(" ");
        int[] x = new int[n];
        int[] y = new int[n];
        double sum1 = 0;
        double sum2 = 0;
        double sum3 = 0;
        double max = 0;
        for(int i = 0; i < n; i++) {
            x[i] = Integer.parseInt(linexsp[i]);
            y[i] = Integer.parseInt(lineysp[i]);
            double dif = x[i] - y[i];
            if(dif < 0) {
                dif = -dif;
            }
            if(i == 0) {
                max = dif;  
            }
            if(max < dif) {
                max = dif;
            }
            sum1 += dif;
            sum2 += Math.pow(dif, 2);
            sum3 += Math.pow(dif, 3);
        }
        System.out.println(sum1);
        System.out.println(Math.sqrt(sum2));
        System.out.println(Math.cbrt(sum3));
        System.out.println(max);
        
    }
 }


Measured memory_bytes: 26480
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);


ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b){
  ll r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return b;
}


ll LCM(ll a,ll b){
  ll c=a,d=b,r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return c/b*d;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

vector<pair<char,ll>> runlength(string s,vector<pair<char,ll>> p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
    return p;
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
  return p;
}



/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  ll n;
  cin>>n;
  vector<ll> v(n),dp;
  rep(i,n) cin>>v[i];
  dp.push_back(0);
  dp.push_back(abs(v[1]-v[0]));
  for(ll i=0;i<n-2;i++){
    dp.push_back(min(dp[i]+abs(v[i]-v[i+2]),dp[i+1]+abs(v[i+1]-v[i+2])));
  }
  cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 2168
#include <algorithm>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;

using namespace std;

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

  string A = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  vector<char> vec;
  rep(i, A.length()) { vec.push_back(A[i]); }

  vector<char> ans(s.length());

  rep(i, s.length()) {
    char c = s[i];
    auto it = lower_bound(vec.begin(), vec.end(), c);
    int index = it - vec.begin();
    int newIndex = (index + n) % vec.size();
    ans[i] = vec[newIndex];
  }

  rep(i, ans.size()) { cout << ans[i]; }
  cout << endl;
}


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

#define rep(i, n) for(int i = 0; i < n; i ++)
#define ALL(T) T.begin(), T.end()
#define mp make_pair
#define pb push_back

using namespace std;

typedef pair<int, int> pii;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;
const int N = (int)1e6 + 1;

int main(void){
    for(int e, res; res = INF, cin >> e, e; cout << res << endl)
        for(int z = 0; z * z * z < N; z ++)
            for(int y = 0; y * y < N; y ++)
                if(y * y + z * z * z <= e)
                    res = min(res, y + z + e - y * y - z * z * z);

    return 0;
}

Measured memory_bytes: 1164
#include <cstdio>
#include <cstdlib>
#include <cstring>
struct Node{
	int x;
	int y;
	int type;
	int S;
	Node *next, *prev;
};


Node *nil;

Node *listSearch(int key_y, int type) {
	Node *cur = nil->prev;
	while (cur != nil && ((cur->y != key_y || cur->type != type))){
		cur = cur->prev;
	}
	return cur;
}

int puddleCount(){
	Node *cur = nil->prev->prev;
	int count=0;
	bool puddle_flag = false;
	nil->prev->y ++;

	while (cur != nil && cur->y != 0){
		cur->y += 1;
		cur = cur->prev;
	}
	cur = cur->next->next;
	while (cur != nil){
		if (cur->y ==-1){
			puddle_flag = true;
		}
		if (puddle_flag && cur->y==0){
			count +=1;
			puddle_flag = false;
		}
		cur = cur->next;
	}
	return count;
}

void init(){
	nil = (Node *)malloc(sizeof(Node));
	nil->next = nil;
	nil->prev = nil;
	nil->x = -1;
	nil->y = 0;
	nil->type=0;
	nil->S = 0;
}

void insert(int x, int y, int type, int S){
	Node *n  = (Node *)malloc(sizeof(Node));
	n->x = x;
	n->y = y;
	n->type = type;
	n->S = S;
	n->prev = nil->prev;
	n->next = nil;
	nil->prev->next = n;
	nil->prev = n;

}

int main(){
	char str[20000];
	int i, k, S, y;
	bool puddle_flag = false;
	Node *puddle_end, *cur;
	scanf("%s", str);
	i=k=S=0;
	init();
	
	while(str[i]!='\0'){
		if(str[i]=='\\'){
			y = nil->prev->y;
			insert(i, y-1, -1, S);
			if(!puddle_flag) puddle_flag=true;
		}
		if(puddle_flag && str[i]=='/'){
			y = nil->prev->y;
			S += i-listSearch(y, -1)->x;
			insert(i, y+1, 1, S);
			if(nil->prev->y == 0){
				k++;
				puddle_flag = false;
			}
		}
		i++;
	}

	puddle_end = nil->prev;
	while(puddle_end->type != 1 && puddle_end != nil){
		puddle_end = puddle_end->prev;
	}
	nil->prev = puddle_end;
	puddle_end->next = nil;
	while(nil->prev->y!=0){
		k += puddleCount();
	}
	printf("%d\n", S);
	printf("%d", k);
	
	cur = nil->next->next;
	S=0;
	for(i=0;i<k;i++){
		while(cur->y != 0 || cur->type != 1){
			cur = cur->next;
		}
		printf(" %d",cur->S - S);
		S = cur->S;
		cur = cur->next;
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define REP(i, init, n) for(int i = (int)(init); i < (int)(n); i++)

int main() {
    int N;
    cin>>N;
    vector<vector<int>> G(N);
    int cnt = 0;
    if(N%2 == 0){
        REP(i, 1, N+1) REP(j, i, N+1){
            if(i == j) continue;
            if(i+j != N+1){
                G[i-1].emplace_back(j);
                cnt++;
            }
        }
    }
    if(N%2 == 1){
        REP(i, 1, N+1) REP(j, i, N+1){
            if(i == j) continue;
            if(i+j != N){
                G[i-1].emplace_back(j);
                cnt++;
            }
        }
    }

    cout << cnt << endl;
    REP(i, 0, N) {
        REP(j, 0, G[i].size()){
            cout << i+1 << " " << G[i][j] << endl;
        }
    }
}

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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define ALL(x) (x).begin(),(x).end()
template<typename T> bool chmax(T& a,const T& b){return a < b ? (a = b,true) : false;}
template<typename T> bool chmin(T& a,const T& b){return b < a ? (a = b,true) : false;}
typedef long long ll;

ll N,X;

int main()
{
	scanf("%lld%lld",&N,&X);

	vector<ll> A(N);
	FOR(i,0,N){
		scanf("%lld",&A [i]);
	}

	ll ans = 0;
	FOR(i,1,N){
		if(A [i] + A [i - 1] > X){
			ans += A [i] - max(0ll,X - A [i - 1]);
			A [i] = max(0ll,X - A [i - 1]);
			if(A [i] + A [i - 1] > X){
				ans += A [i - 1] - max(0ll,X - A [i]);
				A [i - 1] = max(0ll,X - A [i]);
			}
		}
	}

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

	return 0;
}


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

int main(){
  int A,B;
  cin >> A>>B;
  int count=0;
  for(int i=A;i<=B;i++){
    int fifth=i/10000;
    int fourth=(i/1000)%10;
    if( (i-(fourth*10+fifth))%100==0){
      //debug
      //cout << "[palindromic] " << i <<endl;
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256