akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define MOD 1000000007

typedef int Weight;
struct Edge {
	int src, dst;
	Weight weight;
	Edge(int src, int dst, Weight weight) :
		src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

bool augment(const Graph& g, int u,
	vector<int>& matchTo, vector<bool>& visited) {
	if (u < 0) return true;
	REP(i, g[u].size()) {
		auto e = g[u][i];
		if (visited[e.dst]) continue;
		visited[e.dst] = true;
		if (augment(g, matchTo[e.dst], matchTo, visited)) {
			matchTo[e.src] = e.dst;
			matchTo[e.dst] = e.src;
			return true;
		}
	}
	return false;
}

int bipartiteMatching(const Graph& g, int L, Edges& matching) {
	const int n = g.size();
	vector<int> matchTo(n, -1);
	int match = 0;
	REP(u, L) {
		vector<bool> visited(n);
		if (augment(g, u, matchTo, visited)) ++match;
	}
	REP(u, L) if (matchTo[u] >= 0) // make explicit matching
		matching.push_back(Edge(u, matchTo[u], 1));
	return match;
}

int a[111], b[111], c[111], d[111];

int main() {
	int n;
	cin >> n;
	REP(i, n)scanf("%d%d", a + i, b + i);
	REP(i, n)scanf("%d%d", c + i, d + i);
	Graph g(2 * n);
	REP(i, n) {
		REP(j, n) {
			if (a[i] < c[j] && b[i] < d[j]) {
				g[i].push_back(Edge(i, n + j, 1));
			}
		}
	}
	Edges es;
	cout << bipartiteMatching(g, n, es) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <iomanip>
#include <vector>
using namespace std;
#define ll long long
int main()
{
	int n;
	cin >> n;
	string s, t;
	cin >> s >> t;
	for (int i = 0; i < n; i++)
	{
		cout << s[i] << t[i];
	}
	system("pause>0");
	return 0;
}


Measured memory_bytes: 504
# -*- coding: utf-8 -*-

def main():
    import sys

    K = int( sys.stdin.readline() )

    A = 7
    add_digit = 7
    i = 1
    checked = set()


    while True:
        if A % K == 0:
            print(i)
            return

        elif A in checked:
            print("-1")
            return
        
        checked.add(A)
        add_digit = (add_digit * 10) % K
        
        next_A = add_digit + A
        next_A %= K

        A = next_A
        i += 1


if __name__ == "__main__":
    main()


Measured memory_bytes: 77872
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;

void solve() {
	cin >> N;
	cout << N * N * N << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using in = int64_t;
 
int main(){
int n;
  cin >>n;
  double nn = n;
  double x = 0.5;
  double y = (nn+1)/2/nn;
  if(n%2==0) cout <<x;
  else cout <<y;
}

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9

bool cmp(const pair<int, int> l, const pair<int, int> r){
  return l.second < r.second;
}

int main(){
  int N, M;
  cin >> N >> M;
  vector<pair<int, int>> pr(M);
  REP(i, M){
    cin >> pr[i].first >> pr[i].second;
  }

  sort(pr.begin(), pr.end(), cmp);
  int ans = 0, pre = -1;
  REP(i, M){
    int a = pr[i].first, b = pr[i].second;
    if(a > pre){
      pre = b-1;
      ans++;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int k = scan.nextInt();
        int x = scan.nextInt();

        System.out.println(IntStream.range(x - k + 1, x + k).mapToObj(n -> String.valueOf(n)).collect(Collectors.joining(" ")));
    }
}


Measured memory_bytes: 26320
n = int(input())
p_n = list(map(int, input().split()))

count = 0
for i in range(1, n - 1):
    if ((p_n[i - 1] < p_n[i] and p_n[i] < p_n[i + 1]) or
        (p_n[i - 1] > p_n[i] and p_n[i] > p_n[i + 1])):
        count += 1

print(count)


Measured memory_bytes: 3060
#include<stdio.h>

int main(){
    int A, B;
    int S[5];
    int ans=0;

    scanf("%d %d", &A, &B);
    for(int i=A; i<=B; i++){
        S[0] = i%10;
        S[1] = i%100/10;
        S[2] = i%1000/100;
        S[3] = i%10000/1000;
        S[4] = i/10000;
        if(S[0]==S[4] && S[1]==S[3]){
            ans++;
        }
    }
    printf("%d", ans);

    return 0;
}

Measured memory_bytes: 128
n = int(input())
a = input()
b = input()
c = input()

x = 0
for i,j,k in zip(a,b,c):
    if i != j and j != k and k != i:
        x += 2
    elif i == j and j == k:
        continue
    elif i == j or j == k or k == i:
        x += 1
print(x)



Measured memory_bytes: 3060
from collections import deque

h, w = map(int, input().split())
ch, cw = map(int, input().split())
dh, dw = map(int, input().split())
slist = [input() for i in range(h)]

if ch == dh and dw == cw:
    print(0)
    exit()

que = deque()
memo_que = deque()
que.append([ch - 1, cw - 1, 0])
memo = [[False for i in range(w)] for j in range(h)]
memo[ch - 1][cw - 1] = True

while len(que) != 0:
    # 幅たん
    while len(que) != 0:
        sh, sw, count = que.popleft()
        memo_que.append([sh, sw, count])
        #print(sh, sw, count)
        for ph, pw in [[-1, 0], [1, 0], [0, 1], [0, -1]]:
            if 0 <= sh + ph < h and 0 <= sw + pw < w:
                if sh + ph == dh - 1 and sw + pw == dw - 1:
                    print(count)
                    exit()
                if memo[ph + sh][pw + sw]:
                    continue
                if slist[sh + ph][sw + pw] == ".":
                    que.append([sh + ph, sw + pw, count])
                    memo[ph + sh][pw + sw] = True
                    memo_que.append([sh + ph, sw + pw, count])

    for sh, sw, count in memo_que:
        #print("w", sh, sw, count)
        for ph in range(-2, 3):
            for pw in range(-2, 3):
                if 0 <= sh + ph < h and 0 <= sw + pw < w:
                    if sh + ph == dh - 1 and sw + pw == dw - 1:
                        print(count + 1)
                        exit()
                    if memo[ph + sh][pw + sw]:
                        continue
                    if slist[sh + ph][sw + pw] == ".":
                        que.append([sh + ph, sw + pw, count + 1])
                        memo[ph + sh][pw + sw] = True
    memo_que.clear()
print(-1)

Measured memory_bytes: 143312
#include <stdio.h>

int getDirection(char);

int main(){
  int jewel[21][21],x,y;
  int N,M,i,j,distance,can;
  int getJewel[21],nx,ny,dir;
  const int dx[4] = {-1,0,1,0};
  const int dy[4] = {0,1,0,-1};
  char direction;
  char in; /* inテ」ツ?ッテ、ツスツ凖・ツ按?」ツ?ェテヲツ板ケティツ。ツ古」ツつ津ィツェツュテ」ツ?ソティツセツシテ」ツつ?ァツ板ィテ」ツ??*/

  while(1){
    nx = ny = 10;
    scanf("%d",&N);
    if(N == 0){ break; }
    for(i = 0 ; i < 21 ; i++){
      for(j = 0 ; j < 21 ; j++){
        jewel[i][j] = -1;
      }
    }
    for(i = 0 ; i < N ; i++){
      scanf("%d%d",&x,&y);
      jewel[y][x] = i;
      getJewel[i] = 0;
    }
    scanf("%d%c",&M,&in);
    for(i = 0 ; i < M ; i++){
      scanf("%c%d%c",&direction,&distance,&in);
      dir = getDirection(direction);
      for(j = 0 ; j < distance ; j++){
        nx += dx[dir];
        ny += dy[dir];
        if(jewel[ny][nx] != -1){
          getJewel[jewel[ny][nx]] = 1;
        }
      }
    }
    can = 1;
    for(i = 0 ; i < N ; i++){
      if(getJewel[i] == 0){
        can = 0;
        break;
      }
    }
    if(can){ printf("Yes\n"); }
    else{ printf("No\n"); }
  }
  return 0;
}

int getDirection(char ch){
  if(ch == 'W'){ return 0; }
  if(ch == 'N'){ return 1; }
  if(ch == 'E'){ return 2; }
  if(ch == 'S'){ return 3; }
}

Measured memory_bytes: 584
#include <stdio.h>
#include <string.h>

int main(void)
{
	int n[31];
	int m;
	int i;
	
	memset(n, 0, sizeof(n));
	for (i = 1; i <= 28; i++){
		scanf("%d", &m);
		n[m] = 1;
	}
	
	for (i = 1; i <= 30; i++){
		if (n[i] == 0){
			printf("%d\n", i);
		}
	}

	return (0);
}

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef vector<pii> vii;


#define mod 1000000007
#define INF 1e9+100
#define ff first
#define ss second
#define cy cout<<"YES"<<endl;
#define cn cout<<"NO"<<endl;
#define urs(r...)          typename decay<decltype(r)>::type
#define fi(i,n)                for(urs(n) i=0;i<n;i++)
#define rep(i,n)               for(urs(n) i=1;i<=n;i++)
#define pb push_back
#define gap ' '
#define endl '\n'
#define mex 300000
/*#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>*/
main()
{
	int i,j,n,m,t;
	int r;
	cin>>r;
	cout<<2*(3.1416)*r<<endl;
}


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

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

using namespace std;

struct UnionFind
{
  vector<int> par;
  vector<int> sizes;
public:
  UnionFind(int n) : par(n), sizes(n, 1) {
    rep(i,n) par[i] = i;
  }

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

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

    if (x == y) return;

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

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

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

  int size(int x) {
    return sizes[find(x)];
  }
};


int main() {
	int N;
	int M;
	cin >> N >> M;


	int p[N];
	for (int i = 0; i < N; i++) {
		cin >> p[i]; 
		p[i]--;
	}

	UnionFind uf(N);

	for( int i = 0; i < M; i++) {
		int x,y;
		cin >> x >> y;

		uf.unite(x-1, y -1);
	}
	int count = 0;

	for (int i = 0; i < N; i++) {
		if (uf.same(i,p[i])) count++;
	}

	cout << count << endl;

	return 0;
}



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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - Pair
            var lines = ReadLines<int>(1).ToList();
            int k = lines[0][0];

            var odds = new List<int>();
            var evens = new List<int>();
            
            for(int i = 1; i <= k; i++)
            {
                if (i % 2 == 0)
                {
                    evens.Add(i);
                }
                else
                {
                    odds.Add(i);
                }
            }

            Console.WriteLine(odds.Count * evens.Count);
        }
                        
        static IEnumerable<List<T>> ReadLines<T>(int count = 0, char separator = ' ')
        {
            //[summary]コンソールの値を読み込んで、List<T>のコレクションを返却

            //読み込む行数が未指定のときは、1行目の値を"count"とみなす
            if (count == 0)
            {
                string line = Console.ReadLine().TrimEnd();
                count = int.Parse(line);
            }

            for (int i = 0; i < count; i++)
            {
                //コンソールを1行読み込み
                string line = Console.ReadLine().TrimEnd();

                //char型のときは1文字ずつに分割
                if (typeof(T) == typeof(char))
                {
                    var list = line.ToCharArray().ToList();
                    yield return (List<T>)(object)list;
                }
                else
                {
                    //読み込んだ値を"separator"で区切る
                    var list = line.Split(separator).ToList();

                    //int型のときは数値に変換
                    if (typeof(T) == typeof(int))
                    {
                        var numbers = list.ConvertAll(int.Parse);
                        yield return (List<T>)(object)numbers;
                    }
                    else
                    {
                        yield return (List<T>)(object)list;
                    }
                }
            }
        }
    }
}


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

int main()
{
    int n,i;
    cin >> n;
    vector<double> v(n);
    for(i = 0;i < n;++i){
        cin >> v.at(i);
    }
    sort(v.begin(),v.end());
    double ans = (v.at(0) + v.at(1))/2;
    for(i = 2;i < n;++i){
        ans = (ans+v.at(i))/2;
    }
    std::cout<<std::fixed<<std::setprecision(10) << ans << endl;
    return 0;
}

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

int main(){
  vector<int> d(5,0);
  for(int i=0; i<5; i++){
    cin >> d[i];
  }
  vector<int> s(5,0);
  int time = 0;
  for(int i=0; i<5; i++){
    if(d[i]%10){
      time += ((d[i]/10)+1)*10;
      s[i] = ((d[i]/10)+1)*10-d[i];
    }
    else{
      time += d[i];
    }
  }
  sort(s.begin(),s.end());
  time -= s[4];
  cout << time << endl;
}

Measured memory_bytes: 256
def knapsack(N,W,weight,value):
  #初期化
  inf=float("inf")
  dp=[[-inf for i in range(W+1)] for j in range(N+1)]
  for i in range(W+1): dp[0][i]=0
  #DP
  for i in range(N):
    for w in range(W+1):
      if weight[i]<=w: #dp[i][w-weight[i]の状態にi番目の荷物が入る可能性がある
        dp[i+1][w]=max(dp[i][w-weight[i]]+value[i], dp[i][w])
      else: #入る可能性はない
        dp[i+1][w]=dp[i][w]
  return dp[N][W]

n,q = map(int,input().split()) 
li = [input().split() for i in range(n)]
w=[0]*n
v=[0]*n
for i in range(n):
  v[i]=int(li[i][0])
  w[i]=int(li[i][1])
print(knapsack(n,q,w,v))


Measured memory_bytes: 42280
import sys
import heapq
from operator import itemgetter
from collections import deque, defaultdict, Counter
from bisect import bisect_left, bisect_right
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
MOD = 10**9 + 7
INF = float('inf')

def sol():
    N = int(input())
    P = [0] * N

