akhauriyash/Code-Regression huggingface dataset:
import System.Environment
import Data.Maybe
import Data.List
import Control.Exception

main :: IO ()
main = do
  isTest <- getEnv "TEST" `catch` (\(SomeException _) -> return "")
  if isTest == "1"
    then do
      testFile <- readFile "tests"
      putStrLn $ tests testFile
    else do
      input <- getContents
      putStrLn $ trim (solve (trim input))

--処理
solve :: String -> String
solve s = (intercalate "\n" . fmap show) result
 where
  [_, line2] = lines s
  list       = 0 : ((fmap read . words) line2) ++ [0] :: [Int]
  -- i-1からiまで
  price      = fmap (\(x, y) -> abs (x - y)) (zip list (drop 1 list))
  sumPrice   = sum price
  result     = fmap
    (\(x, y, z) -> sumPrice + abs (x - z) - (abs (x - y) + abs (y - z)))
    (zip3 list (drop 1 list) (drop 2 list))

tests :: String -> String
tests text = case testParse text of
  Right bodys -> unlines (fmap (\(i, body) -> test i body) (zip [1 ..] bodys))
  Left  msg   -> "Test file parse error:" ++ msg

test :: Int -> (String, String) -> String
test n (input, outputRight)
  | output == outputRight
  = header ++ "Passed"
  | otherwise
  = header
    ++ "Faild\n"
    ++ "Right:"
    ++ show outputRight
    ++ "\nOutput:"
    ++ show output
 where
  header = "test" ++ show n ++ ":"
  output = trim $ solve input

testParse :: String -> Either String [(String, String)]
testParse s = case lines s of
  (sp1:sp2:bodys) -> testBodysParse sp1 sp2 bodys
  _               -> Left "testParse"

testBodysParse
  :: String -> String -> [String] -> Either String [(String, String)]
testBodysParse sp1 sp2 = (traverse . testBodyParse) sp2 . (split sp1)

testBodyParse :: String -> [String] -> Either String (String, String)
testBodyParse sp body = case fmap (trim . unlines) (split sp body) of
  [input, output] -> Right (input, output)
  _               -> Left "testBodyParse"

split :: Eq a => a -> [a] -> [[a]]
split spratar = foldr f [[]]
 where
  f x (p:ps) | x == spratar = [] : p : ps
             | otherwise    = (x : p) : ps
  f _ _ = undefined

trimHead :: String -> String
trimHead = dropWhile (\s -> isJust (elemIndex s [' ', '\t', '\n', '\r']))

trim :: String -> String
trim = reverse . trimHead . reverse . trimHead

Measured memory_bytes: 65788
//usr/bin/env picoc $0 - $@;exit
#include <stdio.h>
int main(){
	int n,t=0,x=0,y=0;
	for(scanf("%d",&n);n--;){
		int t0,x0,y0;
		scanf("%d%d%d",&t0,&x0,&y0);
		{
			int dt=t0-t,dx=x0-x,dy=y0-y;
			if(dx+dy>dt || (dt-dx-dy)%2){
				puts("No");
				return 0;
			}
		}
		t=t0;x=x0;y=y0;
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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; }



int main(int argc, char const *argv[]) {
  int h,w,line,row;
  cin >> h >> w;
  string s[h][w];
  rep(i,h)rep(j,w){
    cin >> s[i][j];
    if(s[i][j]=="snuke"){
      line=i+1; row=j;
    }
  }
  char ans='A'+row;
  cout << ans << line << endl;
  return 0;
}


Measured memory_bytes: 256
from sys import stdin,setrecursionlimit
import sys
from math import factorial
setrecursionlimit(10**6)
input=stdin.readline

a,b=map(int,input().split())
if abs(a-b)>1:
    print(0)
else:
    mod=10**9+7
    fact=[0]*(max(a,b)+1)
    fact[0],fact[1]=1,1
    for i in range(2,max(a,b)+1):
        fact[i]=(i*fact[i-1])%mod
    ans=(fact[a]*fact[b])%mod
    print(ans if abs(a-b)==1 else (ans*2)%mod)

Measured memory_bytes: 6900
l, r = list(map(int, input().split()))

if r - l > 2018:
    print(0)
else:
    ans = 2018
    for i in range(l, r):
        for j in range(i+1, r+1):
            tmp = (i * j) % 2019
            if ans > tmp:
                ans = tmp
    print(ans)


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

int main()
{
	int n,summ=0,a;
	cin>>n;
	a=n;
	while(n!=0)
	{
		summ=summ+n%10;
		n=n/10;
	}
	if(a%summ==0) cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 256
x,k,d=map(int,input().split())

X=abs(x)

y=X//d

if k<=y:
  ans=X-k*d
  print(ans)
  
else:
  ans1=X-y*d
  ans2=abs(X-y*d-d)
  if (k-y)%2==0:
    print(ans1)
  else:
    print(ans2)

Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const int nmax = 8;
bool graph[nmax][nmax];
const int INF = 1e9;
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
 
ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}
 
ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}


