akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}
#define fasty ios_base::sync_with_stdio(0),cin.tie(0);
#define forinc(a,b,c) for(int a=b,_c=c;a<=_c;++a)
#define fordec(a,b,c) for(int a=b,_c=c;a>=_c;--a)
#define forv(a,b) for(auto&a:b)
#define fi first
#define se second
#define pb push_back
#define ii pair<int,int>
#define mt make_tuple
#define all(a) a.begin(),a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define bit(x,i) ((x>>(i-1))&1)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1<<(i-1)))
#define gg exit(0);

const int N=200010;

int n,k;
double ret;
double a[N];

main(){
    #define task "TASK"
    //freopen(task".inp","r",stdin);
    //freopen(task".out","w",stdout);
    fasty;

    cin>>n>>k;
    forinc(i,1,n){
        cin>>a[i];
        a[i]=(a[i]+1)/2;
        a[i]+=a[i-1];
        if(i>=k) ret=max(ret,a[i]-a[i-k]);
    }
    cout<<setprecision(12)<<fixed<<ret;
}


Measured memory_bytes: 1792
def resolve():
    n=int(input())
    a = list(map(int, input().split()))
    mx=len(bin(max(a)))-2
    b = ["0b"]*n
    ch=0
    for j in reversed(range(mx)):
        for i in range(n):
            if (a[i] >> j) & 1:
                ch+=1
        if ch%2==1:
            for i in range(n):
                if (a[i] >> j) & 1:
                        b[i]+="0"
                else:
                    b[i] += "1"
        else:
            for i in range(n):
                if (a[i] >> j) & 1:
                    b[i] += "1"
                else:
                        b[i]+="0"
        ch=0
    for i in range(n):
        b[i]=int(b[i],0)
    c = [str(x) for x in b]
    L = " ".join(c)
    print(L)
resolve()

Measured memory_bytes: 260012
n=int(input())
m=[list(map(int, input().split())) for i in range(n)]

if n==1:
    dt=m[0][0]
    dx=m[0][1]
    dy=m[0][2]
    if dt<dx+dy:
        print("No")
    else:
        if dt%2!=(dx+dy)%2:
            print("No")
        print("Yes")

else:
    for i in range(n-1):
        dt=m[i+1][0]-m[i][0]
        dx=abs(m[i+1][1]-m[i][1])
        dy=abs(m[i+1][2]-m[i][2])

        if dt<dx+dy:
            print("No")
            exit()
        else:
            if dt%2!=(dx+dy)%2:
                print("No")
                exit()

    print("Yes")

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

unsigned mod = 2;
struct mint {
  using m = mint;
  unsigned v;
  mint(long long a = 0) : v((a %= mod) < 0 ? a + mod : a) {}
  m operator-() const { return m() -= *this; }
  m& operator+=(m r) { if ((v += r.v) >= mod) v -= mod; return *this; }
  m& operator-=(m r) { if (v < r.v) v += mod; v -= r.v; return *this; }
  m& operator*=(m r) { v = (uint64_t)v * r.v % mod; return *this; }
  friend m operator+(m l, m r) { return l += r; }
  friend m operator-(m l, m r) { return l -= r; }
  friend m operator*(m l, m r) { return l *= r; }
  friend bool operator==(m l, m r) { return l.v == r.v; }
  friend string to_string(m a) { return to_string(a.v); }
};

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k >> mod;
  ++n;
  vector<vector<mint>> binom(n + 1, vector<mint>(n + 1));
  for (int i = 0; i <= n; ++i) {
    binom[i][0] = 1;
    for (int j = 1; j <= i; ++j) {
      binom[i][j] = binom[i - 1][j - 1] + binom[i - 1][j];
    }
  }
  vector<vector<mint>> dp(k, vector<mint>(n + 1));
  fill(begin(dp[0]), end(dp[0]), 1);
  for (int x = 1; x < k; ++x) {
    dp[x][0] = 1;
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j <= i; ++j) {
        dp[x][i + 1] += binom[i][j] * dp[x - 1][j + 1] * dp[x][i - j];
      }
    }
  }
  cout << dp.back().back().v << '\n';
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
#include<iomanip>
using namespace std;


int main() {
	int N;
	long long K;
	int A[200000];
	int cnt, first_kaburi;
	bool visited[200000];

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

	for (int i = 0; i < N; i++) {
		visited[i] = false;
	}

	cnt = 0;
	int now = 0;
	while (visited[now] == false) {
		visited[now] = true;
		now = A[now];
		cnt++;
	}
	first_kaburi = now;


	int cnt_s = 0;
	now = 0;
	while (now != first_kaburi) {
		now = A[now];
		cnt_s++;
	}

	int period = cnt - cnt_s;

	int goal = 0;
	if (cnt_s > K) {
		goal = K;
	}
	else {
		goal = (K - cnt_s) % period + cnt_s;
	}

	now = 0;
	for (int i = 0; i < goal; i++) {
		now = A[now];
	}

	cout << now + 1;
}

Measured memory_bytes: 4580
import sys
from decimal import Decimal

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    a, b, c = input().split()
    print("Yes" if Decimal(a) ** Decimal(0.5) + Decimal(b) ** Decimal(0.5) < Decimal(c) ** Decimal(0.5) else "No")


if __name__ == '__main__':
    resolve()


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

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}


