akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <vector>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i >= (b); i--)
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

using namespace std;

struct P { int x, y, H; };

int N;
int x[105], y[105], h[105];
vector<P> v;

P solve() {

	int idx = 0;
    REP(i, 0, N) {
    	if (h[i] > 0) {
    		idx = i;
    		break;
    	}
    }

	REP(cx, 0, 101) {
    	REP(cy, 0, 101) {
    		int hx = abs(x[idx] - cx) + abs(y[idx] - cy) + h[idx];
    		P p = {cx, cy, hx};
    		v.push_back(p);
    	}
    }

    REP(i, 0, v.size()) {
    	int cnt = 0;
    	REP(j, 0, N) {
    		if ( max(v[i].H - abs(x[j] - v[i].x) - abs(y[j] - v[i].y), 0) == h[j]) cnt++;
    	}
    	if (cnt == N) return v[i];
    }
    P p = {-1, -1, -1};
    return p;

}


int main(void) {
    scanf("%d", &N);

    REP(i, 0, N) scanf("%d %d %d", &x[i], &y[i], &h[i]);

    P p = solve();
    
    printf("%d %d %d\n", p.x, p.y, p.H);

	return 0;
}


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

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

int main() {
    int n; cin >> n;
    string s; cin >> s;
    int ans = 0;
    int sum = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == 'I') sum++;
        if(s[i] == 'D') sum--;
        ans = max(ans, sum);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int n; cin >> n;
	vector<int> v(4);
	while (n--)
	{
		string s; cin >> s;
		if (s == "AC")++v[0];
		else if (s == "WA")++v[1];
		else if (s == "TLE")++v[2];
		else ++v[3];
	}

	cout << "AC x " << v[0] << endl;
		cout << "WA x " << v[1] << endl;
		cout << "TLE x " << v[2] << endl;
		cout << "RE x " << v[3] << endl;
}

Measured memory_bytes: 3620
import numpy as np

ABC=np.array(input().split(),dtype=np.int32)

ABC=np.sort(ABC)

if(ABC[0]==ABC[1]):
    if(ABC[1]==ABC[2]):
        print("No")
    else:
        print("Yes")
elif(ABC[1]==ABC[2]):
    if(ABC[0]==ABC[1]):
        print("No")
    else:
        print("Yes")
else:
    print("No")

Measured memory_bytes: 21260
n, m, l = map(int, input().split())
a = [input().split()for _ in range(n)]
b = [input().split()for _ in range(m)]     
c = [[0]*l for _ in range(n)]

for i in range(n):
    for j in range(l):
        for k in range(m):
            c[i][j] += int(a[i][k])*int(b[k][j])
            
for i in range(n):
    print(*c[i])


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

MOD = 2019  # type: int

def solve(L: int, R: int):
    if R - L >= 2019 - 1:
        print(0)
        return
    if R % 2019 <= L % 2019:
        print(0)
        return
    else:
        L = L % 2019
        R = R % 2019
        
        smallest = 10000000
        for i in range(L, R):
            for j in range(i+1, R+1):
                calc = (i*j)%2019
                if calc < smallest:
                    smallest = calc
    print(smallest)
    return


# Generated by 1.1.4 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()
    L = int(next(tokens))  # type: int
    R = int(next(tokens))  # type: int
    solve(L, R)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <cstdio>

using namespace std;

