akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
//priority_queue<int, vector<int>, greater<int> > pq;
#define _CRT_SECURE_NO_DEPRECATE
const int N = 33003;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =  1e9+7;
using namespace std;
//ll n,s;
multiset<long long> m;
int main(){
ll n;
ll x;
cin>>n>>x;
ll ans=1e18;
ll a[n];
rep(i,0,n)
cin>>a[i];
rep(i,0,n)
{
	ll y=i*x;
	m.clear();
	rep(j,0,i+1)
	m.insert(a[j]);
	rep(j,0,n)
	{
		y+=*m.begin();
		m.erase(m.find(a[j]));
		m.insert(a[(i+j+1)%n]);
	}
	ans=min(ans,y);
}
cout<<ans;
}

Measured memory_bytes: 384
object Main extends App {
  val n = io.StdIn.readInt()
  val k = 3
  val actions = Array.fill(n)(io.StdIn.readLine().split(' ').map(_.toInt))
  val dp = Array.ofDim[Int](n,k)

  for (j <- 0 until k) dp(0)(j) = actions(0)(j)
  for (i <- 1 until n)
    for (j <- 0 until k) {
      dp(i)(j) = dp(i-1).zipWithIndex.filter(_._2 != j).maxBy(_._1)._1 + actions(i)(j)
    }

  println(dp(n-1).max)
}

Measured memory_bytes: 109228
#include<bits/stdc++.h>
using namespace std;
#define FIO  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define MOD 10000007
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl


int main()
{

	FIO
#ifndef ONLINE_JUDGE
	freopen ("in.txt", "r", stdin);
	freopen ("out.txt", "w", stdout);
#endif

	int n;
	cin >> n;
	ll a[n][3];
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < 3; j++)
			cin >> a[i][j];
	}


	for (int i = n - 2; i >= 0; i--)
	{
		for (int j = 0; j < 3; j++)
		{
			ll maxi = -1e13;
			for (int k = 0; k < 3; k++)
			{
				if (k != j)
					maxi = max(maxi, a[i + 1][k]);
			}
			a[i][j] += maxi;
		}
	}


	ll ans = -1e13;
	for (int i = 0; i < 3; i++)
		ans = max(ans, a[0][i]);
	cout << ans;
}




Measured memory_bytes: 5868
# -*- coding: utf-8 -*-
h,w = list(map(int,input().split()))
inf=float("inf")
s = [[-1]*(w+2)] + [[-1] + [inf if i=="." else -1 for i in input()] + [-1] for _ in range(h)] + [[-1]*(w+2)]

from copy import deepcopy
from collections import deque

ret = 0
for i in range(1,h+1):
    for j in range(1,w+1):
        temp_s = deepcopy(s)
        if temp_s[i][j]!=-1:
            temp_s[i][j]=-1
            stack_deque = deque([(i,j,0)])
        else:
            stack_deque = []
        max_v=0
        while len(stack_deque)>0:
            hi,wj,v = stack_deque.popleft()
            v+=1
            if temp_s[hi][wj-1]!=-1:
                temp_s[hi][wj-1]=-1
                stack_deque.append([hi,wj-1,v])
                max_v=max(max_v,v)
            if temp_s[hi][wj+1]!=-1:
                temp_s[hi][wj+1]=-1
                stack_deque.append([hi,wj+1,v])
                max_v=max(max_v,v)
            if temp_s[hi-1][wj]!=-1:
                temp_s[hi-1][wj]=-1
                stack_deque.append([hi-1,wj,v])
                max_v=max(max_v,v)
            if temp_s[hi+1][wj]!=-1:
                temp_s[hi+1][wj]=-1
                stack_deque.append([hi+1,wj,v])
                max_v=max(max_v,v)
        ret=max(ret,max_v)
print(ret)

Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll,ll> pii;
typedef vector<pii> vpii;
typedef pii point;
using namespace std;

int main(){
  ll N; cin>>N;
  vi P(N); REP(i,N) cin>>P[i];
  vi v(N+1);
  REP(i,N) v[P[i]]=max(1ll,v[P[i]-1]+1);
  ll ans=0; for(ll i:v) ans=max(ans,i);
  cout<<N-ans<<endl;
}


Measured memory_bytes: 3328
from itertools import *

def find(X):
    for a,b,c,d in permutations(X):
        for x,y,z in product("+-*",repeat=3):
            for f in ("(((%s%s%s)%s%s)%s%s)","(%s%s%s)%s(%s%s%s)"):
                t = f%(a,x,b,y,c,z,d)
                if eval(t)==10:
                    return t
    return 0

while True:
    X = map(int,raw_input().split())
    if X==[0,0,0,0]:
        break
    print find(X)

Measured memory_bytes: 4388
#include <bits/stdc++.h>
#define FOR(i,a,b)  for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n)    FOR(i,0,n)
#define RER(i,n)    FOR(i,0,(n+1))
#define pb          push_back
#define mp(a,b)     make_pair((a),(b))
#define mset(m,v)   memset(m,v,sizeof(m))
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pair<ll, ll> > vpll;
typedef vector<string> vs;
typedef long double ld;
const double EPS    = 1e-10;
const int INF       = 1e+9;
const double PI     = acos(-1);


