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

using namespace std;

const int mod = 1e9 + 7;

int main(){
  int N;
  cin >> N;
  
  vector<long long> T(N), A(N);
  
  for(int i = 0; i < N; i++){
    cin >> T[i];
  }
  
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }
  
  vector<long long> l(N, 0), r(N, 0);
  l[0] = T[0], r[N - 1] = A[N - 1];
  
  for(int i = 1; i < N; i++){
    if(T[i - 1] < T[i]) l[i] = T[i];
  }
  
  for(int i = N - 2; i >= 0; i--){
    if(A[i] > A[i + 1]) r[i] = A[i];
  }
  
  long long p = 1;
  for(int i = 0; i < N; i++){
    if(l[i] && l[i] > A[i]) p = 0;
    else if(r[i] && r[i] > T[i]) p = 0;
    else if(!l[i] && !r[i]) p *= min(T[i], A[i]);
    p %= mod;
  }
  
  if(p < 0) p += mod;
  cout << p << endl;
  
  return 0;
}

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

int main() {
    int N, a = 1000000000, b = 0;
    cin >> N;
    for (int i = 0; i < N; ++i) {
        int x;
        cin >> x;
        a = min(a, x);
        b = max(b, x);
    }
    cout << b - a << endl;
}

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

int main()
{
   int a,b,c;
   scanf("%d%d%d",&a,&b,&c);
 cout<<(a-c)/(b+c)<<endl;

    return 0;
}
 //c*(x+1)+b*x


Measured memory_bytes: 256
N = int(input())
Fs = []
for i in range(N):
  F = list(map(int, input().split()))
  Fs.append(F)
Ps = []
for i in range(N):
  P = list(map(int, input().split()))
  Ps.append(P)
rs = []
for i in range(1, 1<<10):
  r = 0
  for j in range(N):
    F = Fs[j]
    P = Ps[j]
    c = 0
    for k in range(10):
      if i&(1<<k) != 0 and F[k] == 1:
        c += 1
    r += P[c]
  rs.append(r)
r = max(rs)
print(r)


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

typedef long long ll;

int main()
{
	ll n,a,b,count,count2;
	cin>>n>>a>>b;
	count = n / (a + b);
	count2 = n % (a + b);
	ll res = count * a;
	if(count2 < a)
		res += count2;
	else 
		res += a;
	cout<<res<<endl;
	return 0;
}

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

int32_t   main(){
     int x=6,k=2,d=4;;
     cin>>x>>k>>d;
    //  int min = 1000000000000000;
    // cin>>x;
    // char sw = (x>0)?'p':'n';
    int fact,rem;
    // while(true){
    //     if(x>0){
    //         x-=d;
    //         // cout<<"d";
    //         if(x<0&&sw=='p'){
    //             // cout<<"1";
    //             if(k%2==0){
    //                 cout<<abs(x);
    //                 return 0;
    //             }else{
    //                 cout<<abs(x+d);
    //                 return 0 ;
    //             }
    //         }
    //         if(x<0){
    //             sw ='n';
    //         }
            
    //     }else{
    //         x+=d;
    //         // cout<<"in";
    //         if(x>0&&sw=='n'){
    //             // cout<<"2";
    //             if(k%2==0){
    //                 cout<<abs(x);
    //                 return 0 ;
    //             }else{
                    
    //                 cout<<abs(x-d);
    //                 return 0 ;
    //             }
    //         }
    //         if(x>0){
    //             sw='p';
    //         }
    //     }
    //     if(x==0){
    //          if(k%2==0){
    //                 cout<<abs(x);
    //                 return 0 ;
    //             }else{
                    
    //                 cout<<abs(x-d);
    //                 return 0 ;
    //             }
    //     }
        


 
    //     fact = abs(x/d);
    //     k-=fact;
    //     x = (x>0)? x- fact*d : x + fact*d ;
    //     if(k>0){

    //     }else{
    //         break;
    //     }
    
                
    // }
    fact = (x/d);
    
    
    if(abs(fact)>k){
       if(x>0){
            cout<<abs(x-k*d);
       }else{
            cout<<abs(x+k*d);
       }

        return 0 ;
    }
    x = x - fact*d;
    fact = abs(fact);
    k-=fact;
    // cout<<" k remain "<<k<<" x is :"<<x;
    if(k%2==0){
        cout<<abs(x);
        return 0 ;
    }else{
        if(x>0){
            cout<<abs(x-d);
        }else{
            cout<<abs(x+d);
        }
    }
    // cout<<"k is :"<<k<<" ";
    // cout<<abs(x);
  
    return 0;

}


// x  = -7   d = 2    k =3 

// fact = x/d = 3 ; 

// k-=fact ;

// x= x- fact*d;

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

