akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <cstdio>
#include <cmath>

#define rep(i, a, b) for (ll i = a; i < b; i++)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef unordered_map<string, ll> u_map;

// input
void input() {}
template <class Head, class... Tail>
void input(Head &&a, Tail &&... b)
{
    cin >> a;
    input(forward<Tail>(b)...);
}

template <class V>
void input(vector<V> &v)
{
    for_each(v.begin(), v.end(), [](auto &i) { input(i); });
}

// output
template <class V>
void output(vector<V> &v)
{
    for_each(v.begin(), v.end(), [](auto &x) { cout << x << " "; });
    cout << endl;
}

// math functions
ll mpow(ll a, ll n, ll p)
{
    ll x = 1;
    while (n > 0)
    {
        if (n & 1)
        {
            x = a * x % p;
        }
        a = a * a % p;
        n >>= 1;
    }

    return x;
}

ll mfact(ll n, ll p)
{
    ll res = 1;
    for (ll i = 2; i <= n; i++)
    {
        res = res * i % p;
    }
    return res;
}

ll mcomb(ll n, ll r, ll p)
{
    if (n == 0 && r == 0)
    {
        return 1;
    }
    if (n < r || n < 0 || r < 0)
    {
        return 0;
    }

    ll a = mfact(n, p);
    ll b = mfact(n - r, p);
    ll c = mfact(r, p);
    return (((a * mpow(b, p - 2, p)) % p) * mpow(c, p - 2, p)) % p;
}

ll gcd(ll a, ll b)
{
    if (a < b)
    {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    return b ? gcd(b, a % b) : a;
}

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

int main()
{
    int R;
    input(R);
    
    printf("%.10f\n", 2.0 * M_PI * R);
    
    return 0;
}


Measured memory_bytes: 3756
#include<bits/stdc++.h>
#define ll long long
#define lb long double
#define FOR(i,n) for(int i=0;i<n;i++)
#define DEBUG(x) cout << x
#define RUN ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back

using namespace std;
// Solve
	bool flag=0;
void Solve()
{
	ll n;
	cin >> n;
	ll a[n],b[n];
	FOR(i,n)
	{
		cin >> a[i];
		b[i]=a[i];
	}
	sort(b,b+n);
	ll cnt=0;
	FOR(i,n)
	{
		if(b[i]!=a[i]) cnt++;
	}
	if(cnt==2||cnt==0) flag=1;	
}
int main()
{
	RUN;
	Solve();
	if(flag==1) DEBUG("YES");
	else DEBUG("NO");
	return 0;
}

Measured memory_bytes: 256
import collections
import math
import operator as op
from functools import reduce
import numpy as np
import math
import bisect

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd (a, b)

def main():
    A, B = list(map(int, input().split()))

    ans = lcm(A, B)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 12476
n=int(input())
S=list(input())
q=int(input())

D=[[0]*26 for _ in range(n+1)]
for i,s in enumerate(S):
  for j in range(26):
    if j==ord(s)-97:
      D[i+1][j]=D[i][j]+1
    else:
      D[i+1][j]=D[i][j]

n_max=n+1
nn=n_max.bit_length()+1
BITS=[[0]*(2**nn) for _ in range(26)]
for i in range(26):
  BITS[i].insert(0,0)

def bitsum(BIT,i):
  s=0
  while i>0:
    s+=BIT[i]
    i-=i&(-i)
  return s

def bitadd(BIT,i,x):
  while i<=2**nn:
    BIT[i]+=x
    i+=i&(-i)
  return BIT

for _ in range(q):
  q1,q2,q3=map(str,input().split())
  if q1=="1":
    num=int(q2)-1
    prev=ord(S[num])-97
    new=ord(q3)-97
    S[num]=q3
    if prev!=new:
      bitadd(BITS[prev],num+1,-1)
      bitadd(BITS[new],num+1,1)
  else:
    l,r=int(q2),int(q3)
    ans=0
    for i in range(26):
      diff=D[r][i]-D[l-1][i]+bitsum(BITS[i],r)-bitsum(BITS[i],l-1)
      if diff>0:
        ans+=1
    print(ans)



Measured memory_bytes: 611512
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	nums := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&nums[i])
	}
	sort.Sort(sort.Reverse(sort.IntSlice(nums)))
	alice := 0
	bob := 0
	for i, num := range nums {
		if i%2 == 0 {
			alice += num
		} else {
			bob += num
		}
	}
	fmt.Println(alice - bob)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define Maxn 110

int k;
char str[Maxn];

int main()
{
	scanf("%d", &k);
	scanf("%s", str+1);
	int len=strlen(str+1);
	if (len>k)
	{
		for (int i=1; i<=k; i++) printf("%c", str[i]); puts("...");
	}
	else
	{
		printf("%s\n", str+1);
	}
}


Measured memory_bytes: 3760
import java.util.Scanner;

public class Main {
	static final int N = 1000000;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int answer;
		int[] table = new int[N + 1];
		table[0] = 0;
		table[1] = 0;
		for (int i = 2; i <= N; i++) {
			table[i] = 1;
		}
		for (int i = 2; i <= Math.sqrt(N) + 1; i++)
			if (table[i] == 1)
				for (int j = i * 2; j <= N; j += i)
					table[j] = 0;
		while (true) {
			int a = sc.nextInt();
			int d = sc.nextInt();
			int n = sc.nextInt();
			answer = 0;
			if (a == 0 && d == 0 && n == 0)
				break;
			for (int i = a; i < N; i += d) {
				if (n == 0) {
					answer = i - d;
					break;
				}
				if (table[i] == 1)
					n--;
			}
			System.out.println(answer);
		}
		sc.close();
	}
}

Measured memory_bytes: 25608
#include <cstdio>

int ball[200005];
int ball_num[200005] = {0};

