akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<cmath>
#include <iomanip>
#define PI 3.14159265359
using namespace std;
int main()
{
	double a, b, x;
	cin >> a >> b >> x;
	double a2 = (x * 2) / b / a;
//	cout << "a2 = " << a2 << endl;
	double amin = min(a2, a);
//	cout << "amin = " << amin << endl;
	double ans = atan(b / amin) * 180.0 / PI;
	if (amin == a2) {
		cout << setprecision(15) << ans << endl;
	}
	else {
		double b2 = 2*((a*a*b)-(x)) / a / a;
		ans = atan(b2 / a) * 180.0 / PI;
		cout << setprecision(15) << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    string S;
    cin >> S;
    ll ans = 0, bcnt = 0;
    rep(i,S.size()){
        if (S[i] == 'B') bcnt++;
        else
            ans += bcnt;
    }

    cout << ans << endl;
}

Measured memory_bytes: 720
#include <iostream>
#include <string>

using namespace std;

int main() {
	string ss = "qwertasdfgzxcvb";

	string s;
	while (cin >> s) {
		if (s == "#") {
			break;
		}
		int aa = -1;
		int cc = 0;
		for (int i = 0; i < s.size(); i++) {
			int bb = 1;
			for (int j = 0; j < ss.size(); j++) {
				if (s[i] == ss[j]) {
					bb = 0;
					break;
				}
			}
			if (i == 0) {
				aa = bb;
			}
			else {
				if (aa != bb) {
					cc++;
					aa = bb;
				}
			}
		}
		cout << cc << endl;
	}

	return 0;
}


Measured memory_bytes: 3148
let arr_of_str s = Array.init (String.length s) (fun i -> s.[i])
let f stk v =
  if v = 'B' then match stk with [] -> [] | (s::stk') -> stk'
  else (v::stk)
let () =
  Scanf.scanf "%s" arr_of_str
  |> Array.fold_left f []
  |> List.fold_left (fun s x -> x :: s) []
  |> List.iter (Printf.printf "%c");
  print_newline ()


Measured memory_bytes: 2432
#include<cstdio>
#include<iostream>
#include<string>
using namespace std;
using ull = unsigned long long;

int main(){
	string S;
	cin >> S;
	ull answer = 0ULL;
	for (unsigned i = 0; i < S.size(); ++i){
		ull ten = 1ULL;
		for (unsigned j = 0; i + j + 2 <= S.size(); ++j){
			answer += (1ULL<<S.size() - 2 - j)*(S[i] - '0')*ten;
			ten *= 10ULL;
		}
		answer += (1ULL<<i)*(S[i] - '0')*ten;
	}
	printf("%llu\n", answer);
	return 0;
}

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;
using P= pair<ll,ll>;

int main() {
    int X;
    cin>>X;
    if(X>=30)
    	cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>

int main(){
  int i, j, pat[10];
  char num[10];
  while(scanf("%s", num) != EOF){
    for(i = 0;i < 10;i++){
      pat[i] = num[i] - '0';
    }

    for(i = 0;i < 9;i++)
      for(j = 0;j < 9 - i;j++)
        pat[j] = (pat[j] + pat[j + 1]) % 10;

    printf("%d\n", pat[0]);
  }
  return 0;
}

Measured memory_bytes: 540
package main

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

func main() {
	n, k := readInt(), readInt()
	ex := make([]float64, n)
	for i := range ex {
		ex[i] = (readFloat64() + 1) / 2
	}

	ans, t := 0.0, 0.0
	for i := range ex {
		t += ex[i]
		if i < k-1 {
			continue
		}
		if i-k >= 0 {
			t -= ex[i-k]
		}
		ans = maxf(ans, t)
	}

	fmt.Println(ans)
}

func maxf(a, b float64) float64 {
	if a > b {
		return a
	}
	return b
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

// -----------------------------------------------------------------

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 3072
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static long cnt=0;
	public static PrintWriter pw = new PrintWriter(System.out);
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
		pw.flush();
		pw.close();
	}

	public static void solution(String[] args) throws Exception{

		int A = nextInt();
		int B = nextInt();
		int H = nextInt();
		int M = nextInt();


		double x=30*(H%12)+0.5*M;
		double y=6*M;

		//内角の角度
		double r = Math.min(1.0*Math.abs(x-y),1.0*Math.abs(360-Math.abs(x-y)));

		double ans = Math.sqrt(A*A+B*B-2*A*B*Math.cos(Math.toRadians(r)));

		System.out.printf("%.12f\n",ans);


	}


	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}

}



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

int main() {
    //
    long long n;
    long long d;
    long long cnt = 0;

    cin >> n >> d;

    for (int i = 0; i < n; i++){
        long double a,b,c;
        cin >> a >> b;
        if (sqrtl(a * a + b * b) <= d) cnt++;
    }

    cout << cnt;
    //
}


Measured memory_bytes: 3756
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner scn = new Scanner(System.in);
        int l = scn.nextInt();
        int r = scn.nextInt();
        int d = scn.nextInt();
        int count = 0;

        for (int i = l; i <= r; i++) {
            if (i % d == 0) {
                count += 1;
            }
        }

        System.out.println(count);


        scn.close();

    }


}


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