void solve(long long H, long long W, long long h, long long w){
    cout << (H-h) * (W-w) << endl;
}

int main(){
    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    long long h;
    scanf("%lld",&h);
    long long w;
    scanf("%lld",&w);
    solve(H, W, h, w);
    return 0;
}


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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back

typedef long long ll;

const ll MOD = 1e9+7;
const ll INF = 1e9+5;

int n, m, a, b, c;
string s, t, r;

char ch;

int main() {
	cin >>ch ;
	cout <<char(ch+1)  <<endl;
	return 0;
}

Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
// dfmt on

void main()
{
    long N = lread();
    auto W = aryread();
    long ans = long.max;
    foreach (x; 0 .. N)
    {
        ans = ans.min(abs(W[0 .. x + 1].sum() - W[x + 1 .. $].sum()));
    }
    writeln(ans);
}


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

#define INF 999999999

using namespace std;

// input
int n;
vector<int> a;

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

    cin >> n;

    int input;

    int ans = 0;

    for(int i = 0;cin >> input;i++){
        ans += input - 1;
    }

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

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

int main(){
  int K,S;cin>>K>>S;
  int ans=0;
  
  for (int x=0;x<=K;++x){
    for (int y=0;y<=K;++y){
      int z=S-x-y;
      if(z>=0 && z<=K)++ans;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main(int argc, char **argv)
{
    int N;
    cin >> N;
    ll A[N];
    REP(i, N) cin >> A[i];

    map<ll, int> m;

    REP(i, N) {
        ll s = i - A[i];
        if (m.find(s) != m.end()) m[s]++;
        else m[s] = 1;
    }

    ll count = 0;
    REP(i, N) {
        ll s = A[i] + i;
        if (m.find(s) != m.end()) {
            count += m[s];
        }
    }
    cout << count << endl;
    return 0;
}


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

using namespace std;

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

#define mp make_pair
#define F first
#define S second

const ll N = 2e5;
const ll M = 20;
const ll SQ = 320;
const ll INF = 1e16;
const ll MOD = 1e9+7;

int n;
ll a[N];

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

	cin >> n;
	for (int i = 0; i<n; i++)
		cin >> a[i];
	int p = 0;
	ll ans = 0;
	while (p<n)
	{
		ll s = 0;
		while (p<n && a[p]>0)
		{
			s += a[p];
			p++;
		}
		ans += s/2;
		p++;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a[100]={0};
    int i,n;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    for(i=0;i<n;i++)
    {
        if(a[i]%2 == 0)
        {
            if(a[i]%3!=0 && a[i]%5!=0)
                break;
        }
    }
    if(i!=n)
        printf("DENIED");
    else
        printf("APPROVED");
    return 0;
}

Measured memory_bytes: 128
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define inN(x, N) rep(i, N) in(x[i])
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    int N;
    in(N);

    vll A(N);
    inN(A, N);

    ll ans = 0;
    ll maxStep = A[0];

    reps(i, 1, N)
    {
        if (maxStep > A[i])
        {
            ans += maxStep - A[i];
        }
        else
            maxStep = A[i];

    }

    outl(ans);

    return 0;
}

Measured memory_bytes: 4796
n = int(input())
a = list(map(int,input().split()))
q = int(input())
b = []
c = []
sa = []
for i in range(q):
  B,C = map(int,input().split())
  b.append(B)
  c.append(C)
  sa.append(C-B)
lst = [0]*100000
su = 0
for i in a:
  lst[i-1] += 1
  su += i

for i in range(q):
  su += sa[i]*lst[b[i]-1]
  print(su)
  if lst[b[i]-1] != 0:
    lst[c[i]-1] += lst[b[i]-1]
    lst[b[i]-1] = 0

Measured memory_bytes: 26568
#include<iostream>
#include<cmath>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<cstdlib>
#include<queue>
#include<list>
#include<cctype>
#include<algorithm>
const int INF=1e9;
using namespace std;

int main(){
    int x, a, b;
    cin>>x>>a>>b;
    if(abs(x-a)>abs(x-b)) cout<<'B'<<endl;
    else cout<<'A'<<endl;
}


Measured memory_bytes: 256
n = int(input())
s = input()
ans = s.count('R')*s.count('G')*s.count('B')
for i in range(n):
    for j in range(i+1,n):
        k = j - i + j
        if k<n and s[k]!=s[i] and s[k]!=s[j] and s[i]!=s[j]:
            ans-=1
print(ans)

Measured memory_bytes: 9108
#include<iostream>
#include<string>
#include<cmath>
#include<math.h>
//#include<array>
#include<algorithm>
#include<queue>
#include<deque>
#include<vector>
//#include<utility>
//#include<set>
#include<map>
//#include<list>
//#include<bitset>
//#include<iomanip>

using namespace std;
using LLI = long long int;
LLI N;

//配列,座標
/*array<int, 8>dir_x = { 0,0,1,1,1,-1,-1,-1 };
array<int, 8>dir_y = { 1,-1,1,0,-1,1,0,-1 };
array<int, 4>dir_x2 = { 0,0,1,-1 };
array<int, 4>dir_y2 = { 1,-1,0,0 };
char alp[] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };*/

//Union Find
/*class UnionFind {
public:
	vector<int>data;
	UnionFind(int size) :data(size, -1) {};
	bool unionset(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x]) {
				swap(x, y);
			}
			data[x] += data[y];
			data[y] = x;
		}
		return x != y;
	}
	bool findset(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};*/

//最大公約数,最小公倍数
/*LLI gcd(LLI x, LLI y) {
	LLI  r;
	if (x < y) {
		swap(x, y);
	}
	r = x % y;
	while (r != 0) {
		x = y;
		y = r;
		r = x % y;
	}
	return y;
}
LLI lcm(LLI x, LLI y) {
	return x / gcd(x, y) * y;
}*/

//組み合わせ
/*long nCr(int n, int r) {
	long ans = 1;
	for (int i = n; i > n - r; i--) {
		ans = ans * i;
	}
	for (int i = 1; i < r + 1; i++) {
		ans = ans / i;
	}
	return ans;
}
long nHr(int n, int r) {
	n = n + r - 1;
	return nCr(n, r);
}*/

//素数判定
/*bool IsPrime(int num)
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}*/

//サンプル
/*const int n_max = 8;
array<array<bool, n_max>, n_max>graph;
int dfs(int v,int N,array<bool,n_max>visited) {
	int ret = 0;
	bool all_visited = true;
	for (int i = 0; i < N;i++) {
		if (visited[i] == false) {
			all_visited = false;
		}
	}
	if (all_visited) {
		return 1;
	}
	for (int i = 0; i < N;i++) {
		if (graph[v][i] == false) {
			continue;
		}
		if (visited[i] == true) {
			continue;
		}
		visited[i] = true;
		ret += dfs(i,N,visited);
		visited[i] = false;
	}
	return ret;
}*/

//サンプル
/*vector<vector<int>>sub;
int dfs(int id) {
	if (sub[id].size() == 0) {
		return 1;
	}
	int minP = (int)1e9;
	int maxP = 0;
	for (int i : sub[id]) {
		int P = dfs(i);
		minP = min(minP, P);
		maxP = max(maxP, P);
	}
	return minP + maxP + 1;
}*/

//#define debug(x) cerr << #x << " : " << x << endl
//#define debugv(x) cerr << #x << " : "; for(auto i:x) cerr << i << ", "; cerr<<endl

int main(void) {
	string SS;
	for (int i = 0; i < 26; i++) {
		SS += ('A' + i);
	}
	for (int i = 0; i < 26; i++) {
		SS += ('A' + i);
	}
	cin >> N;
	string S;
	cin >> S;
	for (int i = 0; i < S.size(); i++) {
		for (int j = 0; j < 26;j++) {
			if (S[i] == SS[j]) {
				S[i] = SS[j + N];
				break;
			}
		}
	}
	cout << S << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define rep(i, a, b) for(i = a; i < b; i++)
#define per(i, a, b) for(i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define trav(x, it) for(auto it = x.begin(); it != x.end(); it++)
#define pr(x) cout << #x << " = " << x << endl
#define endl "\n"
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector< pii > vpii;
typedef vector< pll > vpll;
const ld eps = 1e-7;
const ll mod = 1000000007;
const ll N = 998244353;

ll binpow(ll b, ll p){ ll ans = 1; while(p > 0){if(p & 1) ans = (ans * b) % mod; b = (b * b) % mod; p >>= 1;}return ans;}
ll modinv(ll x){return binpow(x, mod - 2);}

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

	int h, w, k, i, j, cnt = 0, ans = 0, r, c, x;
	cin >> h >> w >> k;
	char s[h][w], s1[h][w];
	rep(i, 0, h)
	{
		rep(j, 0, w)
		{
			cin >> s[i][j];
		}
	}

	for(i = 0; i < (1 << h); i++)
	{
		for(j = 0; j < (1 << w); j++)
		{
			rep(r, 0, h)
			{
				rep(c, 0, w)
				{
					s1[r][c] = s[r][c];
				}
			}
			for(r = 0; r < h; r++)
			{
				if((1 << r) & i)
				{
					for(x = 0; x < w; x++)
						s1[r][x] = ',';
				}
			}
			for(c = 0; c < w; c++)
			{
				if((1 << c) & j)
				{
					for(x = 0; x < h; x++)
						s1[x][c] = ',';
				}
			}
			cnt = 0;
			rep(r, 0, h)
			{
				rep(c, 0, w)
				{
					if(s1[r][c] == '#')
						cnt++;
				}
			}
			if(cnt == k)
				ans++;

		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3664
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <utility>


using namespace std;

class restaurant{
public:
	string city;
	int satis;
	int flag;

	restaurant(){ city = " "; satis = 0; flag = 0; }
	restaurant(const char *str, int num, int f){city = str; satis = num; flag = f;}
};

bool operator<(const restaurant &a, const restaurant &b){
	if(a.city == b.city) return a.satis > b.satis;
	return a.city < b.city;
}


int main(){
	int n;
	cin >> n;
	restaurant ob1[100];
	for(int i = 0; i < n; i++){
		cin >> ob1[i].city;
		cin >> ob1[i].satis;
		ob1[i].flag = i+1;
	}

	sort(ob1,ob1+n);

	cout << endl;
	for(int i = 0; i< n; i++){
		cout << ob1[i].flag << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
int main() {
    int X, N;
    std::cin >> X >> N;

    std::vector<int> p(N);
    for (int i = 0; i < N; ++i) {
        std::cin >> p[i];
    }

    int ret = 101;
    int dist = std::numeric_limits<int>::max();
    for (int i = 101; i >= 0; --i) {
        if (std::find(p.cbegin(), p.cend(), i) != p.cend()) {
            continue;
        }
        if (std::abs(X - i) <= dist) {
            ret = i;
            dist = std::abs(X - i);
        }
    }

    std::cout << ret << std::endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int c[10010][10010], n, m, l, b[101][10010];

typedef pair<int,int> P;

int main(){
	cin >> n >> m;
	vector<P> vec[10010];
	while(1){
		int s, t, e;
		cin >> s >> t >> e;
		if(s==0)break;
		vec[s - 1].push_back(P(t - 1,e));
	}
	cin >> l;
	for(int i=0;i<l;i++){
		for(int j=0;j<m;j++){
			cin >> b[i][j];
		}
	}
	for(int i=0;i<l;i++){
		for(int j=0;j<n;j++){
			int ans = 0;
			for(P p : vec[j]){
				ans += b[i][p.first] * p.second;
			}
			cout << (j ? " " : "") << ans;
		}
		cout << endl;
	}
	return 0;
}

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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a+b == c || b+c == a || c+a == b)
        cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    int[] a = new int[n];
    for(int i=0; i<n; i++) {
      a[i] = Integer.parseInt(in.readLine());
    }
    
    int count = 0;
    int currentButton = a[0];
    int[] ary = new int[n];
    boolean hantei = false;
    for(int i=0; i<n; i++) {
      if(currentButton==2) {
        count++;
        System.out.println(count);
        return;
      } else {
        count++;
        ary[currentButton-1]++;
        currentButton=a[currentButton-1];
      }
    }
    System.out.println(-1);
  }
}

Measured memory_bytes: 41860
//#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <string>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <vector>
#include <cassert>
#include <fstream>
#include <algorithm>
#include <list>
#include <random>
#include <ctime>
#include <cmath>
#include <random>
#include <bitset>
#include <complex>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
//#define int ll
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef pair<ld, ld> pld;
typedef complex<double> base;

#define mmin(a, b) a = min(a, (b))
#define mmax(a, b) a = max(a, (b))
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define ALL(a) a.begin(),a.end()
#define sqr(x) (x) * (x)
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define cint const int & 
#define SZ(a) ((int)(a.size()))
#define watch(x) cout << (#x) << " = " << x << endl;

const double PI = 2 * acos(0.0);

template<class T>
void show(const vector<T> &a) {
	for (T x : a)
		cout << x << " ";
	cout << endl;
}

ll gets(ll n) {
	ll ret = 0;
	while (n) {
		ret += n % 10;
		n /= 10;
	}
	return ret;
}

vl good() {
	vl pred;
	for (int sm = 1; sm < 200; ++sm) {
		string s = "";
		int kek = sm;
		for (int i = 9; i >= 1; --i) {
			while (kek >= i) {
				s = char(i + '0') + s;
				kek -= i;
			}
		}
		stringstream ss;
		ss << s;
		ll lol;
		ss >> lol;
		pred.pb(lol);
		int lst = s[0] - '0';
		string ns = s.substr(1, SZ(s) - 1);
		for (int i = 0; i < lst; ++i) {
			string kek_ns = ns;
			kek_ns = char(i + '0') + kek_ns;
			kek_ns = char((lst - i) + '0') + kek_ns;
			ll lol;
			stringstream ss;
			ss << kek_ns;
			ss >> lol;
			pred.pb(lol);
		}
	}
	vl ret;
	sort(ALL(pred));
	pred.resize(unique(ALL(pred)) - pred.begin());
	//watch(SZ(pred));
	for (int i = 0; i < SZ(pred); ++i) {
		bool ok = 1;
		for (int j = i + 1; ok && j < SZ(pred); ++j) {
			ld a = (ld)pred[i] * (ld)gets(pred[j]);
			ld b = (ld)pred[j] * (ld)gets(pred[i]);
			if (a > b) ok = 0;
		}
		if (ok) ret.pb(pred[i]);
	}
	//watch(SZ(ret));
	return ret;
}

bool check(ll n, vl ret) {
	for (int j = 0; j < SZ(ret); ++j) {
		ld a = (ld) n * (ld) gets(ret[j]);
		ld b = (ld) ret[j] * (ld) gets(n);
		if (n < ret[j] && a > b) 
			return 0;
		
	}
	return 1;
}

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

	int k;
	cin >> k;
	vl ret = good();
	vl addition;
	string nines = "";
	for (int i = 1; i < 15; ++i, nines += '9') {
		for (int j = 1; ; ++j) {
			stringstream ss;
			ss << j;
			ss << nines;
			ll kek;
			ss >> kek;
			if (check(kek, ret)) addition.pb(kek);
			else break;
		}
	}
	//watch(SZ(addition));
	ret.insert(ret.end(), ALL(addition));
	sort(ALL(ret));
	ret.resize(unique(ALL(ret)) - ret.begin());
	fori(i, k)
		cout << ret[i] << " ";
}


Measured memory_bytes: 256
import sys

ERROR_INPUT = 'input is invalid'
OPECODE = ['+', '-', '*']
STACK = []


def main():
    inp = get_input()
    print(calc_stack(li=inp))


def calc_stack(li):
    for l in li:
        if l in OPECODE:
            STACK.append(calc(right=STACK.pop(), left=STACK.pop(), ope=l))
        else:
            STACK.append(int(l))

    return STACK[0]


def calc(left, right, ope):
    if ope == '+':
        return left + right
    elif ope == '-':
        return left - right
    elif ope == '*':
        return left * right


def get_input():
    inp = input().split(' ')
    opecode_count = 0
    operand_count = 0

    for i in inp:
        if i in OPECODE:
            opecode_count += 1
        elif int(i) < 0 or int(i) > 10**6:
            print(ERROR_INPUT)
            sys.exit(1)
        else:
            operand_count += 1

    if opecode_count < 1 or opecode_count > 100:
        print(ERROR_INPUT)
        sys.exit(1)

    if operand_count < 2 or operand_count > 100:
        print(ERROR_INPUT)
        sys.exit(1)

    return inp


main()

Measured memory_bytes: 5612
#include<bits/stdc++.h>
using namespace std;
const int m=100000+5;
int a[m];
int main()
{
	int n;
	
	cin >> n;
	for(int i=0;i<n;i++)
		cin >> a[i];
	int f=1;
	for(int i=n-1;i>0;i--){
		if(a[i] < a[i-1]){
			if(a[i-1] -  a[i] == 1) a[i-1] =a[i-1]-1;
			else {
				f=0;break;
			}
		}
	}
	if(f) printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

class Program
{
    public static void Main()
    {
        var line = Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray();

        double N = line[0];
        double K = line[1];

        double ans = 0;

        for (int x = 1; x <= N; x++)
        {

            bool a = true;
            int i = -1;
            while (a)
            {
                i = i + 1;
                if (Math.Pow(2, i) * x >= K)
                {
                    a = false;
                }
            }

            ans = ans + ((1 / N) * Math.Pow(0.5, i));

        }

        Console.WriteLine(ans);
    }
}




Measured memory_bytes: 13268
import math

def primes():
    a = 55555
    primes = [i for i in range(a)]
    primes[1] = 0

    for prime in primes:
        if prime > math.sqrt(a):
            break
        if prime == 0: continue
        for non_prime in range(2 * prime, a, prime):
            primes[non_prime] = 0
    return [prime for prime in primes if prime != 0]

N = int(input())
k = 0
p = primes()
i = 0
while k < N:
    if p[i] % 5 == 1:
        print(p[i], end = ' ')
        i += 1
        k += 1
    else:
        i += 1
print()

Measured memory_bytes: 5272
def IsCircleInRect(W, H, x, y, r):

    x_left = x
    x_right = W - x
    y_upper = H - y
    y_lower = y

    if (x < 0) | (y < 0) | (x > W) | (y > H):
        print("No")
    elif (x_left < r) | (x_right < r) | (y_upper < r) | (y_lower < r):
        print("No")
    else:
        print("Yes")

if __name__ == "__main__":

    param = input()
    param = param.split(" ")

    W = int(param[0])
    H = int(param[1])
    x = int(param[2])
    y = int(param[3])
    r = int(param[4])

    IsCircleInRect(W, H, x, y, r)


Measured memory_bytes: 5600
import java.util.Scanner;
public class Main {
  public static void main(String... args) {
    Scanner scan = new Scanner(System.in);
    int count = scan.nextInt();
    double sum = 0;
    for (int i=0; i<count&&scan.hasNextInt(); i++) {
      int in = scan.nextInt();
      sum += ((double)1/(double)in);
    }
    System.out.println(1/sum);
  }
}

Measured memory_bytes: 22996
n = input()
n=int(n)

h=[]
h.append(input().split())
ans =1
check_flag=0

for i in range(n):
	if i ==0:
		continue
	for  k in range(i):
		if int(h[0][i]) < int(h[0][k]):
			check_flag = 1
	if check_flag !=1:
		ans +=1
	check_flag=0
print(ans)

Measured memory_bytes: 3064
l, r = map(int, input().split())
ans = 2018

if r - l >= 2018:
    print(0)
else:
    for i in range(l, r + 1):
        for j in range(i + 1, r + 1):
            ans = min(ans, (i * j) % 2019)
    print(ans)


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

int main()
{
    int n, y; cin >> n >> y; y /= 1000;

    for(int i = 0; i <= n; i++)
    for(int j = 0; j <= n; j++) if(i + j <= n)
    {
        int k = n - i - j;

        int sum = i * 10 + j * 5 + k;

        if(sum == y)
        {
            cout << i << ' ' << j << ' ' << k << endl;
            return 0;
        }
    }

    cout << -1 << ' ' << -1 << ' ' << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        s:chars,
    }
    let mut length = 0;
    for start in 0..s.len() {
        for end in start..s.len() {
            if s[end]!='A' && s[end]!='C' && s[end]!='G' && s[end]!='T' {
                length = std::cmp::max(length, end-start);
                break;
            }
            if end==s.len()-1 {
                length = std::cmp::max(length, end - start + 1);
            }
        }
    }
    println!("{}", length);
}

Measured memory_bytes: 4352
X = int(input())
l = -1
r = 10**10
while r - l > 1:
    m = l + (r-l)//2
    if m*(m+1)//2 > X:
        r = m
    else:
        l = m
    # print(l, m, r)
print(l if l*(l+1)//2 == X else r)


Measured memory_bytes: 38384
def someSum(i):
    return sum([ord(c) - 48 for c in "%d"%i])

def foo(n, a, b):
    r = 0
    for i in range(n+1):
        s = someSum(i)
        if a <= s <= b:
            r += i
    return r

if __name__ == "__main__":
    n, a, b = map(int, input().split())
    print(foo(n, a, b))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
template<typename T, int N, T F(const T& a, const T& b)>
struct SegTree
{
public:
    SegTree()
    {
        dat = vector<T>(N * 2 - 1, 0);
    }

    void update(int i, T x)
    {
        i += N - 1;
        dat[i] = x;
        while (i > 0)
        {
            i = (i - 1) / 2;
            dat[i] = F(dat[i * 2 + 1], dat[i * 2 + 2]);
        }
    }

    T query(int a, int b, int k = 0, int l = 0, int r = N)
    {
        if (r <= a || b <= l) return 0;
        if (a <= l && r <= b) return dat[k];
        else
        {
            T vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
            T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
            return F(vl, vr);
        }
    }

    vector<T> dat;
};

/*------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
------------------------------------------------------------------------------*/











//------------------------------------------------------------------------------
const int maxQ = 200005;
int N, Q;
string s;
int ch[maxQ], dir[maxQ];
//------------------------------------------------------------------------------
bool Left(int p)
{
    rep(i, 0, Q)
    {
        if (s[p] - 'A' == ch[i])
        {
            p += dir[i];
            if (p < 0) return true;
            if (p >= N) return false;
        }
    }
    return false;
}

bool Right(int p)
{
    rep(i, 0, Q)
    {
        if (s[p] - 'A' == ch[i])
        {
            p += dir[i];
            if (p >= N) return true;
            if (p < 0) return false;
        }
    }
    return false;
}


void _main()
{
    cin >> N >> Q;
    cin >> s;

    rep(i, 0, Q)
    {
        string t, d;
        cin >> t >> d;
        ch[i] = t[0] - 'A';
        dir[i] = d[0] == 'L' ? -1 : 1;
    }
    int ans = N;
    int l = -1, r = N;
    while (r - l > 1)
    {
        int m = (l + r) / 2;
        if (Left(m)) l = m;
        else r = m;
    }
    ans -= r;
    l = -1, r = N;
    while (r - l > 1)
    {
        int m = (l + r) / 2;
        if (Right(m)) r = m;
        else l = m;
    }
    ans -= (N - r);
    cout << ans << endl;
}


Measured memory_bytes: 2196
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn inversion(a: &mut [u32]) -> u64 {
    let n = a.len();
    if n <= 1 {
        return 0;
    }
    let m = n / 2;
    let mut ans = inversion(&mut a[0..m]);
    ans += inversion(&mut a[m..]);
    let mut tmp = vec![0; m];
    tmp.copy_from_slice(&a[0..m]);
    let mut i = 0;
    let mut j = m;
    let mut k = 0;
    while i < m && j < n {
        if tmp[i] > a[j] {
            ans += (m - i) as u64;
            a[k] = a[j];
            j += 1;
        } else {
            a[k] = tmp[i];
            i += 1;
        }
        k += 1;
    }
    while i < m {
        a[k] = tmp[i];
        i += 1;
        k += 1;
    }
    ans
}
fn main() {
    input!{
        n: usize,
        k: u64,
        a: [u32;n]
    }
    let MOD:u64 = 1_000_000_007;
    let mut b = a.clone();
    let mut c = a.clone();
    let mut a = &mut a.clone()[..];
    b.append(&mut c);
    // println!("{:?}", b);
    let mut b = &mut b.clone()[..];
    let ans0: u64 = inversion(&mut a);
    let ans1 = inversion(&mut b);
    let sec = ans1 - ans0*2;
    let ans = (((ans0%MOD)*(k%MOD))%MOD + (((k*(k-1)/2)%MOD)*(sec%MOD))%MOD)%MOD;
    // println!("{}", ans0);
    // println!("{}", ans1);
    println!("{}", ans);
}

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

int a[210] = { 0 }, n;

int main() {
	cin >> n;
	int len = 2 * n, ans = 0;
	for (int i = 0; i < len; i++) cin >> a[i];
	sort(a, a + len);
	for (int i = 0; i < len; i += 2) ans += a[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3620
using System;

namespace _2_A
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int N = int.Parse(Console.ReadLine());
                if (N == 0)
                {
                    break;
                }
                int[] A = new int[N];
                for (int i = 0; i < N; i++)
                {
                    A[i] = int.Parse(Console.ReadLine());
                }
                bool flag = true;
                int p = 0;
                while (flag)
                {
                    flag = false;
                    for (int j = N - 1; j > 0; j--)
                    {
                        if (A[j] < A[j - 1])
                        {
                            int x = A[j];
                            A[j] = A[j - 1];
                            A[j - 1] = x;
                            flag = true;
                            p++;
                        }
                    }
                }
                Console.WriteLine(p);
            }
        }
    }
}

Measured memory_bytes: 9196
//=================================
// Created on: 2018/07/03 17:26:33
//=================================
// 7+9:52~
#include <bits/stdc++.h>
using namespace std;
int main()
{
    for (string s;;) {
        cin >> s;
        if (s == "#") { break; }
        int H = 0, W = 0;
        vector<vector<bool>> ball(9, vector<bool>(9, false));
        for (int i = 0, w = 0; i < s.size(); i++) {
            if (s[i] == '/') {
                H++, W = w, w = 0;
            } else if (s[i] == 'b') {
                ball[H][w] = true, w++;
            } else {
                w += s[i] - '0';
            }
        }
        H++;
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a--, b--, c--, d--;
        ball[a][b] = false, ball[c][d] = true;
        string ans;
        for (int i = 0; i < H; i++) {
            int hole = 0;
            for (int j = 0; j < W; j++) {
                if (ball[i][j]) {
                    if (hole > 0) { ans += to_string(hole), hole = 0; }
                    ans.push_back('b');
                } else {
                    hole++;
                }
            }
            if (hole > 0) { ans += to_string(hole), hole = 0; }
            ans.push_back('/');
        }
        ans.pop_back();
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3252
#include<cstdio>

using namespace std;
long long a[51],p[51];

long long f(int n,long long int x){
	if(n == 0){
		return x<=0?0:1;
	}
	if(x == 1)
		return 0;
	if(x <= 1 + a[n-1])
		return f(n-1,x-1);
	else if(x == 2 + a[n-1])
		return 1 + p[n-1];
	else if(x <= 2 + 2 * a[n-1])
		return p[n-1] + 1 + f(n-1,x-2-a[n-1]);
	else if(x == 3 + 2*a[n-1])
		return 1 + 2*p[n-1];
}
int main(){
	int n;
	long long x;
	scanf("%d %lld",&n,&x);
	a[0] = 1;
	p[0] = 1;
	for(int i = 1;i<n;i++){
		a[i] = 2*a[i-1] + 3;
		p[i] = 2*p[i-1] + 1;
//		printf("[%d]:%lld\n",i,a[i]);
	}
	printf("%lld\n",f(n,x));
}


Measured memory_bytes: 128
count_cookie = str(input())
count_cookie = count_cookie.split()
i = 0
while i < len(count_cookie):
    count_cookie[i] = int(count_cookie[i])
    i += 1

count = 0
while count < count_cookie[2]:
    if count % 2 == 0:
        if count_cookie[0] % 2 != 0:
            count_cookie[0] = count_cookie[0] - 1
            give_cookie = count_cookie[0] / 2
            count_cookie[0] = count_cookie[0] - give_cookie
            count_cookie[1] = count_cookie[1] + give_cookie
        else:
            give_cookie = count_cookie[0] / 2
            count_cookie[0] = count_cookie[0] - give_cookie
            count_cookie[1] = count_cookie[1] + give_cookie
    else:
        if count_cookie[1] % 2 != 0:
            count_cookie[1] = count_cookie[1] - 1
            give_cookie2 = count_cookie[1] / 2
            count_cookie[1] = count_cookie[1] - give_cookie2
            count_cookie[0] = count_cookie[0] + give_cookie2
        else:
            give_cookie2 = count_cookie[1] / 2
            count_cookie[1] = count_cookie[1] - give_cookie2
            count_cookie[0] = count_cookie[0] + give_cookie2

    count += 1

print("{0:.0f} {1:.0f}".format(count_cookie[0],count_cookie[1]))


Measured memory_bytes: 3064
n,k = map(int, input().split())
p = list(map(int, input().split()))
ans = 0

for i in range(n-k+1):
    if i==0:
        t=sum(p[0:k])
    else:
        t=t-p[i-1]+p[i+k-1]
    ans=max(ans,t)

print((ans+k)/2)

Measured memory_bytes: 24812
#include<bits/stdc++.h>
#define MN 1000000
#define mod 998244353
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
bool B[MN+5];
int n,a[MN+5],b[MN+5],ans,c[MN+5],num,s[MN/5+5],mu[MN+5],inv[MN+5];
int main()
{
    n=read();inv[0]=inv[1]=mu[1]=1;
    for(int i=2;i<=MN;++i) inv[i]=1LL*(mod-mod/i)*inv[mod%i]%mod;
    for(int i=1,j;i<=n;++i) j=read(),(a[j]+=j)%=mod,ans=(ans+mod-j)%mod;
    for(int i=2;i<=MN;++i)
    {
        if(!B[i]) s[++num]=i,mu[i]=-1;
        for(int j=1;i*s[j]<=MN;++j)
        {
            B[i*s[j]]=1;
            if(i%s[j]==0) break;
            mu[i*s[j]]=-mu[i];
        }
    }
    for(int i=1;i<=MN;++i) for(int j=i;j<=MN;j+=i)  
        b[i]=(b[i]+a[j])%mod,c[j]=(c[j]+1LL*inv[i]*mu[j/i])%mod;
    for(int i=1;i<=MN;++i) ans=(ans+1LL*(c[i]+mod)*b[i]%mod*b[i])%mod;
    cout<<1LL*ans*inv[2]%mod;
    return 0;
}

Measured memory_bytes: 21504
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define r(a,b) for(int i=a;i<b;i++)
int main() {
    int n,m;
    cin>>n>>m;
    vector<vector<int>>g(n);
    r(0,m)
    {
        int h,k;
        cin>>h>>k;
        h--;
        k--;
        g[h].push_back(k);
        g[k].push_back(h);
    }
    queue<int> q;
    int ans[n];
    memset(ans,-1,sizeof ans);
    // r(0,n)ans[i]=-1;
    q.push(0);
    while(!q.empty())
    {
        int tem = q.front();
        q.pop();
        for(auto nbr:g[tem])
        {
            // cout<<tem<<":"<<nbr<<"\n";
            if(ans[nbr]<0)
            {
                ans[nbr] = tem;
                q.push(nbr);
            }
        }
    }
    cout<<"Yes\n";
    r(1,n)
    {
        cout<<ans[i]+1<<"\n";
    }
}


Measured memory_bytes: 10144
#include<stdio.h>
#include<iostream>
#include<string>
#include<math.h>

using namespace std;

int min(int* rep,bool isPasta) {
	int length;
	if (isPasta)length = 3;
	else length = 2;

	int min = rep[0];

	for (int i = 1; i < length; i++) {
		if (min > rep[i]) {
			min = rep[i];
		}
	}
	return min;

}


int main(){

	int pasta[3];
	int juice[2];

	cin >> pasta[0] >> pasta[1] >> pasta[2] >> juice[0] >> juice[1];

	int minPasta = min(pasta,true);
	int minJuice = min(juice, false);

	cout << minPasta + minJuice - 50 << endl;



	//system("pause");
    return 0;
}




Measured memory_bytes: 3080
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
dd = [(0,-1),(1,0),(0,1),(-1,0)]
ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    while True:
        n,l = LI()
        if n == 0:
            break
        a = []
        b = []
        for _ in range(n):
            d,p = LS()
            if int(p) % 2 == 0:
                a.append((d,int(p),_+1))
            else:
                b.append((d,int(p),_+1))

        lc = 0
        rm = 0
        rf = False
        for d,p,i in a:
            if d == 'L':
                lc += 1
            m = int(p)
            if d == 'R':
                m = l - m
            if rm < m or (rm == m and d == 'L'):
                rm = m
                rf = d == 'R'
        ri = lc
        if rf:
            ri = lc + 1
        ari = -1
        if a:
            ari = a[ri-1][2]

        lc = 0
        rf = False
        af = True
        for d,p,i in b:
            if d == 'L':
                lc += 1
            m = int(p)
            if d == 'R':
                m = l - m
            if rm < m or (rm == m and d == 'L'):
                rm = m
                rf = d == 'R'
                af = False
        ri = lc
        if rf:
            ri = lc + 1
        bri = -1
        if b:
            bri = b[ri-1][2]

        if af:
            rr.append('{} {}'.format(rm, ari))
        else:
            rr.append('{} {}'.format(rm, bri))

    return '\n'.join(map(str, rr))


print(main())




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

int main(){
	int A[100];
	int N;
	
	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> A[i];
	}
	
	for(int i = 1; i < N; i++){
		for(int j = 0; j < N; j++){
			cout << A[j];
			if(j != N-1) cout << ' ';
		}
		cout << endl;
		
		int v = A[i];
		int j = i - 1;
		while(j >= 0 && A[j] > v){
			A[j+1] = A[j];
			j--;
			A[j+1] = v;
		}
	}
	
	for(int j = 0; j < N; j++){
		cout << A[j];
		if(j != N-1) cout << ' ';
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 1160