int main(){
  int n,cnt=0;
  cin >> n;

  for(int i=1;i<=n;i++) {
    if(i%2) cnt++;
  }
  cout << fixed << setprecision(10) << (float)cnt/n << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
def solve():
    N = int(input())
    counter = defaultdict(int)
    for x in range(1,101):
        for y in range(1,101):
            for z in range(1,101):
                n = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
                if 1 <= n <= N:
                    counter[n] += 1

    for i in range(1,N+1):
        print(counter[i])
if __name__ == '__main__':
    solve()

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

int main() {
//    freopen("in.txt", "r", stdin);

    int n, x, sum = 0;
    while (1) {
        cin >> n >> x;
        if (n == 0 && x == 0) {return 0;}

        sum = 0;
        for (int i = 1; i <= n; ++i) {
            for (int j = i + 1; j <= n; ++j) {
                for (int k = j + 1; k <= n; ++k) {
                    if (i + j + k == x) {
                        sum += 1;
                    }
                }
            }
        }
        cout << sum << endl;
    }
}

Measured memory_bytes: 3048
void main()
{
    long[] tmp = rdRow;
    long d = tmp[0], g = tmp[1];

    Problem[] p = d.rdCol!Problem;
    long result = inf;
    foreach (i; 0 .. 1<<d)
    {
        long cnt, total;
        foreach (j; 0 .. d)
        {
            if (i & (1 << j))
            {
                cnt += p[j].cnt;
                total += 100 * (j + 1) * p[j].cnt + p[j].bonus;
            }
        }

        foreach_reverse (j; 0 .. d)
        {
            if (total >= g) break;
            if (!(i & (1 << j)))
            {
                long diff = g - total;
                long num = min(p[j].cnt-1, (diff+100*(j+1)-1)/(100*(j+1)));
                cnt += num;
                total += 100 * (j + 1) * num;
            }
        }

        if (total >= g) result = min(result, cnt);
    }

    result.writeln;
}

struct Problem
{
    long cnt, bonus;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define foi(i,k,n) for(int i = (int)k; i < (int)n; ++i)
using namespace std;
using ll = long long;
using ii = pair<int,int>;

constexpr int MAXN = 5 + 1e5;

int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
  int a,b; cin >> a >> b;
  cout << a*b << '\n';
  return 0;
}


Measured memory_bytes: 3640
def main():
    N,M=map(int,input().split())
    s=[[] for i in range(0,M)]
    for i in range(0,M):
        s[i]+=list(map(int,input().split()))
    p=list(map(int,input().split()))
    ans=0
    for i in range(0,2**N):
        flag=0
        for j in range(0,M):
            x=0
            for k in range(1,s[j][0]+1):
                x+=(i >> (s[j][k]-1) & 1)
            if x%2!=p[j]:
                flag=1
        if flag==0:
            ans=ans+1
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    stack<int> S1;
    stack<pair<int, int> > S2;
    char ch;
    int sum = 0;

    for(int i=0; cin >> ch; i++){
        if(ch == '\\'){ S1.push(i); }
        else if(ch == '/' && S1.size() > 0){
            int j = S1.top();
            S1.pop();
            sum += i - j;
            int a = i - j;
            while(S2.size() > 0 && S2.top().first > j){
                a += S2.top().second;
                S2.pop();
            }
            S2.push(make_pair(j, a));
        }
    }

    vector<int> ans;
    while(S2.size() > 0){
        ans.push_back(S2.top().second);
        S2.pop();
    }
    reverse(ans.begin(), ans.end());
    cout << sum << endl;
    cout << ans.size();
    for(int i=0; i<ans.size(); i++){
        cout << " ";
        cout << ans[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3244
n = input()
l = len(n)

if l == 1:
  print(n)
elif l%2==1:
  tmp = sum([(10**(i-1))*9 for i in range(1, l, 2)])
  ans = tmp+ (int(n)-10**(l-1)+1)
  print(ans)
else:
  ans = sum([(10**(i-1))*9 for i in range(1, l, 2)])
  print(ans)
  

Measured memory_bytes: 3064
"use strict";
const Main = (input) =>{
   let xs = input.trim().split('\n');
   let a = xs[0].split('');
   let b = xs[1].split('');
   
   a = a.sort().join();
   b = b.sort().reverse().join();
   if(a<b){
     console.log('Yes');
   }else{
     console.log('No');
   }
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 7500
#include <bits/stdc++.h>
#define int long long

using namespace std;
const int MN = 1e5+7;
const int INF = 1e15+7;
int dp[107][MN];

signed main()
{
    int n, W, w[107], v[107];
    cin >> n >> W;
    for(int i = 0; i < n; i++){
        cin >> w[i];
        cin >> v[i];
    }
    for(int x = 0; x < MN; x++){
        dp[0][x] = INF;
    }
    dp[0][v[0]] = w[0];
    dp[0][0] = 0;
    //cout << dp[0][W] << ' ';
    for(int i = 1; i < n; i++){
        for(int x = 0; x < MN; x++){
            if(x >= v[i])dp[i][x] = min(dp[i-1][x], dp[i-1][x-v[i]] + w[i]);
            else dp[i][x] = dp[i-1][x];
        }
        //cout << dp[i][W] << ' ';
    }
    int maxi = 0;
    for(int i = 0; i < MN; i++){
        if(dp[n-1][i] <= W)maxi = i;
    }
    cout << maxi;
}


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

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

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

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

vector<int> G[MAX];

bool used[MAX];
map<P, int> m;
void dfs(int n, int color) {
    used[n] = true;

    int c = 0;
    for (int next : G[n]) {
        if (used[next]) continue;
        P p = P(min(next, n), max(next, n));
        if (color == c) c++;
        m[p] = c;
        dfs(next, c);
        c++;
    }
}

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

    vector<P> E(N - 1);
    rep(i, N - 1) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
        E[i] = P(a, b);
    }

    int num = 0, x = 0;
    rep(i, N) {
        if (num < G[i].size()) {
            num = G[i].size();
            x = i;
        }
    }

    dfs(x, INF);

    cout << num << endl;
    rep(i, N - 1) {
        P p = E[i];
        int ans = m[p];
        cout << ans + 1 << endl;
    }
}

Measured memory_bytes: 16000
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define REP(a,b,c) for(int a=b;a<=c;a++)
#define re register
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
typedef pair<int,int> pii;
#define mp make_pair
inline int gi()
{
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
const int N=50,Mod=1e9+7;
int n,m,stk[N],f[100010][N],top;
int main()
{
	n=gi();m=gi();
	for(int i=2;i*i<=m;i++)
		if(m%i==0)
		{
			top++;int s=0;
			while(m%i==0)
			{
				s++;m/=i;
			}
			stk[top]=s;
		}
	if(m!=1)stk[++top]=1;
	f[0][0]=1;
	for(int i=1;i<=n;i++)
		for(int j=0;j<=40;j++)
			for(int k=0;k<=j;k++)f[i][j]=(f[i-1][j-k]+f[i][j])%Mod;
	ll ans=1;
	for(int i=1;i<=top;i++)ans=1ll*ans*f[n][stk[i]]%Mod;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 19840
//Only the Creator has given me strength!

#include<cstdio>

#include<sstream>

#include<cstdlib>

#include<cctype>

#include<cmath>

#include<algorithm>

#include<set>

#include<queue>

#include<stack>

#include<list>

#include<iostream>

#include<fstream>

#include<numeric>

#include<string>

#include<vector>

#include<cstring>

#include<map>

#include<iterator>

#include<bitset>

typedef long long ll;

#define pi 3.1415926535897931159979635

#define pb push_back

#define vctr vector < int >

#define vvtr vector < vctr >

using namespace std;

void fastio() {

    ios::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);

}

int main() {

    fastio();

    string a,b;

    cin>>a>>b;

    int len=a.size(),total=b.size(),m=0;

    for(int i=0; i+total<=len; i++) {

        int t=0;

        for(int j=i,k=0; j<i+total; j++,k++) {

            if(a[j]==b[k]) t++;

        }

        if(t>m) m=t;

    }

    cout<<total-m<<"\n";

    return 0;

}

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

double H[1200];

int main(void){
  int N;
  double T,A;
  cin >> N >> T >> A;

  for(int i=0; i<N; i++) {
    double x;
    cin >> x;

    double a = (T - x * 0.006);

    H[i] = a;
  }

  vector<double> vec(H,H+N);

  for(int i=0; i<N; i++){
    vec.at(i) -= A;
    vec.at(i) = abs(vec.at(i));
  }

  vector<double>::iterator min = min_element(vec.begin(), vec.end());
  size_t index = distance(vec.begin(), min);

  cout << index+1 << endl;

  return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }




long long a, b;
int main() {
    while (cin >> a >> b) {
        if (b % a == 0) cout << a + b << endl;
        else cout << b-a << endl;
    }
}













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

using namespace std;

#define pb push_back
#define mp make_pair

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;

const int MOD = 1e9+7;
const int INF = 1e9+10;
const int MAX_N = 1000;

int main() {
  int N; cin >> N;
  vi a(MAX_N), order, rest_order;
  vvi use(2, vi(MAX_N, 0));
  ll ans[2] = {0, 0}, mx = -INF, idx;

  for (int i = 0; i < N; i++) {
    cin >> a[i];
    if (a[i] > mx) {
      mx = a[i];
      idx = i;
    }
    if (a[i] >= 0) {
      use[i&1][i] = 1;
      ans[i&1] += a[i];
    }
  }
  use[0][N] = use[1][N] = 1;

  // for (int i = 0; i < 2; i++) {
  //   for (int j = 0; j < N; j++) {
  //     cout << (use[i][j]?"1":"0");
  //   } cout << endl;
  // }

  if (mx < 0) {
    cout << mx << endl;
    cout << N-1 << endl;
    for (int i = 0; i < idx; i++) cout << 1 << endl;
    for (int i = idx+1; i < N; i++) cout << N-i+1 << endl;
  } else {
    int ind = ans[0] > ans[1] ? 0 : 1;
    int l = 0, r = N-1;
    for (int i = l; i < N; i++) {
      if (use[ind][i] == 0) {
        order.pb(1);
        l++;
      } else {
        break;
      }
    }
    for (int i = N-1; i >= 0; i--) {
      if (use[ind][i] == 0) {
        rest_order.pb(i+1);
        r--;
      } else {
        break;
      }
    }
    int cnt = 0;
    for (int i = l+1; i <= r; i++) {
      if (use[ind][i] == 0) {
        cnt++;
      } else {
        while (cnt > 0) {
          order.pb((cnt+1)/2 + 1);
          cnt -= 2;
        }
        cnt = 0;
      }
    }
    cout << ans[ind] << endl;
    cout << order.size()+rest_order.size() << endl;
    for (int i = 0; i < rest_order.size(); i++) {
      cout << rest_order[i] << endl;
    }
    for (int i = 0; i < order.size(); i++) {
      cout << order[i] << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
#import numpy as np
from decimal import *

H, W = MAP()
A = [input() for _ in range(H)]
cnt = [[0]*W for _ in range(H)]
q = deque()

for y in range(H):
    for x in range(W):
        if A[y][x] == "#":
            q.append((y, x))

dy = [1, 0, -1, 0]
dx = [0, -1, 0, 1]

while q:
    y, x = q.popleft()
    for Dy, Dx in zip(dy, dx):
        ny = y + Dy
        nx = x + Dx
        if 0 <= ny < H and 0 <= nx < W and cnt[ny][nx] == 0 and A[ny][nx] == ".":
            cnt[ny][nx] = cnt[y][x] + 1
            q.append((ny, nx))

ans = 0
for i in range(H):
    ans = max(ans, max(cnt[i]))
print(ans)

Measured memory_bytes: 120432
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
  
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
template<class T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
        
const int  N = 2e5 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-9;
const long long LINF = 1e18 + 3141;
ll f[N];
ll bp(ll a, ll n){
    ll res = 1;
    while(n) {
        if(n & 1)
            res = (res * a) % MOD;
        a = (a * a) % MOD;
        n >>= 1;
    }
    return res;
    
}
ll inv(ll n){
    return bp(n,MOD - 2);
}
ll c(ll n, ll k) {
    if(n < k)
        return 0;
    return ((f[n] * inv(f[n - k])) % MOD * inv(f[k])) % MOD;
}
ll a[N], n, k;
void solve(){
    cin >> n >> k;
    mset <int> s;
    for(int i = 1; i <= n; ++i) {
        cin >> a[i];
    }    
    if(k == 1){
        cout << 0;
        return;
    } 
    sort(a + 1, a + n + 1);
    ll ans = 0;
    for(int i = k; i <= n; ++i) {
        ans += (a[i] * c(i - 1, k - 1)) % MOD;
        ans %= MOD;
    }
    for(int i = 1; i <= n; ++i) {
        ans -= (a[i] * c(n - i, k - 1)) % MOD; 
        ans = (ans + MOD) % MOD;
    }
    cout << ans;
    
    
}
 
int main(){
    speed();
    int t = 1;
    f[0] = 1;
    for(int i = 1; i < N; ++i)  
        f[i] = (f[i - 1] * i) % MOD;
    // cin >> t;
    while(t--)solve();
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

const int INF = 1<<30;

int main(){
  int n;cin>>n;
  vector<vector<pair<int, bool>>> tes(n);
  rep(i, n){
  	int a;cin>>a;
    rep(j, a){
      int x, y;cin>>x>>y;
      tes[i].push_back(make_pair(--x, y==1));
    }
  }
  int ans=-1;
  rep(i, 1<<n){
    bool contradict=false;
    int cnt=0;
  	rep(j, n){
      cnt += bool((i>>j)&1);
      if(!bool((i>>j)&1))continue;
      for(auto& e: tes[j]){
        bool honest = (i>>e.first)&1;
	    if(honest!=e.second){contradict=true;break;}
      }
      if(contradict)break;
    }
    if(!contradict)ans=max(ans, cnt);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long i64;
typedef pair<i64,i64> P;


int n,k;
string s;

int main(){
	cin >> n >> k;
	cin >> s;
	
	for(int i = 0; i < n; i++){
		if(i +1 == k) cout << (char)('a'+s[i]-'A');
		else cout << s[i];
	}
	cout << endl;
	
	return 0;
}

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

int dx[] = {-1, 0, 1};
int dy[] = {-1, 0, 1};

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<char>> s(h, vector<char>(w, 0));
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cin >> s.at(i).at(j);
        }
    }
    
    vector<vector<int>> ans(h, vector<int>(w, 0));
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (s.at(i).at(j) == '#') continue;

            int cnt = 0;
            for (int x = 0; x < 3; x++)
            {
                for (int y = 0; y < 3; y++)
                {
                    if (i + dy[y] < 0 || i + dy[y] >= h || j + dx[x] < 0 || j + dx[x] >= w) continue; 
                    if (s.at(i + dy[y]).at(j + dx[x]) == '#') cnt++;
                }
            }
            ans.at(i).at(j) = cnt;
        }
    }
    
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (s.at(i).at(j) == '#') cout << '#';
            else cout << ans.at(i).at(j);
        }
        cout << endl;
    }
    
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define INF 1<<30

int main() {
  int N = 1000000;
  bool dp[N+1];
  dp[1] = true;
  for (int i=2; i<=N; ++i) {
    if (i%2==0&&dp[i/2] || i%3==0&&dp[i/3] || i%5==0&&dp[i/5]) {
      dp[i] = true;
    } else {
      dp[i] = false;
    }
  }
  int m,n;
  while(cin>>m,m) {
    cin >> n;
    cout << count(dp+m, dp+n+1, true) << endl;
  }
}

Measured memory_bytes: 0
l=[]
lp=[10]
for i in range(5):
    l.append(int(input()))
    if l[i]%10!=0:
        lp.append(l[i]%10)
lp_min=min(lp)
if lp_min==10:
    lp_min=0
ans=0
for i in range(5):
    ans+=-(-l[i]//10)*10
if lp_min!=0:
    ans=ans-10+lp_min
print(ans)

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

int m[110][110];

int main(){
  int w, h, n; cin >> w >> h >> n;
  for (int ni = 0; ni < n; ni++) {
    int a, x, y; cin >> x >> y >> a;
    switch(a) {
      case 1:
        for (int i = 0; i < h; i++) {
          m[i][0]++;
          m[i][x]--;
        }
        break;
      case 2:
        for (int i = 0; i < h; i++) {
          m[i][x]++;
          m[i][w]--;
        }
        break;
      case 3:
        for (int i = 0; i < w; i++) {
          m[0][i]++;
          m[y][i]--;
        }
        break;
      case 4:
        for (int i = 0; i < w; i++) {
          m[y][i]++;
          m[h][i]--;
        }
        break;
    }
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      m[i][j+1] += m[i][j];
    }
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      m[i+1][j] += m[i][j];
    }
  }
  int count = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (m[i][j] == 0) count++;
      //cout << m[i][j] << " ";
    }
    //cout << endl;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

import java.lang.*;

import java.math.*;



public class Main {

	

	class P{

		double x;

		double y;

		P(double x,double y){

			this.x =x;

			this.y = y;

		}

		P norm(){

			return new P(x/Math.sqrt(x*x+ y*y),y/Math.sqrt(x*x+ y*y));

		}

		

		double g(P p){

			P r = p.norm();//³K»

			return -r.x*this.y+r.y*this.x; //ñ]µÄCyÀWªãÉé©ºÉé©

		}

		

	}

	

	Scanner sc = new Scanner(System.in);

	void run(){

		for(;sc.hasNextLine();){

			String buffer=  sc.nextLine();

			Scanner in = new Scanner(buffer.replace(',', ' '));

			P[] point = new P[4];

			for(int i = 0; i < 4; i ++){

				double c = in.nextDouble();

				double d = in.nextDouble();

				point[i] = new P(c,d);

			}

			P[] d = new P[4];

			for(int i = 0; i < 4; i ++){

				d[i] = new P(point[(i+1)&3].x-point[i].x,point[(i+1)&3].y-point[i].y);

			}

			double c[] = new double[4];

			for(int i=0;i<4;i++){

				c[i] = d[i].g(d[(i+1)&3]);

//				System.out.println(c[i]);

			}

			boolean ret=true;

			for(int i = 1; i < 4;i++){

				ret = (c[i]*c[i-1] > 0)&&ret ;

			}

			System.out.println(ret?"YES":"NO");

		}

		

	}

	public static void main(String[] args){

		Main m = new Main();

		m.run();

		

	}

}

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

const int con = 1e18+10;

//二分探索でA[i]を固定した時のA[j]の個数を求めていく

int sage(int a, int b){ // 負数込みのfloor
  
  int c = abs(a); int d = abs(b);
  
  if( a >= 0 && b >= 0 ){ return c/d;}
  else if( a >= 0 && b < 0 ){ return -(c+d-1)/d;}
  else if( a < 0 && b >= 0 ){ return -(c+d-1)/d;}
  else{ return c/d;} //ここは実際には使わない
}

int age(int a, int b){ // 負数込みのceil
  
  int c = abs(a); int d = abs(b);
  if( a >= 0 && b >= 0 ){ return (c+d-1)/d;}//ここは使わない
  else if( a >= 0 && b < 0 ){ return -c/d;}
  else if( a < 0 && b >= 0 ){ return -c/d;}
  else{ return (c+d-1)/d;} 
}

signed main(void){
  
  int N,K; cin >> N >> K;
  
  vector<int> A(N);
  for(int i = 0; i < N; i++){ cin >> A[i];}
  
  sort(A.begin(),A.end());
  
  int left = -con; int right = con;

  while( right - left > 1 ){ 
    
    int mid = sage(left+right,2);
    
    int cnt = 0;
    
    for(int i = 0; i < N; i++){ 
      //片方を固定した時の、 A[i]*A[j] <= midなるj(!=i)の個数を求めたい
      int val;
      if( A[i] == 0 ){ //この時、A[j]がなんであっても必ず0
        if( mid >= 0 ){ cnt += N-1;}
        else{ cnt += 0;}
        continue;
      }
             
                       
      else if( A[i] > 0 ){ 
        val = sage(mid,A[i]); //負数込みのfloor
        // 以降、 A[j] <= valの範囲を求めていく
        
        int itr = upper_bound(A.begin(),A.end(),val)-A.begin();
        
        cnt += itr;
     
                          
      }                
      else{ 
        val = age(mid,A[i]);
        //以降、 A[j] >= valの範囲を求めていく
        int itr = lower_bound(A.begin(),A.end(),val)-A.begin();
       
        cnt += N-itr;
        
      }
      
      
      if( A[i]*A[i] <= mid ){ cnt--;}// j == iの場合を除く
    
     
    }
    // for-i
    
    cnt /= 2;
    
    if( cnt >= K ){ //midはK番目以上
      right = mid;
    }
    else{
      left = mid;
    }
    
  }
  
  cout << right << endl;
  
  return 0;
}

Measured memory_bytes: 1792
N = int(input())

def fes(cul='0'):
    if int(cul) > N:
        return 0 
    counter = 0
    if "3" in cul and "5" in cul and "7" in cul:
        counter += 1
    counter += fes(cul + "3")
    counter += fes(cul + "5")
    counter += fes(cul + "7")

    return counter

print(fes())

Measured memory_bytes: 3060
from collections import defaultdict
from heapq import heappop, heappush

YEN = 10**15
INF = float('inf')


class Graph:
    def __init__(self):
        self.__graph = defaultdict(list)

    def add_edge(self, source, destination, cost):
        self.__graph[source].append((destination, cost))
        self.__graph[destination].append((source, cost))

    @property
    def graph(self):
        return self.__graph


class Dijkstra:
    def __init__(self, graph, source):
        self.__costs = defaultdict(lambda: INF)
        costs = self.__costs
        costs[source] = 0
        g = graph.graph
        q = []
        heappush(q, (costs[source], source))

        while q:
            cp, p = heappop(q)
            if costs[p] < cp:
                continue
            for dst, cost in g[p]:
                alternative = cp + cost
                if costs[dst] > alternative:
                    costs[dst] = alternative
                    heappush(q, (alternative, dst))

    @property
    def costs(self):
        return self.__costs


def spline(func_=int, iter_=None):
    if iter_ is None:
        iter_ = input().split()
    return map(func_, iter_)


def main():
    n, m, s, t = spline()
    g_yen = Graph()
    g_snuuk = Graph()
    for _ in range(m):
        u, v, cost, b = spline()
        g_yen.add_edge(u, v, cost)
        g_snuuk.add_edge(u, v, b)
    d_s = Dijkstra(g_yen, s).costs
    d_t = Dijkstra(g_snuuk, t).costs
    costs = [0] * n
    min_cost = INF
    for i in range(n, 0, -1):
        min_cost = min(min_cost, d_s[i] + d_t[i])
        costs[i - 1] = min_cost
    for cost in map(lambda x: YEN - x, costs):
        print(cost)


if __name__ == "__main__":
    main()


Measured memory_bytes: 102680
#include <stdio.h>
#include <vector>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <cstring>
using namespace std;
using ll = long long;

int main(){
  ll n,q;
  scanf("%d%d\n",&n,&q );
  ll bucket[1001];
  memset(bucket,0,8008);
  ll sum[100001];
  memset(sum,0,800008);
  ll a[100001];
  memset(a,0,800008);
  ll bumax = n/320;
  for (ll i = 0; i < q; i++) {
    ll com,x,y;
    scanf("%d%d%d\n",&com,&x,&y );
    if (com == 0) {
      //add
      a[x] += y;
      for (ll j = (x+319)/320 ; j <= bumax; j++) {
        bucket[j] += y;
      }
    } else {
      //get
      sum[y] = bucket[(y-1)/320];
      for (ll j = (y-1)/320*320+1; j <= y; j++) {
        sum[y] += a[j];
      }
      --x;
      sum[x] = bucket[(x-1)/320];
      for (ll j = (x-1)/320*320+1; j <= x; j++) {
        sum[x] += a[j];
      }
      
      printf("%lld\n",sum[y]-sum[x] );
    }
  }
  return 0;
}


Measured memory_bytes: 4796
# 行列と列ベクトルの積を求めるプログラム
import sys

# 標準入力からデータを読み込む
def read_data():
    n, m = [int(i) for i in sys.stdin.readline().strip().split(' ')]
    matrix = []
    for _ in range(n):
        matrix.append([int(num) for num in sys.stdin.readline().strip().split(' ')])

    vector = []
    for _ in range(m):
        vector.append(int(sys.stdin.readline().strip()))

    return matrix, vector

# 行列xベクトルの計算
def multiple(matrix, vector):
    n = len(matrix)
    m = len(vector)
    ans = []

    for i in range(n):
        sum = 0
        for j in range(m):
            sum += (matrix[i][j] * vector[j])

        ans.append(sum)

    return ans

# メイン関数
def main():
    matrix, vector = read_data()
    ans = multiple(matrix, vector)
    for i in ans:
        print(i)
        
if __name__ == '__main__':
    main()


Measured memory_bytes: 5944
#include "bits/stdc++.h"

using namespace std;
using ll = long long;

int main() {
    int n; cin >> n;
    int a[n];

    ll sum = 0;
    map <ll, ll> cnt;
    for (int i = 0; i < n; i++) {
        ll x; cin >> x;
        sum += x;
        cnt[x]++;
    }

    int q; cin >> q;
    while (q--) {
        ll b, c; cin >> b >> c;
        sum -= (cnt[b] * b);
        sum += (cnt[b] * c);
        cnt[c] += cnt[b];
        cnt[b] = 0;
        cout << sum << endl;
    }

}


Measured memory_bytes: 9368
#!usr/bin/env python3

from math import floor


def string_two_numbers_spliter():
    a, b = [int(i) for i in input().split()]
    return a, b


def main():
    a, b = string_two_numbers_spliter()
    print('%d %d %f' % (floor(a/b), a%b, a/b))


if __name__ == '__main__':
    main()

Measured memory_bytes: 7800
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin >> n;
  string s[n];
  map<string,int> m;
  for(int i=0;i<n;i++)
  {
    cin >> s[i];
  }
  for(int i=0;i<n;i++)
  {
    m[s[i]]++;
  }
  cout << m.size() << endl;
  return 0;
}


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

pair<int, int> solve(int A, int B, int C, int D, int E, int F){
    vector<bool> sugar(F + 1);
    vector<bool> water(F + 1);
    for (int s = 0; s <= F; s += C) sugar[s] = true;
    for (int s = 0; s + D <= F; ++s) if (sugar[s]) sugar[s + D] = true;
    vector<int> sugars;
    for (int s = 0; s <= F; ++s) if (sugar[s]) sugars.push_back(s);
    for (int w = 0; w <= F; w += 100 * A) water[w] = true;
    for (int w = 0; w + 100 * B <= F; w += 100) if (water[w]) water[w + 100 * B] = true;
    vector<int> waters;
    for (int w = 0; w <= F; w += 100) if (water[w]) waters.push_back(w);
    int best_s = 0;
    int best_w = 100 * A;
    for (auto w : waters){
        for (auto s : sugars){
            if (w + s > F) continue;
            if (E * w < s * 100) continue;
            if (best_s * w < s * best_w){
                best_s = s;
                best_w = w;
            }
        }
    }
//    int idx_s = 0;
//    for (int w = 100; w + sugars[idx_s] <= F; w += 100){
//        if (not water[w]) continue;
//        while (idx_s < sugars.size() and E * w / 100 >= valid_sugar[idx_s]) ++idx_s;
//        if (idx_s == valid_sugar.size()) --idx_s;
//        if (valid_sugar[idx_s] > E * w / 100) --idx_s;
//        if (valid_sugar[idx_s] * best_w > best_s * w){
//            best_s = valid_sugar[idx_s];
//            best_w = w;
//        }
//    }
    return make_pair(best_s + best_w, best_s);
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;
    int M, S;
    tie(M, S) = solve(A, B, C, D, E, F);
    cout << M << ' ' << S << endl;
    return 0;
}

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

#define FOR(i , num) for(i = 0; i < num; i++)
#define REP(i, n) for(int i = 0;i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()

using namespace std;

int main()
{
    int N, i;

    long long int A[100000];
    
    cin >> N;

    bool include_zero = false;

    REP(i, N)
    {
        cin >> A[i];

        if(A[i] == 0)
        {
            include_zero = true;
        }
    }

    unsigned long long int res = 1;
    bool is_over = false;
    REP(i, N)
    {
        long long int next = A[i];
        float next_rank = log10f128(next);

        float res_rank = log10f128(res);

        if(next_rank + res_rank < 18.1)
        {
            res *= next;

            if(res > 1000000000000000000)
            {
                is_over = true;
                break;
            }
        }
        else
        {
            is_over = true;
            break;
        }        
    }

    if(include_zero)
    {
        cout << 0 << endl;
    }
    else if(is_over)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << res << endl;
    }
    



    return 0;   
}

