akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <ll,int> ii;
typedef pair <ii,int> iii;

const int mod = 1e9 + 7;
const int N = 100005;

int v[N];

void solve(){
	int n,m;
	cin >> n >> m;
	int total = 0, ans = 0;
	for(int i = 0; i < n; i++){
		cin >> v[i];
		total += v[i];
	}
	double x = (double)total/(4.0*(double)m);
	for(int i = 0; i < n; i++)
		ans += (double)v[i]>=x;
	cout << (ans >= m ? "Yes":"No") << "\n";
}

int main(){
	fastio;
	int t = 1;
	//cin >> t;
	while(t--)
		solve();
	return 0;
}


Measured memory_bytes: 3668
n = int(input())
A = list(map(int, input().split()))

def gcd(x, y):
    while x != 0 and y != 0:
        x, y = max(x, y), min(x, y)
        x = x % y
    return max(x, y)

GCD = [[0] * n for i in range(2)]

GCD[0][0] = float("inf")
GCD[1][-1] = float("inf")
GCD[0][1] = A[0]
GCD[1][-2] = A[-1]

for i in range(2, n):
    GCD[0][i] = gcd(GCD[0][i-1], A[i-1])
    #print(GCD[0][i-1], A[i-1])
    GCD[1][-i-1] = gcd(GCD[1][-i], A[-i])

#print(GCD)

ans = 1
for i in range(1, n-1):
    ans = max(ans, gcd(GCD[0][i], GCD[1][i]))

print(max(ans, GCD[0][-1], GCD[1][0]))

Measured memory_bytes: 70252
a, b, c, d = map(int, input().split())
flg1 = False
flg2 = False
while True:
    c -= b
    a -= d
    if c <= 0:
        flg1 = True
    if a <= 0:
        flg2 = True

    if flg1:
        print("Yes")
        exit()
    if flg2:
        print("No")
        exit()


Measured memory_bytes: 9120
N,K=map(int,input().split())
P=list(map(int,input().split()))
S=0
sumlist=[0 for i in range(N+K-1)]
sumlist[0]=sum(P[:K])
for i in range(1,N-K+1):
  sumlist[i]=sumlist[i-1]+P[K+i-1]-P[i-1]
S=max(sumlist)
ans=(K+S)/2
print(ans)

Measured memory_bytes: 24804
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0; i<(n); i++)
#define PI 3.14159265359
int main() {
    /*変数定義，入力*/
    ll N;
    cin >> N;
    
    //ll A, B;cin >> A >> B;
    //vector<ll> a(N);  rep(i, N) cin >> a[i];
    
    /*演算*/
    double d;
    d = 2 * PI * N;
    /*出力*/
    cout << d << endl;

    /*終了*/
    return 0;
}

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

int comp(const void* a, const void* b){
  return *(int *)a - *(int *)b;
}

int main(){
  int temp, min, i, n, k, h[100000];
  scanf("%d%d", &n, &k);
  for(i = 0; i < n; i++) scanf("%d", &h[i]);
  qsort(h, n, sizeof(int), comp);
  min = h[k - 1] - h[0];
  for(i = 1; i < n - k + 1; i++){
    temp = h[i + k - 1] - h[i];
    if(min > temp) min = temp;
  }
  printf("%d", min);
}