int main()
{
    int num;
    scanf("%d", &num);

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

    long long sum = 0;
    for(int i = 0; i <= num; i++)
    {
        long long a = ball_num[i];
        if(a > 1)
        {
            long long b = a - 1;
            if(a % 2) b /= 2;
            else a /= 2;
            sum += a * b;
        }
    }

    for(int i = 0; i < num; i++)
    {
        long long a = ball_num[ball[i]] - 1;
        long long output = sum;
        if(a > 0) output -= a;
        printf("%lld\n", output);
    }

    return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define ll long long
using namespace std;
 
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    ll a, ans = 1;
    string b;
    cin>>a>>b;
 
    int n = b.size();
    ll x = stoi(b), y = (b[n-2]-'0')*10 + (b[n-1]-'0');
    ans = a*x + (a*y)/100;
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 3664
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    inf=10**10
    n,m,k=MI()
    aa=LI()
    bb=LI()

    ca=[0]
    for a in aa:ca.append(ca[-1]+a)
    cb=[0]
    for b in bb:cb.append(cb[-1]+b)

    ans=0
    j=m
    for i,a in enumerate(ca):
        while j and a+cb[j]>k:j-=1
        if a+cb[j]>k:break
        ans=max(ans,i+j)
    print(ans)

main()

Measured memory_bytes: 47720
#include <bits/stdc++.h>
using namespace std;
string S;
int main() {
	cin >> S;
	int ans = 0;
	for (int i = 0; i < S.length(); i++) {
		if (S[i] == 'R') ans++;
	}
	if (ans == 2 && S[1] == 'S') cout << 1;
	else cout << ans;
	return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=100010,M=1000010,P=1e9+7;
const int inf=0x3f3f3f3f;
const int INF=0xcfcfcfcf;
const double eps=1e-6,pi=asin(1)*2;
inline ll read();
inline void write(ll x);
inline void writeln(ll x);
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define plus(a,b) a=(a+(b))%P
#define minus(a,b) a=(a-(b)+P)%P
#define mul(a,b) a=(a*(b))%P
#define mem(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define mp(x,y) make_pair(x,y)

inline ll quickmi(ll x,ll n)
{
	ll res=1;
	for(;n;n>>=1)
	{
		if(n&1) mul(res,x);
		mul(x,x);
	}
	return res;
}
#define ni(x) quickmi(x,P-2)

ll fac[N],inv[N];
int num[N];
inline void init(int n=100000)
{
	fac[0]=1;
	for(int i=1;i<=n;i++) fac[i]=fac[i-1]*i%P;
	inv[n]=ni(fac[n]);
	for(int i=n;i;i--) inv[i-1]=inv[i]*i%P;
	num[0]=0;
	for(int i=1;i<=n;i++) num[i]=num[i>>1]^(i&1);
}
inline ll C(ll n,ll m)
{
	return n>=m?fac[n]*inv[m]%P*inv[n-m]%P:0;
}

int n,m;
int a[N];
inline bool cmp(int x,int y)
{
	return x>y;
}
ll dp[22][(1<<16)|10];

//#define FILE "shiratsuyu"
#ifdef FILE
char buf[1<<25],*p1=buf,*p2=buf;
#define getchar() p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<25,stdin),p1==p2)?EOF:*p1++
#endif
inline ll read()
{
	ll s=0;
	bool flag=false;
	char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar()) if(ch=='-') flag=true;
	for(;'0'<=ch&&ch<='9';ch=getchar()) s=(s<<3)+(s<<1)+(ch^'0');
	if(flag) return -s;
	return s;
}
inline void write(ll x)
{
	if(!x)
	{
		putchar('0'),putchar(' ');
		return ;
	}
	if(x<0) putchar('-'),x=-x;
	char ch[20];
	int tot=0;
	while(x) ch[++tot]=x%10,x/=10;
	for(int i=tot;i;i--) putchar(ch[i]^48);
	putchar(' ');
}
inline void writeln(ll x)
{
	write(x);
	putchar('\n');
}

int main()
{
#ifdef FILE
	freopen(FILE ".in","r",stdin);
	freopen(FILE ".out","w",stdout);
#endif
	init();
	n=read(),m=read();
	for(int i=1;i<=m;i++) a[i]=read();
	sort(a+1,a+m+1,cmp);
//	for(int i=1;i<=m;i++) cerr<<a[i]<<" ";
//	cerr<<"\n";
	dp[0][0]=1;
	for(int i=1;i<=m;i++)
	{
		for(int S=0;S<(1<<n);S++) dp[i][S]=dp[i-1][S];
		for(int S=0;S<(1<<n);S++)
		{
			for(int j=0;j<n;j++)
			{
				if((S|(1<<j))!=S) continue;
				int T=S-(1<<j);
				plus(dp[i][S],dp[i-1][T]*C((1<<n)-T-a[i],(1<<j)-1)%P*fac[1<<j]%P);
			}
		}
	}
	
//	for(int S=0;S<(1<<n);S++) cerr<<dp[m][S]<<" ";
//	cerr<<"\n";
	
	for(int S=0;S<(1<<n);S++) mul(dp[m][S],fac[(1<<n)-1-S]);
	ll ans=0;
	for(int S=0;S<(1<<n);S++) plus(ans,(num[S]?-1:1)*dp[m][S]);
	printf("%lld\n",(ans%P+P)*(1<<n)%P);
	return 0;
}


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

int main () {
    int N, M, tmp;
    long min = 0;
    priority_queue<int> que;

    cin >> N >> M;
    for (int i = 0; i < N; i++) {
        cin >> tmp;
        que.push(tmp);
    }
  
    for (int i = 0; i < M; i++) {
        que.push(que.top()/2);
        que.pop();
    }

    for (int i = 0; i < N; i++) {
        min += que.top();
        que.pop();
    }
  
    cout << min << endl;
    return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;

void solve() {
    int n; cin >> n;
    Vl a(n);
    rep(i, 0, n) cin >> a[i];
    double sum = 0;
    rep(i, 0, n) sum += a[i];
    sum /= n;
    double sa = 99999999; int m = 0;;
    rep(i, 0, n){
        if(abs(a[i]-sum) < sa){
            sa = abs(a[i]-sum);
            m = i;
        }
    }
    cout << m << endl;
}

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

    solve();
    return 0;
}
 


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
//typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

int A[300][300];

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N, M; cin >> N >> M;
  REP(i, N) REP(j, M) {
    cin >> A[i][j];
    A[i][j]--;
  }
  int ans = N;
  vector<bool> can_use(M, true);

  while (any_of(ALL(can_use), [](bool x) { return x; })) {
    vector<int> cnt(M, 0);
    REP(i, N) {
      REP(j, M) {
        if (can_use[A[i][j]]) {
          cnt[A[i][j]]++;
          break;
        }
      }
    }

    int c_max = *max_element(ALL(cnt));
    ans = min(ans, c_max);
    REP(i, M) if (cnt[i] == c_max) can_use[i] = false;
    //REP(i, M) cout << cnt[i] << (i == M - 1 ? '\n' : ' ');
    //cout << c_max << endl;
    //REP(i, M) cout << can_use[i] << (i == M - 1 ? '\n' : ' ');
  }
  cout << ans << endl;

  return 0;
}


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

