akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define MAX 200
#define inf 1<<29
#define linf 1e18
#define eps (1e-8)
#define mod 1000000007
#define pi M_PI
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.9f\n",(double)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<double,int> pdi;
typedef vector<int> vi;
typedef vector<pii> vpi;

int V,m,a;
vector<int> G[MAX];
vector<int> rG[MAX];
vector<int> vs;
bool used[MAX];
int cmp[MAX];
double p[MAX],ip[MAX];

void init(){
  FOR(i,0,MAX){
    G[i].clear();
    rG[i].clear();
    p[i]=1.0;
    ip[i]=0.0;
  }
}

void add_edge(int from, int to){
  G[from].push_back(to);
  rG[to].push_back(from);
}
  
void dfs(int v){
  used[v] = true;
  for(int i = 0;i < G[v].size();i++){
    if(!used[G[v][i]])dfs(G[v][i]);
  }
  vs.push_back(v);
}
  
void rdfs(int v,int k){
  used[v] = true;
  cmp[v] = k;
  for(int i = 0;i < rG[v].size();i++){
    if(!used[rG[v][i]]) rdfs(rG[v][i],k);
  }
}
  
void scc(){
  memset(used,0,sizeof(used));
  vs.clear();
  for(int v = 0;v < V;v++){
    if(!used[v]) dfs(v);
  }
  memset(used,0,sizeof(used));
  int k = 0;
  for(int i = vs.size() - 1;i >= 0;i--){
    if(!used[vs[i]])rdfs(vs[i],k++);
  }
  return;
}

void solve(){
  double res=1.0;
  map<int,vector<int> > mp;
  FOR(i,0,V)mp[cmp[i]].pb(i);
  FOR(i,0,V)FOR(j,0,V)if(cmp[i]==cmp[j])p[i]*=ip[j];
  FOR(i,0,V){
    vector<int> v=mp[i];
    if(v.size()==0)continue;
    bool flag=true;
    FOR(j,0,v.size()){
      int now=v[j];
      FOR(k,0,rG[now].size()){
        int next=rG[now][k];
        if(cmp[next]!=i)flag=false;
      }
    }
    if(flag)res*=(1.0-p[v[0]]);
  }
  pd(res);
}

int main()
{
  while(1){
    cin>>V;
    if(V==0)break;
    init();
    FOR(i,0,V){
      cin>>ip[i]>>m;
      FOR(j,0,m){
        cin>>a;
        add_edge(i,a-1);
      }
    }
    scc();
    solve();
  }
  return 0;
}

Measured memory_bytes: 3376
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n,0);
  int min_cost=1001001;
  for(int i=0;i<n;i++){
     cin>>a[i];
  }
  for(int i=-100;i<=100;i++){
    int cost=0;
    for(int j=0;j<n;j++){
      int re=i-a[j];
      cost+=pow(re,2);
    }
    min_cost=min(min_cost,cost);
  }
  cout<<min_cost<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define N int(1e5)
#define MP make_pair
	int x, y, ndir = 0, cnt = 0, dp[8001][8001] = {}, maxx = 0, maxy = 0;
	string s;
	vector<int> dircnt[2];
int main(void)
{

	cin >> s;
	cin >> x >> y;
	y = abs(y);
	for(int i = 0; i < s.size(); ++i)
	{

		if(s[i]=='F')
		{
			cnt++;
		}
		else
		{
			dircnt[ndir%2].push_back(cnt);
			cnt = 0;
			++ndir;
		}
	}
	dircnt[ndir % 2].push_back(cnt);
	x -= dircnt[0][0];
	x = abs(x);
	for(int i = 1; i < dircnt[0].size(); ++i)
	{
		maxx += dircnt[0][i];
	}
	for(int i = 0; i < dircnt[1].size(); ++i)
	{
		maxy += dircnt[1][i];
	}
	maxx -= x;
	maxy -= y;
	if(maxx % 2 || maxy % 2 || maxx < 0 || maxy < 0)
	{
		cout << "No" << endl;
		return 0;
	}
	maxx /= 2;
	maxy /= 2;
	dp[1][0] = 1;
	for(int i = 1; i < dircnt[0].size(); ++i)
	{
		for(int j = 0; j <= maxx; ++j)
		{
			if(dp[i][j])
			{
				dp[i + 1][j + dircnt[0][i]] = 1;
				dp[i + 1][j] = 1;
			}
		}
	}
	if(!dp[dircnt[0].size()][maxx])
	{
		cout << "No"  << endl;
		return 0;
	}
	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1;
	for(int i = 0; i < dircnt[1].size(); ++i)
	{
		for(int j = 0; j <= maxy; j++)
		{
			if(dp[i][j])
			{
				dp[i + 1][j + dircnt[1][i]] = 1;
				dp[i + 1][j] = 1;
			}
		}
	}
	if(!dp[dircnt[1].size()][maxy])
	{
		cout << "No"  << endl;
		return 0;
	}
	
	cout << "Yes" << endl;
	return 0;
}


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

