akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
 
bool codejam = 0;
 
typedef long long li;
typedef long double ld;
 
void solve();

int32_t main () {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(20);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	int t = 1; 
	// cin >> t;
	int tt = t;
	while (t--) { 
		if (codejam) cout << "Case #" << tt - t << ": ";
		solve();
	}
	return 0;
}

void solve() {
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; ++i) {
		string lol = to_string(i);
		if ((int)lol.size() & 1) ans += 1;
	}	
	cout << ans;
}	


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast                                                                   \
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define ll long long
#define f(i, n) for (int i = 0; i < n; i++)
#define ff(i, n) for (int i = 1; i <= n; i++)
#define F first
#define S second
#define vpii vector<pair<int,int> >
#define sz size()
#define all(v) v.begin(),v.end()
#define pb push_back   
#define PB pop_back
#define vl vector<int>
#define mp make_pair
#define mod 1000000007
typedef unsigned long long ull;
const int N = 200005;
const int MOD = 998244353 ;

void solve(){
    string s, t;
    cin>>s>>t;
    int ans = 0;
    f(i,s.length())if(s[i]!=t[i])ans++;
    cout<<ans;
}

int32_t main() {
    fast
    int t;
    t = 1;
    //cin >> t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 3796
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int h[N],dp[N];
int read()
{
	int x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9') {if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9') x=(x<<1)+(x<<3)+(ch&15),ch=getchar();
	return x*f;
}
int main()
{
	int n=read(),K=read();
	for (register int i=1;i<=n;++i) h[i]=read();
	dp[1]=0;
	for (register int i=2;i<=n;++i)
	{
		dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
		for (register int j=max(i-K,1);j<=i-2;++j) dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));
	}
	printf("%d\n",dp[n]);
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <queue>

#define pb push_back
     
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
     
bool debug = false;
     

struct state
{
    ll a,b,c;

    state(ll a, ll b, ll c) : a(a), b(b), c(c)
    {

    }

  bool operator==(const state &other) const
  { return (a == other.a
            && b == other.b
            && c == other.c);
  }
};


struct KeyHasher
{
    size_t operator()(const state& k) const
  {
    //using std::size_t;
    //using std::hash;
    //using std::string;

    return ((hash<ll>()(k.a)
               ^ (hash<ll>()(k.b) << 1)) >> 1)
               ^ (hash<ll>()(k.c) << 1);
  }
};  


void solve(ll casen)
{
    ll res = 0;
    
    cout << "Case #" << casen << ": " << res << endl;
}

ll findN(ll x)
{
    ll q = 1;

    while ( (q*(1+q))/2 <= x ) q++;
    q--;
    return q;
}

int main()
{
    // $ g++ -std=c++14 -Wshadow -Wall -o c C.cpp

    // !!! Here, unordered map was too slow!!!
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    
   ll n;
   cin >> n;

   if (n == 0) 
    {
        cout << 0 << endl;
        return 0;
    }

    ll res = 0;

    ll tmpRes = 0;
    while (n % 2 == 0)
    {
        tmpRes++;
        n /= 2;
    }

    res += findN(tmpRes);

    for (ll i = 3; i*i <= n; i += 2)
    {
        ll tmpRes = 0;
        while (n % i == 0)
        {
            tmpRes++;
            n /= i;
        }

        res += findN(tmpRes);
    }

    if (n > 2) res++;



    cout << res << endl;



  

    return 0;
}

Measured memory_bytes: 3692
n, d = input().split(' ')
n = int(n)
d = int(d)
res = 0
while n > 0 :
    x, y = input().split(' ')
    x = int(x)
    y = int(y)
    if (((x**2)+(y**2))**0.5) <= d:
        res += 1
    n -= 1
print(res)

Measured memory_bytes: 9540
#include <bits/stdc++.h>
using namespace std;
const int maxs = 1e9;
int main()
{
	int n, k, s;
	cin >> n >> k >> s;
	if(s == maxs)
	{
		for(int i = 1; i <= k; ++i) cout << s << ' ';
		for(int i = k + 1; i <= n; ++i) cout << 1 << ' ';
	}
	else
	{
		for(int i = 1; i <= k; ++i) cout << s << ' ';
		for(int i = k + 1; i <= n; ++i) cout << s + 1 << ' ';
	}
	return 0;
}

Measured memory_bytes: 1280
#include <stdio.h>
#include <iostream>
#include <string>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <memory.h>
#include <math.h>
#include <queue>
#include <map>
#include <stack>
#include <bitset>

#define INFI 0x7fffffff
#define MAXN 100010

using namespace std;

int dist[30]={0,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1};

string buf;
    int k;