Measured memory_bytes: 4828
#include <stdio.h>

int main()
{
    int A, B;
    scanf("%d%d", &A, &B);
    if((B-1)%(A-1) == 0){
        printf("%d\n", (B-1)/(A-1));
    } else {
        printf("%d\n", (B-1)/(A-1)+1);
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
// #include <atcoder/all>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
template <class T>
inline bool chmin(T &a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}

ll gcd(ll n, ll m)
{
	ll tmp;
	while (m != 0)
	{
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;
//using namespace atcoder;

void solve(){
	int n;
	cin>>n;
	vector<ll>a(n),b(n);
	rep(i,n)cin>>a[i];
	rep(i,n)cin>>b[i];
	int pos=0;
	rep(i,n){
		if(a[i]==b[i]){
			while(pos<n){
				if(a[i]!=b[pos]&&a[pos]!=b[i]){
					swap(b[i],b[pos]);
					break;
				}
				++pos;
			}
		}
	}
	bool ng=false;
	rep(i,n)if(a[i]==b[i])ng=true;
	if(ng){
		pos=0;
		rep(i,n){
			if(a[i]==b[i]){
				while(pos<n){
					if(a[i]!=b[pos]&&a[pos]!=b[i]){
						swap(b[i],b[pos]);
						break;
					}
					++pos;
				}
			}
		}
		ng=false;
		rep(i,n)if(a[i]==b[i])ng=true;
		if(ng)cout<<"No\n";
		else{
			cout<<"Yes\n";
			rep(i,n){
				if(i)cout<<" ";
				cout<<b[i];
			}
			cout<<"\n";
		}
	}
	else{
		cout<<"Yes\n";
		rep(i,n){
			if(i)cout<<" ";
			cout<<b[i];
		}
		cout<<"\n";
	}
}


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


Measured memory_bytes: 6344
N = int(input())
A = [0] + list(map(int, input().split()))

dp = [0] * (N+1)
dp[1] = 1000
for i in range(2, N+1):
    dp[i] = dp[i-1]
    for j in range(1, i):
        stock = dp[j] // A[j]
        momey = dp[j] + (A[i] - A[j]) * stock
        dp[i] = max(dp[i], momey)
print(dp[N])

Measured memory_bytes: 9144
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug: "<<x<<" "<<y<<endl;
using namespace std;
typedef unsigned long long ll;
const int maxn = 100005;

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int sum = 0;
  int n,m;
  cin>>n>>m;
  for(int i=1;i<=n;i++)sum+=m+i-1;
  int diff = -1,ret;
  for(int i=1;i<=n;i++){
    int tt = abs(m+i-1);
    if(diff==-1||diff>tt){
      diff=tt;
      ret=sum-(m+i-1);
    }
  }
  cout<<ret<<endl;
  return 0;
}

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

using namespace std;


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

  vector<long> x(n);
 
    for(int i=0;i<n;i++) cin >> x[i];
                     
  long res=1000000000;
  
   for(int i=0;i<=n-k;i++){
    res=min(res,abs(x[i])+abs(x[i+k-1]-x[i]));
   }
   for(int i=0;i<=n-k;i++){
    res=min(res,abs(x[i+k-1])+abs(x[i+k-1]-x[i]));
   }
  
  
  cout << res << endl;
}

Measured memory_bytes: 1024
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author NikuKyabe
 */

#include "bits/stdc++.h"
using namespace std;


class ADontBeLate {
public:
	void solve(std::istream& in, std::ostream& out) {
    double d,t,s;
    in >> d >> t >> s;
    if(t >= d / s) out << "Yes" << endl;
    else out << "No" << endl;
	}
};


signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout << fixed;
	ADontBeLate solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3732
def main(D, T, S):
    time = D//S
    if D%S != 0:
        time += 1
    if time <= T:
        return 'Yes'
    else:
        return 'No'

if __name__ == '__main__':
    D, T, S = map(int, input().split())
    ans = main(D, T, S)
    print(ans)



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

using namespace std;

#define mp make_pair
#define F first
#define S second
#define pb push_back
#define fo(i, n) for(int i = 1; i <= n; ++i)

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

const int N = 200200;
const int mod = 1e9 + 7;
int n, a[N];
vector<int> bad, good, other;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	fo(i, n)
	{
		cin >> a[i];
		if(a[i] % 2)
			bad.pb(a[i]);
		else if(a[i] % 4 == 0)
			good.pb(a[i]);
		else 
			other.pb(a[i]);
	}
	if(bad.size() > good.size() + 1)
		return cout << "No", 0;
	if(bad.size() == good.size() + 1 && other.size())
		return cout << "No", 0;
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 1404
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var l1 = ReadIntArray();
        var hp = l1[0];
        var sp_damage_list = ReadIntArray();

        var damage_total = sp_damage_list.Sum();
        Console.WriteLine(hp > damage_total ? "No" : "Yes");
    }

    static string[] ReadStringArray()
    {
        return Console.ReadLine().Trim().Split(' ');
    }

    static int[] ReadIntArray()
    {
        return ReadStringArray().Select(_ => int.Parse(_)).ToArray();
    }
}
 


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