int main(void){
    int N;
    scanf("%d", &N);
    int *array = (int *)malloc(N * sizeof(int));
    int counter[1000000+10] = {0};
    for (int i = 0; i < N; i++) {
        scanf("%d", &array[i]);
        counter[array[i]]++;
    }
    qsort(array,N,sizeof (int), asc);   
    bool flag[1000000+10] = {0};
    for (int i = 0; i < N; i++) {
        int now = 2;
        while(now * array[i] <= (long long)array[N-1]){
            flag[now * array[i]] = 1;
            now += 1;
        }
    }
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if ((!flag[ array[i] ]) && counter[array[i]] == 1) {
            ans++;
        }
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 7392
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int x;
    cin>>x;
    int maxn=-1000000000;
    int minn=x;
    n--;
    while(n--)
    {
        cin>>x;
        maxn=max(maxn,x-minn);
        minn=min(minn,x);
    }
    cout<<maxn<<endl;
    return 0;
}



Measured memory_bytes: 3108
#include <iostream>
using namespace std;
int main()
{
	int num[200010];
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>num[i];
	for(int i=1;i<=n-k;i++)
	{
		if(num[i+k]>num[i])
			cout<<"Yes"<<endl;
		else 
			cout<<"No"<<endl;
	}
	return 0;		
}

Measured memory_bytes: 4400
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <list>

using namespace std;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

typedef pair<long long int, long long int> P;
typedef pair<long long int, P> P2;

int N = 300000 - 1; // 必要な数よりも大きい2^nよりも大きい数を入れるとよい
long long int BIT[300000];

void add(int a, long long int w){
	
	// a番目の要素にwを足す O(log N)
	
	for(int x = a; x <= N; x += x & -x){
		BIT[x] += w;
	}
}

long long int sum(int a){
	
	// 1からaまでの要素の合計を返す O(log N)
	
	long long int ret = 0;
	for(int x = a; x > 0; x -= x & -x){
		ret += BIT[x];
	}
	return ret;
}

void init(){
	for(int i = 0; i < N; i++){
		BIT[i] = 0;
	}
}

int main(){
	
	int N;
	cin >> N;
	
	vector<P2> v;
	map<long long int, int> mx;
	
	for(int i = 0; i < N; i++){
		long long int x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		if(x1 > x2){
			swap(x1, x2);
		}
		if(y1 > y2){
			swap(y1, y2);
		}
		mx[x1] = mx[x2] = 1;
		if(x1 == x2){
			P2 p2;
			p2.first = y1;
			p2.second = make_pair(-INF, x1);
			v.push_back(p2);
			p2.first = y2;
			p2.second = make_pair(INF, x1);
			v.push_back(p2);
		}else{
			P2 p2;
			p2.first = y1;
			p2.second = make_pair(x1, x2);
			v.push_back(p2);
		}
	}
	
	map<long long int, int>::iterator ite;
	
	int cnt = 1;
	for(ite = mx.begin(); ite != mx.end(); ite++){
		ite -> second = cnt;
		cnt++;
	}
	
	sort(v.begin(), v.end());
	init();
	long long int ans = 0;
	
	for(int i = 0; i < v.size(); i++){
		
		int x = mx[v[i].second.second];
		
		if(v[i].second.first == -INF){
			ans -= sum(x);
		}else if(v[i].second.first == INF){
			ans += sum(x);
		}else{
			add(x + 1, -1);
			int x2 = mx[v[i].second.first];
			add(x2, 1);
		}
	}
	
	cout << ans << endl;
	
	return 0;
}



Measured memory_bytes: 13480
// Package main provides
//
// File:  d.go
// Author: ymiyamoto
//
// Created on Tue Jan 22 16:40:32 2019
//
package main

import (
	"fmt"
	"sort"
)

type pair struct {
	t, d int
}

type pairs []pair

func (ps pairs) Len() int {
	return len(ps)
}

func (ps pairs) Swap(i, j int) {
	ps[i], ps[j] = ps[j], ps[i]
}

func (ps pairs) Less(i, j int) bool {
	return ps[i].d > ps[j].d
}

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

	s := make(pairs, N)
	for i := range s {
		fmt.Scan(&s[i].t, &s[i].d)
	}
	sort.Sort(s)

	dSum := 0
	kinds := map[int]int{}
	for i := 0; i < K; i++ {
		dSum += s[i].d
		kinds[s[i].t]++
	}
	k := len(kinds)

	max := dSum + k*k
	minIndex := K - 1
	for i := K; i < len(s); i++ {
		t, d := s[i].t, s[i].d
		if _, ok := kinds[t]; ok {
			continue
		}
		kinds[t]++

		for kinds[s[minIndex].t] <= 1 {
			minIndex--
			if minIndex == -1 {
				fmt.Println(max)
				return
			}
		}
		minT, minD := s[minIndex].t, s[minIndex].d
		kinds[minT]--

		minIndex--

		dSum += -minD + d
		k++
		if max < dSum+k*k {
			max = dSum + k*k
		}
	}
	fmt.Println(max)
}


Measured memory_bytes: 9216
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        scan.close();

        boolean count = false;

        if(a == b) count = !count;
        else if(a == c) count = !count;
        if(b == c) count = !count;
        
        if(count) System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 23252