string ans;
int len;
int main()
{
    cin>>buf>>k;
    ans=buf;
    len=buf.size();
    for(int i=0;i<len;++i)
    {
        if(dist[buf[i]-'a']<=k)
        {
            k-=dist[buf[i]-'a'];
            buf[i]='a';
        }
    }
    if(k>0) buf[len-1]=(buf[len-1]-'a'+k)%26+'a';
    printf("%s\n",buf.c_str());
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#define rep(i,n) for(int i=0;i<(n);++i)


using namespace std;

int main(){
	char ans;
	cin>>ans;
	if(isupper(ans))cout<<"A"<<endl;
	else    cout<<"a"<<endl;
  

return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
# define fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl "\n"
#define all(v) v.begin(),v.end()
#define mod 1000000007 ;
typedef long long ll;

void IO()
{
	#ifndef ONLINE_JUDGE
			freopen("input.txt","r",stdin);
			freopen("output.txt","w",stdout);
	#endif 
}
vector<bool> used(200000);
vector<int> adj[200000];
vector<int> a,b;
void bfs(int i)
{	
queue<int> q;
	q.push(i);
	used[i] = 1;
	a.push_back(i);
	while(!q.empty())
	{	i = q.front();
		q.pop();
		for(auto vertex:adj[i])
		{	
			if(used[vertex]==-1)
			{
				used[vertex] = used[i]^1;
				if(used[vertex]==1) a.push_back(vertex);
				else b.push_back(vertex);
				q.push(vertex);
			}
			if(used[vertex]==used[i]){
				cout<<-1;
				exit(0);
			}
	
			}


	}
}
int dp[4000][4000];
// string ans = "";
// int LCS(string x,string y,int n,int m)
// {
// if(n==0 | m==0) return dp[n][m] = 0;
// if(dp[n][m]!=-1) return dp[n][m];
 
// if(x[n-1] == y[m-1] )
// 	return dp[n][m] = 1 + LCS(x,y,n-1,m-1);
// return dp[n][m] = max(LCS(x,y,n-1,m),LCS(x,y,n,m-1));

// }
void solve()
{

string x,y;
cin>>x>>y;
int n = x.size(), m = y.size();
// memset(dp,-1,sizeof(dp));	
for(int i = 0;i<=m;i++)
dp[0][i] = 0 ;
for(int i = 0;i<=n;i++)
	dp[i][0] = 0 ;
for(int i = 1;i<=n;i++)
for(int j = 1;j<=m;j++)
{
	
    if(x[i-1] == y[j-1])
		dp[i][j] = dp[i-1][j-1] + 1;
	else dp[i][j] = max(dp[i-1][j] , dp[i][j-1]);
	
}
string ans = "";
int i = n,j = m;	 
while(i>0 & j>0){
if(x[i-1] == y[j-1])
{
	ans = x[i-1] + ans;
	i--;j--;
}
else {
	if(dp[i-1][j] >= dp[i][j-1])
		i--;
	else j--;
}

}

cout<<ans<<endl;

}
int main()
{
	IO();
	fast;
	// int t;cin>>t;while(t--)
	
	solve();	

		

	return 0;
}





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

int main() {
  int h, w;
  std::cin >> h >> w;
  std::vector<std::string> vec(h, "");
  for (int m = 0; m < h; m++) {
    std::cin >> vec.at(m);
  }
  
  int i, j, sum;
  for (int n = 0; n < h * w; n++) {
    sum = 0;
    i = n / w;
    j = n % w;

    if (vec.at(i).at(j) == '.') {
      if (i > 0 && j > 0 && vec.at(i-1).at(j-1) == '#') {
        sum += 1;
      }
      if (i > 0 && vec.at(i-1).at(j) == '#') {
        sum += 1;
      }
      if (i > 0 && j < w-1 && vec.at(i-1).at(j+1) == '#') {
        sum += 1;
      }
      if (j > 0 && vec.at(i).at(j-1) == '#') {
        sum += 1;
      }
      if (vec.at(i).at(j) == '#') {
        sum += 1;
      }
      if (j < w-1 && vec.at(i).at(j+1) == '#') {
        sum += 1;
      }
      if (i < h-1 && j > 0 && vec.at(i+1).at(j-1) == '#') {
        sum += 1;
      }
      if (i < h-1 && vec.at(i+1).at(j) == '#') {
        sum += 1;
      }
      if (i < h-1 && j < w-1 && vec.at(i+1).at(j+1) == '#') {
        sum += 1;
      }
      std::cout << sum;
    } else {
      std::cout << '#';
    }
    if (j == w-1) {
      std::cout << '\n';
    }
  }
}


Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
from decimal import Decimal
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,q = inpl()
s = input()
a = [0]*(n+1)
for i in range(1,n):
    if s[i-1] == 'A' and s[i] == 'C':
        a[i+1] = a[i] + 1
    else:
        a[i+1] = a[i]
# print(a)
for _ in range(q):
    x,y = inpl()
    print(a[y] - a[x])

Measured memory_bytes: 79828
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;

int main(void)
{
	int n, i, temp;
	scanf("%d", &n);
	temp = 7;
	for (i = 1; i <= 1000000; i++)
	{
		if (temp % n == 0)
			break;
		temp = (temp * 10 + 7) % n;
	}
	if (i > 1000000)
		printf("-1\n");
	else
		printf("%d\n", i);
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<ll> H(N);
  for(int i = 0; i < N; i++) {
    cin >> H.at(i);
  }
  for(int i = N - 1; i > 0; i--) {
    if(H.at(i) < H.at(i - 1)) {
      H.at(i - 1)--;
      if(H.at(i) < H.at(i - 1)) {
        cout << "No" << endl;
        return 0;
      } else if(H.at(i - 1) < 0) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;    
}

Measured memory_bytes: 1024
import java.util.*;
public class Main{
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] list1 = makeList();
		int[] dp1 = new int[1000000];
		int[] dp2 = new int[1000000]; 

		Arrays.fill(dp1, 2 << 27);
		Arrays.fill(dp2, 2 << 27);

		dp1[0] = dp2[0] =  0;

		for(int i = 0; i < 180; i++) {
			int tmp = list1[i];
			if(list1[i] % 2 == 0)
			for(int j = tmp; j < 1000000; j++) {
				dp1[j] = Math.min(dp1[j-tmp]+1, dp1[j]);
			}
			else
			for(int j = tmp; j < 1000000; j++) {
				dp1[j] = Math.min(dp1[j-tmp]+1, dp1[j]);
				dp2[j] = Math.min(dp2[j-tmp]+1, dp2[j]);
			}
		}
		while(true) {
			int a = sc.nextInt();
			if(a == 0) break;
			System.out.println(dp1[a] + " " + dp2[a]);
		}
	}
	final static int[] makeList() {
		int[] list1 = new int[180];
		for(int i = 0; i < 180; i++) {
			list1[i] = (i+1)*(i+2)*(i+3)/6;
		}
		return list1;
	}

	
}

Measured memory_bytes: 29776
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int V[21], C[21];
    rep(i, N) cin >> V[i];
    rep(i, N) cin >> C[i];
    int ans = 0;
    rep(i, N) ans += max(0, V[i] - C[i]);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
     
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long int
#define pb push_back
#define endl "\n"
#define ff first
#define ss second
#define N 200009
#define M 15000007
#define mod 1000000007
#define debug cout<<"There There\n";
#define debug1(x) cout<<"\nValue is "<<x<<endl
#define debug2(x,y) cout<<"\nValue is "<<x<<" "<<y<<endl
#define debug3(x,y,z) cout<<"\nValue is "<<x<<" "<<y<<" "<<z<<endl  
#define pq priority_queue<int>
#define mpq priority_queue<int,vector<int>,greater<int>>
#define pr pair<int,int>
#define mx INT_MAX
#define lmx LLONG_MAX
#define err return 0
#define all(a) a.begin(),a.end()

int a,b,c;

int32_t main()
{
     IOS;
     cin>>a>>b>>c;
     int maxi = max(a,max(b,c));
     cout<<a+b+c-maxi<<endl;
}

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

typedef long long ll;

using namespace std;

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

    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    string s;
    cin >> s;
    for(int i = 0; i<=5; i++)
    {
        if(s[2] == s[3] && s[4] == s[5])
        {
            cout << "Yes" << endl;
            break;

        }

        else
        {
            cout << "No" << endl;
            break;
        }
    }
}


Measured memory_bytes: 3596
import math
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

P = [A, B, C, D, E]
p = min(P)
if p>=N:
    print(5)
else:
    ans = 4+math.ceil(N/p)
    print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>

const int MAXN = 1000 + 10;

int n;
double x[MAXN], y[MAXN], r[MAXN];
double dis[MAXN];
bool vis[MAXN];

inline double calcdis(int i, int j) { return sqrt((y[i] - y[j]) * (y[i] - y[j]) + (x[i] - x[j]) * (x[i] - x[j])); }
inline double calc(int i, int j) { return std::max(0.0, calcdis(i, j) - r[i] - r[j]); }

int main() {
	int i, j, k;
	
	scanf("%lf %lf %lf %lf", &x[1], &y[1], &x[2], &y[2]);
	scanf("%d", &n);
	n += 2;
	for(i=3; i<=n; i++) 
		scanf("%lf %lf %lf", &x[i], &y[i], &r[i]);

	memset(dis, 0x7f, sizeof(dis));
	dis[1] = 0;
	for(i=1; i<n; i++) {
		k = 0;
		for(j=1; j<=n; j++)	
			if(!vis[j] and dis[j] < dis[k])
				k = j;
		
		vis[k] = true;
		for(j=1; j<=n; j++)
			dis[j] = std::min(dis[j], dis[k] + calc(j, k));
	}
	printf("%.10lf\n", dis[2]);
	return 0;
} 

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;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

ll dp[410][410];
ll a[410], acc[410];

int main(){
    int n;
    cin >> n;
    rep(i, n) cin >> a[i];
    rep(i, n) acc[i+1] = acc[i] + a[i];

    for (int w = 2; w <= n; w++){
        for (int l = 0; l+w <= n; l++){
            int r = l + w;
            ll tmp = LINF;
            for(int m = l+1; m < r; m++){
                ll cost1 = acc[m] - acc[l];
                ll cost2 = acc[r] - acc[m];
                tmp = min(tmp, dp[l][m] + dp[m][r] + cost1 + cost2);
            }
            dp[l][r] = tmp;
        }
    }

    cout << dp[0][n] << endl;

    return 0;
}


Measured memory_bytes: 4904
n, k = map(int, input().split())

a = list(map(int, input().split()))

visited = [-1] * (n + 1)

next = 1
cnt = 0
while cnt < k:
    if visited[next] == -1:
        visited[next] = cnt
        cnt += 1
    else:
        mod = cnt - visited[next]
        break
    next = a[next - 1]

if cnt == k:
    print(next)
    exit(0)

k -= cnt
k %= mod

for i in range(k):
    next = a[next - 1]

print(next)


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

class Progaram
{
    static void Main(string[] args)
    {
        var l = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
        var a = l[0]; var b = l[1];
        var ans = Algorithm.Lcm(a, b);
        Console.WriteLine(ans);
    }
}

public static class Algorithm
{
    /// <summary>
    /// 最大公約数を求める
    /// </summary>
    /// <param name="a">引数１</param>
    /// <param name="b">引数２</param>
    /// <returns>最大公約数</returns>
    public static Int64 Gcd(Int64 a, Int64 b)
    {
        if (b == 0) return a;
        return Gcd(b, a % b);
    }

    /// <summary>
    /// 最小公倍数を求める
    /// </summary>
    /// <param name="a">引数１</param>
    /// <param name="b">引数２</param>
    /// <returns>最小公倍数</returns>
    public static Int64 Lcm(Int64 a, Int64 b)
    {
        return a / Gcd(a, b) * b;
    }

    /// <summary>
    /// 2つの値をSwapする
    /// </summary>
    /// <param name="a">引数１</param>
    /// <param name="b">引数２</param>
    public static void Swap(ref Int64 a, ref Int64 b)
    {
        Int64 t = a;
        a = b;
        b = t;
    }
}

Measured memory_bytes: 13396
//
// Created by yamunaku on 2020/01/26.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main(){
    // CFS;
    int h, n;
    cin >> h >> n;
    vl a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];
    vl dp(h + 1, LINF);
    dp[h] = 0;
    rep(i, n){
        perl(j, 1, h + 1){
            int k = max(0ll, j - a[i]);
            dp[k] = min(dp[k], dp[j] + b[i]);
        }
    }
    cout << dp[0] << endl;
    return 0;
}

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