signed main(){

  int x, y; cin >> x >> y;
  for(int i = 0; i < 300; i++){
    for(int j = 0; j < 300; j++){
      if(i + j == x && i * 2 + j * 4 == y){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 3628
from itertools import combinations
n = int(input())
l = list(map(int, input().split()))

ans = 0
for i,j,k in combinations(l,3):
  if i == j or i == k or j == k: continue
  if i >= j+k or j >= i+k or k >= i+j: continue
  ans += 1
print(ans)

Measured memory_bytes: 9100
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

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

signed main(void)
{
	int x, y;
	cin >> x >> y;
	int a[] = {1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
	if(a[x-1] == a[y-1]) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BS
import qualified Data.Maybe as MA

main = do
    [n, r] <- fmap (fst . MA.fromJust . BS.readInt) . BS.words <$> BS.getLine :: IO [Int]
    putStrLn . show $ if n >= 10 then r else r + 100 * (10 - n)


Measured memory_bytes: 380
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;
constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

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

    int n;
    cin >> n;
    int a[n]{};
    FOR(i, 1, n) {
        cin >> a[i];
        a[i]--;
    }
    int ans[n]{};
    for(int j = n - 1; j; j--) {
        ans[a[j]]++;
    }

    rep(i, n) cout << ans[i] << endl;

    return 0;
}

Measured memory_bytes: 5216
def main()
  a,b = gets.chomp.split(' ').map(&:to_i)
  ans = 0
  for i in 1..a do
    for j in 1..31 do
      break if (i == a) and (j > b)
      ans = ans + 1 if i == j
    end
  end
  puts ans
end

main()

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
 
int main() {
  string s;
  cin >> s;
  int a, b, c, d;
  a=s[0]-'0';
  b=s[1]-'0';
  c=s[2]-'0';
  d=s[3]-'0';

   if(a+b+c+d==7){
      cout<<a<<'+'<<b<<'+'<<c<<'+'<<d<<'='<<'7'<<endl;
   }
   else if(a+b+c-d==7){
      cout<<a<<'+'<<b<<'+'<<c<<'-'<<d<<'='<<'7'<<endl;
   }
   else if(a+b-c-d==7){
      cout<<a<<'+'<<b<<'-'<<c<<'-'<<d<<'='<<'7'<<endl;
   }
   else if(a+b-c+d==7){
      cout<<a<<'+'<<b<<'-'<<c<<'+'<<d<<'='<<'7'<<endl;
   }
   else if(a-b+c+d==7){
      cout<<a<<'-'<<b<<'+'<<c<<'+'<<d<<'='<<'7'<<endl;
   }
   else if (a-b+c-d==7){
      cout<<a<<'-'<<b<<'+'<<c<<'-'<<d<<'='<<'7'<<endl;
   }
   else if (a-b-c-d==7){
      cout<<a<<'-'<<b<<'-'<<c<<'-'<<d<<'='<<'7'<<endl;
   }
   else if (a-b-c+d==7){
      cout<<a<<'-'<<b<<'-'<<c<<'+'<<d<<'='<<'7'<<endl;
   }
}


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

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

  vector<string> grid(h+2);
  string frame(w+2, '-');
  grid.at(0) = frame;
  grid.at(h+1) = frame;

  for (int i = 1; i < h+1; i++) {
    string x;
    cin >> x;
    string row = "-" + x + "-";
    grid.at(i) = row;
  }
  
  for (int i = 1; i < h+1; i++) {
    for (int j = 1; j < w+1; j++) {
      if (grid.at(i).at(j) == '#') {
        cout << '#';
      } else {
        int cnt = 0;
        for (int y = -1; y <= 1; y++) {
          for (int x = -1; x <= 1; x++) {
            if (grid.at(i + y).at(j + x) == '#') cnt++;
          }
        }
        cout << cnt;
      }
      if (j == w) cout << endl;
    }
  }
}


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

int main() {
  int a, b;
  cin >> a >> b;
  if (a % 2 == 0 || b % 2 == 0){
    cout << "Even" << endl;
  }
  else{
    cout << "Odd" << endl;
  }
}


Measured memory_bytes: 256
X = int(input())
remain = X
if X // 500 != 0:
    a = remain // 500
    remain = X - 500*a
else:
    a = 0
if remain // 5 !=0:
    b = remain // 5
    remain == b + remain % 5
else:
    b = 0
result = 1000*a + 5*b 
print(str(result))

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

int main(){
  string s;
  cin >> s;
  if (s == "SUN") cout << 7 << endl;
  if (s == "MON") cout << 6 << endl;
  if (s == "TUE") cout << 5 << endl;
  if (s == "WED") cout << 4 << endl;
  if (s == "THU") cout << 3 << endl;
  if (s == "FRI") cout << 2 << endl;
  if (s == "SAT") cout << 1 << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());

		long a[];
		a = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = Long.parseLong(sc.next());
			if (a[i] == 0) {
				System.out.println(0);
				return;
			}
		}

		long result = 1;
		long limit = 1000000000000000000L;
		for (int i = 0; i < n; i++) {

			if (result <= limit / a[i]) {
				result = result * a[i];
			} else {
				System.out.println(-1);
				return;
			}
		}

		System.out.println(result);

	}

}

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

int main() {
    int A, B;
    cin >> A >> B;
    int ans = 0;
    for (int i = A; i <= B; i++) {
        string s = to_string(i);
        int n = s.size();
        for (int j = 0; j < (n + 1) / 2; j++) {
            if (s[j] != s[n - 1 - j]) break;
            if (j == (n + 1) / 2 - 1) ans++;
        }
    }
    cout << ans << endl;
}

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

using ll = long long;

int main() {
    int n, m; cin >> n >> m;
    vector<int> p(m);
    for(int i = 0; i < m; ++i) {
        cin >> p[i];
    }
    vector<int> a(n - 1), b(n - 1), c(n - 1);
    for(int i = 0; i < n - 1; ++i) {
        cin >> a[i] >> b[i] >> c[i];
    }

    vector<int> sum(n);
    for(int i = 0; i + 1 < m; ++i) {
        const int l = min(p[i], p[i + 1]), r = max(p[i], p[i + 1]);
        sum[l - 1] += 1, sum[r - 1] -= 1;
    }
    for(int i = 0; i + 1 < n; ++i) {
        sum[i + 1] += sum[i];
    }

    ll ans = 0;
    for(int i = 0; i < n - 1; ++i) {
        ans += min(1LL * a[i] * sum[i], 1LL * b[i] * sum[i] + c[i]);
    }
    cout << ans << endl;
}



Measured memory_bytes: 4648
using System;
using System.Linq;

namespace ABC065
{
    class B
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] A = new int[N + 1];

            for (int i = 1; i <= N; i++)
            {
                A[i] = int.Parse(Console.ReadLine());
            }
            int count = 1;
            int a = 1;
            for (int i = 0; i < N; i++)
            {
                if (A[a] == 2) { Console.WriteLine(count); return; }
                a = A[a];
                count++;

            }
            Console.WriteLine(-1);
        }
    }
}


