akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
    double w,h,x,y;
    cin>>w>>h>>x>>y;
    cout<<fixed<<setprecision(15)<<(w*h)/2<<" ";
    if(abs(w*.5-x)<0.1 && abs(h*.5-y)<0.1)
        cout<<1<<endl;
    else
        cout<<0<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main (void){

	int i, j ,t ,n ,x=0 ,minj;
	int a[100]; 
	scanf("%d" ,&n);
for(i = 0; i < n; i++){
	scanf("%d" , &a[i]);
}

for(i = 0;i < n-1; i++){
	minj = i;
	for(j = i;j < n;j++){
	if(a[j] < a[minj])
	minj = j;
}
	t = a[i]; a[i] = a[minj]; a[minj] = t;
	if(i != minj)x++;
	}
for(i = 0; i < n; i++){
	if(i > 0)
	printf(" ");
	printf("%d", a[i]);
}
	printf("\n");
	printf("%d\n" ,x);
return 0;

}

Measured memory_bytes: 604
#line 1 "main.cpp"

/**
 * @title Template
 */

#include <iostream>
#include <algorithm>
#include <utility>
#include <numeric>
#include <vector>
#include <array>
#include <cassert>

#line 2 "/Users/kodamankod/Desktop/cpp_programming/Library/other/chmin_chmax.cpp"

template <class T, class U>
constexpr bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) { lhs = rhs; return true; }
  return false;
}

template <class T, class U>
constexpr bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) { lhs = rhs; return true; }
  return false;
}

/**
 * @title Chmin/Chmax
 */
#line 2 "/Users/kodamankod/Desktop/cpp_programming/Library/other/range.cpp"

#line 4 "/Users/kodamankod/Desktop/cpp_programming/Library/other/range.cpp"

class range {
public:
  class iterator {
  private:
    int64_t M_position;

  public:
    constexpr iterator(int64_t position) noexcept: M_position(position) { }
    constexpr void operator ++ () noexcept { ++M_position; }
    constexpr bool operator != (iterator other) const noexcept { return M_position != other.M_position; }
    constexpr int64_t operator * () const noexcept { return M_position; }
  };

  class reverse_iterator {
  private:
    int64_t M_position;
  
  public:
    constexpr reverse_iterator(int64_t position) noexcept: M_position(position) { }
    constexpr void operator ++ () noexcept { --M_position; }
    constexpr bool operator != (reverse_iterator other) const noexcept { return M_position != other.M_position; }
    constexpr int64_t operator * () const noexcept { return M_position; }
  };
  
private:
  const iterator M_first, M_last;

public:
  constexpr range(int64_t first, int64_t last) noexcept: M_first(first), M_last(std::max(first, last)) { }
  constexpr iterator begin() const noexcept { return M_first; }
  constexpr iterator end() const noexcept { return M_last; }
  constexpr reverse_iterator rbegin() const noexcept { return reverse_iterator(*M_last - 1); } 
  constexpr reverse_iterator rend() const noexcept { return reverse_iterator(*M_first - 1); } 
};

/**
 * @title Range
 */
#line 2 "/Users/kodamankod/Desktop/cpp_programming/Library/other/rev.cpp"

#include <type_traits>
#include <iterator>
#line 6 "/Users/kodamankod/Desktop/cpp_programming/Library/other/rev.cpp"

template <class T>
class rev_impl {
public:
  using iterator = decltype(std::rbegin(std::declval<T>()));

private:
  const iterator M_begin;
  const iterator M_end;

public:
  constexpr rev_impl(T &&cont) noexcept: M_begin(std::rbegin(cont)), M_end(std::rend(cont)) { }
  constexpr iterator begin() const noexcept { return M_begin; }
  constexpr iterator end() const noexcept { return M_end; }
};

template <class T>
constexpr decltype(auto) rev(T &&cont) {
  return rev_impl<T>(std::forward<T>(cont));
}

/**
 * @title Reverser
 */
#line 17 "main.cpp"

using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;

constexpr i32 inf32 = (i32(1) << 30) - 1;
constexpr i64 inf64 = (i64(1) << 62) - 1;

int main() {
  i32 x, y;
  std::cin >> x >> y;
  std::cout << (y % 2 == 0 && 2 * x <= y && y <= 4 * x ? "Yes" : "No") << '\n';
  return 0;
}


