akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include<algorithm>

using namespace std;

int main(){
  
  int n,k,q;
  cin>>n>>k>>q;
  
  vector<int> v(n,0);
  
  for(int i=0;i<q;i++){
    int a;
    cin >>a;
    v[a-1]+=1;}
  
   for(int i=0;i<n;i++){
    if(k-q+v[i]>0){
      cout <<"Yes"<<endl;}
     else 
       cout <<"No"<<endl;
   }
  
}
  
  
 
  
 

Measured memory_bytes: 1024
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;


int main() {
	while (1) {
		string st; cin >> st;
		if (st == "-") {
			break;
		}
		else {
			int N; cin >> N;
			while (N--) {
				int a; cin >> a;
				string newst = st.substr(a) + st.substr(0, a);
				st = newst;
			}
			cout << st << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3220
#include <stdio.h>

int main(){
  int n, s, i, sum,max,min;

  scanf("%d",&n);

  while(n > 0){
    sum = 0;
    scanf("%d",&s);
    max=s;
    scanf("%d",&s);
    min=s;
    if (max<min){
      min=max;
      max=s;
    }
    for (i=2;i<n;i++){

      scanf("%d",&s);
      if (s>max){
	sum += max;
	max=s;
      }else if(s<min){
        sum +=min;
	min=s;
      }else{
	sum +=s;
      }
    }
    printf("%d\n",sum/(n-2));
    scanf("%d",&n);
  }
  return 0;
}

Measured memory_bytes: 600
h,w = map(int,input().split())
meiro = []
for i in range(h):
    meiro.append(list(input()))
#進む方向のリスト
d = [(1,0) , (-1,0) , (0,1),(0,-1)]
ans = 0

def search(n,m):
    ans = -1  #最後に次の層に行けなくても+1するから-1から
    
    X = [[0 for i in range(w)] for j in range(h)]  #探索判定用配列
    X[n][m] = 1#初期位置を到達済みにする
    que = [(n,m)]#初期位置をキューに追加
    while que:#キューがからでないなら
        new_que = []#深さ+1で到達済みの点を次のqueにする
        for x,y in que:
            for dx,dy in d:
                if 0<= x+dx < h and 0<= y+dy < w and meiro[x+dx][y+dy] == '.' and X[x+dx][y+dy] == 0:
                    X[x+dx][y+dy] = 1
                    new_que.append((x+dx , y+dy))
        ans += 1
        que = new_que
    return ans

for i in range(h):
    for j in range(w):
        if meiro[i][j] == '.':
            ans = max(ans , search(i,j))
            
print(ans)
        

Measured memory_bytes: 3064
package main

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

func nextLine() string {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	return sc.Text()
}

func main() {
	line := nextLine()
	abs := strings.Split(line, " ")
	a, _ := strconv.Atoi(abs[0])
	b, _ := strconv.Atoi(abs[1])

	if a <= 5 {
		fmt.Print("0")
	} else if a <= 12 {
		fmt.Print(b / 2)
	} else {
		fmt.Print(b)
	}
}


Measured memory_bytes: 640
#include<iostream>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	char X,Y;
	while (~scanf(" %c %c",&X,&Y)){
		if (X > Y)
			printf(">\n");
		else if (X < Y)
			printf("<\n");
		else
			printf("=\n");
	}
	return 0;
}

Measured memory_bytes: 256
import sys
import os
import math
import bisect
import collections
import itertools
import heapq
import re
import queue
from decimal import Decimal

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    A = il()

    ret, r, sm = 0, 0, 0
    for l in range(N):
        while r < N and (l == r or A[r] ^ sm == sm + A[r]):
            sm += A[r]
            r += 1

        ret += r - l
        if l == r:
            r += 1
        else:
            sm -= A[l]
    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 22436
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <bitset>
#include <functional>
using namespace std;
const constexpr int INF = 1e9;
//typedef std::pair<std::string,double> P;

long long L, R;
string s; 
void solve(){
    int cnt=0;
    stack<int> st;
    for(int i=0; i<s.size(); ++i){
        if(s[i]=='S'){
            st.push(1);
        }else if(s[i]=='T'){
            if(!st.empty()){
                st.pop(); cnt++;
            }
        }   
    }
    cout << s.size()-2*cnt << endl;
}
int main() {
    cin >> s;
    solve();
	return 0;
}

Measured memory_bytes: 900
# カンニングしました。。。。。。。。

def dfs(s: str, m: int):
    global n
    if len(s) == n:
        print(s)
    else:
        for c in range(ord('a'), m + 1):
            dfs(s + chr(c), m + 1 if c == m else m)


n = int(input())
dfs('', ord('a'))


Measured memory_bytes: 4340
//#pragma GCC optimize("03")
//#pragma GCC target("avx2")
 
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iomanip>
#include <utility>
#include <unordered_map>
#include <unordered_set>
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sqr(a) (a)*(a)
#define um unordered_map 
#define us unordered_set
using namespace std;
 
hash<string> hfn;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pld;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef double dbl;
typedef unsigned int ui;
const int inf = 2e9;
const ll mod = 1e9 + 7;
const ld eps = 1e-9;
const ll biginf = 1e18;
const ld pi = acosl(-1);

void solve()
{
  int n;
  cin >> n;
  vector<ld> p(n);
  for(auto& i : p)
    cin >> i;
  vector<vector<ld> > dp(n, vector<ld>(n+2, 0)), ps(n, vector<ld>(n+2, 0));
  dp[0][1] = p[0];
  ps[0][1] = p[0];
  for(int i = 1; i < n; i++)
  {
    for(int sz = i+1; sz >= 1; sz--)
    {
      dp[i][sz] = ((dp[i-1][sz-1] == 0) ? p[i] : ps[i-1][sz-1] * p[i]);;
      ps[i][sz] = dp[i][sz] + ps[i-1][sz] - dp[i][sz+1];
    }
  }
  /*for(int i = 0; i < n; i++)
  {
    cout << i+1 << "th: ";
    for(int sz = 0; sz <= n; sz++)
      cout << ps[i][sz] << " ";
    cout << endl;
  }*/
  ld s = 0;
  for(int sz = (n+1)/2; sz <= n; sz++)
    s += ps.back()[sz];
  cout << fixed << setprecision(10) << ps.back()[(n+1)/2];
}
 
void multisolve()
{
  int t;
  cin >> t;
  while(t--)
    solve();
}
 
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  //freopen("hull.in", "r", stdin);
  //freopen("hull.out", "w", stdout);
  solve();
  //multisolve();
}

Measured memory_bytes: 281856
import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
na = lambda : map(int, stdin.readline().split())
ni = lambda : int(ns())
def main():
  n = ni()
  f = lambda x: (x * (x+1)) // 2
  for i in range(1, n+1):
    if (f(i) >= n):
      print(i)
      return
main()

Measured memory_bytes: 3060
fun main(arr:Array<String>) {
    val s = readLine()!!
    for(i in s.indices) {
        if(i + 1 <= s.lastIndex) {
            if(s[i] == s[i+1]) {
                println("%s %s".format(i+1,i+2))
                return
            }
            if(i+2 <= s.lastIndex) {
                if(s[i] == s[i+2]) {
                    println("%s %s".format(i+1,i+3))
                    return
                }
            }
        } else {
            break
        }
    }
    println("-1 -1")

}


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

using namespace std;

typedef long long ll;
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(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#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, vector<T>& vec) {
    REP(i, vec.size()) {
        if(i) os << " ";
        os << vec[i];
    }
    return os;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin >> n;
    vector<ll> p(n); cin >> p;
    REP(i, n) --p[i];
    vector<vector<ll>> v(n);
    REP(i, n) {
        v[p[i]].pb(i);
    }
    vector<ll> ans(n, -1);
    stack<P> S;
    RREP(i, n) {
        S.push({i, 0});
        EACH(j, v[i]) {
            if (S.size() == 0 || S.top().second == 1) {
                S.push({j, 1});
            }
            else {
                ans[S.top().first] = j;
                S.pop();
            }
        }
    }
    int rest = S.size();
    assert(rest % 2 == 0);
    vector<int> ids;
    REP(i, rest) {
        assert(S.top().second == (i < rest/2 ? 0 : 1));
        ids.pb(S.top().first);
        S.pop();
    }
    assert(S.size() == 0);
    REP(i, rest/2) {
        assert(ans[ids[i]] < 0);
        ans[ids[i]] = ids[rest-i-1];
    }
    REP(i, n) cout << ans[i]+1 << endl;
}

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

using namespace std;

int main() {
	enum { M, A, R, C, H };
	long long int ch[5] = { 0,0,0,0,0 };
	long long int count = 0;
	int n, i, j, m;
	string s;

	cin >> n;

	for (i = 0; i < n; i++) {
		cin >> s;
		if (s[0] == 'M')
			ch[M]++;
		else if (s[0] == 'A')
			ch[A]++;
		else if (s[0] == 'R')
			ch[R]++;
		else if (s[0] == 'C')
			ch[C]++;
		else if (s[0] == 'H')
			ch[H]++;
	}

	for (i = 0; i < 5; i++) {
		if (ch[i] != 0) {
			count++;
		}
	}

	if (count < 3) {
		cout << 0;
	}
	else {
		count = 0;
		for (i = 0; i < 3; i++) {
			for (j = i + 1; j < 4; j++) {
				for (m = j + 1; m < 5; m++) {
					count += ch[i] * ch[j] * ch[m];
				}
			}
		}
		cout << count;
	}

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
  char  a[50][51], b[50][51];
  int  n, m, i, j, k, l, f=0;

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

  for(i=0; i <= n-m; i++){
    for(j=0; j <= n-m; j++){
      f = 0;
      for(k=0; k < m; k++){
        for(l=0; l < m; l++){
          if(a[i+k][j+l] == b[k][l]){
            f++;
          }
        }
      }
      if( f == m*m ){
        break;
      }
    }
    if( f == m*m ){
      break;
    }
  }

  if( f == m*m){
    printf("Yes\n");
  }else {
    printf("No\n");
  }

  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n;
  cin >> n;
  map<string,ll> cnt;
  for(ll i=0;i<n;i++) {
    string s;
    cin >> s;
    cnt[s]++;
  }
  cout << cnt.size() << endl;
}

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

int main(){
    int n,m;
    cin >> n >> m;
    int trial = 1900*m + 100*(n-m);
    cout << pow(2,m)*trial << endl;
    return 0;
}

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

int main(void) {
    int64_t X,Y,Z,tmp;

    cin >> X >> Y >> Z;

    swap(X,Y);
    swap(X,Z);    

    printf("%ld %ld %ld\n",X,Y,Z);    

    return 0;
}


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

using namespace std;
int main()
{
  vector<int> a(3);
  for(int i=0;i<3;i++) cin>>a.at(i);

  sort(a.begin(),a.end());

  int ans=(a.at(2)-a.at(1))+(a.at(1)-a.at(0));

  cout<<ans<<endl;


}


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

template<typename T>
struct Segtree{
	vector<T> node;
	int n;
	const T unit=(1ll<<31)-1;
	Segtree(vector<T> data):node(2*(1<<(int)ceil(log2(data.size()))),((1ll<<31)-1)){
		int sz = data.size();
		n = 1<<(int)ceil(log2(sz));
		for(int i=0; i<sz; i++){
			node.at(n+i) = data.at(i);
		}
		for(int i=n-1; i>0; i--){
			node.at(i) = comp( node.at(i*2),node.at(i*2+1) );
		}
	} 
	T comp(const T &a, const T &b){
		return min(a,b);
	}
	void update(int i, T v){
		i += n;
		node.at(i) = v;
		while(i/2){
			i /= 2;
			node.at(i) = comp( node.at(i*2),node.at(i*2+1) );
		}
		for(int i=0; i<node.size(); i++){
			//cout << node.at(i) << endl;
		}
		//cout << endl;
	}
	T find(int a, int b, int now=1, int l=0, int r=-1){
		if(r<0) r = n;
		if(r <= a || b <= l) return unit;
		if(a <= l && r <= b) return node.at(now);
		T lv = find(a, b, 2*now,   l, (l+r)/2);
		T rv = find(a, b, 2*now+1, (l+r)/2, r);
		return comp(lv, rv);
	}
};

int main(){
	int n,q; cin>>n>>q;
	vector<ll> data(n,(1ll<<31)-1);
	Segtree<ll> segtree(data);
	for(int i=0; i<q; i++){
		int q0; cin>>q0;
		if(q0==0){
			int x,y; cin>>x>>y;
			segtree.update(x,y);
		}
		else{
			int x,y; cin>>x>>y;
			cout << segtree.find(x,++y) << '\n';
		}
		
	}
	cout << flush;
	
}


Measured memory_bytes: 6780
#include <stdio.h>

int main()
{
  int n,i,j,a,flag,cnt=0;

  scanf("%d",&n);

  int A[n];

  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  for(i=0;i<n;i++){
    for(j=n-1;j>i;j--){
      if(A[j]<A[j-1]){
	a=A[j-1];
	A[j-1]=A[j];
	A[j]=a;
	cnt++;
      }
    }
  }

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



Measured memory_bytes: 2104
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
b = [(a[i], i) for i in range(N)]
b.sort()
res = [0] * pow(N, 2)
for i in range(N): res[a[i] - 1] = i + 1
#print(res, b)
for k in range(N):
  i = b[k][1]
  x = i
  if i == 0: continue
  for j in range(a[i] - 1):
    if res[j]: continue
    res[j] = i + 1
    x -= 1
    if x == 0: break
  #print(res, i, a[i])
  if x:
    print("No")
    exit(0)
  #print(res)
#print(res)
for i in range(N):
  x = N - i - 1
  for j in range(a[i], N ** 2):
    if res[j]: continue
    res[j] = i + 1
    x -= 1
    if x == 0: break
  #print(res)
  if x:
    print("No")
    exit(0)
print("Yes")
print(*res)

Measured memory_bytes: 57564
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using i64 = int64_t;
using ll = long long;
int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  vector<ll> B(N);
  rep(i,N){
    cin >> A.at(i);
    B.at(i) = A.at(i); 
  }
  sort(B.begin(),B.end());
  ll P,Q;
  P = B.at(N/2-1);
  Q = B.at(N/2);
  rep(i,N){
    if(A.at(i) <= P){
      cout << Q << endl;
    }
    else if(A.at(i) >= Q){
      cout << P << endl;
    }
  }
  return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif


void Main() {
    ll A, B; cin >> A >> B;
    if (1 <= A && A <= 9 && 1 <= B && B <= 9){
        cout << A * B << endl;
    } else {
        cout << -1 << endl;
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {

	var n string
	fmt.Scan(&n)

	switch n {
	case "SUN":
		fmt.Println(7)
	case "MON":
		fmt.Println(6)
	case "TUE":
		fmt.Println(5)
	case "WED":
		fmt.Println(4)
	case "THU":
		fmt.Println(3)
	case "FRI":
		fmt.Println(2)
	case "SAT":
		fmt.Println(1)
	}
}


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

int main()
{
    int a,b;
    cin>>a>>b;
    double fa=a,fb=b;
    cout<<fixed;
    cout<<setprecision(8)<<(a/b)<<" "<<(a%b)<<" "<<(fa/fb);
    cout<<"\n";
    return 0;
}




Measured memory_bytes: 3288
// In the Name of Allah
// Ya Ali

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define F first
#define S second
#define all( x ) x.begin() , x.end()
#define pb push_back
#define mp make_pair

const int maxn = 1e5 + 10 ;
const int mod = 998244353 ;
const int INF = 1e18 ;

int n , a , aa , bb , cc , ans1 = 0 , ans2 = 0 ;
string s ;

signed main()
{
 ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0) ;

 cin >> a ;
 cin >> s ;
 aa = s[ 0 ] - '0' ;
 bb = s[ 2 ] - '0' ;
 cc = s[ 3 ] - '0' ;

 ans1 = a*aa ;
 ans2 = (a*( bb*10 + cc ))/100 ;

 cout << ans1 + ans2 ;

    return 0;
}


Measured memory_bytes: 3652
package main

import (
	"fmt"
)

const N = 100000

func main() {
	isPrime := make([]bool, N+1)
	for i := range isPrime {
		isPrime[i] = true
	}
	isPrime[0] = false
	isPrime[1] = false
	for i := 2; i <= N; i++ {
		if !isPrime[i] {
			continue
		}
		for j := i * 2; j <= N; j += i {
			isPrime[j] = false
		}
	}

	s := make([]int, N+1)
	for i := 0; i < N; i++ {
		x := 0
		if isPrime[i] && isPrime[(i+1)/2] {
			x = 1
		}
		s[i+1] = s[i] + x
	}

	var q int
	fmt.Scan(&q)
	var l, r int
	for i := 0; i < q; i++ {
		fmt.Scan(&l, &r)
		r++
		fmt.Println(s[r] - s[l])
	}
}


Measured memory_bytes: 7940
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main(){

	long long n,m,l,A[100][100],B[100][100],C[100][100];
	int i,j,k,sum;

	cin >> n >> m >> l;

	//Initialization
	for(i=0;i<100;i++){
		for(j=0;j<100;j++){
			A[i][j] = 0;
			B[i][j] = 0;
			C[i][j] = 0;
		}
	}

	//Input A
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			cin >> A[i][j];
		}
	}
	//Input B
	for(i=0;i<m;i++){
		for(j=0;j<l;j++){
			cin >> B[i][j];
		}
	}

	//Calculation C
	for(i=0;i<n;i++){
		for(j=0;j<l;j++){
			for(k=0;k<m;k++){
				C[i][j] += A[i][k] * B[k][j];
			}
		}
	}

	//Print C
	for(i=0;i<n;i++){
		for(j=0;j<l;j++){
			cout << C[i][j];
			if(j == l-1);
			else cout << " ";
		}
		cout << endl;
	}


	return 0;
}


Measured memory_bytes: 3364
L = input()
N = len(L)
mod = 10 ** 9 + 7
dp = [[0] * 2 for _ in range(N + 10)]

dp[0][0] = 1
for i in range(1, N + 1):
    s = L[i - 1]
    if s == "1":
        dp[i][0] += 2 * dp[i - 1][0] % mod
        dp[i][1] += dp[i - 1][0] % mod
    else:
        dp[i][0] += dp[i - 1][0] % mod

    dp[i][1] += dp[i - 1][1] * 3 % mod

print((dp[N][0] + dp[N][1]) % mod)


Measured memory_bytes: 19680
#include<bits/stdc++.h>
using namespace std;
int n,a[100001],sum;
int main()
{
cin>>n;
for(int i=1;i<=n;i++)cin>>a[i];
sort(a+1,a+n+1);
for(int i=1;i<n;i++)sum+=a[i];
cout<<sum+a[n]/2<<endl;
return 0;
}

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

using namespace std;

#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
static const ll maxLL = (ll) 1 << 62;
const ll MOD = 1000000007, INF = 1e18;

template<typename T1, typename T2>
bool pairCompare(const pair<T1, T2> &firstElof, const pair<T1, T2> &secondElof) {
    return firstElof.second > secondElof.second;
}

int mapMaxValue(std::map<ll, int> m) {
    int max = 0;
    for (std::map<ll, int>::iterator it = m.begin(); it != m.end(); it++) {
        if (max < it->second) max = it->second;
    }
    return max;
}

int main(void) {
    int n;
    cin >> n;
    int ans = 1;
    for (int i = 0; i < 3; ++i) {
        ans *= n;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define mod 1000000007
#define exp pow(10,-9)
#define F first
#define S second
#define PB push_back 
#define MP make_pair
#define daman ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define lowercase(str) transform(str.begin(), str.end(), str.begin(), ::tolower);
#define uppercase(str) transform(str.begin(), str.end(), str.begin(), ::toupper);
main(){
	daman;
	int n;
	cin>>n;
	lli arr[n];
	lli xorr = 0;
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
		xorr ^= arr[i];
	}
	
	for(int i=0;i<n;i++)
	{
		lli ans = xorr^arr[i];
		cout<<ans<<" ";
	}
	cout<<"\n";
}

Measured memory_bytes: 5112
#include<bits/stdc++.h>
using namespace std;
int x[109],y[109];

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  for(int i=a;i<b;i++){
    x[i]=1;
  }
  for(int i=c;i<d;i++){
    y[i]=1;
  }
  int ans=0;
  for(int i=0;i<=100;i++){
    if(x[i]==1&&y[i]==1)ans++;
  }
  cout<<ans<<endl;
  return(0);
}


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

from bisect import bisect_left

N, K = map(int, input().split())
A = list(map(int, input().split()))

indexes = {}
for i, a in enumerate(A):
    if not a in indexes.keys():
        indexes[a] = [i]
    else:
        indexes[a].append(i)

L = [N]
ind = N
while True:
    ind = (ind+1)%(N+1)
    if ind == N: break
    a = A[ind]
    if indexes[a][-1] == ind:
        ind = indexes[a][0]
        L.append(ind)
    else:
        loc = bisect_left(indexes[a], ind)
        ind = indexes[a][loc+1]
    

start_ind = L[(K-1)%len(L)] + 1
if start_ind == N+1: start_ind = 0
in_list = {}
for a in A:
    in_list[a] = 0
ans = []
for i in range(start_ind, N):
    a = A[i]
    if in_list[a] == 0:
        ans.append(a)
        in_list[a] = 1
    else:
        while True:
            b = ans.pop()
            in_list[b] -= 1
            if a == b:
                break

for a in ans:
    print(a, end=' ')
print()


Measured memory_bytes: 74684
a_list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(a_list[int(input())-1])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  ll x;
  cin>>x;
  ll ans=0;
  ans+=x/500*1000;
  x%=500;
  ans+=x/5*5;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<unordered_set>
#include<unordered_map>
#include<set>
#include<map>
#include<list>

using namespace std;

#define in(s) cin >> s
#define out(s) cout << s << endl
#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define MOD 1000000007

#define IMIN INT_MIN;
#define IMAX INT_MAX;


int main(){
    int K, A, B;
    in(K); in(A); in(B);
    bool flag = false;
    for (int i=A; i<=B; i++) {
        if (i % K == 0) {
            flag = true;
        }
    }
    cout << ((flag)? "OK":"NG") << endl;

	return 0;
}


Measured memory_bytes: 3600
n = int(input())
s = list(input())
a = s.count("E")
b1 = 0
t = 10000000000000
for i in range(n):
    if s[i] == "E":
        a -= 1
        c = b1 + a
    else:
        c = b1 + a
        b1 += 1
    if t > c:
        t = c
print(t)

Measured memory_bytes: 64112
H,W=map(int,input().split())
N=int(input())
a=list(map(int,input().split()))
G=[[0]*W for i in range(H)]
tate,yoko,now=0,0,0
rev=False
cnt=0
while(cnt<H*W):
    G[tate][yoko]=now+1
    a[now]-=1
    if(a[now]==0):
        now+=1
    if(not rev):
        if(tate<H-1):
            tate+=1
        else:
            yoko+=1
            rev=not rev
    else:
        if(tate>0):
            tate-=1
        else:
            yoko+=1
            rev=not rev
    cnt+=1
    
    
for i in range(H):
    print(*G[i])

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a,b;
	string s;
	cin>>n>>a>>b>>s;
	int jap=0,over=0;
	for(int i=0;i<n;i++)
		if(jap+over<a+b&&s[i]=='a')
			cout<<"Yes"<<endl,jap++;
		else if(jap+over<a+b&&over<b&&s[i]=='b')
			cout<<"Yes"<<endl,over++;
		else
			cout<<"No"<<endl;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 102000;
int n;ll a[N],ans[N],mn[N][18];map<ll,ll>Map[N];
inline int findpre(int i, ll x){//lst(<i) val<x
	i--;per(j,17,0)if(i-(1<<j)+1>=0&&mn[i-(1<<j)+1][j]>x)i-=1<<j;
	if(i<0)return 0;
	if(a[i]<x)return i;
	return max(0,i-1);
}
int main() {//freopen("1.in","r",stdin);freopen("1.out","w",stdout);
	int orilen;read(orilen);read(n);rep(i,1,n)read(a[i]);a[0]=orilen;
	rep(i,0,n)mn[i][0]=a[i];
	rep(j,1,17)rep(i,0,n-(1<<j)+1)mn[i][j]=min(mn[i][j-1],mn[i+(1<<j-1)][j-1]);
	Map[n][a[n]]=1;
	per(i,n,1){
	for(map<ll,ll>::iterator it=Map[i].begin();it!=Map[i].end();it++){
			ll len=(*it).fi,xs=(*it).se;
			int j=findpre(i,len);//printf("%d-->%d(%lld)\n",i,j,len);
			if(a[j]<len){Map[j][len%a[j]]+=xs;Map[j][a[j]]+=xs*(len/a[j]);}
			else Map[j][len]+=xs;
		}
		//Map[i-1][len]+=xs;
	}
//	if(i<=200)cerr<<i<<' '<<SZ(Map[i])<<endl;
	for(map<ll,ll>::iterator it=Map[0].begin();it!=Map[0].end();it++)
		ans[(*it).fi]+=(*it).se;
	per(i,orilen,1)ans[i]+=ans[i+1];
	rep(i,1,orilen)printf("%lld\n",ans[i]);
	int tot=0;rep(i,0,n)tot+=SZ(Map[i]);cerr<<tot;
	return 0;
}


Measured memory_bytes: 49280
N,x = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
for i in range(N-1):
    if a[i] + a[i+1] > x:
        y = a[i] + a[i+1] - x
        ans += y
        a[i+1] = max(0,a[i+1]-y)
print(ans)

Measured memory_bytes: 19924
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
typedef long long ll;
int i;
int main() {
int N, M; cin >> N >> M;

vector<ll> A(N), B(M), C(M);
rep(i, N) cin >> A[i];
priority_queue<pair<int, int>> g;
rep(i, N) g.push(make_pair(A[i], 1));

  rep(i, M) {cin >> B[i] >> C[i];
  
     g.push(make_pair(C[i], B[i]));
} 
ll ans = 0;
rep(i, N) {

auto p = g.top();
g.pop();

ans+=p.first;
if(p.second>1) {
     p.second--;
     g.push(p);
}

}
     cout << ans << endl;
}


Measured memory_bytes: 4724
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <stack>
#include <queue>
#include <list>
#include <cstdlib>
#include <cmath>

#define _USE_MATH_DEFINES
#define REP(i,n) for(i = 0;i<n;i++)

using namespace std;


int main() {

	int a, b;

	cin >> a >> b;

	if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)
		cout << "Possible" << endl;
	else
		cout << "Impossible" << endl;

	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
#define lint long long int
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
*/

int main() {
	int N;
	cin >> N;
	vector<int>vec(N);
	for (int ia = 0; ia < N; ia++) {
		cin >> vec.at(ia);
	}
	int ans = 0;
	for (int ib = 0; ib < N; ib++) {
		ans += vec.at(ib);
	}
	cout << ans - N << endl;
}



Measured memory_bytes: 256
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
  int dt[3][3];
  char c;
  while(1){
    bool cnt=true;
    bool br=false;
    rep(i,3){
      rep(j,3){
	cin>>c;
	if(c=='0'){
	  br=true;
	  break;
	}
	if(c=='b')dt[i][j]=2;
	else if(c=='w')dt[i][j]=1;
	else dt[i][j]=0;
      }
      if(br)break;
    }
    if(br)break;
    rep(i,3){
      if(dt[i][0]==dt[i][1] && dt[i][1]==dt[i][2]){
	if(dt[i][0]==1){
	  if(cnt)cout<<'w'<<endl;
	  cnt=false;
	}else if(dt[i][0]==2){
	  if(cnt)cout<<'b'<<endl;
	  cnt=false;
	}
      }
      if(dt[0][i]==dt[1][i] && dt[1][i]==dt[2][i]){
	if(dt[0][i]==1){
	  if(cnt)cout<<'w'<<endl;
	  cnt=false;
	}else if(dt[0][i]==2){
	  if(cnt)cout<<'b'<<endl;
	  cnt=false;
	}
      }
    }
    if((dt[0][0]==dt[1][1] && dt[1][1]==dt[2][2]) || (dt[2][0]==dt[1][1] && dt[1][1]==dt[0][2])){
      if(dt[1][1]==1){
	if(cnt)cout<<'w'<<endl;
	cnt=false;
      }else if(dt[1][1]==2){
	if(cnt)cout<<'b'<<endl;
	cnt=false;
      }
    }
    if(cnt)cout<<"NA"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1132
Module Main

    Sub Main()

        Dim s As String = String.Empty
        Dim cnt As Integer = 0

        '入力値取得
        s = Console.ReadLine()

        For i As Integer = 0 To s.Length - 1
            If s(i) = "1"c Then
                cnt += 1
            End If
        Next

        '処理結果出力
        Console.WriteLine(cnt.ToString)

    End Sub

End Module

Measured memory_bytes: 11092
#include<stdio.h>
int main(void){
    int N = 0;
    scanf("%d",&N);
    if(N == 1){
        printf("Hello World\n");
    }else if(N == 2){
        int A= 0, B = 0;
        scanf("%d",&A); scanf("%d",&B);
        printf("%d\n",(A+B));
    }

    return 0;
}

Measured memory_bytes: 128
//abc167

#include <bits/stdc++.h>
#include <string>
using namespace std;

int main() {

  int a,b,c,k;
  cin >> a >> b >> c >> k;

  if(k < a){
    cout << k << endl;
  }else if(k <= a + b){
    cout << a << endl;
  }else{
    cout << a - (k - a - b) << endl;
  }

}


Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
#define cs const
#define re register
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define y1 shinkle
#define fi first
#define se second
#define bg begin
namespace IO{
	
cs int RLEN=1<<20|1;
char ibuf[RLEN],*ib,*ob;
inline char gc(){
    (ib==ob)&&(ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
    return (ib==ob)?EOF:*ib++;
}
inline int read(){
    char ch=gc();
    int res=0;bool f=1;
    while(!isdigit(ch))f^=ch=='-',ch=gc();
    while(isdigit(ch))res=(res*10)+(ch^48),ch=gc();
    return f?res:-res;
}
inline ll readll(){
    char ch=gc();
    ll res=0;bool f=1;
    while(!isdigit(ch))f^=ch=='-',ch=gc();
    while(isdigit(ch))res=(res*10)+(ch^48),ch=gc();
    return f?res:-res;
}
inline char readchar(){
	char ch=gc();
	while(isspace(ch))ch=gc();
	return ch;
}
inline int readstring(char *s){
	int top=0;char ch=gc();
	while(isspace(ch))ch=gc();
	while(!isspace(ch)&&ch!=EOF)s[++top]=ch,ch=gc();
	s[top+1]='\0';return top;
}

}
using IO::read;
using IO::readll;
using IO::readchar;
using IO::readstring;
template<typename tp>inline void chemx(tp &a,tp b){a=max(a,b);}
template<typename tp>inline void chemn(tp &a,tp b){a=min(a,b);}
int mod;
inline int add(int a,int b){return (a+b)>=mod?(a+b-mod):(a+b);}
inline int dec(int a,int b){return (a<b)?(a-b+mod):(a-b);}
inline int mul(int a,int b){static ll r;r=(ll)a*b;return (r>=mod)?(r%mod):r;}
inline void Add(int &a,int b){a=(a+b)>=mod?(a+b-mod):(a+b);}
inline void Dec(int &a,int b){a=(a<b)?(a-b+mod):(a-b);}
inline void Mul(int &a,int b){static ll r;r=(ll)a*b;a=(r>=mod)?(r%mod):r;}
inline int ksm(int a,int b,int res=1){for(;b;b>>=1,Mul(a,a))(b&1)&&(Mul(res,a),1);return res;}
inline int Inv(int x){return ksm(x,mod-2);}
cs int N=305;
int f[N][N][N],n,m;
int main(){
	#ifdef Stargazer
	freopen("lx.in","r",stdin);
	#endif
	n=read(),m=read(),mod=read();
	f[0][1][0]=1;
	for(int i=0;i<=n;i++)
	for(int j=1;j<=m;j++)
	for(int k=i;~k;k--){
		if(k)Add(f[i][j][k-1],f[i][j][k]);
		else Add(f[i][j+1][i],f[i][j][k]);
		Add(f[i+1][j][k],mul(f[i][j][k],k+1));
	}cout<<f[n][m][0];return 0;
}

Measured memory_bytes: 110976
#include <iostream>
#include <cstdlib>
#include <stack>

using namespace std;

bool op_stack(stack<int>& s, int& a, int& b)
{
  if (s.size() < 2) return false;
  a = s.top();
  s.pop();
  b = s.top();
  s.pop();

  return true;
}

int main()
{
  stack<int> calc;
  int a, b;
  string op_or_num;

  while (cin >> op_or_num) {
    if (op_or_num[0] == '+') {
      if (!op_stack(calc, a, b)) return 1;
      calc.push(a + b);
    } else if (op_or_num[0] == '-') {
      if (!op_stack(calc, a, b)) return 1;
      calc.push(b - a);
    } else if (op_or_num[0] == '*') {
      if (!op_stack(calc, a, b)) return 1;
      calc.push(a * b);
    } else {
      calc.push(atoi(op_or_num.c_str()));
    }
  }

  cout << calc.top() << endl;
}
  



Measured memory_bytes: 3168
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef long long LL;
//typedef LL int;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
    int n;
    cin >> n;
    vector<LL> a;
    
    REP(i, n){
        int x;
        cin >> x;
        a.pb(x);
    }

    LL sunuke = 0, arai = 0;
 
    LL ans = 9999999999;
    REP(i, n){
        sunuke += a[i]; 
    }

    REP(i, n-1){
        sunuke -= a[i];
        arai += a[i];
        ans = min(ans, abs(sunuke - arai));
    }
    cout << ans << endl;

}


Measured memory_bytes: 2420
<?php
$server = "php://stdin";
$local = "input.txt";
$handle = fopen($server, "r");
$x = trim(fgets($handle));
$a=explode(' ',$x);$t='';
if($a[1]<=$a[0])
{

    for($i=0;$i<$a[0];$i++)
    {
        $t.=$a[1];
    }
}else
{
    for($i=0;$i<$a[1];$i++)
    {
        $t.=$a[0];
    }

}
echo $t;
?>

Measured memory_bytes: 4856
n,k=map(int,input().split())
e=[[]for _ in range(n+1)]
for _ in range(n-1):
  a,b=map(int,input().split())
  e[a]+=[b]
  e[b]+=[a]
mod=10**9+7
vis=[1]*(n+1)
vis[1]=0
q=[1]
ans=k
while q:
  now=q.pop()
  i=0
  for to in e[now]:
    if vis[to]:
      vis[to]=0
      ans*=max(k-i-1-(now!=1),0)
      ans%=mod
      q+=[to]
      i+=1
print(ans)

Measured memory_bytes: 96684
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n, r;
    cin >> n >> r;
    if(n < 10) {
        r += 100 * (10-n);
    }
    cout << r << endl;
}


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

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589
#define MOD 1000000007

using namespace std;

template<typename T> T gcd(T a, T b){return (a % b)? gcd(b, a % b) : b;}
template<typename T> T lcm(T a, T b){return a * b / gcd(a, b);}

int main(void){
    int n;
    cin >> n;
    int a[n];
    REP(i,n) cin >> a[i];

    int ctr = 0;
    while(1){
        bool exist = true;
        REP(i,n){
            if(a[i] % 2 == 1){
                exist = false;
            }
        }
        if(exist){
            REP(i,n) a[i] /= 2;
            ctr++;
        } else break;
    }
    cout << ctr << endl;
    return 0;
}

Measured memory_bytes: 3560
/*
Original problem: 
Author: sammochen
*/

#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

using namespace std;

#define REP(x,l,u) for(ll x = l;x<u;x++)
#define RREP(x,l,u) for(ll x = l;x>=u;x--)

#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef vector<ll> VLL;
typedef vector<int> VI;

const int inf = 1e9+7;

namespace SOLVE {
	void main() {
		ll n, w, a, b;
        cin >> n >> w;
        vector<PLL> objs(n);

        REP(i,0,n){
            cin >> a >> b;
            objs[i] = MP(a,b);
        }
        // maximum value is 100000
        // dp[i] is the smallest weight of a value - if dp[i] = inf not possible
        VLL dp(100001, inf); 
        dp[0] = 0;
        REP(i,0,n) {
            RREP(oldv, 100000, 0) {
                if (dp[oldv] != -1) { // then i can possibly add something to it
                    ll oldw = dp[oldv];
                    ll neww = oldw + objs[i].first;
                    ll newv = oldv + objs[i].second;

                    if (neww <= w) {
                        dp[newv] = min(dp[newv], neww); 
                    }
                }
            }
        }

        
        RREP(v, 100000, 0) {
            if (dp[v] != inf) {
                cout << v << endl;
                return;
            }
        }
        cout << -1 << endl;
        return;
	}
}


signed main() {
	int t;
	t = 1;
	// cin >> t;
	while (t--) {
		SOLVE::main();
	}

	return 0;
}

Measured memory_bytes: 1024
import itertools
N = int(input())
*L, = map(int, input().split())
ans = 0
for l in itertools.combinations(L, 3):
    l = list(l)
    l.sort()
    if l[0] != l[1] and l[1] != l[2] and l[0] != l[2]:
        if l[2] < (l[0]+l[1]):
            ans += 1
print(ans)


Measured memory_bytes: 68200
import itertools

N = int(input())

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

cntP = 0
cntQ = 0

for i in itertools.permutations(range(1,N+1)):
    if i == P:
        break
    cntP += 1

for i in itertools.permutations(range(1,N+1)):
    if i == Q:
        break
    cntQ += 1

print(abs(cntP - cntQ))

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

int main(){
	int n;
	cin>>n;
	double sum=0;
	for(int i=0;i<n;i++){
		int k;
		cin>>k;
		sum+=1.0/k;
	}
	printf("%lf",1.0/sum);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n,k;
	scanf("%d %d",&n,&k);
	int input[n+1];
	for(int i = 0;i<n;i++)
	{
		scanf("%d",&input[i]);
	}
	int beda = n-k;
	for(int i = 0;i<beda;i++,k++)
	{
		if(input[k] > input[i])
		{
			puts("Yes");
		}	
		else{
			puts("No");
		}
	}
return 0;
}

Measured memory_bytes: 2412
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
#include <cassert>
#include <unordered_map>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const ld PI = 3.14159265358979323846;
const ll MOD = 1e9 + 7;


int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll n, k;
	cin >> n >> k;
	vector<vector<int>> g(n);
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		x--;
		g[i].push_back(x);
	}
	vector<int> used(n), cnt(n + 1);
	int cur = 0;
	cnt[0] = 0;
	used[0] = 1;
	ll need = k;
	for (int i = 0; i < n; i++) {
		cur = g[cur][0];
		if (used[cur]) {
			int len = i + 1 - cnt[cur];
			k = (k - cnt[cur]) % len + cnt[cur];
			for (int j = 0; j < n; j++) {
				if (cnt[j] == k) {
					cout << j + 1;
					return 0;
				}
			}
		}
		else{	
			cnt[cur] = i + 1;
			used[cur] = 1;
			if (i + 1 == k) {
				cout << cur + 1;
				return 0;
			}
		}

	}
}