Measured memory_bytes: 15172
#include <bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) int((x).size())
#define debug(x) cout << #x << ":" << x << ' ';
#define debugg(x) cout << #x << ":" << x << ' ' << "\n";
#define endl '\n'
#define ff first
#define ss second
#define L(X) ((X)<<1)
#define R(X) (((X)<<1)|1)
#define M(X,Y) (((X)+(Y))>>1)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int MAXN = 1e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long int LLINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const double PI = acos(-1);

template<typename T>   T max_self(T& a, T b) { if (a < b) a = b; return a; }
template<typename T>   T min_self(T& a, T b) { if (a > b) a = b; return a; }
template<typename T>   T add(T x, T y) { return ((x % MOD)  + (y % MOD)) % MOD;}
template<typename T>   T mul(T x, T y) { return ((x % MOD) * (long long)(y % MOD)) % MOD;}
template<typename T>   T sub(T x, T y) { return add(x, -y + MOD);}
template<typename T>   T gcd(T a, T b) { return b ? gcd(b, a % b) : a;}
template<typename T>   T lcm(T a, T b) { return a / gcd(a, b) * b;}
template<typename T>   vector<T> read(vector<T>& v, int n) {v.resize(n); for (auto &x : v) cin >> x;}
template<typename T>   void trav(vector<T> &v) {for (int i = 0 ; i < (int)v.size() ; ++i) {cout << v[i]; if (i != (int)v.size() - 1) cout << ' ';}}
int lg2(long long x)   {   return 64 - __builtin_clzll(x) - 1;	}
int lg2(int x)   {   return 32 - __builtin_clzll(x) - 1;	}

struct pair_hash{
	template<class T1, class T2>
	size_t operator() (const pair<T1, T2> &p) const {
		auto h1 = hash<T1>{}(p.first);
		auto h2 = hash<T2>{}(p.second);
		return h1 ^ h2;
	}
};

int fast_mod(int x, int m = MOD) {
	while(x <= m) x -= m;
	if(x < 0) x += m;
	return x;
}

int mod_add(int x, int y) {
	return fast_mod(x + y);
}

ll a, b;


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

	cin >> a >> b;

	cout << lcm(a,b) << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int x,y;
    cin>>x>>y;
    
    if(x==1||y==1)
    {
        cout<<1<<endl;
        return 0;
    }

    
    long long int ans;
    
    ans=((x*y+1)/2);
    
    
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <cstring>
#include <vector>

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t = 1;
    while(t--){
        int n;
        cin >> n;
        vector<double> p(n);
        for(int i=0 ; i<n ; i++) cin >> p[i];

        vector<vector<double>> dp(n,vector<double>(n+1,0.0));
        //dp[i][j] corresponds to probability of getting j heads in first i+1 coins
        dp[0][0] = 1 - p[0];
        dp[0][1] = p[0];
        for(int i=1 ; i<n ; i++){
            for(int j=0 ; j<n+1 ; j++){
                if(j==0){
                    dp[i][j] = dp[i-1][j] * (1.0 - p[i]);
                }
                else
                    dp[i][j] = dp[i-1][j] * (1.0 - p[i]) + dp[i-1][j-1] * p[i];
            }
        }
        double out = 0.0;
        for(int i=n/2+1 ; i<=n ; i++)
            out += dp[n-1][i];
        cout.precision(10);
        cout << out << "\n";
    }
    return 0;
}



Measured memory_bytes: 73776
import java.util.*;
import java.lang.*;

class MathLib{
    public static long divCeil(long a, long b){
        return (a+b-1)/b;
    }

    public static long gcd(long a, long b){
        if(a<b) return gcd(b,a);
        if(b==0) return a;
        if(a%b==0) return b;
        return gcd(b,a%b);
    }
    public static long lcm(long a, long b){
        return (a/gcd(a,b))*b;
    }

    public static LinkedList<Long> divisors(long N){
        LinkedList<Long> ans = new LinkedList<>();
        for(long n = (long)(Math.sqrt(N)+2); n>0; n--){
            if(n*n>N) continue;
            else if(n*n==N) ans.add(n);
            else if(N%n==0){
                ans.addFirst(n);
                ans.addLast(N/n);
            }
        }
        return ans;
    }
}

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int D = sc.nextInt();
        System.out.println(MathLib.divCeil(N, 2*D+1));
    }
}


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

typedef std::vector<int> VceInt;

VceInt input();
int match(VceInt S,VceInt T);
int output(int count);

int main()
{
	VceInt S = input();
	VceInt T = input();
	int count = match(S, T);
	output(count);
	return 0;
}

VceInt input()
{
	int n = 0;
	std::cin >> n;
//	std::cout << n << std::endl;
	VceInt S;
	S.resize(n);
	for(int i = 0; i < n; i++){
		std::cin >> S[i];
	}
	return S;
}