Measured memory_bytes: 3540
#include<iostream>
using namespace std;
int main(){
	int a, b;
	char op ;
	while (1){
	cin >> a>>op>>b ;
		switch (op){
		case '+':cout << a + b<<endl;
			break;
		case '-':cout << a - b<<endl;
			break;
		case '*':cout << a*b<<endl;
			break;
		case '/':cout << a / b<<endl;
			break;
		case '?':return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
int main()
{
   vector<int> ans;
   while(1)
   {
       int n, x;
       cin >> n >> x;
       if(n == 0 && x == 0)
       {
           break;
       }
       int count = 0;
       for (int i = 1; i <= n; i++)
       {
           for (int j = i+1; j <= n; j++)
           {
               for (int k = j+1; k <= n; k++)
               {
                   if(i + j + k == x)
                   {
                       count++;
                   }
               }
               
           }
       }
        ans.push_back(count);
   }
   for (int i:ans)
   {
       cout << i << endl;
   }
   
}


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

const int N = 100005, MOD = 1E9 + 7, MX = 13;

int n, dp[N][MX];
char s[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> (s + 1);
    n = strlen(s + 1);
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < MX; j++) {
            if (s[i] >= '0' && s[i] <= '9') {
                (dp[i][(j * 10 + s[i] - '0') % MX] += dp[i - 1][j]) %= MOD;
            } else {
                for (int k = 0; k < 10; k++) {
                    (dp[i][(j * 10 + k) % MX] += dp[i - 1][j]) %= MOD;
                }
            }
        }
    }
    cout << dp[n][5];
}


Measured memory_bytes: 5504
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;

#define ll long long
#define pb push_back

int main(){

	int N, M;
	cin >> N >> M;
	for(int i = M / N; i >= 1; i --){
		if(M % i == 0){
			cout << i << endl;
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 256
var x={};
  x["1to2"]=300;
  x["1to3"]=500;
  x["1to4"]=600;
  x["1to5"]=700;
  x["1to6"]=1350;
  x["1to7"]=1650;
  x["2to1"]=6;
  x["2to3"]=350;
  x["2to4"]=450;
  x["2to5"]=600;
  x["2to6"]=1150;  
  x["2to7"]=1500;
  x["3to1"]=13;
  x["3to2"]=7;
  x["3to4"]=250;
  x["3to5"]=400;
  x["3to6"]=1000;
  x["3to7"]=1350;
  x["4to1"]=18;
  x["4to2"]=12;
  x["4to3"]=5;
  x["4to5"]=250;
  x["4to6"]=850;
  x["4to7"]=1300;
  x["5to1"]=23;
  x["5to2"]=17;
  x["5to3"]=10;
  x["5to4"]=5;
  x["5to6"]=600;
  x["5to7"]=1150;
  x["6to1"]=43;
  x["6to2"]=37;
  x["6to3"]=30;
  x["6to4"]=25;
  x["6to5"]=20;
  x["6to7"]=500;
  x["7to1"]=58;
  x["7to2"]=52;
  x["7to3"]=45;
  x["7to4"]=40;
  x["7to5"]=35;
  x["7to6"]=15;
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.replace(/\n$/,"")).split("\n");
while(true){
   var s=Arr.shift()-0;
   if(s==0)break;
   var hm1=(Arr.shift()).split(" ").map(Number);
   var g=Arr.shift()-0;
   var hm2=(Arr.shift()).split(" ").map(Number);
   var S=(parseInt(hm1[0],10)*60)+parseInt(hm1[1],10);
   var G=(parseInt(hm2[0],10)*60)+parseInt(hm2[1],10);
   var cnt=0;
   if((S<=1050 && G<=1170) || (S>=1050 && G>=1170) || (S>=1050 && G<=1170))cnt++;
   if(x[g+"to"+s]<=40)cnt++;
   var money=x[s+"to"+g];
   if(cnt==2){
      money=Math.floor(money/2);
      while(money%50!=0)money++;
   }
   console.log(money);
}

Measured memory_bytes: 7904
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
ll mod=1000000007;
string s;

int main() {
  int n,m;cin >> n >>m;
  vector<int> v1;
  vector<int> vn;
  for(int i=0;i<m;++i){
    int a,b;cin >>a>>b;
    if(a==1)v1.push_back(b);
    if(b==n)vn.push_back(a);
  }
  sort(v1.begin(),v1.end());
  sort(vn.begin(),vn.end());
  //bool isfound=false;
  vector<int> result;
  set_intersection(v1.begin(), v1.end(),
    vn.begin(), vn.end(),
    inserter(result, result.end()));
  /*for(int j=0;j<v1.size();++j){
    if(find(all(vn),v1[j]) != vn.end()) {
      isfound=true;
      break;
    }
  }*/
  if(result.size()>0){
    cout << "POSSIBLE" << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
  return 0;
}


Measured memory_bytes: 1276
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
long long INF = (1LL<<62);

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	long long A, B, C, K;
	cin >> A >> B >> C >> K;
	long long ans = 0;
	if((K % 2) == 1){
		ans = B - A;
	}
	else{
		ans = A -B;
	}
	printf("%lld\n", ans);
	return 0;
}



Measured memory_bytes: 3744
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;
const long long int MOD=1e9+7;

int main(){
  long long n, k;
  vector<long long> a, f;
  cin >> n >> k;
  for(long long i=0;i<n;i++){
    long long tmpa; cin >> tmpa;
    a.push_back(tmpa);
  }
  for(long long i=0;i<n;i++){
    long long tmpf; cin >> tmpf;
    f.push_back(tmpf);
  }
  sort(a.begin(), a.end());
  sort(f.begin(), f.end(), greater<int>());
  long long lb = 0, ub = 2e15;
  long long md;
  while(ub-lb>1){
    md = (lb+ub)/2;
    long long sm = 0;
    for(int i =0;i<n;i++){
      sm+=a[i] - min(a[i], md/f[i]);
    }
    if(sm>k)lb=md;
    else ub=md;
  }
  cout << (lb==0?0:lb+1) << endl;
}


Measured memory_bytes: 4976
#if 0
2019.12.15

题解先咕着。
#endif
#include <cstdio>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long ll;
typedef unsigned long long ull;

struct {
	inline operator int () { int x; return scanf("%d", &x), x; }
	inline operator ll () { ll x; return scanf("%lld", &x), x; }
	template<class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read;

int main() {
	ll l = read, r = read;

	if(l == r) return puts("1"), 0;

	int k = 63 - __builtin_clzll(ull(l ^ r));

	/* debug("%d\n", k); */

	l &= (2ll << k) - 1;
	r &= (2ll << k) - 1;

	/* debug("%lld %lld\n", l, r); */

	int d = r == (1ll << k) ? 0 : 64 - __builtin_clzll(ull(r ^ (1ll << k)));

	/* debug("%d\n", d); */

	ll l1 = l, r1 = (1ll << k) + (1ll << d) - 1;
	ll l2 = (1ll << k) + l, r2 = (1ll << k << 1) - 1;

	/* debug("%lld %lld %lld %lld\n", l1, r1, l2, r2); */

	if(l2 <= r1) printf("%lld\n", r2 - l1 + 1);
	else printf("%lld\n", r2 - l2 + r1 - l1 + 2);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    int v[n][3];
    for(int i = 0; i < n; i++) {
        cin >> v[i][0] >> v[i][1] >> v[i][2];
    }
    for(int i = 1; i < n; i++) {
        v[i][0] += max(v[i-1][1], v[i-1][2]);
        v[i][1] += max(v[i-1][0], v[i-1][2]);
        v[i][2] += max(v[i-1][1], v[i-1][0]);
    }
    cout << max(v[n-1][0], max(v[n-1][1], v[n-1][2]));
}


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

namespace Structured_Program_II
{
    class Spreadsheet
    {
        static void Main(string[] args)
        {
            var size = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

            var sheet = new int[size[0]][];
            var newsheet = new int[size[0]+1][];
            for (int i = 0; i < sheet.Length; i++)
            {
                sheet[i] = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
                newsheet[i] = sheet[i].Concat(new int[] { sheet[i].Sum() }).ToArray();
            }

            newsheet[size[0]] = new int[size[1] + 1];

            for (int col = 0; col < size[1]+1; col++)
            {
                var sum = 0;
                for(int row =0; row < size[0]; row++)
                    sum += newsheet[row][col];
                newsheet[size[0]][col] = sum;
            }

            for (int i = 0; i < newsheet.Length; i++)
            {
                for (int j = 0; j < newsheet[i].Length; j++)
                {
                    Console.Write(newsheet[i][j]);
                    if (j != newsheet[i].Length - 1) Console.Write(" ");
                    else Console.WriteLine();
                }
            }
        }
    }
}

Measured memory_bytes: 9796
B = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
N, M = map(int, input().split())
A = list(map(int, input().split()))
dic = {i: B[i] for i in A}
dp = [0] * (N + 1)
for i in range(N + 1):
    for j in A:
        if i>0 and dp[i]==0:
            break
        if i + dic[j] <= N:
            dp[i + dic[j]] = max(dp[i] * 10 + j, dp[i + dic[j]])
print(dp[N])

Measured memory_bytes: 14692
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll ;
typedef double db;
const double pi = 3.141592654;
#define pb         push_back
#define forab(i,a,b)       for(int i=(a);i<=(b);i++)
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)
#define pcase(z,x)     printf("Case %ld: %lld\n",z,x)
#define nw	 "\n"
#define mod 1000000007


int main(void)
{
	CIN;
	ll tc,l,k=0,sum=0,x=0,y,z=0,m=1,n=0,ans=0,cnt=0;
	cin>>n;
	ll a[n+1],b[n];
	for(ll i=0;i<=n;i++)
		cin>>a[i];
	for(ll i=0;i<n;i++)
		cin>>b[i];
	for(ll i=0;i<n;i++){
		sum+=min(a[i],b[i]);
		b[i]-=min(a[i],b[i]);
		a[i]-=min(a[i],b[i]);
		sum+=min(a[i+1],b[i]);
		a[i+1]-=min(a[i+1],b[i]);
	}
	cout<<sum;
}

Measured memory_bytes: 5112
#include<stdio.h>
int search(int *a,int n,int key){
	int left=0,right=n,mid;
	while(left<right){
		mid=(left+right)/2;
		if(a[mid]==key){
			return mid;
		}else if(a[mid]>key){
			right=mid;
		}else{
			left=mid+1;
		}
	}
	return 0;
}
int main(){
	int n,a[100000+1],q,i,key,sum=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	scanf("%d",&q);
	for(i=0;i<q;i++){
		scanf("%d",&key);
		if(search(a,n,key)){
			sum++;
		}
	}
	printf("%d\n",sum);
	return 0;
}


Measured memory_bytes: 2128
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod=1e9+7;
ll add(ll a,ll b){
    return ((a%mod)+(b%mod))%mod;
}
ll mul(ll a,ll b){
    return ((a%mod)*(b%mod))%mod;
}
ll powm(ll x,ll n,ll M)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%M;
        x=(x*x)%M;
        n=n/2;
    }
    return result;
}
ll solve(ll x){
    ll ans=0;
    for(int i=1;i<=10;i++){
        ll n=x*i;
        ans+=(x%10);
    }
    return ans;
}
int main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,W;
    cin>>n>>W;
    vector<ll>dp(W+1,0);
    for(int x=0;x<n;x++){
        ll a,b;
        cin>>a>>b;
            for(int j=W-a;j>=0;j--){
                dp[j+a]=max(dp[j+a],dp[j]+b);
            }
    }
    ll cnt=0;
    //cout<<*max_element(dp.begin(),dp.end());
    for(int i=0;i<=W;i++)cnt=max(cnt,dp[i]);
    cout<<cnt;
    
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
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; }

