akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define ppll pair<ll,pll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
// #define ll int
using namespace std;
const ll INF = 1 << 29;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const int MAX_V = 500;
// const ll mod = 998244353;
const ll MAX = 2100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
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; }



void solve() {
    ll n,x,t;
    cin>>n>>x>>t;
    ll ans = (n/x)*t;
    if(n%x!=0) ans+=t;
    cout<<ans<<endl;
}







signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);


    ll t=1;
    rep(i,t){
        solve(); 
    }


    return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>
int main(void)
{
    char s[13];
    scanf("%s",s);
    printf("%c%c%c%c %c%c%c%c%c%c%c%c\n",s[0],s[1],s[2],s[3],s[4],s[5],s[6],s[7],s[8],s[9],s[10],s[11]);
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

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

        int N = scanner.nextInt();
        int[] stones = new int[N];

        dp = new Long[N + 1][N + 1];

        for (int i = 0; i < stones.length; i++) {
            stones[i] = scanner.nextInt();
        }

        System.out.printf("%d\n", recurse(stones, 0, stones.length - 1));
    }

    private static long recurse(int[] stones, int l, int r) {
        if (l == r) {
            return stones[l];
        }

        if (dp[l][r] != null) {
            return dp[l][r];
        }

        dp[l][r] = Math.max(stones[l] - recurse(stones, l + 1, r), stones[r] - recurse(stones, l, r - 1));
        return dp[l][r];
    }
}

Measured memory_bytes: 193780
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    List<List<String>> bubble = new ArrayList<>();
    List<List<String>> select = new ArrayList<>();
    for(int i = 0; i < n; i++) {
      List<String> list = Arrays.asList(sc.next().split(""));
      bubble.add(list);
      select.add(list);
    }
    for(int i = 0; i < n; i++) {
      for(int j = n - 1; j > i; j--) {
        int k = Integer.parseInt(bubble.get(j).get(1));
        int l = Integer.parseInt(bubble.get(j - 1).get(1));
        if(k < l) {
          List<String> v = bubble.get(j);
          bubble.set(j, bubble.get(j - 1));
          bubble.set(j - 1, v);
        }
      }
      if(i == n - 1) {
        System.out.println(bubble.get(i).get(0) + bubble.get(i).get(1));
        System.out.println("Stable");
      } else {
        System.out.print(bubble.get(i).get(0) + bubble.get(i).get(1) + " ");
      }
    }
    boolean stable = true;
    for(int i = 0; i < n; i++) {
      int min = i;
      for(int j = i; j < n; j++) {
        int k = Integer.parseInt(select.get(j).get(1));
        int l = Integer.parseInt(select.get(min).get(1));
        if(k < l) {
          min = j;
        }
      }
      List<String> v = select.get(i);
      select.set(i, select.get(min));
      select.set(min, v);
      String bub = bubble.get(i).get(0) + bubble.get(i).get(1);
      String sel = select.get(i).get(0) + select.get(i).get(1);
      if(!bub.equals(sel)) {
        stable = false;
      }
      if(i == n - 1) {
        System.out.println(select.get(i).get(0) + select.get(i).get(1));
        if(stable) {
          System.out.println("Stable");
        } else {
          System.out.println("Not stable");
        }
      } else {
        System.out.print(select.get(i).get(0) + select.get(i).get(1) + " ");
      }
    }
  }
}