#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)

// policy-based
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;	


using namespace std;


typedef long long ll; // int or long long
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;

/*
typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
*/
 
const ll MAX = 3e5+100;
const ll inf = 1e12;
const ll mod = 1e9+7;




int main(){
	fastio;
	ll tc,n,x,y,k;
	ll a = 0,b = 0;
	string s;
	cin  >> n >>s;
	x = 0;
	f(i,0,n) if(s[i] == 'R') x++;

	f(i,0,x) if(s[i] == 'W') a++;
	af(i,n-1,x) if(s[i] == 'R') b++;

	cout << min(a,b) << endl;
	
}

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

#define ll long long
#define ull unsigned long long 
#define endl '\n'
#define pii pair<int, int>
#define all(a) a.begin(),a.end()
template <typename T>
inline T gcd(T a, T b) { while (b != 0) swap(b, a %= b); return a; }

int main(){
    int n;
    cin >> n;
    deque<int> ans;
    for(int i=0; i<n; ++i){
        int x;
        cin >> x;

        if(!((i^n)&1)){
            ans.push_back(x);
        }
        else{
            ans.push_front(x);
        }
    }

    for(auto x:ans)
        cout << x << " ";
}

Measured memory_bytes: 4440
h,w = map(int, input().split())
a = [list(input()) for _ in range(h)]
dx = [1,0,-1,0]
dy = [0,1,0,-1]
for k in range(h):
    for j in range(w):
        x,y = k,j
        if a[x][y] == "#":
            for i in range(4):
                xi,yi = x+dx[i],y+dy[i]
                if 0 <= xi < h and 0 <= yi < w and a[xi][yi] == "#":
                    break
            else:
                print("No")
                exit()

print("Yes")

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

# C - Forbidden List
x, n = map(int, input().split())

if n == 0:
	print(x)
else:
	p = set(list(map(int, input().split())))
	i = 0

	while True:
		if not (x - i) in p: 
			print(x - i)
			break
		elif not (x + i) in p:
			print(x + i)
			break
		else:
			i += 1

Measured memory_bytes: 9100
from collections import defaultdict


def solve():
    N = int(input())
    D = list(map(int, input().split()))
    M = int(input())
    T = list(map(int, input().split()))
    cnt = defaultdict(int)
    for d in D:
        cnt[d] += 1
    for t in T:
        if cnt[t] <= 0:
            print('NO')
            return
        cnt[t] -= 1
    print('YES')


if __name__ == "__main__":
    solve()


