akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Modular
    {
        private const int M = 1000000007;
        private static readonly List<int> facs = new List<int> { 1 };
        private long value;

        public Modular(long value)
        {
            this.value = value;
        }
        public static implicit operator Modular(long a)
        {
            return new Modular(a % M);
        }
        public static Modular operator +(Modular a, Modular b)
        {
            return (a.value + b.value) % M;
        }
        public static Modular operator -(Modular a, Modular b)
        {
            return ((a.value - b.value) % M + M) % M;
        }
        public static Modular operator *(Modular a, Modular b)
        {
            return a.value * b.value % M;
        }
        private static Modular Pow(Modular a, int n)
        {
            switch (n)
            {
            case 0:
                return new Modular(1);
            case 1:
                return a;
            default:
                var p1 = Pow(a, n / 2);
                var p2 = p1 * p1;
                return ((n % 2) == 0) ? p2 : p2 * a;
            }
        }
        public static Modular operator /(Modular a, Modular b)
        {
            return a * Pow(b, M - 2);
        }
        private static Modular Fac(int n)
        {
            for (int i = facs.Count; i <= n; ++i)
            {
                facs.Add((int)(Math.BigMul(facs.Last(), i) % M));
            }
            return new Modular(facs[n]);
        }
        public static Modular Ncr(int n, int r)
        {
            return (n < r)  ? new Modular(0)
                 : (n == r) ? new Modular(1)
                            : Fac(n) / Fac(r) / Fac(n - r);
        }
        public static explicit operator int(Modular a)
        {
            return (int)a.value;
        }
    }

    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static int Solve(int N, int M, int K)
        {
            Modular a = 0, b = 0;
            for (int i = 0; i < N; ++i) { a += Math.BigMul(N - i, i); }
            for (int i = 0; i < M; ++i) { b += Math.BigMul(M - i, i); }
            return (int)((a * M * M + b * N * N) * Modular.Ncr(N * M - 2, K - 2));
        }

        static void Main(string[] args)
        {
            var V = ReadInts();
            Console.WriteLine(Solve(V[0], V[1], V[2]));
        }
    }
}


Measured memory_bytes: 16984
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder s = new StringBuilder(sc.next());
		int n=3;
		for(int i=0;i<Math.pow(2, n);i++) {
			int[] status = new int[n];
			int sum=Integer.valueOf(s.substring(0,1));
			String res=s.substring(0, 1);
			for(int j=0;j<n;j++) {//iを2進数にした場合にどこの桁が1になっているか判定し、1の場合はstatusに代入
				if((1&i>>j)==1) {
					status[j]=1;
				}
			}
			for(int j=0;j<n;j++) {
				if(status[j]==1) {
					sum+=Integer.valueOf(s.substring(j+1,j+2));
					res+="+";
				}else {
					sum-=Integer.valueOf(s.substring(j+1, j+2));
					res+="-";
				}
				//System.out.println(sum);
				res+=s.substring(j+1, j+2);
			}
			if(sum==7) {
				System.out.println(res+"=7");
				break;
			}
		}

	}
}



Measured memory_bytes: 21844
n, m = map(int, input().split())

if n == 1 and m == 0:
  print(0)
  exit()

ans = [-1] * n


for i in range(m):
    s, c = map(int, input().split())
    s -= 1
    if ans[s] != -1 and ans[s] != c:
        print(-1)
        exit()

    else:
        ans[s] = c

if ans[0] == 0 and n >= 2:
    print(-1)
    exit()

elif ans[0] == -1:
    ans[0] = 1

a = ""
for i in ans:
    a += str(i) if i != -1 else "0"
print(a)

Measured memory_bytes: 3064
#include <stdio.h>
#include <ctype.h>