Measured memory_bytes: 26536
#include<bits/stdc++.h>
inline int getint(void)
{
    int n=0,f=1;
	char ch=getchar();
    while(ch<'0'||ch>'9')
    {
        if(ch=='-') f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9')
    {
        n=n*10+ch-'0';
        ch=getchar();
    }
    return n*f;
}
int main(void)
{
	int a=getint(),b=getint();
	if(a>0&&b>0) printf("Positive\n");
	else if(a<0&&b>0) printf("Zero\n");
	else if((abs(a-b)+1)&1) printf("Negative\n");
	else printf("Positive\n");
	return 0; 
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdio.h>

int main(void) {
	double x1, y1, x2,y2;
	
	double a;
	
	scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
	
	a = hypot(x2-x1,y2-y1);
	
	printf("%lf\n", a);
	
	return 0;
}

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

int main(){
  int w,h;
  char a;
  cin >> h >> w;
  cin >> a;
  char c[25][25];
  for(int i=0; i<w; i++){
    for(int j=0; j<h; j++){
      if(i==0 || i==w-1){
        if(j==0 || j==h-1) c[i][j] = '+';
        else c[i][j] = '-';
      }
      else{
        if(j==0 || j==h-1) c[i][j] = '|';
        else c[i][j] = '.';
      }
    }
  }
  c[w/2][h/2] = a;
  for(int i=0; i<w; i++){
    for(int j=0; j<h; j++){
      cout << c[i][j];
    }
    cout << endl;
  }      
  return 0;
}



Measured memory_bytes: 3092
def get_div(n):
    div = []
    append = div.append
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            append(i)
            if i != n // i:
                append(n // i)
    div.sort()
    return div


# input
N = int(input())

# div = divisors(N)
div = get_div(N)
mov = []
append = mov.append
for x in div:
    y = N // x
    append(sum([x - 1, y - 1]))

print(min(mov))

# check
cnt = 0

Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
int main(){
    vector <int> lineA1(3,0);
    vector <int> lineA2(3,0);
    vector <int> lineA3(3,0);
    for(int i = 0; i<3; i++){
        cin>>lineA1[i];
    }
    for(int i = 0; i<3; i++){
        cin>>lineA2[i];
    }
    for(int i = 0; i<3; i++){
        cin>>lineA3[i];
    }
    int n;
    cin >> n;
    vector <int> b(n,0);
    for(int i = 0; i<n; i++){
        cin>> b[i];
    }
    #if 0
    for(int i = 0; i<3; i++){
        cout << lineA1[i] << " ";
    }
    cout << endl;
    for(int i = 0; i<3; i++){
        cout << lineA2[i] << " ";
    }
    cout << endl;
    for(int i = 0; i<3; i++){
        cout << lineA3[i] << " ";
    }
    cout << endl;
    for(int i = 0; i< n; i++){
        cout << b[i] << " ";
    }
    cout << endl;
    #endif
    for(int i = 0; i<n; i++){
        for(int j = 0; j<3; j++){
            if(b[i]==lineA1[j])lineA1[j]=0;
            if(b[i]==lineA2[j])lineA2[j]=0;
            if(b[i]==lineA3[j])lineA3[j]=0;
        }
    }
    #if 0
    for(int i = 0; i<3; i++){
        cout << lineA1[i] << " ";
    }
    cout << endl;
    for(int i = 0; i<3; i++){
        cout << lineA2[i] << " ";
    }
    cout << endl;
    for(int i = 0; i<3; i++){
        cout << lineA3[i] << " ";
    }
    cout << endl;
    #endif
    string ans = "No";
    for(int i = 0; i<3; i++){
        if(lineA1[i]==0){
            if(lineA1[i]==lineA2[i]){
                if(lineA2[i]==lineA3[i]){
                    ans="Yes";
                    break;
                }
            }
        }
    }
    if((lineA1[0]==lineA1[1])&&(lineA1[1]==lineA1[2])){
        if(lineA1[0]==0)ans="Yes";
    }
    if((lineA2[0]==lineA2[1])&&(lineA2[1]==lineA2[2])){
        if(lineA2[0]==0)ans="Yes";
    }
    if((lineA3[0]==lineA3[1])&&(lineA3[1]==lineA3[2])){
        if(lineA3[0]==0)ans="Yes";
    }
    //naname
    if((lineA3[0]==lineA2[1])&&(lineA2[1]==lineA1[2])){
        if(lineA3[0]==0)ans="Yes";
    }
    if((lineA1[0]==lineA2[1])&&(lineA2[1]==lineA3[2])){
        if(lineA1[0]==0)ans="Yes";
    }
    cout << ans << endl;

    
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <utility>
#include <vector>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

using vb = vector<bool>;
using vv = vector<vb>;

int max_value(vv &s, vv &r, size_t n) {
	if (s.size() == n) {
		int c = 0;
		for (size_t i = 0; i < r[0].size(); i++) {
			size_t t = 0;
			for (size_t j = 0; j < r.size(); j++)
				t += r[j][i];
			int x = max(t, r.size() - t);
			c += x;
		}
		return c;
	}
	r.push_back(s[n]);
	int a = max_value(s, r, n + 1);
	r[n].flip();
	int b = max_value(s, r, n + 1);
	r.pop_back();
	return max(a, b);
}

int main() {
	for (int r, c; r = in(), c = in(), r || c;) {
		vv S = vv(r, vb(c)), R;
		for (auto &s: S)
			for (size_t i = 0; i < s.size(); i++)
				s[i] = in();
		outl(max_value(S, R, 0));
	}
}


Measured memory_bytes: 2460
H, W, K = list(map(int, input().split()))
C = []
for _ in range(H):
    row = input()
    C.append(row)


def check(use_rows, use_cols):
    count = 0
    for i in range(H):
        if i in use_rows:
            continue
        for j in range(W):
            if j in use_cols:
                continue
            if C[i][j] == '#':
                count += 1
    return count


count = 0
for bit_row in range(2 ** H):
    use_rows = set()
    for i in range(H):
        if (bit_row >> i & 1):
            use_rows.add(i)

    for bit_col in range(2 ** W):
        use_cols = set()
        for j in range(W):
            if (bit_col >> j & 1):
                use_cols.add(j)

        # print(bit_row, bit_col, use_rows, use_cols)
        if K == check(use_rows, use_cols):
            # print(use_rows, use_cols)
            count += 1

print(count)


Measured memory_bytes: 68956
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????

		//System.out.println("??\???>>");

		Scanner scan = new Scanner(System.in);
		//ArrayList<Integer[]> list = new ArrayList<Integer[]>();

		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();

		int intCount = 0;

		if(a < b){

			for(int i = a; i <= b; i++){

				if(c % i == 0){
					intCount++;
				}
				//System.out.println("i: " + i);
			}
			//System.out.println("intCount: " + intCount);
			System.out.println(intCount);
		}else{

			for(int i = b; i <= a; i++){

				if(c % i == 0){
					intCount++;
				}
				//System.out.println("i: " + i);
			}
			//System.out.println("intCount: " + intCount);
			System.out.println(intCount);
		}

	}
}

Measured memory_bytes: 17232
N = int(input())
XL = [list(map(int,input().split())) for _ in range(N)]
r_l = []
for n in range(N):
  xl = XL[n]
  x = xl[0]
  l = xl[1]
  r_l.append([x-l,x+l])

r_l = sorted(r_l,key = lambda x:x[1])
ans = 1
l = r_l[0][1]
for a in r_l:
  if a[0]<l:
    continue
  else:
    ans += 1
    l = a[1]
    
print(ans)

Measured memory_bytes: 43560
#include<iostream>
#include<vector>
#include<algorithm>
#include<string.h>
using namespace std;

struct hg
{
	int l;
	int m;
};


int m, n;
vector<int> man;
vector<hg> hako;
int memo[30000];

int dp(int h, int ma)
{
	if (h >= n)return 0;
	memo[ma] = min(memo[max(0,ma - hako[h].l)] + hako[h].m,memo[ma]);
	if (ma == 0)return 0; else dp(h, ma - 1);
	return 0;
}

int main()
{
	cin >> m >> n;
	memset(memo, -1, sizeof(memo));
	for (int i = 0; i < m; i++)
	{
		int x;
		cin >> x;
		man.push_back(x);
	}
	for (int i = 0; i < 30000; i++)memo[i] = 9999999999999;
	sort(man.rbegin(), man.rend());
	for (int i = 1; i < m; i++)
	{
		man[i] += man[i - 1];
	}
	for (int i = 0; i < n; i++)
	{
		hg o;
		cin >> o.l >> o.m;
		hako.push_back(o);
	}
	int ans = 0;
	memo[0] = 0;
	for (int i = 0; i < n;i++)dp(i, m);
	for (int i = 1; i <= m; i++)
	{
		ans = max(-1 *( memo[i] - man[i-1]), ans);
	}
	cout << ans << endl;

}

Measured memory_bytes: 1600
from math import*
def solve(B):
    α=b*sin((90-B)*pi/180)/sin(B*pi/180)
    s=α*b/2
    if α>a:s-=(α-a)*(b-b*a/α)/2
    return s>=x/a
a,b,x=map(int,input().split())
ok=0
ng=90
while ng-ok>1e-7:
    mid=(ok+ng)/2
    if solve(mid):ok=mid
    else:ng=mid
print(ok)

Measured memory_bytes: 3316
program main
  implicit none

  integer a, b

  read(*,*)a, b
  if (b <0) then
    if (a < 0) then
      write(*,*)a*b
    else
      write(*,*)a-b
    end if
  else
    write(*,*)max(a+b,a*b)
  end if

end program main

Measured memory_bytes: 256
import Control.Monad
import Control.Monad.ST
import qualified Data.Array as A
import qualified Data.Array.ST as ST
import qualified Data.Array.Unboxed as AU
import qualified Data.ByteString.Char8 as BS
import Data.Char
import Data.Int
import qualified Data.IntMap as IM
import Data.List
import qualified Data.Map as M
import Data.Maybe
import Data.Ord
import qualified Data.Set as S
import Data.Time
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

main = do
  [x, y] <- map read . words <$> getLine
  print $ solve x y

solve x y = f x y 1
  where
    f acc y len
      | acc * 2 <= y = f (acc * 2) y (len + 1)
      | otherwise = len

Measured memory_bytes: 508
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <iostream>
#include <climits>
#include <algorithm>
using namespace std;

int main(void){
    int a,b,t;
    cin >> a >> b >> t;
    int num = (int)(t + 0.5) / a;
    int ans = b*num;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<limits.h>
#include<cmath>
#include<queue>
#define rep(i,n) for (int i=0; i<n; i++)
using namespace std;
typedef long long ll;

ll gcd(ll a,ll b){
  ll r;
  while ((r=a%b)){a=b;b=r;}
  return b;
}

int main(){

  ll a,b; cin >> a >> b;
  ll g = gcd(a,b);
  ll k=2;
  ll ans=0;
  while (g!=1 && k*k<=g){
    int isP=0;
    while (g%k==0){
      g/=k;
      isP=1;
    }
    if (isP) {ans++;}
    k++;
  }

  if (g!=1) {ans++;}
  cout << ans+1;
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  long long ans = 0;
  while ( n-- > 0 ) {
    long long a;
    cin >> a;
    a--;
    ans += a;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3580
n, m = map(int, input().split())
A = [list(map(int, input().split())) for i in range(n)]
b = [int(input()) for i in range(m)]
for i in range(n):
    c = 0
    for j in range(m):
        c += A[i][j] * b[j]
    print(c)



Measured memory_bytes: 6012
#include <iostream>

using namespace std;

int main(){
	int N;
	cin >> N;
	string s;
	cin >> s;
	for(size_t i = 0; i < s.size(); i++)
		s[i] = 'A' + (s[i] - 'A' + N)%26;

	cout << s << '\n';

	return 0;
}

Measured memory_bytes: 256
import itertools

# AGC
# ACG
# GAC
# A*GC
# AG*C
mod = 10 ** 9 + 7
N = int(input())
keys = [i + j + k for i, j, k in itertools.product('ACGT', repeat=3)]
dp = [dict() for _ in range(N)]
for i in range(N):
    for key in keys:
        dp[i][key] = 0

for key in keys:
    if key in ['AGC', 'ACG', 'GAC']:
        val = 0
    else:
        val = 1
    dp[2][key] = val

for i in range(2, N - 1):
    for key, val in dp[i].items():
        nexts = {'A', 'C', 'G', 'T'}
        if key[1:] == 'AG':
            nexts.discard('C')
        elif key[1:] == 'AC':
            nexts.discard('G')
        elif key[1:] == 'GA':
            nexts.discard('C')
        if key[0] == 'A' and (key[1] == 'G' or key[2] == 'G'):
            nexts.discard('C')
        for ne in nexts:
            next_key = key[1:] + ne
            dp[i + 1].setdefault(next_key, 0)
            dp[i + 1][next_key] += val
print(sum(dp[N - 1].values()) % mod)


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
int main(){
    ll n ,k;
    cin >> n >> k;
    ll r = 1e12+1;
    ll l = 0;
    vector<ll>a(n);
    vector<ll>f(n);
    ll ans = r;
    rep(i,n){
        cin >> a[i];
    } 
    rep(i,n){
        cin >> f[i];
    }
    sort(a.begin(),a.end());
    sort(f.begin(),f.end(),greater<ll>());
    while(l<r){
        ll m = (l+r)/2;
        ll cnt = 0; 
        rep(i,n)
        {
            if(a[i]*f[i]>m){
                cnt+=a[i]-m/f[i];
            }
        }
        if(cnt>k){
            l = m+1;
        }
        else{
            ans = min(ans,m);
            r = m;
        }
    }
    cout << ans << endl;
return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 5, INF = 0x3f3f3f3f, M = N << 1;
const ll LNF = 0x3f3f3f3f3f3f3f3f;
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define per(i, r, l) for (int i = r; i >= l; i--)
#define repe(i, u) for (int i = head[u]; i; i = nxt[i])



int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  string s1, s2;
  cin >> s1 >> s2;
  int ans = 0;
  rep(i, 0, 2) if (s1[i] == s2[i]) ans++;
  cout << ans << '\n';
}

Measured memory_bytes: 256
def check():
  S = input()
  T = input()

  if len(S) != len(T) or False in [ S.count(s) == T.count(s) for s in list(set(S))]:
    print("No")
    return
  i = 0
  lim = len(T)
  while i < lim:
    S = S[-1] + S[0:-1]
    if S == T:
      print("Yes")
      return
    i += 1
    
  print("No")

check()

Measured memory_bytes: 3060
/* Harsh Pathak - pogba */
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
const int N = 100;
int n;
const int W0 = 1e5;
int W;
int v[N];
int w[N];
ll dp[N+1][W0+1];
int main(int argc, char const *argv[])
{
	cin >> n >> W;
	for (int i = 0; i < n; ++i)
	{
		cin >> w[i] >> v[i]; 
	}
	for (int i = 0; i < n+1; ++i)
	{
		for (int j = 0; j < W+1; ++j)
		{
			if(i == 0 || j == 0){
				dp[i][j] = 0;
				continue;
			}
			dp[i][j] = -1;
			dp[i][j] = max(dp[i][j], dp[i-1][j]);
			if(j - w[i-1] >= 0)dp[i][j] = max(dp[i][j], v[i-1] + dp[i-1][j - w[i-1]]);
		}
	}
	cout << dp[n][W] << endl;
	return 0;
}

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

using namespace std;

#define LL long long
#define pb push_back
#define pLL pair<LL,LL>
#define ff first
#define ss second
#define rep(i,a,b) for(LL i=a;i<=b;++i)
#define ld double
#define mp make_pair
#define vLL vector<LL>
#define vpLL vector<pLL>
#define vld vector<ld>
#define pld pair<ld,ld>
#define vpld vector<pld>
#define SLL set<LL>
#define SpLL set<pLL>
#define FIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)

int main()
{
    LL a,b,c;
    cin>>a>>b>>c;
    if(a+b==c||b+c==a||c+a==b) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
h = list(map(int,input().split()))
edge =  [[] for _ in range(n)]
ans = 0
for i in range(m):
    a,b = map(int,input().split())
    edge[a-1].append(h[b-1])
    edge[b-1].append(h[a-1])
for j in range(n):
    if edge[j]==[] or h[j]>max(edge[j]):
        ans += 1
    
print(ans)

Measured memory_bytes: 23020
#include <bits/stdc++.h>
using namespace std;
string a,b,c;
int main() {
cin>>a>>b>>c;
a[0]=a[0]-'a'+'A';
b[0]=b[0]-'a'+'A';
c[0]=c[0]-'a'+'A';
cout<<a[0]<<b[0]<<c[0]<<endl;
}


Measured memory_bytes: 3616
IDENTIFICATION DIVISION.
PROGRAM-ID. 163A.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 R          PIC 9(3).
01 OUT        PIC Z(3).9(4).
*>
PROCEDURE DIVISION.
  ACCEPT R.
*>
  COMPUTE OUT = R * 2 * 3.1415926.
*>
  DISPLAY FUNCTION TRIM(OUT).
  STOP RUN.


Measured memory_bytes: 3880
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

template <class T>
std::map<T, int> compress(std::vector<T>& v) {
    std::sort(v.begin(), v.end());
    v.erase(std::unique(v.begin(), v.end()), v.end());

    std::map<T, int> rev;
    for (int i = 0; i < (int)v.size(); ++i) rev[v[i]] = i;
    return rev;
}

using lint = long long;
constexpr lint INF = 30000;

bool solve() {
    int n;
    std::cin >> n;
    if (n == 0) return false;

    std::vector<lint> xs{-INF, INF}, ys{-INF, INF};
    std::vector<std::pair<lint, lint>> ps(n + 4);
    for (auto& p : ps) {
        std::cin >> p.first >> p.second;
        xs.push_back(p.first);
        ys.push_back(p.second);
    }

    auto revx = compress(xs);
    auto revy = compress(ys);

    for (auto& p : ps) {
        p.first = revx[p.first];
        p.second = revy[p.second];
    }

    auto crossing = [&](int x, int y, int i, int j) {
        if (ps[i].second <= y) return false;

        int xi = ps[i].first,
            xj = ps[j].first;

        for (int q = 0; q < 2; ++q) {
            if (xi <= x && x + 1 <= xj) return true;
            std::swap(xi, xj);
        }
        return false;
    };

    lint ans = 0;
    int h = xs.size(), w = ys.size();
    for (int x = 0; x + 1 < h; ++x) {
        for (int y = 0; y + 1 < w; ++y) {
            int cnt = 0;
            for (int i = 0; i < n; ++i) {
                int j = (i + 1) % n;
                if (crossing(x, y, i, j)) ++cnt;
            }

            if (cnt % 2 == 0) continue;

            cnt = 0;
            for (int i = 0; i < 4; ++i) {
                int j = (i + 1) % 4;
                if (crossing(x, y, n + i, n + j)) ++cnt;
            }

            if (cnt % 2 != 0) continue;

            ans += (xs[x + 1] - xs[x]) * (ys[y + 1] - ys[y]);
        }
    }

    std::cout << ans << std::endl;
    return true;
}

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

    while (solve()) {};

    return 0;
}



Measured memory_bytes: 3112
import sys

sys.setrecursionlimit(10 ** 9)


def rec(v):
    if dp[v] != -1:
        return dp[v]

    res = 0
    for nv in g[v]:
        res = max(res, rec(nv) + 1)
    dp[v] = res
    return res


N, M = map(int, input().split())
g = [[] for _ in range(N)]
for _ in range(M):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    g[x].append(y)

dp = [-1 for _ in range(N)]

ans = 0
for t in range(N):
    ans = max(ans, rec(t))
print(ans)


Measured memory_bytes: 59172
import java.util.*;

public class Main {
	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		int ans[] = new int[1001];
		for(int i=1;i<1000;i++){
			for(int j=i+1; j<1001;j++){
				int sum = (j-i+1)*(i+j)/2;
				if(sum<=1000) ans[sum]++;
			}
		}
		while(true){
			int n = in.nextInt();
			if(n==0) return ;
			System.out.println(ans[n]);
		}
	}
}

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

int main ()
{
    long n;
    cin >> n ;
    long minV=2000000009;
    long maxV=-2000000009;
    long tmp;
    for(long i=0;i<n;i++){
        cin >> tmp;
        maxV=max(maxV,tmp-minV);
        minV=min(tmp,minV);
    }
    cout << maxV << endl;
    return 0;
}










Measured memory_bytes: 3096
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
int main(){
	vi dp(110001,-1);
	int a,b,c;
	cin>>a>>b>>c;
	dp[c]=c;
	vvi in(b,vi(a));
	rep(i,b)rep(j,a)cin>>in[i][j];
//			rep(k,20)cout<<k<<" "<<dp[k]<<endl;
	
	rep(i,b-1){
//cout<<endl;		rep(k,20)cout<<k<<" "<<dp[k]<<endl;
		rep(j,a){
			for(int k=110000;k>=0;k--){
				if(dp[k]==-1)continue;
				if(in[i][j]>in[i+1][j])continue;
				if(k-in[i][j]>=0)dp[k-in[i][j]]=max(dp[k-in[i][j]],dp[k]+in[i+1][j]-in[i][j]);
			}
			
		}
		//rep(k,20)cout<<k<<" "<<dp[k]<<endl;
		vi tmp(1100001,-1);
		rep(k,110000)if(dp[k]!=-1)tmp[dp[k]]=dp[k];
		dp=tmp;
	}
	for(int k=110000;k>=0;k--)if(dp[k]!=-1){cout<<k<<endl;break;}
}

Measured memory_bytes: 10116
#include <bits/stdc++.h>
using namespace std;
typedef int64_t i64;

int main()
{
  
  int A,B;
  cin >> A >> B ;

  int C = A + B;
  int D = A - B;
  int E = A * B;

  int F = max(C,D);
  int ans = max(F,E);

  cout << ans << endl;


}


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

int main() {

  string a,b;
  cin >> a;
  
  if(a == "ABC") cout << "ARC" << endl;
  else cout << "ABC" << endl;
  
  
  

}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,p,i,a,A[2];
long long ans,t;
int main() {
	cin>>n>>p;t=1; 
	for(i=1;i<=n;i++)
	cin>>a,A[a&1]++;i=0;
	while(A[1]>=0) {
		if((A[1]&1)==p) ans+=t;
		t*=A[1]--;t/=++i; 
	}
	while(A[0]) ans*=2,A[0]--;
	cout<<ans;
}

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

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
#include <complex>
#define X real()
#define Y imag()
typedef complex<double> P;
typedef pair<P, P> Line;
bool eq(double x, double y){
  if(abs(x - y) < EPS) return true;
  else return false;
}
bool eq(P a, P b){
  if(eq(a.X, b.X) && eq(a.Y, b.Y)) return true;
  else return false;
}
bool isok(vector<Line> L){
  int N = L.size();
  if(N % 2 != 0) return false;
  for(int i = 0; i < N / 2; i++){
    if(!eq(L[i].second - L[i].first, L[i + N/2].first - L[i + N/2].second)) return false;
  }
  return true;
}
int main(){
  int N;
  while(cin>>N){
    vector<P> points;
    REP(i, N){
      double x, y;
      cin>>x>>y;
      points.push_back(P(x, y));
    }
    vector<Line> lines;
    REP(i, N) lines.push_back(Line(points[i], points[(i + 1) % N]));
    if(isok(lines)){
      double ansX, ansY;
      ansX = (points[0].X + points[0 + N/2].X)/2;
      ansY = (points[0].Y + points[0 + N/2].Y)/2;
      printf("%.5lf %.5lf\n", ansX, ansY);
    }else{
      cout<<"NA"<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <sstream>
#include <iterator>
#include <complex>
using namespace std;

int main()
{
	int N;
	cin>>N;
	vector<pair<string,int>> l(N);

	for(int i=0; i<N; i++)
	{
		string s;
		int v;
		cin>>s>>v;
		v = -v;
		l[i] = make_pair(s,v);
	}
	vector<pair<string,int>> r = l;
	sort(r.begin(),r.end());

	for(int i=0; i<N; i++)
	{
		auto itr = find(l.begin(),l.end(),r[i]);
		cout<<distance(l.begin(),itr)+1<<endl;
		//cout<<r[i].first<<" "<<r[i].second<<endl;
	}
}

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


void solve() {
    string s ;
    cin >> s ;
    long long int ans = 0 ;
    for( char c : s ){
        int x = c - '0';
        ans = ans + x ;
    }
    if( ans % 9 == 0 ) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
}

int main()
{
 
/*    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("/home/yash/Desktop/CPP/input.txt","r",stdin);
    freopen("/home/yash/Desktop/CPP/output3.txt","w",stdout);
    #endif*/

    ll t  ;
    t = 1 ;
    while ( t-- ){
        solve();
    }

}





Measured memory_bytes: 3756
#include<stdio.h>
#define MAX 10000
#define NIL -1

typedef struct { int p , l , r;} Node;
Node T[MAX];
int n;

void preParse(int u) {
  if(u == NIL) return;
  printf(" %d", u);
  preParse(T[u].l);
  preParse(T[u].r);
}

void inParse(int u) {
  if(u == NIL) return;
  inParse(T[u].l);
  printf(" %d", u);
  inParse(T[u].r);
}


void postParse(int u) {
  if(u == NIL) return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d", u);

}

int main( )  {
  int i,v,l,r,root;

  scanf("%d\n",  &n);
  for(i = 0; i< n ; i++) T[i].p = NIL;
  for(i = 0; i < n;i++) {
    scanf("%d %d %d\n",&v, &l,&r );
    T[v].l = l;
    T[v].r = r;
    if(l != NIL) T[l].p = v;
    if(r != NIL) T[r].p = v;
  }

  for(i = 0; i < n ; i++)  if(T[i].p == NIL) root =i;

  printf("Preorder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");

  return 0;
}

Measured memory_bytes: 624
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int mod = 1000000007;

int main(){
    int h, w;
    cin >> h >> w;

    //処理部
    vvi dist(10, vi(10));
    rep(i, 10)rep(j, 10) cin >> dist[i][j];
    
    rep(k, 10)rep(i, 10)rep(j, 10){
        dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j]);
    }

    //出力部
    int ans = 0;
    rep(i, h)rep(j, w){
        int x;
        cin >> x;
        if(x==-1) continue;
        ans += dist[x][1];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
 
int main(){
  int j=0;
  rep(i,4){
    char x;
    cin >> x;
    if(x=='+') {
      j++;
    }
    else{
      j--;
    }
  }
  cout << j << endl;
    
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
bool solve(int p, int t);
int A[3000];
int main(){
  int n,q;
  cin >> n;
  for(int i=0;i<n;i++) cin >> A[i];	
  for(int i=0;i<n;i++) for(int j=i+1;j<n;j++)
	if(A[i]>A[j]) A[i]^=A[j]^=A[i]^=A[j];
  cin >> q;
  for(int j=0,tmp,lim,i;j<q;j++){
    cin >> tmp;
    for(i=0,lim=n-1;i<n;i++)
  	if(tmp<A[i]&&((lim=(i-1>=0?i-1:0))?true:true)) break;
    if(solve(lim,tmp)) cout << "yes\n";
    else cout << "no\n";
  }
  return 0;
}
bool solve(int i, int t){
  if(t==A[i]) return true;
  if(t<=0) return false;
  if(i==0) return false;
  if(solve(i-1,t-A[i])) return true;
  if(solve(i-1,t)) return true;
  return false;
}

Measured memory_bytes: 1124
#include <iostream>
#include <algorithm>

int main() {
    std::string S;
    std::cin >> S;
    
    size_t s_max;
    if (S.size() % 2 == 0) s_max = S.size()-2;
    else s_max = S.size()-1;
    
    for (size_t i=s_max; i>=1; i-=2) {
        std::string left = S.substr(0, i/2);
        std::string right = S.substr(i/2, i/2);
        if (left == right) {
            std::cout << i << std::endl;
            break;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll h, w; cin >> h >> w;
    vector<string> lab(h);
    rep(i, h) cin >> lab[i];
    vvi chk(h, vi(w, 0));

    // 右に動ける場合は右に移動し、行けない場合は下に行く
    queue<pair<ll, ll>> que;
    que.push(make_pair(0, 0));
    chk[0][0] = 1;
    while(que.size()){
        auto pos = que.front();
        que.pop();
        ll x = pos.second;
        ll y = pos.first;
        if(x+1 < w && lab[y][x+1] =='#'){
            que.push(make_pair(y, x+1));
            chk[y][x+1]=1;
        }
        else if(y+1 < h && lab[y+1][x] =='#'){
            que.push(make_pair(y+1, x));
            chk[y+1][x]=1;
        }
    }

    // 通った箇所と'#'の箇所が同一かチェック
    bool ans = true;
    rep(i, h){
        rep(j, w){
            if(lab[i][j] == '#' && chk[i][j] == 0) ans = false;
        }
    }

    cout << (ans ? "Possible" : "Impossible") << endl;
}

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

int main(){
  ll n,a,b;
  cin>>n>>a>>b;
  cout<<n/(a+b)*a+min(n%(a+b),a)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()
int main(){
    int r,g;cin>>r>>g;
    if(r+g>=10)cout<<"error"<<endl;
    else cout<<r+g<<endl;
}


Measured memory_bytes: 3604
#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>
#include <numeric>
#include <iomanip>
#define M_PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;

const int MAX = 510000;
const int MOD = 1000000007;

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;
}
struct edge {
	int t;
	ll cost;
	edge(int _t, ll _cost) : t(_t)
		, cost(_cost) {
	}
};
bool use[100010];

struct v {
	ll a, b, c;
};
bool comp(const v &left, const v &right) {
	return left.c > right.c;
}
void Solve() {

	int n;
	cin >> n;
	v ar[100010];
	for (size_t i = 0; i < n; i++)
	{
		cin >> ar[i].a >> ar[i].b;
		ar[i].c = abs(ar[i].a + ar[i].b);
	}
	sort(ar, ar + n,comp);
	ll res = 0;
	for (size_t i = 0; i < n; i++)
	{
		if (i % 2 == 0) {
			res += ar[i].a;
		}
		else res -= ar[i].b;
	}
	cout << res << endl;
}


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



Measured memory_bytes: 2560
l = list(map(int, input().split()))
K = int(input())

def check(nums):
    if nums[0] < nums[1]:
        if nums[1] < nums[2]:
            print('Yes')
            exit(0)

check(l)
for i in range(K):
    if l[0] >= l[1]:
        l[1] *= 2
        check(l)
        continue
    elif l[1] >= l[2]:
        l[2] *= 2
        check(l)
        continue

print('No')

exit(0)


Measured memory_bytes: 9192
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <complex>

int main(){

  long long int a, b, c;
  std::cin >> a >> b >> c;

  if(c > a+b && 4*a*b < (c-a-b)*(c-a-b)){
    std::cout << "Yes" << std::endl;
  }
  else{
    std::cout << "No" << std::endl;
  }

  return 0;
  
}


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

void printVector(vector<int> v) {
    for (auto x : v) {
        cout << x << ' ';
    }
    cout << '\n';
}

void printArray(ll A[], int size) {
    for (int i = 0; i <= size - 1; i++) cout << A[i] << ' ';
}

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

    int n, m;
    cin >> n >> m;
    int l, c;
    cin >> l >> c;
    cout << n * m - (m * l + (n - l) * c) << '\n';
    return 0;
}

Measured memory_bytes: 3620
/*
 * atcoder/abc107/c.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

const ll INF = 100000000000000000;
int N, K;
vector<ll> X;

void solve() {
  cin >> N >> K;
  ll x;
  loop(n,0,N) {
    cin >> x;
    X.push_back(x);
  }

  ll min_ = INF;
  for (int l=0; l+K-1<N; l++) {
    int r = l+K-1;
    chmin(min_, abs(X[l]) + abs(X[r] - X[l]));
    chmin(min_, abs(X[r]) + abs(X[l] - X[r]));
  }
  cout << min_ << endl;
}
int main() {
  // cout.precision(15);
  // cout << fixed << double

  solve();

  return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()
int main(){
    int d,t,s;cin>>d>>t>>s;
    if(d<=s*t){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    
}

Measured memory_bytes: 3672
def main():
	N = int(input())
	X = list(map(int, input().split()))
	x = list(X)
	x.sort()
	mid = x[N//2]
	if N % 2 == 1:
		mid = (x[N//2]+x[N//2 + 1])/2
	for i in range(N):
		if X[i] < mid:
			if N % 2 == 0:
				print(x[N//2])
			else:
				print((x[N//2]+x[(N//2)+1])/2)
		elif X[i] == mid and N % 2 == 1:
			print((x[(N//2) - 1] + x[(N//2) + 1])/2)
		else:
			if N % 2 == 0:
				print(x[(N//2)-1])
			else:
				print((x[N//2]+x[(N//2)-1])/2)


if __name__ == '__main__':
    main()

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

using Int = int;
using namespace std;

#define ARC(i, a, b) for(Int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(Int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)
template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; };
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; };
template<class T> T th(T &a, const T &b, T (*f)(const T &, const T &)){ a = f(a, b); }
#define anth(a, b) th(a, b, ant)
#define onth(a, b) th(a, b, ont)

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	RC(i, n){
		cin >> a[i];
	}
	int x = 0;
	RC(i, n){
		x ^= a[i];
	}
	cout << (x ? "No" : "Yes") << endl;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(void){ 
   int a,b,c; 
     cin >> a >> b >> c;
 if(a == b){ 
   cout << c << endl; 
 }else if(a == c){ 
   cout << b << endl; 
 }else{ 
   cout << a << endl; 
 }
 return 0;
 }

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#include <time.h>
#include <chrono>
#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a,b) for(ll i=a;i>b;i--)
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define repl(i,l,r) for(int i=(1);i<(r);i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
const ll INF = (1LL << 31) - 1;
const ll mod = 1e9 + 7;

ll lcm(ll A, ll B) {
	if (A < B)swap(A, B);
	
	ll a = A, b = B;
	

	ll r = a % b;
	while (r != 0) {
		a = b; b = r; r = a % b;
	}
	
	A /= b; B /= b;

	return A * B*b;

}


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


	ll N, M,L=1;
	ll two = 0;
	cin >> N >> M;
	FOR(i, 0, N) {
		ll cur; cin >> cur;

		ll copy = cur;
		ll cnt = 0;
		while (copy % 2 == 0) {
			copy /= 2;
			cnt++;
		}

		if (i == 0) {
			two = cnt;
		}
		else {
			if (two != cnt) {
				cout << 0 << endl;
				return 0;
			}
		}

		L = lcm(L, cur/2);
		if (L > 1e9) {
			cout << 0 << endl;
			return 0;
		}
	}
	//cout << L << endl;
	cout << (M + L) / (2 * L) << endl;



}

Measured memory_bytes: 3644
#include<iostream>
using namespace std;
int main()
{ int n,flag=0;
 cin>>n;
  for(int i=1;i<=9;i++)
  {
    for(int j=1;j<=9;j++)
     if(n==i*j){
     	flag=1; 
		 break; 
	 }
 if(flag==1)break; }
 
 if(flag==1) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
	return 0;
} 

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

type edge struct {
	To int
	ID int
}

var (
	edges  [][]edge
	colors []int
)

func dfs(current, usedColor, from int) {
	color := 1
	for _, e := range edges[current] {
		if e.To == from {
			continue
		}
		if color == usedColor {
			color++
		}
		colors[e.ID] = color
		dfs(e.To, color, current)
		color++
	}
}

func main() {
	N := readInt()

	edges = make([][]edge, N)
	for i := 0; i < N-1; i++ {
		a := readInt() - 1
		b := readInt() - 1
		edges[a] = append(edges[a], edge{To: b, ID: i})
		edges[b] = append(edges[b], edge{To: a, ID: i})
	}

	colors = make([]int, N)
	dfs(0, -1, -1)

	K := -1
	for _, i := range colors {
		if i > K {
			K = i
		}
	}
	fmt.Println(K)

	for i := 0; i < N-1; i++ {
		fmt.Println(colors[i])
	}
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


Measured memory_bytes: 23040
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max(a * b, c * d) << endl;
	return 0;
}


Measured memory_bytes: 256
n=int(input())
w=list(map(int,input().split()))
s=[w[0]]
for i in range(1,n):
    s.append(s[i-1]+w[i])
S=s[n-1]

T=[]
for k in range(n):    
    T.append(abs(S-2*s[k]))

ans=min(T)
print(ans)



Measured memory_bytes: 3060
import Data.List
import Data.Maybe
import Data.Ord
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = readParams >>= mapM_ print . solve . tail

readParams :: IO [Int]
readParams = map b2int . B.words <$> B.getContents
  where b2int = fst . fromJust . B.readInt

solve :: [Int] -> [Int]
solve as = zipWith max ls rs
  where ls = init $ scanl max 0 as
        rs = tail $ scanr max 0 as


Measured memory_bytes: 44156
import java.io.*;
public class Main {
    public static void main(String[] args) throws IOException{
        long X=0;
        int i=0;
        long n = 100;
        double k = 0;
        BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
        X = Long.parseLong(r.readLine());
        do{
            i++;
            k = Math.ceil((double)(n/100));
            n += (long)k;
        }while(n<X);
        System.out.println(i);
    }
}

Measured memory_bytes: 32792
/*input
5
1 1
2 2
3 3
4 4
5 5
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
typedef long long int ll;
#define ld long double
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define sz(_a) (ll)(_a.size())
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
const ll maxn=105;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;

ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}
pii arr[maxn];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;

    REP(i,n){
        cin>>arr[i].f>>arr[i].s;
    }
    ll ans=0;
    for(ll px=-1;px<=1;px+=2){
        for(ll py=-1;py<=1;py+=2){
            vector<pii> prev;
            prev.pb({0,0});
            REP(j,n){
                vector<pii> neww;
                REP(i,sz(prev)){
                    neww.pb(prev[i]);
                    neww.pb({prev[i].f+arr[j].f*px,prev[i].s+arr[j].s*py});
                }
                sort(ALL(neww));
                reverse(ALL(neww));
                prev.clear();
                REP(i,sz(neww)){
                    if(sz(prev)==0 or neww[i].s>(prev.back()).s){
                        prev.pb(neww[i]);
                    }
                }
            }
            REP(i,sz(prev)) ans=max(ans,prev[i].f*prev[i].f+prev[i].s*prev[i].s);
        }
    }
    cout<<fixed<<setprecision(30)<<sqrt(ans);
}

Measured memory_bytes: 12316