Measured memory_bytes: 892
#include<string>
#include<iostream>
#include<cstdio>
#define mod 1000000007
using namespace std;
int main() {
	int n,ans=0;
	scanf("%d", &n);
	for (int i = 1; i <= n; i+=2) {
		int cnt = 0;
		for (int j = n; j >= 1; j--) {
			if (!(i%j))cnt++;
		}
		if (cnt == 8) ans++;
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.Stack;

public class Main{
	public static class FastReader {
		BufferedReader br;
		StringTokenizer root;
		
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (root == null || !root.hasMoreTokens()) {
				try {
					root = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return root.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	static int mod = (int) (1e9+7);
	static long cf = 998244353;
    static final int MAX = (int) 1e6;
    public static List<Pair>[] edges;
    public static int[][] parent;
    public static int col = 20;
    public static long[] Bit;
    public static long[] fac,inv;
    public  static int[] prime; 
    public static long[] dp;
	public static FastReader sc = new FastReader();
	public static void main(String[] args) {
	//	Scanner sc = new Scanner(System.in);
 
		int n = sc.nextInt(),m=sc.nextInt();
		int l =1,r=n;
		for(int i=0;i<m;++i) {
			l = Math.max(l, sc.nextInt());
			r = Math.min(r, sc.nextInt());
		}
	 out.print(Math.max(0, r-l+1));
		 
		out.close();
	}

	
	static class Pair{
		int x;
		int y;
		Pair(int x,int y){
			this.x = x;
			this.y = y;
		}
	}
	
}

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

L=[]
for i in range(1,10**5):
    if (i*(i+1)//2)>10**5:
        break
    else:
        L.append(i*(i+1)//2)
#print(i)
if N not in L:
    print("No")
    exit()
print("Yes")
for i in range(448):
    if N==i*(i+1)//2:
        print(i+1)
        break
L=[i+1 for i in range(i)]
ans=str(i)
for j in L:
    ans+=" "+str(j)
print(ans)
A=[[a+1]for a in range(i)]
#print(A)
cnt=i+1
for a in range(1,i+1):
    for b in range(i):
        if cnt>(((i)*(i+1))//2):
            break
        A[b%(i)].append(cnt)
        A[(b+a)%(i)].append(cnt)
        cnt+=1
#print(A)
for a in range(i):
    ANS=str(i)
    for j in A[a]:
        ANS+=" "+str(j)
    print(ANS)

Measured memory_bytes: 48220
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;

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

long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}

int K;
int X;

int main(){
    cin >> K >> X;
    if(K*500>=X)puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void) {
	char s[4];
	
	scanf("%s", s);

	if (s[0] == 'S' && s[1] == 'A')
		printf("1");
	if (s[0] == 'F')
		printf("2");
	if (s[0] == 'T' && s[1] == 'H')
		printf("3");
	if (s[0] == 'W')
		printf("4");
	if (s[0] == 'T' && s[1] == 'U')
		printf("5");
	if (s[0] == 'M')
		printf("6");
	if (s[0] == 'S' && s[1] == 'U')
		printf("7");

	return 0;
}

Measured memory_bytes: 128
import java.util.*

fun main(arg: Array<String>) {
    val k = readLine()!!.toInt()
    val edge = LinkedList(listOf(1 to 1))
    val score = IntArray(k) { -1 }
    while (edge.isNotEmpty()) {
        val (f, s) = edge.poll()
        score[s] = f
        if (s == 0) break
        val next1 = (s * 10) % k
        val next2 = (s + 1) % k
        if (score[next1] < 0) edge.push(Pair(f, next1))
        if (score[next2] < 0) edge.add(Pair(f + 1, next2))
    }
    println(score[0])
}


Measured memory_bytes: 46848
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repm(i,m,n) for (int i = m; i < (n); i++)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vs= vector<string>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using psi = pair<string, int>;

int main() {
  int N;
  cin >> N;
  
  vector<tuple<string,int,int>> p(N);
  rep(i,N) {
    string S;
    int P;
    cin >> S >> P;
    p.at(i) = make_tuple(S,-P,i);
  }
  
  sort(p.begin(), p.end());
  
  rep(i,N) {
    int id;
    tie(ignore, ignore, id) = p.at(i);
    cout << id+1 << endl;
  }
}

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

const int N=2e5+20;

int n,x,f[N];

int main()
{
	scanf("%d",&n);
	for(int i=0;i<n-1;i++) scanf("%d",&x),f[x]++;
	for(int i=1;i<=n;i++) printf("%d\n",f[i]);
}

Measured memory_bytes: 4568
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int main()
{
    int n;
    cin>>n;
    LL res=0;
    for(LL i=1;i<=n;i++)
    {
        res+=(i+n/i*i)*(n/i)/2;
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 3592
#include <stdio.h>

int main(){
  int N,W[200],M=1000000;
  scanf("%d",&N);
  W[0]=0;
  for(int i=1;i<=N;i++){
    scanf("%d",W+i);
    W[i]+=W[i-1]; 
  }
  int S;
  for(int i=1;i<N;i++){
    S=W[N]-2*W[i];
    if(S<0) S=-S;
    if(S<M) M=S;
  }
  printf("%d\n",M);
  return 0;
}

Measured memory_bytes: 1736
import re
a = str(input())

m1 = re.match(r"^hi$", a)
m2 = re.match(r"^hihi$", a)
m3 = re.match(r"^hihihi$", a)
m4 = re.match(r"^hihihihi$", a)
m5 = re.match(r"^hihihihihi$", a)

if m1 or m2 or m3 or m4 or m5:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3188
#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<int,int>;

int main() {
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (to_string(i).size()%2 == 1) ++ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3716
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), cout, ", ") << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, ostream &os = cout, string sep = " ")
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), os, ", ") << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    IN(ll, M);
    AIN(string, A, N);
    AIN(string, B, M);
    bool yes = false;
    REP(i, N - M + 1)
    {
        REP(j, N  - M + 1)
        {
            bool ok = true;
            REP(u, M)
            {
                REP(v, M)
                {
                    ok &= A[i + u][j + v] == B[u][v];
                }
            }
            yes |= ok;
        }
    }
    YES(yes);
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int H, N;
  cin >> H >> N;
  int A[N], B[N], cost[N];
  for (int i = 0; i < N; i++){
    cin >> A[i] >> B[i];
  }

  long long dp[N+1][H+1];
  for (int i = 0; i <= N; i++){
    for (int j = 0; j <= H; j++){
      dp[i][j] = 1000000000000000000;
    }
  }

  dp[0][0] = 0;

  for (int i = 0; i < N; i++){
    for (int j = 0; j <= H; j++){
      if(dp[i+1][j] > dp[i][j]){
        dp[i+1][j] = dp[i][j];
      }
      if(dp[i+1][min(j+A[i], H)] > dp[i+1][j] + B[i]){
        dp[i+1][min(j+A[i], H)] = dp[i+1][j] + B[i];
      }
    }
  }
  
  printf("%lld\n", dp[N][H]);
  
}


Measured memory_bytes: 81892
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

const int INF = 10000000;
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};
using namespace std;
typedef long long  ll;

int P, Q, A, N, ans;

/** Problem1131 : Unit Fraction Partition **/
void dfs(int p, int q, int n, int old)
{
	if (P*q == p*Q) {
		ans++;
		return;
	} else if (P*q < p*Q)
			return ;

	if (n==N) return;
	for (int i=old; i*q<=A; i++) {
		dfs(p*i+q, i*q, n+1, i);
	}
}

int main()
{
	while (cin>>P>>Q>>A>>N, P||Q||A||N) {
		ans=0;
		dfs(0, 1, 0, 1);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


n, m = li()
a = [ni() for _ in range(m)]
aset = set(a)

MOD = 10**9+7

dp = [0]*(n+1)
dp[0] = 1

for i in range(n):
    if i+1 in aset:
        continue

    if i == 0:
        dp[1] = 1

    else:
        dp[i+1] = dp[i] + dp[i-1]
        dp[i+1] %= MOD

print(dp[n])

Measured memory_bytes: 13212
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; ++i)
        cin >> A[i];

    vector<ll> dp(N + 1, 1000);
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < i; ++j) {
            ll tmp = dp[j] / A[j];
            dp[i + 1] = max(dp[i + 1], dp[j + 1]);
            dp[i + 1] = max(dp[i + 1], dp[j + 1] + (ll)tmp * (A[i] - A[j]));
        }
    }

    cout << dp[N] << endl;

    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);    
int a,b;
cin>>a>>b;
if(a<10&&b<10){
cout<<a*b;}else{
    cout<<-1;
}
}

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