int main()
{
	int n; cin >> n;
	
	int cnt = 0;
	for (int i = 1; i <= n; i++) {
		if (i % 2 != 0) cnt++;	
	}

	cout << fixed << setprecision(11) << (double) cnt / n << endl;

	return 0;
}

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

using namespace std;

int main(){
    int A, B;

    cin >> A >> B;

    if ( A <= 5 ) cout << 0 << endl;
    else if ( A >= 6 && A <= 12) cout << B/2 << endl;
    else if ( A >= 13 ) cout  << B << endl;

    return 0;
}


Measured memory_bytes: 256
N, A, B = list(map(int, input().split()))
a, b = 0, 0
for e in input():
    if e == "a" and (a + b) < (A + B):
        print("Yes")
        a += 1
    elif e == "b" and (a + b) < (A + B) and b < B:
        print("Yes")
        b += 1
    else:
        print("No")


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

int main(){
  int N,K;cin>>N>>K;
  ll count =0;
  for (int b=K+1;b<=N;++b){
    if(K!=0){
    count+=N/b*(b-K)+max(N%b-K+1,0);
    }
    else{
      count+=N;
    }
  }
  cout << count << endl;
  return 0;
}

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

namespace abc141_b
{
  class Program
  {
    static void Main(string[] args)
    {
      var s = CIn.Read().ToCharArray();

      var n = s.Where((e, i) => (e == 'L' && i % 2 == 0) || (e == 'R' && i % 2 == 1)).Count();

      Console.WriteLine(n == 0 ? "Yes" : "No");
    }
  }