int main(){

    char word;

    while (1)
    {
        scanf("%c",&word);
        
        if (word=='\n')
        {
            break;
        }
        if (islower(word))
        {
           printf("%c",toupper(word));
        }
        else if (isupper(word))
            printf("%c",tolower(word));
        else
            printf("%c",word);
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        

fast();
//ll t;cin>>t;while(t--)
{
    ll n,ans=0;
    cin>>n;
    ll nn=n*3;
    ll a[(nn)];
    for(int i=0;i<nn;i++)
    {
      cin>>a[i];
    }
    sort(a,a+nn);
    //for(auto t:a)cerr<<t<<" ";
      //cerr<<endl;
    ll i=nn-2,c=0;
    while(c<n)
    {
      c++;
      ans+=a[i];
      i-=2;

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

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, ll> Pl;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int mod = 1e+9 + 7;
const int INF = 1e+9;

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

    double n;
    cin >> n;
    double tmp = n / 1.08;
    if(tmp == (int)tmp){
        cout << tmp << endl;
    }
    else{
        int num = (int)tmp;
        for(int i = num - 10; i <= num + 10; ++i){
            int d = (int)i * 1.08;
            if(d == (int)n){
                cout << i << endl;
                return 0;
            }
        }
        cout << ":(\n";
    }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int digit = N%10;
        if (digit == 2 || digit == 4 || digit == 5 || digit == 7 || digit == 9) {
            System.out.println("hon");
        } else if (digit == 0  || digit == 1 || digit == 6 || digit == 8) {
            System.out.println("pon");
        } else {
            System.out.println("bon");
        }
    }
}

Measured memory_bytes: 35696
var GET = (function () {function f(s) {return new g(s);}function g(s) {this._s = s.trim().split("\n");}g.prototype.getValue = function (n) {return this._s[n];};g.prototype.getArray = function (n) {return this.stoa(this._s[n]);};g.prototype.slice = function (s, limit) {return this._s.slice(s, +limit + s || undefined).map(v => this.stox(v));};g.prototype.sliceArray = function (s, limit) {return this._s.slice(s, +limit + s || undefined).map(v => this.stoa(v));};g.prototype.stoa = function (s) {return s.split(" ").map(v => this.stox(v));};g.prototype.stox = function (v) {var i = +v;return (i === i) ? i : v;};return f;})();
var o = GET(require("fs").readFileSync("/dev/stdin", "utf8"));

console.log(main());
function main(){
    var N = +o.getValue(0);

    if (N % 1000 === 0) {
        return 0;
    }

    return 1000 - (N % 1000);
}

Measured memory_bytes: 30548
N = int(input())
H = list(map(int, input().split(" ")))

ans = 0
cnt = 0
for i in range(N - 1):
    if H[i] >= H[i + 1]:
        cnt += 1
    else:
        ans = max(ans, cnt)
        cnt = 0

ans = max(ans, cnt)
print(ans)

Measured memory_bytes: 14252
n = int(input())
sp = [input().split() for _ in range(n)]

s = [_sp[0] for _sp in sp]
p = [int(_sp[1]) for _sp in sp]

s_idx = sorted(range(len(s)), key=s.__getitem__)

s_unique = list(set(s))
s_unique.sort()

for i in range(len(s_unique)):
    l = []
    for j in range(n):
        if s[j] == s_unique[i]:
            l.append(j)
    _p = []
    for k in l:
        _p.append(p[k])
    _p_idx = sorted(range(len(_p)), key=_p.__getitem__)
    _p_idx = _p_idx[::-1]
    for x in _p_idx:
        print(l[x] + 1)


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

int main(){
    int N;
    cin >> N;
    string s[10000];
    for(int i=0;i<N;i++) cin >> s[i];

    int64_t cnt = 0;
    int cb=0, ca=0, cab=0;
    for(int i=0;i<N;i++){
        bool a = false;
        for(size_t j=0;j<s[i].size();j++){
            if(s[i][j] == 'B' && a == true) cnt++;
            if(s[i][j] == 'A') a = true;
            else a = false;
        }
        if(s[i].back()=='A' && s[i].front()=='B') cab++;
        else if(s[i].back()=='A') ca++;
        else if(s[i].front()=='B') cb++;
    }

    if(ca==0 && cb==0){
        if(cab==0) cout << cnt << endl;
        else cout << cnt + cab -1 << endl;
    }else{
        cout << cnt + cab + min(ca, cb) << endl;
    }
    
    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int ans;
int main(void){
    int n; cin>>n;
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            if(n==i*j){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
    
}


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

#define rep(i,n) for(int i=0 ; 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 FORR(i,m,n) for(int i=(m) ; i>=(n) ; i--)

#define All(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;

const int INF = 1e9;

int main(){
   int a,b,k;cin >> a >> b >> k;
   for(int i=a;i<=min(b,a+k-1);i++)cout << i << endl;
   for(int i=max(b-k+1,a+k);i<=b;i++)cout << i << endl;
   return 0;
}


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

using namespace std;

int bubbleSort(int a[], int N) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0;flag;i++) {
		flag = 0;
		for (int j = N - 1;j >= i + 1;j--) {
			if (a[j - 1] > a[j]) {
				swap(a[j - 1], a[j]);
				flag = 1;
				sw++;
			}
		}
	}
	return sw;
}

int main() {
	int N;
	cin >> N;
	int a[114514];
	int i, j;
	for (i = 0;i < N;i++) {
		cin >> a[i];
	}
	int sw = bubbleSort(a, N);
	for (int i = 0;i < N;i++) {
		if (i)cout << " ";
		cout << a[i];
	}
	cout << endl;
	cout << sw << endl;
	return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#define N 8
using namespace std;

int qc;

int Row[N] = {};
int Column[N] = {};
int Decrease[2 * N - 1] = {};
int Increase[2 * N - 1] = {};

bool Board[8][8] = {};

void PrintBoard()
{

    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            if (Board[i][j])
            {
                if (Row[i] != j)
                {
                    return;
                }
            }
        }
    }

    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            if (Board[i][j] || Row[i] == j)
            {
                cout << 'Q';
            }
            else
            {
                cout << '.';
            }
            /*if (j != N - 1)
            {
                cout << ' ';
            }*/
        }
        cout << endl;
    }
}