using namespace std;

const int MAXN = 3010;

bool seen[MAXN][MAXN/2];
double memo[MAXN][MAXN/2];
double p[MAXN];

double pd(int n, int odds){
    if(n == 0 && odds) return 0.0;
    if(n == 0 && !odds) return 1.0;
    if(seen[n][odds]) return memo[n][odds];

    double ans = 0.0L;

    ans = pd(n-1, odds) * (1-p[n]);
    ans += pd(n-1, max(odds-1, 0)) * p[n];

    seen[n][odds] = true;
    return memo[n][odds] = ans;
}

int main(){
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> p[i];
    printf("%.9lf\n", pd(n, n/2+1));
    return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define each(it,v) for(auto &it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vl vector<long>
#define P pair<int,int>
using namespace std;

main()
{
        set<char> s;
        rep(i,4)
        {
                char c; cin>>c;
                s.insert(c);
        }
        if(s.size()==2)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main (void){
  int n;
  cin >> n;
  vector<long> h(n);
  
  for(int i = 0; i < n; i++){
    cin >> h[i];
  }
  
  int ok = 1;
  for(int i = n-1; i > 0; i--){
    if(h[i - 1] <= h[i]){
      
    }
    else if(h[i - 1] == h[i] + 1){
      h[i-1]--;
    }
    else if(h[i - 1] - h[i] > 1){
      ok = 0;
      break;
    }
  }
  if(ok){
    cout << "Yes";
  } else{
    cout << "No";
  }
  return 0;
}

Measured memory_bytes: 1024
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}
func fSum(a []float64) float64 {
	x := 0.
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	m := iScan()
	a := iSScan(n)
	b := iSScan(m)
	x := make([]int, n*m+1)
	y := make([]int, n*m+1)
	xm := make(map[int]int)
	ym := make(map[int]int)
	for _, v := range a {
		x[v]++
		xm[v]++
	}
	for _, v := range b {
		y[v]++
		ym[v]++
	}
	for i := 1; i <= n*m; i++ {
		x[i] += x[i-1]
		y[i] += y[i-1]
	}
	ans := 1
	for i := n * m; i > 0; i-- {
		if xm[i] > 1 || ym[i] > 1 {
			ans *= 0
			break
		} else if xm[i] == 1 && ym[i] == 1 {
			continue
		} else if xm[i] == 1 {
			ans *= m - y[i-1]
		} else if ym[i] == 1 {
			ans *= n - x[i-1]
		} else {
			ans *= (n-x[i-1])*(m-y[i-1]) - (n*m - i)
		}
		ans %= mod
	}
	fmt.Println(ans)
}


Measured memory_bytes: 18188
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//int goal=2001;
		int n=sc.nextInt();
		int d=sc.nextInt();
		int x=sc.nextInt();
		int a[] = new int[n];
		int num=x;
		for(int i=0;i<n;i++) {
			a[i]=sc.nextInt();
			for(int j=1;j<=d;j+=a[i]) {
				num++;
			}
		}
		
		System.out.println(num);
	}
}