using namespace std;
const int maxn = 3*1e3 + 7;
int dp[maxn];
int main()
{   
    //  freopen("input.txt","r",stdin);
    //  freopen("output.txt","w",stdout);
    string s1,s2;
    cin >>s1 >>s2;
    int n,m;
    n = (int) s1.length();
    m = (int) s2.length();
    vector< vector<int> > dp(n+1,vector<int>(m+1,0));
    for(int i = 1;i<=n;i++) {
        for(int j = 1;j<=m;j++) {
            if(s1[i-1]==s2[j-1]) dp[i][j] = dp[i-1][j-1] +1;
            else dp[i][j] = max(dp[i][j-1],dp[i-1][j]); 
        }
    }
    int i = n,j = m;
    string ans = "";
    while(i>0&&j>0) {
        if(s1[i-1]==s2[j-1]) {
          ans=ans + s1[i-1];
          i--;
          j--;
        }
        else {
            if(dp[i-1][j]>dp[i][j-1]) i--;
            else j--;
        }
    }
    reverse(ans.begin(),ans.end());
    cout <<ans<<'\n';
    return 0;
}



Measured memory_bytes: 38980
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define println(x) cout << x << endl
#define fi first
#define se second
#define Yes println("Yes")
#define No println("No")
#define YES println("YES")
#define NO println("NO")

