akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long int
using namespace std;

int main()
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll op1=a*c;
    ll op2=a*d;
    ll op3=b*c;
    ll op4=b*d;
    
    cout<<max(op1,max(op2,max(op3,op4)));
}


Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
using namespace std;
#define MAX 200
char s[MAX], t[MAX];
int n;

int Ans(){
    int ans1=0, ans2=0, flag=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(s[i]!=t[j])break;
            int k;
            ans1=1;
            for(k=1;k<n-i;k++){
                if(s[i+k]==t[j+k]){ans1++;continue;}
                else break;
            }
            if(k==n-i){flag=1;break;}
        }
        if(flag)break;
    }
    flag=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(t[i]!=s[j])break;
            int k;
            ans2=1;
            for(k=1;k<n-i;k++){
                if(s[j+k]==t[i+k]){ans2++;continue;}
                else break;
            }
            if(k==n-i){flag=1;break;}
        }
        if(flag)break;
    }
    if(!ans1&&!ans2)return n*2;
    ans1=n-ans1+n;
    ans2=n-ans2+n;
    return ans1>ans2?ans2:ans1;
}

int main()
{
    while(cin>>n){
        scanf("%s", &s[0]);
        scanf("%s", &t[0]);
        int ans = Ans();
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define re register
#define ll long long
#define inc(i,j,k) for(re int i=j;i<=k;i++)
#define dec(i,j,k) for(re int i=j;i>=k;i--)
#define edge(u) for(re int i=head[u];i;i=e[i].nxt)
#define pb push_back
#define mp make_pair
#define In inline
#define fi first
#define se second
#define db double
#define ui unsigned int
#define ull unsigned long long 
using namespace std; 
inline int read(){
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while('0'<=ch&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return f*x;
}
ll a,b,v,w,t;
int main(){ 
	a=read(),v=read(),b=read(),w=read(),t=read();
	if(a==b) return puts("YES"),0;
	if(v<=w) return puts("NO"),0;
	if((v-w)*t>=abs(a-b)) return puts("YES"),0;
	puts("NO");
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<int> a(200010),count(200010);
  for(int i=2;i<=n;i++){
    cin >> a[i];

  }
    for(int i=0;i<n;i++){
      count[i] = 0;
    }
for(int i=2;i<=n;i++){
  count[a[i]]++;
}
  for(int i=1;i<=n;i++){
  cout << count[i] <<endl;
}
}

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



using namespace std;



static const int INF = 999999;



int main(){

	int n,array[100][100];



	for(int i=0; i<100; i++){

		for(int j=0; j<100; j++){

			if(i==j) array[i][j]=0;

			else array[i][j]=INF;

		}

	}

	

	cin>>n;



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

		int u,k;

		cin>>u>>k;

		for(int j=0; j<k; j++){

			int t,c;

			cin>>t>>c;

			array[u][t]=c;

		}

	}



	int d[100];

	fill(d,d+n,INF);

	d[0]=0;

	bool flag[100]={};



	while(1){

		int u=-1,infn=INF;

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

			if(!flag[i] && d[i]<=infn){

				u = i;

				infn = d[u];

			}

		}

		if(u==-1) break;

		flag[u] = true;



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

			if(array[u][i]!=INF && !flag[i]){

				d[i] = min(d[i],d[u]+array[u][i]);

			}

		}

	}



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

		cout<<i<<" "<<d[i]<<endl;

	}



	return 0;

}

Measured memory_bytes: 1200
import Data.List (findIndex)
import Data.Maybe (maybe)

main = putStrLn =<< solve <$> getLine

solve :: String -> String
solve s = unwords [show a, show b] where
    (a, b) = solve' s

solve' :: String -> (Int, Int)
solve' = maybe (-1, -1) (\(a, b) -> (a + 1, b + 1)) . findUnBalanceIndex

findUnBalanceIndex :: String -> Maybe (Int, Int)
findUnBalanceIndex [a, b]
    | a == b = Just (0, 1)
    | otherwise = Nothing
findUnBalanceIndex s = fmap (\i -> (i, i + 2)) . findIndex isUnbalance $ window' s

isUnbalance :: String -> Bool
isUnbalance [a, b, c] = a == b || b == c || c == a
isUnbalance s = error $ "length s must be 3 but " ++ (show $ length s)

window' :: [a] -> [[a]]
window' [] = []
window' [a] = []
window' [a, b] = []
window' xs = take 3 xs : window' (tail xs)


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

int ans;

int main()
{
    int x, a, b, left, amountOfDon;

    cin >> x >> a >> b;

    if(x - a >= 0)
    {
        ans++;

        x -= a;

        left = 0;
        amountOfDon = 0;

        left = x % b;

        x -= left;

        amountOfDon = x / b;

        if(amountOfDon > 0)

        x -= b * amountOfDon;
    }

    cout << x + left;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 

vll dp(100100);

ll sum(ll n) {
ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}


 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n,k;
    ci(n>>k);
  st s;
    ci(s);
  vll A;
  ll count=1;
  FOR(i,1,n-1){
    if(s[i]!=s[i-1]){
      A.push_back(count);
      count=1;
    }
    else{
      count++;
    }
  }

  if(s[n-1]!=s[n-2]){
    A.push_back(count);
    A.push_back(1);
  }
  else{
    A.push_back(count+1);
  }

  ll a=A.sz;
  ll ans=0;
  FOR(i,0,a){
    //co(A[i])
    ans+=A[i]-1;
  }
  
  if(k>=a/2){
    ans=n-1;
  }
  else{
    ans+=2*k;
  }
  co(ans)
  }