auto main() -> int
{
    string c;
    cin >> c;
    if ( c == "a" || c == "e" || c == "i" || c == "o" || c == "u" ) {
        cout << "vowel" << endl;
    } else {
        cout << "consonant" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#include <cmath>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
const int INF=2e9;

int main(){
	int x,y,a,b,c;
	cin>>a>>b>>c>>x>>y;
	x*=2;
	y*=2;
	int z=max(x,y);
	int ans=INF;
	rep(i,z+1){
		int p,q,r;
		r=i*c;
		p=((max(0,x-i)+1)/2)*a;
		q=((max(0,y-i)+1)/2)*b;
		ans=min(ans,p+q+r);
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>

const int MN = 100005;

int N, M, deg[MN];
int stk[MN], C4;
std::vector<int> G[MN];

int vis[MN], cnt;
void DFS(int u) {
	vis[u] = 1, ++cnt;
	for (auto v : G[u]) if (!vis[v]) DFS(v);
}

int main() {
	scanf("%d%d", &N, &M);
	for (int i = 1; i <= M; ++i) {
		int x, y;
		scanf("%d%d", &x, &y);
		G[x].push_back(y);
		G[y].push_back(x);
		++deg[x], ++deg[y];
	}
	for (int i = 1; i <= N; ++i) if (deg[i] & 1) return puts("No"), 0;
	for (int i = 1; i <= N; ++i) if (deg[i] >= 6) return puts("Yes"), 0;
	for (int i = 1; i <= N; ++i) if (deg[i] == 4) stk[++C4] = i;
	if (C4 >= 3) return puts("Yes"), 0;
	if (C4 <= 1) return puts("No"), 0;
	vis[stk[2]] = 1;
	DFS(stk[1]);
	puts(cnt == N - 1 ? "No" : "Yes");
	return 0;
}

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

using namespace std;
using LLONG = long long;

int main()
{
    double a, b;
    cin >> a >> b;
    cout << static_cast<int>(ceil((a + b) / 2.0)) << endl;

    return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

// 約数列挙
vector<int> get(int n) {
    if (n == 1) return {};
    vector<int> ret;
    for (int i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i != 1 && i * i != n) {
                ret.push_back(n / i);
            }
        }
    }
    return ret;
}

class DNotDivisible {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;
        vector<int> A(N);
        REP(i, N) cin >> A[i];

        map<int, int> s;
        REP(i, N) {
            s[A[i]]++;
        }

        int res = 0;
        REP(i, N) {
            if (s[A[i]] > 1) continue;
            auto v = get(A[i]);
            bool ok = true;
            for (auto n : v) {
                if (s.count(n)) {
                    ok = false;
                    break;
                }
            }
            if (ok) res++;
        }
        cout << res << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    DNotDivisible solver;
    solver.solve(in, out);
    return 0;
}


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

#define ll long long

const int mxN = 1e7 + 10;
int n, c[mxN];

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

  cin >> n;
  for (int i = 1; i <= n; ++i)
    for (int j = 0; j <= n; j += i)
      ++c[j];
  ll ans = 0;
  for (int i = 1; i <= n; ++i)
    ans += (ll)i * c[i];
  cout << ans << '\n';
}



Measured memory_bytes: 42688
#include<bits/stdc++.h>
using namespace std;
int main(){
	int x1,y1,x2,y2,x3,y3,x4,y4;
	scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
	x3=x2-y2+y1;
	y3=y2+x2-x1;
	x4=x3-x2+x1;
	y4=y3-y2+y1;
	printf("%d %d %d %d\n",x3,y3,x4,y4);
	return 0;
}

Measured memory_bytes: 256
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int vis[5]={0};
    int x,y;
    cin>>x>>y;
    vis[x]=1;
    vis[y]=1;
    for(int i=1;i<=3;++i)
        if(!vis[i])
            cout<<i;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
const double pi = 3.14159265358979323846;
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
int main()
{
    ll n,sum=0;
    cin>>n;

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

    for(int i=1;i<=n;i++)
        sum+=i*b[i];

    cout<<sum;
    return 0;
}

Measured memory_bytes: 81708
import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
 
  
  
  
public class Main {
    
    
    public static void main(String[] args) {
         
        try {
            
        	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  
            String s;
            List<Integer> List = new ArrayList<Integer>();  
            
            int verticalNum = Integer.parseInt(br.readLine());
           
            for(int i = 1; i<=verticalNum; i++)
            {
            	List.add(i);
            }
            int horizontalNum = Integer.parseInt(br.readLine());
            
            for(int i = 0; i<horizontalNum; i++)
            {
            	s = br.readLine();
            	StringTokenizer st = new StringTokenizer(s,",");
            
            	int a = Integer.parseInt(st.nextToken()) - 1;
                int b = Integer.parseInt(st.nextToken()) - 1;
                int temp = 0;
                
                temp = List.get(a);
                List.set(a,List.get(b));
                List.set(b, temp);
                     
            }
            
            for(int i = 0; i<List.size(); i++)
            {
            	System.out.println(List.get(i));
            }
     
        }catch (Exception e) {
            e.printStackTrace();
        }
         
    }
    
   
    
  
}

Measured memory_bytes: 24264
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <ctype.h>

int main(void)
{
  int n,a,b,c, vv,i;
  scanf("%d %d %d",&n,&a,&b);
  c = 0;
  for(i=1;i<=n;i++){
    vv = f(i);
    if( a<=vv && vv<=b ){
      c+= i;
    }
  }
  
  printf("%d\n",c);
  return EXIT_SUCCESS; 
}

int f (int v){
  int i,tot ;
  tot = 0;
  while( v > 0){
    tot += v % 10;
    v = ( v/10);
  }
  return tot;
}



Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<deque>
#include<iomanip>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
using namespace std;

#define pb push_back
//#define mp make_pair
#define myfor(i, a, b) for (int i = a; i < b; ++i)

template<typename T>inline bool upmin(T &x,T y) { return y<x?x=y,1:0; }

const double PI = acos(-1.0);
const double EPS = 1e-6;
const int INF = 0x3f3f3f3f;

int n;
int a[20], b[20], ind[20];

bool vis[20];

bool check(vector<int> &tp, int id, int x, int is_b) {
    bool flag = false;
    myfor(i, 0, n) if (!vis[i] && (x == tp[i]) && ((abs(id - i) & 1) == is_b)) {
        vis[i] = 1;
        ind[id] = i;
        return true;
    }
    return false;
}

int main()
{
    cin >> n;
    myfor(i, 1, n + 1) cin >> a[i];
    myfor(i, 1, n + 1) cin >> b[i];

    int ans = INF;
    myfor(i, 0, (1 << n)) {

        int cnt = 0;
        vector<int> tp;

        myfor (j, 0, n) {
            if ((i >> (n - j - 1)) & 1) tp.pb(b[j + 1]);
            else tp.pb(a[j + 1]);
        }
        sort(tp.begin(), tp.end());

        bool flag = true;
        memset(vis, 0, sizeof(vis));
        memset(ind, 0, sizeof(ind));

        myfor(j, 0, n) {
            int is_b = (i >> (n - j - 1)) & 1;
            int x = is_b ? b[j + 1] : a[j + 1];
            if (!check(tp, j, x, is_b)){
                flag = false;
                break;
            }
        }

        if (flag) {
            myfor(j, 0, n) {
                for (int k = n - 1; k > j; k--) if (ind[k] < ind[k - 1]) {
                    cnt++;
                    swap(ind[k], ind[k - 1]);
                }
            }
            ans = min(ans, cnt);
        }
    }

    cout << ((ans == INF) ? -1 : ans) << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<string.h>
#include<queue>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<cstdlib>
#include<math.h>
#include<set>
#include<array>
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; }



#define rep(n) for(int i=0;i<n;i++)
typedef pair<int, int> pii;

typedef long long ll;
typedef pair<ll, ll>pll;
const int MOD = 1000000007;
const int INF = 1 << 29;


int main() {
	int n;

	cin >> n;
	char s[101];
	rep(n) { cin >> s[i]; }
	int cnt = 0;
	if (n % 2 != 0) {
		cout << "No" << endl;
		return 0;
	}
	for (int i = 0; i < n / 2; i++) {
		if (s[i] == s[n / 2 + i])cnt++;
	}
	if (cnt == n / 2) {
		cout<<"Yes" << endl;
	}
	else cout << "No" << endl;;
	return 0;
}


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

int main(){
	
	int n , trash ;
	string card ;
	
	while(1){
		cin >> n ;
		if( n==0  ) break ;
		
		cin >> card ;
		int num[100] = {} ;
		trash = 0 ;
		
		for( int i=0 ; i<100 ; i++ ){
			if( card[i] == 'M' ) num[i%n]++ ;
			else if( card[i] == 'L' ){
				num[i%n] += trash + 1 ;
				trash = 0 ;
			}
			else if( card[i] == 'S' ){
				trash += num[i%n] + 1 ;
				num[i%n] = 0 ;
			}
		}
		
		sort( num , num+n ) ;
		for( int i=0 ; i<n ; i++ ) cout << num[i] << " " ;
		cout << trash << endl ;
	}
	
return 0; 
}

Measured memory_bytes: 1228
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>
#define REP(i,n) for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;

int main(){
  ll N;
  cin >> N;
  ll a,b;
  string s;
  for(int i = 1;i < sqrt(N)+1;i++){
    if(N%i  == 0){
      a = N/i;
      if(i <= a){
	b = a;
      }
      else
	break;
      
    }
    if(a < i)
      break;
    //cout << i << endl;
  }
  int sum = 0;
  while(b != 0){
    sum++;
    b /=10;
  }
  printf("%d\n",sum);
  return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
s=list(str(input()))
f=0
mf=0
for i in range(n+1):
    if s[i]=='1':
        f+=1
        mf=max(mf,f)
    else:
        f=0
if mf>=m:
    print(-1)
    exit()
reans=[]
s.reverse()
nk=0
while nk<n:
    for i in range(min(n-nk,m),0,-1):
        if s[nk+i]=='0':
            nk=nk+i
            reans.append(i)
            break
reans.reverse()
print(*reans)
        


Measured memory_bytes: 55048
#define PROB Hexspeak

#include <bits/stdc++.h>

using namespace std;
typedef long long LL;
#define rep(i, l, r) for (int i = l; i<r;i++)
#define all(b) b.begin() , b.end()
#define mp(a, b) make_pair(a,b)
#define pb(a) push_back(a)
#define vi vector<int>
#define vd vector<double>
#define vs vector<string>
#define vii vector<pair<int,int>>
#define vvi vector<vector<int>>
#define ii pair<int,int>
#define turnOff(k, i) (k&(~(1<<(i-1))))
#define isOn(k, i) (k&&(1<<i-1)?true:false)
#define pll pair<long long int , long long int>
#define ull unsigned long long int
#define ll  long long int
#ifdef  DEBUG
#define MAXN 25
#else
#define MAXN 5000020
#endif
#define MAXLG 20
#define endl '\n'
#define PI 3.14159265i3589793238
#define MOD (1000000007)
#define INF (1000000007)
#define EPS (0.00000001)
#define treap treapNode*

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
#ifdef DEBUG
    freopen("input", "r", stdin);
#endif
    int n;
    cin>>n;
    ll arr[n];
    ll sum[n];
    rep (i,0,n) cin>>arr[i];
    ll s = 0;
    rep(i,0,n) {
        sum[i] = arr[i] + s;
        s += arr[i];
    }
    ll maximum =INT64_MAX;
    rep (i,0,n-1) {
        ll x = sum[i];
        ll y = sum[n-1] - sum[i];
        maximum = min(abs(x-y), maximum);
    }
    cout<<maximum;
    return 0;
}

























Measured memory_bytes: 3328
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           node(a,b,c)                 mp(mp(a,b),c)
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;
const int N=2e6+5;
//Template from __Ash_ code
namespace Combi {
    int fact[N], inv[N];

    int bm(int b, int p, int m) {
        if(p == 0) return 1%m;
        int t = bm(b,p/2,m);
        t = (1ll*t*t)%m;
        if(p&1) return 1ll*t*b%m;
        return t;
    }

    int C(int n, int r) {
        if(n < 0 or r < 0 or r > n) return 0;
        int ret = 1ll*fact[n]*inv[r]%mod;
        ret = 1ll*ret*inv[n-r]%mod;
        return ret;
    }
    // X1 + X2 + ... + Xvar = Sum
    int no_of_eqns(int sum, int var) {
        return C(sum+var-1,var-1); // Xi >= 0
        // return C(sum-1,var-1); // Xi > 0
    }
    void init() {
        fact[0] = 1;
        for(int i = 1; i < N; i++) {
            fact[i] = 1ll*fact[i-1]*i%mod;
        }
        inv[N-1] = bm(fact[N-1], mod-2, mod);
        for(int i = N-2; i >= 0; i--) {
            inv[i] = 1ll*inv[i+1]*(i+1)%mod;
        }
    }
}

 main()

{
    fast
    Combi::init();
    int s;
    cin>>s;
    int ses=0;
    f(len,1,s)
    {
       if(s<(3*len))continue;
       int sum=s-3*len;
       int yo=Combi::no_of_eqns(sum,len);
       ses=(ses+yo)%mod;
    }
    if(ses<0)ses+=mod;
    ses=ses%mod;
    cout<<ses<<"\n";
    return 0;

}





































Measured memory_bytes: 34880
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()

d = {"s":r, "p":s, "r":p}
score = 0
for idx in range(k):
    List = []
    for i in range(n):
        if idx+i*k > n-1:
            break
        else:
           List.append(t[idx+i*k])
    not_liset = True
    tmp = List[0]
    score += d[tmp]
    for i in range(1, len(List)):
        if tmp == List[i] and not_liset:
            not_liset = False
        else:
            score += d[List[i]]
            not_liset = True
        tmp = List[i]
print(score)

Measured memory_bytes: 4084
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
using namespace std;
main(){
  int m,n;
  while(cin>>m>>n,n){
    int a1[n][n],a2[n][n],q,w,e,r;
    r(i,n)r(j,n){
      if(i==j)a2[i][j]=a1[i][j]=0;
      else a2[i][j]=a1[i][j]=INF;
    }
    while(m--){
      scanf("%d%d%d%d",&q,&w,&e,&r);q--;w--;
      a1[q][w]=a1[w][q]=e;
      a2[q][w]=a2[w][q]=r;
    }
    r(k,n)
    #pragma omp parallel
    r(i,n)r(j,n){
      a1[i][j]=min(a1[i][j],a1[i][k]+a1[k][j]);
      a2[i][j]=min(a2[i][j],a2[i][k]+a2[k][j]);
    }
    cin>>e;
    while(e--){
      scanf("%d%d%d",&q,&w,&r);q--;w--;
      if(r)cout<<a2[q][w]<<endl;
      else cout<<a1[q][w]<<endl;
    }
  }
}

Measured memory_bytes: 3216
N, K, Q = map(int, input().split(' '))
A = tuple(int(input()) for _ in range(Q))

scores = [0] * N

for a in A:
    scores[a - 1] += 1

for i in range(N):
    if scores[i] > Q - K:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 8636
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i<(int)n; ++i)
#define forr(i, t, n) for (int i = t; i<n; ++i)
#define rmod(x, y) (((x%y)+y)%y)
#define pb push_back
#define emp emplace_back
#define ppb pop_back
#define len(v) int(v.size())
#define all(v) (v).begin(),(v).end()
#define ri(x) scanf("%d",&(x))
#define rii(x,y) scanf("%d %d",&(x),&(y))
#define riii(x,y,z) scanf("%d %d %d",&(x),&(y),&(z))
#define rl(x) scanf("%lld",&(x))
#define rll(x,y) scanf("%lld %lld",&(x),&(y))
#define rlll(x,y,z) scanf("%lld %lld %lld",&(x),&(y),&(z))
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
void fastio(){ios_base::sync_with_stdio(false); cin.tie(0);}

const long double PI = acos(-1);
const long long MOD = 1000000000 +7;
const int maxn = 1024;

int main() {
	int n;
	ri(n);
	string s;
	cin >> s;
	if (n%2) {
		puts("No");
		return 0;
	}
	if (s.substr(0, n/2) == s.substr(n/2, n/2)) puts("Yes");
	else puts("No");
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
  char s[3];
  std::cin >> s[0] >> s[1] >> s[2];
  
  int ans = 0;
  for(int i = 0; i < 3; ++i)
  {
    if(s[i] == '1') ++ ans;
  }
  
  std::cout << ans;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 5e3 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int a, b, c;
	cin >> a >> b >> c;
	if (a + c == 2 * b) puts("YES");
	else puts("NO");
	return 0;
}

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

class AtCoder
{
    const int MOD = 1000000007;
    public void Slove()
    {
        var inputs = Console.ReadLine().Split();
        var n = int.Parse(inputs[0]);
        var d = int.Parse(inputs[1]);
        var d2 = d * 2 + 1;
        Console.WriteLine((n - 1 + d2) / d2);
    }
    static void Main()
    {
        var ac = new AtCoder();
        ac.Slove();
    }
}

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

int main()
{
    ll l,r;cin>>l>>r;
    for(ll i = 0; i < 990589; i++){
        if(l <= 2019*i && r >= 2019*i) {
            cout << 0 << endl;
            return 0;
        }
    }
    ll ans = 2200;
    for(int i = l; i < r; i++){
        for(ll j = i + 1; j <= r; j++){
            ans = min(ans, i*j%2019);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int a,b;cin>>a>>b;
    cout<<LCM(a,b)<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------



Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,x,y;
    scanf("%d%d",&a,&b);
    if(a>=b)
    {
        x=a;
        a=a-1;
        if(a>=b)
        {
            y=a;
        }
        else
        {
            y=b;
        }
    }
    else
    {
        x=b;
        b=b-1;
        if(b>=a)
        {
            y=b;
        }
        else
        {
            y=a;
        }
    }

    printf("%d",x+y);
    return 0;
}



Measured memory_bytes: 2140
#070_D
from heapq import heappop, heappush
import sys
sys.setrecursionlimit(100000)
inf = 10 ** 15

def dijkstra(s):
    que = []
    d[s] = 0
    heappush(que, (0,s))
    
    while len(que):
        dist, node = heappop(que)
        
        if d[node] < dist:
            continue
        for to, cost in edges[node]:
            if d[to] > dist + cost:
                d[to] = dist + cost
                heappush(que, (d[to], to))
                
n = int(input())
edges = [[] for _ in range(n)]
for _ in range(n-1):
    a, b, c = map(int, input().split())
    edges[a-1].append((b-1, c))
    edges[b-1].append((a-1, c))
    
q, k = map(int, input().split())
d = [inf for _ in range(n)]
dijkstra(k-1)

for _ in range(q):
    x, y = map(int, input().split())
    print(d[x-1] + d[y-1])

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

public class Main {

    public static void solve(InputReader in, PrintWriter out) throws Exception {

        int n = in.nextInt();

        int[] arr = new int[n];

        int[][] val = new int[n][3];

        for(int i=0;i<n;i++)
            for(int j=0;j<3;j++)
            val[i][j]=in.nextInt();


        int[][] dp = new int[n+1][4];

        for(int i=0;i<=n;i++) {
            for (int j = 0; j < 4; j++) {

                if(i==0||j==0)
                {
                    dp[i][j]=0;
                    continue;
                }

                dp[i][j]=0;

                if(j==1)
                    dp[i][1]=Math.max(val[i-1][j-1]+dp[i-1][2],val[i-1][j-1]+dp[i-1][3]);
                else if(j==2)
                    dp[i][2]=Math.max(val[i-1][j-1]+dp[i-1][1],val[i-1][j-1]+dp[i-1][3]);
                else if(j==3)
                    dp[i][3]=Math.max(val[i-1][j-1]+dp[i-1][1],val[i-1][j-1]+dp[i-1][2]);
            }

        }

        out.println(Math.max(dp[n][3],Math.max(dp[n][1],dp[n][2])));

    }

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


    private final static long hash(long x, long y) {
        x += offset;
        y += offset;
        return x << 32 | y;
    }

    private final static int offset = (int) 3e5;

    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solve(in, out);
        out.close();
    }

    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        private String nextToken() throws IOException {
            while (tokenizer == null || !tokenizer.hasMoreTokens())
                tokenizer = new StringTokenizer(reader.readLine());
            return tokenizer.nextToken();
        }

        public String nextLine() throws IOException {
            return reader.readLine();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(nextToken());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(nextToken());
        }

        public double nextDouble() throws IOException {
            return Double.parseDouble(nextToken());
        }

    }
}


Measured memory_bytes: 61512
// luogu-judger-enable-o2
#include<cstdio>
#pragma GCC optimize(3)
int n,a[200010];
inline int read(){
	register int ret=0;char c=getchar();
	while(c<'0'||c>'9')c=getchar();
	while(c>='0'&&c<='9')ret=(ret<<1)+(ret<<3)+(c^48),c=getchar();
	return ret;
}
int main()
{
	n=read();
	for(register int i=1;i<=n;++i)a[i]=read();
	for(register int i=n;i>0;i-=2)printf("%d ",a[i]);
	for(register int i=(n&1)+1;i<=n;i+=2)printf("%d ",a[i]);
	return 0;
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll h,w;
  cin >> h >> w;
  vector<string> maze(h,"");
  REP(i,h) cin >> maze[i];

  ll ans = 0;
  REP(i,h){
    REP(j,w){
      if(maze[i][j]=='#') continue;
      vector<vl> cos(h,vl(w,h*w));
      vector<vector<bool>> verified(h,vector<bool>(w,false));
      cos[i][j] = 0;
      verified[i][j] = true;
      queue<pll> que;
      que.push({i,j});
      while(!que.empty()){
        pll node = que.front();
        que.pop();
        ll y = node.first;
        ll x = node.second;
        //cout << y << "," << x << endl;
        if(y>0){
          ll xi = x;
          ll yi = y-1;
          if(maze[yi][xi]!='#' && !verified[yi][xi]){
            que.push({yi,xi});
            cos[yi][xi] = cos[y][x]+1;
            verified[yi][xi] = true;
          }
        }
        if(y<h-1){
          ll xi = x;
          ll yi = y+1;
          if(maze[yi][xi]!='#' && !verified[yi][xi]){
            que.push({yi,xi});
            cos[yi][xi] = cos[y][x]+1;
            verified[yi][xi] = true;
          }
        }
        if(x>0){
          ll xi = x-1;
          ll yi = y;
          if(maze[yi][xi]!='#' && !verified[yi][xi]){
            que.push({yi,xi});
            cos[yi][xi] = cos[y][x]+1;
            verified[yi][xi] = true;
          }
        }
        if(x<w-1){
          ll xi = x+1;
          ll yi = y;
          if(maze[yi][xi]!='#' && !verified[yi][xi]){
            que.push({yi,xi});
            cos[yi][xi] = cos[y][x]+1;
            verified[yi][xi] = true;
          }
        }
      }
      ll tmp = 0;
      REP(k,h){
        REP(l,w){
          if(maze[k][l]=='.'){
            CHMAX(tmp,cos[k][l]);
            //cout << cos[k][l];
          }
          //else cout << "#";
        }
        //cout << endl;
      }
      //cout << endl;
      CHMAX(ans,tmp);
    }
  }
  
  //cout << fixed << setprecision(10);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.string;
import std.range;
import std.array;
import std.conv;
import std.complex;
import std.math;
import std.ascii;
import std.bigint;
import std.container;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

const real eps = 1e-10;

long calc(long a, long b) {
    if(a > b) {
        swap(a, b);
    }
    if(b%a == 0) {
        return 2*b-a;
    } else {
        return 2*(b/a)*a + calc(a, b%a);
    }
}

void main(){
    long n, x;
    readlnTo(n, x);
    long ans = n + calc(x, n-x);
    writeln(ans);
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a;
  cin >> a;
  int vec[a];
  int ans = 0, now = 0;
  for (int i = 0; i < a; i++) {
    cin >> vec[i];
    vec[i]--;
  }
  for (;;) {
    if (now == 1) {
      cout << ans << endl;
      break;
    }
    else if (ans >= a) {
      cout << -1 << endl;
      break;
    }
    ans++;
    now = vec[now];
  }
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int n;
inline void g(int &x) 
{ 
    char ch=getchar(); bool mark=false; 
    for(;!isdigit(ch);ch=getchar())if(ch=='-')mark=true; 
    for(x=0;isdigit(ch);ch=getchar())x=x*10+ch-'0'; 
    if(mark)x=-x; 
} 
int main()
{
	int T=0;
	g(n);
	if(n>=1&&n<2){cout<<1;return 0;}
	if(n>=2&&n<4){cout<<2;return 0;}
	if(n>=4&&n<8){cout<<4;return 0;}
	if(n>=8&&n<16){cout<<8;return 0;}
	if(n>=16&&n<32){cout<<16;return 0;}
	if(n>=32&&n<64){cout<<32;return 0;}
	if(n>=64){cout<<64;return 0;}
}

Measured memory_bytes: 256
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res

N=II()
S=input()
s1 = set()
s2 = set()
res = 0
for i in range(1, N):
    for c in S[:i]:
        s1.add(c)
    for c in S[i:]:
        s2.add(c)
    res = max(len(s1.intersection(s2)), res)
    s1.clear()
    s2.clear()
print(res)


Measured memory_bytes: 3188
#include <cstring>
#include <cassert>
#include <utility>
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <bitset>
#include <chrono>
#include <cstdlib>
#include <functional>
#include <tuple>
#include <climits>
#include <limits>
#include <deque>
#include <list>
#include <array>
#include <stack>
#include <queue>
#include <random>
#include <complex>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
 
#define init ios::sync_with_stdio(0); cin.tie(NULL);cout.tie(NULL);
#define setpr(x) cout << setprecision((x))
#define PI atan(1)*4
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define mk(a , b) { min((a) , (b)) , max((a) , (b)) }
#define flush cout.flush()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endc "\n"
#define MOD 998244353
#define meme(x) memset((x), 0, sizeof((x)))
#define memo(x) memset((x),-1, sizeof((x)))
 
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pld;

// #define int ll

ll egcd(ll a, ll b, ll &x, ll &y){
    if (a == 0LL){  
        x = 0LL;  
        y = 1LL;  
        return b;  
    }
    ll xx, yy;
    ll val = egcd(b % a, a, xx, yy);  
    x = yy - (b / a) * xx;  
    y = xx;  
    return val;
}

ll gcd(ll a, ll b){
    while(true){
        if(a>b)
            swap(a,b);
        if (a == 0) 
            return b; 
        ll p = b % a  , q = a;
        a = p;
        b = q;
    }
}
 
ll powerMod(ll x,ll y){
    ll res = 1;
    x %= MOD;
    while(y > 0){
        if(y & 1)res = (res*x)%MOD;
        y = y >> 1;
        x = (x * x)%MOD;
    }
    return res%MOD;
}

//  ==========     //\\       //||     ||====//||
//      ||        //  \\        ||     ||   // ||
//      ||       //====\\       ||     ||  //  ||
//      ||      //      \\      ||     || //   ||
//  ========== //        \\  ========  ||//====|| 
//  code

void solve(){
    ll n,i,j,k,l,p,w;
    cin >> n >> w;
    vector< vector<ll> > dp(n + 1, vector<ll>(w + 1, 0));
    vector<ll> weights(n), values(n);
    for(i = 0; i < n; i++){
        cin >> weights[i] >> values[i];
    }

    for(j = 1; j <= w; j++){
        for(i = 0; i < n; i++){
            dp[i + 1][j] = dp[i][j];
            if(j >= weights[i]){
                dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - weights[i]] + values[i]);
            }
        }
    }
    cout << dp[n][w] << endc;
}

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


Measured memory_bytes: 83132
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include <string>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
map<int, int> mp;
map<int, int>mm;
#define ll long long
#define ld long double
#define PI 3.14159265358979l



int main() {

	int n, m, c;
	int b[20];
	int a[20][20];
	cin >> n >> m >> c;
	rep(i, m)cin >> b[i];
	rep(i, n) {
		rep(j, m)cin >> a[i][j];
	}
	int ans = 0;
	rep(i, n) {
		int cnt = 0;
		rep(j, m) {
			cnt += a[i][j] * b[j];
		}
		cnt += c;
		if (cnt > 0)ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ld double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
/*
    vec1.size();
    str1.length();
    vec1.pop_back;
*/
typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll, ll> pll;
typedef vector<pll> vplll;
#define rep(i,l,r) for (ll i = l; i < r; ++i)
#define reprev(i,l,r) for (ll i = r; i >= l; --i)
ll mod = 1e9+7;
ll expo_mod(ll x, ll y, ll p) 
{ 
    ll res = 1;
    x = x % p; 
    if (x == 0) 
        return 0; 
    while (y > 0) 
    {
        if (y%2==1) 
            res = (res*x) % p; 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
} 
ll gcd(ll a,ll b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,w;
    cin>>n>>w;
    ll weight[n+1],value[n+1];
    rep(i,1,n+1)
    {
        cin>>weight[i]>>value[i];
    }
    ll dp[n+1][w+1];
    rep(i,0,w+1)
    {
        dp[0][i]=0;
    }
    rep(i,0,n+1)
    {
        dp[i][0]=0;
    }
    rep(i,1,n+1)
    {
        rep(j,1,w+1)
        {
            if(j<weight[i])
            {
                dp[i][j]=dp[i-1][j];
            }
            else
            {
                dp[i][j]=max(dp[i-1][j],value[i]+dp[i-1][j-weight[i]]);
            }
        }
    }
    cout<<dp[n][w]<<"\n";
    return 0;
}

Measured memory_bytes: 79232
#include <cstdio>
using namespace std;
int main(void){
    char s[100];
    scanf("%s",s);
    if(s[0] == 'S') printf("Cloudy\n");
    else if(s[0] == 'C') printf("Rainy\n");
    else printf("Sunny\n");
    return 0;
}


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



int main(){
    long long int a,b,x;

    scanf("%lld %lld %lld",&a,&b,&x);

    if(a!=0)
       printf("%lld\n",(b/x)-((a-1)/x));
    else
        printf("%lld\n",b/x+1);


    return 0;
}



Measured memory_bytes: 128
// ######      ###      #######    #######    ##     #     #####        ###     ##### //
// #     #    #   #          #        #       # #    #    #     #      #   #     ###  //
// #     #   #     #        #         #       #  #   #   #       #    #     #    ###  //
// ######   #########      #          #       #   #  #   #           #########    #   //
// #     #  #       #     #           #       #    # #   #    ####   #       #    #   //
// #     #  #       #    #            #       #     ##   #    #  #   #       #        //
// ######   #       #   #######    #######    #      #    #####  #   #       #    #   //

// #pragma GCC optimize(2)
// #pragma GCC optimize(3)
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
// #pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define ain(a,n) for(ll i=0;i<(n);++i)	cin>>(a)[i];
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(ll i=0;i<(n);++i)
#define FOR(i,a,b) for(ll i=(a);i<=(b);++i)
#define FORD(i,a,b) for(ll i=(a);i>=(b);--i)
#define cases ll T=0;cin>>T;while(T--)
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define END "\n"
#define pb push_back
#define go(c,itr) for(auto itr=(c).begin(); itr!=(c).end(); ++itr)
#define back(c,itr) for(auto itr=(c).rbegin(); itr!=(c).rend(); ++itr)
#define PI 3.14159265359
#define inf 9e18
#define MOD 1000000007
#define MODU 998244353
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MAXN 1000005
#define PP pair<pair<ll,ll>,pair<pair<ll,ll>,ll>>
const string alpha = "abcdefghijklmnopqrstuvwxyz";
const ll N = 1e9;
ll binexp(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
void task(bool flag)
{
	if (flag)
		cout << "YES\n";
	else
		cout << "NO\n";
}
ll lcm(ll a, ll b)
{
	return ((1LL * a * b) / (__gcd(a, b)));
}

signed main() {

	fast
	// cases
	{
		ll n;
		cin >> n;
		vl a(n);
		ain(a, n);
		ll ans = 1;
		sort(all(a));
		const ll p = 1e18;
		loop(i, n)
		{
			if (a[i] <= (p / ans))
			{
				ans *= a[i];
			}
			else
			{
				ans = -1;
				break;
			}
			if (ans == 0)
				break;
		}
		cout << ans << END;
	}


// #ifndef ONLINE_JUDGE
// 	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
// #endif
	return 0;
}

Measured memory_bytes: 3972
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1;i<=n;i++)
int main(){int ans[4];int n,m,s,c;cin>>n>>m;rep(i,4)ans[i]=10;rep(i,m){cin>>s>>c;if(ans[s]==10||ans[s]==c)ans[s]=c;else{cout<<-1;return 0;}}if(n!=1&&ans[1]==0){cout<<-1;return 0;}rep(i,n)if(ans[i]==10)ans[i]=0;if(n!=1&&ans[1]==0)ans[1]++;rep(i,n)cout<<ans[i];}

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

int main(int argc, char const *argv[])
{
    int n,k,x,y;
    int price=0;
    cin >> n >> k >> x >> y;

    for(int i =1; i <= n; i++) {
        if (i <= k){
            price += x;
        } else {
            price += y;
        }
    }
    cout << price << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int i,j,n,u,k,v,A[100][100];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++) A[i][j]=0;
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      A[u-1][v-1]=1;
    }
  }

  for(i=0;i<n;i++){
    for(j=0;j<n-1;j++) printf("%d ",A[i][j]);
    printf("%d\n",A[i][n-1]);
  }

  return 0;
}

Measured memory_bytes: 636
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
using namespace std;

char a[55];
int main()
{
	scanf("%s", a );
	int len = strlen(a);
	for (int i = 0; i < len - 8; i++){
		printf("%c", a[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int n;
int main(){
	cin>>n;int t=0;
	for(int i=5000;i>=0;i--){
		int c=i*(i+1)/2;
		if(c<n){t=i+1;break;}
	}
	for(int i=t;i>=1;i--){
		if(n>=i){cout<<i<<endl;n-=i;}
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define first F
#define second S

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int l,a,b,c,d;
  cin>>l>>a>>b>>c>>d;
  int jpn=a/c+(a%c!=0);
  int math=b/d+(b%d!=0);
  cout<<l-max(jpn,math)<<endl;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(s) cout << (string)(s) << endl


int main(){
    ll a, b, k;
  cin >> a >> b >> k;
    ll c = k - a;
    if(k <= a){
        a -= k;
    }
    else if(a < k && k <= a+b && a + b - k > 0){
        a = 0;
        b -= c;
       
    }
    else{
        a = 0;
        b = 0;
    }
    cout << a << " " << b << endl;
}


Measured memory_bytes: 256
A,B,C,X,Y=map(int,input().split())
P=[X*A+Y*B]

if Y>=X:
  P.append(X*C*2+(Y-X)*min(B,C*2))
else:
  P.append(Y*C*2+(X-Y)*min(A,C*2))

print(min(P))

Measured memory_bytes: 3060