#include"bits/stdc++.h"
using namespace std;
int main(){
	string s;
	cin>>s;
	while(true){
		s.erase(s.size()-1);
		if(!(s.size()&1) && s.substr(0,s.size()/2)==s.substr(s.size()/2))
			break;
	}
	cout<<s.size();
}

Measured memory_bytes: 256
N,M=map(int,input().split())
S=[list(map(int,input().split()))[1:] for i in range(M)]
P=list(map(int,input().split()))
#print(S)
#print(P)

ans=0
for i in range(2**N):
  #print(bin(i))
  p=[]
  for s in S:
    tmp=0
    for ss in s:
      if i>>(N-ss)&1:
        tmp+=1
    p.append(tmp%2)
  if p==P:
    ans+=1
print(ans)

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

typedef long long ll;
typedef unsigned long long ull;

ull powmod(ull  a,ull b, ull mod) {
  ull res=1;
  for(; b; b >>= 1){
    if(b & 1){
      res = res * a % mod;
    }
    a = a * a % mod;
  }
  return res;
}

bool MillerRabin(ull n, ull k){
  if (n == 2){
    return true;
  }
  if (n == 1 || (n & 1) == 0){
    return false;
  }

  random_device rd;
  mt19937 rand_src(rd());
  uniform_int_distribution<ull> rand_dist(1, n - 1);

  ull d = n - 1;
  while ((d & 1) == 0){
    d >>= 1;
  }
  while(k--){
    ull a = rand_dist(rand_src);
    ull t = d;
    ull y = powmod(a, t, n);
    while (t != n - 1 && y != 1 && y != n - 1){
      y = (y * y) % n;
      t <<= 1;
    }
    if (y != n - 1 && (t & 1) == 0){
      return false;
    }
  }
  return true;
}

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

  cin >> a >> b >> c;

  ull count = 0;
  for (ull i = a; i <= b; i ++){
    if (c % i == 0) {
      count ++;
    }
  }
  cout << count <<"\n";
}



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

int main(){
	int n;
	cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++)
		cin>>a[i];
	vector<int> dp(n,0);
	dp[1]=abs(a[1]-a[0]);
	for(int i=2;i<n;i++){
		dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
	}
	cout<<dp[n-1]<<endl;
	return 0;
}

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

int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;

  int max = 0;
  if (A >= K) {
    cout << K << endl;
  } else {
    K = K - A;
    if (B >= K) {
      cout << A << endl;
    } else {
      K = K - B;
      cout << A - K << endl;
    }
  }

  return 0;
}


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

//the answer must be bountry * bountry
public class Main  {
    static StringTokenizer st;
    static BufferedReader br;  
    static PrintWriter out;
 
    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
 
        String S = next();
 
        int sum = 0;

        for (int i=0; i<S.length(); i++) {
             int temp = S.charAt(i)-'0';
             sum += temp;
        }

        if(sum%9==0){
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
        
 
    }
    
      
    public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    public static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

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

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine().trim());
        return st.nextToken();
    }
}


Measured memory_bytes: 36500
import Control.Monad
import Data.Maybe
import Control.Applicative

totalDist :: [Int] -> Maybe (Int, Int)
totalDist [] = Nothing
totalDist [_] = Nothing
totalDist [_, _] = Nothing
totalDist (i:d1:d2:_) = Just (i, d1 + d2)

findMax :: [(Int, Int)] -> (Int, Int) -> (Int, Int)
findMax [] a = a
findMax (x:xs) a =
  if snd x > snd a
    then findMax xs x
    else findMax xs a


solver :: [[Int]] -> (Int, Int)
solver [] = (-1, -1)
solver xs =
  let ys = mapMaybe totalDist xs -- ys :: [(Int, Int)]
  in
      findMax ys (0, 0)

main :: IO()
main = do
  n <- (read :: String -> Int) <$> getLine
  unless (n == 0) $ do
     line <- map (map (read :: String -> Int) . words) <$> replicateM n getLine
     let m = solver line
     putStrLn $ show (fst m) ++ " " ++ show (snd m)
     main

Measured memory_bytes: 11532
#include "bits/stdc++.h"
#define MAXN 100009
#define MOD 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
#define vi vector <int>

using namespace std;

typedef long long ll;
typedef pair<int,int> PII;