int main()
{
	string s;
	cin >> s;
	int cnt = 0; //(グーの数) - (パーの数)
	int ans = 0;
	rep(i,s.size())
	{
		if (s[i] == 'g') cnt++;
		else cnt--;
	}
	cout << cnt/2 << endl;
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<sstream>
using namespace std;
int s2i(string str){
  istringstream iss(str);
  int x;iss >> x;
  return x;
}
int main(){
  int r=0,q=0;
  string str;
  while(cin >> str){
    for(int i=0;i<str.size();i++) if(str[i]==',') str[i]=' ';
    stringstream ss(str);
    int a,b,c; ss >> a >> b >> c;
    if(a*a+b*b==c*c) r++;
    if(a==b) q++;

  }

  cout << r << endl << q << endl;
}

Measured memory_bytes: 1216
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cassert>
#include <cctype>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> PLL;

typedef string::iterator State;

const LL MOD = 1000000007;

string expression;

void sp(State&);
LL number(State&);
LL term(State&);
LL sExpr(State&);
LL expr(State&);

void sp(State& s) {
    while (s != end(expression) && *s == ' ') ++s;
}

LL number(State& s) {
    sp(s);
    LL ret = 0;
    for (; s != end(expression) && isdigit(*s); ++s) {
        ret *= 10;
        ret += *s - '0';
    }
    return ret;
}

LL sExpr(State& s) {
    sp(s);
    ++s; // S
    sp(s);
    ++s; // <
    LL v = expr(s);
    sp(s);
    ++s; // >
    return (v * v) % MOD;
}

LL term(State& s) {
    sp(s);
    if (isdigit(*s)) {
        return number(s);
    }
    return sExpr(s);
}

bool nextRShift(State s) {
    int count = 0;
    sp(s);
    while(s != end(expression) && *s == '>') {
        ++count;
        ++s;
    }
    sp(s);
    return s != end(expression) && *s != '>' && count == 2;
}

LL expr(State& s) {
    sp(s);
    LL t = term(s);
    sp(s);
    while (s != end(expression) && *s == '>') {
        if (!nextRShift(s)) {
            return t;
        }
        ++s; ++s; // >>

        LL u = term(s);
        if (u >= 32) {
            t = 0;
        } else {
            t /= pow(2LL, u);
        }
        sp(s);
    }
    return t;
}

bool solve() {
    getline(cin, expression);
    if (expression == "#") { return false; }
    State iter = begin(expression);
    cout << expr(iter) << endl;
    return true;
}

int main() {
    while(solve());
    return 0;
}

Measured memory_bytes: 5552
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n, m;
	while(cin >> n >> m, n){
		int ans = 0, sum = 0;
		set<int> s;
		s.insert(0);
		rep(i, n){
			int x; cin >> x; x %= m;
			sum = (sum + x) % m;
			s.insert(sum);
			
			auto it = s.upper_bound(sum);
			if(it != s.end()) ans = max(ans, (sum + m - *it) % m);
			ans = max(ans, sum);
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 4244
#include <bits/stdc++.h>
#define push(x) st[++top] = x;

typedef long long ll;

inline ll read()
{
    ll w = 0, t = 1;
    char ch = getchar();
    while (ch > '9' || ch < '0') { if (ch == '-') t = -1; ch = getchar(); }
    while (ch >= '0' && ch <= '9') { w = (w << 3) + (w << 1) + (ch ^ 48); ch = getchar(); }
    return w * t;
}

const int maxn = 1e5 + 5;

int n, m, top = 0;
ll st[maxn], f[maxn], de[maxn];//de差分

// inline int binary_search(int rest)
// {
//     int l = 1, r = top, pos = 0;
//     while (l < r) 
//     {
//         int mid = (l + r) >> 1;
//         if (rest > st[mid]) l = mid + 1, pos = mid;
//         else r = mid - 1;
//         //printf("$rest%d %d %d %d\n", rest, l, r, mid);
//     }
//     return pos;
// }

void count(ll rest, ll F) 
{
    if (!rest) return;
    // int last = binary_search(rest);
    // printf("$%d\n", last);
    int last = std::upper_bound(st + 1, st + top + 1, rest) - st - 1;
    if (last)
    {
        f[last] += rest / st[last] * F;
        count(rest % st[last], F); //(a[i] % a[i - 1]) % a[last]; 
    }

    else de[1] += F, de[rest + 1] -= F; 
}

int main()
{
    n = read();
    m = read();
    push(n);
    for (int i = 1; i <= m; i++)
    {
        ll input = read();
        while (input <= st[top]) top--; //去除无效操作
        push(input);
    }
    f[top] = 1;
    for (int i = top; i >= 2; i--)
    {
        f[i - 1] += st[i] / st[i - 1] * f[i];
        count(st[i] % st[i - 1], f[i]);
    }
    de[1] += f[1];
    de[st[1] + 1] -= f[1];
    for (int i = 1; i <= n; i++) 
    {
        de[i] += de[i - 1];
        printf("%lld\n", de[i]); // %d wa 自闭
    }
    return 0;
}

Measured memory_bytes: 5988
using namespace std;

#include<iostream>



int main(){

    string str1;
    string str2 = "abcdefghijklmnopqrstuvwxyz";
    cin >> str1;
    int k = 26;

    int num[26];

    for (int i=0;i<26;i++)
    {
        num[i] = 0;
    }

    for(int i=0;i < str1.length();i++)
    {
        for(int j=0;j < 26;j++)
        {
            if(str1[i] == str2[j])
            {
                num[j] = 1;
            }
        }
    }

    for (int k = 0;k < 27;k++)
    {
        if(k == 26)
        {
            cout << "None" << endl;
            return 0;
        }
        if(num[k] == 0)
        {
            cout << str2[k] << endl;
            return 0;
        }
        
    }

    
}

Measured memory_bytes: 512
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

import java.util.*;

public class Main {
    long MOD = (long) 1e9 + 7;

    InputStream in;
    OutputStream out;

    public Main() {
        this(System.in, System.out);
    }

    public Main(InputStream in, OutputStream out) {
        this.in = in;
        this.out = out;
    }

    void run() {
        Scanner sc = new Scanner(this.in);
        PrintWriter out = new PrintWriter(this.out);

        // write your code
        int s = sc.nextInt();
        int l = (s + 2) / 3;
        long[][] dp = new long[l + 1][s + 1];
        long[][] sum = new long[l + 1][s + 1];
        dp[0][0] = 1;
        for (int i = 0; i <= s; i++) {
            sum[0][i] = 1;
        }

//        debug(dp[0]);
//        debug(sum[0]);

        long ans = 0;
        for (int i = 1; i <= l; i++) {
            for (int j = 3 * i; j <= s; j++) {
                dp[i][j] = (sum[i - 1][j - 3]) % MOD;
                sum[i][j] = (sum[i][j - 1] + dp[i][j]) % MOD;
            }
//            debug(i, dp[i]);
//            debug(i, sum[i]);
            ans = (ans + dp[i][s]) % MOD;
        }

        out.println(ans);

        out.flush();
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}

Measured memory_bytes: 66904
n = int(input())
H = list(map(int,input().split()))
ans = "Yes"

for i in range(n-1):
    if H[i] < H[i+1]:
        H[i+1] -= 1
    
    if H[i] > H[i+1]:
        ans = "No"
        break
        
print(ans)

Measured memory_bytes: 14224
#include <iostream>
using namespace std;
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)

int main() {
	int A, B, C, X; cin >> A >> B >> C >> X;
	int cnt = 0;
	repe(i, 0, A) {
		repe(j, 0, B) {
			repe(k, 0, C) {
				if (X == 500 * i + 100 * j + 50 * k) {
					cnt++;
				}
			}
		}
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
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; }
//ミョ(-ω- ?)
int main() {
    ll l,r,k;
    cin >> l >> r >> k;
    ll res = 0;
    for(ll i = l;i <= r;i++)if(i%k == 0)res++;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3632
# import sys
# sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

from collections import deque

def solve():
    n = II()
    V = sorted(LI())
    ans = V[0]
    for i in range(1, n):
        ans = (ans + V[i]) / 2
    print(ans)

if __name__ == '__main__':
    solve()


Measured memory_bytes: 3316
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

#define INF (1000000000000000009)

int main()
{
	long long n;
	cin >> n;
	vector<long long> a(n);
	for(long long i=0;i<n;i++)
		cin >> a[i];
	vector<vector<vector<long long>>> dp(2,vector<vector<long long>>(3,vector<long long>(n,(-1)*INF)));

	dp[1][0][0]=a[0];
	dp[0][1][0]=0;

	for(int i=1;i<n;i++)
	{
		for(int j=0;j<3;j++)
		{
			dp[1][j][i]=dp[0][j][i-1]+a[i];
			if(j==0)
				dp[0][j][i]=dp[1][j][i-1];
			else
				dp[0][j][i]=max(dp[1][j][i-1],dp[0][j-1][i-1]);
		}
	}

	long long ans=(-1)*INF;
	for(int i=0;i<2;i++)
		for(int j=0;j<3;j++)
		{
			if(n%2==0 and j==2)continue;
			if(n%2==1 and j==0)continue;
//			cout << i << " " << j << " " << dp[i][j][n-1] << endl;
			if(ans<dp[i][j][n-1])
				ans=dp[i][j][n-1];
		}
	
	cout << ans << endl;


}


Measured memory_bytes: 19944
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
using namespace std;

int main() {

	long N;
	cin >> N;

	double sum = 0.0;
	vector<double> v(N, 0.0);

	for (long i = 0; i < N; i++) {
		cin >> v[i];
		sum += v[i];
	}

	sort(v.begin(), v.end(), greater<double>());

	double x, y;
	while (v.size() != 1) {
		x = v.back();
		v.pop_back();
		y = v.back();
		v.pop_back();
		v.push_back((x + y) / 2.0);
		sort(v.begin(), v.end(), greater<double>());
	}

	cout << fixed;
	cout << setprecision(6) << v[0] << endl;

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 1010
#define MOD 1000000007
using namespace std;
int n,m,a[N],b[N];
int cnt[N*N],backa[N*N],backb[N*N],line=0,row=0,writen=0,zero=0;
long long ans=1;
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]),backa[a[i]]=i,cnt[a[i]]++;
	for (int i=1;i<=m;i++) scanf("%d",&b[i]),backb[b[i]]=i,cnt[b[i]]++;
	for (int i=1;i<=n*m;i++) if (cnt[i]>2) zero=1;
	for (int i=n;i>=1;i--)
	    for (int j=m;j>=1;j--)
	    {
	    	int num=(i-1)*m+j;
	    	if (backa[num]&&backb[num])
	    	{
	    		row++;
	    		line++;
	    		writen++;
			}
			else if (backa[num])
			{
				if (line==0) zero=1;
				ans=ans*line%MOD;
				writen++;
				row++;
			}
			else if (backb[num])
			{
				if (row==0) zero=1;
				ans=ans*row%MOD;
				writen++;
				line++;
			}
			else
			{
				if (line==0||row==0) zero=1;
				ans=ans*(row*line-writen)%MOD;
				writen++;
			}
		}
	if (zero) printf("0\n");
	else printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4352
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <bitset>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000000000//10^18
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007
#define MODANOTHER 998244353
#define PI acos(-1)

using namespace std;



int main(void)
{
	//変数の宣言
	ll int n;

	//よく使う変数
	int i,j,k,l;
	int flag=0;
	ll int ans=0;
	int count=0;
	int temp=0;
	int temp1=0;
	int temp2=0;
	int max=0;
	int min=INFINT;
	int len=0;
	int sum=0;
	int ok=0;
	int ng=0;
	char dummy;



	//データの読み込み


	scanf("%lld",&n);
//	scanf_s("%lld",&n);


	//	scanf("%s",&s);
	//	scanf_s("%s",&s,200010);

//	scanf("%c",&dummy);
//	scanf_s("%c",&dummy);


/*	for(i=0;i<n;i++){
//		scanf("%s",&s);
		scanf_s("%s",&s,15);
	}*/

/*	for(i=0;i<n;i++){
//		scanf("%c",&t[i]);
		scanf_s("%c",&t[i]);
	}*/

	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

	//nが小さい場合大丈夫？？


	for(i=1;i<sqrt(n);i++){
		if(n%i==0&&i<n/i-1){
			ans=ans+n/i-1;
		}
	}

	
	//	printf("計算部分終了\n");

	//出力

	printf("%lld",ans);

//C	printf("\nL=%d,R=%d,D=%d,U=%d\n",L,R,D,U);

	//	printf("結果の出力終了\n");

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    string T;
    cin >> T;

    rep(i, T.size()) {
        if (T[i] == '?') cout << 'D';
        else cout << T[i];
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 3752
#include <iostream>
#include <cmath>
#include <string>
using namespace std;

int main(){
  string S,K;
  cin >> S >> K;
  int n=100;
  int t,o,num;
  for(int i=0; i<S.size(); i++){
    if(S[i] != '1'){
      n = i;
      break;
    }
  }
  if(n==100){
    cout << '1' << '\n';
    return 0;
  }
  if(K.size()==2){
    t = K[0] - '0';
    o = K[1] - '0';
    num = 10*t + o;
  }else if(K.size()==1){
    num = K[0] - '0';
  }else{
    cout << S[n] << '\n';
    return 0;
  }
  if(n > num-1){
    cout << '1' << '\n';
    return 0;
  }else{
    cout << S[n] << '\n';
    return 0;
  }
}

Measured memory_bytes: 256
import bisect
import sys
 
N, K = map(int, raw_input().split())
x = map(int, raw_input().split())
res = [sys.maxint] * N
 
pos = 0
f_pos = bisect.bisect_left(x, 0)
x.insert(f_pos, 0)
result = sys.maxint
if f_pos + K <= N:
	result = min(result, x[f_pos + K])
if f_pos - K >= 0:
	result = min(result, -x[f_pos - K])
for i in range(K):
	if f_pos + i <= N and f_pos - K + i >= 0:
		result = min(result, x[f_pos + i] - x[f_pos -  K + i] + min(x[f_pos + i], -x[f_pos - K + i]))
print result


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

#define ll long long
#define endl "\n"
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define f first
#define s second
#define vecll vector<ll>
#define pairll pair<ll,ll>
#define vecpairll vector<pair<ll,ll>>
#define mapllll map<ll,ll>
#define mapstrll map<string,ll>
#define mapllvecll map<ll,vecll>
#define setll set<ll>
#define fio ios_base::sync_with_stdio (false); cin.tie (NULL); cout.tie(NULL);

using namespace std;

ll const N=1e5+5;
ll const inf=1e18+5;
ll const MOD=1e9+7;

ll t,n,m,x,y,z,w,k;

int main()
{
    fio

    cin>>n;

    ll ans = 0;
    for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<=n;j++)
        {
            for(ll k=1;k<=n;k++)
            {
                ans += __gcd(i,__gcd(j,k));
            }
        }
    }
    cout<<ans;
    return 0;
}



Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

lint eq[112][5];
lint lt[112][5];

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

    lint k;
    cin >> k;

    lint n = s.length();

    eq[0][k] = 1;
    for(lint i=0; i<n; i++)
    for(lint cnt=0; cnt<=3; cnt++) {
        lint a = s[i] - '0';
        if(a == 0) {
            eq[i+1][cnt] += eq[i][cnt];
            lt[i+1][cnt] += lt[i][cnt];
            if(cnt-1 >= 0)  lt[i+1][cnt-1] += 9*lt[i][cnt];
        } else {
            if(cnt-1 >= 0)  eq[i+1][cnt-1] += eq[i][cnt];
            if(cnt-1 >= 0)  lt[i+1][cnt-1] += (a-1) * eq[i][cnt];
            lt[i+1][cnt] += eq[i][cnt];

            if(cnt-1 >= 0)  lt[i+1][cnt-1] += 9*lt[i][cnt];
            lt[i+1][cnt] += lt[i][cnt];
        }
    }

    cout << eq[n][0] + lt[n][0] << endl;
}

Measured memory_bytes: 256
N,K=map(int,input().split())
mod=pow(10,9)+7
numbers=[a for a in range(0,N+1)]
z=sorted(numbers,reverse=True)
NN=[]
b=0
for a in numbers:
    b+=a
    NN.append(b)
c=0
SS=[]
for a in z:
    c+=a
    SS.append(c)
if N+1==K:
    print(1)
else:
    answer=1
    for a in range(K,N+1):
        kotae=SS[a-1]-NN[a-1]+1
        answer+=kotae
        answer=answer%mod
    print(answer%mod)


Measured memory_bytes: 110896
#include <iostream>

using namespace std;

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

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

    int next_max=0;
    for(i=0; i<N; i++) {
        if(i==max_index) continue;
        if(next_max<A[i]) {
            next_max = A[i];
        }
    }

    for(i=0; i<N; i++) {
        if(i==max_index) cout << next_max << endl;
        else cout << max << endl;
    }



    return 0;

}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
#include<time.h>
#include<stdlib.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC target("sse4")
#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define pll pair<ll,ll>
#define vll vector<ll,ll>
#define all(a) (a).begin(),(a).end()
#define ff first
#define ss second
#define sz(x) (ll)x.size()
#define hell 1000000007
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>b;i--)
#define lbnd lower_bound
#define ubnd upper_bound
#define bs binary_search
#define gcd(a,b) __gcd((a),(b))
#define EPS 1e-12
#define lcm(a,b) ((a)*(b))/__gcd((a),(b))
#define sqrt sqrtl
#define mod 1000000007
#define cbrt cbrtl
using namespace __gnu_pbds;
using namespace std;

int main()
{
  IOS

  ll n;
  cin>>n;
  ll a[n+5],i;
  for(i=1;i<=n;i++)
  	cin>>a[i];
  ll j,sum=0;
  for(i=1;i<=n;i++)
  	for(j=i+1;j<=n;j++)
  		sum=sum+(a[i]*a[j]);
  	cout<<sum;
  return 0; 
  		
}

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

llint sx, sy, tx, ty;
const int FACT_MAX = 3000005;
llint fact[FACT_MAX], fact_inv[FACT_MAX];

llint modpow(llint a, llint n) {
	if(n == 0) return 1;
	if(n % 2) {
		return ((a%mod) * (modpow(a, n-1)%mod)) % mod;
	} else {
		return modpow((a*a)%mod, n/2) % mod;
	}
}

void make_fact() {
	llint val = 1;
	fact[0] = 1;
	for(int i = 1; i < FACT_MAX; i++) {
		val *= i;
		val %= mod;
		fact[i] = val;
	}
	fact_inv[FACT_MAX-1] = modpow(fact[FACT_MAX-1], mod-2);
	for(int i = FACT_MAX-2; i >= 0; i--) {
		fact_inv[i] = fact_inv[i+1] * (i+1) % mod;
	}
}

llint comb(llint n, llint k) {
	llint ret = 1;
	ret *= fact[n];
	ret *= fact_inv[k], ret %= mod;
	ret *= fact_inv[n-k], ret %= mod;
	return ret;
}

int main() {
	make_fact();

	cin >> sx >> sy >> tx >> ty;

	llint ans = 0;
	for(int i = sx; i <= tx; i++) {
		ans += comb(i+ty+1, ty), ans %= mod;
		ans += mod - comb(i+(sy-1)+1, sy-1), ans %= mod;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 47104
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define erep(i, n) for (int i = 0; i <= (n); i++)
#define erep1(i, n) for (int i = 1; i <= (n); i++)
using namespace std;
using ll = long long;

int main() {
    string s, s1, s1r;
    cin >> s;
    string sr = s;
    reverse(sr.begin(), sr.end());
    if (s == sr) {
        s1 = s.substr(0, (s.size() - 1) / 2);
        s1r = s1;
        reverse(s1r.begin(), s1r.end());
        if (s1==s1r){
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    return 0;
}


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

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

using namespace std;

typedef long long ll;


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

	int n;
	cin >> n;

	int ans = 0;
	for(int i = 1; i <= n; i += 2){
		int cnt = 0;
		for(int j = 1; j <= i; j++){
			if(i % j == 0) cnt++;
		}
		if(cnt == 8) ans++;
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;

int main() {
    ll H,N;
    cin >> H >> N;
    ll A[N];
    for(int i = 0; i < N; i++){
        ll tmp;
        cin >> tmp;
        H -= tmp;
    }
    if(H <= 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}


Measured memory_bytes: 256
s = input().rstrip()
length = len(s) - 1

ans = 0
for i in range(2**length):
    val = 0
    nums = s[:]
    prev_j = 0
    for j in range(length):
        if i >> j & 1:
            val += int(nums[prev_j:j+1])
            prev_j = j+1
    val += int(nums[prev_j:])
    ans += val
print(ans)

Measured memory_bytes: 3064
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " " 
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(lli i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    cout << std::fixed << std::setprecision(10);
    lli n;
    cin>>n;
    vi d(n);
    rep(i,n){
        cin>>d[i]; 
    }
    sort(all(d));
    out(d[n/2]-d[n/2-1]);
}

Measured memory_bytes: 4092
#include <stdio.h>
#define MN 20
#define MA 50

int manzoku(int A[], int B[], int C[], int* p)
{
	int prev, score, num, i;
	prev = A[0];
	score = B[prev - 1];

	for(i = 1; i < *p; i++){
		num = A[i];
		score += B[num - 1];
		if(num == prev + 1){
			score += C[prev - 1];
		}
		prev = num;
	}
	return score;
}

int main(void)
{
	int i, n, *p;

	scanf("%d", &n);
	p = &n;

	int A[MN], B[MA], C[MA];

	for(i = 0; i < n; i++){
		scanf("%d", &A[i]);
	}

	for(i = 0; i < n; i++){
		scanf("%d", &B[i]);
	}

	for(i = 0; i < n - 1; i++){
		scanf("%d", &C[i]);
	}

	printf("%d", manzoku(A,B,C,p));

	return 0;
}


Measured memory_bytes: 128
/*
─────────────────────
───────────████████──
──────────███▄███████
──────────███████████
──────────███████████
──────────██████─────
──────────█████████──
█───────███████──────
██────████████████───
███──██████████──█───
███████████████──────
███████████████──────
─█████████████───────
──███████████────────
────████████─────────
─────███──██─────────
─────██────█─────────
─────█─────█─────────
─────██────██────────
─────────────────────
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define int long long
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define reads(s) string s; cin >> s;
#define readarr(a, n) int a[(n) + 1] = {}; fori (i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; fori (i, 1, n) {fori (j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) fori (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) fori (i, 1, n) {fori (j, 1, m) cout << a[i][j] << " "; cout << endl;}
#define all(v) v.begin(), v.end()
#define sz(s) (int)(s.size())
#define pb push_back
#define fi first
#define se second
#define rz resize
#define fori(i, a, b) for (int i = (a); i <= (b); i++)
#define ford(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
#define setprec(x) cout << fixed << setprecision(x);
 
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair <int, int>> vpi;
typedef vector < vector <int> > vvi;
 
const int INF = 4e18;
const int mod = 1e9+7; 

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


    //start from here

    readb(a, b)
    print(max(a+b, max(a-b, a*b)))

    return 0;
}


Measured memory_bytes: 3636
import sys
import numpy as np
import itertools
from itertools import product
# from decimal import Decimal
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, m = map(int, readline().split())
k = [list(map(int, readline().split())) for _ in range(m)]
p = list(map(int, readline().split()))

ans = 0
flag = True

for i in product((0, 1), repeat=n):
    #print(i, i[0])

    for j, valK in enumerate(k):
        pp = p[j]
        temp = 0
        for k1, k2 in enumerate(valK):
            if (k1 == 0):
                continue
            else:
                temp += i[k2 - 1]

        if (temp % 2 == pp):
            continue
        else:
            flag = False
            break
    if (flag is False):
        flag = True
        continue
    else:
        ans += 1


print(ans)


Measured memory_bytes: 27144
#include <bits/stdc++.h>
#if 1
#define int long long
#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define stoi stoll
#else
#define MAX INT_MAX
#define MIN INT_MIN
#endif
#define ALL(obj) (obj).begin(), (obj).end()
#define fi first
#define se second
const int NIL = -1;
const int MOD = 1000000007;
#define REP(i,n) for (int i=0; i < (n); ++i)
#define FOR(i,a,b) for (int i=(a); i < (b); ++i)
using namespace std;

int get_gcd(int a, int b){while(1){if (a < b) swap(a, b); if (b == 0) return a; a %= b;}}
int get_lcm(int a, int b){return a * b / get_gcd(a, b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//-------------------------テンプレここまで-------------------------//

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

  string s;
  cin >> s;

  string ans;
  for (int bit = 0; bit < (1<<3); bit++) {
    int sum = s[0] - '0';
    ans.resize(0);
    ans += s[0];
    for (int i = 0; i < 3; i++) {
      sum += (bit & (1<<i)) ? (s[i+1] - '0') : -(s[i+1] - '0');
      ans += (bit & (1<<i)) ? '+' : '-';
      ans += s[i+1];
    }
    if (sum == 7) {
      ans += "=7";
      break;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
def consunt():
    if input_.count(input_str_arr[0]) and input_.count(input_str_arr[1]):
      print("Yes")
    else:
      print("No")

input_ = input()

input_str = set(input_)

input_str_arr = [s for s in input_str]

if len(set(input_str_arr))==2:
    consunt()
else:
    print("No")

    


Measured memory_bytes: 3064
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cstdlib>
#include<ctime>
#include<iostream>
#include<set>
#include<complex>
#include<map>
using namespace std;
inline int ri()
{
	register int x=0;
	bool f=0;
	register char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-')	f=1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')
	{
		x=(x<<3)+(x<<1)+ch-'0';
		ch=getchar();
	}
	if(f)	return -x;
	else	return x;
}
void wi(int x)
{
	if(x<0)	putchar('-'),x=-x;
	if(x>9)	wi(x/10);
	putchar(x%10+'0');
}
const int N=1e5+7;
int a[N];
int main()
{
	int n=ri(),i,j;
	for(i=1;i<=n;i++)	a[i]=ri();
	sort(a+1,a+1+n);
	j=lower_bound(a+1,a+1+n,(a[n]+1)/2)-a;
	wi(a[n]);putchar(' ');
	if(j==1||fabs(0.5*a[n]-a[j-1])>fabs(0.5*a[n]-a[j])+1e-6)	wi(a[j]);
	else	wi(a[j-1]);
	putchar('\n');
	return 0;
}
/*
5
6 9 4 2 11







*/

Measured memory_bytes: 640
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
ll INF = 10000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}
ll at[30][30];
ll bt[30][30];
ll ar[30];
ll upt[30][30][30];
ll mid(ll x, ll y, ll z) {
	if (x <= y && y <= z) {
		return y;
	}
	else if (y <= x && x <= z) {
		return x;
	}
	else return z;
}
int c[30];
ll ggd(ll x, ll v) {

	if (v == 0) return 0;
	ll rem = x % v;
	ll di = ((x / v) * v) * 2;
	ll r = di + x;
	return r + ggd(v, rem) - rem;

}
//]
void solv() {

	int a, b, c;
	cin >> a >> b >> c;
	cout << min(b / a, c) << endl;
	
	//cin >> n >> m;
	//fill(memo, memo + n, -1);
	//for (size_t i = 0; i < m; i++)
	//{
	//	int p, q,c;
	//	cin >> p >> q >> c;
	//	co[p, q] = c;
	//	co[q, p] = co[p, q];
	//	ve[p].push_back(q);
	//	ve[q].push_back(p);
	//}

	//
	//cout << rec(1, 0) << endl;

}


int main() {
	solv();

	return 0;
}


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

int main(){
    int n,k;
    cin>>n>>k;
    vector<int>d(n);
    int t,ans=0;
    for(int i=0;i<n;i++){
        d.at(i)=0;
        }
    for(int i=0;i<n;i++){
        cin>>t;
        d.at(t-1)++;
        }
    sort(d.begin(),d.end());
    reverse(d.begin(),d.end());
    for(int i=k;i<n;i++){
        ans+=d.at(i);
        }
    cout<<ans<<endl;
    }


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
using namespace std;
long long ans=0;
long long now=0;
int main()
{
    string s;cin>>s;
    int len=s.length();
    int times=1<<(len-1);
    for(int cnt=0;cnt<times;cnt++)
    {
        now=s[0]-'0';
        for(int i=0;i<len;i++)
        {
            if(1<<i&cnt||i==len-1)
            {
                ans+=now;
                now=0;
                if(i==len-1) break;
            }
            now=now*10+(s[i+1]-'0');
        }
    }
    printf("%lld\n",ans);

    return 0;
}


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

const int MAXN = 200005;

char str[MAXN];
int n, k;

int main()
{
	scanf("%d%d", &n, &k);
	scanf("%s", str+1);
	for (int i = 1; i <= n; i++) str[i] -= 'A';
	int cnt = 0, cur = str[1], cc = 0;
	str[n+1] = 1;
        for (int i = 1; i <= k && cnt < n; i++) {
		cc++;
		if (cur == 0) {
			cur ^= 1;
		} else {
			cnt++;
			cur = str[cnt+1]^(cnt&1);
		}
	}
	if (k > cc) {
		k = (k-cc)&1;
		if (k == 1 && (n&1))
			cur ^= 1;
	}
	putchar('A'+cur);
	for (int i = 2; i <= n; i++) {
		if (i+cnt <= n) putchar('A'+(str[i+cnt]^(cnt&1)));
		else putchar(((n-i)&1)?'B':'A');
	}
	puts(""); 
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <stack>
#include <limits>
#include <array>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <numeric>
#include <tuple>

constexpr long long mod = static_cast<long long>(1e9 + 7);

struct Data
{
  int _1;
  int _2;
};

int main() {
  int N;
  std::cin >> N;
  std::vector<Data> vec(N);
  for(int i = 0; i < N; ++i)
  {
    std::cin >> vec[i]._1;
    vec[i]._2 = i;
  }
  std::sort(begin(vec), end(vec), [](auto& v, auto& u){ return v._1 < u._1;});
  std::vector<int> ans(N);
  for(int i = 0; i < N; ++i)
  {
    if(i<N/2)
      ans[vec[i]._2] = vec[N/2]._1;
    else
      ans[vec[i]._2] = vec[N/2 - 1]._1;
  }
  for(auto& x: ans)
    std::cout << x << "\n";
  std::cout  << std::flush;
  return 0;
}


Measured memory_bytes: 4480
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define frfr  freopen("input.text","r",stdin); //freopen("output.txt","w",stdout)
#define LL long long int
#define ull unsigned long long int
#define wh int T;cin >> T;while(T--)
#define REP(i,n) for(int i=0;i<n;i++)
#define forn(i,k,n) for(int i=k;i<n;i++)
#define PB push_back
#define mod 1000000007 
#define UMP unordered_map<int,int>
#define MP map<int,int> 
#define stack stack<int>
#define stackL 	stack<LL>
#define take(x) int x;cin >> x; 

int gcd(int a, int b) { 
    return  (!a)? b : gcd(b%a,a);      
} 
void solve(){
	LL a,b,c,d;
	cin >> a >> b >> c >> d;
	vector<LL> v;
	v.push_back(a*c);
	v.push_back(a*d);
	v.push_back(b*c);
	v.push_back(b*d);
	sort(v.begin(),v.end());
	 cout << v[3] << endl;
	
} 


int main()
{
	solve();
	
	
 return 0;	
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    string S; cin >> S;
    bool ok = false;
    for (int i = 0; i < 3; i++) {
        if (S[i] == '7') {
            ok = true;
        }
    }
    cout << (ok ? "Yes" : "No") << '\n';
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
// const lint MOD = 998244353;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}

//k!
ll facctorialMethod(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum = (sum*i%MOD)%MOD;
    }
    return sum;
}

//nCr
ll permutationMethod(ll n,ll r){
    ll n_sum,r_sum;
    ll i;
	ll rr = n - r;
    n_sum = facctorialMethod(n);
    r_sum = (facctorialMethod(rr)*facctorialMethod(r))%MOD;
	print(n_sum);
	print(r_sum);
    return n_sum/r_sum;
}

int main(){
	double w,h,x,y; cin >> w >> h >> x >> y;
	if (w/2 == x && h/2 == y){
		printf("%.6f 1\n",w*h/2);
	}else{
		printf("%.6f 0\n",w*h/2);
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// const ll INF = 1LL <<60;
// const int INF = 10000;

//最大公約数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

const int MAX = 1e6+1;
const int MOD = 1e9+7;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}

long long modpow(long long res,long long a, long long n, long long mod) {
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//sieve(MAX);でベクトルIsPrimeに「MAXまでの数値の素数の真偽」を格納する。
vector<bool> IsPrime;
void sieve(size_t max){
    if(max+1 > IsPrime.size()){     // resizeで要素数が減らないように
        IsPrime.resize(max+1,true); // IsPrimeに必要な要素数を確保
    } 
    IsPrime[0] = false; // 0は素数ではない
    IsPrime[1] = false; // 1は素数ではない

    for(size_t i=2; i*i<=max; ++i) // 0からsqrt(max)まで調べる
        if(IsPrime[i]) // iが素数ならば
            for(size_t j=2; i*j<=max; ++j) // (max以下の)iの倍数は
                IsPrime[i*j] = false;      // 素数ではない
}
// ここから開始
int main(){
  int n;
  string s,t;
  cin>>n>>s>>t;
  for(int i = 0; i < n; i++){
    cout<<s[i]<<t[i];
  }
  cout<<endl;
  return 0;
}



Measured memory_bytes: 256
/*
    @uthor: Amit Kumar
    user: CodeChef: dr_virus_ ; Codeforces,Hackerearth,Hakerrank: dr_virus;
*/
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;
//#define ln mp::cpp_int;
#define ll long long
#define ld double
#define pp pair<ll,ll>
#define endl "\n"
#define nfrep(a) for(size_t i=0;i<a;i++)
#define fnrep(a,b) for(size_t i=a;i<=b;i++)
#define nbrep(a) for(size_t i=a;i>=0;i--)
#define bnrep(a,b) for(size_t i=a;i>=b;i--)
 
const ll mod = 1e9+7;
const ll inf = 1e18;
 
 
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
 /* #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif */
ll n;
  cin>>n;
  ll arr[n]={0};
  for(ll i=0;i<n-1;i++){
  ll t;
    cin>>t;
    arr[t-1]+=1;
  }
  for(ll i=0;i<n;i++) cout<<arr[i]<<endl;
    //cerr<<"Time Elapsed: "<<clock()/(double)CLOCKS_PER_SEC<<endl;
    return 0;
}

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

int main(){
  long long int h,w,d;
  cin>>h>>w>>d;
  vector<vector<long long int> > a(h,vector<long long int>(w));
  vector<pair<long long int,long long int> > x(h*w+1);
  for(long long int i=0;i<h;i++){
    for(long long int j=0;j<w;j++){
      cin>>a[i][j];
      x[a[i][j]]=make_pair(i,j);
    }
  }
  vector<long long int> t(h*w+1,0);
  for(long long int i=d+1;i<h*w+1;i++){
    t[i]=t[i-d]+abs(x[i].first-x[i-d].first)+abs(x[i].second-x[i-d].second);
  }
  long long int q;
  cin>>q;
  for(long long int i=0;i<q;i++){
    long long int l,r;
    cin>>l>>r;
    cout<<t[r]-t[l]<<endl;
  }
}


Measured memory_bytes: 3968
n = int(input())
s = [input().split() for _ in range(n)]
t = []
for i in range(n):
  t.append(s[i][0])
x = input()
k = t.index(x)
y = 0
for i in range(k+1, n):
    y += int(s[i][1])
print(y)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i, x) for(ll i = 0; i < x; i++)
#define rep2(i, x) for(ll i = 1; i <= x; i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
const ld pi = 3.141592653589793238;

ll modpow(ll x, ll y) {
	ll res = 1;
	while (y) {
		if (y % 2) { res *= x; res %= mod; }
		x = x * x % mod; y /= 2;
	}
	return res;
}

ll inx[123456], iny[123456];
signed main() {
	ll n, m; cin >> n >> m;
	vector<ll> x, y;
	rep(i, n) {
		cin >> inx[i];
		if (i != 0) {
			x.push_back(inx[i] - inx[i - 1]);
		}
	}
	rep(i, m) {
		cin >> iny[i];
		if (i != 0) {
			y.push_back(iny[i] - iny[i - 1]);
		}
	}
	ll ans1 = 0, ans2 = 0;
	ll cnt = 1; reverse(all(x));
	rep(i, n - 1) {
		x[i] = (x[i] * cnt) % mod; cnt++;
	}
	cnt = 1; reverse(all(x));
	rep(i, n - 1) {
		ans1 += (x[i] * cnt) % mod; cnt++; ans1 %= mod;
	}

	cnt = 1; reverse(all(y));
	rep(i, m - 1) {
		y[i] = (y[i] * cnt) % mod; cnt++;
	}
	cnt = 1; reverse(all(y));
	rep(i, m - 1) {
		ans2 += (y[i] * cnt) % mod; cnt++; ans2 %= mod;
	}

	cout << (ans1 * ans2) % mod << endl;
	return 0;
}

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

using ll = long long;
const ll amari = 1e9+7;
#define ben(a) a.begin(),a.end()
#define pb(a,b) a.push_back(b)

int main(){
	int n;
	cin >> n;
	int maxi = 0;
	int h;
	int sum = 0;
	for(int i = 0; i < n; i++){
		cin >> h;
		if(maxi <= h)sum++;

		maxi = max(h,maxi);
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main(void){
    int S[4];
    char T[4];
    int f = 0;
    int f2 = 0;

    for(int i = 0; i < 4; i++){
        T[i] = 0;
    }

    for(int i = 0; i < 4; i++){
        scanf("%c", &T[i]);
    }

    for(int i = 0; i < 4; i++){
        S[i] = T[i]-48;
    }

    if(S[0] == 0){
        if(S[1] == 0){
            f = 1;
        }
    }
    else if(S[0] == 1){
        if(S[1] > 2){
            f = 1;
        }
    }else {
        f = 1;
    }

    if(S[2] == 0){
        if(S[3] == 0){
            f2 = 1;
        }
    }
    else if(S[2] == 1){
        if(S[3] > 2){
            f2 = 1;
        }
    }
    else {
        f2 = 1;
    }

    if(f == 1){
        if(f2 == 1){
            printf("NA\n");
        }else {
            printf("YYMM\n");
        }
    }else {
        if(f2 == 1){
            printf("MMYY\n");
        }else {
            printf("AMBIGUOUS\n");
        }
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	 ll n,weight ;
	 cin>>n>>weight;
	 ll w[n+1];
	 ll v[n+1];
	 ll dp[n+1][weight+1];
	 for(int i=1; i<=n;i++){
		 cin>>w[i]>>v[i];
	 }
	 memset(dp,0,sizeof(dp));
	 for(int i=1;i<n+1;i++){
		 for(int j=0;j<=weight;j++){
			 if(j-w[i]>=0)
			 dp[i][j]=max(v[i]+dp[i-1][j-w[i]],dp[i-1][j]);
			else
			 dp[i][j]=dp[i-1][j];
		 }
	 }
	 cout<<dp[n][weight];
	 return 0;
}

Measured memory_bytes: 79104
N, K = map(int, input().split())
A = list(map(int, input().split()))
mod = 10**9+7

ans = 0
tmp = 0
tmp2 = 0
for i in range(N):
    for j in range(i):
        if A[i] < A[j]:
            tmp += 1
    for j in range(N):
        if A[i] > A[j]:
            tmp2 += 1

k = (K * (K-1) // 2) % mod
ans = ans + (tmp * K % mod) + (tmp2 * k % mod)
print(ans % mod)


Measured memory_bytes: 3188
import sys
import math
from collections import Counter
from collections import OrderedDict
def inputt():
    return sys.stdin.readline().strip()
def printt(n):
    sys.stdout.write(str(n)+'\n')
def listt():
    return [int(i) for i in inputt().split()]

def gcd(a,b): 
   return math.gcd(a,b) 
 
def lcm(a,b): 
    return (a*b) / gcd(a,b) 

def dfs(src, visit):
    count=1
    visit[src] = 1
    for nbr in dic[src]:
        if nbr==-1:
            continue
        if visit[nbr] == 0:
            count+=dfs(nbr, visit)   
    return count          


a,b,c,d=map(int,inputt().split())
l=[]
l.append(b*d)
l.append(a*d)
l.append(a*c)
l.append(b*c)
print(max(l))
                 

    

Measured memory_bytes: 9480