Measured memory_bytes: 15788
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define int ll


string s;
int k;

signed main(){
  cin>>s>>k;

  rep(i,s.size()){
    if(s[i]!='1'){
      cout<<s[i]<<endl;
      return 0;
    }
    if(i+1==k){
      cout<<s[i]<<endl;
      return 0;
    }
  }

  cout<<1<<endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  ll N,M;
  cin >> N >> M;
  vl A(N);
  rep(i,N) {
    cin >> A[i];
  }
  sort(rng(A));
  ll l=0,r=INF;
  while(l+1<r) {
    ll m = (l+r)/2;
    ll cnt = 0;
    rep(i,N) {
      auto itr = lower_bound(rng(A),m-A[i]);
      cnt += N - (itr-A.begin());
    }
    if(cnt>=M) {
      l = m;
    } else {
      r = m;
    }
  }
  vl sum(N+1,0);
  rep(i,N) {
    sum[i+1] = sum[i];
    sum[i+1] += A[i];
  }
  ll ans = 0;
  ll rem = M;
  rep(i,N) {
    auto itr = lower_bound(rng(A),r-A[i]);
    ll exc = itr-A.begin();
    ans += sum[N] - sum[exc];
    ans += A[i]*(N - exc);
    rem -= N - exc;
  }
  ans += rem*l;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;i++)