int match(VceInt S, VceInt T)
{
	int count = 0;
	for(int j = 0; j < T.size(); j++){
		for(int i = 0; i < S.size(); i++){
			if( T[j] == S[i] ){
				count++;
				break;
			}
		}
	}
	return count;
}

int output(int count)
{
	std::cout << count << std::endl;
	return 0;
}

Measured memory_bytes: 3224
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include<list>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e9
typedef long long ll;
using namespace std;

int main() {
    int n; cin >> n;
    vector<int> a;
    vector<int> b;
    vector<int> c;
    int x,y,z;
    cin >> x;
    rep(i,x) {
        int num; cin >> num;
        a.push_back(num);
    }
    cin >> y;
    rep(i,y) {
        int num; cin >> num;
        b.push_back(num);
    }
    cin >> z;
    rep(i,z) {
        int num; cin >> num;
        c.push_back(num);
    }

    vector<int> ans;
    rep(i,z) {
        bool flag = true;
        rep(j,x) {
            if(c[i] == a[j]) flag = false;
        }
        if(flag) ans.push_back(c[i]);
    }

    rep(i,y) {
        rep(j,z) {
            if(b[i]==c[j]) ans.push_back(b[i]);
        }
    }
    sort(ALL(ans));
    ans.erase(unique(ALL(ans)),ans.end());

    cout << ans.size() << endl;


    return 0;
}


Measured memory_bytes: 3160
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios :: sync_with_stdio(false);
	cin.tie(0);
	long long n;
	cin >> n;
	long long sum[n+1],j,l,q,i,k,a[n+1];
	long long dp[n+1][n+1]={ };
	a[0] = 0;
	sum[0] = 0;
	for(i=1;i<=n;i++)
	{
		cin >> a[i];
		sum[i]=a[i]+sum[i-1];
	}
	//matrix multiplication idea
	for(l=2;l<=n;l++)
	{
		for(i=1;i<=(n-l+1);i++)
		{
			j=i+l-1;
			dp[i][j] = LONG_LONG_MAX;
			for(k=i;k<j;k++)
			{
				q = dp[i][k]+dp[k+1][j]+sum[j]-sum[i-1];
				if(q<dp[i][j])
				{
					dp[i][j] = q;
				}
				//if(!dp[i][j]) dp[i][j]=dp[i][k]+dp[k+1][j]+sum[j]-sum[i-1];
                //else dp[i][j]=min(dp[i][j],dp[i][k]+dp[k+1][j]+sum[j]-sum[i-1]);
			}
		}
	}
	cout << dp[1][n] <<endl;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
const int kInf = numeric_limits<int>::max();

int main() {
    int n; cin >> n;
    vector<int> h(n, 0), p(n, 0);

    for (int i = 0; i < n; i += 1)
        cin >> h[i] >> p[i];

    vector<int> perm(n, 0);

    for (int i = 0; i < n; i += 1) {
        perm[i] = i;
    }

    sort(perm.begin(), perm.end(), [&] (int a, int b) {
        return h[a] + p[a] < h[b] + p[b];
    });
    
    vector<vector<int>> dp(n + 1, vector<int> (n + 1, kInf));
    
    dp[0][0] = 0;

    for (int i = 0; i < n; i += 1) {
        for (int j = 0; j <= i; j += 1) {
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
            if (h[perm[i]] >= dp[i][j]) {
                dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + p[perm[i]]);
            }
        }
    }

    for (int i = n; i >= 0; i -= 1) {
        if (dp[n][i] < kInf) {
            cout << i << "\n";
            return 0;
        }
    }
}

Measured memory_bytes: 98176
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)

	ans := 0
	for i := 1; i <= N; i += 2 {
		tmp := 0
		for j := 1; j <= i; j++ {
			if i%j == 0 {
				tmp++
			}
		}
		if tmp == 8 {
			ans++
		}
	}
	fmt.Println(ans)
}


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

int main() {
	int a,b,k;
  cin>>a>>b>>k;
  for(int i=0;i<k;i++){
    a-=a%2;
    b+=a/=2;
    swap(a,b);
  }
  if(!(k%2))cout<<a<<" "<<b;
  else cout<<b<<" "<<a;
	return 0;
}

Measured memory_bytes: 256
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use text_io::*;

fn main() {
    const U_INF: usize = 1 << 60;
    const I_INF: isize = 1 << 60;

    let n: usize = read!();

    let mut ps = vec![];

    for _ in 0..n {
        let pi: f64 = read!();
        ps.push(pi);
    }

    let mut dp = vec![vec![0.0; n + 10]; n + 10];
    dp[0][0] = 1.0;
    for i in 1..=n {
        for j in 0..=n {
            let pi = ps[i - 1];
            let pix = 1.0 - pi;
            dp[i][j] += dp[i - 1][j] * pix;
            if j != 0 {
                dp[i][j] += dp[i - 1][j - 1] * pi;
            }
        }
    }

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

    println!("{}", ans);
}


Measured memory_bytes: 73044
/******************************************
* NICK : nikhilsinghh59 *
******************************************/
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"

#define PB push_back
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
const int M = 1e9+7;