Measured memory_bytes: 2296
#define _USE_MATH_DEFINES  
#include <bits/stdc++.h>
#include <cmath>
#include <iomanip>

using namespace std;

int main(void) {
    int R;

    cin >> R;

    cout << setprecision(20) << (R * 2) * (double)M_PI << endl;

    return 0;
}


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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = 1e9+7; typedef vector<ll> VL;

void dbg(){ cerr << "\n"; } template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	vector<string> vs(n);
	rep(i, n) cin >>vs[i];
	
	int ans =0;
	rep(i,n){
		int c=0;
		while(1){
			c = vs[i].find("AB", c);
			if(c==-1) break;
			ans++; c++;
		}
	}
	
	int ab=0, a=0, b=0;
	rep(i,n){
		if(vs[i][0] =='B' && vs[i].back()=='A') ab++;
		else if(vs[i][0] =='B') b++;
		else if(vs[i].back() =='A') a++;
	}
	
	VI sv ={ans, ab, a, b};
	
	if(ab>1){
		ans += ab-1;
		ab =1;
	}
	if(a>0 && b>0 && ab>0){
		ans += 2; a--; b--; ab--;
	}
	
	ans += min(a,b);
	if(a !=b && ab==1) ans++;
	
	dbg(ans, ab,a,b);
	cout << ans <<"\n";
	

	return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <array>

using namespace std;

int main() {
	vector <vector <int>> spreadsheet;
	vector <int> pusher;
	int rows = 0;
	int columns = 0;
	int total = 0;
	int sum = 0;
	int num = 0;

	cin >> rows >> columns;
	for (int i = 0; i < rows; i++) {
		for (int j = 0; j < columns; j++) {
			cin >> num;
			pusher.push_back(num);
		}
		spreadsheet.push_back(pusher);
		pusher.clear();
	}
//	for (int i = 0; i < rows; i++) {
//		for (int j = 0; j < columns; j++) {
//			cout << spreadsheet[i][j];
//			if (j != columns-1) {
//				cout << ' ';
//				continue;
//			}
//			cout << endl;
//		}
//	}
	for (int i = 0; i < rows; i++) {
		for (int j = 0; j < columns; j++) {
			sum += spreadsheet[i][j];
		}
		spreadsheet[i].push_back(sum);
		total += sum;
		sum = 0;
	}
	for (int j = 0; j < columns; j++) {
		for (int i = 0; i < rows; i++) {
			sum += spreadsheet[i][j];
		}
		pusher.push_back(sum);
		total += sum;
		sum = 0;
	}
	pusher.push_back(total/2);
	spreadsheet.push_back(pusher);
	rows++;
	columns++;
	for (int i = 0; i < rows; i++) {
		for (int j = 0; j < columns; j++) {
			cout << spreadsheet[i][j];
			if (j != columns-1) {
				cout << ' ';
				continue;
			}
			cout << endl;
		}
	}
}



Measured memory_bytes: 3156
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

s=list(ss())
if s[2]==s[3] and s[4]==s[5]:
    print("Yes")
else:
    print("No")









Measured memory_bytes: 65516
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int D = sc.nextInt();
		int[] c = new int[26];
		Arrays.setAll(c, i -> sc.nextInt());
		int[][] s = new int[D][26];
		for(int i = 0; i < D; i++)
			Arrays.setAll(s[i], x -> sc.nextInt());
		int[] con = new int[D];
		TreeSet<Integer>[] used = new TreeSet[26];
		for(int i = 0; i < 26; i++) {
			used[i] = new TreeSet<>();
			used[i].add(-1);
		}
		int sat = 0;
		for(int d = 0; d < D; d++) {
			int t = sc.nextInt()-1;
			con[d] = t;
			used[t].add(d);
			sat += s[d][t];
			for(int j = 0; j < 26; j++)
				sat -= c[j] * (d - used[j].last());
		}
		for(int i = 0; i < 26; i++)
			used[i].add(D);
		int M = sc.nextInt();
		for(int i = 0; i < M; i++) {
			int d = sc.nextInt()-1;
			int q = sc.nextInt()-1;
			sat -= s[d][con[d]];
			sat += s[d][q];
			used[con[d]].remove(d);
			sat -= c[con[d]] * (used[con[d]].ceiling(d) - d) * (d - used[con[d]].lower(d));
			sat += c[q] * (d - used[q].lower(d)) * (used[q].ceiling(d) - d);
			con[d] = q;
			used[q].add(d);
			System.out.println(sat);
		}
	}

}

Measured memory_bytes: 63228
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint operator^(const ll& t)const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

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


int main() {
	ll X, Y;
	cin >> X >> Y;
	if (X%Y == 0) { cout << -1<<endl; }
	else { cout << X<<endl; }
	
	system("PAUSE");
}


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

using namespace std;

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

typedef complex<double> point;
struct line { point p, q; };

double dot(point a, point b) { return real(conj(a) * b); }