const ll INF=1e15;
const ll MOD=1000000007;

int main(){
    int N,M;cin>>N>>M;
    vector<vector<int>> info(M);
    rep(i,M){
        int k;cin>>k;
        rep(j,k){
            int s;cin>>s;
            info.at(i).push_back(s);
        }
    }
    int check[M];
    rep(i,M)cin>>check[i];
    int count=0,ans=0;
    rep(bit,1<<N){
        count=0;
        rep(i,M){
            int now=0;
            rep(j,info.at(i).size())if(bit & (1<<(info.at(i).at(j)-1)))now++;
            if(now%2==check[i])count++;
        }
        if(count==M)ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define NUMBER 10000
int main(void){
  int  i,num;
  int a[NUMBER];
  scanf("%d",&num);

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

  int min;
  long max,sum;
  min=max=sum=a[0];
  for(i=1;i<num;i++){
      if(a[i]>max){
      max=a[i];}
      if(a[i]<min){
      min=a[i];}
      sum+=a[i];
  }
  printf("%d %ld %ld\n",min,max,sum);
  return 0;
}


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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

ll n,h;
pair<ll,ll> a[maxn];
ll hit;


bool good(ll x) {
  ll left = max(0LL, x-n);
  ll H = h;
  H -= left*hit;
  x -= left;
  for (int i=0; i<min(x,n); i++) {
    H -= a[i].first;
  }
  return H<=0;
}

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

  cin>>n>>h;
  for (int i=0; i<n; i++) {
    cin>>a[i].second>>a[i].first;
    hit = max(hit, a[i].second);
  }
  sort(a,a+n);
  reverse(a,a+n);
  while (n-1>=0 && a[n-1].first<hit) {
    n--;
  }

  ll lo = 0;
  ll hi = 1e9+10;
  while (hi - lo > 1) {
    ll mid = (lo + hi) / 2;
    if (good(mid)) {
      hi = mid;
    } else {
      lo = mid;
    }
  }

  cout<<hi<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
int main(void){
    int N, i;
    scanf("%d",&N);
    int A,B[N+1];
    for(i=0;i<N+1;i++){
        B[i] = 0;
    }
    for(i=0;i<N-1;i++){
        scanf("%d",&A);
        B[A]+=1; 
    }
    for(i=0;i<N;i++){
        printf("%d\n",B[i+1]);
    }
return 0;
}

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

int main() {
  double H, W, x, y;
  cin >> W >> H >> x >> y;
  if (W/2 == x && H/2 == y){
    cout << (W*H)/2 << " " << 1 << endl;;
  }
  else cout << (W*H)/2 << " " << 0 << endl;;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 10007;
static const int INF = 1 << 25;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { 1, -1, 0, 0,  1, -1,  1, -1 };
static const int dy[] = { 0, 0, 1, -1 , 1,  1, -1, -1 };

int n;
string str;

PII many_push;
int ans;
pair<bool, bool> now;

int gcd( int m, int n ) {
	if ( n == 0 ) return m;
	return gcd( n, m % n );
}

int main() {
	
	while ( ~scanf( "%d", &n ) && n ) {
		ans = 0;
		now = make_pair( false, false );
		for ( int i = 0; i < n; i++ ) {
			cin >> str;
			if ( str == "lu" ) {
				now.first = true;
				ans += now.second && !( ans % 2 );
				continue;
			}
			if ( str == "ru" ) {
				now.second = true;
				ans += now.first && !( ans % 2 );
				continue;
			}
			if ( str == "ld" ) {
				now.first = false;
				ans += !now.second && ans % 2;
				continue;
			}
			if ( str == "rd" ) {
				now.second = false;
				ans += !now.first && ans % 2;
				continue;
			}
		}
		printf( "%d\n", ans );
	}
	return 0;
}

Measured memory_bytes: 1240