int main()
{   
    

    ll t;
    cin >> t;

    double pi = 3.141592653589793238;
    cout << 2*pi*t ;
    
    return 0;
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main(){
    int N,C,K;
    cin >> N >> C >> K;
    vector<int>T(N);
    for(int i = 0; i < N; i++) {
        cin >> T[i];
    }
    sort(T.begin(),T.end());
    int cnt = 0,ans = 0,mi = T[0];
    for(int i = 0; i < N; i++) {
        if(mi+K >= T[i] && cnt+1 <= C) {
            cnt++;
        }
        else {
            ans++;
            cnt = 1;
            mi = T[i];
        }
    }
    ans++;
    cout << ans << endl;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

#define LEN 2000
#define isok(a,b) (a=='?'||b=='?'||a==b)

bool ab[101010];
bool ac[101010];
bool bc[101010];

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string a,b,c; cin>>a>>b>>c;
    int n = a.size();
    int m = b.size();
    int l = c.size();
    rep(i,n)rep(j,m)if(!isok(a[i],b[j])) ab[i-j+5000]=true;
    rep(i,n)rep(j,l)if(!isok(a[i],c[j])) ac[i-j+5000]=true;
    rep(i,m)rep(j,l)if(!isok(b[i],c[j])) bc[i-j+5000]=true;
    int ans=101010;
    FOR(i,-2*LEN,2*LEN)FOR(j,-2*LEN,2*LEN){
        if (!ab[i+5000] && !ac[j+5000] && !bc[j-i+5000]){
            int left = min(0, min(i,j));
            int right = max(n, max(i+m,j+l));
            chmin(ans,right-left);
        }
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 384
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();

		int total = 0;

		for (int i=1; i<=n; i++){
			int sum = 0;;
			sum += i / 10000;
			sum += i % 10000 / 1000;
			sum += i % 1000 / 100;
			sum += i % 100 / 10;
			sum += i % 10;
			if (sum >= a && sum <= b){
				total += i;
			}
		}
		System.out.println(total);
	}
}


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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define ALLTRUE(xs) all_of(ALL(xs),[](bool x){return x;})
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define ANYTRUE(xs) any_of(ALL(xs),[](bool x){return x;})
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define DUMPP(xs) for (auto x:xs) cout<<'('<<x.first<<','<<x.second<<')';cout<<endl
#define FOR(i,a,b) for (ll i=(ll)(a);i<(ll)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

typedef long long ll;
typedef pair<ll, ll> P;

struct edge { int to,cost; };
const int MOD=1e9+7;

int main() {
  // それぞれのポイント
  // ワーシャルフロイトで全ての点から点の最短距離を計算
  // 次に順列でどの順番が一番短いか
  ll N,M,R;cin>>N>>M>>R;
  vector<int> rs(R);
  REP(i,R) cin>>rs[i];

  vector<vector<ll>> d(N,vector<ll>(N,INT_MAX));
  REP(i,N) d[i][i] = 0;
  REP(i,M) {
    int A,B,C;cin>>A>>B>>C;
    A--;B--;
    d[A][B]=d[B][A]=C;
  }
  REP(k,N)REP(i,N)REP(j,N) {
    d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
  }

  sort(ALL(rs));
  ll ans = LLONG_MAX;
  do {
    ll tmp = 0;
    FOR(i,1,R) {
      tmp += d[rs[i]-1][rs[i-1]-1];
    }
    ans = min(ans,tmp);
  } while (next_permutation(ALL(rs)));

  OUT(ans);

  return 0;
}

Measured memory_bytes: 512
#include<stdio.h>

int main(){
   int a[10000];
   int n,m;
   int x = 0;
   scanf("%d %d", &n, &m);

   for(int i = 0; i < m; i++){
      scanf("%d", &a[i]);
   }

   for(int i = 0; i < m; i++){
      x += a[i];
   }
   if(x > n){
      printf("-1\n");
   }else{
      printf("%d\n", n-x);
   }
   return 0;
}


Measured memory_bytes: 1744
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define repr(i, a, b) for(int i = b-1; i >= a; i--)
// #define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

////////////////////////////////////////////////////////

int main() {
    ll n; cin >> n;
    Vl a(n);
    rep(i, 0, n) cin >> a[i];

    if(n%2 == 0){
        sort(ALL(a));
        Vl u, d;
        rep(i, 0, n/2) d.push_back(a[i]);
        rep(i, n/2, n) u.push_back(a[i]);
        Vl v;
        rep(i, 0, n/2){
            v.push_back(u[i]);
            v.push_back(d[i]);
        }
        ll ans = 0;
        rep(i, 0, sz(v)-1){
            ans += abs(v[i]-v[i+1]);
        }
        co(ans);
    }else{
        ll ans1 = 0, ans2 = 0;
        sort(ALL(a));
        Vl d, u;
        d.push_back(a[n/2]);
        rep(i, 0, n/2) d.push_back(a[i]);
        rep(i, n/2 + 1, n) u.push_back(a[i]);
        Vl v;
        rep(i, 0, n/2){
            v.push_back(d[i]);
            v.push_back(u[i]);
        }
        v.push_back(d[n/2]);
        rep(i, 0, sz(v)-1){
            ans1 += abs(v[i] - v[i+1]);
        }

        //
        // rep(i, 0, sz(d)) cout << d[i] << " ";
        // coel;
        // rep(i, 0, sz(u)) cout << u[i] << " ";
        // coel;
        // rep(i, 0, sz(v)) cout << v[i] << " ";
        // coel;
        //


        d = {}, u = {};
        rep(i, 0, n/2) d.push_back(a[i]);
        rep(i, n/2+1, n) u.push_back(a[i]);
        u.push_back(a[n/2]);
        v = {};
        rep(i, 0, n/2){
            v.push_back(u[i]);
            v.push_back(d[i]);
        }
        v.push_back(u[n/2]);
        rep(i, 0, sz(v)-1){
            ans2 += abs(v[i] - v[i+1]);
        }

        //
        // rep(i, 0, sz(v)) cout << v[i] << " ";
        // coel;
        //

        co(max(ans1, ans2));
    }

    return 0;
}
 
 


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

int main(void) {
	int N, K;
	vector<int> D(10);
	cin >> N >> K;
	for (int i = 0; i < K; i++) {
		int a; cin >> a;
		D[a]++;
	}

	int ans = N;
	while (true) {
		int s = 1;
		int ss = ans;
		while (ss) {
			if (D[ss % 10] == 1) {
				s = 0;
				break;
			}
			ss /= 10;
		}

		if (s == 1) {
			cout << ans << endl;
			break;
		}
		ans++;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef long double ld;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

// 最大公約数 O(log(n))
// gcd(12,0)=gcd(0,12)=12
ll gcd(ll a, ll b)
{
    if(b==0) swap(a,b);
    if(a%b == 0){
        return(b);
    }
    else{
        return(gcd(b, a%b));
    }
}

// 最小公倍数
ll lcm(ll a, ll b)
{
    return a  / gcd(a, b) * b;
}

int main(void)
{
    ll K, i, j, k, ans=0, a;

    cin >> K;

    for(i=1; i<=K; i++){
        for(j=1; j<=K; j++){
            for(k=1; k<=K; k++){
                a = gcd(i,j);
                ans += gcd(a,k);
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = (ll)a;i < (ll)b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = (ll)b-1LL;i >= (ll)a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

const ll INF=(1LL<<50);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif
template<class T>
bool chmax(T& a,const T& b){
  if(a<b){
    a=b;
    return true;
  }
  return false;
}
template<class T>
bool chmin(T& a,const T& b){
  if(a>b){
    a=b;
    return true;
  }
  return false;
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long N, long long K, long long C, std::string S){
  vector<ll> L(N),R(N);
  {ll prev=-INF,cnt=0;
  REP(N){
    if(S[i]=='o'&&prev+C<i){
      ++cnt;
      prev=i;
    }
    L[i]=cnt;
  }
  prev=INF;cnt=0;
  For(j,N){
    ll i=N-1-j;
    if(S[i]=='o'&&prev-C>i){
      ++cnt;
      prev=i;
    }
    dump(prev);
    R[i]=cnt;
  }}
  if(C==0){
    REP(N){
      ll tmp=0;
      if(i>0){
        tmp+=L[i-1];
      }
      if(i<N-1){
        tmp+=R[i+1];
      }
      if(tmp<K){
        cout<<i+1<<endl;
      }
    }
    return;
  }
  dump(L);
  dump(R);
  auto calc=[&](ll l){
    if(l<0)return R[l+C+1];
    if(l+C+1>=N)return L[l];
    return L[l]+R[l+C+1];
  };
  map<ll,ll> s;
  auto add_s=[&s](ll x){
    if(s.count(x)){
      ++s[x];
    }else{
      s[x]=1;
    }
  };
  auto sub_s=[&s](ll x){
    --s[x];
    if(s[x]<=0){
      s.erase(x);
    }
  };
  for (ll i = -C; i < 0; i++)
  {
    add_s(calc(i));
  }
  REP(N){
    ll x=prev(s.end())->first;
    if(x<K){
      cout<<i+1<<endl;
    }
    sub_s(calc(i-C));
    add_s(calc(i));
  }
}

int main(){
  cout<<setprecision(1000);
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    long long C;
    scanf("%lld",&C);
    std::string S;
    std::cin >> S;
    solve(N, K, C, S);
    return 0;
}


Measured memory_bytes: 5124
#include<stdio.h>
int main(){
  int N,n = 0,c = 1;
  scanf("%d",&N);
  while(N >= c * 10){
    c *= 10;
  }
  int N_ = N;
  for(int i = c;i >= 1;i /= 10){
    n += (N / i);
    N %= i;
  }
  if(N_ % n == 0){
    printf("Yes");
  }else{
    printf("No");
  }
  return 0;
}

Measured memory_bytes: 128
from numpy import*;N,K=map(int,input().split());m,L,o=zeros((3*K,3*K)),2*K,0
for _ in[0]*N:x,y,c=input().split();t=c=='W';m[int(x)%L,int(y)%L]+=2*t-1;o+=t
for _ in[0,0]:m[L:]=m[:K];m=cumsum(m,0);m[:L]-=m[K:];m=m.T
m=m[:L,:L];print(o-int((m+roll(roll(m,K,0),K,1)).min()))

Measured memory_bytes: 153076
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define Ans(f, y, n) if(f) cout << y << endl; else cout << n << endl;
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i, v.size()){ cout << v[i] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

template<typename T> void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }

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

int mod = 1000000007;
//int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod
#define AddMult(x, y, z) x = (x + (y) * (z)) % mod

class UnionFind
{
public:
    vector<int> par;
    vector<int> sz;

    UnionFind(int N){
        par = vector<int>(N);
        REP(i, N) par[i] = i;
        sz = vector<int>(N, 1);
    }

    int find(int x){
        if(par[x] == x) return x;
        else return par[x] = find(par[x]);
    }

    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return;

        if(sz[x] < sz[y]) swap(x, y);

        par[y] = x;
        sz[x] += sz[y];
    }

    bool is_union(int x, int y){
        x = find(x);
        y = find(y);
        return x == y;
    }

    int union_size(int x){
        return sz[find(x)];
    }

};


signed main(){

    int N, M; cin >> N >> M;
    UnionFind UF(N);
    int a, b;
    REP(i, M){
        cin >> a >> b;
        UF.unite(a - 1, b - 1);
    }
    int sz1 = UF.union_size(0), sz2 = UF.union_size(1);
    int r = N - sz1 - sz2;
    if(sz1 < sz2) swap(sz1, sz2);
    sz1 += r;
    int ans = sz1 * (sz1 - 1) / 2 + sz2 * (sz2 - 1) / 2 - M;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
// Ivan Carvalho
// Problem E - Educational Dynamic Programming Contest - AtCoder
// Link : https://atcoder.jp/contests/dp
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const int MAXV = 1e5 + 10;
const int MAXN = 1e3 + 10;
const ll INF = 1e13;

ll dp[MAXV];
int N,W,V,wi[MAXN],vi[MAXN];

int main(){

	cin >> N >> W;
	for(int i = 1;i<=N;i++){
		cin >> wi[i] >> vi[i];
		V += vi[i];
	}

	for(int i = 1;i<=V;i++) dp[i] = INF;
	dp[0] = 0;
	
	for(int item = 1;item<=N;item++){
		int w = wi[item], v = vi[item];
		for(int i = V;i>=v;i--){
			dp[i] = min(dp[i],dp[i - v] + w);
		}
	}

	for(int i = V;i>=0;i--){
		if(dp[i] <= W){
			cout << i << endl;
			break;
		}
	}

	return 0;

}

Measured memory_bytes: 4404
s = str(input())

for i in range(8):
    x = s[0]
    for j in range(3):
        if i>>j & 1:
            x += '+'
            x += s[j+1]
        else:
            x += '-'
            x += s[j+1]
    ans = eval(x)
    if  ans == 7:
      print(x+'=7')
      exit()


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

using ll = long long;
using ld  = long double;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=9223372036854775807;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-10; //微調整用（EPSより小さいと0と判定など）

int ii() { int x; if (scanf("%d", &x)==1) return x; else return 0; }
long long il() { long long x; if (scanf("%lld", &x)==1) return x; else return 0; }
string is() { string x; cin >> x; return x; }
char ic() { char x; cin >> x; return x; }
void oi(int x) { printf("%d ", x); }
void ol(long long x) { printf("%lld ", x); }
void od_nosp(double x) { printf("%.15f", x); } // 古い問題用
void od(double x) { printf("%.15f ", x); }
// long doubleで受け取り、fをLfなどに変えて出力すると、変な数値が出る
// それをなんとかするには独自の出力を作らなければならなそう
void os(const string &s) { printf("%s ", s.c_str()); }
void oc(const char &c) { printf("%c ", c); }
#define o_map(v){cerr << #v << endl; for(const auto& xxx: v){cout << xxx.first << " " << xxx.second << "\n";}} //動作未確認
void br() { putchar('\n'); }

// #define gcd __gcd //llは受け取らない C++17~のgcdと違うので注意
// int lcm(int a, int b){return a / gcd(a, b) * b;}
#define begin_end(a) a.begin(),a.end() //sort(begin_end(vec));
#define REP(i,m,n) for(ll i=(ll)(m) ; i < (ll)(n) ; i++ )
#define DREP(i,m,n) for(ll i=(ll)(m) ; i > (ll)(n) ; i-- )
#define rep(i,n) REP(i,0,n)
#define m_p(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define p_b push_back
#define SZ(x) ((ll)(x).size()) //size()がunsignedなのでエラー避けに
#define endk '\n'


// coutによるpairの出力（空白区切り）
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << " " << p.second << ")";}
// coutによるvectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " "; //"\t"に変えるとTabで見やすく区切る
  }
  return s;
}
// coutによる多次元vectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}

//最大値、最小値の更新。更新したor等しければtrueを返す
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

//4近傍（上下左右） rep(i, 2) にすると右・下だけに進む
vector<int> dx_4 = {1, 0, -1, 0};
vector<int> dy_4 = {0, 1, 0, -1};

// -------- template end - //


// - library ------------- //



// --------- library end - //


int main(){

  ll N = il();
  ll k = 0;
  REP(i, 2, 1000){
    if ((i-1)*i % 2 == 0){
      if ((i-1) * i / 2 == N) {
        k = i;
        break;
      }
    }
  }

  if (k == 0){
    cout << "No" << endk;
    return 0;
  }

  // k 行 k-1 列
  vector<vector<ll> > ans(k, vector<ll>(k-1, 0));

  ll num = 1;
  rep(h, k-1){
    REP(w, h, k-1){
      ans[h][w] = num;
      ans[w+1][h] = num;
      num++;
    }
  }

  cout << "Yes" << endk;
  cout << k << endk;
  rep(i, k){
    cout << k-1 << " ";
    cout << ans[i] << endk;
  }



}

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

int main() {
    int H1,M1,H2,M2,K;

    cin >> H1 >> M1 >> H2 >> M2 >> K;

    cout << H2 * 60 + M2 - (H1 * 60 + M1) - K << endl ;


}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
using namespace std;
int main(){
    int k,x;
    cin >> k >>x;
    for(int i=k-1;i>0;i--){
        cout<<x-i<<" ";
    }
    cout<<x<<" ";
    for(int i=1;i<k;i++){
        if(i==k-1){
            cout<<x+i<<endl;
        }else{
        cout<<x+i<<" ";
        }
    }
    
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl;
#define printD(a) cout << setprecision(10) << ans << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<int>& a,int n);

int n;

signed main(){
    n = 3;
    vec(a,n);
    REP(i,n){
        cin >> a[i];
    }
    Sort(a);
    cout << a[0] << " " << a[1] << " " << a[2] << endl;
    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<int>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}



Measured memory_bytes: 3164
#include<iostream>
#include<stdio.h>

using namespace std;

int main()
{
	int a,b,c;

	cin >> a >> b >> c;

	if(a > b){
		int tmp;
		tmp = a;
		a = b;
		b = tmp;
	}

	if(a > c){
		int tmp1;
		tmp1 = a;
		a = c;
		c = tmp1;
	}

	if(b > c){
		int tmp2;
		tmp2 = b;
		b = c;
		c = tmp2;
	}

	cout << a << ' ' << b << ' ' <<  c << endl;
	return 0;
}

Measured memory_bytes: 1160
#n, m, q = map(int, input().split())
#List = list(map(int, input().split()))
#req = [list(map(int, input().split())) for _ in range(q)]
#t = t[:-1]
#print(ans[j], end = "") 改行無しで出力
#ans = [0]*n
n = int(input())
sum = 0

for i in range(1, n+1):
    if i % 3 != 0 and i % 5 != 0:
        sum += i

print(sum)


Measured memory_bytes: 9152
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define int long long
#ifndef FAST_IO
  #define IOS ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
#endif
#define ff first
#define ss second
#define endl "\n"
#define all(c) c.begin(),c.end()
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" "; cout<<endl;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int MAXN=1e5+11;
int pref[MAXN];
void solve(){
	 vector<int> v(3);
	 for(auto &it:v)cin>>it;
	 //print(v);
	 int ans=v[0]*v[1];
	 ans/=2;
	 cout<<ans<<endl;
}
int32_t main(){
   IOS;
   solve();
   //debug();
  #ifdef LOCAL_DEFINE
   cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
  #endif	
}


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

#define rep(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define re(i,a,b) for( (i)=(a);(i)<(b);(i)++)


using namespace std;

int nd[101]={0};
int md[101]={0};
int main() {
	int n,m;
	int sum;
	cin>>n>>m;
	while(n>0){
		sum=0;
	rep(i,0,n){cin>>nd[i];sum+=nd[i];}
	rep(i,0,m){cin>>md[i];sum-=md[i];}
	int x,y;
	int mx=101,my=101;
	for(x=0;x<n;x++)for(y=0;y<m;y++)if((nd[x]-md[y])*2==sum)if(nd[x]+md[y]<mx+my)mx=nd[x],my=md[y];

	if(mx==101)
		cout<<-1<<endl;
	else
		printf("%d %d\n",mx,my);

	cin>>n>>m;
	}
}

Measured memory_bytes: 1192
N, M = map(int, input().split())
mod = int(1e+9 + 7)

kai = [1 for _ in range(N+M+1)]
for i in range(2,N+M+1):
    kai[i] = (kai[i-1]*i)%mod
#%%
ap = 0
for i in range(N+1):
    sp = (kai[M]*pow(kai[M-i], mod-2, mod))%mod
    restp = (kai[M-i]*pow(kai[M-N], mod-2, mod))%mod
    chose = ((kai[N]*pow(kai[N-i], mod-2, mod))%mod*pow(kai[i], mod-2,mod))%mod
    sign = (-1)**i
    ap = (ap + (sign*sp)%mod*(chose*restp**2)%mod)%mod
print(ap%mod)

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

bool str_match(std::string str,std::string tar);

int main(void){
  std::string str,target;
  std::cin>>str>>target;
  if(str_match(str,target)) std::cout<<"Yes"<<std::endl;
  else std::cout<<"No"<<std::endl;

  return 0;
}

bool str_match(std::string str,std::string tar){
  int size=str.size();
  for(int i=0;i<size;i++){
    int target_index=0;
    while(str[(i+target_index)%size]==tar[target_index]) target_index++;
    if(target_index==tar.size()) return true;
  }
  return false;
}



Measured memory_bytes: 3212
#include <iostream>
#include <cstdlib>

using namespace std;

int main()
{
	int a, b, c, d;

	cin >> a >> b >> c >> d;

	if(abs(a-c) <= d)
	{
		cout << "Yes" << endl;
		return 0;

	}else if(abs(a-b) <= d && abs(b-c) <= d)
	{
		if((a <= b && b <= c) || (a > b && b >= c))
		{
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;

	return 0;
}

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

int main() {
	
	int n,m;
	
	cin >> n >> m;
	
	vector<int> v(n,0);
	
	for(int i = 0;i < m;i++){
		int a,b;
		
		cin >> a >> b;
		
		v[a-1]++;
		v[b-1]++;
		
	}
	
	for(auto &x:v){
		
		cout << x << endl;
		
	}
	
	return 0;
}

Measured memory_bytes: 256
N, Q = map(int, input().split())
S = input()

sum_table = [0] * (N+1)

for i in range(N):
    sum_table[i+1] = sum_table[i] + (1 if S[i:i+2] == "AC" else 0)

ans_table = []
for i in range(Q):
    left, right = map(int, input().split())
    ans_table.append(sum_table[right-1] - sum_table[left-1])

for i in range(len(ans_table)):
    print(ans_table[i])


Measured memory_bytes: 11876
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;


int main() {
    int a;
    string s;
    cin >> a >>s;
    if(a <3200)  {
      cout<<"red";
    } 
    else {
      cout<<s;
    }
    return 0;
}


Measured memory_bytes: 256