point projection(const line &l, const point &p)
{
	double t = dot(p - l.p, l.p - l.q) / norm(l.p - l.q);
	return l.p + t * (l.p - l.q);
}

point reflection(const line &l, const point &p)
{
	return p + 2.0 * (projection(l, p) - p);
}

point read(){
	double x, y; cin >> x >> y;
	return point(x, y);
}

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

	point p, q;
	p = read(), q = read();
	line l = {p, q};

	int n; cin >> n;
	for (int i = 0; i < n; ++i){
		point r = read();
		point a = reflection(l, r);
		cout.precision(15);
		cout << fixed << a.real() << " " << a.imag() << endl;
	}

	return 0;
}

Measured memory_bytes: 1324
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-05-20 00:27:08 +0900
# LastModified: 2020-05-20 13:11:16 +0900
#


import os
import sys
#import numpy as np
#import pandas as pd
from itertools import combinations_with_replacement as crlp

def main():
    n,m,q = map(int,input().split())
    ans = 0
    a = []
    b = []
    c = []
    d = []
    for _ in range(q):
        a_,b_,c_,d_ = map(int,input().split())
        a.append(a_-1)
        b.append(b_-1)
        c.append(c_)
        d.append(d_)

    for seq in crlp(range(1,m+1),n):
        tmp = 0
#        print(seq)
        for i in range(q):
            if seq[b[i]]-seq[a[i]]==c[i]:
                tmp+=d[i]
        if ans<tmp:
            ans=tmp
    print(ans)

    


if __name__ == "__main__":
    main()


Measured memory_bytes: 9232
antenas = [int(raw_input()) for i in range(5)]
dist = int(raw_input())
antenas.sort()
antenas2 = antenas

dists = [antenas2[j]-antenas[i] for i in range(5) for j in range(5)]

n = sum(i > dist for i in dists)
if n == 0:
    print "Yay!"
else:
    print ":("

Measured memory_bytes: 2568
#include <stdio.h>

void printA(int, int *);

int main(void)
{
	int i, j, v, n, A[100];
	
	scanf("%d",&n);
	for (i=0; i<n; i++) {
		scanf("%d",&A[i]);
	}
	printA(n, A);
	for (i=1; i<n; i++) {
		v = A[i];
		j = i-1;
		while(j>=0 && A[j]>v) {
			A[j+1] = A[j];
			j--;
		}
		A[j+1] = v;
		printA(n, A);
	}
	return 0;
}

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

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int N,g=0;
  cin>>N;
  vector<int> A(N);
  for(int &i:A){
    cin>>i;
    g+=i;
  }
  vector<int> B(N);
  for(int i=1;i<N;i+=2)
    B[0]+=A[i];
  for(int i=1;i<N;i++)
    B[i*2%N]=B[(i*2-2+N)%N]+A[(i*2-2)%N]-A[(i*2-1+N)%N];
  for(int i=0;i<N;i++){
    cout<<g-B[i]*2;
    if(i==N-1)
      cout<<endl;
    else
      cout<<' ';
  }
}

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