int main(){
  int a; cin>>a;
  if(a == 25){
    cout<<"Christmas";
  }else if(a == 24){
    cout<<"Christmas Eve";
  }else if(a == 23){
    cout<<"Christmas Eve Eve";
  }else if(a == 22){
    cout<<"Christmas Eve Eve Eve";
  }
}


Measured memory_bytes: 256
/**********************************************
 * author : deepak nayan
 * file   : e:/Solutions/atcoder/abc162_a.cpp
 * time   : Sat May  2 21:26:18 2020
 * quest  : A - Lucky 7
 *********************************************/
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string n;
  cin >> n;
  cout << ((n[0] =='7' || n[1] == '7' || n[2] == '7') ? "Yes\n" : "No\n");
  return 0;
}


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

int main(){
  int A,B,C,N;
  int ans=0;
  // A*B+C = N
  cin  >> N;
  for (int A = 1; A < N; A++)
  {
    for (int B = 1; B < N; B++)
    {
      if (A*B < N){ans++;}
      else {break;}
    }
    
  }
  cout << ans << endl; 
  
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <stack>
#include <cmath>
#include <map>
#include <cstring>
using namespace std;
#define mod 1000000007
#define PI acos(-1.0)
const long long MAX=200005;
typedef long long ll;
const int INF=0x3f3f3f3f;
//int d[8][2]={-1,0,0,-1,0,1,1,0,1,1,-1,-1,-1,1,1,-1};
int main()
{
    int n,a;
    scanf("%d%d",&n,&a);
    n=n%500;
    if(n>a)
        printf("No\n");
    else printf("Yes\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
#define ff first
#define ss second
#define MP make_pair
#define PB push_back
#define ll long long
#define int long long
#define f(i,x,n) for(int i=x;i<n;i++)
#define ld long double
#define mod 1000000007
int x,y,d;
void gcd(int a,int b){
	if(b==0){
		d=a;
		x=1;
		y=0;
		return ;
	}
	gcd(b,a%b);
	int X,Y;
	X=y;
	Y=x-(a/b)*y;
	x=X;  y=Y;
}
int a,b,c,m; 
int exp(int a,int b){
	m=b+1;
	int res=1;
	while(b!=0){
		if(b&1){
			res*=a;
			res%=m;
		}
		b/=2;
		a*=a; a%=m;
	}
	return res;
}
void prime(){
	int n; cin>>n;
	if(n<2){
		cout<<"composite\n";
		return ;
	}else if(n==2){
		cout<<"prime\n";
		return ;
	}else if(n%2==0){
		cout<<"composite\n";
		return ;
	}else {
		for(int i=3;i*i<=n;i+=2){
			if(n%i==0){
				cout<<"composite\n";
				return ;
			}
		}
		cout<<"prime\n";
	}
}
void toutient(int n) {
    vector<int> phi(n + 1);
    phi[0] = 0;
    phi[1] = 1;
    for (int i = 2; i <= n; i++)
        phi[i] = i - 1;

    for (int i = 2; i <= n; i++)
        for (int j = 2 * i; j <= n; j += i)
              phi[j] -= phi[i];
	cout<<phi[n];
}
int pr[11000];
int dig(int a){
	int s=0;
	while(a!=0){
		s+=(a%10);
		a/=10;
	}
	return s;
}
int ans[11000];
void seive(){
	pr[0]=pr[1]=1;
	for(int i=2;i<11000;++i){
		if(pr[i]==0){
			for(int j=2*i;j<11000;j+=i){
				pr[j]=1;
			}
		}
	}
	for(int i=0;i<11000;++i)
		ans[i]=-1;
	for(int i=0;i<11000;++i){
		if(pr[i]==0){
			ans[i]=1;
			if(i<100){
				ans[i*i]=1;
			}
		}
		else if(ans[i]==-1) ans[i]=LLONG_MAX;
	}
	vector<int> v;
	for(int i=0;i<11000;++i)
	if(ans[i]==1)
	v.push_back(i);
	for(int i=0;i<11000;++i){
		if(ans[i]!=LLONG_MAX){
			for(auto it : v){
				ans[i+it]=min(ans[i+it],ans[i]+1);
			}
		}
	}
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//seive();
	string s; cin>>s;
	if((s[2]==s[3])&&(s[4]==s[5]))
	cout<<"Yes";
	else cout<<"No";
	return 0;
}

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

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


    int N;
    std::string S;
    std::cin >> N >> S;
    std::vector<int> white(N + 1, 0);
    for (int i = 0; i < N; ++i) {
        white[i + 1] = white[i] + ((S[i] == '.')?1:0);
    }
    int min = N;
    for (int i = 0; i <= N; ++i) {
        int change = (i-white[i]) + (white[N] - white[i]);
        min = std::min(min, change);
    }
    std::cout << min << std::endl;
}

Measured memory_bytes: 1428
using System;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var NAB = ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
        var (N, A, B) = (NAB[0], NAB[1], NAB[2]);

        var q = N / (A + B);
        var r = N % (A + B);

        var ans = q * A + Math.Min(A, r);

        WriteLine(ans);
    }
}


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