    for i in range(N):
        P[i] = int(input())

    pToIndex = {p : i for i, p in enumerate(P)}

    maxLeng = 1
    length = 1
    for n in range(1, N):
        if pToIndex[n] < pToIndex[n + 1]:
            length += 1
            maxLeng = max(maxLeng, length)
        else:
            length = 1

    print(N - maxLeng)

sol()

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

static class Weight
{
    static void Main()
    {
        var input = Console.In.ReadToEnd()
            .Split( 
                new[] { '\r', '\n' },
                StringSplitOptions.RemoveEmptyEntries )
            .Select( int.Parse );
        var weights = new [] {
            "1", "2", "4", "8", "16", 
            "32", "64", "128", "256", "512" };
        var q =
            from m in input
            select Enumerable.Range( 0, 10 )
                .Where( x => ( m >> x & 1 ) == 1 )
                .Select( x => weights[x] )
                .Aggregate( (x, y) => x + " " + y );
        q.ToList().ForEach( Console.WriteLine );
    }
}

Measured memory_bytes: 5732
from sys import stdin
readline = stdin.readline
def i_input(): return int(readline().rstrip())
def i_map(): return map(int, readline().rstrip().split())
def i_list(): return list(i_map())


def main():
    X, Y = i_map()
    ans = False
    z = Y - (X * 2)
    if z < 0:
        pass
    elif z == 0 or (z % 2 == 0 and (z // 2) <= X):
        ans = True
    print("Yes" if ans else "No")

if __name__ == "__main__":
    main()


Measured memory_bytes: 61828
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define foreach( gg,itit )  for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define mp make_pair
#define pb push_back
#define all(s) s.begin(),s.end()
#define sz(s) (int)s.size()
#define present(c,x) ((c).find(x) != (c).end())
const double EPS = 1e-8;
const int mod = 1e9+7;
const int N = 1e6+10;
const ll INF = 1e18;

ll power(ll x,ll y){
	ll t=1;
	while(y>0){
		if(y%2) y-=1,t=t*x%mod;
		else y/=2,x=x*x%mod;
	}
return t;
}

int main(){
	int n,x,cnt=0;
	scanf("%d",&n);
	REP(i,n){
		scanf("%d",&x);
		if (x%2) cnt++;
	}
	if (cnt%2) printf("NO\n");
	else printf("YES\n");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#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()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}


template<typename Compare = greater<int>>
vi knapsack_limitations(const vi &w, const vi &m, const vi &v,const int &W, const Compare &comp = Compare()) {
  const int N = (int) w.size();
  const int NG = -1;
  vi dp(W + 1, NG), deqv(W + 1);
  dp[0] = 0;
  vi deq(W + 1);
  for(int i = 0; i < N; i++) {
    for(int a = 0; a < w[i]; a++) {
      int s = 0, t = 0;
      for(int j = 0; w[i] * j + a <= W; j++) {
        if(dp[w[i] * j + a] != NG) {
          auto val = dp[w[i] * j + a] - j * v[i];
          while(s < t && comp(val, deqv[t - 1])) --t;
          deq[t] = j;
          deqv[t++] = val;
        }
        if(s < t) {
          dp[j * w[i] + a] = deqv[s] + j * v[i];
          if(deq[s] == j - m[i]) ++s;
        }
      }
    }
  }
  return dp;
}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int n,W;
  cin>>n>>W;
  vi v(n),w(n),m(n);
  rep(i,n){
    cin>>v[i]>>w[i]>>m[i];
  }

  auto res=knapsack_limitations(w,m,v,W);

  cout<<*max_element(all(res))<<endl;


}


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

using namespace std;

int main() {
	int N;
	string str;

	cin >> N >> str;

	int ans = 0, count;

	for (int i = 0; i < str.length() - 1; i++) {
		count = 0;
		for (char ch = 'a'; ch <= 'z'; ch++) {
			if (str.find(ch) <= i && str.find(ch, i + 1) != -1)
				count++;
		}
		if (ans < count) ans = count;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.List
import Data.Char
strToInt s = (read :: String -> Int) s
strToInteger s = (read :: String -> Integer) s

main :: IO ()
main = do
    -- 整数の入力
    n <- getLine
    -- スペース区切り整数の入力
    as <- map strToInteger . words <$> getLine
    bs <- map strToInteger . words <$> getLine
    let cs = zipWith (\a b -> b - a) as bs
        negs = sum $ filter (<= 0) cs :: Integer
        poss = sum $ map (\x -> if odd x then pred x else x) $ filter (>= 0) cs :: Integer
    if (abs negs) * 2 <= poss then putStrLn "Yes" else putStrLn "No"


Measured memory_bytes: 9596
N = int(raw_input())
S = raw_input()

ans = 0
for i in range(N):
    count = 0
    s1 = S[:i]
    s2 = S[i:]
    s1 = list(s1)
    s1 = list(set(s1))
    for j in range(len(s1)):
        if s2.find(s1[j]) > -1:
            count += 1
    ans = max(ans, count)

print(ans)

Measured memory_bytes: 2568
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
const int mod = 1e9 + 7;

int main(){
    long long int k;
    int n;
    cin >> n >> k;
    vector<int> a(n), b(n);
    for (int i = 0; i < n;i++) {
        cin >> a[i];
        b[i] = a[i];
    }
    long long int ans = 0;

    //1st
    //Aの転倒数
    for (int i = 0; i < n;i++) {
        for (int j = i + 1; j < n;j++) {
            if(a[i]>a[j]){
                ans++;
                ans = ans % mod;
            }
        }
    }
    ans = ans * k % mod;
    //cout << ans << endl;

    //2nd~end
    //A の各要素について、それより小さい要素が A にいくつ存在するかを調べる
    int count[2010] = {0};
    long long int countSum = 0;
    sort(b.begin(), b.end());
    for (int i = n - 1; i >= 0;i--) {
        for (int j = i - 1; j >= 0;j--) {
            if(b[i]>b[j]) {
                count[i]++;
            }
        }
        countSum += count[i];
        countSum %= mod;
    }
    //cout << countSum << endl;

    ans = (ans + k * (k - 1) / 2 % mod *countSum) % mod;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0; i<n; ++i)
#define rep1(i,n) for(ll i=1; i<=n; ++i)
#define revrep(i,n) for(ll i=n-1; n>=0; --i)
inline constexpr ll Inf = (1ULL << 62) -1;

template <class T>
void updatemax(T& a, T b) { if (b > a) a = b; }

int main() {
    ll x;
    cin >> x;
    for (int i=0; i<=200; ++i) {
        ll a5 = (ll)i*i*i*i*i;
        for (int j=-200; j<=200; ++j) {
            ll b5 = (ll)j*j*j*j*j;
            if (a5-b5 == x) {
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 3528
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N, K = get_ints

even = K % 2 == 0

x = even ? K / 2 : K

waru = N / x

if even
  x = waru / 2
  y = waru % 2
  puts (x + y) ** 3 + x ** 3
else
  puts waru ** 3
end




Measured memory_bytes: 14512
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

string solve() {
    ll N, D;
    string X;  cin >> N >> X >> D;
    string preX = X;
    for (int i = 0; i < (int)X.length(); i++) {
        if (D == 0) break;
        if (preX[i] == '1') continue;
        X[i] = '1';
        D--;
    }
    for (int i = (int)X.length() - 1; i >= 0; i--) {
        if (D == 0)break;
        if (preX[i] == '0') continue;
        X[i] = '0';
        D--;
    }
    return X;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << solve() << endl;
    return 0;
}



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

int main(){
  int a,b;
  cin >> a >> b;
  rep(i,1010){
    int am,bm;
    am = i*0.08;
    bm = i*0.1;
    if(a==am&&b==bm){
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    ll a, b; cin>>a>>b;
    if(a%2!=b%2){
        cout<<"IMPOSSIBLE"<<endl;
    }else{
        cout<<(a+b)/2<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define int long long
#define ve vector<int>
#define mod 1000000007
#define eb emplace_back
#define inf ((long long) 1e18 )
#define all(x) (x).begin(),(x).end()
#define debug(x) cout << '>' << #x << ':' << x << '\n';
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug2(x,y) cout << '>' << #x <<" = "<< x <<" & "<< #y <<" = "<< y << '\n';
#define fileIO freopen("input.txt", "r", stdin); freopen("output2.txt", "w", stdout);
using namespace std;
const int N = 1e6 + 7;

int32_t main()
{
	IOS
#ifndef ONLINE_JUDGE
	fileIO
#endif
	int t;
	t = 1;
	// cin >> t;
	while (t--) {
		int n, d;
		cin >> n >> d;
		int x, y;
		int ans = 0;

		for (int i = 0 ; i < n ; i++) {
			cin >> x >> y;
			if (sqrt(x * x + y * y) <= d)
				ans += 1;
		}

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


Measured memory_bytes: 3628
#include<cstdio>
#include<iostream>
using namespace std;
typedef int64_t i64;typedef int32_t i32;
typedef i64 int__;
#define rep(i,j) for(int__ i=0;i<j;i++)

int P,Q,A,N;

int dfs(i64 sum_u,i64 sum_d,int i,int a,int n){
  if(P*sum_d==Q*sum_u)return 1;
  if(n<=0)return 0;

  int ret=0;
  while(i*a<=A){
    int u=sum_u*i+sum_d;
    int d=sum_d*i;
    //P/Q>=u/d and n*1/i+u/d>=P/Q
    if(P*d>=Q*u and Q*(n*d+u*i)>=P*d*i)
      ret+=dfs(u,d,i,i*a,n-1);
    i++;
  }
  return ret;
}


int main()
{
  while(true){
    cin>>P>>Q>>A>>N;
    if(Q==0)break;
    cout<<dfs(0,1,1,1,N)<<endl;
  }
  return 0;
}

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

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s; cin>>s;
  LL n = s.size();
  LL l = 0, r = ((n-1)/2) - 1;
  int b = 1;
  while(l<r){
    if(s[l]!=s[r]){
      b =0;
      break;
    }
    l++, r--;
  }
  l = ((n+3)/2) -1, r = (n) - 1;
  while(l<r){
    if(s[l]!=s[r]){
      b =0;
      break;
    }
    l++, r--;
  }
  l = 0, r = (n) - 1;
  while(l<r){
    if(s[l]!=s[r]){
      b =0;
      break;
    }
    l++, r--;
  }
  cout<<(b?"Yes":"No")<<endl;
  return 0;
}


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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
  ll a,b,c,d,e;
  string s,ss;
  vector<ll>aa(3);
  cin>>aa[0]>>aa[1]>>aa[2];
  cin>>a;
  sort(aa.begin(),aa.end());
  cout<<(ll)aa[0]+aa[1]+aa[2]*pow(2,a)<<endl;
  return 0;
}


Measured memory_bytes: 512
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%lld", &(n))
#define nai(a, n) for (int i = 0; i < (n); i++) ni(a[i])
#define nal(a, n) for (int i = 0; i < (n); i++) nl(a[i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%lld\n", (n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
const double pi = acos(-1);
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const int MAXN = 1e6 + 5;
const double eps = 1e-9;
int dp[MAXN], a[MAXN];
int n, k;

int main()
{
    ni(n), ni(k);
    nai(a, n);
    dp[0] = -1; // losing state
    for (int x = 1; x <= k; x++) {
        for (int i = 0; i < n; i++) {
            if (a[i] <= x) {
                if (dp[x - a[i]] == -1)
                    dp[x] = 1;
            } else
                break;
        }
        if (dp[x] != 1)
            dp[x] = -1;
    }
    if (dp[k] == -1)
        printf("Second\n");
    else
        printf("First\n");
    return 0;
}


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

using namespace std;

char a[110][110];

int main()
{
    int H, W;
    scanf("%d %d\n", &H, &W);

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> a[i][j];
        }
    }

    for (int i = 0; i < H; i++) {
        bool flag = false;
        for (int j = 0; j < W; j++) {

            if (a[i][j] == '#') {
                flag = true;
                printf("%c", a[i][j]);

            } else {
                bool flag1 = false;
                for (size_t k = 0; k < H; k++) {
                    if (a[k][j] == '#') {
                        flag1 = true;
                        break;
                    }
                }

                bool flag2 = false;
                for (size_t k = 0; k < W; k++) {
                    if (a[i][k] == '#') {
                        flag2 = true;
                        break;
                    }
                }

                if (flag1 && flag2) {
                    flag = true;
                    printf(".");
                }

            }


        }

        if (flag) {
            printf("\n");
        }

    }

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
 
int main()
{
  int t[4][14];
  int n, i,j,c;
  char m, d;
  for(i=0; i < 4; i++){
    for(j=0; j < 14; j++){
      t[i][j]=0;
    }
  }
 scanf("%d", &c);
  for(i = 0; i < c; i++){
    scanf("%c", &d);
    scanf("%c %d", &m, &n);
    if(m == 'S'){
      t[0][n] = 1;
    }
    else if(m == 'H'){
      t[1][n] = 1;
    }
    else if(m == 'C'){
      t[2][n] = 1;
    }
    else if(m == 'D'){
      t[3][n] = 1;
    }
  }
  for(j=1; j < 14; j++){
    if(t[0][j] != 1){
      printf("S %d\n", j);
    }
  }
 
 for(j=1; j < 14; j++){
    if(t[1][j] != 1){
      printf("H %d\n", j);
    }
  }
 
 for(j=1; j < 14; j++){
    if(t[2][j] != 1){
      printf("C %d\n", j);
    }
  }
 
 for(j=1; j < 14; j++){
    if(t[3][j] != 1){
      printf("D %d\n", j);
    }
  }
 return 0;
}
 

Measured memory_bytes: 596
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr int MOD_TYPE = 2;
constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
constexpr int INF = (int)1e9;
constexpr ll LINF = (ll)4e18;
constexpr ld PI = acos(-1.0);
constexpr ld EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

#pragma endregion

void solve()
{
  ll x, y;
  cin >> x >> y;
  int cnt = 1;
  while (x * 2 <= y)
  {
    x *= 2;
    cnt++;
  }
  cout << cnt << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define debug(x) cerr << #x << " = " << x << "\n";
#define debug_v(x) cerr << #x << " ="; for(auto i : x) {cerr << " [" <<  i << "]";} cerr << "\n";
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vii = vector<pii>;
const double PI = acos(-1);
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 1e18 + 100;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cout << fixed << setprecision(20);
	string s;
	cin >> s;
	bool ok = true;
	for(int i = 1;i < (int)s.size();i++){
		if(s[i] == s[i - 1]){
			ok = false;
		}
	}
	cout << (ok ? "Good\n" : "Bad\n");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define eps 1e-8
#define INF 0x3f3f3f3f
#define pb push_back
#define endl '\n'
using namespace std;
const ll maxn = 1e6 + 5;
int A[maxn],n,m,q;
int a[maxn],b[maxn],c[maxn],d[maxn];
int ans = 0;
void dfs(int cnt,int lst){
    if(cnt == n + 1){
        int res = 0;
        for(int i = 1; i <= q; i++)
            if(A[b[i]] - A[a[i]] == c[i])
                res += d[i];
        ans = max(res,ans);
    }else
        for(int i = lst; i <= m; i++)
            A[cnt] = lst,dfs(cnt + 1,i);
}
int main()
{
    cin >> n >> m >> q;
    for(int i = 1; i <= q; i++)
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    dfs(1,1);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3640
#include<stdio.h>
#include<string.h>
int s(int a[],int x,int y,int f){
	int i,j,k;
	for(i=y;i>0;i--){
		a[f]=i;k=a[f];
		//for(j=0;j<=f;j++)k+=a[j];
		if(k==x){
			for(j=0;j<=f;j++)printf("%s%d",(j==0)?"":" ",a[j]);
			printf("\n");
		}else if(k<x){
			//for(j=0;j<=f;j++)printf(" %s%d",(j==0)?"":" ",a[j]);
			//printf("\n");
			s(a,x-k,i,f+1);
		}
		
	}
}
int main(){
	int n,d[35];
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		memset(d,0,sizeof(d));
		s(d,n,n,0);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin() , v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)


int main(){
    int n; string a, b, c; cin >> n >> a >> b >> c;
    int ans = 0;
    rep(i, n){
        if(a[i] == b[i] && b[i] == c[i]){
            continue;
        } else if(a[i] == b[i] || b[i] == c[i] || c[i] == a[i]){
            ans++;
        } else {
            ans += 2;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
# あまりにもTLEになるから解説見ちゃった

from sys import stdin
import numpy as np
from copy import deepcopy
from fractions import gcd

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

"""
## 入力生成用
import random
N = 1000
A = [random.randint(1,1e9) for i in range(N)]
"""

solve = []
L = np.zeros(N)
R = np.zeros(N)

for i in range(N-1):
  L[i+1] = gcd(L[i], A[i])
  R[N-2-i] = gcd(R[N-1-i], A[N-1-i])
  
for i in range(N):
  var = gcd(L[i], R[i])
  solve.append(var)

ans = int(max(solve))
print(ans)
  
  

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

int main() {
    cin.tie(0)->sync_with_stdio(false);

    ll q, h, s, d;
    cin >> q >> h >> s >> d;
    ll n;
    cin >> n;

    vector<ll> val2(4);
    val2[0] = q * 8;
    val2[1] = h * 4;
    val2[2] = s * 2;
    val2[3] = d;
    sort(val2.begin(), val2.end());

    ll ans = (n / 2) * val2[0];
    if (n % 2) {
        vector<ll> val1(3);
        val1[0] = q * 4;
        val1[1] = h * 2;
        val1[2] = s;
        sort(val1.begin(), val1.end());
        ans += val1[0];
    }

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;

void solve(long long N, long long K, vector<long long> a){
	ll suma[N], sumb[N];
	suma[0] =  max(a[0],0LL);
	sumb[0] =  a[0];
	repn(i,N-1) {
		suma[i] = suma[i-1] + max(a[i],0LL);
		sumb[i] = sumb[i-1] + a[i];
	}
	// rep(i,N) {
	// 	cout << suma[i] << endl;
	// }
	ll res = 0;
	rep(i,N-K+1) {
		ll now = suma[N-1];
		now -= suma[i+K-1];
		if (i-1 >= 0) now += suma[i-1];
		ll borw = sumb[i+K-1];
		if (i-1 >= 0) borw -= sumb[i-1];
		now += max(borw, 0LL);
		res = max(res, now);
	}
	cout << res << endl;
}

int main(){	
	long long K;
	long long N;
	scanf("%lld",&N);
	vector<long long> a(N-1+1);
	scanf("%lld",&K);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&a[i]);
	}
	solve(N, K, a);
	return 0;
}



Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

namespace std {
	#define u(x, a, b) for(ll x = a; x < b; x++)
	#define d(x, a, b) for(ll x = a; x > b; x--)
}

typedef long long ll;
typedef long double ld;

#define MAXI 100010
#define MOD 1000000007

int main(){
	
	ll n;
	cin >> n;
	
	ll a[n];
	ll cnt = 0; 
	u(one, 0, n){cin >> a[one]; 
		if(one%2==0 && a[one]%2==1){cnt++;}
	}
	
	cout << cnt;
	
}


Measured memory_bytes: 3616
#include <iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define ALL(a) (a).begin(), (a).end()
#define p(a, b) printf(a, b);
#define c(s) cout << (s) << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define cyn(c) cout << (c ? "Yes" : "No") << endl;
#define cYN(c) cout << (c ? "YES" : "NO") << endl;
#define pyn(c) printf("%s\n", c ? "Yes" : "No");
#define pYN(c) printf("%s\n", c ? "YES" : "NO");
#define INF 1e18
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> P;
template <class T>
bool contain(const std::string &s, const T &v)
{
  return s.find(v) != std::string::npos;
}
ULL mod = 1e9 + 7;

int main()
{
  int h, w;
  cin >> h >> w;
  char a[h][w];
  rep(i, h)
  {
    rep(j, w)
    {
      cin >> a[i][j];
    }
  }

  rep(i, w + 2) cout << "#";
  cout << endl;
  rep(i, h)
  {
    cout << "#";
    rep(j, w)
    {
      cout << a[i][j];
    }
    cout << "#" << endl;
  }
  rep(i, w + 2) cout << "#";
  cout << endl;
}

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

vector<long long> S(3);

long long solve(long long H,long long W){
	long long ans=99999999999999;
	for(long long h=1;h<H;h++){
		S[0]=h*W;
		if(H-h>1){
			long long h1=(H-h)/2;
			long long h2=H-h-h1;
			S[1]=h1*W;
			S[2]=h2*W;
			ans=min(ans,*max_element(S.begin(),S.end())-*min_element(S.begin(),S.end()));
		}
		if(W>1){
			long long w1=W/2;
			long long w2=W-w1;
			S[1]=(H-h)*w1;
			S[2]=(H-h)*w2;
			ans=min(ans,*max_element(S.begin(),S.end())-*min_element(S.begin(),S.end()));
		}
	}
	return ans;
}

int main(){
	long long H,W;
	cin >> H >> W;
	long long ans1=solve(H,W);
	long long ans2=solve(W,H);
	cout << min(ans1,ans2) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,s,n) for (int i = (s); i < (n); ++i)
#define rrep(i,n,g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define len(x) (int)(x).size()
#define dup(x,y) (((x)+(y)-1)/(y))
#define append push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int mod = 1000000007;
int dp[10010][101][2];

int main() {
  string s; int d;
  cin >> s >> d;
  int n = len(s);
  dp[0][0][0] = 1;
  rep(i,0,n) rep(j,0,d) rep(k,0,2) {
    int x = s[i]-'0';
    rep(nx,0,10) {
      int ni = i+1, nj = 0, nk = k;
      nj = (j + nx) % d;
      if (k == 0) {
        if (nx > x) continue;
        if (x > nx) nk = 1;
      }
      dp[ni][nj][nk] += dp[i][j][k];
      dp[ni][nj][nk] %= mod;
    }
  }
  int ans = (dp[n][0][0] + dp[n][0][1] - 1) % mod;
  ans = (ans + mod) % mod;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 11508
n,m = map(int,input().split())
li = [list(map(int, input().split())) for _ in range(n)]
li.sort()
s = 0
money = 0
for i in range(len(li)):
  s+=li[i][1]
  if s>= m:
    s -=li[i][1]
    nokori = m-s
    money += li[i][0]*nokori
    break
  else:
    money += li[i][0]*li[i][1]
print(money)

Measured memory_bytes: 27752
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))
#define all(c) c.begin(),c.end()
#define str string
#define edl "\n"
#define add insert
#define cot continue
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
const double PI = acos(-1);
const ll LINF = LLONG_MAX;




int main() 
{

 fast();
  
  // #ifndef ONLINE_JUDGE
  //   freopen("input.txt", "r", stdin);
  //   freopen("output.txt","w",stdout);
  // #endif
  
  ll n,a,b,c;
  str s;
  cin>>a>>b;
  ll r=a+b;
  if(r&1)
  {
    cout<<"IMPOSSIBLE";
  }
  else
  {
    cout<<r/2;
  }
  
  


  


    




    cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
    return 0;
}
 

Measured memory_bytes: 764
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N,A,B;
  cin>>N>>A>>B;
  vector<int> X(N);
  REP(i,N){
    int P;
    cin>>P;
    P--;
    X[P]=i+1;
  }
  
  vector<vector<ll>> DP(N+1,vector<ll>(N+1,INF));
  REP(i,N+1) DP[0][i]=0;
  
  REP(i,N){
    REP(j,N+1){
      if(j>0) DP[i+1][j]=DP[i+1][j-1];
      chmin(DP[i+1][j],DP[i][j]+(X[i]<=j ? A : B));
      if(X[i]==j) chmin(DP[i+1][j],DP[i][j-1]);
    }
  }
  cout<<DP[N][N]<<endl;
  return 0;
}

Measured memory_bytes: 198828