void PutQueen(int i)
{
    if (i == N)
    {
        PrintBoard();
        return;
    }

    for (int j = 0; j < N; j++)
    {
        if (Column[j] == 1 || Increase[i + j] == 1 || Decrease[i - j + N - 1] == 1)
        {
            continue;
        }
        Row[i] = j;
        Column[j] = Increase[i + j] = Decrease[i - j + N - 1] = 1;
        PutQueen(i + 1);
        Column[j] = Increase[i + j] = Decrease[i - j + N - 1] = 0;
    }
}

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int posX, posY;
        cin >> posX >> posY;
        Board[posX][posY] = 1;
    }

    PutQueen(0);

    return 0;
}


Measured memory_bytes: 3124
N =int(input())
S = str(input())
A = 0
R = []
G = []
B = []
for i in range(len(S)):
  if S[i] == "R":
    R.append(i+1)
  elif S[i] == "G":
    G.append(i+1)
  else:
    B.append(i+1)

A = len(R)*len(G)*len(B)
for i in range(N):
  for j in range(i+1,N):
    k = j + (j-i)
    if k >= N:
      break
    if S[i] != S[j] and S[j] != S[k] and S[i] != S[k]:
      A -= 1
print(A)


Measured memory_bytes: 68156
x,n = map(int,input().split())
lst = list(map(int,input().split()))
i = 0
j = 0
while True :
    if x + i not in lst or x + j not in lst :
        if x + j not in lst :
            print(x+j)
            break
        else :
            print(x+i)
            break
    i += 1
    j -= 1


Measured memory_bytes: 9176
from math import ceil

D, G = map(int, input().split())
Pd, Cd = [0] * D, [0] * D

for i in range(D):
    Pd[i], Cd[i] = map(int, input().split())


ans = float("inf")
for i in range(1 << D):
    score, solved, unsolved = 0, 0, 0
    for j in range(D):
        if i & (1 << j):
            score += 100 * (j+1) * Pd[j] + Cd[j]
            solved += Pd[j]
        else:
            unsolved = j

    rest = G - score
    if rest > 0:
        k = 100 * (unsolved+1)
        if k * Pd[unsolved] < rest:
            continue
        solved += ceil(rest/k)

    ans = min(ans, solved)