int N;
int L[2000];

void input() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin >> N;
	for(int i = 0; i < N; ++i) cin >> L[i];
}

void solve() {
	input();
	vector<int> a(N);
	for(int i = 0; i < N; ++i) a[i] = L[i];
	sort(a.begin(), a.end());
	ll ans = 0;
	for(int mid = N - 1; mid >= 0; mid--)
	{
		for(int low = mid - 1; low >= 0; low--)
		{
			auto itr = lower_bound(a.begin(), a.end(), a[mid] + a[low]);
			int ng = distance(itr, a.end());
			ans += (N - 1 - mid) - ng;
		}
	}
	
	cout << ans;
}

int main() {
	solve();		
}


Measured memory_bytes: 256
s = int(input())
S = []
while s > 0:
    S.append(s % 10)
    s //= 10
S.reverse()

N = len(S)
ans = 0
for i in range(N):
    left = i
    right = N - i - 1
    score = 1
    for k in range(0, right + 1):
        if right - k > 0:
            ans += S[i] * score * (1 << left) * (1 << (right - k - 1))
        else:
            ans += S[i] * score * (1 << left)
        score *= 10

print(ans)


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

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

    string answer = "No";
    if (int(s.size()) >= 4)
    {
        if ((s.at(0) == 'Y') & (s.at(1) == 'A') & (s.at(2) == 'K') & (s.at(3) == 'I'))
        {
            answer = "Yes";
        }
    }
    cout << answer << endl;
}

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! {
        n: usize,
        p: [f64; n],
    }

    let mut dp = vec![vec![0.0; n+1]; n+1];
    dp[0][0] = 1.0;

    for i in 0..n {
        for j in 0..i+1 {
            dp[i+1][j+1] = dp[i+1][j+1] + dp[i][j] * p[i];
            dp[i+1][j] = dp[i+1][j] + dp[i][j] * (1.0-p[i]);
        }
    }

    let mut ans = 0.0;
    for i in (n+1)/2..n+1 {
        ans = ans + dp[n][i];
    }
    println!("{}", ans);
}

Measured memory_bytes: 90492
import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    

def main():
    N, K = MI()
    L = [LI() for i in range(K)]
    D = [0] * N
    D[0] = 1
    D[1] = -1
    num = 0
    mod = 998244353
    for index in range(N):
        num += D[index] % mod
        for l, r in L:
            if index + r + 1 <= N-1:
                D[index+l] += num
                D[index+r+1] -= num
            elif index+l <= N-1:
                D[index+l] += num
                
    print(num % mod)
    
if __name__ == "__main__":
    main()

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

int main() {
  int A, B, H, M;
  cin >> A >> B >> H >> M;
  
  double x1, y1, x2, y2;
  
  x1 = A * cos(2*M_PI*(H*60+M)/720);
  y1 = A * sin(2*M_PI*(H*60+M)/720);
  x2 = B * cos(2*M_PI*M/60);
  y2 = B * sin(2*M_PI*M/60);
  
  double length = sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
  cout << fixed << setprecision(20);
  cout << length;
}


Measured memory_bytes: 4072
#include <iostream>
#include <vector>