Measured memory_bytes: 21844
H,W=map(int,input().split())
m=[list(input()) for _ in range(H)]

ans="Yes"
for h in range(H):
	for w in range(W):
		if m[h][w] == "#":
			ok = False
			if h-1 >= 0 and m[h-1][w] == "#":
				ok = True
			if w-1 >= 0 and m[h][w-1] == "#":
				ok = True
			if h+1 < H and m[h+1][w] == "#":
				ok = True
			if w+1 < W and m[h][w+1] == "#":
				ok = True
			if not ok:
				ans="No"
print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<climits>
#include<algorithm>
using namespace std;

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

    vector<int> X(N);
    for (int i = 0; i < N; i++)
        cin >> X[i];

    int ans = INT_MAX;
    for (int i = 1; i < 101; i++) {
        int sum = 0;
        for (int j = 0; j < N; j++)
            sum += (i - X[j])*(i - X[j]);

        ans = min(ans, sum);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    int ans = n/2;

    if(n%2 == 0) {
        ans--;
    }

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

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

int main() {
    int a, b;
    while(cin >> a >> b, a) {

    vector <vector <int>> dp(a, vector <int> (b, 0));
    int n;
    cin >> n;
    while(n--) {
        int x, y;
        cin >> x >> y;
        dp[a - x][y - 1] = -1;
    }

    dp[a - 1][0] = 1;
    for (int i = a - 1; i >= 0; i--) rep (j, b) {
        int tmp = 0;
        if (i + 1 <= a - 1 && dp[i + 1][j] != -1) tmp += dp[i + 1][j];
        if (j - 1 >= 0     && dp[i][j - 1] != -1) tmp += dp[i][j - 1];
        if (dp[i][j] != -1) dp[i][j] += tmp;
    }
    cout << dp[0][b - 1] << endl;

    }
    return 0;
}


Measured memory_bytes: 3128
n = int(input())
p = list(map(int, input().split()))
suu = 0
for i in range(n - 2):
  han = []
  han.append(p[i])
  han.append(p[i+1])
  han.append(p[i+2])
  sor = sorted(han)
  if sor[1] == p[i+1]:
    suu += 1
print(suu)

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

int main() {
  int N;
  cin >> N;
  vector<vector<int>> data(4, vector<int>(13, 0));
  for (int i=0; i<N; i++) {
    string a;
    int b;
    cin >> a >> b;
    if (a == "S") data.at(0).at(b-1) = 1;
    if (a == "H") data.at(1).at(b-1) = 1;
    if (a == "C") data.at(2).at(b-1) = 1;
    if (a == "D") data.at(3).at(b-1) = 1;
  }
  
  for (int i=0; i<4; i++) {
    for (int j=0; j<13; j++) {
      if (data.at(i).at(j) == 0) {
        if (i == 0) cout << "S " << j+1 << endl;
        if (i == 1) cout << "H " << j+1 << endl;
        if (i == 2) cout << "C " << j+1 << endl;
        if (i == 3) cout << "D " << j+1 << endl;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3152
def calc(summation, step, operation):
    if step < len(line):
        # plus
        calc(summation+line[step], step+1, operation+"+")
        # minus
        calc(summation - line[step], step + 1, operation+"-")
    if step == len(line):
        if summation == 7:
            ans = str(line[0])+operation[0]+str(line[1])+operation[1] + \
                str(line[2])+operation[2]+str(line[3])+"=7"
            print(ans)
            exit()


line = [int(i) for i in input()]
calc(line[0], 1, "")


Measured memory_bytes: 9196
#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<int,int>;

int main() {
    string S;
    cin >> S;
    int maxi = 0;
    int conti = 0;
    for (int i = 0; i < 3; i++) {
        if (S[i] == 'R') {
            conti++;
            if (conti > maxi) maxi = conti;
        } else {
            conti = 0;
        }
    }
    cout << maxi << endl;
    return 0;
}


Measured memory_bytes: 3616
N, W = gets.split.map(&:to_i)

h = { 0 => 0 }

N.times{
	a, b = gets.split.map(&:to_i)
	h.to_a.each{ | w, v |
		h[ w + a ] = [ h[ w + a ] || 0, v + b ].max if w + a <= W
	}
}
p h.values.max

Measured memory_bytes: 2812
H, W = list(map(int, input().split()))
S = [input() for _ in range(H)]

g = [".", "#"]
HL = [[0] * W for _ in range(H)]
HR = [[0] * W for _ in range(H)]

for i in range(H):
  l = 0
  r = 0
  for j in range(W):
    if S[i][j] == g[0]:
      l += 1
    else:
      l = 0
    HL[i][j] = l
    if S[i][W - 1 - j] == g[0]:
      r += 1
    else:
      r = 0
    HR[i][W - 1 - j] = r

WU = [[0] * W for _ in range(H)]
WD = [[0] * W for _ in range(H)]

for i in range(W):
  u = 0
  d = 0
  for j in range(H):
    if S[j][i] == g[0]:
      u += 1
    else:
      u = 0
    WU[j][i] = u
    if S[H - j - 1][i] == g[0]:
      d += 1
    else:
      d = 0
    WD[H - j - 1][i] = d

ans = 0

for i in range(H):
  for j in range(W):
    k = HL[i][j] + HR[i][j] + WU[i][j] + WD[i][j] - 3
    ans = max(ans, k)

print(ans)


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	vector<pii> arr (1 << N);
	F0R(i, 1<<N) {
		int x; cin >> x;
		arr[i] = {x, i};
	}
	vector<set<pii>> data (1 << N);
	F0R(i, 1<<N) {
		data[i].insert(arr[i]);
		F0R(j, N) if (i & (1 << j)) {
			for (pii x : data[i ^ (1 << j)]) data[i].insert(x);
		}
		while (data[i].size() > 2) data[i].erase(data[i].begin());
	}

	int best = 0;
	FOR(i, 1, 1<<N) {
		int ns = (*data[i].begin()).first + (*++data[i].begin()).first;
		best = max(best, ns);
		print(best);
	}
}

Measured memory_bytes: 42340
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)

def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math


a, b = getList()
if abs(a-b) % 2 == 1:
    print("IMPOSSIBLE")
else:
    print((a+b) // 2)

Measured memory_bytes: 38384
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
A.sort()
count_of_a = Counter(A)
# すでに出現した倍数の場合はアウト
ans = 0
max_A = max(A)
dp = [True] * (max_A+1)
happpend = set()
for a in A:
    if count_of_a[a] >= 2:
        # 複数出現するとしても，初めての要素の場合は処理を行う
        if a in happpend:
            continue
        x = a*2
        while x <= max_A:
            dp[x] = False
            x += a
        happpend.add(a)
    else:
        if dp[a]:
            ans += 1
        x = a*2
        while x <= max_A:
            dp[x] = False
            x += a
print(ans)


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

int main() {
    int n;cin>>n;
    int a[n],tmp;
    for(int i=0;i<n;++i){
        a[i]=0;
    }
    for(int i=0;i<n-1;++i){
        cin>>tmp;
        a[tmp-1]+=1;
//        cout<<a[tmp-1]<<endl;
    }
    for(int i=0;i<n;++i){
        cout<<a[i]<<endl;
    }    
    
	return 0;
}

Measured memory_bytes: 4416
import sys
input = sys.stdin.readline

N = int(input())
A = [int(input()) for _ in range(N)] + [0]

ans = 0
for i in range(N):
    # できるだけ左でペアを作る
    Lpair = A[i] // 2
    ans += Lpair
    A[i] -= 2 * Lpair

    if A[i] > 0 and A[i + 1] > 0:
        ans += 1
        A[i] -= 1
        A[i + 1] -= 1


print(ans)


Measured memory_bytes: 7840
L = []
for _ in range(3):
    x, y = map(int, input().split())
    L.append(x)
    L.append(y)

num = []
num.append(L.count(1))
num.append(L.count(2))
num.append(L.count(3))
num.append(L.count(4))

if max(num) == 3:
    print('NO')
else:
    print('YES')

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

long long getSumOfDigits(long long n){
    int sum = 0;
    while(n>0){
        sum += n%10;
        n /= 10;
    }
    return sum;
}

int main(){
    long long n;
    cin >> n;
    if((n%getSumOfDigits(n))==0)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
S = input()


R = []
B = []
G = []
p = 0
for i in S:
    if(i == "R"):
        R.append(p)
    elif(i == "B"):
        B.append(p)
    elif(i == "G"):
        G.append(p)
    p += 1
R = set(R)
B = set(B)
G = set(G)
sum = len(R) * len(B) * len(G)
for r in R:
    for b in B:
        up = max(r, b)
        dw = min(r, b)
        d = up-dw
        if up + d in G:
            sum -= 1
        if dw - d in G:
            sum -= 1
        if (r+b)/2 in G:
            sum -= 1

print(sum)


            

Measured memory_bytes: 9464
function main(input) {
  var args = input.split('\n');
  var n = parseInt(args[0]);
  var vi = args[1].split(' ');
  var ci = args[2].split(' ');
  var benefit = 0;
  for(var i = 0; i < n; i++){
    v = parseInt(vi[i]);
    c = parseInt(ci[i]);
    if(v > c){
      benefit += (v - c);
    }
  }
  console.log(benefit);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 11468
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N = int(input())

w = input()
last = w[-1]
past = [w]
for _ in range(N-1):
    w = input()
    if w[0] != last or w in past:
        print('No')
        quit()
    last = w[-1]
    past.append(w)
print('Yes')

Measured memory_bytes: 9080
s=int(input())
if 400<=s<=599:
    print('8')
elif 600<=s<=799:
    print('7')
elif 800<=s<=999:
    print('6')
elif 1000<=s<=1199:
    print('5')
elif 1200<=s<=1399:
    print('4')
elif 1400<=s<=1599:
    print('3')
elif 1600<=s<=1799:
    print('2')
elif 1800<=s<=1999:
    print('1')

Measured memory_bytes: 9184
N, K = map(int, input().split())
H = [int(input()) for i in range(N)]

H.sort(reverse = True)
ans = H[0] - H[0 + K - 1]
for i in range(N - K + 1):
    if H[i] - H[i + K - 1] < ans:
        ans = H[i] - H[i + K - 1]

print(ans)

Measured memory_bytes: 7384
#include<cstdio>
#include<iostream>
#include<map>
#include<set>
#include<vector>
#include<cstring>
#include<cassert>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<limits>
#include<ctime>
#include<stack>
#include<bits/stdc++.h>
#include<string>
#include<stdlib.h>
#include<stdio.h>
typedef long long ll;

using namespace std;

int main(){
	ll n,sum=0,i=0;
	cin>>n;
	while(n>=1){
		sum+=(pow(2,i));
		n/=2;
		i++;
	}
	cout<<sum;
}



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

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

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    start = time.time()
    n,m,p = LI()
    abc = [LI() for _ in range(m)]
    er = collections.defaultdict(set)
    err = collections.defaultdict(set)
    for a,b,c in abc:
        er[b].add(a)
        err[a].add(b)

    v = set([n])
    q = [n]
    qi = 0
    while len(q) > qi:
        t = q[qi]
        qi += 1
        for b in er[t]:
            if b not in v:
                v.add(b)
                q.append(b)

    u = set([1])
    q = [1]
    qi = 0
    while len(q) > qi:
        t = q[qi]
        qi += 1
        for b in err[t]:
            if b not in u:
                u.add(b)
                q.append(b)

    v &= u

    e = collections.defaultdict(list)
    for a,b,c in abc:
        if a not in v or b not in v:
            continue
        e[a].append((b,c-p))

    en = len(e)
    km = sum(map(lambda x: x[2], abc))
    def search(s):
        d = collections.defaultdict(lambda: -inf)
        vc = collections.defaultdict(int)
        q = []
        d[s] = 0
        heapq.heappush(q, (0, s))
        ttt = 0
        while len(q):
            ttt += 1
            if ttt % 1024 == 0:
                if time.time() - start > 1.5:
                    return
            mk, u = heapq.heappop(q)
            k = -mk
            if d[u] > k:
                continue
            if k > km or vc[u] > en:
                return
            vc[u] += 1

            for uv, ud in e[u]:
                vd = k + ud
                if d[uv] < vd:
                    d[uv] = vd
                    heapq.heappush(q, (-vd, uv))

        return d

    d = search(1)
    if d is None:
        return -1
    return max(0, d[n])

print(main())





Measured memory_bytes: 139604
n, k = map(int,input().split())
nlist=[0]*n
for i in range(k):
    d=int(input())
    alist=list(map(int, input().split()))
    for al in alist:
        nlist[al-1]+=1

answer=0
for nl in nlist:
    if nl==0:
        answer+=1

print(answer)

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

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

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n, i##_len=(n); i>=0; i--)
#define FOR(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)

//最大公約数 
 ll gcd(ll a,ll b){
 if(b == 0) return a;
 return gcd(b,a%b);
 }

//最小公倍数
 ll lcm(ll a,ll b){
 ll g = gcd(a,b);
 return a / g * b; // Be careful not to overflow  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
} 

int main(){
	int N;
	cin >> N;
	vector<ll> T(N);
	REP(i, N) cin >> T[i];
	ll ans = 0;
	if(N == 1) {
		cout << T[0] << endl;
		return 0;
	}
	else ans = lcm(T[0], T[1]);

	for(int i = 2; i < N; i++){
		ans = lcm(ans, T[i]);
		// cout << ans << endl;		
	}
cout << ans << endl;

}

Measured memory_bytes: 256
N,W = [int(v) for v in input().split()]
dp = [[0 for _ in range(W+1)] for _ in range(N+1)]

for i in range(1,N+1):
    w,v = [int(v) for v in input().split()]
    for cap in range(W+1):
        if cap - w >= 0:
            dp[i][cap] = max(dp[i][cap],dp[i-1][cap-w]+v)
        dp[i][cap] = max(dp[i][cap],dp[i-1][cap])

print(dp[-1][-1])


Measured memory_bytes: 173576
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    int A[200010];
    rep(i, N) cin >> A[i];
    K = min(K, 460LL);
    while(K--) {
        int B[200010] = {};
        rep(i, N) {
            B[max(0LL, i - A[i])]++;
            B[min(N - 1, i + A[i]) + 1]--;
        }
        rep(i, N) B[i + 1] += B[i];
        rep(i, N) A[i] = B[i];
    }
    rep(i, N) {
        if(i != 0) cout << " ";
        cout << A[i];
    }
    cout << endl;


    return 0;
}


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

int main() {
	string s;
	cin >> s;
	string ans = "Good";
	for (int i = 0; i < 4-1; i++) {
		if (s.at(i) == s.at(i+1)) {
			ans = "Bad";
			cout << ans << endl;
			return 0;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
sys.setrecursionlimit(10**7)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
PI = math.pi
# endregion
N = ri()
ans = 'No'
for c in range(100):
    for d in range(100):
        if c * 4 + d * 7 == N:
            ans = 'Yes'
print(ans)

Measured memory_bytes: 65260
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << endl;
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << "";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define wh while
#define ve vector
#define mp make_pair
#define tp tuple
#define mt make_tuple
#define pb push_back
#define pof pop_front
#define pob pop_back
#define pf push_front
#define fr front
#define ft first
#define sc second
#define tos to_string
#define len length
#define rt return
#define br break
#define con continue
#define lcm(n, m) (n * m / __gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define revi(i, m, n) for(ll i=(ll)(m) - 1;i>=(ll)(n);i--)
#define rev(i, m) revi(i, m, 0)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) n.begin(), n.end()
#define allr(n) n.rbegin(), n.rend()
#define sp(n) cout << fixed << setprecision(n)
#define pi 3.14159265358979323846
#define inf 1000000007
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

ve<int> dx = {0, 0, 1, -1}, dy = {1, -1, 0, 0};

int main() {
  int d;
  ci(d);
  ve<int> C(26);
  ve<ve<int>> S(d, ve<int>(26));
  ve<int> T(d);
  rep(i, 26){
    ci(C.at(i));
  }
  rep(i, d){
    rep(j, 26){
      ci(S.at(i).at(j));
    }
  }
  rep(i, d){
    ci(T.at(i));
    T.at(i)--;
  }
  int m;
  ci(m);
  rep(k, m){
    int a, b;
    ci(a, b);
    a--, b--;
    T.at(a) = b;
    ve<int> L(26, 0);
    ll ans = 0;
    rep(i, d){
      ans += S.at(i).at(T.at(i));
      L.at(T.at(i)) = i + 1;
      rep(j, 26){
        ans -= C.at(j) * (i + 1 - L.at(j));
      }
    }
    co(ans);
  }
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
	int n,W;
	cin >> n >> W;
	VL w(n),v(n);
	for (int i = 0; i < n; i++) {
		cin >> w[i] >> v[i];
	}
	VVL dp(n,VL(W+1,0));
	for (int i = w[0]; i < W+1; i++) {
		dp[0][i] = v[0];
	}

	for (int i = 1; i < n; i++) {
		for (int j = 0; j < W+1; j++) {
			if (j - w[i] < 0) {
				dp[i][j] = dp[i-1][j];
				continue;
			}
			dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i]] + v[i]);
		}
	}
	cout << dp[n-1][W] << endl;
	return 0;
}


Measured memory_bytes: 79360
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define Mod 1000000007
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
#define INF 999999999999999999
#define NN (ll)(1e6+5)
int mod(string s,int a) 
{ 
    int ans=0; 
    for (int i=0;i<s.length();i++) 
         ans=(ans*10+(int)s[i]-'0')%a; 
    return ans; 
}
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
ll power(ll x,unsigned ll y) 
{ 
    if (y==0) 
        return 1; 
    else if (y%2==0) 
        return power(x,y/2)*power(x,y/2); 
    else
        return x*power(x,y/2)*power(x,y/2); 
}
ll hcf(ll a,ll b) 
{ 
    if(b==0) 
        return a; 
    return hcf(b,a%b);  
}
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE 
    	freopen("input.txt", "r", stdin); 
    	freopen("output.txt", "w", stdout); 
    	freopen("error.txt", "w", stderr); 
   #endif*/
   ll TT=1;
   //cin>>TT;
   while(TT--)
   {    
       ll n,i,c=0;
       cin>>n;
       vector <ll> v(n),vis(NN,0);
       map <ll,ll> mp;
       for(auto &u:v)
       {
           cin>>u;
           vis[u]++;
       }       
       if(vis[1]>1)
       {
           cout<<"0\n";
           return 0;
       }
       if(vis[1]==1)
       {
           cout<<"1\n";
           return 0;
       }
       for(auto u:v)
       {
           if(mp.find(u)!=mp.end())
           {
               c+=mp[u];
               continue;
           }
           if(vis[u]>1)
           {
               mp[u]=0;
               continue;
           }
           ll x=u,f=0;
           for(i=2;i*i<=x;i++)
           {
               if(x%i==0)
               {
                   if(vis[i])
                   {
                       f=1;
                       break;
                   }
                   if(x/i!=i)
                   {
                       if(vis[x/i])
                       {
                           f=1;
                           break;
                       }
                   }
               }
           }
           if(f)
            mp[u]=0;
           else
            mp[u]=1;
           c+=mp[u];  
       }
       cout<<c<<"\n";
   }
}

Measured memory_bytes: 25092
#include <iostream>
#include <iomanip>
using namespace std;
int main(void){
    
    int a,b ;
    cin >> a ;
    cin >> b ;
    
    int d = a/b;
    int r = a%b;
    double f = double(a) / double(b);
    
    cout << d;
    cout << " ";
    cout << r;
    cout << " ";
    cout << fixed << setprecision(5) << f;
    cout << endl;

    
}


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

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    map<string, int> mp;
    for (int i=0; i<n; i++){
        cin >> s.at(i);
        sort(s.at(i).begin(), s.at(i).end());
        mp[s.at(i)]++;
    }

    long long cnt = 0;

    for (auto s: mp){
        cnt += (long long)s.second * (s.second - 1) / 2;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 18176
data Edge = Edge Int Int Int deriving (Eq)
instance Show Edge where
  show (Edge a b c) = show a ++ " " ++ show b ++ " "  ++ show c

gep 2 = (1, 0)
gep x = let 
          p = head $ filter (\c-> 2^c >= x) [0..]
          q = if 2^p == x then p else p - 1
          r =  x - 2^q
        in (q, r)

graph :: Int-> (Int, Int, [Edge])
graph x = (nn, en, edges)
  where
    (a, m) = gep x 
    nn = a + 1
    edges = [Edge p q r | p <- [1..nn-1], let q = p + 1, r<-[0, 2^(p-1)]] ++
      etge nn (2^(nn - 1) - 1) m
    en = length edges 

etge :: Int->Int->Int->[Edge]
etge a b 0 = []
etge a b 1 = [Edge 1 a (b+1)]
etge a b x = let
              (p, q) = gep x
             in  Edge (p + 1) a (b + 1) : etge a (b + 2^p) q


format :: (Int, Int, [Edge]) -> String
format (a, b, edges) = foldl (\x y -> x ++ show y ++ "\n") (show a ++ " " ++ show b ++ "\n") edges

main = do
  n <- readLn
  putStrLn $ format $ graph n

Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long int W,H,x,y;
  cin >> W>>H>>x>>y;
  
  int c=0;
  double S;
  S=W*H/2.;
  if(2*x==W && 2*y==H)c=1;
  cout<<fixed;  
  cout << setprecision(8)<<S<<" ";
  cout <<c<<endl;

}


Measured memory_bytes: 256
// acdart
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <string>
#include <queue>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <cstdlib>
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define X first
#define Y second
#define F first
#define S second
#define MOD9 1000000009ll
#define MOD7 1000000007ll
#define MOD
#define INF  1023456789ll
#define INF16 10000000000000000ll
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define SZ(x) ((int)(x).size())
#define MAXN 10010
#define MAXM
#define ALL(x) ((x).begin()),((x).end())
#define RESET(a,b) memset(a,b, sizeof a)
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define LEN(X) strlen(X)
#define FI(a,b,c) for(int a=b; a<c; a++)
#define FD(a,b,c) for(int a=b; a>c; a--)
using namespace std;
typedef long long ll;
typedef long long LL;
typedef double db;
typedef double D;
typedef long double ld;
typedef long double LD;
/*********default*********/

int main()
{
	int n;
	long long a[110];
	
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		scanf("%lld", &a[i]);
	}
	sort(a, a + n);
	int x;
	long long t = 0x3ffffffffffff;
	for (x = -100; x <= 100; x++){
		long long s = 0;
		for (int i = 0; i < n; i++){
			s += (a[i] - x) * (a[i] - x);
		}
		t = min(s, t);
	}
	printf("%lld\n", t);
}

Measured memory_bytes: 256