  class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }

      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(long n)
    {
      var array = new string[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }

      return array;
    }

    public static int[] ReadIntArray(long n)
    {
      var array = new int[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }

      return array;
    }

    public static long[] ReadLongArray(long n)
    {
      var array = new long[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }

      return array;
    }
    public static double[] ReadDoubleArray(long n)
    {
      var array = new double[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }

      return array;
    }
  }
}


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

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

    int n; cin>>n; int p[n];
    for (int i = 0; i < n; i++)cin>>p[i];
    sort(p,p+n);
    cout<<p[n/2]-p[n/2-1]<<'\n';
}
    

Measured memory_bytes: 640
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>
#include <random>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
int main(void){
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    ll now = a[0];
    ll ans = 0;
    for(ll i = 1; i < n; i++){
        if(now > a[i]){
            ans += abs(now - a[i]);
        }
        now = max(now, a[i]);
    }

    cout << ans << endl;

}   

Measured memory_bytes: 4768
#include <iostream>
#include <cstring>


using namespace std;

typedef long long ll;
const int MAX = 1e6;
char str[MAX];
int dp[MAX + 1][2];

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

    cin >> str;
    int len = strlen(str);
    for (int j = 0; j < len; ++j) {
        str[j] -= '0';
    }

    dp[0][0] = str[0];
    dp[0][1] = 10 - str[0] + 1;
    for (int i = 1; i < len; ++i) {
        dp[i][0] = min(dp[i - 1][1] + str[i], dp[i - 1][0] + str[i]);
        dp[i][1] = min(dp[i - 1][1] - 1 + 10 - str[i], dp[i - 1][0] + 10 - str[i] + 1);
    }

    cout << min(dp[len - 1][0], dp[len - 1][1]);
    return 0;
}

Measured memory_bytes: 9088
#include <iostream>

int main() {
    int a, b, c;
    int k;
    std::cin >> a >> b >> c >> k;
    // b>a c>b
    for (int i = 0; i < k; ++i) {
        if (a < b) {
            c = c * 2;
        } else {
            b = b * 2;
        }
    }
    if (a < b && b < c) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
int main() {
	int a, b;
	std::cin >> a >> b;
	int ans = 0;
	for (int i = a; i <= b; ++i) {
		int x = i, tmp = 0;
		while (x != 0) {
			tmp = tmp*10+(x%10);
			x /= 10;
		}
		if (tmp == i) ans++;	
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
void add(int &a, const int &b) {
	a += b;
	if (a >= MOD)a -= MOD;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M;
	cin >> N >> M;
	vector<int> A(N);
	vector<int> V(N, 0);
	int mn = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		A[i]--;
	}
	{
		int t = -1;
		int b = -1;
		for (int i = 0; i < N; i++) {
			if (t < A[i]) {
				t = A[i];
			}
			else {
				if (b > A[i]) {
					cout << 0 << endl;
					return 0;
				}
				else {
					b = A[i];
				}
			}
		}
	}



	int mx = -1;
	pair<int, int> cur;
	vector<pair<int, int> > X;
	for (int i = 0; i < N; i++) {
		if (mx < A[i]) {
			if (mx < mn) {
				if (i != 0) {
					X.push_back(cur);
				}
				cur.first = 1;
				cur.second = 0;
			}
			else {
				cur.first++;
			}
			mx = A[i];
		}
		else {
			cur.second++;
		}
		V[A[i]] = 1;
		while (mn < N && V[mn] == 1)mn++;
	}
	X.push_back(cur);

	/*for (int i = 0; i < X.size(); i++) {
		cerr << X[i].first << " " << X[i].second << endl;
	}*/
	vector<int> dp(N + 1, 0);
	dp[0] = 1;
	for (int i = 0; i < X.size(); i++) {
		vector<int> ndp(N + 1, 0);
		for (int j = 0; j + X[i].first <= N; j++) {
			add(ndp[j + X[i].first], dp[j]);
		}
		for (int j = 0; j + X[i].second <= N; j++) {
			add(ndp[j + X[i].second], dp[j]);
		}
		swap(dp, ndp);
	}

	int res = 0;
	for (int i = N - M; i <= M; i++) {
		add(res, dp[i]);
	}

	cout << res << endl;
}


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

using namespace std;
# define int long long 
int n;
int a[100005];
int dp[100005];

int fun(int ind) {
	if(ind==(n-1)) return 0; 
	if(ind>=n) return INT_MAX; 
 
	if(dp[ind]!=-1) return dp[ind]; 
    
	int left = abs(a[ind]-a[ind+1]) + fun(ind+1); 
	int right = INT_MAX; 
	if(ind+2<n) {
		right = abs(a[ind] - a[ind+2]) + fun(ind+2); 
	}
 
	return dp[ind] = min(left, right); 
}


signed main(){
  cin>>n;
  for(int i=0; i<n; i++){
   cin>>a[i]; 
  }
  
  memset(dp,-1,sizeof dp);
  
 cout<<fun(0);
  //return 0;
}


Measured memory_bytes: 9832
#include<iostream>
#include<stdio.h>
using namespace std;
void print(int a[], int n) {
	int i;
	for (i = 0; i < n; i++) {
		if (i > 0) printf(" ");
		cout << a[i];
	}
	cout << endl;
}
void insertionsort(int a[], int n) {
		int i, j, tmp;
		for (i = 1; i < n; i++) {
			tmp = a[i];
			for (j = i; j > 0 && a[j - 1] > tmp; j--) 
				a[j] = a[j - 1];
				a[j] = tmp;
			print(a, n);
		}
	}
int main() {
	int n;
	int a_list[105];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a_list[i];
	}
	print(a_list, n);
	insertionsort(a_list, n);
}


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

typedef long long ll;
#define PB push_back

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	int a, b; cin >> a >> b;
	if (b == 1) cout << 0;
	else {
		int ans = 1;
		while (ans * a - (ans - 1) < b) ans++;
		cout << ans;
	}
}