using pii = pair<int, int>;

struct Robot
{
    int x;
    int s;
    int t;
    Robot(int x, int l)
    {
        x = x;
        s = x - l;
        t = x + l;
    }
    bool covers(Robot& r1)
    {
        return t > r1.s;
    }
};

bool operator<(const Robot& r1, const Robot& r2)
{
    return r1.t < r2.t;
}

int main()
{
    int n;
    cin >> n;
    vector<Robot> vr;
    rep(i, n)
    {
        int x, l;
        cin >> x >> l;
        Robot r = Robot(x, l);
        vr.push_back(r);
    }
    sort(all(vr));
    int count = n;
    Robot prev = vr[0];
    rep2(i, 1, n)
    {
        if (prev.covers(vr[i])) count--;
        else prev = vr[i];
    }
    println(count);
}

Measured memory_bytes: 1912
#include <iostream>
#include <string>
#include <vector>

using namespace std;



int main()
{
	string s, t = "keyence";
	cin >> s;
	
	for (int i = 0; i < s.length(); i++) {
		for (int j = i - 1; j < s.length(); j++) {
			if (s.substr(0, i) + s.substr(j + 1, s.length() - j + 1) == t) {
				cout << "YES" << endl;
				return 0;
			}
		}
	}
	cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define rrep(i,m,n) for(int i = m; i >= n; i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
typedef struct{
    ll to;
    ll cost;
} edge;
typedef pair<ll, ll> lpair;
ll dp[110][100010] = {};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,W;
    ll w[110], v[110];
    cin >> N >> W;
    rep(i,0,N){
        cin >> w[i] >> v[i];
    }
    rep(i,0,N+1){
        rep(j,0,100010){
            dp[i][j] = INF;
        }

    }
    dp[0][0] = 0;
    rep(i,0,N){
        rep(j,0,100010){
            if(j - v[i] >= 0){
                dp[i+1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]);
            }else{
                dp[i+1][j] = dp[i][j];
            }
        }
    }
    ll ans = 0;
    rep(i,0,100010){
        if(dp[N][i] <= W){
            ans = i;
        }
    }
    print(ans);
}


Measured memory_bytes: 80128
let js = Array.make 10 true
let rec f n = if n <= 9 then js.(n) else js.(n mod 10) && f (n / 10)
let _ = Scanf.scanf " %d %d" @@ fun n k -> for _ = 1 to k do js.(Scanf.scanf " %d" (+) 0) <- false done; for i = n to 100000 do if f i then (Printf.printf "%d\n" i; exit 0) done

Measured memory_bytes: 384
s = input()
tmp = "keyence"
# if s == "keyence":
#     print("YES")
#     exit()
for i in range(len(s)):
    for j in range(i, len(s)):
        tmp2 = s[:i] + s[j:]
        if tmp2 == "keyence":
            print("YES")
            exit()
else:
    print("NO")

Measured memory_bytes: 3060