template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
ll a, b;
int main()
{
    //~ freopen("file.in", "r", stdin);
	cin >> a >> b;
	ll k = 1ll * a * b / __gcd(a, b);
	k --;
	k /= a;
	k = 1ll * a * k;
	if(k % b == 0)
		k = -1;
	cout << k;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef vector<ll> vel;
typedef vector<str> ves;
#define REP(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, b) REP(i, 0, b)
const ll mod = 1000000007;
const double pi = 3.14159265358979;

int main() {
    str a, b;
    cin >> a >> b;
    if (a[0] == b[2] && a[1] == b[1] && a[2] == b[0]) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	cnt := map[int]int{}
	for i := 0; i < n; i++ {
		cnt[scanInt()]++
	}

	c := []int{}
	for _, e := range cnt {
		c = append(c, e)
	}

	sort.Ints(c)

	s := make([]int, len(c)+1)
	for i := 0; i < len(c); i++ {
		s[i+1] += s[i] + c[i]
	}

	ans := map[int]int{}
	p := []int{}
	for i := 1; i <= n; i++ {
		idx := sort.Search(len(c), func(idx int) bool { return i <= c[idx] })
		debug(i, idx)
		ans[(s[idx]+i*(len(c)-idx))/i] = i
		p = append(p, (s[idx]+i*(len(c)-idx))/i)
	}

	sort.Ints(p)

	for i := 0; i < n; i++ {
		idx := sort.Search(len(p), func(idx int) bool { return i+1 <= p[idx] })
		if idx == n {
			fmt.Fprintln(wr, 0)
			continue
		}
		fmt.Fprintln(wr, ans[p[idx]])
	}

}


Measured memory_bytes: 31104
from enum import Enum
from queue import Queue
import collections

import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

N = int(input())
H = list(map(int,input().split()))
flag = True
# if N == 1:
#     if H[0] > 1:
#         flag = False
#     print(1)
# else:
for i in reversed(range(1,N)):
    if H[i] < H[i-1]:#操作前は減少列になっている時
        H[i-1] -= 1
    if H[i] < H[i-1]:
        flag = False
        break

if flag:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 15804
#include <iostream>
using namespace std;
int main (void)
{
	int size;
	string s;
	cin >> size >> s;
	int ans = 0;
	for (int i = 0; i < size - 2; i++){
		if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C')
			ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
ll INF = (1LL << 50) - 1;
int MOD = 1e9+7;
ll func(ll h, ll w){
    ll mini = INF;
    rep(i,1,h){
        ll hh = h - i;
        ll sum[] = {i * w, hh * (w/2), hh * ((w+1)/2)};
        sort(sum, sum+3);
        mini = min(mini, sum[2] - sum[0]);
           // cout << sum[2] << " " << sum[1] << " " << sum[0] << endl;
        ll sum2[] = {i * w, (hh/2) * w, ((hh+1)/2) * w};
        sort(sum2, sum2+3);
        mini = min(mini, sum2[2] - sum2[0]);
         //   cout << sum2[2] << " " << sum2[1] << " " << sum2[0] << endl;
    }
    return mini;
}
main(){
    ll H,W;
    cin >> H >> W;
    cout << min(func(H,W), func(W,H) ) << endl;
}

Measured memory_bytes: 256
N = int(input())
matrix = []
matrix.append(list(map(int, input().split(' '))))
matrix.append(list(map(int, input().split(' '))))


max_num = 0
for i in range(N):
    tmp_num = 0
    tmp_num += sum([matrix[0][j] for j in range(i + 1)])
    tmp_num += sum([matrix[1][i + k] for k in range(N - i)])
    if tmp_num >= max_num:
        max_num = tmp_num
        
print(max_num)

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

long long int knapsack1(vector<long long int>w,vector<long long int >v,long long int W)
{
    int n=w.size();
    vector<vector<long long>>dp(n+1,vector<long long>(W+1,0));
   
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=W;j++)
        {
            if(j-w[i-1]>=0)
                dp[i][j]=max(dp[i-1][j],v[i-1]+dp[i-1][j-w[i-1]]);
            else dp[i][j]=dp[i-1][j];
        }
    }
    
    return dp[n][W];
   
}

int main() {
	int n;
	long long int W;
	cin>>n>>W;
	vector<long long int>w(n);
	vector<long long int>v(n);
	for(int i=0;i<n;i++)cin>>w[i]>>v[i];
	
	cout<<knapsack1(w,v,W);
	return 0;
}

Measured memory_bytes: 80256
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
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 a,b,c,d;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >>a>>b>>c>>d;
    while(true){
        c-=b;
        if(c<=0)return yes,0;
        a-=d;
        if(a<=0)return no,0;
    }
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
 
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dumpi(x1) fprintf(stderr, "#%s.%d (%s) = (%d)\n", __func__, __LINE__, #x1, x1);
#define dumpii(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%d, %d)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumpiii(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%d, %d, %d)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
 
struct S002 {
  int n;
  S002& operator > (long& x) {
    n = x;
    return *this;
  }
  S002& operator > (long&& x) {
    n = x;
    return *this;
  }
  S002& operator >= (long& x) {
    if( scanf("%ld", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (double& x) {
    if( scanf("%lf", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (std::string& s) {
    if( not (std::cin >> s) ) exit(0);
    return *this;
  }
  template<typename a>
  S002& operator >= (std::vector<a>& v) {
    v.resize(n);
    for(long i = 0; i < n; ++i) {
      *this >= v[i];
    }
    return *this;
  }
  template<typename a, std::size_t s>
  S002& operator >= (std::array<a, s>& x) {
    for(long i = 0; i < (long)s; ++i) {
      *this >= x[i];
    }
    return *this;
  }
};

template<typename a>
struct S014 {
  long w, h;
  std::vector<std::vector<a>> z;
  S014(long w, long h, a x) {
    z.resize(h);
    for(long i = 0; i < h; ++i) {
      z[i].resize(w);
    }
    for(long r = 0; r < h; ++r) {
      for(long c = 0; c < w; ++c) {
        z[r][c] = x;
      }
    }
  }
  a& operator()(long c, long r) {
    return z[r][c];
  }
  void foreach(long cl, long cr, long rl, long rr, std::function<void(long,long,a&)> f) {
    for(long r = rl; r < rr; ++r) {
      for(long c = cl; c < cr; ++c) {
        f(c, r, z[r][c]);
      }
    }
  }
};

struct Solver {
  std::array<std::string, 3> xs;
  Solver() {
    S002 r;
    r >= xs;
  }
  void solve() {
    printf("A%cC\n", xs[1][0]);
  }
};
 
int main() {
  for(;;) std::unique_ptr<Solver>(new Solver())->solve();
  return 0;
}

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

int main(){
	int n, m;
	string u[100010];
	string input;
	bool isOpen = false;

	cin >> n;
	for(int i=0; i < n; i++){
		cin >> u[i];
	}
	cin >> m;
	for(int i=0; i < m; i++){
		cin >> input;

		bool isExist = false;
		for(int j=0; j < n; j++){
			if(u[j] == input){
				isExist = true;
			}
		}
		if(isExist){
			if(isOpen){
				cout << "Closed by " << input << endl;
				isOpen = false;
			}
			else {
				cout << "Opened by " << input << endl;
				isOpen = true;
			}
		}
		else {
			cout << "Unknown " << input << endl;
		}
	}
}

Measured memory_bytes: 1996
class InputLine
  def self.to_s
    gets.chomp
  end

  def self.to_i
    InputLine.to_s.to_i
  end
  
  def self.to_f
    InputLine.to_s.to_f
  end

  def self.to_sa
    InputLine.to_s.split(' ')
  end

  def self.to_ia
    InputLine.to_sa.map(&:to_i)
  end
  
  def self.to_fa
    InputLine.to_sa.map(&:to_f)
  end
end

N = 5

def main(argv)
  xs = InputLine.to_ia

  idx = -1
  N.times do |n|
    idx = n + 1 if xs[n] == 0
  end
  puts idx.to_s
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 14244
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;
typedef vector<char> vchar;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================



int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================


	int N, M;
	cin >> N >> M;

	if (M != 0) {
		vint S(M);
		vchar C(M);
		for (int i = 0; i < M; i++)
		{
			cin >> S[i] >> C[i];
		}


		string ans = "";
		for (int i = 0; i < N; i++)
		{
			ans += "a";
		}

		for (int i = 0; i < M; i++)
		{
			ans[S[i] - 1] = C[i];
		}

		for (int i = 0; i < M; i++)
		{
			for (int j = 0; j < M; j++) {
				if (S[i] == S[j] && C[i] != C[j]) {
					cout << -1;
					return 0;
				}
			}
		}

		for (int i = 0; i < M; i++)
		{
			if (S[i] > N)
			{
				cout << -1;
				return 0;
			}
		}

		for (int i = 1; i < N; i++)
		{
			if (ans[i] == 'a')
			{
				ans[i] = '0';
			}
		}
		if (ans[0] == 'a')
		{
			ans[0] = '1';
		}

		if (ans[0] == '0' && N!=1)
		{
			cout << -1;
			return  0;
		}


		cout << ans;
	}
	else
	{
		if (N != 1) {
			cout << int(pow(10, N - 1));
		}
		else {
			cout << 0;
		}
	}
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const double pi=3.14159265358979323846;
int ctoi(const char c) {
    if ('0' <= c && c <= '9') return (c - '0');
    return -1;
}
vector<int> input(int n) {
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }
    return vec;
}
void output(vector<int> vec) {
    for (int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    return;
}
vector<vector<int>> input(int n, int m) {
    vector<vector<int>> table(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> table. at(i).at(j);
        }
    }
    return table;
}
void output(vector<vector<int>> table) {
    for (int i = 0; i < table.size(); i++) {
        for (int j = 0; j < table.at(0).size(); j++) {
            cout << table.at(i).at(j) << " ";
        }
        cout << endl;
    }
}
long long perm(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long perm = 1;
    for (int i = n; i > n - r; i--) {
        perm *= i;
    }
    return perm;
}
long long comb(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long comb = perm(n,r);
    for (int i = r; i > 0; i--) {
        comb /= i;
    }
    return comb;
}
long long homo(int n, int r) {
    return comb(n + r - 1, n - 1);
}
long long fact(int n) {
    long long fact = 1;
    for (int i = n; i > 0; i--) {
        fact *= i;
    }
    return fact;
}
int gcd(int a, int b){
    if (a % b == 0){
        return(b);
    }else{
        return(gcd(b, a % b));
    }
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
bool isprime(int n){
    if (n < 2) return false;
    else if (n == 2) return true;
    else if (n % 2 == 0) return false;

    for (int i = 3; i <= sqrt(n); i += 2){
        if (n % i == 0){
            return false;
        }
    }
    return true;
}
void sayYes(bool f) {
    if (f) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}
void sayYES(bool f) {
    if (f) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

int main() {
  string s;
  cin >> s;
  rep(i,3){
    cout << s[i];
  }
  cout << endl;
}

Measured memory_bytes: 3728
h,w,k = map(int, input().split())
s = [list(input()) for i in range(h)]
ans = []
now = 0
switch = True
for key_i,i in enumerate(s):
  if any(x == "#" for x in i):
    sharp = []
    mini_ans = []
    for key_j,j in enumerate(i):
      if j == "#":
        now += 1
        sharp += [(key_j,now)]
    if len(sharp) == 1:
      mini_ans = [now] * w
      ans.append(mini_ans)
    else:
      now2 = -1
      for k1,k2 in sharp:
        mini_ans += [k2] * (k1-now2)
        now2 = k1
      mini_ans += [sharp[-1][1]] * (w - now2 -1)
      ans.append(mini_ans)
    if switch:
      switch = False
      for y in range(key_i):
        ans.append(mini_ans)
      
          
  else:
    if not switch:
      ans.append(ans[-1])
      
for i in ans:
  print(*i)

Measured memory_bytes: 8272
#define ll long long
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;

    cin>>s;

    for(int i=0;i<4-1;i++)
    {
        if(s[i]==s[i+1])
        {
            cout<<"Bad"<<endl;
            return 0;
        }
    }

    cout<<"Good"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
#include <limits.h>
#include <algorithm>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <string>
#include <string.h>
#include <sstream>
#include <ctime>

using namespace std;

#define eps 1e-12
#define pi 3.14159265358979323846
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define bgn begin
#define ll long long
#define ld long double
#define ull unsigned long long
#define ii pair<ll,ll>











ll a, b, c, k, sm;



void solve()
{
	cin >> a >> b >> c >> k;
	if(k <= a)
	{
		sm = k;
	}
	else if(k <= a + b)
	{
		sm = a;
	}
	else
	{
		sm = a - (k - (a + b));
	}
	cout << sm << "\n";
}

int main()
{
	std::ios::sync_with_stdio(0);
	cin.tie(0);
#ifdef localProject
	freopen("in.txt","r",stdin);
#endif
	solve();
	return 0;
}

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  vector<int> tmp = {A, B, C};
  sort(tmp.begin(), tmp.end());
  int mn = tmp[0], md = tmp[1], mx = tmp[2];
  int ans = mx - md;
  mn += ans;
  if ((mx - mn) % 2) {
    ans += 2;
  }
  ans += (mx - mn) / 2;
  cout << ans << endl;
}

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

int main(){
  int x;
  cin >> x;
  cout << (x == 0 ? 1 : 0) << endl;
  return 0;
}


Measured memory_bytes: 3588
#include <stdio.h>//c??§aoj Ring
#include <string.h>
int main(void)
{
	char s[100], p[100];
	int i, j, count=0, a=0;

	scanf("%s", s);
	scanf("%s", p);

	for (i=0;i<=strlen(s);i++)
	{
		count=0;

		if (p[0] == s[i])
		{
			for (j=0;j<=strlen(p)-1;j++)
			{
				if (strlen(s) > i+j)
				{
					if (s[i+j] != p[j])
					{
						count++;
					}
				}
				else if (strlen(s) <= i+j)
				{
					if (s[i+j-strlen(s)] != p[j])
					{	
						count++;
					}
				}

				else if (count != 0)
				{
					break;
				}
			}

			if (count == 0)
			{
				a=1;
			}
		}
	}
	if (a==1)
	{
		printf("Yes\n");
	}
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 524
import math

a, b, h, m = map(int, input().split())
fai = 30 * h + 0.5 * m
sita = 6 * m
kakudo = abs(fai - sita)
print(((a ** 2) + (b ** 2) - (2 * a * b * math.cos(math.radians(kakudo)))) ** 0.5)


Measured memory_bytes: 62380
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
const int Maxx = 1e5;
int n;
int a[Maxx + 7];

int main() {
	while(scanf("%d", &n) != EOF) {
		int sum = 0;
		for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
		a[0] = 0;
		a[n + 1] = 0;
		for(int i = 1; i <= n + 1; i++) sum += abs(a[i] - a[i - 1]); //所有花费
		for(int i = 1; i <= n; i++) {
			int t1 = abs(a[i + 1] - a[i]); //多加的花费，要减掉
			int t2 = abs(a[i] - a[i - 1]); //多加的花费，要减掉
			int t3 = abs(a[i + 1] - a[i - 1]); //删除后新的花费，要加上
			printf("%d\n", sum - t1 - t2 + t3);
		}
	}
}

Measured memory_bytes: 1536
//code by lynmisakura.wish to be accepted
/****************************/
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
#include<set>
#include<bitset>
using namespace std;
/***************************/
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<pair<int,int>> vpi;

const long long Mod = 998244353;
const long long mod = 1000000007;
const long long INF = 10000000000000;

#define itn int
//#define endl "\n"
#define pb push_back
#define mp make_pair
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(int i = 0;i < n;i++)
#define rep(i,n) for(int i = 0;i < n;i++)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }

#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define MAX_N 200020
int par[MAX_N];
int main(void){
	
	int n;cin >> n; int qe;cin >> qe;
	vector<vector<int>> T(n,vector<int>(0));
	rep(i,n-1){
		int a,b;cin >> a >> b;
		a--,b--;
		T[a].pb(b);T[b].pb(a);
	}
	vector<int> parent(n,-1);
	vector<ll> p(n,0LL);
	rep(i,qe){
		ll a,x;cin >> a >>x;
		a--;
		p[a] += x;
	}
	
	
	vector<ll> ans(n,0LL);
	
	
	queue<int> q;
	q.push(0);
	vector<int> check(n,0);
	check[0] = 1;
	q.push(0);
	parent[0] = 0;
	ans[0] = p[0];
	while(!q.empty()){
		int x = q.front(); q.pop();
		check[x] = 1;
		for(int i = 0;i < T[x].size();i++){
			if(check[T[x][i]] == 0){
				q.push(T[x][i]);
				ans[T[x][i]] = ans[x] + p[T[x][i]];
			}
		}
	}
	//rep(i,n) debug(p[i]);
	rep(i,n) cout << ans[i] << endl;
	return 0;
}


Measured memory_bytes: 20212
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scn = new Scanner(System.in);
		int n,buf;
		while((n = scn.nextInt()) != 0) {
			int[][] ans = new int[n+1][n+1];
			for(int i = 0;i < n;i++) {
				buf = 0;
				for(int j = 0;j < n;j++) {
					ans[i][j] = scn.nextInt();
					buf += ans[i][j];
				}
				ans[i][n] = buf;
			}
			for(int j = 0; j <= n ;j++) {
				buf = 0;
				for(int i = 0;i < n;i++) {
					buf += ans[i][j];
				}
				ans[n][j] = buf;
			}

			for(int i = 0;i < n+1;i++) {
				for(int j = 0;j < n+1;j++) {
					System.out.print(String.format("%5d", ans[i][j]));
				}
				System.out.println();
			}

		}
	}
}


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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int n, d, x, total=0;
    cin >> n >> d >> x;

    for(int i=0; i<n; i++){
        int a, sum = 0;
        cin >> a;
        int j = 1;
        for(int k=0; k<d; k++){
            if(a*k+1>d) break;
            sum++;
        }
        total+=sum;
    }
    cout << total+x << endl;
    return 0;
}

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

using namespace std;
#define rep(i,n) for(int i = 0 ; i < n ; ++i)
using ll = long long;

vector<int> ans;
void solve(int n){
    int idx = lower_bound(ans.begin(), ans.end(), n+1)-ans.begin();
    --idx;
    cout<<ans[idx]-2<<" "<<ans[idx]<<endl;
}

int main(){
    vector<int> isprime(12345,1);
    isprime[1]=isprime[0]=false;
    for(int i = 2 ; i <=10000 ; ++i){
        if(!isprime[i])continue;
        if(isprime[i-2])ans.push_back(i);
        for(int j = 2 * i ; j <= 10000 ; j+=i){
            isprime[j]=false;
        }
    }
    int n;
    while(cin>>n,n!=0)solve(n);
}


Measured memory_bytes: 3208
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.buffer.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

a, v = rm()
b, w = rm()
t = ri()
if v - w == 0:
  print('NO')
  exit()
if 0 <= abs(a-b) / (v-w) <= t:
  print('YES')
else:
  print('NO')



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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> v(n);

    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    int sum = 0;
    int str = n - k;
    for(int i = str; i < n; i++){
        sum += v[i];
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
n,m,c = gets.chomp.split(" ").map{|i|i = i.to_i}
b = gets.chomp.split(" ").map{|i|i = i.to_i}
a = []
count = 0
n.times do|i|
  a = gets.chomp.split(" ").map{|ii|ii = ii.to_i}
  sum = c
  m.times do|j|
    sum+=a[j]*b[j]
  end
  if sum>0 then count+=1 end
end
puts count






Measured memory_bytes: 1788
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int N, L;
	cin >> N >> L;
	vector<string> vec;
	for (int i = 0; i < N; i++) {
		string s;
		cin >> s;
		vec.push_back(s);
	}
	sort(vec.begin(), vec.end());
	string res;
	for (string s : vec) {
		res += s;
	}
	cout << res << endl;
	return 0;


}

Measured memory_bytes: 3676
#include "bits/stdc++.h"

#include <unordered_map>

//#include <iostream>//POJ
//#include <vector>
//#include <string>
//#include <iomanip>
//#include <math.h>
//#include <algorithm>
//#include <cstring>
using namespace std;
#define setc cin.tie(0);ios::sync_with_stdio(0)
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define repi_(i,a,b) for(int i=(a), i##_len=(b); i<=i##_len; ++i)
#define rep_(i,n) repi_(i,0,n)
#define repir(i,a,b) for(int i=(a)-1, i##_first=(b); i>=i##_first; --i)
#define repr(i,n) repir(i,n,0)
#define repir_(i,a,b) for(int i=(a), i##_first=(b); i>=i##_first; --i)
#define repr_(i,n) repir_(i,n,0)
#define all(x) (x).begin(),(x).end()
#define vsort(v) sort((v).begin(), (v).end())
#define gsort(v) tsort(v); reverse((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())
//template<typename T> T vpop(vector<T> *v) {
//	T res = v->back();
//	v->pop_back();
//	return res;
//}
//char vpop(string *v) {
//	char res = v->back();
//	v->pop_back();
//	return res;
//}
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define cnt(v, n) count(all(v), n)
#define vmin(v) *min_element(v.begin(), v.end())
#define vmax(v) *max_element(v.begin(), v.end())
#define contain(q) !q.empty()
#define cont(q) !q.empty()
//#define qpop(q, a, b) a=q.back().first;b=q.back().second;q.pop()
//#define pqpop(p, a, b) a=q.top().first;b=q.top().second;q.pop()
#define el "\n"
#define sp " "
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define cosp(x) cout<<(x)<<' '
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#define POSSIBLE(c) coc(c, "POSSIBLE", "IMPOSSIBLE")
#define Possible(c) coc(c, "Possible", "Impossible")
#define possible(c) coc(c, "possible", "impossible")
#define inf INT_MAX
#define wildcard(T) numeric_limits<T>::min()

#define pb push_back
#define pq priority_queue
#define np next_permutation

#ifdef tqktmp_2
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
const unsigned int bf0 = (1 << 0);
const unsigned int bf1 = (1 << 1);
const unsigned int bf2 = (1 << 2);
const unsigned int bf3 = (1 << 3);
const unsigned int bf4 = (1 << 4);
const unsigned int bf5 = (1 << 5);
const unsigned int bf6 = (1 << 6);
const unsigned int bf7 = (1 << 7);

typedef long long lint;
typedef vector<int> ivec; typedef vector<string> svec;
typedef vector<lint> lvec;
typedef vector<vector<int>> ivvec;
typedef pair<int, int> P;

const int
dx8[8] = { 0,1,1,1,0,-1,-1,-1 },
dy8[8] = { 1,1,0,-1,-1,-1,0,1 },
dx4[4] = { 0,1,0,-1 },
dy4[4] = { 1,0,-1,0 };

template<class T>inline bool maxi(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool mini(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

int main(){
	setc;

	int list[6]={ 105,135,165,189,195,inf };
	lint n;cin>>n;
	lint ans=0;
	rep(i, 6){
		if (list[i] > n){
			co(i);
			gc();
			return 0;
		}
	}
	gc();
}


Measured memory_bytes: 256
def is_prime(n):
    if n==2:
        return True
    if n%2==0 or n==1:
        return False
    for i in range(3,int(n**0.5)+1,2):
        if n%i==0:
            return False
    return True
        
n = int(input())
print(str(n)+": ", end='')
if is_prime(n):
    print(n)
else:
    ans = []
    while n % 2 == 0:
        n //= 2
        ans.append(2)
    d = 3
    while d <= n ** 0.5:
        if is_prime(d):
            while n % d == 0:
                n //= d
                ans.append(d)
        d += 2
    if is_prime(n):
        ans.append(n)
    print(*ans)


Measured memory_bytes: 5656
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(auto i = (N) - 1; i >= 0; i -= 1)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define rand mtrand
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cout << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,...) do { cout << #v << " = "; array_out(v , ##__VA_ARGS__);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
#endif
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = 0x1FFFFFFFFFFFFFFFLL;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}

random_device seed_gen; mt19937_64 mtrand(seed_gen());
constexpr int MOD = 1000000007;
//////////////////////////////////////////

int main(){
  ins(S); ini(w);
  for(int i = 0; i < sz(S); i += w){
    cout << S[i];
  }
  out();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef signed long long int ll;
#define INF (1<<29)
int l;
//ll a[200005];
ll a;
ll dp[200005][5]={0};
int main(){
    cin>>l;
    //for(int i=0;i<l;i++) cin>>a[i];
    
    /*for(int i=0;i<5;i++){
        for(int j=0;j<l+2;j++){
            dp[j][i]=INF;
        }
    }*/
    
    //for(int i=0;i<5;i++) dp[0][i]=0;
    
    for(int i=1;i<=l;i++){
        cin>>a;
        int b=(a==0?2:(a%2));
        
        int c=!(a%2);
        
        dp[i][0]=dp[i-1][0]+a;
        
        dp[i][1]=min(dp[i][0],dp[i-1][1]+b);
        
        dp[i][2]=min(dp[i][1],dp[i-1][2]+c);
        
        dp[i][3]=min(dp[i][2],dp[i-1][3]+b);
        
        dp[i][4]=min(dp[i][3],dp[i-1][4]+a);
        
    }
    cout<<dp[l][4]<<endl;
    return 0;
    
}


Measured memory_bytes: 8064
#include <stdio.h>
int gcd(int a,int b)
{

	if(a%b==0)

		return b;

	else

		return(gcd(b,a%b));

}

int main(void)
{
	int x,y,tmp;
	scanf("%d %d",&x,&y);
	if(y>x){
		tmp=x;
		x=y;
		y=tmp;
	}		
	printf("%d\n",gcd(x,y));
	return 0;
}	


Measured memory_bytes: 2104
#include <cstdio>
#include <cstring>

using namespace std;

int N,A;
int x[51];
long long dp[3000][52][52];

int main() {
  scanf("%d%d",&N,&A);
  for(int i=0;i<N;++i) {
    scanf("%d", &x[i]);
  }
  memset(dp, 0,sizeof(dp));
  dp[0][0][0]=1;
  for(int k=0;k<N;++k) {
  for(int j=0;j<N;++j) {
  for(int i=0;i<2600;++i) {
        dp[i+x[j]][j+1][k+1] += dp[i][j][k];
        dp[i][j+1][k] += dp[i][j][k];
      }
    }
  }
  long long answer =0;
  for(int i=1;i<=N;++i) {
    answer += dp[i*A][N][i];
  }
  printf("%lld\n", answer);
  return 0;
}


Measured memory_bytes: 63616
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b,i,j,k,n,m,x,y,z,t;
    double a1,a2;
    cin>>n;

    m=n*n;
    if(n==1)
    {
        cout<<1<<endl;

    }
    else
    {
        cout<<n*n<<endl;
    }
}


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

using namespace std;

typedef long long ll;

ll N, M, P, Q, R, S, A, B, C, D, E, F, X, Y, Z;
ll arr[200005];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5]){
		cout << "Yes\n";
	}
	else cout << "No\n";
	return 0;
}

Measured memory_bytes: 256