Measured memory_bytes: 256
package main

import "fmt"

func pow(k int,i int) int {
	f := 1
	for j := 1 ; j <= i ; j++{
		f *= k
	}
	return f
}

func main(){
	var n,k,f int
	fmt.Scan(&n,&k)
	for i := 0 ; ;i++ {
		f = pow(k,i)
		if n < f{
			fmt.Println(i)
			break
		}
	}
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fr(i,n) for(int i=0;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
	int h,w,n;
    int sr,sc;
    string s,t;
    bool ans = true;
  	cin >> h >> w >> n >> sr >> sc >> s >> t;
    int smuki[4];
    int tmuki[4];
	fr(i,4){
      smuki[i]=0;
      tmuki[i]=0;
    }
  	fr(i,n){
      if(s.substr(i,1)=="L"){
        smuki[0]+=1;
      }else if(s.substr(i,1)=="R"){
        smuki[1]+=1;
      }else if(s.substr(i,1)=="U"){
        smuki[2]+=1;
      }else if(s.substr(i,1)=="D"){
        smuki[3]+=1;
      }
      if(smuki[0]>=sc){ans = false;}
      if(smuki[1]>=w-sc+1){ans = false;}
      if(smuki[2]>=sr){ans = false;}
      if(smuki[3]>=h-sr+1){ans = false;}
      if(t.substr(i,1)=="L"){
        smuki[1]-=1;
        if(smuki[1]<=-sc)smuki[1]=-sc+1;
      }else if(t.substr(i,1)=="R"){
        smuki[0]-=1;
        if(smuki[0]<=-w+sc-1)smuki[0]=-w+sc;
      }else if(t.substr(i,1)=="U"){
        smuki[3]-=1;
        if(smuki[3]<=-sr)smuki[3]=-sr+1;
      }else if(t.substr(i,1)=="D"){
        smuki[2]-=1;
        if(smuki[2]<=-h+sr-1)smuki[2]=-h+sr;
      }
      
    }
    if(ans){cout << "YES" << endl;}
  	else{cout << "NO" << endl;}
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;

const int MM = 1e9 + 7;
const double eps = 1e-8;
const int MAXN = 2e6 + 10;

int n, m;

void prework(){

}

void read(){

}

ll pw(ll p, ll q){
	ll ret = 1;
	for(; q; q >>= 1){
		if (q & 1)
		 ret = ret * p % MM;
		p = p * p % MM;
	}
	return ret;
}

ll Inv[MAXN];

/*
13
4 6 8 9 10 12 14 15 16 18 20 21 22
1 3 5 7 9  11 13 15 ** 17 19 21 23
1 2 3 4 5  6  7  8  9  9  10 11 12
*/

void solve(int casi){
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
		Inv[i] = pw(i, MM - 2);
	ll ans = 1;
	int cnt = 0;
	for(int i = 1, j = 1; i <= n; i++, j+=2){
		int x;
		scanf("%d", &x);
		ans = ans * (i - cnt) % MM;
		if (x >= j)
			;
		else{
			int k = (j - x + 1) / 2;
			cnt += k;
			j -= 2 * k;
		}
	}
	printf("%lld\n", ans);
}

void printans(){

}


int main(){
	prework();
	int T = 1;
//	cin>>T;
	for(int i = 1; i <= T; i++){
		read();
		solve(i);
		printans();
	}
	return 0;
}




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

public class Program{
  public static void Main(){
    var n = ulong.Parse(Console.ReadLine());
    ulong p=1;
    for(ulong i=1; i<=n; i++) p = (p*i) % 1000000007;
    Console.WriteLine("{0}", p);
  }
}


Measured memory_bytes: 13268
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <bitset>
#include <stack>
#include <deque>
using namespace std;
typedef pair<int, int> pii;
typedef long long LL;

int main() {
    int n;
    // freopen("vary_2.txt", "r", stdin);
    scanf("%d", &n);
    map<int, int> mp[2];
    for (int i = 0; i < n; i++) {
        int tmp;
        scanf("%d", &tmp);
        if (!mp[i & 1].count(tmp)) mp[i & 1][tmp] = 1;
        else mp[i & 1][tmp]++;
    }
    vector<pii> line[2];
    for (int i = 0; i < 2; i++) {
        for (auto j : mp[i]) {
            line[i].push_back(make_pair(j.second, j.first));
        }
        sort(line[i].begin(), line[i].end(), greater<pii>());
    }
    if (line[0][0].second == line[1][0].second) {
       int num0 = n / 2 - line[0][0].first;
       int num1 = n / 2 - line[1][0].first;
       if (line[0].size() > 1) num0 = line[0][1].first;
       if (line[1].size() > 1) num1 = line[1][1].first;
       printf("%d\n", min(n - line[0][0].first - num1, n - line[1][0].first - num0));
    } else {
       printf("%d\n", n - line[0][0].first - line[1][0].first);
    }
    return 0;
}


Measured memory_bytes: 6136
s = input()

flag = True

for i in range(len(s)):
  if i % 2 == 1 and s[i] in ['L', 'U', 'D']:
    pass
  elif i % 2 == 1:
    print('No')
    flag = False
    break
  
  if i % 2 == 0 and s[i] in ['R', 'U', 'D']:
    pass
  elif i % 2 == 0:
    print('No')
    flag = False
    break
    
if flag:
  print('Yes')

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

static int cmp(const void *a, const void *b)
{
    return *((int *)a) < *((int *)b);
}

int main(int argc, char *argv[])
{
    int i, N;
    int list[100], v;
    int d = 0;

    scanf("%d\n", &N);
    for ( i = 0; i < N; i++ ){
        scanf("%d\n", &v);
        list[i] = v;
    }
    qsort(list, N, sizeof(int), cmp);
    for ( i = 1; i < N; i++ ){
        d += (list[i-1]-list[i]);
    }
    printf("%d\n", d);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
int dp[1003][1003];
char g[1003][1003];
int h, w;

int main() {
	memset(dp, 0, sizeof(dp));
	dp[1][1] = 1;
	scanf("%d %d", &h, &w);
	for(int i = 1;i <= h; i++) {
		for(int j = 1;j <= w; j++) {
			scanf(" %c", &g[i][j]);
		}
	}
	
	for(int i = 1;i <= h; i++) {
		for(int j = 1;j <= w; j++) {
			if(g[i][j] == '#') continue;
			if(dp[i-1][j]) dp[i][j] = (dp[i][j] + dp[i-1][j])%mod;
			if(dp[i][j-1]) dp[i][j] = (dp[i][j] + dp[i][j-1])%mod;
		}
	}
	
//	for(int i = 1;i <= h; i++) {
//		for(int j = 1;j <= w; j++) {
//			printf("%d ", dp[i][j]);
//		}
//		puts("");
//	}
	printf("%d\n", (dp[h][w]+mod)%mod);
}

Measured memory_bytes: 8656
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>
#define itn int
#define retrun return
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
using namespace std;
typedef long long llong;
typedef pair<int, int> pii;
llong gcd(llong a, llong b) {
	if (a < b) std::swap(a, b);
	if (a % b == 0)
		return b;
	else
		return gcd(b, a % b);
}
llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}
//ここまで共通
int main() {
	int A[32] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	int K;
	cin >> K;
	cout << A[K - 1];
	return 0;
}

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

int main(){
    string s; cin>>s;
    ll cnt=0;
    rep(i,0,s.size()){
        if(s[i]=='A'){
            for(ll j=s.size()-1; j>=i; j--){
                cnt = j-i+1;
                if(s[j]=='Z')break;
            }
            if(cnt!=0)break;
        }
    }
    cout << cnt << endl;
    return 0;
}

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

using namespace std;

#define endl '\n'

vector<int> vi, wi;
long long dp[101][100005];

long long solve(int idx, int cap) {
  if (cap <= 0 || idx < 0) return 0;
  if (dp[idx][cap] != -1) return dp[idx][cap];
  long long val = 0;
  if (cap - wi[idx] >= 0)
    val = vi[idx] + solve(idx - 1, cap - wi[idx]);
  return dp[idx][cap] = max(val, solve(idx - 1, cap));
}

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

  int n, w;
  cin >> n >> w;
  vi.resize(n);
  wi.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> wi[i] >> vi[i];
  }
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= w; j++) {
      dp[i][j] = -1;
    }
  }
  long long ans = -1e18;
  for (int i = n - 1; i >= 0; i--) {
    ans = max(ans, solve(i, w));
  }
  cout << ans << endl;

	return 0;
}