print(ans)


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

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> H(N);
  for(int i = 0; i < N; i++){
    cin >> H.at(i);
  }
  vector<int> A(M);
  vector<int> B(M);
  for(int i = 0; i < M; i++){
    cin >> A.at(i) >> B.at(i);
  }
  vector<bool> S(N, true);
  for(int i = 0; i < M; i++){
    if(H.at(A.at(i)-1) > H.at(B.at(i)-1)){
      S.at(B.at(i)-1) = false;
    }else if(H.at(A.at(i)-1) < H.at(B.at(i)-1)){
      S.at(A.at(i)-1) = false;
    }else{
      S.at(A.at(i)-1) = false;
      S.at(B.at(i)-1) = false;
    }
  }
  int count = 0;
  for(int i = 0; i < N; i++){
    if(S.at(i)){
      count ++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 4580
#include<bits/stdc++.h>
using lint=long long;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n,k;std::cin>>n>>k;k--;
    std::vector<lint>a(n);
    for(lint&x:a)std::cin>>x;
    std::sort(a.begin(),a.end());
    lint ans=std::numeric_limits<lint>::max();
    for(lint i=0;i<n-k;i++){
        lint now=a.at(i+k)-a.at(i);
        if(ans>now)ans=now;
    }
    std::cout<<ans<<'\n';
}


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

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;
// }}}
signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  i64 n, x;
  cin >> n >> x;

  vector<i64> vec;
  i64 sum = 0;
  rep(i, n) {
    i64 a;
    cin >> a;
    sum += a;
    vec.push_back(a);
  }

  if (sum == x) cout << n << "\n";
  else if (sum < x) cout << n - 1 << "\n";

  else {
    sort(all(vec));
    i64 res = 0;
    for (auto e : vec) {
      if (e <= x) {
        ++res;
        x -= e;
      }
      else {
        cout << res << "\n";
        return 0;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>

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

    int i=0;
    int l=0;
    int a[n];
    int sum=0;
    
    while(std::cin >> l){
        a[i] = l;
        i++; 
        if(i>=n){
            break;
        }
    }

    for(int j=0; j<n-1; j++){
        for(int k=j+1; k<n; k++){
            sum += a[j]*a[k]; 
        }
    }
    std::cout << sum <<std::endl;

    return 0;
}

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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
//constexpr int INF = 1001001001;
constexpr ll INF = 1001001001001001001LL;
//constexpr double INF = 1e10;
constexpr double EPS = 1e-10;
using number = long long;


vi G[605];
double E[605];
double F[605];

int main() {
    int n, m; cin >> n >> m;
    int s, t;
    rep(i, m) {
        cin >> s >> t;
        s--, t--;
        G[s].pb(t);
    }
    F[n - 1] = 0;
    for (int i = n - 2; i >= 0; i--) {
        for (auto v : G[i]) {
            F[i] += F[v];
        }
        F[i] /= (double)G[i].size();
        F[i] += (double)1;
    }

    double ans = F[0];
    //cout << ans << endl;

    rep(k, n - 1) {
        if (G[k].size() == 1) continue;
        int hf = k;
        int ht = G[k][0];
        rep(i, G[k].size()) {
            if (F[ht] < F[G[k][i]]) ht = G[k][i];
        }
        //cout << hf << " " << ht << endl;

        memset(E, 0, sizeof(E));
        for (int i = n - 2; i >= 0; i--) {
            if (i == hf) {
                for (auto v : G[i]) {
                    if (v == ht) continue;
                    E[i] += E[v];
                }
                E[i] /= (double)(G[i].size() - 1);
            }
            else {
                for (auto v : G[i]) {
                    E[i] += E[v];
                }
                E[i] /= (double)G[i].size();
            }
            E[i] += (double)1;
        }

        chmin(ans, E[0]);
    }

    cout << ans << endl;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main()
{
     int n;
    cin>>n;
  
      int arr[n];
     for(int i=0;i<n;i++)
          cin>>arr[i];
  
        double sum=0;
      for(int i=0;i<n;i++)
      sum+=double(1.0/arr[i]);
 
     double x=1/sum;
        cout<<x;
}
       

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

namespace CsTest
{
   
    public class Program
    {
        static void Main(string[] args)
        {
            int[] rDx = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int x = rDx[2];
            for(int i = 0; i < 10; ++i)
            {
                x = (rDx[0] * x) - rDx[1];
                Console.WriteLine(x);
            }
        }
    }
}


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define DISP1(as)		for(auto it : as) cout<<it.f<<" "<<it.s<<") ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	2e+5 + 99;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, k, l, q, x;
string s;

ll a[600],c[505];
vpll b;
vll res;

// < ----------- func eh ---------------- ? //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin>>n;
	for(ll i=3;i<=7;i+=2) {
		if(n==i) {
			cout<<"YES\n";
			return;
		}
	}
	cout<<"NO\n";
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 3664
#include <stdio.h>

/*enum MARK {

	S, H, C, D

};*/

int main(void) {
	
	int card[4][13]= {};

	// ??\???????????\???????????°
	int point;
	scanf("%d", &point);
	
	// ????????????????????????????????\??????
	for(int cnt = 0; cnt < point*2; cnt++) {
		
		// enum????????£?¨?
		//enum MARK mark;
		
		char mark;
		
		// ???????????????????????\????????????
		int num;
		
		scanf("%c %d", &mark, &num);
		
		switch(mark) {
			
			case 'S':
			card[0][num-1] = 1;
			break;
			
			case 'H':
			card[1][num-1] = 1;
			break;
			
			case 'C':
			card[2][num-1] = 1;
			break;
			
			case 'D':
			card[3][num-1] = 1;
			break;
		}
	}
	
	// ???????????????????????????????????\????????????
	for(int line = 0; line < 4; line++) {
		
		for(int col = 0; col < 13; col++) {
			
			if(card[line][col] == 0) {
				
				switch(line) {
				
					case 0:
					printf("S %d\n", col+1);
					break;
			
					case 1:
					printf("H %d\n", col+1);
					break;
			
					case 2:
					printf("C %d\n", col+1);
					break;
			
					case 3:
					printf("D %d\n", col+1);
					break;
				
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1828
n,m,l = map(int, input().split())
a = []
b = []
for i in range(n):
    a.append(list(map(int, input().split())))
for j in range(m):
    b.append(list(map(int, input().split())))
for  k in range(n):
    for o in range(l):
        sum = 0
        for p in range(m):
            sum += (a[k][p] * b[p][o])
        print(sum, end = "")
        if o != l-1:
            print(" ", end = "")
    print()


Measured memory_bytes: 6560
#include<stdio.h>

int main(){
	int a,b,c,k,maxv,x=1;
	scanf("%d%d%d%d",&a,&b,&c,&k);
	maxv=a;
	if(b>maxv)maxv=b,x=2;
	if(c>maxv)maxv=c,x=3;
	for(int i=1;i<=k;++i)maxv<<=1;
	if(x==1)maxv+=b+c;
	else if(x==2)maxv+=a+c;
	else maxv+=a+b;
	printf("%d\n",maxv);
}

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  int n, k;
  cin >> n >> k;
  vi a(n);
  rep(i, n) cin >> a[i];
  dump(a);
  rep(j, k) {
    vi b(n);
    vi f(n + 1);
    rep(i, n) {
      f[max(0, i - a[i])]++;
      f[min(n, i + a[i] + 1)]--;
    }
    dump(f);
    rep(i, n) b[i] = i == 0 ? f[i] : b[i - 1] + f[i];
    dump(b);
    if (a == b) break;
    a = b;
  }
  rep(i, n) cout << a[i] << ' ';
  cout << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 5580
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
using namespace std;
using ll=long long;
#define MOD  1000000007

int main(int argc, char const *argv[]) {
  int n;
  std::cin >> n;
  if(n%2==1) {
    n++;
    std::cout << (n/2-1)*n/2 << '\n';
  }

  else std::cout << (n/2)*(n/2) << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <map>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

typedef long long ll;

const int N=2.5e5+5;

int n;
ll h[3],w[3],ha[3],p[N][3],k[N][3],b[N][3];
ll base[3]={7,29,47},inv[3]={142857144,481911067,13933357},P[3]={1000000007,998244353,19260817};
char st[N];

ll pwr(ll x,ll y,ll P) {
	ll z=1;
	for(;y;y>>=1,x=x*x%P)
		if (y&1) z=z*x%P;
	return z;
}

struct Node{
	ll h[3];
	friend bool operator < (Node a,Node b) {
		fo(i,0,2) {
			if (a.h[i]<b.h[i]) return 1;
			if (a.h[i]>b.h[i]) return 0;
		}
		return 0;
	}
}a;

map<Node,int> mp;

int main() {
	scanf("%d",&n);
	scanf("%s",st+1);
	fd(i,n,1) {
		fo(j,0,2) {
			if (st[i]=='+') h[j]=(h[j]+1)%P[j];
			if (st[i]=='-') h[j]=(h[j]+P[j]-1)%P[j];
			if (st[i]=='>') h[j]=h[j]*base[j]%P[j];
			if (st[i]=='<') h[j]=h[j]*inv[j]%P[j];
		}
	}
	fo(j,0,2) w[j]=1;
	fo(i,1,n) {
		fo(j,0,2) {
			p[i][j]=p[i-1][j];
			if (st[i]=='+') p[i][j]=(p[i][j]+w[j])%P[j];
			if (st[i]=='-') p[i][j]=(p[i][j]+P[j]-w[j])%P[j];
			if (st[i]=='>') w[j]=w[j]*base[j]%P[j];
			if (st[i]=='<') w[j]=w[j]*inv[j]%P[j];
		}
	}
	fo(j,0,2) k[0][j]=1;
	fo(i,1,n) {
		fo(j,0,2) {
			b[i][j]=b[i-1][j];k[i][j]=k[i-1][j];
			if (st[i]=='+') b[i][j]=(b[i][j]+P[j]-1)%P[j];
			if (st[i]=='-') b[i][j]=(b[i][j]+1)%P[j];
			if (st[i]=='>') b[i][j]=b[i][j]*inv[j]%P[j],k[i][j]=k[i][j]*base[j]%P[j];
			if (st[i]=='<') b[i][j]=b[i][j]*base[j]%P[j],k[i][j]=k[i][j]*inv[j]%P[j]; 
		}
	}
	ll ans=0;
	fd(i,n,1) {
		fo(j,0,2) a.h[j]=p[i][j];mp[a]++;
		fo(j,0,2) a.h[j]=(h[j]-b[i-1][j]+P[j])*k[i-1][j]%P[j];
		ans+=mp[a];
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 57088
#include <iostream>
#include <vector>
#include <algorithm>
#include <deque>
using namespace std;
using ll = long long;

int main(){
    string base;cin>>base;
    int Q;cin>>Q;
    Q += base.size();
    vector<int> multipl(Q,1);
    vector<pair<int,char>> queries;
    for(int i = 0;i < base.size(); i++){
        queries.push_back(pair<int,char>{2,base[i]});
    }
    for(int i = base.size();i < Q;i++){
        int type;cin>>type;
        if(type == 1){
            queries.push_back(pair<int,char>{0,0});
            multipl[i] = -1;
        }else{
            int b;char c;cin>>b>>c;
            queries.push_back(pair<int,char>{b,c});
        }
    }
    deque<char> deq;
    for(int i = Q-2;i >= 0;i--){
        if(multipl[i] == -1){
            multipl[i] = -1 * multipl[i+1];
        }else{
            multipl[i] = multipl[i+1];
        }
    }
    // for(int i = 0;i < Q;i++){
    //     cout<<multipl[i];
    // }
    for(int i = 0;i < Q;i++){
        if(queries[i].first == 0)continue;
        int place;char c;
        place = queries[i].first;c = queries[i].second;
        if(multipl[i] == -1 && place == 1){
            place = 2;
            // cout<<"?";
        }
        else if(multipl[i] == -1 && place == 2){
            // cout<<"!";
            place = 1;
        }
        if(place == 1){
            deq.push_front(c);
        }
        else {
            deq.push_back(c);
        }

    }
    for(auto itr = deq.begin();itr != deq.end();itr++){
        std::cout<<*itr;
    }
    std::cout<<endl;
}

Measured memory_bytes: 7664
//Author rahuliitkgp

/*A thing of beauty is a joy forever,
Its loveliness increases,
it will never pass into nothingness.*/
//Men at Work :)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;

#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define INF (int)1e9 + (int)1e8
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void cpp() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int main(){
    cpp();
    ll n;
    cin>>n;
    vector<double> v(n);
    for(ll i=0; i<n; i++){
        cin>>v[i];
    }
    vector<vector<double> > dp(n+1, vector<double>(n+1));
    for(ll i=0; i<=n; i++){
        dp[i][0] = 1;
    }
    dp[0][0] = 1;
    for(ll i=1; i<=n; i++){
        for(ll j=1; j<=n; j++){
            dp[i][j] = dp[i-1][j-1]*(v[i-1])+dp[i-1][j]*(1-v[i-1]);
        }
    }
    cout<<ps(dp[n][(n+1)/2],9)<<endl;
    return 0;
}






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


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

Measured memory_bytes: 256
import sys
from functools import reduce
import itertools


input = sys.stdin.readline

N = int(input())
P = tuple(map(int, input().split(" ")))
Q = tuple(map(int, input().split(" ")))

if (P == Q):
    print(0)
else:
    res = list(filter(lambda t: t[1] == P or t[1] == Q, enumerate(itertools.permutations(range(1, N + 1)))))

    print(abs(res[0][0] - res[1][0]))

Measured memory_bytes: 38512
#include <iostream>
#include<iomanip>
#include <cmath>
#include <climits>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <queue>
using namespace std;

vector <int> edges[100000];
vector <int> children[100000];
bool done[100000];
long long dp_include[100000];
long long dp_exclude[100000];

int M = 1000000007;

int main(){
    int N;
    cin >> N;
    int x;
    int y;
    for(int i = 0; i < N - 1; i++){
        cin >> x >> y;
        edges[x-1].push_back(y-1);
        edges[y-1].push_back(x-1);
    }

    for(int i = 0; i < N; i++){
        done[i] = false;
    }
    vector <int> order;
    queue <int>q;
    q.push(0);

    int cur;
    while(!q.empty()){
        //cout << cur << endl;
        cur = q.front();
        q.pop();
        order.push_back(cur);
        done[cur] = true;

        for(int i = 0; i < edges[cur].size(); i++){
            if(!done[edges[cur][i]]){
                q.push(edges[cur][i]);
                children[cur].push_back(edges[cur][i]);
            }
        }
    }
    //cout << "Hi" << endl;

    for(int i = N - 1; i >= 0; i--){
        //is leaf
        int cur_node = order[i];
        if(children[cur_node].size() <= 0){
            dp_include[cur_node] = 1;
            dp_exclude[cur_node] = 1;
            continue;
        }
        dp_include[cur_node] = 1;
        dp_exclude[cur_node] = 1;
        for(int j = 0; j < children[cur_node].size(); j++){
            int cur_child = children[cur_node][j]; 
            dp_include[cur_node] = (dp_include[cur_node] * dp_exclude[cur_child]) % M;
            dp_exclude[order[i]] = (dp_exclude[cur_node] * ((dp_include[cur_child] + dp_exclude[cur_child]) % M)) % M;
        }
    }

    cout << (dp_include[order[0]] + dp_exclude[order[0]]) % M << endl;
    return 0;

}

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

int main() {

    long long int l[87];

    l[0] = 2;
    l[1] = 1;

    int n;

    cin >> n;

    for(int i=2; i<=n; i++){
        l[i] = l[i-1] + l[i-2];
    }

    cout << l[n] << endl;

    return 0;
}

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


int main(){
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  if(a*b>=c*d){cout << a*b << endl;}else{cout << c*d << endl;}
}

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

int main()
{
    int k;
    cin >> k;
    queue<long long> q;
    for (int i = 1; i < 10; i++)
    {
        q.push(i);
    }

    long long ans;
    while (k--)
    {
        ans = q.front();
        q.pop();

        if(ans % 10 != 0)q.push(10 * ans + ans % 10 - 1);
        q.push(10 * ans + ans % 10);
        if(ans % 10 != 9)q.push(10 * ans + ans % 10 + 1);
    }
    cout << ans << endl;
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,k; cin>>n>>k;
  vll a(n);
  rep(i,n) cin>>a[i];
  cout<<(n-1+k-2)/(k-1)<<endl;
}

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

int main(){
    int N; cin>>N;
    vector<int> R(N);
    for(int i=0;i<N;i++) cin>>R[i];
    int ans = -1e9;
    int buy = R[0];
    
    for(int i=1;i<N;i++){
        ans = max(ans,R[i]-buy);
        buy = min(buy,R[i]);
    }

    cout<<ans<<endl;

}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  
  int ans0=1e9;
  ans0=A*X+B*Y;
  int ans1=1e9;
  int ans2=1e9;
  if(X>Y) {
  ans1=A*(X-Y)+C*2*Y;
  }
  else {
  ans2=B*(Y-X)+C*2*X;
  }
  int ans3=1e9;
  ans3=C*max(X, Y)*2;
  int ans;
  ans=min({ans0, ans1, ans2, ans3});
  cout << ans << endl;
}

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

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

    long cnt=0;
    long bcnt=0, cnt1=0, cnt2=0;
    rep(i,s.size()) {
        if (s.at(i)=='B') {
            bcnt++;
            cnt1 += i;
        }
    }
    for (long i=s.size()-bcnt; i<s.size(); ++i) {
        cnt2 += i;
    }

    cout << cnt2 - cnt1 << endl;
    return 0;
}

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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll K, A, B;
  cin >> K >> A >> B;
  ll ans = 0;
  if (A >= B)
    cout << K + 1 << endl;
  else
  {
    ll res = 1;
    ll cnt = K;
    while (cnt > 0)
    {
      if (cnt >= 2 && res >= A)
      {
        res -= A;
        res += B;
        cnt -= 2;
      }
      else
      {
        res++;
        cnt--;
      }
    }
    ans = max(K + 1, res);
    cout << ans << endl;
  }
  return 0;
}

// A < Bのときは貪欲　お金に変えてビスケットに変えるから2回必要


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long N,P;cin>>N>>P;
  long ans=1;
  long d=2,C=P;
  while(d*d<=C){
    long tmp=0;
    while(P%d==0){P/=d;tmp++;}
    for(long i=0;i<tmp/N;i++)ans*=d;
    d++;
  }
  if(N==1)ans*=P;
  cout<<ans;
  assert(ans>=0);
}

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

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1000000000; //
const ll LINF = (ll) 4000000000000000000; //
const ll MOD = (ll) 1000000007; //
const double PI = 3.1415926535898; //
const int limit = 100010;

#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep2(i,n) REP(i,1,n+1)
#define rep3(i,n) REP(i,0,n+1)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define repll(i,n) REPLL(i,0,n)
#define repll2(i,n) REPLL(i,1,n+1)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())

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

int main() {
    int n;
    cin >> n;
    string up, bottom;
    cin >> up >> bottom;

    vector<char> v;
    int i = 0;
    while (i < n) {
        if (up[i] == bottom[i]) {
            v.push_back('|');
            i++;
        } else {
            v.push_back('-');
            i += 2;
        }
    }

    char prev = 'a';
    ll ans = 3;
    for (auto c : v) {
        if (c == '|' && prev == '|') {
            ans *= 2;
            ans %= MOD;
        } else if (c == '-' && prev == '-') {
            ans *= 3;
            ans %= MOD;
        } else if (c == '-') {
            ans *= 2;
            ans %= MOD;
            prev = '-';
        } else {
            prev = '|';
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値
 
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
ll n;
cin>>n;
ll a=0;
ll b=0;
ll c=0;
ll d=0;
string s;
ll ans=0;
rep(i,n){
cin>>s;
ll f=s.size()-1;
rep(k,f){
if(s.at(k)=='A'&&s.at(k+1)=='B'){
ans++;}}
if(s.at(0)=='B'){
b++;}
if(s.at(f)=='A'){
a++;}
if(s.at(0)=='B'&&s.at(f)!='A'){
d++;}
if(s.at(0)!='B'&&s.at(f)=='A'){
c++;}}
//cout << d << endl;
if(c==0&&d==0){
if(a!=0)
ans+=a-1;}
else if(c!=0&&d==0){
ans+=b;}
else if(c==0&&d!=0){
ans+=a;}
else{
ll e = a-c;
if(e>=1){
ans+=e-1;
c++;
d++;}
ans+=min(c,d);}
cout << ans << endl;}


Measured memory_bytes: 3620
from sys import stdin
n,W=map(int,input().split())
INF=1<<60
sum_v=0
vector=[]
for i in range(n):
    w,v=map(int,stdin.readline().split())
    sum_v+=v
    vector.append((w,v))

dp=[INF for i in range(sum_v+1)]
dp[0]=0

for w,v in vector:
    for j in range(sum_v-v,-1,-1):
        dp[v+j]=min(dp[v+j],dp[j]+w)

index=0
for i in range(len(dp)):
    if dp[i]<=W:
        index=max(index,i)
print(index)

Measured memory_bytes: 45232
#include<bits/stdc++.h>
using namespace std;
//#pragma comment(linker, "/STACK:102400000,102400000")
typedef long long ll;
typedef pair<int,int> P;
#define ls(x) (x<<1)
#define rs(x) (x<<1|1)
#define lowbit(x) (x&-x)
const ll INF=0x3f3f3f3f;
const double EPS=1e-7;
const int N=2e5+10;
const ll mod=1e9+7;
inline ll read()
{  ll f=1,x=0;char ch=getchar();
   for(;ch>'9'||ch<'0';ch=getchar())if(ch=='-') f=-1;
   for(;ch<='9'&&ch>='0';ch=getchar()) x=x*10+ch-'0';
   return x*f;
}
ll n,k;
double a[N];
bool check(double mid)
{  ll cnt=0;
   for(ll i=1;i<=n;i++)
   {  if(a[i]<=mid)continue;
      ll q=ceil((a[i]-mid)/mid);
      //printf("q=%d\n",q);
      if(q)cnt=cnt+q;
      if(cnt>1000000000)return 0;
   }
   if(cnt>k)return 0;
   else return 1;
}
int main()
{  //printf("%lf",ceil(0.5/0.2-1.0));
   cin>>n>>k;
   for(int i=1;i<=n;i++)cin>>a[i];
   double l=0.000001,r=1e9+5,ans;
   for(int i=1;i<=200;i++)
   {  double mid=(l+r)/2;
      if(check(mid))
      {  ans=mid;
         r=mid-EPS;
      }
      else
      {  l=mid+EPS;
      }

   }
   printf("%.0lf\n",ceil(r));
}

Measured memory_bytes: 5324
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e2 + 10;
LL dp[N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	string str;
	cin >> str;
	int n = str.length();
	for (int i = n - 1; i >= 0; i--)
	{
		LL sum = 0;
		for (int j = i; j < n; j++)
		{
			sum = sum * 10 + str[j] - '0';
			dp[i] += dp[j + 1] + sum * (1LL << max(0, n - j - 2));
		}
	}
	cout << dp[0] << endl;
	return 0;
}

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

int main(){
    int N, M;
    cin >> N >> M;
    int x[M], y[M];
    for(int i = 0; i < M; ++i){
        cin >> x[i] >> y[i];
    }

    int box[N];
    int prob[N];
    for(int i = 0; i < N; ++i){
        box[i] = 1;
        prob[i] = (i == 0);
    }

    for(int i = 0; i < M; ++i){
        box[x[i]-1]--;
        box[y[i]-1]++;
        if(prob[x[i]-1]){
            prob[y[i]-1] = 1;
        }
        if(box[x[i]-1] == 0){
            prob[x[i]-1] = 0;
        }
    }

    int ans = 0;
    for(int i = 0; i < N; ++i){
        if(prob[i]>=1 && box[i]!=0) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;
using static Prog;
using NX = System.Int64;

public class Solver{

    List<Pair>[] Edge;
    int[] ans;
    public void Solve()
    {
        int N = NextInt();
        Edge = Enumerable.Range(0, N + 1).Select(v => new List<Pair>()).ToArray();
        ans = new int[N - 1];
        int max_node = 0;
        for (int i = 0; i < N - 1; i++)
        {
            int a = NextInt(), b = NextInt();
            Edge[a].Add(new Pair(b, i));
            Edge[b].Add(new Pair(a, i));
            max_node = Math.Max(max_node, Math.Max(Edge[a].Count(), Edge[b].Count()));
        }
        Console.WriteLine(max_node);

        dfs(1, -1, -1);
        ans.ToList().ForEach(v => Console.WriteLine(v));
    }
    void dfs(int s, int x, int n)
    {
        int color = 1;
        foreach (var e in Edge[s])
        {
            //帰らないようにする
            if (e.x != x)
            {
                if (color == n) color++;
                ans[e.y] = color;
                dfs(e.x, s, color++);
            }
        }
    }
}


public class Prog
{
    public struct Pair { public int x, y; public Pair(int a, int b) { x = a; y = b; } }

    static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        new Solver().Solve();
        Console.Out.Flush();
        return;
    }
}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
    public long Abs(long a, long b) => Math.Abs(a - b);
}


Measured memory_bytes: 30892
import java.util.Scanner;

public class Main {
	private static int[] L;
	private static int N, A, B, C;
	private static int INF = 10000000;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		A = sc.nextInt();
		B = sc.nextInt();
		C = sc.nextInt();
		L = new int[N];
		for (int i = 0; i < N; i++) {
			L[i] = sc.nextInt();
		}

		System.out.println(dfs(0, 0, 0, 0));
	}

	private static int dfs(int i, int a, int b, int c) {
		//停止条件
		if (i == N) {
			if(a == 0 || b == 0 || c == 0) return INF;	//いずれも一本は必ず使わなければならない
			return Math.abs(a - A) + Math.abs(b - B) + Math.abs(c - C) - 30;	//合体してできたa, b, cをA, B, Cにするコスト
		}

		//分岐
		//竹を使わないとき
		int res = dfs(i + 1, a, b, c);
		//A, B, Cを使うとき
		res = Math.min(res, dfs(i + 1, a + L[i], b, c) + 10);
		res = Math.min(res, dfs(i + 1, a, b + L[i], c) + 10);
		res = Math.min(res, dfs(i + 1, a, b, c + L[i]) + 10);

		return res;
	}
}

Measured memory_bytes: 22996
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  int a,b;
  cin >> a >> b;

  if(a<=9&&b<=9) cout << a*b << "\n";
  else cout << -1 << "\n";
  return 0;
}


Measured memory_bytes: 256