int main() {
    using namespace std;
    int N;
    cin >> N;
    vector<int> candies[2];
    for (int i = 0; i < 2; i++) {
        candies[i].resize(N);
    }
    for (int i = 0; i < 2; i++){
        for (int j = 0; j < N; j++){
             cin >> candies[i][j] ;
        }
    }
    int maxscore = 0;
    for (int right = 0; right < N; right++){
         int score = 0;
        for (int rep = 0; rep <= right; rep++){
            
            score += candies[0][rep];
        }
        score += candies[1][right];
        
        for (int rep = right + 1; rep < N; rep++){
            score += candies[1][rep];
            
        }
        
        if (score > maxscore){
            maxscore = score;
        }

    }
    cout << maxscore;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
class Simple {
    int A, B, C, D, E, F;
    void Solve() {
        //input
        A = io.Int;
        B = io.Int;
        C = io.Int;
        D = io.Int;
        E = io.Int;
        F = io.Int;
        //cal
        var kosa = 0D;
        var water = 0;
        var sugar = 0;
        for (int i = 0; i <= 31; ++i) {
            for (int j = 0; j <= 31; ++j) {
                for (int k = 0; k <= 101; ++k) {
                    for (int l = 0; l <= 101; ++l) {
                        var x = 100 * A * i + 100 * B * j;
                        var y = C * k + D * l;
                        if (x + y <= F && y <= E * A * i + E * B * j)
                            if ((100 * y) != 0 && kosa < (100.0 * y) / (y + x)) {
                                kosa = (100.0 * y) / (y + x);
                                sugar = y;
                                water = x + y;
                            }
                    }
                }
            }
        }
        //ret
        Console.WriteLine((water==0?100*A:water) + " " + sugar);

    }
    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) { new Simple().Stream(); }
    void Stream() {
        Solve();
        io.writeFlush();
    }
}
class SimpleIO {
    string[] nextBuffer;
    int BufferCnt;
    char[] cs = new char[] { ' ' };
    StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
    public SimpleIO() {
        nextBuffer = new string[0];
        BufferCnt = 0;
        Console.SetOut(sw);
    }
    public string Next() {
        if (BufferCnt < nextBuffer.Length)
            return nextBuffer[BufferCnt++];

        string st = Console.ReadLine();
        while (st == "")
            st = Console.ReadLine();
        nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        BufferCnt = 0;
        return nextBuffer[BufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void writeFlush() { Console.Out.Flush(); }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPP(i, n) for(int i = 1; i <= n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const ll MOD = 1000000007;

int main() {
    double w,h,x,y; cin >> w >> h >> x >> y;
    double ans = w*h/2;
    cout << setprecision(9) << ans << " " << (w/2==x && h/2==y) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> v(M, vector<int>(2));
  vector<int> ans(N + 1, 0);
  for (int i = 0; i < M; i++) {
    cin >> v.at(i).at(0) >> v.at(i).at(1);
    ans[v.at(i).at(0)]++;
    ans[v.at(i).at(1)]++;
  }
  for (int i = 1; i <= N; i++) {
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
#define pb push_back
#define mod 1000000007
#pragma GCC optimize ("-O3")
#define mod2 998244353
#define MAXN 1000000000
#define v32 vector<int>
#define v64 vector<lli>
#define v1024 vector <vector <int>>
#define v4096 vector <vector <lli>>
#define vt vector
#define f(x, y, z) for (lli x = y; x < z; x++)
#define fd(x, y, z) for (lli x = y; x > z; x--)
#define lb lower_bound
#define ld long double
#define m64 map<lli,lli>
#define m32 map<int,int>
#define m64it map<lli,lli>::iterator
#define m32it map<int,int>::iterator
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ist insert
#define endl "\n"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define p_q priority_queue 
#define min_p_q priority_queue <int,vt <int>,greater <int>>
using namespace std;
using namespace __gnu_pbds; 

template <typename T> 
void DEBUG_ARR(vt<T> a,char c)
{
	f(i,0,a.size())cout<<a[i]<<c;
	cout<<"\n";
}

//USE AT YOUR OWN RISK
lli tmod(lli x,lli m=mod){return (x%m+m)%m;}

//make sure x is below mod
lli power(lli x, lli y,lli m=mod) 
{
    lli res = 1;  
   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x)%m; 
        y = y>>1; 
        x = (x*x)%m;  
    }
    if(res<0)
       res+=m; 
    return res; 
}
//rank is equal to number of vertices in a connected component
class UnionFind 
{
  public: v32 p, rank;
  // remember: vi is vector<int>
  UnionFind(int N) { rank.assign(N, 1);
  p.assign(N, 0); for (int i = 0; i < N; i++) p[i] = i; }
  int findSet(int i) { return (p[i] == i) ? i : (p[i] = findSet(p[i])); }
  bool isSameSet(int i, int j) { return findSet(i) == findSet(j); }
  void unionSet(int i, int j) 
  {
  if (!isSameSet(i, j)) {
  // if from different set
  int x = findSet(i), y = findSet(j);
  if (rank[x] > rank[y]) p[y] = x,rank[x]+=rank[y];
  // rank keeps the tree short
  else 
     {
     p[x] = y;
     rank[y]+=rank[x]; 
     }
  
  } 
 
  }   
};
// lli fact[2000009];
// lli ncr(lli n,lli r){
//     lli ans=fact[n];
//     if(r>n)return 0;
//     ans=(ans*power(fact[n-r],mod-2))%mod;
//     ans=(ans*power(fact[r],mod-2))%mod;
//     return ans;
// }
// int mat[][]
v1024 v;
int main() 
{ 
    // fact[0]=1;
    // f(i,1,2000001)fact[i]=(i*fact[i-1])%mod;
    fastio;
    int t;
    // cin>>t;
    t=1;
    int temp=t;
	while(t--){
        // cout<<"Case #"<<temp-t<<": ";
        lli n,k;cin>>n>>k;
        n=n%k;
        cout<<min(n,k-n);
    }   
    return 0; 	
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
int main() 
{
    int a,b;
    cin>>a>>b;
    if(a>0)cout<<"Positive";
    else if(a==0||a<0&&b>0)cout<<"Zero";
    else if((abs(b)-abs(a))%2!=0)cout<<"Positive";
    else cout<<"Negative";
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>


using namespace std;
typedef long long int ll;


int main() {
    int N;
    cin >> N;
    vector<int> a(N);

    for (size_t i = 0; i < N; i++)
    {
        cin >> a[i];   
    }

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

    cout << a[N-1] - a[0] << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
int grid[1005][1005];
int dp[1005][1005];

int solve(int r,int c)
{

    
        for(int i=1;i<=r;i++)
            { 
                if(grid[1][i])
                dp[1][i]=1;
                
                else 
                break;
            }
            
        for(int i=1;i<=r;i++)
            { 
                if(grid[i][1])
                dp[i][1]=1;
                
                else 
                break;
            }

    
    dp[1][1]=1;
    for(int i=2;i<=r;i++)
    {
        for(int j=2;j<=c;j++)
        {
            if(!grid[i][j])
              continue;
            else
            {
                dp[i][j]= (dp[i-1][j])%mod + (dp[i][j-1])%mod;
            }

        }
    }
    
   
    
  return (dp[r][c])%mod;
}

int main(){
ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
    int r,c;
    cin>>r>>c;
    memset(dp,0,sizeof dp);
     
    for(int i=1;i<=r;i++)
    {
        for(int j=1;j<=c;j++)
        {  char c;
            cin>>c;
            if(c=='#')
                grid[i][j]=0;
                
            else 
            grid[i][j]=1;

        }
    }

    cout<<solve(r,c)<<"\n";
return 0;
}


Measured memory_bytes: 8192
#C
N=int(input())
A=[int(x) for x in input().split()]

P=[0 for i in range(N+1)]
P[N]=[A[N],A[N]]
for i in range(N-1,-1,-1):
    MIN,MAX=P[i+1]
    mi=int(A[i]+(MIN+MIN%2)/2)
    ma=A[i]+MAX
    P[i]=[mi,ma]
    
    
if P[0][0]==1:
    Q=[0 for i in range(N+1)]
    Q[0]=1
    cnt=1
    for i in range(N):
        Q[i+1]=min((Q[i]-A[i])*2,P[i+1][1])
        cnt+=Q[i+1]
    print(cnt)
else:
    print("-1")

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

int main() {
  int n;
  int time = 0;
  cin >> n;
  int t[n];
  int i;
  for (i = 0; i < n; i++) {
    cin >> t[i];
    time += t[i];
  }
  int m;
  cin >> m;
  int p[m], x[m];
  for (i = 0; i < m; i++) {
    cin >> p[i] >> x[i];
  }
  for (i = 0; i < m; i++) {
    cout << time - (t[p[i] - 1] -x[i]) << endl;
  }

  return 0;
}


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

int main()
{
string n ;
cin >> n ;
ll k=0;
for (ll i = n.size()-1; i >= 0; i--)
{
  if(n[i]-'0'+k>=6){ans+=10-(n[i]-'0'+k);k=1;}
  if(n[i]-'0'+k<=4){ans+=(n[i]-'0')+k;k=0;}
  if(n[i]-'0'+k==5){
    if(i!=0&&n[i-1]-'0'>=5){ans+=5;k=1;}
    else {ans+=5;k=0;}
  }
}

cout << ans+k << endl;
return 0;
}

Measured memory_bytes: 1412
#include <algorithm>
#include <iostream>
#include <limits>
#include <numeric>
#include <queue>
#include <vector>

#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
bool compare_by_b(pair<int, long long> a, pair<int, long long> b) {
    if(a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}
int H, W;
int MAX = 26000;
int dp[80][80][26000];

int main() {
    cin >> H >> W;
    vector<vector<int>> A(H, vector<int>(W));
    vector<vector<int>> B(H, vector<int>(W));
    rep(i, 0, H) {
        rep(j, 0, W) { cin >> A[i][j]; }
    }
    rep(i, 0, H) {
        rep(j, 0, W) { cin >> B[i][j]; }
    }
    rep(a, 0, 80) {
        rep(b, 0, 80) {
            rep(c, 0, MAX) { dp[a][b][c] = 0; }
        }
    }
    int zero = 13000;

    dp[0][0][zero + (A[0][0] - B[0][0])] = 1;
    rep(a, 0, H) {
        rep(b, 0, W) {
            int sa = A[a][b] - B[a][b];
            int sa2 = B[a][b] - A[a][b];
            if(a == 0) {
                if(b == 0) {
                    dp[0][0][zero + sa] = 1;
                    dp[0][0][zero + sa2] = 1;
                } else {
                    rep(i, 0, MAX) {
                        if(dp[a][b - 1][i] == 1) {
                            dp[a][b][i + sa] = 1;
                            dp[a][b][i + sa2] = 1;
                        }
                    }
                }
            } else {
                if(b == 0) {
                    rep(i, 0, MAX) {
                        if(dp[a - 1][b][i] == 1) {
                            dp[a][b][i + sa] = 1;
                            dp[a][b][i + sa2] = 1;
                        }
                    }
                } else {
                    rep(i, 0, MAX) {
                        if(dp[a][b - 1][i] == 1) {
                            dp[a][b][i + sa] = 1;
                            dp[a][b][i + sa2] = 1;
                        }
                    }
                    rep(i, 0, MAX) {
                        if(dp[a - 1][b][i] == 1) {
                            dp[a][b][i + sa] = 1;
                            dp[a][b][i + sa2] = 1;
                        }
                    }
                }
            }
        }
    }
    int min = MAX + 1;
    rep(i, 0, MAX) {
        if(dp[H - 1][W - 1][i] == 1) {
            int t = abs(zero - i);
            if(t < min) {
                min = t;
            }
        }
    }
    cout << min << endl;
}

Measured memory_bytes: 650240
import sys

inpt = sys.stdin.readline
N = int(inpt())
vals = [int(d) for d in inpt().split()]

min_val = float('inf')
for i_sl in range(1, N):
  diff = abs(sum(vals[:i_sl]) - sum(vals[i_sl:]))
  if min_val>diff:
    min_val = diff
  else:
    break
print(min_val)

Measured memory_bytes: 3060
def subset_sum(s, a):
	dict = {}
	return subset_rec(0, s, a, dict)
	
def subset_rec(i, s, a, dict):
	key = str(i) + '-' + str(s)
	if key in dict:
		ret = dict[key]
	elif s == 0:
		ret = True
	elif i >= len(a):
		ret =  False
	else:
		ret = subset_rec(i+1, s-a[i], a, dict) or subset_rec(i+1, s, a, dict)
	dict[key] = ret
	return ret

n = int(input())
a = list(map(int, input().split()))
p = int(input())
q = list(map(int, input().split()))
for i in range(p):
	if subset_sum(q[i], a):
		print('yes')
	else:
		print('no')



Measured memory_bytes: 6412
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void dp(int i, vector<vector<pair<ll,ll>>> &edge, vector<ll> &vertex, queue<int> &tmp,ll n){
    for(pair<ll,ll> p:edge.at(i)){
        if(vertex.at(p.first)==-1){
            vertex.at(p.first)=(vertex.at(i)+p.second)%2;
            tmp.push(p.first);
        }
    }
}

int main(){
    ll n;
    cin>>n;
    vector<vector<pair<ll,ll>>> edge(n+1);
    vector<ll> vertex(n+1,-1);
    rep(i,n-1){
        ll u,v,w;
        cin>>u>>v>>w;
        edge.at(u).push_back({v,w%2});
        edge.at(v).push_back({u,w%2});
    }
    vertex.at(1)=0;
    queue<int> tmp;
    tmp.push(1);
    while(!tmp.empty()){
        int a=tmp.front();
        tmp.pop();
        dp(a,edge,vertex,tmp,n);
    }
    rep(i,n){
        cout<<vertex.at(i+1)<<endl;
    }
}

Measured memory_bytes: 8704
#include <stdio.h>
int main () {

  int n,k,r,s,p;
  scanf("%d %d %d %d %d", &n, &k, &r, &s, &p);

  char t[n+1];

  for(int i=0; i<n; i++)
    scanf(" %c", &t[i]);

  int pontos=0;
  for(int i=0; i<k; i++){
    if(t[i]=='r')
      pontos+=p;

    if(t[i]=='p')
      pontos+=s;

    if(t[i]=='s')
      pontos+=r;
  }

  for(int i= k; i <= n-1; i++)
  {
    if(t[i] != t[i-k])
    {
      if(t[i]== 'r')
        pontos+=p;

      if(t[i]== 's')
        pontos+=r;

      if(t[i]== 'p')
        pontos+=s;
     }
     else
        t[i]='e';
  }
  printf("%d\n",pontos);

  return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	const maxWord = (1 << 30)
	buf := []byte{}
	sc.Buffer(buf, maxWord)
	sc.Split(bufio.ScanWords)
}

func input() string {
	sc.Scan()
	return sc.Text()
}

func solve(h, w int, a []string) string {
	point := 0
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			if a[i][j] == '#' {
				if j < point {
					return "Impossible"
				}
				point = j
			}
		}
	}
	return "Possible"
}

func main() {
	h, _ := strconv.Atoi(input())
	w, _ := strconv.Atoi(input())
	a := make([]string, h)
	for i := 0; i < h; i++ {
		a[i] = input()
	}

	fmt.Println(solve(h, w, a))
}


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

#define FOR0(i,n) for (int i = 0; i < n; i++)
#define FOR(i,j, n) for (int i = j; i < n; i++)
// bool isEven(ll n) {return (n%2!=0)?false:true;};
#define INF 1000000000 // 1 billion, safer than 2B for Floyd Warshall’s

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
// #define int ll

using namespace std;

//atcoder

int main()
{
	char c;
	cin>>c;
	cout<<(char)(c+1)<<endl;
}

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

int main()
{
    int n;cin>>n;
    vector<int> a(n-1);
    vector<int> b(n-1);
    int i;
    for(i=0;i<n-1;i++)cin>>a.at(i)>>b.at(i);
    vector<int> count(n+1,0);
    vector<vector<int>> linked(n+1,vector<int>(0)); 
    for(i=0;i<n-1;i++)
    {
        count.at(a.at(i))++;
        count.at(b.at(i))++;
        linked.at(a.at(i)).emplace_back(i);
        linked.at(b.at(i)).emplace_back(i);        
    }
    int maxv=-1;
    int maxind=0;
    for(i=1;i<=n;i++)
    {
        if(count.at(i)>maxv)
        {
            maxv=count.at(i);
            maxind=i;
        }
    }
    cout<<maxv<<endl;
    vector<int> ans(n-1,0);
    queue<int> q;
    queue<int> q2;
    vector<bool> vis(n+1,false);
    vector<int> num(n+1,-1);
    q.push(maxind);
    while(!q.empty())
    {
      int now=q.front();
      vis.at(now)=true;
      int count=0;
      for(i=0;i<linked.at(now).size();i++)
      {
        int ind=linked.at(now).at(i);
        int togo=(a.at(ind)!=now)?a.at(ind):b.at(ind);
        if(!vis.at(togo))
        {
          q2.push(togo);
          num.at(togo)=(num.at(now)+1+count)%maxv;
          count++;
          ans.at(ind)=num.at(togo);
        }
      }
      while(!q2.empty())
      {
        q.push(q2.front());
        q2.pop();
      }
      q.pop();
    }
    for(i=0;i<n-1;i++)
    {
      cout<<ans.at(i)+1<<endl;
    }
}


Measured memory_bytes: 8064
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// std::ios::sync_with_stdio(false);

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int maxv = 310;
int N,G[maxv][maxv],G_[maxv][maxv];

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    while (cin >> N) {
        FOR(i,0,N) FOR(j,0,N) {
            cin >> G[i][j]; G_[i][j] = G[i][j];
        }
        FOR(k,0,N) FOR(i,0,N) FOR(j,0,N)
            G[i][j] = min(G[i][j], G[i][k]+G[k][j]);
        bool good = true;
        FOR(i,0,N) FOR(j,0,N)
            good &= G[i][j] == G_[i][j];
        if (good) {
            LL ans = 0;
            FOR(i,0,N) FOR(j,i+1,N)
                ans += G[i][j];
            FOR(i,0,N) FOR(j,i+1,N) {
                FOR(k,0,N) if (k != i && k != j) {
                    if (G[i][k]+G[k][j] == G[i][j]) {
                        ans -= G[i][j];
                        break;
                    }
                }
            }
            cout << ans << endl;
        }
        else
            cout << -1 << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
///
// File:  0002.cpp
// Author: ymiyamoto
//
// Created on Sat Nov  4 15:39:12 2017
//

#include <cstdint>
#include <iostream>

using namespace std;

int32_t main()
{
  while (true) {
    uint32_t a, b;
    cin >> a >> b;
    if (cin.eof()) break;
    cout << to_string(a + b).size() << endl;
  }

  return 0;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int n; cin>>n;
	map<string, int64_t> mp;
	rep(i,n){
		string s; cin>>s;
		sort(all(s));
		mp[s]++;
	}
	int64_t ans=0;
	for(auto i:mp){
		int64_t ii=i.second;
		ans+=ii*(ii-1)/2;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 11136
import itertools
import numpy as np

_,*_t=[list(map(int,i.split())) for i in open(0)]
n=_[0]
m=_[1]
x=_[2]
table=np.array(_t)
patterns=list(itertools.product([False,True], repeat=n))
value=9000000


def boolAchieve(nums):
  for i in range(1,m+1):
    if nums[i]<x:
      return False
  return True


tmp=np.sum(table,axis=0)
if not boolAchieve(tmp):
  print(-1)
  exit()


for i in range(1,2 ** n):
  selects=patterns[i]
  picks=np.sum(table[selects,:],axis=0)
  if not boolAchieve(picks):
    continue
  value=min(value,picks[0])

  
print(value)

Measured memory_bytes: 27672
n, w = map(int, input().split())
wv = [tuple(map(int, input().split())) for _ in range(n)]
 
dp = [0] * (w+1)
for wi, vi in wv:
    for sum_w in reversed(range(wi, w+1)):
        dp[sum_w] = max(dp[sum_w], dp[sum_w - wi] + vi)
print(dp[w])


Measured memory_bytes: 41708
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        int[][] a = new int[H+2][W+2];
        int[][] b = new int[H+2][W+2];
        boolean[][][] dp = new boolean[H+1][W+1][((H+W)*80)+1];
        for(int i = 0; i<H+2; i++) {
            for(int j = 0; j<W+2; j++) {
                if(i==0||j==0||i==H+1||j==W+1) {
                    a[i][j] = -1;
                    continue;
                }
                a[i][j] = sc.nextInt();
            }
        }
        for(int i = 0; i<H+2; i++) {
            for(int j = 0; j<W+2; j++) {
                if(i==0||j==0||i==H+1||j==W+1) {
                    b[i][j] = -1;
                    continue;
                }
                b[i][j] = sc.nextInt();
            }
        }
        for(int i = 1; i<H+1; i++) {
            for(int j = 1; j<W+1; j++) {
                if(i==1 && j ==1) {
                    int ini = Math.abs(a[i][j] - b[i][j]);
                    dp[i][j][ini] = true;
                }
                for(int k = 0; k<((H+W)*80); k++) {
                    if(i==1 && j ==1) {
                        continue;
                    }
                    if(dp[i][j-1][k] == true) {
                        int plus = k + Math.abs(a[i][j] - b[i][j]);
                        int minus = Math.abs(k - Math.abs(a[i][j] - b[i][j]));
                        dp[i][j][plus] = true;
                        dp[i][j][minus] = true;
                    }
                    if(dp[i-1][j][k] == true) {
                        int plus = k + Math.abs(a[i][j] - b[i][j]);
                        int minus = Math.abs(k - Math.abs(a[i][j] - b[i][j]));
                        dp[i][j][plus] = true;
                        dp[i][j][minus] = true;
                    }
                }
            }
        }
        for(int k = 0; k<((H+W)*80); k++) {
            if(dp[H][W][k]) {
                System.out.println(k);
                break;
            }
        }
    }
}

Measured memory_bytes: 157964
n = int(input())
import copy
ans = [[0]]
for i in range(n-1):
    x = len(ans)
    for j in range(x):
        mx = max(ans[j])
        for k in range(mx+2):
            tmp = ans[j].copy()
            tmp.append(k)
            ans.append(tmp)
    ans = [s for s in ans if len(s)==i+2]
for s in ans:
    tmp = ""
    for i in s:
        tmp += chr(ord("a")+ i)
    print(tmp)

Measured memory_bytes: 33708
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
using namespace std;
int main() {
    int a,b;
  cin>>a>>b;
    cout<<(a-1)*(b-1)<<endl;
}   




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  loop(i,0,n)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << endl

using namespace std;


int main(){
  ios_base::sync_with_stdio(false); cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> hate(k);
  rep(i,k) cin >> hate[i];
  
  int f = false;
  for(int i=n;;i++){
    f = true;
    for(int j=0;j<k;j++){
      if(to_string(i).find(to_string(hate[j])) != -1){
        f = false; 
        break;
      }
    }
    if(f == true){
      cout << i << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <iostream>
#include <string>

#include <algorithm>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define PB push_back
#define MP make_pair

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

#define ALL(v) (v).begin(),(v).end()

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

typedef pair<int, int> PII;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VPII;

const int MOD = 1000000007;
const int INF = 1e9;

const double EPS = 1e-9;
const double PI = acos(-1.0);

LL gcd(LL a, LL b) { return b ? gcd(b, a % b) : a; }
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }

LL A, B;

int main() {
    cin >> A >> B;
    LL C = gcd(A, B);
    LL ans = 1;
    for (LL i = 2; i <= sqrtl(C); i++) {
        if (C % i) {
            continue;
        }
        while (C % i == 0) {
            C /= i;
        }
        ans++;
    }
    if (C > 1) {
        ans++;
    }
    cout << ans << endl;
    return 0;
}


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

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

    bool z;
    z = true;
    int count = 0;
    int y;
    y = s.size()/2;

    for (int i=0; i<y; i++){
        if (s.at(i) != s.at(s.size()-i-1)) z = false;
        count++;
    }

     for (int i=0; i<(y/2); i++){
        if (s.at(i) != s.at(y-i-1)) z = false;
    }

    if (z) cout  << "Yes" << endl;
    else cout  << "No" << endl;

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int N;
	int count = 0;
	string S;
	cin >> N >> S;
	if (N % 2 == 0) {
		for (int i = 0; i < S.size() / 2; i++) {
			if (S[i] != S[i + (S.size() / 2)]) {
				cout << "No" << endl;
				count++;
				break;
			}
		}
		if (count == 0) cout << "Yes" << endl;
	}
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
a, b, c = map(int, input().split())
k = int(input())

while k > 0:
  if (b <= a):
    b = b * 2
    k -= 1
  else:
    if (c <= b):
      c = c * 2
      k -= 1
    else:
      print('Yes')
      exit()
if (b > a and c > b):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9188
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}

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


	int M = 0;
	while ((ct = getcha()) >= '0') M = M * 10 + ct - '0';
	ll nagasa = 0;
	ll ketawa = 0;
	rep(i, M) {
		if (ci - cn + 20 > cm) {
			int d = getcha() - '0';
			getcha();
			ll A = 0;
			while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
			ketawa += d * A;
			nagasa += A;
		}
		else {
			int d = *ci++ - '0';
			ci++;
			ll A = 0;
			while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
			ketawa += d * A;
			nagasa += A;
		}
	}

	ll kotae = nagasa - 1;
	kotae += (ketawa - 1) / 9;

	printf("%lld", kotae);


	Would you please return 0;
}

Measured memory_bytes: 256