Measured memory_bytes: 82448
#include <stdio.h>
#include <math.h>
 
int main(void)
{
    double a, b, x, r;
    scanf("%lf %lf %lf", &a, &b, &x);
  	if (x/a/a > b/2)
		r = atan((b-x/a/a)/(a/2));
    else
      	r = atan(b/(2*x/a/b));
   	printf("%.12lf",  r * 180.0 / (atan(1.0) * 4.0));
  	return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections;
using System.IO;
using System.Linq;

namespace CompetitiveProgramming
{
  
  class Solve
  {
    const int INF = (int)(1e9) + 10;

    private void Main()
    {
      string S = Console.ReadLine();

      ulong ans = 0;
      
      for (uint i = 0; i < (1 << S.Length - 1); i++)
      {
        string T = S;
        int c = 0;
        for (int j = S.Length - 1; j >= 0; j--)
        {
          if ((i & (1 << j)) != 0)
          {
            T = T.Insert(c, "+");
            c++;
          }
          c++;
        }

        ulong[] nums = T.Split('+').Select(ulong.Parse).ToArray();
        foreach(var n in nums)
        {
          ans += n;
        }
      }

      Console.WriteLine(ans);
    }

    public Solve()
    {
      Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
      Main();
      Console.Out.Flush();
    }
  }

  class Program
  {
    static void Main(string[] args)
    {
      new Solve();
    }
  }
}

Measured memory_bytes: 3288
t1,t2=map(int,input().split())
a1,a2=map(int,input().split())
b1,b2=map(int,input().split())
p=a1-b1
q=a2-b2
if p*t1+q*t2==0:print('infinity');exit()
elif p<0:p,q=-p,-q
#p>0
if p*t1+q*t2>0:print(0)
else:
    a=p*t1
    d=-(a+q*t2)
    print(2*(a//d)+int(not(not a%d)))


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int INF=1001001001001001001ll;

int N,P;

int dp[111][111][111];

int latte[111][111];

int X[111],Y[111];
signed main(){
    cin>>N>>P;
    rep(i,N)cin>>X[i]>>Y[i];

    rep(i,N){
        for(int j=i+1;j<=N;j++){
            int pre=0;
            for(int k=i;k<j;k++){
                int x=max(0ll,X[k]-pre);
                pre=max(0ll,Y[k]-x);
            }
            latte[i][j]=pre;
        }
    }

    fill_n(**dp,111*111*111,INF);
    dp[0][0][0]=0;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            for(int k=0;k<N;k++){
                if(dp[i][j][k]==INF)continue;
                int tmp=latte[i-k][i];

                chmin(dp[i+1][j][0],dp[i][j][k]);
                int x=max(0ll,X[i]-tmp);
                chmin(dp[i+1][j+1][k+1],dp[i][j][k]+max(0ll,Y[i]-x));
            }
        }
    }

    int ans=0;
    rep(i,N+1)rep(j,N+1)if(dp[N][i][j]<=P)chmax(ans,i);
    cout<<ans<<endl;
}

Measured memory_bytes: 13864
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef vector<int>::iterator vit;
int main() {
	int n, k;
	cin >> n >> k;
	vector <int> x(n, 0);
	for (vit it = x.begin();it != x.end();it++) {
		cin >> *it;
	}
	if (n == k) {
		int answer = 0;
		if (x[0] <= 0 && x[n - 1] >= 0) {
			if (x[n - 1] > -x[0]) {
				answer = x[n - 1] - 2 * x[0];
			}
			else {
				answer = 2 * x[n - 1] - x[0];
			}
		}
		else if (x[0] > 0) {
			answer = x[n - 1];
		}
		else {
			answer = -x[0];
		}
		cout << answer << endl;
	}
	else {
		int cnt;
		int shorter = 100000010;
		for (int i = 0;i < n - k + 1;i++) {
			if (x[i] <= 0 && x[i + k - 1] >= 0) {
				if (x[i + k - 1] > -x[i]) {
					cnt = x[i + k - 1] - 2 * x[i];
				}
				else {
					cnt = 2 * x[i + k - 1] - x[i];
				}
			}
			else if (x[i] > 0) {
				cnt = x[i + k - 1];
			}
			else {
				cnt = -x[i];
			}
			if (shorter > cnt) {
				shorter = cnt;
			}
		}
		cout << shorter << endl;
	}
	return 0;
}

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

using namespace std;

using LL = long long;


int K, N;
string S;

LL dp[110][4][3];


LL solve(int pos, int k, int carry) {
	if (k < 0) return 0;
	if(pos >= N) return (k==0 && carry==0);
	//if (k == 0) return 1;

	LL &p = dp[pos][k][carry];
	if(p != -1) return p;

	p = 0;

	for(int i = 0; i < 10; ++i) {
		int x = S[pos]-'0';
		if(i + carry <= x) {
			p += solve(pos + 1, k - (i != 0), 0);
		}
		else {
			p += solve(pos + 1, k - (i != 0), 1);
		}
	}

	return p;
}


int main() {

	ios_base :: sync_with_stdio(0); cin.tie(NULL);

	cin >> S >> K;

	reverse(S.begin(), S.end());

	N = S.length();
	memset(dp, -1, sizeof(dp));

	cout << solve(0, K, 0) << '\n';

	return 0;
}

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

#define rep(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define SZ(x) ((int) (x).size())
typedef long long ll;

int main(){
        //freopen("a.in","r",stdin);
	int a,b,c;
	cin >> a >> b >> c;
	if(2*b == a + c) puts("YES");
	else puts("NO");
        return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0; i<n; i++){
    cin >> a[i];
  }
  
   double mean=0;
  for(int i=0; i<n; i++){
    mean += a[i];
  }
  
  mean /= n;
  
  int t=n;
  double d=10000;
  for(int i=n-1; i>=0; i--){
    if(abs(a[i]-mean) <= d){
      d = abs(a[i]-mean);
      t = i;
    }
  }
  
  cout << t << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    string s,t;
    cin>>s>>t;
    int f=0;
    for(int i=0;i<s.length();i=i+1){
        // cout<<s[i]<<"\n";
        if(s[i]!=t[i]){
            cout<<"No\n";
            f=1;
            break;
        }
    }
    
    if(f==0){
        cout<<"Yes\n";
    }


}