const long long INF = 1LL << 60;
char s[60][60];
int bomb[60][60];
int main()
{
	int h, w;cin >> h >> w;
	for (int i = 0;i < h;i++) {
		for (int j = 0;j < w;j++) {
			cin >> s[i][j];
		}
	}
	string res = "Yes";
	for (int i = 0;i < h;i++) {
		if (res == "No") {
			break;
		}
		for (int j = 0;j < w;j++) {
			if (s[i][j] == '#') {
				int flg = 0;
				if (i - 1 >= 0) {
					if (s[i - 1][j] == '#') {
						flg++;
					}
				}
				if (j - 1 >= 0) {
					if (s[i][j-1] == '#') {
						flg++;
					}
				}
				if (i + 1 <= h-1) {
					if (s[i + 1][j] == '#') {
						flg++;
					}
				}
				if (j + 1 <= w-1) {
					if (s[i][j + 1] == '#') {
						flg++;
					}
				}
				if (flg == 0) {
					res = "No";
				}
			}
		}
	}
	cout << res << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string a,b;
    cin>>a>>b;
    char x[a.size()],y[b.size()];
    for(int i=0;i<a.size();i++) x[i]=a[i];
    for(int i=0;i<b.size();i++) y[i]=b[i];
    sort(x,x+a.size());
    sort(y,y+b.size());
    for(int i=0;i<min(a.size(),b.size());i++){
        if(x[i]>y[b.size()-i-1]){
            cout<<"No"<<endl;
            return 0;
        }
        else if(x[i]<y[b.size()-i-1]){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    if(a.size()<b.size()) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void)
{
  int A,B;
  int X,Y;
  scanf("%d %d",&X,&Y);
  A = (4*X-Y);
  B = (-2*X+Y);
  if (A < 0 || B < 0) printf("No");
  else if (A%2 || B%2) printf("No");
  else printf("Yes");
  printf("\n");
  return 0;
}


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

int main(){
  
  int n;
  cin >> n;
  
  vector<int>a(n);
  for(int i = 0; i < n; i++)cin >> a[i];
  
  sort(a.begin(),a.end());
  
  int ans = 0, cnt = 0;
  for(int i = 0; i < n; i++){
    if(i!=n-1 && a[i] == a[i+1]) cnt++;
    else{
      if(cnt+1 >= a[i]) ans += cnt+1 - a[i];
      else ans += cnt+1;
      cnt = 0;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll K, A, B;
  cin >> K >> A >> B;


  if (B - A <= 2) {
    cout << K + 1 << endl;
  } else {
    ll n = (K - (A - 1)) / 2;
    ll ans = n * (B - A) + A;
    if (K - 2 * n - (A - 1) == 1) {
      ans++;
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    long x;
    int a,b,c;
    scanf("%ld",&x);
    a = x / 500;
    x = x - 500*a;
    b = x / 5;
    c = 1000*a + 5*b;
    printf("%d",c);
    return 0;
}

Measured memory_bytes: 1736
main :: IO ()
main = do
  [n,yy] <- map read . words <$> getLine :: IO [Int]
  putStrLn . f $ [[x,y,z] | z <- [0..n]
                       , y <- [0..(n-z)]
                       , let x = n-z-y, 10000*x + 5000*y + 1000*z == yy]

f :: [[Int]] -> String
f [] = "-1 -1 -1"
f list = unwords . map show $ head list


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

#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define fi first
#define se second
#define pb push_back
 
#define ll long long
#define pii pair<int, int>
//#define int ll
const int MOD = 1000000007;

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    cout << n + n*n + n*n*n << endl;
}



Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define ll long long

int main() {
    ll n, triangle = 0;
    cin >> n;
    vector<ll> s(n);
    for(auto &i: s) cin >> i;
    sort(s.begin(), s.end());
    for(int i = 0; i < n - 2; i++) {
        for(int j = i + 1; j < n - 1; j++) {
            for(int k = j + 1; k < n; k++) {
                if(s[i] + s[j] > s[k] && s[i] + s[k] > s[j] && s[k] + s[j] > s[i]) {
                    triangle++;
                }
                else if (s[i] + s[j] <= s[k]) break;
            }
        }
    }
    cout << triangle << endl;
    return 0;
}

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

#define MAX 100000

long n, k, w[MAX];

int check(long p){
    long c = 1, a = p;
    
    rep(i, n){
        
        if(w[i] > p) return 0;
        
        if(a < w[i]) {
            c++; a = p;
        }
        
        a -= w[i];
    }
    
    return c <= k;
}

int main(){
    
    cin >> n >> k;
    rep(i, n) cin >> w[i];
    
    long left = 0, right = LONG_MAX;
    
    while(left < right){
        
        long mid = (left + right) / 2;
        
        if(check(mid) && !check(mid - 1)){
            cout << mid << endl;
            return 0;
        }
        
        if(check(mid)) right = mid;
        else left = mid + 1;
    }
}


Measured memory_bytes: 3888
import itertools 
N=int(input())
n=[i for i in range(1,N+1)]
P=tuple(map(int,input().split()))
Q=tuple(map(int,input().split()))


n_new=list(itertools.permutations(n,N))
map(list,n_new)
a=n_new.index(P)
b=n_new.index(Q)
print(abs(a-b))




Measured memory_bytes: 8052
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll a, b;
  cin >> a >> b;
  
  cout << a*b << newl;
  return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>

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

using namespace std;

string S;

int main() {
    cin >> S;
    S.replace(0, 4, "2018");
    cout << S << endl;
}


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

int main() {
  
  int N, M, X; cin >> N >> M >> X;
  
  int table[N][M + 1]; int ans = pow(10, 5) * 12 + 1;
  
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M + 1; j++) {
      cin >> table[i][j];
    }
  }
  
  for (int bit = 0; bit < (1 << 12); bit++) {
    
    bitset<12> subTable(bit);
    
    int moneySum = 0; vector<int> pointSum(M, 0); bool flag = true;
    
    for (int i = 0; i < N; i++) {
      
      if (subTable.test(i)) {
        
        moneySum += table[i][0];
        
        for (int j = 0; j < M; j++) pointSum[j] += table[i][j + 1];
        
      }
      
    }
    
    for (int a : pointSum) if (a < X) flag = false;
    
    if (flag) ans = min(ans, moneySum);
    
  }
  
  if (ans == pow(10, 5) * 12 + 1) cout << -1 << endl;
  
  else cout << ans << endl;
  
}

Measured memory_bytes: 3632
mod = 10**9 + 7
n, a, b = map(int, input().split())
ans = pow(2, n, mod) - 1

for r in [a, b]:
    x = 1
    for i in range(r):
        x *= n-i
        x %= mod
        x *= pow(i+1, mod-2, mod)
        x %= mod
    ans = (ans + mod-x)%mod

print(ans)



Measured memory_bytes: 39152
#include<iostream>
#include<string>
using namespace std;
int main(){
    int n;
    string s1,s2;
    int a=0,b=0;
    cin>>n;
    
    for(int i=0;i<n;i++){
        cin>>s1>>s2;
        if(s1>s2){
            a+=3;
        }else if(s1<s2){
            b+=3;
        }else{
            a++;b++;
        }
    }
    cout<<a<<" "<<b<<endl;
    return 0;
}


Measured memory_bytes: 3108
N = int(input())
l = []
ans = 0
for i in range(N):
  l.append(list(map(str, input().split())))
  l[-1][0] = float(l[-1][0])

for i in range(N):
  if l[i][1] == 'JPY':
    ans += l[i][0]
  else:
    ans += 380000 * l[i][0]
    
print(ans)

Measured memory_bytes: 3064
a, b, c = map(int, input().split())
ca, cb, cc = a, b, c

result = 0
for i in range(100):
    if a & 1 or b & 1 or c & 1:
        print(result)
        break
    a, b, c = (b + c) // 2, (a + c) // 2, (a + b) // 2
    if a == ca and b == cb and c == cc:
        print(-1)
        break
    result += 1


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

using namespace std;

int main(void){
    int n, point, maxj = -1;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
        maxj = max(maxj, a[i]);
        if(maxj == a[i]) point = i;
    }
    sort(a.begin(), a.end());
    for(int i = 0; i < n; i++){
        if(i == point){
            cout << a[n-2] << endl;
        }else{
            cout << a[n-1] << endl;
        }
    }
    return 0;
}

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

int main()
{
	int n;
	cin >> n;
	map<string,int> mp;
	int ans = 0;
	for(int i = 0;i<n;i++)
	{
		string s;
		cin >> s;
		ans += mp[s]==0?1:0;
		mp[s]=1;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 19124
//#pragma GCC optimize ("Ofast")
//#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define pb push_back
#define all(_obj) _obj.begin(),_obj.end()
#define F first
#define S second
#define INF 1e18
#define pll pair<ll, ll> 
#define vll vector<ll>
ll n,m,a,b,c,k,temp,x,y;
const int MAXN=1e5+11,mod=1e9+7;
inline ll max(ll a,ll b) {return ((a>b)?a:b);}
inline ll min(ll a,ll b) {return ((a>b)?b:a);}
inline vll read(int n) {vll v(n);for (int i = 0; i < v.size(); i++)cin>>v[i];return v;}
inline ll gcd(ll a ,ll b) {if(b==0) return a;a%=b;return gcd(b,a);}
bool vis[1111111];
int cnt[1111111];
int counter[1111111];
void sol(void)
{
cin>>n;
vll v=read(n);
bool setwise=false;
int g=v[0];
for(int i=1;i<n;i++)
g=gcd(v[i],g);
setwise=(g==1);
for(auto x:v) counter[x]++;
for(int i=2;i<=1000000;i++)
{
    if(!vis[i])
    for(int j=2*i;j<=1000000;j+=i)
    vis[j]=true;
}
bool pairwise=true;
for(int i=2;i<=1000000;i++)
{
    if(!vis[i])
    {
        for(int j=i;j<=1000000;j+=i)
        {
            cnt[i]=cnt[i]+counter[j];
        }
        if(cnt[i]>1) pairwise=false;
    }
}
if(pairwise)
{
    cout<<"pairwise coprime";
}
else if(setwise)
{
    cout<<"setwise coprime";
}
else
{
    cout<<"not coprime";
}
return ;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int test=1;
    //cin>>test;
    for(int i=1;i<=test;i++)
    sol();
}


Measured memory_bytes: 19772
#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 n, m, q;
int ans = 0;
vector<int> a, b, c, d;

void dfs(vector<int> A) {
    if (A.size() == n+1){
        // calc score
        int now = 0;
        rep(i,q) {
            if (A[b[i]] - A[a[i]] == c[i]) now += d[i];
        }
        ans = max(ans, now);
        return;
    }

    A.push_back(A.back());
    while (A.back() <= m) {
        dfs(A);
        ++A.back();
    }
}

int main() {
    cin >> n >> m >> q;
    a = b = c = d = vector<int> (q);
    rep(i,q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    vector<int> x(1,1);
    dfs(x);
    cout << ans << endl;
    return 0;
}

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

int main(){
  int a,b;
  cin >> a >> b;
  cout << a*b << endl;
  return 0;
}


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

int main()
{
    int n;
    cin >> n;
    map<pair<string, int>, int> kek;
    for (int i = 1; i <= n; ++i)
    {
        string a;
        int score;
        cin >> a >> score;
        kek[{a, -score}] = i;
    }
    for (auto &tmp : kek)
        cout << tmp.second << '\n';
}

Measured memory_bytes: 256
#n札の参考書
#mのアルゴリズム
#x以上

n,m,x=map(int,input().split())
ca=[list(map(int, input().split())) for _ in range(n)]

result=10**9

for i in range(2**n):
    understand=[0]*m
    cost=0
    for j in range(n):
        if i>>j&1:
            temp=ca[j]
            cost+=temp[0]
            for index,item in enumerate(temp[1:]):
                understand[index]+=item
    flag=0
    for item in understand:
        if item<x:
            flag=1
    if flag==0:
        result=min(cost,result)
if result==10**9:
    print(-1)
else:
    print(result)
            


Measured memory_bytes: 73932
N, S = open(0).read().split()
N = int(N)
cnt = 0
l = 0
for i in range(N):
  if S[i]=='(':
    cnt += 1
  else:
    if cnt==0:
      l += 1
    else:
      cnt -= 1
cnt = 0
r = 0
for i in range(N-1,-1,-1):
  if S[i]==')':
    cnt += 1
  else:
    if cnt==0:
      r += 1
    else:
      cnt -= 1
print('('*l+S+')'*r)

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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 998244353;



int main() {
	ll x, y;
	cin >> x >> y;
	if (abs(x - y) > 1) {
		cout << "Alice" << endl;
	}
	else cout << "Brown" << endl;


}





Measured memory_bytes: 256
X, N = map(int,input().split())
p = list(map(int,input().split()))
kazu = [i for i in range(-100,201)]
sa = [0]*301
for i in range(301):
    if kazu[i] in p:
        kazu[i] = 10000
for i in range(301):
    sa[i] = abs(X-kazu[i])
print(kazu[sa.index(min(sa))])

Measured memory_bytes: 9140
n = input()

M = [[float("inf") for j in xrange(n)] for i in xrange(n)]
p = [-1 for i in xrange(n)]

for i in xrange(n):
    tmp = map(int, raw_input().split())
    for j in xrange(tmp[1]):
        M[i][tmp[(j + 1)*2]] = tmp[j*2 + 3]

def dijksrra(s):
    color = ["WHITE" for i in xrange(n)]
    d = [float("inf") for i in xrange(n)]

    d[s] = 0
    p[s] = -1

    while 1:
        mincost = float("inf")
        for i in xrange(n):
            if color[i] != "BLACK" and d[i] < mincost:
                mincost = d[i]
                u = i

        if mincost == float("inf"):
            break

        color[u] = "BLACK"

        for v in xrange(n):
            if color[v] != "BLACK" and M[u][v] != float("inf"):
                if d[u] + M[u][v] < d[v]:
                    d[v] = d[u] + M[u][v]
                    p[v] = u
                    color[v] = "GRAY"

    for i in xrange(n):
        print "%d %d" % (i, d[i])


dijksrra(0)

Measured memory_bytes: 6828
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>

using namespace std;
typedef long long ll;

int main() {
  int N;
  cin >> N;
  vector<int> L(N);
  for (int i = 0; i < N; ++i) {
    cin >> L[i];
  }
  sort(L.begin(), L.end());
  int cnt = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = i + 1; j < N; ++j) {
      int sum = L[i] + L[j];
      auto it = lower_bound(L.begin() + j + 1, L.end(), sum);
      cnt += distance(L.begin() + j + 1, it);
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 384
private fun getInts(): IntArray {
    return readLine()!!.split(" ").map {it.toInt()}.toIntArray()
}

fun main(){
    val n = getInts()[0]
    var a = 1
    var b = n
    var count =0
    while(a<n && b>0) {
        while(a*b >= n){
            b--
        }
        count += b
        a++
    }
    print (count)
}

Measured memory_bytes: 36432
#include <iostream>
#include <cstdio>
using namespace std;
int n;
int sum[501][501];
int lowbit(int x) {
    return x&-x;
}
void update(int x,int y) {
    for(int i = x;i > 0;i -= lowbit(i)) {
        for(int j = y;j <= n;j += lowbit(j)) {
            sum[i][j] ++;
        }
    }
}
int get(int x,int y) {
    int ans = 0;
    for(int i = x;i <= n;i += lowbit(i)) {
        for(int j = y;j > 0;j -= lowbit(j)) {
            ans += sum[i][j];
        }
    }
    return ans;
}
int main() {
    int m,q;
    scanf("%d%d%d",&n,&m,&q);
    int a,b;
    for(int i = 0;i < m;i ++) {
        scanf("%d%d",&a,&b);
        update(a,b);
    }
    for(int i = 0;i < q;i ++) {
        scanf("%d%d",&a,&b);
        printf("%d\n",get(a,b));
    }
}


Measured memory_bytes: 1920
#include <iostream>

using namespace std;

int main(int argc, char* argv[]) {
  long long N;
  cin >> N;

  long long a[N];
  for (long long i = 0; i < N; ++i)
    cin >> a[i];

  long long rets[N];
  long long c = 0;
  for (int i = N; i > 0; --i) {
    long long x = 0;
    for (long long j = 2; j <= N / i; ++j) {
      x += rets[i * j - 1];
    }
    if (x % 2 == 0 && a[i - 1] == 0)
      rets[i - 1] = 0;
    else if (x % 2 == 0 && a[i - 1] == 1)
      rets[i - 1] = 1;
    else if (x % 2 == 1 && a[i - 1] == 0)
      rets[i - 1] = 1;
    else if (x % 2 == 1 && a[i - 1] == 1)
      rets[i - 1] = 0;
    if (rets[i - 1] == 1)
      ++c;
  }

  cout << c << endl;
  bool first = true;
  if (c > 0) {
    for (long long i = 0; i < N; ++i) {
      if (rets[i] == 1) {
        if (!first)
          cout << " ";
        cout << i + 1;
        first = false;
      }
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 3968
#!/usr/bin/python3
# -*- coding:utf-8 -*-

import heapq

def main():
  na, nb, nc, K = map(int, input().split())
  As = sorted(list(map(int, input().split())), reverse=True)
  Bs = sorted(list(map(int, input().split())), reverse=True)
  Cs = sorted(list(map(int, input().split())), reverse=True)
  
  scores = [(-(As[0]+Bs[0]+Cs[0]), 0, 0, 0)]
  used = [(0, 0, 0)]
  def push(i, j, k):
    heapq.heappush(scores, (-(As[i] + Bs[j] + Cs[k]), i, j, k))
    
  for _ in range(K):
    (score, i, j, k) = heapq.heappop(scores)
    print(-score)
    for di, dj, dk in [[1,0,0], [0,1,0], [0,0,1]]:
      if not (i+di < na and j+dj<nb and k+dk < nc):
        continue        
      if (i+di, j+dj, k+dk) not in used:
        push(i+di, j+dj, k+dk)
        used.append((i+di, j+dj, k+dk))

if __name__=='__main__':
  main()



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

const int mod = 1000000007;
signed main(void)
{
	long long n, ans;
	cin >> n;
	ans = 1;
	for (long long i = 1; i <= n; i++)
	{
		ans *= i;
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
    int a, b;
    cin >> a >> b;
    int sum = a + b;
    if (sum % 2 == 0) {
        cout << sum / 2 << endl;
    } else {
        cout << sum / 2 + 1 << endl;
    }
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int z;
string s,huga="AKIHABARA";

signed main() {
    cin >> s;
    rep(i,s.size()) {
        if (s[i] != huga[z]) {
            if (huga[z] != 'A') {
                cout << "NO" << endl;
                return 0;
            } else i--;
        }
        z++;
    }
    if (z==8 || z==9) cout << "YES" << endl;
    else cout << "NO" << endl;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

using namespace std;

int ps[11];
int cs[11];

int main(void) {
  int d, goal;
  scanf("%d%d", &d, &goal);
  vector<int> vs;
  REP(i, d) {
    scanf("%d%d", &ps[i], &cs[i]);
    REP(j, ps[i]) {
      vs.push_back((i+1)*100);
    }
  }
  sort(vs.begin(), vs.end());
  // reverse(vs.begin(), vs.end());

  int res = 1e9;
  REP(pat, 1 << d) {
    // cerr << "> " << pat << endl;
    int score = 0;
    int cur = 0;
    REP(i, d) {
      if(pat & (1 << i)) {
        score += cs[i] + (i+1)*100 * ps[i];
        cur += ps[i];
      }
    }
    int i1 = (int)vs.size() - 1;
    // cerr << score << endl;
    while(score < goal && i1 >= 0) {
      int s = vs[i1];
      if(pat & (1 << (s/100-1))) {
        // nothing
      } else {
        score += s;
        ++cur;
      }
      --i1;
    }
    // cerr << cur << endl;
    if(i1 >= 0) {
      res = min(res, cur);
    }
  }
  printf("%d\n ", res);

  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int T,H,S;
    int t;

    while (1)
    {
        scanf("%d %d %d", &T, &H, &S);
        if (T < 0){
            break;
        }
        t = 7200 - (3600 * T + 60 * H + S);
        printf("%02d:%02d:%02d\n", t / 3600, (t % 3600) / 60, t % 60);
        t *= 3;
        printf("%02d:%02d:%02d\n", t / 3600, (t % 3600) / 60, t % 60);
    }
    return (0);
}


Measured memory_bytes: 2036
#include<stdio.h>

int main( ){
	int people,num,one,two,anum,max;

	while(1) {
		max = 0;
		scanf( "%d" ,&people );
		if( people == 0 )break;

		for( int i = 0; i < people; i++ ){
			scanf( "%d %d %d" ,&num ,&one ,&two );
			if( max < one + two ){
				max = one + two;
				anum = num;
			}
		}
		printf( "%d %d\n" ,anum ,max );
	}
	return 0;
}

Measured memory_bytes: 1028
N=int(input())
S=input()
e=S.count("E")#東を向いている人の数
w=N-e#西を向いている人の数
ans=10**9
for i in range(N):
    left=i
    right=N-1-i
    if i==0:
        left_e=0
        left_w=0
        if S[i]=="E":
            right_e=e-1
            right_w=w
        else:
            right_e=e
            right_w=w-1
    else:
        if S[i-1]=="E":
            left_e+=1
        elif S[i-1]=="W":
            left_w+=1
        if S[i]=="E":
            right_e-=1
        elif S[i]=="W":
            right_w-=1
    tmp=left_w+right_e
    #print(left,left_e,left_w,right,right_e,right_w,tmp)
    if ans>tmp:
        ans=tmp
print(ans)

Measured memory_bytes: 9712
//includes
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#include<assert.h>
#include<cstring>
#include<unordered_map>
#include<bitset>


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

//macros and consts
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define FORE(i,a) for(auto &i : a)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define accm accumulate
#define Fi first
#define Se second
#define INF 1e9
#define llINF (1LL<<60)
#define mINF -1e9
#define mllINF -(1LL<<60)
#define endl "\n"
#define CONT continue
#define BRK break
#define modulo(n, m) (((n)%(m)+(m))%m)

//shorter types
using namespace std;
using ll = long long;
using vi = std::vector<int>;
using vc = std::vector<char>;
using vll = std::vector<long long>;
using vs = std::vector<string>;
using Mi = map<int,int>;
using Mll = map<ll,ll>;
using UMi = unordered_map<int,int>;
using UMll = unordered_map<ll,ll>;
using Pi = pair<int,int>;
using Pll = pair<ll,ll>;
using vPi = vector<Pi>;
using vPll = vector<Pll>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using pqgi = priority_queue<int,vector<int>,greater<int>>;
using pqsi = priority_queue<int,vector<int>,less<int>>;
using pqgll = priority_queue<int,vector<int>,greater<int>>;
using pssll = priority_queue<int,vector<int>,less<int>>;
template<class T>
using vec = vector<T>;
#define int long long

int N,W;
//here begins your code
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cin >> N >> W;
  vector<int> w,v;
  w.resize(N);
  v.resize(N);

  for(int i = 0; i < N ; i++){
  	cin >> w[i] >> v[i];
  }
  vector<vector<int>> dp(110, vector<int>(100100,0));
  for(int i = 0 ; i < N ; i++){
  	for(int sum_w = 0 ; sum_w <= W; sum_w++){
  		if(sum_w - w[i] >= 0) chmax(dp[i + 1][sum_w],dp[i][sum_w - w[i]]  + v[i]);
  		chmax(dp[i + 1][sum_w], dp[i][sum_w]);
  	}
  }
  cout << dp[N][W] << endl;
  //check types
  //do not eb if you resize
  //resize before you access by idx
  return 0;
} 

Measured memory_bytes: 87296
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int[][] a = new int[3][3];
		for (int i = 0; i < 3; i++)
			Arrays.setAll(a[i], idx -> sc.nextInt());
		
		boolean[][] opened = new boolean[3][3];
		
		int n = sc.nextInt();
		for (int i = 0; i < n; i++) {
			int b = sc.nextInt();
			open(a, opened, b);
		}
		
		String ans = isBingo(opened) ? "Yes" : "No";
		System.out.println(ans);
		
		sc.close();
	}
	
	
	static boolean isBingo(boolean[][] opened) {
		outer:
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < opened[i].length; j++) {
				if (!opened[i][j]) continue outer;
			}
			return true;
		}
	
		outer:
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < opened[i].length; j++) {
				if (!opened[j][i]) continue outer;
			}
			return true;
		}
		
		
		boolean flg = true;
		for (int i = 0; i < 3; i++) {
			if (!opened[i][i]) flg = false;
		}
		if (flg) return true;
		
		flg = true;
		for (int i = 0; i < 3; i++) {
			if (!opened[i][2 - i]) flg = false;
		}
		return flg;
	}
	
	static void open(int[][] a, boolean[][] opened, int b) {
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				if (a[i][j] == b) {
					opened[i][j] = true;
					return;
				}
			}
		}
	}
}




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

int main(){
    string s,t;
    cin >> s >> t;
    bool ok_fl = true;
    rep(i,s.size()){
        if(s.at(i) != t.at(i)) {
            ok_fl = false;
            break;
        }
    }
    if(ok_fl){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <math.h>
#include <time.h>

typedef int32_t i32;
typedef int64_t i64;
typedef double f64;

void *const null=(void *)0;
i64 const llinf=4611686018427387903LL;
i64 const mod=1000000009LL;
f64 const pi=3.141592653589793;
f64 const rad=57.295779513082323;

#define CODE_

i32 main(void){
    i64 x,y=0LL;
    i64 a,b,c,d,p;
    scanf("%lli%lli%lli%lli%lli",&a,&b,&c,&d,&p);
    x=a*p;
    y=b;
    if(p>c) y+=(p-c)*d;
    printf("%lli\n",x<=y?x:y);
    return 0;
}



Measured memory_bytes: 2048
N = int(input())
TXY = [tuple(map(int,input().split())) for i in range(N)]
ct = cx = cy = 0
for t,x,y in TXY:
    d = abs(cx-x) + abs(cy-y)
    if d > t-ct or d%2 != (t-ct)%2:
        print('No')
        exit()
    ct,cx,cy = t,x,y
print('Yes')

Measured memory_bytes: 17324
#include<stdio.h>
typedef long long int ll;

int main()
{
	ll n,k;
	scanf("%lld %lld",&n,&k);
	ll array[n+1],array1[n+1];
	for(ll i=1;i<=n;i++)
	{
		scanf("%lld",&array[i]);
		array1[i]=0;
	}
	array1[1]=0;
	ll c=1,f1=0,f2=0;
	if(k<=n)
	{
		for(ll i=1;i<=k;i++)
		{
			c=array[c];
			if(array1[c]>0)
			{
				f2=array1[c];
				f1=i;
				i=n+1;
			}
			array1[c]=i;
		}
		printf("%lld\n",c);
	}
	else
	{
		for(ll i=1;i<=n;i++)
		{
			c=array[c];
			if(array1[c]>0)
			{
				f2=array1[c];
				f1=i;
				i=n+1;
			}
			array1[c]=i;
		}
		{
			ll cnt=c;
			if((k-f2+1)%(f1-f2)==0)
			{
				for(ll i=1;i<(f1-f2);i++)
					cnt=array[cnt];
			}
			else
			{
				for(ll i=2;i<=((k-f2+1)%(f1-f2));i++)
				{
					cnt=array[cnt];
				}
			}
			printf("%lld\n",cnt);
		}
	}
}


Measured memory_bytes: 4828
#include <iostream>
#include <algorithm>
#include <string.h>
#include <stdio.h>
#include <time.h>
#include <ctime>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <math.h>
#include <queue>
#include <stdlib.h>
#define F first
#define S second
#define ll long long
#define ull unsigned long long
using namespace std;
ll a,b,c;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> a >> b >> c;
    ll t=min(a*b,min(b*c,a*c));
    if (a%2*b%2*c%2==1) cout << t; else cout << 0;
}


Measured memory_bytes: 256
def main(n, ns):
    if len(set(ns)) == 1:
        return 0
    
    min_v  = -100
    max_v  = 101
    answer = pow(100, 3)
    for i in range(min_v, max_v):
        cost = sum([(n - i) ** 2 for n in ns])
        answer = min(answer, cost)
    return answer
 
 
if __name__ == '__main__':
    n = int(input())
    ns = [int(e) for e in input().split()]
    print(main(n, ns))


Measured memory_bytes: 3060
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <string>
#include <iostream>
#include <stack>

using namespace std;
typedef long long ll;

int main(){
    ll p, q, r;
    cin >> p >> q >> r;
    cout << min(p + q, min(p + r, q + r)) << endl;
    return 0;
}


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

using namespace std; using ll=long long; const ll LNF=1e18; const int INF = 1e9+1; const ll M = 1e9+7;
typedef pair<int,int> P;
ll gcd(ll x, ll y) {if (y==0) return x; else return gcd(y, x%y);}
int main() {
  ll a,b,c,d; cin>>a>>b>>c>>d; a--;
  ll an = b - b/c - b/d + b/(c*d/gcd(c,d));
  //cout<<an<<" "<<b<<" "<<b/c<<" "<<b/d<<" "<<b/gcd(c,d)<<" "<<gcd(c,d)<<endl;
  an -= a - a/c - a/d + a/(c*d/gcd(c,d));
  //cout<<an<<" "<<a<<" "<<a/c<<" "<<a/d<<" "<<a/c/d<<endl;
  cout<<an<<endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    EACH(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    REP(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    REP(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a, b, c; cin >> a >> b >> c;
    if (a == b && b == c) {
        cout << 1 << endl;
    }
    else if (a == b || b == c || c == a) {
        cout << 2 << endl;
    }
    else {
        cout << 3 << endl;
    }
}


Measured memory_bytes: 256