Measured memory_bytes: 45072
def fa(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
N=int(input())
soi=fa(N)
ans=0
for n in range(len(soi)):
    if soi[n][1]<=2:
        ans+=1
    elif soi[n][1]<=5:
        ans+=2
    elif soi[n][1]<=9:
        ans+=3
    elif soi[n][1]<=14:
        ans+=4
    elif soi[n][1]<=20:
        ans+=5
    elif soi[n][1]<=27:
        ans+=6
    elif soi[n][1]<=35:
        ans+=7
    elif soi[n][1]<=44:
        ans+=8
    elif soi[n][1]<=54:
        ans+=9
if N==1:
    ans=0
print(ans)


Measured memory_bytes: 9540
class Problem
  # start ========
  def main
    n = gets.to_i
    a = gets.to_i
    solve(n,a)
  end

  def solve(n, a)
    if n % 500 <= a
      puts 'Yes'
    else
      puts 'No'
    end
  end
  # ======== end
end

if __FILE__ == $0
  Problem.new.main
end

Measured memory_bytes: 1788
import sys
input = sys.stdin.readline
from operator import itemgetter
from collections import defaultdict

def main():
	n = int(input().strip())
	st = defaultdict(int)
	for i in range(n):
		s = input().strip()
		d = []
		for c in s:
			d.append(ord(c))
		d.sort()
		st[tuple(d)] += 1
	ans = 0
	for v in st.values():
		if v == 1:
			continue
		ans += v*(v-1) // 2
	print(ans)

if __name__ == '__main__':
	main()


Measured memory_bytes: 80092
# https://atcoder.jp/contests/agc038/tasks/agc038_a

h, w, a, b = map(int, input().split())

matrix = [[0] * w for _ in range(h)]

for i in range(h):
    for j in range(w):
        if (i < b) ^ (j < a):
            matrix[i][j] = 1

for r in matrix:
    print(''.join(map(str, r)))


Measured memory_bytes: 76928
module Main where
import Control.Monad
import Control.Applicative
import Data.Maybe
import Data.List
import qualified Text.Printf
import qualified Data.ByteString.Char8 as BC
import qualified Data.ByteString as BC

------------------------------------------

main :: IO ()
main = do
  s' <- getLine
  trg <- getLine
  let find [] = []
      find xx@(x:xs) =
        case match xx of
          Nothing -> map (x':) (find xs)
          Just xx' -> xx' : map (x':) (find xs)
        where x' = if x == '?' then 'a' else x

      match str = go trg str
        where go [] ys = Just $ trg ++ fillA ys
              go _ [] = Nothing
              go (x:xs) (y:ys) = guard (y == '?' || x == y) >> go xs ys
              
              fillA = map (\x -> if x == '?' then 'a' else x)

      cands = find s'

  case sort cands of 
    []    -> putStrLn "UNRESTORABLE"
    (x:_) -> putStrLn x


------------------------------------------

{- Int input -}

parseInt :: BC.ByteString -> Int
parseInt = fst . fromJust . BC.readInt

parseInts :: BC.ByteString -> [Int]
parseInts = map parseInt <$> BC.words

readInt :: IO Int
readInt = parseInt <$> BC.getLine

readInts :: IO [Int]
readInts = parseInts <$> BC.getLine

{- Double Formatting -}

doubleFmt :: Double -> String
doubleFmt = Text.Printf.printf "%.12f"


Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
bool vis[1010];
int main()
{
string s;
cin>>s;
for (int i=0;i<s.size();i++) vis[s[i]]=1;
if (vis['S']!=vis['N']) return puts("No"),0;
if (vis['E']!=vis['W']) return puts("No"),0;
puts("Yes");
return 0;
}

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

int main()
{
    int N, H[250];
    cin >> N;

    for (int i = 0; i < N; i++)
        cin >> H[i];
    int k = 0;
    while (k < N) {
        cout << "node " << k + 1 <<": key = " << H[k] << ", ";
        int l = (k + 1) / 2 - 1;
        if (k!=0)
            cout << "parent key = " << H[l]<<", ";
        l = (k + 1) * 2-1;
        if (l < N)
            cout << "left key = " << H[l]<<", ";
        l = (k + 1) * 2 ;
        if (l < N)
            cout << "right key = " << H[l] << ", ";
        cout << endl;
        k++;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define print printf("==================\n")
#define ll long long
#define pi acos(-1.0)
#define eps 1e-16
#define max3(a,b,c) max(a,max(b,c))
const ll INF = 1 << 30;
typedef pair<double, double  > payar;
typedef struct
{
    ll  x, y;
} point;
priority_queue<payar, vector<payar>,  greater<payar> > pq; ///accending
vector< pair<double,payar  > > vpp;
vector < payar >  vp;
ll dp[105][100005];
ll cap;
ll w[1001];
ll val[1001];
ll a;
ll cal(ll ind, ll wt )
{
    if(ind==a+1)
        return 0 ;

    if(dp[ind][wt]!=-1)
        return dp[ind][wt];
    ll a =0,b=0;
    if(w[ind]+wt<=cap)
    {
        a =  val[ind]+cal(ind+1,wt+w[ind]);
    }
    if(1)
    {
        b =  cal(ind+1,wt);
    }
    return dp[ind][wt]=max(a,b);


}
int main()
{


    memset(dp,-1,sizeof dp);
    cin>>a>>cap;
    for(int i = 1 ; i<= a ; i++)
    {

        cin>>w[i]>>val[i];

    }
    cout<<cal(1,0);

    return  0 ;
}


Measured memory_bytes: 82432
A, B, C, X, Y = map(int, input().split())
ans = 0
if A + B >= 2 * C:
  ans += 2 * C * min(X, Y)
  if X > Y:
    if A > 2 * C:
      ans += 2 * C * (X - Y)
    else:
      ans += A * (X - Y)
  else:
    if B > 2 * C:
      ans += 2 * C * (Y - X)
    else:
      ans += B * (Y - X)
else:
  ans = A * X + B * Y
print(ans)

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

int main() {
	long long N, A, B;
	cin >> N >> A >> B;
	long long ANS = 0;
	ANS += A * (N / (A + B));
	if (N % (A + B) <= A) ANS += N % (A + B);
	else ANS += A;
	cout << ANS << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
ll dx[4] = { 0, 1, 0, -1 };
ll dy[4] = { 1, 0, -1, 0 };
const ll INF = 1 << 21;
const ll MOD = 1e9 + 7;

int graph[100][100];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    memset(graph, 0, sizeof(graph));
    rep(i, n)
    {
        int u, k;
        cin >> u >> k;
        u--;
        rep(j, k)
        {
            int v;
            cin >> v;
            v--;
            graph[u][v] = 1;
        }
    }
    rep(i, n)
    {
        rep(j, n)
        {
            cout << graph[i][j];
            if (j != n-1) {
                cout << " ";
            }
        }
        cout << endl;
    }
    return 0;
}


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

int main(){
  int n;
  cin>>n;
  int k=n;
  int sum=0;
  while(n){
    sum+=n%10;
    n/=10;
  }
 (k%sum==0)?cout<<"Yes":cout<<"No";
  return 0;
}

Measured memory_bytes: 256
from fractions import gcd


def lcm(a, b):
    return a * b // gcd(a, b)


def mod_inv(a, m):
    return pow(a, m-2, m)


MOD = 10 ** 9 + 7
N = int(input())
A = list(map(int, input().split()))

LCM = 1
for a in A:
    LCM = lcm(LCM, a)
LCM %= MOD

# ans = LCM * sum([mod_inv(a, MOD) for a in A]) % MOD
ans = 0

for a in A:
    ans += LCM * mod_inv(a, MOD) % MOD
    ans %= MOD

print(ans)


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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;  cin >> h >> w;
    string board[h];
    rep(i, h) cin >> board[i];
    int dh[8] = {0, 0, 1, 1, 1, -1, -1, -1};
    int dw[8] = {1, -1, 0, 1, -1, 0, 1, -1};
    rep(i, h) {
      rep(j, w) {
        if (board[i][j] == '.') {
          int cnt = 0;
          rep(k, 8) {
            int x = i + dh[k];
            int y = j + dw[k];
            if (x >= 0 && x < h && y >= 0 && y < w) {
              if (board[x][y] == '#') cnt++;
            }
          }
          board[i][j] = cnt + '0';
        }
      }
    }
    rep(i, h) cout << board[i] << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <utility>
#include <functional>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <numeric>
#include <complex>
#include <cassert>
#include <climits>

using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const int INF = (1<<30);
const i64 INFL = (1LL<<62);
const i64 MOD = 1000000007;
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> i64 mod_pow(i64 a, i64 n, T mod) { mod=(i64)mod; i64 res=1, p=a%mod; while(n){ if(n&1) res=res*p%mod; p=p*p%mod; n>>=1; } return res; }
void print() { std::cout << std::endl; }
template <typename T, typename... A> void print(const T& first, const A&... rest) { cout << sizeof...(rest) << endl; std::cout << first; if (sizeof...(rest)) std::cout << " "; print(rest...); }
template <typename... A> void print(const A&... rest) { print(rest...); }
template <typename A> void print(const std::vector<A>& v) { std::for_each(v.begin(), v.end(), [](A x) { std::cout << x << " "; }); std::cout << std::endl; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int m;
    cin >> m;
    // vector<int> d(m);
    // vector<int> c(m);
    vector<pair<i64, i64>> dc;
    i64 digitsum = 0;
    i64 ketasu = 0;
    rep(i, m){
        i64 b, c;
        cin >> b >> c;
        dc.push_back({b, c});
        digitsum += (b * c);
        ketasu += c;
    }
    cout << (digitsum + (digitsum % 9 == 0 ? -1 : 0)) / 9 + ketasu - 1 << endl;    

    return 0;
}


Measured memory_bytes: 6128
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>
#include<functional>
#include<unordered_set>
#include<unordered_map>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;
const long long ll_max = 9223372036854775807;
const long long ll_min = -9223372036854775807;
const int int_max = 2147483647;

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

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> ret;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			ret[i] ++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

template<typename T>
T modinv(T a, T m) {
	T 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;
}



// 繰り返し二乗法
ll pow2(ll n, ll p, ll mod) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n % mod, p / 2, mod);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret % mod;
	}
}


#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)



int main() {
	ll h, w, k;
	cin >> h >> w >> k;

	vector<string> s(h);
	vector<vll> ans(h, vll(w));
	ll num = 1;
	ll first_row = 0;
	rep(i, 0, h) {
		cin >> s[i];
		ll idx = -1;
		vll tmp(w);
		rep(j, 0, w) {
			tmp[j] = num;
			if (s[i][j] == '#') {
				tmp[j] = num;
				idx = j;
				num++;
			}
		}
		if (idx < 0) {
			if (first_row == i) {
				first_row++;
			}
			else {
				tmp = ans[i - 1];
			}
		}
		else {
			rep(j, idx + 1, w) {
				tmp[j] = num - 1;
			}
		}
		ans[i] = tmp;
	}
	rep(i, 0, first_row) {
		ans[i] = ans[first_row];
	}

	rep(i, 0, h) {
		cout << ans[i][0];
		rep(j, 1, w) {
			cout << " " << ans[i][j];
		}
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 4432
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> key;

int dp[256];
int par[10005];
int sz[10005];
int find(int x) {
  return par[x] == x ? x : (par[x] = find(par[x]));
}
void merge(int x, int y) {
  x = find(x);
  y = find(y);
  if(x == y) return;
  sz[y] += sz[x];
  par[x] = y;
}
void solve() {
  int r,c;
  cin >> r >> c;
  for(int i = 0; i < r*c; i++) {
    par[i] = i;
    sz[i] = 1;
  }
  for(int i = 0; i < r; i++) {
    string s;
    cin >> s;
    for(int j = 0; j < c; j++) {
      merge(i*c+j, i*c+(c-1-j));
      merge(i*c+j, (r-1-i)*c+j);
      dp[s[j]]++;
    }
  }
  set<int> seen;
  bool bad = false;
  for(int want = 4; !bad && want >= 1; want--) {
    for(int i = 0; !bad && i < r*c; i++) {
      if(seen.count(find(i)) || sz[find(i)] != want) continue;
      seen.insert(find(i));
      bool found = false;
      for(int a = 0; a < 256; a++) {
        if(dp[a] >= sz[find(i)]) {
          dp[a] -= sz[find(i)];
          found = true;
          break;
        }
      }
      bad = !found;
    }
  }
  if(bad) {
    cout << "No\n";
  }
  else {
    cout << "Yes\n";
  }
}

void casesolve() {
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << " ";
    solve();
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  // casesolve();
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int X = scan.nextInt();
        int L[] = new int[N+1];
        int D[] = new int[N+2];
        D[1] = 0;
        for (int i = 1; i <= N; i++) {
            L[i] = scan.nextInt();//3 4 5
        }
        int count=1;
        for (int j = 2; j <= N + 1; j++) {
                D[j] = D[j - 1] + L[j-1]; //座標
                if (X < D[j]){
                    break;
                }
                count++;
        }
        System.out.println(count);
        scan.close();
    }
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD 1000000007
using Graph = vector<vector<int>>;
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
int main (){
  int pri=0;
  long long N;
  long long Ncopy;
  vector<int>ask;
  cin>>N;
  Ncopy=N;
  if(N==1){
    cout<<0;
    return 0;
  }
  for(int i=2;i<=sqrt(Ncopy)+1;i++){
    if(N%i==0){
      pri=1;
      int x=0;
      while(N%i==0){
        N=N/i;
        x++;
      }
      ask.push_back(x);
    }
  }
  if(N!=1)ask.push_back(1);
  if(pri==0){
    cout<<1;
    return 0;
  }
  int ans=0;
  rep(i,ask.size()){
    int j=1;
    while((ask[i]-j)>=0){
      ans++;
      ask[i]=ask[i]-j;
      j++;
    }
  }
  cout<<ans;
  
}


Measured memory_bytes: 3720
#include<cstdio>
#include<iostream>
using namespace std;
int n,x,y,z,nw;
const int mod=1e9+7;
int S,f[45][1<<17],ans=1;
int main()
{
    scanf("%d",&n);
    scanf("%d%d%d",&x,&y,&z);
    for (int i=1;i<=n;i++) ans=1ll*ans*10%mod;
    nw=(1<<x-1)|(1<<x+y-1)|(1<<x+y+z-1);
    S=(1<<x+y+z)-1;//---
    f[0][0]=1;//---
    for (int i=1;i<=n;i++)
        for (int j=0;j<=S;j++)
        {
            for (int k=1;k<=10;k++)
            {
                int T=(j<<k)|(1<<k-1);
                T&=S;
                if ((T&nw)!=nw) f[i][T]=(f[i][T]+f[i-1][j])%mod;
            }
        }
    for (int i=0;i<=S;i++) ans=(ans-f[n][i]+mod)%mod;
    printf("%d",ans);
} 

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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

typedef pair<int, int> p_ii;

int main() {
  int N; cin >> N;
  p_ii A[N];
  rep(i,N) { int tmp; cin >> tmp; A[i] = make_pair(i, tmp); }
  sort(A, A+N, [](const p_ii& x, const p_ii& y){return x.second < y.second;});
  // rep(i,N) cout << A[i].first << ":" << A[i].second << endl;
  int result = 0;
  rep(i,(N+1)/2) if (A[i*2].first%2==1) result++;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 1024
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef long long ll;

int read() {
	int X=0,w=1; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
	return X*w;
}

const int N=100000+10;

int n; char s[N];

bool check(int p,char* t) {
	int l=strlen(t);
	if (p+l-1>n) return 0;
	for (int i=0;i<l;++i) if (s[p+i]!=t[i]) return 0;
	return 1;
}

int main() {
	scanf("%s",s+1); n=strlen(s+1);
	for (int i=1;i<=n;++i) {
		if (check(i,"dreameraser")) { i+=10; continue; }
		if (check(i,"dreamerase")) { i+=9; continue; }
		if (check(i,"dreamer")) { i+=6; continue; }
		if (check(i,"dream")) { i+=4; continue; }
		if (check(i,"eraser")) { i+=5; continue; }
		if (check(i,"erase")) { i+=4; continue; }
		puts("NO"); return 0;
	}
	puts("YES");
	return 0;
}

Measured memory_bytes: 3860
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n-1); i >= 0; i--)
#define all(v) (v).begin(),(v).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
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; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a/gcd(a,b)*b; }
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    int cnt = 0;
    cin >> n;
    rep(i,n) {
        int a, b;
        cin >> a >> b;
        if(a==b) ++cnt;
        else cnt = 0;
        if(cnt==3) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3608
package main

import "fmt"

var s string
var w int

func main() {
	fmt.Scan(&s, &w)
	ans := []string{}
	for i := 0; i < len([]rune(s)); i += w {
		ans = append(ans, string([]rune(s)[i]))
	}
	for _, a := range ans {
		fmt.Print(a)
	}
	fmt.Println()
}


Measured memory_bytes: 5504
#n = int(input()) #入力
#a, b = (int(x) for x in input().split())

#a = [int(x) for x in input().split()]
#a = list(map(int, input().split()))
#a = [list(map(int,input().split(" "))) for i in range(N)]   #2次元


#a.sort() # C++ の sort(a.begin(), a.end());
#a.append(3) # C++ の a.push_back(3);


#exit(0) # return 0 的な。終了できる。

import math
import copy
#math.gcd(a, b) で、gcd 計算できる。
#math.pi は円周率。

INF = 10**18 #べき乗 C++ の pow(10, 18) or 1e18;
pi = math.pi

MOD = 1000000007
#MOD = 1000000009
#MOD = 998244353




#繰り返し2乗法
#N^aの、Mで割った余りを求める。
def my_pow(N, a, M):
    if(a == 0):
        return 1
    else:
        if(a % 2 == 0):
            tempo = my_pow(N, a/2, M)
            return (tempo * tempo) % M
        else:
            tempo = my_pow(N, a - 1, M)
            return (tempo * N) % M




#N_C_a を M で割った余り
def my_combination(N, a, M):
    res = 1

    for i in range(0, a):
        res *= N - i
        res %= M

    for i in range(0, a):
        res *= my_pow(i + 1, M - 2, M)
        res %= M

    return res




#N_C_i を M で割った余りを、v[i] に代入する。
def my_combination_table(N, M, v):
    if(len(v) < N + 1):
        l = N + 1 - len(v)
        tempo = [1] * l
        v.extend(tempo)

    for i in range(1, N + 1):
        v[i] = v[i - 1] * (N - (i - 1))
        v[i] %= M

        v[i] *= my_pow(i, M - 2, M)
        v[i] %= M

    return




#math.factorial で階乗は計算できる。
#math.gcd で gcd は計算できる。

a1, a2, a3 = input().split()
X = int(a1)
K = int(a2)
D  = int (a3)


if (X - K * D >= 0):
   print(X - K * D)
   exit(0)
elif (X + K * D <= 0):
   print(abs(X + K * D))
   exit(0)
else:
    i = (X + K * D) // (2 * D)
    res = abs(X - K * D)
    
    if (0 <= i and i <= K):
        res = min(res, abs(X + K * D - 2 * i * D))   

    if (0 <= i + 1 and i + 1 <= K):
        res = min(res, abs(X + K * D - 2 * (i + 1) * D))

    if (0 <= i - 1 and i - 1 <= K):
        res = min(res, abs(X + K * D - 2 * (i - 1) * D))

    print(res)
    exit(0)
   
   
    






print(res)







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

std::vector<std::pair<int, int>> st;

bool solve() {
    int n;
    std::cin >> n;
    if (n == 0) return false;

    std::vector<int> cs(n);
    for (auto& c : cs) std::cin >> c;

    int ans = n;
    for (int i = 0; i < n; ++i) {
        int pc = cs[i];

        for (int nc = 1; nc <= 3; ++nc) {
            if (i != 0 && nc == pc) continue;
            cs[i] = nc;

            st.emplace_back(0, 0);
            for (auto c : cs) {
                if (st.back().first != c &&
                    st.back().second >= 4) {
                    st.pop_back();
                }

                if (st.back().first == c) {
                    ++st.back().second;
                } else {
                    st.emplace_back(c, 1);
                }
            }

            if (st.back().second >= 4) st.pop_back();

            int ret = 0;
            while (!st.empty()) {
                ret += st.back().second;
                st.pop_back();
            }

            ans = std::min(ans, ret);
        }
        cs[i] = pc;
    }

    std::cout << ans << "\n";
    return true;
}

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

    while (solve()) {}

    return 0;
}



Measured memory_bytes: 3284
s = input()
n = int(input())
for _ in range(n):
    ins, *args = input().split()
    if ins == 'print':
        start, end = int(args[0]), int(args[1])+1
        print(s[start:end])
    elif ins == 'reverse':
        start, end = int(args[0]), int(args[1])+1
        s = s[:start] + s[start:end][::-1] + s[end:]
    else:
        start, end, new = int(args[0]), int(args[1])+1, args[2]
        s = s[:start] + args[2] + s[end:]


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

long sum_n(long n){
  long x = 0; long k = n; long sum = 0;
  while(k){
    x = k % 10;
    k = (k - x) / 10;
    sum += x;
  }
  return sum;
}

int main() {
  long K; cin >> K;
  long plusnum = 1; long ans = 0; long checkans = 0;
  for(long i = 0; i < K; i++){
    checkans = ans + plusnum;
    if (checkans > sum_n(checkans) * plusnum){
      plusnum *= 10;
        }
    ans += plusnum;
    cout << ans << endl;
  }
  return 0;
 
}

Measured memory_bytes: 256
n, m = map(int, input().split())
wa = [0] * n
ac = [0] * n
ps = []
score = 0
pena = 0
for _ in range(m):
    ps = input().split()
    if ps[1] == 'WA':
        wa[int(ps[0])-1] += 1
    else:
        if ac[int(ps[0])-1] == 0:
            score += 1
            pena += wa[int(ps[0])-1]
            ac[int(ps[0])-1] += 1
print(score, pena)

Measured memory_bytes: 4596
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n;
	int a[35] = {0};
	for (int i = 1; i <= 28; i++) {
		cin >> n;
		a[n] = 1;
	}
	for (int i = 1; i <= 30; i++) {
		if (!a[i]) cout << i << endl;
	}
}



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

int main() {
	string s;
	int k;
	vector<string>v;
	cin >> s >> k;
	int n = s.size();
	int m = min(n, k);
	for (int i = 1;i <= m;i++) {
		for (int j = 0;j < n - i + 1;j++) {
			v.push_back(s.substr(j, i));
		}
	}
	sort(v.begin(), v.end());
	unique(v.begin(), v.end());
	cout << v[k - 1] << endl;
}

Measured memory_bytes: 1660
N, W = map(int, input().split())
WV = [list(map(int, input().split())) for _ in range(N)]
dp = [[0] * (W+1) for i in range(N+1)]

for i in range(1,N+1):
    w, v = WV[i-1]
    for j in range(1, W+1):
        if j-w < 0:
            dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = max(dp[i-1][j-w]+v, dp[i-1][j])

ret = 0
for i in dp:
    ret = max(ret, i[-1])
print(ret)

Measured memory_bytes: 119916
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<list>
#include<queue>
#include<string.h>
#include<functional>
#include<stack>
#include<deque>
#include<string>
#include<limits.h>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#define int long long
using namespace std;

int a[50];
signed main(){
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int ans = 0;
	while (1) {
		int k = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] > a[k]) {
				k = i;
			}
		}
		if (a[k] < n)break;
		int S = (a[k] - (n - 1)) / n;
		if ((a[k] - (n - 1)) % n)S++;
		ans += S;
		for (int i = 0; i < n; i++) {
			if (i == k) {
				a[i] -= S*n;
			}
			else {
				a[i] += S;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const double PI  = acos(-1.0);

#define print(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 
int main()
{
    string S;
    cin >> S;
    
    if (S == "ARC"){
        cout << "ABC";
    } else {
        cout << "ARC";
    }
    return 0;
}



Measured memory_bytes: 3592
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include<queue>

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; }

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
int gcd(int a, int b){return b ? gcd(b, a%b) : a;}

int n, m, q;
vector<int> a, b, c, d;
int ans = 0;

void dfs(vector<int> A){
    if(A.size() == n+1){
        //終了条件
        int now = 0;
        for(int i = 0; i < q; i++){
            if(A[b[i]]-A[a[i]] == c[i]) now += d[i];
        }
        ans = max(ans, now);
        return;
    }

    A.push_back(A.back());
    while(A.back() <= m){
        dfs(A);
        A.back()++;
    }
}

int main(){
    cin >> n >> m >> q;
    a = b = c = d = vector<int>(q);
    for(int i = 0; i < q; i++){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    dfs(vector<int>(1,1));
    cout << ans << endl;
    return 0;
}
 

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

int main() {
  int R,C,K;
  cin >> R >> C >> K;

  vector<vector<int>> m(R, vector<int>(C));
  vector<vector<vector<long long>>> s(R+1, vector<vector<long long>>(C+1 ,vector<long long>(4)));

  int r,c,v;
  for(int i=0;i<K;i++){
    cin >> r >> c >> v;
    m[r-1][c-1] = v;
  }

  for(int i=0;i<R;i++){
    for(int j=0;j<C;j++){
      for(int k=2;k>=0;k--){
	s[i][j][k+1]=max(s[i][j][k+1],s[i][j][k]+m[i][j]);
      }
      for(int k=0;k<4;k++){
	s[i+1][j][0]=max(s[i+1][j][0], s[i][j][k]);
	s[i][j+1][k]=max(s[i][j+1][k], s[i][j][k]);
      }
    }
  }

  long long ans=0;
  for(int k=0;k<4;k++){
    ans=max(ans,s[R-1][C-1][k]);
    // cout << ans << endl;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 671720
#include <bits/stdc++.h>
#define ll long long
#define INF INT_MAX 
#define mod 1000000007
using namespace std;
int main(){
    ll Q,H,S,D,N;
    cin >> Q >> H >> S >> D >> N;
    H = min(2*Q,H);
    S = min(2*H,S);
    D = min(2*S,D);
    ll ans=0;
    if(N>=2){
        ans = D*(N/2);
        N = N%2;
        ans = ans + S*N;
    }else{
        ans = N*S;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>  
#include<algorithm>  
using namespace std;  
   
int main()  
{  
    int N;  
    long long t;  
    scanf("%d",&N);  
    scanf("%lld",&t);  
    long long gb = t;  
    for(int i = 1;i < N;i ++)  
    {  
        scanf("%lld",&t);  
        long long a = max(gb,t);  
        long long b = min(gb,t);  
        while(b)  
        {  
            long long c = a%b;  
            a = b;  
            b = c;  
        }  
        gb = gb/a*t; 
    }  
    printf("%lld\n",gb);  
}  

Measured memory_bytes: 128
using System;
using System.Linq;

namespace ABC085C
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var amount = input[0];
            int sum = input[1];

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

                    if (10000 * i + 5000 * j + 1000 * k == sum)
                    {
                        Console.WriteLine($"{i} {j} {k}");
                        return;
                    }
                }
            }

            Console.WriteLine("-1 -1 -1");
        }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1e9+7LL;

int dp[110][100010];

int main() {
    int X; cin >> X;
    if(X>=30) cout << "Yes" << endl;
    else  cout << "No" << endl;
}

Measured memory_bytes: 3632
n = input()
n = int(n)
ary = (int(x) for x in input().split())
flg = True
for num in ary:
    if num % 2 == 0:
        #偶数の時
        if num % 3 == 0:
            #で割り切れる
            pass
        elif num % 5 == 0:
            #5で割り切れる
            pass
        else:
            flg = False
    else:
        pass
        #奇数の時
if flg:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main()
{
	int a,b,c,d,p;
	cin>>a>>b>>c>>d>>p;
	int A=a*p;
	int B=b;
	if(p>c)B+=(p-c)*d;
	cout<<min(A,B)<<endl;
	return 0;
}

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

int main(){
	int N;
	cin >> N;
	vector<string> s(N);
	
	for(int i=0;i<N;i++){
		cin >> s.at(i);
	}
	
	int M;
	cin >> M;
	vector<string> t(M);
	
	for(int i=0;i<M;i++){
		cin >> t.at(i);
	}  //���͂����܂�
	
	int ans=0;
	
	for(int i=0;i<N;i++){
		int a=0, b=0;
		for(int j=0;j<N;j++){
			if(s.at(j)==s.at(i)){
				a++;
			}
		}
		for(int j=0;j<M;j++){
			if(t.at(j)==s.at(i)){
				b++;
			}
		}
		ans=max(a-b,ans);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
using namespace std;
 
int main(void){
  int N, count = 0, max = 0;
  cin >> N;
  int H[N];
  
  for (int i = 0; i < N; i++){
    cin >> H[i];
  }
  
  for (int i = 1; i< N; i++){
    if(H[i] <= H[i - 1]){
      count++;
    } else {
      if(count > max){
        max = count;
      }
      count = 0;
    }
  }
  if(count > max){
     max = count;
  }
  
  cout << max << endl;
 
  return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;
import java.lang.Character;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        if(Character.isUpperCase(a.charAt(0))){
            System.out.print("A");
        }else{
            System.out.print("a");
        }
    }
}


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

using namespace std;

int const maxn = 101;
int const maxk = 101010;
int const mod = 1e9 + 7;

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr);
    
    int n, k;
    cin >> n >> k;

    vector<int> a(n);
    for (auto& i : a) cin >> i;

    vector<int> now(k+1), old(k+1);
    now[0] = 1;

    for (auto ai : a) {
        swap(now, old);

        for (int j = 1; j <= k; j++) {
            old[j] = (old[j-1] + old[j]);

            if (old[j] >= mod) old[j] -= mod;
        }

        for (int i = 0; i <= k; i++) {
            int r = i;
            int l = i - min(ai, i);

            if (l == 0) now[i] = old[r];
            else {
                now[i] = old[r] - old[l-1];
                if (now[i] < 0) now[i] += mod;
            }
        }
    }

    cout << now[k] << "\n";
}

Measured memory_bytes: 1024