Measured memory_bytes: 3596
#include <stdio.h>

int main(void)
{
	float a, b, c, d, e, f;
	float x, y;

	while (scanf("%f %f %f %f %f %f", &a, &b, &c, &d, &e, &f) != EOF){
		y = (a * f - d * c) / (a * e - d * b);
		x = (c - b * y) / a;

		printf("%.3f %.3f\n", x, y);
	}

	return (0);
}

Measured memory_bytes: 648
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    int N = sc.nextInt();
	    if(N == 1) {
	        System.out.println(1);
	    }else if(N % 2 == 0) {
	        System.out.println(0.5);
	    }else {
	        System.out.println(((double)(N/2)+1) / N);
	    }
	}
}

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

#define ll long long
#define ld long double
#define pii pair<int,int>
#define fi first
#define se second
#define mex 1000005
//vector<int> adj[mex];
int mod=1e9+7;
long long fact[100005];

long long power(long long a,long long b){
	long long res=1;
	while(b){
		if(b&1)
		 res=(res*a)%mod;
		b=b/2;
		a=(a*a)%mod;
	}
	return res;
}
 
long long comb(long long n,long long k){
	if(k>n || k<0)
	 return 0;
	return ((fact[n]*power(fact[k],mod-2))%mod*power(fact[n-k],mod-2))%mod;
}
 
int main(){
	int n,k;
	cin>>n>>k;
	vector<long long int> v(n);
	for(int i=0;i<n;i++)
	 cin>>v[i];
	sort(v.begin(),v.end());
	fact[0]=1;
	for(int i=1;i<=n;i++)
	 fact[i]=(fact[i-1]*i)%mod;
	long long sum1=0,sum=0;
	for(int i=k-1;i<n;i++){
		long long tx=(v[i]*comb(i,k-1))%mod;
		long long ti=(v[n-i-1]*comb(i,k-1))%mod; 
		sum=(sum+tx)%mod;
		sum1=(sum1+ti)%mod;
	}
	cout<<(sum-sum1)%mod;

}




Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>
void merge(int *,int,int,int);
void mergeSort(int *,int,int);
int n,c=0;