int main() {
  int N;
  string S;
  cin >> N >> S;
  int ans = 0;
  for (int P = 0; P <= 999; ++P) {
    int p[] = {P / 100, P / 10 % 10, P % 10}, j = 0;
    for (int i = 0; i < S.size(); ++i) {
      if (S[i] - '0' == p[j])
        ++j;
      if (j == 3) {
        ++ans;
        break;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void)
{
    char s[100],a,t[100];
    int n,i;
    scanf("%s",s);
    n = strlen(s);
    for(i = 0 ; i < (n - 1)/2 ; i++)
    {
        if(s[i] != s[n - i - 1])
        {
            printf("No");
            return 0 ;
        } 
    }
    for(i = 0; i <= (n-3)/4 ; i++)
    {
        if(s[i] != s[(n-3)/2-i])
        {
            printf("No");
            return 0 ;
        }
    }
    for(i = 0 ; i <= (n-7)/4 ; i++)
    {
        if(s[i + (n+1)/2] != s[n - i-1])
        {
            printf("No");
            return 0 ;
        }
        
    }
    printf("Yes");
    return 0;

}

Measured memory_bytes: 1732
n=int(input())
a=[int(i) for i in input().split()]
g=[]
k=[]
for i in a:
    if i%2==0:
        g+=[i]
        g=[sum(g)]
    else:
        k+=[i]
        if len(k)%2==0:
            g+=[sum(k)]
            k=[]

print('YES'if g==[] or k==[] else 'NO')

Measured memory_bytes: 14108
#include<algorithm>
#include<array>
#include<cmath>
#include<iostream>
#include<iomanip>
#include<iso646.h>
#include<queue>
#include<stack>
#include<string>
#include<vector>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

#define FOR(counter,initial_value,condition) for(int counter = initial_value; counter < condition;counter++)


int main()
{
	string a, b;
	cin >> a >> b;
	if (a.length() > b.length())cout << "GREATER" << endl;
	else if (a.length() < b.length())cout << "LESS" << endl;
	else {
		FOR(i, 0, a.length()) {
			if (a[i] != b[i]) {
				if (a[i] > b[i]) {
					cout << "GREATER" << endl;
					return 0;
				}
				if (a[i] < b[i]) {
					cout << "LESS" << endl;
					return 0;
				}
			}
		}
		cout << "EQUAL" << endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Bye return 0
#define ll long long

using namespace std;

void solve(){
    ll n, m, x; cin>>n>>m>>x;
    ll price[n];
    ll level[n][m];
    for (ll i=0; i<n; i++){
        cin>>price[i];
        for (ll j=0; j<m; j++)
            cin>>level[i][j];
    }

    ll minimum = LONG_LONG_MAX;
    for (ll i=1; i<(1<<n); i++){

        vector<ll> understand(m);
        ll payment = 0;
        for (ll j=0; j<n; j++){
            if(i & (1<<j)){
                payment += price[j];
                for (ll x=0; x<m; x++)
                    understand[x] += level[j][x];
            }
        }

        ll counter = 0;
        for (ll j=0; j<m; j++)
            counter += (understand[j]>=x);
        
        if(counter == m) minimum = min(minimum, payment);
    }

    cout<<(minimum^LONG_LONG_MAX ? minimum: -1)<<endl;
}

int main(){
    solve();
    Bye;
}

Measured memory_bytes: 3604
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <stack>
#include <functional>
#include <sstream>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007
#define M 998244353

using namespace std;

int main(){
    lli a,b,n,x,ans;
    lli i,j;
    cin>>a>>b>>n;
    x=b;
    if(n<b){
        ans=n*a/b;
    }
    else{
        lli c=n/b;
        x=c*b-1;
        lli sum1=floor(x*a/b)-a*floor(x/b);
        lli sum2=floor(n*a/b)-a*floor(n/b);
        ans=max({sum1,sum2,ans});
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3632
class SparseTableMAX():
    def __init__(self, array, n):
        '''テーブルを構築する'''
        self.row_size = n.bit_length()
        
        # log_tableを構築する
        # log_table = [0, 0, 1, 1, 2, 2, 2, 2, ...]
        self.log_table = [0] * (n + 1)
        for i in range(2, n + 1):
            self.log_table[i] = self.log_table[i//2] + 1
        
        # sparse_tableを構築する
        self.sparse_table = [[0] * n for _ in range(self.row_size)]
        for i in range(n):
            self.sparse_table[0][i] = array[i]
        for row in range(1, self.row_size):
            for i in range(n - (1 << row) + 1):
               self.sparse_table[row][i] = self._merge(self.sparse_table[row - 1][i], \
                                                       self.sparse_table[row - 1][i + (1 << row - 1)])

    def _merge(self, num1, num2):
        '''クエリの内容'''
        return max(num1, num2)

    def query(self, l, r):
        '''区間[l, r)に対するクエリに答える'''
        if r == l:
            return None
        row = self.log_table[r - l]
        return self._merge(self.sparse_table[row][l], self.sparse_table[row][r - (1 << row)])


class SparseTableMIN():
    def __init__(self, array, n):
        '''テーブルを構築する'''
        self.row_size = n.bit_length()
        
        # log_tableを構築する
        # log_table = [0, 0, 1, 1, 2, 2, 2, 2, ...]
        self.log_table = [0] * (n + 1)
        for i in range(2, n + 1):
            self.log_table[i] = self.log_table[i//2] + 1
        
        # sparse_tableを構築する
        self.sparse_table = [[0] * n for _ in range(self.row_size)]
        for i in range(n):
            self.sparse_table[0][i] = array[i]
        for row in range(1, self.row_size):
            for i in range(n - (1 << row) + 1):
               self.sparse_table[row][i] = self._merge(self.sparse_table[row - 1][i], \
                                                       self.sparse_table[row - 1][i + (1 << row - 1)])

    def _merge(self, num1, num2):
        '''クエリの内容'''
        return min(num1, num2)

    def query(self, l, r):
        '''区間[l, r)に対するクエリに答える'''
        if r == l:
            return None
        row = self.log_table[r - l]
        return self._merge(self.sparse_table[row][l], self.sparse_table[row][r - (1 << row)])
      
n, k = map(int, input().split())
a = list(map(int, input().split()))
max_st = SparseTableMAX(a, n)
min_st = SparseTableMIN(a, n)

ans = 0
for i in range(1,n-k+1):
    l = a[i-1]
    r = a[i+k-1]
    min_ = min_st.query(i-1, i-1+k)    
    max_ = max_st.query(i, i+k)
    if l != min_ or r != max_:
        ans += 1

tmp = 0
cnt = 0
tmp_ans = 0
l = -1
for i in range(1, n):
    if a[i-1] > a[i]:
        tmp = i
    if i >= k-1 and tmp <= i - k + 1:
        if i - l > 1:
            cnt += 1
        l = i
ans += 1 - max(cnt - 1, 0)

print(ans)

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

int main() {
    ll N; cin >> N;
    string ans = "APPROVED";
    vector<ll> v(N); for(int i = 0; i < N; ++i) {
        cin >> v[i];
        if (v[i] % 2 == 0) {
            if (v[i] % 3 != 0 && v[i] % 5 != 0) ans = "DENIED";
        }
    }
    cout << ans << endl;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  int ans = 0;
  for(int i=0; i<N; i++){
    ans ^= vec.at(i);
  }
  
  if(ans == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;

int main(){
    long N;
    scanf("%ld",&N);
    long count = 0;
    for (int i=1; i<sqrt(N); i++){
        if (N%i == 0){
            if(N/i > i+1){
                count += N/i - 1;
            }
        }
    }
    if (N==2){
        printf("0");
    }
    else if(N==6){
        printf("5");
    }
    else{
    printf("%ld",count);
    }
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
int a, b;
scanf("%d %d", &a, &b);
if(a>b)
printf("a > b\n");
else if(a<b)
printf("a < b\n");
else if(a==b)
printf("a == b\n");
return 0;
}

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

int main(){
  int n,i;
  string s;
  cin >> n;
  cin >> s;
  if(n%2!=0){
    cout << "No" << endl;
    return 0;
  }else{
    for(i=0;i<n/2;++i){
      if(s[i]==s[n/2+i]){
        continue;
      }else{
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;

}


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

int main() {
	vector<string> hand(3);
	for(int i = 0; i < 3; i++) cin >> hand.at(i);

	int turn = 0;
	while(true) {
		if(hand.at(turn) == "") break;
		char next = hand.at(turn).at(0);
		hand.at(turn).erase(hand.at(turn).begin());
		switch(next) {
			case 'a': turn = 0; break;
			case 'b': turn = 1; break;
			case 'c': turn = 2; break;
			default: break;
		}
	}

	switch(turn) {
		case 0: cout << "A" << endl; break;
		case 1: cout << "B" << endl; break;
		case 2: cout << "C" << endl; break;
		default: break;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
using namespace std;
typedef pair<int,int>pii;
int n,m,root;
vector<int>G[100010];
int rudu[100010];
int rnk[100010];
int fa[100010];
int dfs(int x){
	if(rnk[x]!=-1)return rnk[x];
	rnk[x]=0;
	for(int to:G[x]){
		rnk[x]=max(rnk[x],dfs(to)+1);
	}
	return rnk[x];
}
void dfs2(int x,int pr){
	if(fa[x]!=-1)return;
	fa[x]=pr;
	vector<pii>ch;
	for(auto to:G[x])ch.push_back(mp(rnk[to],to));
	sort(ch.begin(),ch.end(),[](pii a,pii b){return a>b;});
	for(auto to:ch)dfs2(to.second,x);
}
int main(){
	memset(rnk,-1,sizeof(rnk));
	memset(fa,-1,sizeof(fa));
	cin>>n>>m;
	for(int i=1;i<=n+m-1;i++){
		int x,y;
		cin>>x>>y;
		G[x].pb(y);
		rudu[y]++;
	}
	for(int i=1;i<=n;i++)if(rudu[i]==0)root=i;
	dfs(root);
	dfs2(root,0);
	for(int i=1;i<=n;i++)cout<<fa[i]<<endl;
	return 0;
}


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

int main(){
	char s[100+1];
	char res[1024];
	int i,j;

	while(cin >> s){
		i=0;
		j=0;


		while(s[i]!='\0'){

			if(s[i]!='@'){
				res[j]=s[i];
				++j;
			}

			else if(s[i]=='@'){
				++i;
				for(int k=0;k<s[i]-'0';++k){
					res[j]=s[i+1];
					++j;
				}
				++i;
			}
			++i;
		}
		res[j]='\0';

		cout<<res<<endl;



	}
	return 0;
}








		

Measured memory_bytes: 1136
# coding: utf-8
# Your code here!
import collections 
 
N=int(input())
l=[]
 
for i in range(N):
    l.append(list(input()))
    l[i].sort()
    l[i]="".join(l[i])
    
clist=list(collections.Counter(l).values())

count=0
for c in clist:
    count+=int(c*(c-1)//2)
    
print(count)

Measured memory_bytes: 19720
#include <stdio.h>

#define SIZE 16384

int linearSearch(int *S, int n, int key){
  int i = 0;
  S[n] = key;
  while (S[i] != key)
    i++;
  if (i == n)
    // not found
    return 0;
  return 1;
}

int main(void){
  int n, q, S[SIZE] = {0}, T[SIZE] = {0}, C = 0, i;

  scanf("%d", &n);
  for (i = 0; i < n; i++)
    scanf("%d", &S[i]);
  scanf("%d", &q);
  for (i = 0; i < q; i++)
    scanf("%d", &T[i]);

  // search for S
  for (i = 0; i < q; i++)
    if (linearSearch(S, n, T[i]))
      C++;
  printf("%d\n", C);

  return 0;
}

Measured memory_bytes: 736
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0L;i--)
#define prep(i,n) for(int64_t i=1;i <= (int64_t)(n);i++)
using namespace std;

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  fspcnt = 0;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}

int64_t calcmodcomb(int64_t n,int64_t r){
  return (((modfact.at(n)*modinvfact.at(r))%univMod)*modinvfact.at(n-r))%univMod;
}

int64_t calcmodpositive(int64_t n){
  return (n + ((abs(n)+univMod-1)/univMod)*univMod)%univMod;
}
  
    */


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  if(accumulate(a.begin(),a.end(),0L) - a.at(n-1) > a.at(n-1)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

int main(){
    string str;

    while(cin >> str){
        string result;
        for(int i=0; i<str.size(); i++){
            if(str.at(i) == '@'){
                int n = str.at(i+1) - '0';
                for(int j=1; j<=n; j++){
                    result += str.at(i+2);
                }
                i += 2;
            }else{
                result += str.at(i);
            }
        }
        cout << result << endl;
    }

    return 0;
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = 1e9;
const LL LLINF = 1e18;

int F[101];
int P[101][11];

int bit_count(int bit, int N)
{
    int cnt = 0;
    for (int i = 0; i < N; i++)
        if (bit & (1 << i))
            cnt++;
    return cnt;
}

void solve()
{
    int N;
    cin >> N;

    REP0(i, N)
    {
        REP0(j, 10)
        {
            int f;
            cin >> f;
            F[i] += (f << j);
        }
    }

    REP0(i, N)
    {
        REP0(j, 11)
        {
            cin >> P[i][j];
        }
    }

    int ans = -INTINF;

    REP0(bit, (1 << 10))
    {
        if (bit_count(bit, 10) == 0)
            continue;
            
        int pro = 0;
        REP0(i, N)
        {
            pro += P[i][bit_count(bit & F[i], 10)];
        }
        ans = max(ans, pro);
    }
    cout << ans << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,u[50],t,i,j;
	float p;
	scanf("%d", &n);
	for(i=0; i<n; i++)
	scanf("%d", &u[i]);
	for(i=0; i<n-1; i++)
	{
		for(j=n-1; j>=i+1; j--)
		{
			if(u[j]<u[j-1])
			{
				t=u[j];
				u[j]=u[j-1];
				u[j-1]=t;
			}
		}
	}
	p=(u[0]+u[1])/2.0;
	for(i=2; i<n; i++)
	{
		p+=u[i];
		p/=2.0;
	}
	printf("%f\n", p);
	return 0;
}

Measured memory_bytes: 128
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n=INT()
    s=set()
    for i in range(n):
        s.add(INT())
    print(len(s))
if __name__ == '__main__':
    do()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll mod=1e9+7;
int dy[]={1,-1,0,0};
int dx[]={0,0,1,-1};

int main(){
  int N;
  cin>>N;
  vector<int> p(N);
  for(int i=0;i<N;i++){
    cin>>p[i];
    
  }
  int ans=0;
  for(int i=1;i<N-1;i++){
    //if((p[i]>p[i-1]&&p[i]<p[i+1])||(p[i]<p[i-1]&&p[i]>p[i+1])) ans++;
    if((p[i]-p[i-1])*(p[i+1]-p[i])>0) ans++;
  }
  cout<<ans<<endl;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n, a;
  cin >> n >> a;
  cout << (n % 500 <= a ? "Yes" : "No") << endl;
}


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

int main() {
  char c;
  cin >> c;
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'){
    cout << "vowel" << endl;
  }else{
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s1,s2;
    cin>>s1>>s2;
    int i,d,count=0;
    for(i=0; i<s1.size(); i++)
    {
        if(s1[i]!=s2[i])
            count++;
    }
    cout<<count;
    return 0;
}


Measured memory_bytes: 3760
h, w = [int(i) for i in input().split(" ")]
s = ["" for i in range(0, h)]

for i in range(0, h):
    s[i] = input()

xs = [[0 for j in range(0, w)] for i in range(0, h)]
ys = [[0 for j in range(0, w)] for i in range(0, h)]

for i in range(0, h):
    l = 0
    r = 0
    c = 0
    for j in range(0, w + 1):
        if j < w and s[i][j] == ".":
            r = j
            c += 1
        else:
            for k in range(l, r + 1):
                xs[i][k] = c
            l = j
            r = j
            c = 0

for j in range(0, w):
    l = 0
    r = 0
    c = 0
    for i in range(0, h + 1):
        if i < h and s[i][j] == ".":
            r = i
            c += 1
        else:
            for k in range(l, r + 1):
                ys[k][j] = c
            l = i
            r = i
            c = 0

mx = 0

for i in range(0, h):
    for j in range(0, w):
        if s[i][j] == "." and xs[i][j] + ys[i][j] - 1 > mx:
            mx = xs[i][j] + ys[i][j] - 1
print(mx)

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

public class Main {
	public void solve() {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int[] n = new int[N+1];
		for (int i=1; i<=N; i++) {
			n[i] = in.nextInt();
		}
		in.close();
		
		int[] b = new int[N+1];
		Arrays.fill(b, 0);
		int count = 0;
		for (int i=N; i>0; i--) {
			int total = 0;
			for (int j=i+i; j<=N; j+=i) {
				total += b[j];
			}
			total = total % 2;
			if (total != n[i]) {
				b[i] = 1;
				count++;
			}
		}
		
		System.out.println(count);
		for (int i=1; i<=N; i++) {
			if (b[i] != 0) {
				System.out.println(i);
			}
		}
		
	}
	
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
	}
 
}


Measured memory_bytes: 90032
using System;
using static System.Console;
using System.Collections.Generic;


namespace AtCoder_ABC_A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            String strLine = Console.ReadLine();        //入力を受けとりString型に代入
            String[] strSplited = strLine.Split(' ');       //Stringを数字ごとに分割しString配列に代入
            int n = int.Parse(strSplited[0]);
            int bounceArea = int.Parse(strSplited[1]);

            int ans = 0;
            int[] bounceLength = new int[n + 1];
            
            int[] inputLength = new int[n];                        
            inputLength = inputAndSetNumsToArray(n);       ////IF YOU WANT TO USE ARRAY, CHOOSE THIS

            //int n = int.Parse(Console.ReadLine());　
            //List<int> intNumsList = new List<int>();          //リストintNumsを初期化
            //int[] intNumsArray = new int[n];                        //配列intNumsを初期化

            //intNumsList = inputAndSetNumsToList(n);             //IF YOU WANT TO USE LIST, CHOOSE THIS
            //intNumsArray = inputAndSetNumsToArray(n);       ////IF YOU WANT TO USE ARRAY, CHOOSE THIS



            for (int i = 0; i < n + 1; i++)
            {
               if(i == 0)
                {
                    bounceLength[i] = 0;
                    if (bounceLength[i] <= bounceArea)
                    {
                        ans++;
                    }
                }
                else
                {
                    bounceLength[i] = bounceLength[i - 1] + inputLength[i - 1];
                    if (bounceLength[i] <= bounceArea)
                    {
                        ans++;
                    }
                }
            }

           
            Console.WriteLine(ans);
        }



        
        public static  List<int> inputAndSetNumsToList(int n)
        {
            List<int> getIntNums = new List<int>();     //リストgetIntNumsを初期化
            
            String strLine = Console.ReadLine();        //入力を受けとりString型に代入
            String[] strSplited = strLine.Split(' ');       //Stringを数字ごとに分割しString配列に代入

            for (int i = 0; i < n; i++)
            {
                getIntNums.Add(int.Parse(strSplited[i]));   //リストintNumsにString配列の中身を代入
            }
            return getIntNums;
        }

        

        public static int[] inputAndSetNumsToArray(int n)
        {
            int[] getIntNums = new int[n];      //配列getIntNumsを初期化

            String strLine = Console.ReadLine();        //入力を受けとりString型に代入
            String[] strSplited = strLine.Split(' ');       //Stringを数字ごとに分割しString配列に代入

            for (int i = 0; i < n; i++)
            {
                getIntNums[i] = int.Parse(strSplited[i]);   //リストintNumsにString配列の中身を代入
            }
            return getIntNums;
        }

    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define mod 1000000007
#define dd double
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
int dp[100001];
int knap(int arr[],int n,int size){
	if(n==1)
		return 0; 
	if(dp[n] != -1)
		return dp[n];
	int one_step;
	if(n>1){
		
		if(dp[n-1]!=-1)
			one_step = dp[n-1];
		else
			one_step = knap(arr,n-1,size);
	}
	else{
		one_step = 1e5;
	}		 
	int two_step;
	if(n>2){
		
		if(dp[n-2]!=-1)
			two_step = dp[n-2];
		else
			two_step = knap(arr,n-2,size);
	}
	else{
		two_step = 1e5;
	}
	//cout<<n<<" "<<one_step<<" "<<two_step<<endl;

	return dp[n] = min(one_step+abs(arr[size-n]-arr[size-n+1]),two_step+abs(arr[size-n]-arr[size-n+2]));
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
#ifndef ONLINE_JUDGE    
    freopen("input.txt", "r", stdin);     
    freopen("output.txt", "w", stdout);
#endif
 memset(dp,-1,sizeof(dp));
	int n;
	cin>>n;
	int arr[n];
	for(int i = 0;i<n;i++){
		cin>>arr[i];
	}	
	int size = n;
	cout<<knap(arr,n,size)<<endl;







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

return 0;
}

Measured memory_bytes: 9112
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
#include <stack>
#include <iomanip>
typedef long long ll;
using namespace std;

const int MOD = 1000000007;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main()
{
    int N,M;
    cin >> N >> M;
    vector<bool> safe(N+1,true);
    for(int i = 0; i < M; i++)
    {
        int a;
        cin >> a;
        safe[a] = false;
    }

    vector<int> dp(N+1,0);
    dp[0] = 1;
    if(safe[1]) dp[1] = 1;
    for(int i = 2; i < N+1; i++)
    {
        if(safe[i - 1]) dp[i] += dp[i - 1];
        if(safe[i - 2]) dp[i] += dp[i - 2];
        dp[i] %= MOD;
    }
    cout << dp[N] << endl;
}


Measured memory_bytes: 888
#include<stdio.h>
int main(){
   int x[5];
   int i;
   for(i=0;i<5;i++){
      scanf("%d",&x[i]);
   }
   for(i=0;i<5;i++){
      if(x[i]==0){
         printf("%d",i+1);
      }
   }
   return 0;
}

Measured memory_bytes: 3128
n, m, c = map(int, input().split())
lsb = list(map(int, input().split()))
l = 0

for i in range(n):
    lsa = list(map(int, input().split()))
    lsab = [0 for x in range(m)]
    k = 0
    for j in range(m):
        lsab[j] = lsa[j] * lsb[j]
    k = sum(lsab) + c
    if k > 0:
            l += 1

print(l)

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll power(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)

//your code here!

int main(void){
    ll A, B;
    scanf("%lld %lld", &A, &B);
    if(A<=9 && B<=9) printf("%lld\n", A*B);
    else puts("-1");
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
string s;
char t;
int n,m,flag=1,k,p;
vector<char> v1,v2;
int main(){
    cin>>s>>n;
    while(n--)
    {
        cin>>k;
        if(k==1)
            flag=3-flag;
        else
        {
            cin>>p>>t;
            if((p+flag)%2)
                v2.push_back(t);
            else
                v1.push_back(t);
        }
    }
    if(flag==2)
    {
        for(int i=v2.size()-1;i>=0;i--)
            cout<<v2[i];
        for(int i=s.size()-1;i>=0;i--)
            cout<<s[i];
        for(int i=0;i<v1.size();i++)
            cout<<v1[i];
    }
    else
    {
        for(int i=v1.size()-1;i>=0;i--)
            cout<<v1[i];
        cout<<s;
        for(int i=0;i<v2.size();i++)
            cout<<v2[i];
    }
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

bool isin(int i, int j, int k, int n) {
    return i >= 0 && j >= 0 && k >= 0 && i < n && j < n && k < n;
}

bool judge(int a[7][7][7], int n, int m){
    int dx[] = {1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1};
    int dy[] = {0, 1, 0, 1,-1, 0, 0, 1, 1, 1,-1, 1,-1};
    int dz[] = {0, 0, 1, 0, 0, 1,-1, 1,-1, 1, 1,-1,-1};
    REP(i,n) REP(j,n) REP(k,n) REP(l,13){
        int c = 0;
        for (int ii = i, jj = j, kk = k, p = 0; isin(ii,jj,kk,n) && p < m && a[ii][jj][kk] > 0; ii+=dx[l], jj+=dy[l], kk+=dz[l], p++){
            if (a[ii][jj][kk] == a[i][j][k]) c++;
        }
        if (c == m) return 1;
    }
    return 0;
}

int main() {
    int n, m, p;

    while (cin >> n >> m >> p && n) {
        vector<P> move(p);
        REP(i,p) {
            int a, b;
            cin >> a >> b;
            a--; b--;
            move[i] = make_pair(a, b);
        }
        int a[7][7][7] = {}, d[7][7] = {};
        REP(i,p) {
            int x = move[i].first, y = move[i].second;
            a[x][y][d[x][y]] = (i % 2) + 1;
            d[x][y]++;
            if (judge(a, n, m)) {
                if (i % 2 == 0)
                    cout << "Black " << i+1 << endl;
                else
                    cout << "White " << i+1 << endl;
                break;
            }
            if (i == p-1)
                cout << "Draw" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3052
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

int main()
{
	int n;
	cin >> n;
	int res[200001] = {};
	int maxRes = 0;
	for(int i = 0; i < n; i++){
		int p;
		cin >> p;
		p--;
		res[p] = 1;
		if(p > 0) res[p] += res[p - 1];
		maxRes = max(maxRes, res[p]);
	}
	cout << n - maxRes << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>


double theta_min(int min) {
  return ((double) min)/60*2*M_PI;
}
double theta_hour(int min, int hour) {
  double dmin = ((double)min)/60*2*M_PI/12;
  double dhour = ((double) hour)/12*2*M_PI;
  return dmin + dhour;
}

class point{
public:
  double x;
  double y;

  point(double r, double theta) {
    x = r * cos(theta);
    y = r * sin(theta);
  }

};

double dist(point p1, point p2) {
  double dx = pow((p1.x - p2.x ),2);
  double dy = pow((p1.y - p2.y ),2);
  return pow((dx+dy),0.5);
}


int main() {

  std::string in;

  int a,b,h,m;

  std::cin >> in;
  a = std::stoi(in);
  std::cin >> in;
  b = std::stoi(in);
  std::cin >> in;
  h = std::stoi(in);
  std::cin >> in;
  m = std::stoi(in);

  double t_min = theta_min(m);
  double t_hor = theta_hour(m,h);

  point p_min(b,t_min);
  point p_hor(a,t_hor);

  std::cout << std::fixed << std::setprecision(9) << dist(p_min,p_hor) << std::endl;



  return 0;

}


Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;

class Main{


	public static void main(String args[]){
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try{
			String str;
			while((str = br.readLine()) != null){
				int n = Integer.parseInt(str);
				calc(n);
			}
		}catch(Exception e){
		}
	}

	static void calc(int n){
		switch(n){
		case 0:{
			System.out.println(0);
		}
		case 1:{
			System.out.println(1);
			break;
		}
		case 2:{
			System.out.println(2);
			break;
		}
		case 3:{
			System.out.println(5);
			break;
		}
		default:{
			if(n%2 == 0){
				int m = n/2 - 1;
				int result = 1;
				int edge = 3;
				for(int i = 0; i < m; i++){
					result += edge;
					edge *= 3;
				}
				System.out.println(result * 2);
			}else{
				int m = (n - 1) / 2;
				int result = 1;
				int edge = 4;
				for(int i = 0; i < m; i++){
					result += edge;
					edge *= 3;
				}
				System.out.println(result);
			}
		}
		}
	}
}

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

using namespace std;

typedef long long int ll;

ll pwr(ll a){
	return  a * a * a * a * a;
}

int main(){
	ll x;
	cin >> x;
	for(ll i = -200; i < 200; i++){
		for(ll j = -200; j < 200; j++){
			if(pwr(i)-pwr(j)==x){
				cout << i << " " << j << "\n";
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3660