int main(){
  int i;
  int *S;
  scanf("%d",&n);
  S=(int *)malloc(n*sizeof(int));
  for(i=0;i<n;i++) scanf("%d",&S[i]);
  
  
  mergeSort(S,0,n);
  
  for(i=0;i<n;i++){
    printf("%d",S[i]);
    if(i<n-1) printf(" ");
  }
  printf("\n%d\n",c);

  free(S);
  return 0;
}

void merge(int *A,int left,int mid, int right){
  int n1,n2,i,j,k,L[mid-left],R[right-mid];
  n1=mid-left;
  n2=right-mid;
  
  for(i=0;i<n1;i++) L[i]=A[left+i];

  for(i=0;i<n2;i++) R[i]=A[mid+i];

  L[n1]=999999999;
  R[n2]=999999999;
  i=0;
  j=0;

  for(k=left;k<right;k++){

    if(L[i]<R[j]){
      A[k]=L[i];
      i++;

    }else{
      A[k]=R[j];
      j++;
    }
    c++;
  }
  
}

void mergeSort(int *A,int left,int right){
  int mid;
  
  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
  
}



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

n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ans = 0

for i in range(n):
    if a[i] <= b[i]:
        ans += a[i]
        b[i] -= a[i]
        if a[i+1] <= b[i]:
            ans += a[i+1]
            a[i+1] = 0
        else:
            a[i+1] -= b[i]
            ans += b[i]
    else:
        ans += b[i]
        a[i] -= b[i]

print(ans)

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

using namespace std;

int main(int argc, const char *argv[]) {
  int n, m;
  cin >> n >> m;

  vector<pair<int, int>> vab(m);
  for (auto &p : vab) {
    cin >> p.first >> p.second;
  }

  sort(vab.begin(), vab.end());

  int l = vab[0].first, r = vab[0].second, ans = 1;
  for (int i = 1; i < m; ++i) {
    l = max(l, vab[i].first);
    r = min(r, vab[i].second);

    if (r - l < 1) {
      ans++;
      l = vab[i].first;
      r = vab[i].second;
    }
  }

  cout << ans << '\n';
  return 0;
}

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

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2")

using namespace std;

#define int long long
#define sz(a) (int) (a).size()
#define all(a) (a).begin(), (a).end()
#define x first
#define y second

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxn = 2e5 + 10;
int dp1[maxn], dp2[maxn];

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

    int n, k, c;
    cin >> n >> k >> c;
    string s;
    cin >> s;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'x') {
            if (i != 0) {
                dp1[i] = dp1[i - 1];
            }
            continue;
        }
        if (i == 0) {
            dp1[i] = 1;
        } else {
            int val = 1;
            if (i - c - 1 >= 0) val += dp1[i - c - 1];
            dp1[i] = max(dp1[i - 1], val);
        }
    }
    for (int i = n - 1; i >= 0; i--) {
        if (s[i] == 'x') {
            if (i != n - 1) {
                dp2[i] = dp2[i + 1];
            }
            continue;
        }
        if (i == n - 1) {
            dp2[i] = 1;
        } else {
            int val = 1;
            if (i + c + 1 < n) val += dp2[i + c + 1];
            dp2[i] = max(dp2[i + 1], val);
        }
    }
    for (int i = 0; i < n; i++) {
        if (s[i] == 'x') continue;
        int val1 = 0;
        if (i - c - 1 >= 0) val1 += dp1[i - c - 1];
        int mx1 = 0;
        if (i - 1 >= 0) mx1 = dp1[i - 1];
        int val2 = 0;
        int mx2 = 0;
        if (i + 1 < n) mx2 = dp2[i + 1];
        if (i + c + 1 >= 0) val2 += dp2[i + c + 1];
        if (val1 + val2 + 1 == k && mx1 < k && mx2 < k && val2 + mx1 < k && val1 + mx2 < k) {
            cout << i + 1 << "\n";
        }
    }

    return 0;
}

Measured memory_bytes: 5012
import math

N = int(input())

M = [2] * (N+1)
M[1] = 1

for i in range(2, N//2 +1):
    for j in range(i*2, N+1, i):
        M[j] += 1

ans = 0
for i in range(1, N+1):
    ans += i * M[i]

print(ans)

Measured memory_bytes: 145956
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 100010
#define INF 0x3FFFFFFF
#define LL long long
int a[MAXN],n;
LL sum=0,pre[MAXN],ans=-INF;
bool b[MAXN];
char s[10];
int main()
{
	scanf("%d",&n);
	scanf("%d",&a[1]);
	for(int i=2;i<=n;i++)
	{
		scanf("%s%d",s,&a[i]);
		if(s[0]=='-') b[i]=1;
	}
	for(int i=n;i>0;i--)
		pre[i]=pre[i+1]+a[i];
	int ls=1;
	while(b[ls]==0&&ls<=n)
	{
		sum+=a[ls];
		ls++;
	}
	while(ls<=n)
	{
		int ls1=ls+1;
		LL sum1=0;
		while(ls1<=n&&b[ls1]==0)
		{
			sum1+=a[ls1];
			ls1++;
		}
		if(ls1<=n) ans=max(ans,sum-sum1-a[ls]+pre[ls1]);
		sum-=a[ls],sum+=sum1;
		ls=ls1;
	}
	ans=max(ans,sum);
	printf("%lld\n",ans);
}

Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
using namespace std;
int main(){
int A,B;
cin >>A>>B;
if(A==1 && B!=1) cout <<"Alice"<<endl;
else if(A==1 && B==1) cout <<"Draw"<<endl;
else if(B==1) cout <<"Bob"<<endl;
else if(A<B) cout <<"Bob"<<endl;
else if(A>B) cout <<"Alice"<<endl;
else cout <<"Draw"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int X, Y;
    cin >> X >> Y;
    cout << X + (Y / 2) << endl;
}


Measured memory_bytes: 256
n = int(input())
a_list = list(map(int, input().split()))
a_list = [a_list[index] - (index + 1) for index in range(n)]
a_list.sort()
mid = n//2
b = a_list[mid]
sum = 0
for i in range(n):
    sum += abs(a_list[i]-b)
print(sum)

Measured memory_bytes: 99796