akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl
#define debug2(s, t, u) cout << s << " " << t << " " << u << endl
#define printvec(v)       \
    for (auto &&i : v)    \
        cout << i << " "; \
    cout << endl

using namespace std;
using i64 = long long;
using Graph = vector<vector<int>>;

int N, M, Q;
vector<int> a(50), b(50), c(50), d(50);

int sum(vector<int> &aa)
{
    // printvec(aa);
    int res = 0;
    for (size_t i = 0; i < Q; i++)
    {
        if (aa[b[i] - 1] - aa[a[i] - 1] == c[i])
        {
            res += d[i];
        }
    }
    // debug(res);
    return res;
}

int rec(int n, int an, vector<int> aa)
{
    if (n == 0)
    {
        return sum(aa);
    }

    aa.push_back(an);
    int mx = 0;
    for (size_t i = an; i <= M; i++)
    {
        mx = max(mx, rec(n - 1, i, aa));
    }
    return mx;
}

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

    for (size_t i = 0; i < Q; i++)
    {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }

    int ans = 0;
    vector<int> aa;
    for (size_t i = 1; i <= M; i++)
    {
        ans = max(ans, rec(N, i, aa));
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3636
N=int(input())
A=list(map(int,input().split()))
B=[0]*N
for i in range(N):
    if A[i]%2==1:
        B[i]=0
    else :
        if A[i]%5==0 or A[i]%3==0 :
            B[i]=0
        else :
            B[i]=1
print("APPROVED" if sum(B)==0 else "DENIED")

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

int main(){
  int N;
  cin >>N;
  vector<int> d(N,0);
  for (int i=0; i<N; i++){
    cin >>d.at(i);
  }
  
  sort(d.begin(),d.end());
  
  int ans = 1;
  for (int i=1; i<N; i++){
    if(d.at(i-1)<d.at(i)) ans++;
  }
  cout <<ans <<endl;
  
}

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

using namespace std;

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

#define TT template<typename T>
TT T    sq(T x){ return x*x; }
TT int  ubnd(vector<T>& v,T x){ return upper_bound(v.begin(), v.end(), x) - v.begin(); }
TT int  lbnd(vector<T>& v,T x){ return lower_bound(v.begin(), v.end(), x) - v.begin(); }
TT void sort(T& v){ sort(v.begin(), v.end()); }
TT void revs(T& v){ reverse(v.begin(), v.end()); }
TT void uniq(T& v){ sort(v); v.erase(unique(v.begin(), v.end()), v.end()); }
TT void show(T& v,char d=' ',char e='\n'){for(int i=0;i<v.size();++i)cout<<v[i]<<((i==v.size()-1)?e:d);}
TT void inpt(vector<T>& v,int n){ v.reserve(n);for(int i=0;i<n;++i){T x; cin>>x; v.push_back(x);} }
TT T    In(T& x){ cin >> x; return x; }

static inline void fast_io(){ ios::sync_with_stdio(0); cin.tie(0); }
static inline int in(){ int x; scanf("%d", &x); return x; }
static inline string instr(){ string x; cin >> x; return x; }
static const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
static const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};

struct Rect {
  int h, w, d;
  Rect(int h, int w) : h(h), w(w), d(sq(h) + sq(w)) {}
  bool operator<(const Rect& x) const {
    return d == x.d ? h < x.h : d < x.d;
  }
};

int main()
{
  vector<Rect> v;
  int h, w;
  for (int x = 1; x <= 150; x++){
    for (int y = 1; y < x; y++){
      v.push_back(Rect(y, x));
    }
  }
  sort(v);

  while (h = in(), w = in(), h || w){
    Rect r = Rect(h, w);
    int index = ubnd(v, r);
    printf("%d %d\n", v[index].h, v[index].w);
  }
  return (0);
}

Measured memory_bytes: 1320
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

int main()
{ios_base::sync_with_stdio(false);

ll a,b;
cin>>a>>b;
if(a%b==0)
{
	ol("-1");
	return 0;
}
ol(a*b-a);
return 0;
}



Measured memory_bytes: 764
#include<bits/stdc++.h>
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i,n) for(ll i=0;i<(n);i++)
#define REPR(i,n) for(ll i=n;i>=0;i--)
#define FOR(i,m,n) for(ll i=m;i<n;i++)
#define MOD 1000000007
#define INF 1e9
#define F first
#define S second
#define All(x) (x).begin(),(x).end()
typedef long long ll;
const double PI = acos(-1);
using namespace std;





int main(void){
    int A,B,C,D,X,Y;
    cin>>A>>B>>C;
    if(A+B+C>=22){
        cout<<"bust"<<endl;
    }else{
        cout<<"win"<<endl;
    }
}





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

class Program
{
    static Scan sc = new Scan();
    static void Main()
    {
        int n = sc.Int;
        var a = sc.IntArr;
        Array.Sort(a);
        Console.WriteLine(a[n - 1] - a[0]);
    }
}
class Scan
{
    public int Int { get { return int.Parse(Str); } }
    public long Long { get { return long.Parse(Str); } }
    public double Double { get { return double.Parse(Str); } }
    public string Str { get { return Console.ReadLine().Trim(); } }
    public int[] IntArr { get { return StrArr.Select(int.Parse).ToArray(); } }
    public long[] LongArr { get { return StrArr.Select(long.Parse).ToArray(); } }
    public double[] DoubleArr { get { return StrArr.Select(double.Parse).ToArray(); } }
    public string[] StrArr { get { return Str.Split(new []{' '}, System.StringSplitOptions.RemoveEmptyEntries); } }
}


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

int main(){
	string s, p;
	cin >> s;
	cin >> p;
	int n = s.length();
	int l = p.length();
	bool f = true;
	for(int i = 0; i < n; ++i){
		f = true;
		for(int j = 0; j < l; ++j){
			if(s[(i + j) % n] != p[j]){
				f = false;
				break;
			}
		}
		if(f){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 1184
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0034
{
    public class Program

    {
        public static void Main(string[] args)
        {
            while (true)
            {
                string line = Console.ReadLine();
                if (string.IsNullOrEmpty(line)) return;

                int[] items = Array.ConvertAll(line.Trim().Split(','), e => int.Parse(e));

                int[] lengths = items.Take(10).ToArray();
                int v1 = items[10];
                int v2 = items[11];

                double intersectionL = lengths.Sum() * v1 / (double)(v1 + v2);

                double lengthSum = 0;
                for (int i = 0 ; i < lengths.Length ; i++)
                {
                    lengthSum += lengths[i];
                    if (lengthSum >= intersectionL)
                    {
                        Console.WriteLine(i + 1);
                        break;
                    }
                }
            }
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}



Measured memory_bytes: 16232
x1,y1,x2,y2 = list(map(int, input().split()))

cos90 = 0
sin90 = 1

x3 = (x1-x2)*cos90 + (y1-y2)*sin90 + x2
y3 = -(x1-x2)*sin90 + (y1-y2)*cos90 + y2
x4 = (x2-x1)*cos90 - (y2-y1)*sin90 + x1
y4 = (x2-x1)*sin90 + (y2-y1)*cos90 + y1

print("{} {} {} {}".format(x3, y3, x4, y4))

Measured memory_bytes: 3060
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let N: usize = sc.get();
    let mut ans = 0;
    for i in 1..=N {
        if i % 3 == 0 || i % 5 == 0 {
            continue;
        }
        ans += i;
    }
    println!("{}", ans);
}


Measured memory_bytes: 2144
# easy for C!!!

n = int(input())
l = [int(x) for x in input().split()]
i =0
while len(l) >= 2:
    l.sort()
    a = l.pop(i)
    b = l.pop(i)
    c = (a + b) / 2
    l.append (c)

print(*l)


Measured memory_bytes: 2940
N, M = map(int,input().split())
H = list(map(int,input().split()))
root = [[]]*M
for i in range(M):
    root[i] = list(map(int, input().split()))

judge = [1]*N
for i in range(M):
    if H[root[i][0]-1] > H[root[i][1]-1]:
        judge[root[i][1]-1] = 0
    elif H[root[i][0]-1] < H[root[i][1]-1]:
        judge[root[i][0]-1] = 0
    else:
        judge[root[i][0] - 1] = 0
        judge[root[i][1] - 1] = 0

print(sum(judge))

Measured memory_bytes: 32008
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<int,string> tp;
//typedef vector<tp> vt;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e9;
const ll INF=2e18;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n;
	cin>>n;
	map<string,int>ma;
	rep(i,n){
		string s;
		cin>>s;
		ma[s]=1;
	}
	cin>>n;
	bool h=false;
	rep(i,n){
		string s;
		cin>>s;
		if(ma[s]==0)cout<<"Unknown "<<s<<endl;
		else{
			if(h)cout<<"Closed by "<<s<<endl;
			else cout<<"Opened by "<<s<<endl;
			h^=1;
		}
	}
}

Measured memory_bytes: 3232
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define eb emplace_back
#define f first
#define s second
#define sz(x) (ll)x.size()
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> osSet;

using pll = pair<ll, ll>;

const ll maxN = 1e5;
const ll INF = 1e17;
const ll MOD = 1e9 + 7;

ll xs[] = {-1, 1, 0, 0, -1, 1, 1, -1};
ll ys[] = {0, 0, -1, 1, -1, 1, -1, 1};

ll segtree[maxN << 2];
ll lazy[maxN << 2];
ll A[maxN];

inline ll left(ll x){
	return x << 1;
}

inline ll right(ll x){
	return (x<<1) + 1;
}

ll func(ll x){
	return (x*(x+1))/2;
}

ll _pow(ll b, ll p){
	if(p == 0) return 1;
	if(p == 1) return b;
	ll exB = b*b;
	if(p&1) return b*_pow(exB, p/2);
	return _pow(exB, p/2);
}

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin >> n;
	vector<ll> pref(n, 0);
	for(ll i=0; i<n; i++){
		cin >> A[i];
		pref[i] = (i == 0 ? A[i] : A[i]^pref[i-1]);
	}
	ll ans[n];
	ll cur = 0;
	for(ll i=n-1; i>=0; i--){
		if(i != 0)
			ans[i] = pref[i-1]^cur;
		else
			ans[i] = cur;
		cur ^= A[i];
	}
	for(ll i=0; i<n; i++)
		cout << ans[i] << " ";	return 0;
}

Measured memory_bytes: 7784
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdio>
#include<queue>
#include<string>
using namespace std;
using ll = long long;

ll MOD = 1e9 + 7;
const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    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;
    }
}

// 二項係数計算
long long COM(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;
}


int main(){
    COMinit();
    ll n,k;
    cin >> n >> k;
    vector<ll> a(n);
    for(ll i=0;i<n;i++) cin >> a[i];
    sort(a.begin(),a.end());
    ll k_kai=1;
    for(ll i=1;i<=k;i++){
            k_kai*=i;
            k_kai = k_kai%MOD;
    }
    ll ans=0;
    vector<ll> temp(n);

    for(ll i=0;i<n-k+1;i++){
        for(ll j=i+k-1;j<n;j++){
            temp[j-i-1]+=a[j]-a[i];
        }
    }
    for(ll i=0;i<temp.size();i++){
        if(temp[i]>0){
            ans += ((temp[i]%MOD)*COM(i,k-2))%MOD;
        }
    }
    cout << ans%MOD << endl;
}

Measured memory_bytes: 13824
import Control.Monad
import Data.List

getInt = read <$> getLine :: IO Int
getInts = map read . words <$> getLine :: IO [Int]


calc l = (*) 2 $ flip div 2 $ (+) 1 $ sum $ map ((subtract 1) . length) $ group $ sort l

main = do
    n <- getInt
    as <- getInts
    print $ length as - calc as



Measured memory_bytes: 48508
import java.util.Scanner;

//
class Main{
    final static int MOD = (int)(Math.pow(10, 9) + 7);

    static long[] cumulativeSum(int[] a) {
        long[] b = new long[a.length + 1];
        b[0] = 0L;
        for(int i = 0; i < a.length; i++)
            b[i + 1] = (b[i] + a[i]) % MOD;

        return b;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N];

        for(int i = 0; i < N; i++)
            a[i] = sc.nextInt();

        long[] b = cumulativeSum(a);

        long sum = 0L;
        for(int i = 0; i < N - 1; i++) {
            sum += (a[i] * (b[N] - b[i + 1] + MOD)) % MOD;
            sum %= MOD;
        }

        System.out.println(sum % MOD);
    }

}


Measured memory_bytes: 59916
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  set<string> s;
  re(i, n){
    string t;std::cin >> t;
    s.insert(t);
  }
  std::cout << s.size() << '\n';
  return 0;
}


Measured memory_bytes: 15696
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

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

int main(void) {
  int i,j,k;
  int n=8;
  vector<string> s;
  string t;
  while(cin>>t)s.push_back(t);

  rep(i,s.size()){
    for(j=i;j<i+n;j++)rep(k,n)if(s[j][k]=='1'){
	if(j+1<i+n && k+1<n && s[j][k+1]=='1' && s[j+1][k]=='1' && s[j+1][k+1]=='1')
	  cout<<"A"<<endl;
	if(j+3<i+n && s[j+1][k]=='1' && s[j+2][k]=='1' && s[j+3][k]=='1')
	  cout<<"B"<<endl;
	if(k+3<n && s[j][k+1]=='1' && s[j][k+2]=='1' && s[j][k+3]=='1')
	  cout<<"C"<<endl;
	if(j+2<i+n && k!=0 && s[j+1][k]=='1' && s[j+1][k-1]=='1' && s[j+2][k-1]=='1')
	  cout<<"D"<<endl;
	if(j+1<i+n && k+2<n && s[j][k+1]=='1' && s[j+1][k+1]=='1' && s[j+1][k+2]=='1')
	  cout<<"E"<<endl;
	if(j+2<i+n && k+1<n && s[j+1][k]=='1' && s[j+1][k+1]=='1' && s[j+2][k+1]=='1')
	  cout<<"F"<<endl;
	if(j+1<n+i && k && k+1<n && s[j][k+1]=='1' && s[j+1][k]=='1' && s[j+1][k-1]=='1')
	  cout<<"G"<<endl;
	goto END;
      }
  END:i+=n-1;
  }
}

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

const ll MOD = 1000000007;


int main(){
    int n, m, x;
    cin >> n >> m >> x;
    int c[12];
    int a[12][12];
    rep(i, n){
        cin >> c[i];
        rep(j, m){
            cin >> a[i][j];
        }
    }
    ll yen;
    int aa[12];
    ll ans = MOD;
    for(int bit = 0; bit < (1 << n); bit++){
        yen = 0;
        rep(i, 12) aa[i] = 0;
        for(int i = 0; i < n; i++){
            if(bit & (1 << i)){
                yen += c[i];
                rep(j, m){
                    aa[j] += a[i][j];
                }
            }
        }
        bool flag = true;
        rep(i, m){
            if(aa[i] < x) flag = false;
        }
       // cout << yen << endl;
        if(flag){
            if(ans > yen) ans = yen;
        }
    }
    if(ans != MOD){
        cout << ans << endl;
    }else{
        cout << -1 << endl;
    }
        
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
using namespace std;
const int INF = 1e9;

int n,tmp=1,k,ans,d=1;
vector<int> a;

int main(){
  cin>>n;
  a.push_back(1);
  while((tmp*9)<=n){
    tmp*=9;
    a.push_back(tmp);
  }
  while((d*6)<=n){
    d*=6;
    a.push_back(d);
  }
  vector<int> dp(n+2,INF);
  sort(a.begin(),a.end());
  dp[0]=0;
  for(int i=0;i<=n;i++){
    for(int j=0;j<a.size();j++){
      if(i-a[j]>=0){
	dp[i]=min(dp[i-a[j]]+1,dp[i]);
      }
    }
  }
 
  cout<<dp[n]<<endl;
  return 0;
}



Measured memory_bytes: 640
require 'set'; require 'prime'
INF=Float::INFINITY; MOD=10**9+7
n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)

if a.all?{|a| a.odd? || (a%3==0 || a%5==0)}
  puts 'APPROVED'
else
  puts 'DENIED'
end

Measured memory_bytes: 2300
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {

            List<List<int>> listorverlap = new List<List<int>>();

            string output = string.Empty;

            while (true)
            {
                string[] Input = Console.ReadLine().Split(' ');

                //??\???????????????????????????-1?????????????????????Break??????
                if (Input[0] == "-1" && Input[1] == "-1" && Input[2] == "-1") break;

                List<int> resultlist = new List<int>();

                //??\???????????????Add??????
                foreach (var setdata in Input)
                {
                    resultlist.Add(int.Parse(setdata));
                }
                listorverlap.Add(resultlist);
            }


            foreach(var resul in listorverlap)
            {
                if (resul[0] == -1 || resul[1] == -1)
                {
                    output = "F";
                }
                else
                {
                    int sum = resul[1] + resul[0];

                    Console.WriteLine(Check(sum, resul[2]));
                    continue;
                }

                Console.WriteLine(output);


            }

        }


        private static string Check(int a, int b)
        {
            string rank = string.Empty;

            if(a >= 80) rank = "A";

            if(a >= 65 && a < 80) rank = "B";

            if(a >= 50 && a < 65) rank = "C";

            if(a >= 30 && a < 50)
            {
                if (b >= 50) rank = "C";
                else rank = "D";
            }

            if (a < 30) rank = "F";

            return rank;
        }
    

    }

    }

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

//.define
// #define FILE_IN_OUT
#define RET(_x)    return cout << (_x) << '\n', 0;
#define all(_obj)  (_obj).begin(), (_obj).end()
#define loop(_n)   for (int i = 0; i < (_n); ++i)
#define sz(_obj)   static_cast<int>((_obj).size())
#ifdef SHJ_LOCAL
#define debug(_x)  std::cerr << (#_x) << " = " << (_x) << '\n' << std::flush;
#else
#define debug(_x)  {}
#endif
#define endl "\n"
template<typename P, typename Q>
P CeilDiv(P _dividend, Q _divider) {
    return static_cast<P>((_dividend - 1LL + _divider) / _divider);
}
template<typename Tp>
inline void outarr(Tp _begin, Tp _end, const char* _delim = " ") {
    for (Tp current = _begin; current != _end; ++current) {
        std::cout << *current << _delim;
    }
    std::cout << '\n';
}

//.constant
using ll  = long long;
using pii = std::pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr int MOD = static_cast<const int>(1e9 + 7);

//.data
struct City {
    int X;
    int Y;
    int P;
};

bool HasBit(int x, int b) {
    return (x >> b) & 1;
}

int best_x[1 << 15][15];
int best_y[1 << 15][15];
int kbit[1 << 15];

//.code
int main() {
#ifdef FILE_IN_OUT
    std::ifstream cin ("input.txt",  std::ios::in);
    std::ofstream cout("output.txt", std::ios::out);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif

    int n;
    cin >> n;
    vector<City> arr(n);
    loop(n) {
        cin >> arr[i].X >> arr[i].Y >> arr[i].P;
    }
    const int full_mask = 1 << n;
    for (int mask = 0; mask < full_mask; ++mask) {
        for (int i = 0; i < n; ++i) {
            if (!HasBit(mask, i)) {
                best_x[mask][i] = abs(arr[i].X);
                best_y[mask][i] = abs(arr[i].Y);
                for (int j = 0; j < n; ++j) {
                    if (HasBit(mask, j)) {
                        best_x[mask][i] = min(best_x[mask][i], abs(arr[i].X - arr[j].X));
                        best_y[mask][i] = min(best_y[mask][i], abs(arr[i].Y - arr[j].Y));
                    }
                }
            }
        }
    }
    vector<ll> ans(n + 1, LLONG_MAX);
    for (int mask = 0; mask < full_mask; ++mask) {
        kbit[mask] = kbit[mask >> 1] + (mask & 1);
        if (ans[kbit[mask]] == 0) {
            continue;
        }
        for (int sub_mask = mask; sub_mask > 0; sub_mask = (sub_mask - 1) & mask) {
            ll val = 0;
            for (int i = 0; i < n; ++i) {
                if (!HasBit(mask, i)) {
                    val += 1LL * min(best_x[sub_mask][i], best_y[mask ^ sub_mask][i]) * arr[i].P;
                }
            }
            ans[kbit[mask]] = min(ans[kbit[mask]], val);
        }
        ll val = 0;
        for (int i = 0; i < n; ++i) {
            if (!HasBit(mask, i)) {
                val += 1LL * min(best_x[0][i], best_y[mask][i]) * arr[i].P;
            }
        }
        ans[kbit[mask]] = min(ans[kbit[mask]], val);
    }
    for (ll x : ans) {
        cout << x << endl;
    }

#ifdef FILE_IN_OUT
    cin.close();
    cout.close();
#endif
    return 0;
}

Measured memory_bytes: 7596
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      String line;
      String[] digit;
      int sum;
      String buf;
      StringBuilder result = new StringBuilder();
      while(true) {

        if( (line = br.readLine()) == null || line.isEmpty() ) break;

        digit = line.split(" ");
        sum = Integer.parseInt( digit[0] ) + Integer.parseInt( digit[1] );
        buf = String.valueOf(sum);
        result.append(buf.length()).append("\n");
      }

      System.out.print(result);
    }
  }
}


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

void printVec(vector<int> vec) {
  for (size_t i = 0; i < vec.size(); i++) {
    if (i == vec.size() - 1) {
      cout << vec[i] << endl;
    } else {
      cout << vec[i] << " ";
    }
  }
}

int main() {
  int N, cnt = 0;
  cin >> N;
  vector<int> A(N);
  for (size_t i = 0; i < N; i++) {
    cin >> A.at(i);
  }

  for (size_t i = 0; i < N; i++) {
    auto minA = i;

    for (size_t j = i; j < N; j++) {
      if (A[minA] > A[j]) {
        minA = j;
      }
    }
    if (minA != i) {
      auto tmp = A[minA];
      A[minA] = A[i];
      A[i] = tmp;
      cnt++;
    }
  }

  printVec(A);
  cout << cnt << endl;
}


Measured memory_bytes: 3152
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {

    int n;
    cin >> n;
    string c;
    cin >> c;

    int ans = 0;
    int left = 0, right = c.size() - 1;
    while (true) {
        while (left < c.size() && c[left] != 'W')
            left++;
        while (0 <= right && c[right] != 'R')
            right--;

        if (left > right)
            break;

        swap(c[left], c[right]);
        ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3480
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val (n, m, q) = (sc.nextInt(), sc.nextInt(), sc.nextInt())
  val records = (1 to q).map { _ =>
    val (a, b, c, d) = (sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt())
    Record(a, b, c, d)
  }

  val result = new MainIterator(n, m).map { ax =>
    records.map(_.point(ax)).sum
  }.max
  println(result)
}

class MainIterator(n: Int, m: Int) extends Iterator[Array[Int]] {
  private val ax = Array.fill(n)(1)
  private var isNext = true
  override def hasNext: Boolean = isNext

  override def next(): Array[Int] = {
    val result = ax.clone()
    val upPos = if(ax.last != m) {
      Some(ax.length - 1)
    } else {
      ax.indices.reverse.tail.find { pos => ax(pos) < ax(pos + 1) }
    }
    upPos.foreach { pos =>
      ax(pos) += 1
      ((pos + 1) until ax.length).foreach(ax(_) = ax(pos))
    }
    isNext = upPos.isDefined
    result
  }
}

case class Record(a: Int, b: Int, c: Int, d: Int) {
  def point(ax: Array[Int]): Int = {
    if(ax(b - 1) - ax(a - 1) == c) d else 0
  }
}


Measured memory_bytes: 60384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
const int mod = 1e9+7, A = 2e5+5;
ll n, a[A], dp[A][3];
ll solve(int ind, int f)
{
	if (ind >= n)
		return (f == 2 ? -1e18 : 0);
	if (dp[ind][f] != -1e18)
		return dp[ind][f];
	ll val = -1e18;
	if (f) val = max(val, solve(ind + 1, f - 1));
	val = max(val, solve(ind + 2, f) + a[ind]);
	return dp[ind][f] = val;
}
int main()
{
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < A; i++)
		for (int j = 0; j < 3; j++)
				dp[i][j] = -1e18;
	cout << solve(0, 1 + (n % 2));
	return 0;
}


Measured memory_bytes: 16152
import java.util.*;
 
public class Main {
  public static void main(String[] args)  {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int A = sc.nextInt();
    int B = sc.nextInt();
    
    int sum = 0;
    for (int i = 1; i <= N; i++) {
      int tmp = 0;
      int tmp1 = i;
      while (tmp1 > 0) {
        tmp += tmp1%10;
        tmp1 /= 10;
      }
      if (A <= tmp && tmp <= B) sum+=i;
    }
    System.out.println(sum);
  }
}
    

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

using namespace std;
#define ll long long
#define ld long double
#define mk make_pair
#define pb push_back
#define sz(a) (int)(a).size()
#define rep(i, a, b) for (int i = (a), _b = (b); i < _b; ++i)
#define frep(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i)
#define fwr(x) { cout << x << '\n'; }

typedef complex<ld> cplex;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<iii> viii;

const int inf = 1e9 + 7;
const ll linf = 1ll * inf * inf;
const int N = 10000000;
const int M = 1000000;
const int multipleTest = 0;
const double pi = acos(-1);

int n;

ll pw[M];
int f[N + 10];

ll calc(int x) {
    if (x < M) return pw[x] % inf;
    else {
        if (x & 1) return calc(x - 1) * 10 % inf;
        else {
            ll tmp = calc(x >> 1);
            return tmp * tmp % inf;
        }
    }
}

void solve() {
    cin >> n;
    
    ll res = 0;
    
    pw[0] = 1;
    rep(i, 1, M) {
        pw[i] = pw[i - 1] * 10ll;
        if (pw[i] >= inf) pw[i] %= inf;
    }
    
    int last_j = 0;
    int cnt = 0;
    for (int i = 1; i < N; ++i) {
        if (i == pw[last_j]) {
            ++last_j;
            cnt++;
        }
        f[i] = cnt + f[i - 1];
    }
    
    
    
    int j = N - 1;
    for (int i = 1; i < N; ++i) {
        if (f[N - 1] - f[i - 1] >= n) {
            j = max(j, i);
            while (j < N - 1 && f[j] - f[i - 1] < n) ++j;
            while (j > i && f[j] - f[i - 1] > n) --j;
            if (f[j] - f[i - 1] == n) {
                ++res;
            }
        } else {
            int tmp = n - (f[N - 1] - f[i - 1]);
            if (!(tmp & 7)) {
                ++res;
            }
        }
    }
    
    for (int sl = 1; sl <= n / 8; ++sl) {
        if (n % sl == 0) {
            
        } else {
            ++res;
        }
    }
    
    vector<int> d;
    for (int i = 1; 1ll * i * i <= n; ++i) {
        if (n % i == 0) {
            if (i <= n / 8) d.push_back(i);
            int tmp = n / i;
            if (tmp != i && tmp <= n / 8) d.push_back(tmp);
        }
    }
    
    for (int sl : d) {
        int digits = n / sl;
        ll tmp = calc(digits) - calc(digits - 1);
        res += tmp - sl + 1;
    }
    
    res %= inf;
    if (res < 0) res += inf;
    
    
    cout << res << '\n';
}

int main() {
#ifdef _LOCAL_
    freopen("inp.txt", "r", stdin);
    //    freopen("out.txt", "w", stdout);
#endif
    
    int Test = 1;
    if (multipleTest)
        cin >> Test;
    
    for(int i = 0; i < Test; ++i) {
        //        printf("Case #%d: ", i + 1);
        solve();
    }
#ifdef _LOCAL_
    cout<< "\n" << 1.0 * clock() / CLOCKS_PER_SEC << "\n";
#endif
}


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

int main(){
  int x,y;
  cin>>x>>y;

  string mp[10001];
  for(int i=0;i<y;i++)cin>>mp[i];
  
  int w=0,e=0;
  for(int i=0;i<y;i++)
    for(int j=0;j<x;j++)w+=(mp[i][j]=='W');
  
  
  int W=1,err=w;
  for(int i=0;i<x;i++){
    for(int j=0;j<y;j++){
      w-=mp[j][i]=='W';
      e+=mp[j][i]=='E';
    }
    if(e+w<err) W=i+2 ,err=e+w;
  }
  cout << W-1 <<" "<<W<<endl;
    
  return 0;
}

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

const int MOD=1e9+7;

int main(){
  int n;
  cin>>n;
  ll u=1,a=1,b=1; 
  rep(i,n){
    u*=10; a*=9; b*=8;
    u%=MOD; a%=MOD; b%=MOD;
  }
  ll ans=u-(a*2-b);
  ans%=MOD;
  if(ans<0) ans+=MOD;
  cout<<ans<<endl;
}

Measured memory_bytes: 3640
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e17;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);

const int N=200005;



void solve()
{
   
    ldb cr=100;
    ldb x;
    cin>>x;
    
    for(int i=1;i<=1e7;i++)
    {
        int z=cr/100;
        cr=cr+z;
        if(cr>=x)
        {
            cout<<i<<endl;
            return;
        }
    }
    
}

int32_t main()
{
    IOS;
   // FILE *fin = freopen("in.txt","r",stdin);
    //FILE *fout = freopen("out.txt","w",stdout);

    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        
        solve();
    }
    return 0;
}


Measured memory_bytes: 3748
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define DEBUG true
#ifdef ONLINE_JUDGE
#undef DEBUG
#define DEBUG false
#endif 

using namespace std;

#define MAXN ((int)2e5+5)
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9 + 9)
#define ll long long
#define _ << " " <<
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define TRACE(x) if(DEBUG) cerr << #x << " = " << x << endl;
#define TRACE2(x,y) if(DEBUG) cerr << #x << " = " << x << " | " << #y << " = " << y << endl;
#define pb push_back
#define adouble(x) x.begin(), x.end()
#define endl "\n"
#define pii pair<int,int>
#define mid ((l+r)/2)
#define MP(x,y) make_pair(x,y)
#define PI (3.14159265358979323846) 

double n,a,b;
double ans = 0;

bool sign(double x)
{
	return x >= 0;
}

struct p
{
	double x,y;

	bool operator<(p& rhs)
	{
		return angle() > rhs.angle();
	}	

	p operator+(p rhs)
	{
		return {x + rhs.x, y + rhs.y};
	}
	p operator-(p rhs)
	{
		return {x - rhs.x, y - rhs.y};
	}

	double py()
	{
		return x*x + y*y;
	}

	double angle()
	{
		if(x == 0)
			return (PI / 2) * ((y>0) ? 1:3); 
		if(y == 0)
			return (x>0)? 0:PI;

		if(y < 0 and x < 0)
			return PI + atan(y/x);
		if(y < 0 and x > 0)
			return 3 * PI / 2 + atan(x / abs(y));
		if (y > 0 and x < 0)
			return PI / 2 + atan(abs(x) / y);
		if(y > 0 and x > 0)
			return atan(y/x);
	}
};

void test(p& a)
{
	ans = max(ans, a.py());
}

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);
	
	cin >> n;
	vector <p> v(n);
	for (int i = 0; i < n; ++i)
		cin >> v[i].x >> v[i].y;

	sort(adouble(v));

	// for (auto a : v)
	// 	cout << a.x _ a.y _ a.angle() << endl;

	// return 0;

	vector <p> pre(n);

	pre[0] = v[0];

	for (int i = 1; i < n; ++i)
		pre[i] = pre[i-1] + v[i];

	for (int i = 0; i < n; ++i)
	{
		for (int j = i; j < n; ++j)
		{
			p t = pre[j];
			if(i) t = t - pre[i-1];

			p comp = pre[n-1] - t;

			test(t);
			test(comp);
		}
	}

	cout << fixed << setprecision(30) << sqrt((long double)(ans)) << endl;
}

Measured memory_bytes: 512
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
  public static void main(String[] args) {
    FastScanner sc = new FastScanner();

    int N = sc.nextInt();
    int M = sc.nextInt();
    int A = 0;

    for (int i = 0; i < M; i++) {
      A += sc.nextInt();
    }
    if (A > N) {
      System.out.println(-1);
    } else {
      System.out.println(N - A);
    }

  }
}

class FastScanner {
  private final InputStream in = System.in;
  private final byte[] buffer = new byte[1024];
  private int ptr = 0;
  private int buflen = 0;

  private boolean hasNextByte() {
    if (ptr < buflen) {
      return true;
    } else {
      ptr = 0;
      try {
        buflen = in.read(buffer);
      } catch (IOException e) {
        e.printStackTrace();
      }
      if (buflen <= 0) {
        return false;
      }
    }
    return true;
  }

  private int readByte() {
    if (hasNextByte()) {
      return buffer[ptr++];
    } else {
      return -1;
    }
  }

  private static boolean isPrintableChar(int c) {
    return 33 <= c && c <= 126;
  }

  private void skipUnprintable() {
    while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
      ptr++;
    }
  }

  public boolean hasNext() {
    skipUnprintable();
    return hasNextByte();
  }

  public String next() {
    if (!hasNext()) {
      throw new NoSuchElementException();
    }
    StringBuilder sb = new StringBuilder();
    int b = readByte();
    while (isPrintableChar(b)) {
      sb.appendCodePoint(b);
      b = readByte();
    }
    return sb.toString();
  }

  public int nextInt() {
    if (!hasNext()) {
      throw new NoSuchElementException();
    }
    int n = 0;
    boolean minus = false;
    int b = readByte();
    if (b == '-') {
      minus = true;
      b = readByte();
    }
    if (b < '0' || '9' < b) {
      throw new NumberFormatException();
    }
    while (true) {
      if ('0' <= b && b <= '9') {
        n *= 10;
        n += b - '0';
      } else if (b == -1 || !isPrintableChar(b)) {
        return minus ? -n : n;
      } else {
        throw new NumberFormatException();
      }
      b = readByte();
    }
  }

  public long nextLong() {
    if (!hasNext()) {
      throw new NoSuchElementException();
    }
    long n = 0;
    boolean minus = false;
    int b = readByte();
    if (b == '-') {
      minus = true;
      b = readByte();
    }
    if (b < '0' || '9' < b) {
      throw new NumberFormatException();
    }
    while (true) {
      if ('0' <= b && b <= '9') {
        n *= 10;
        n += b - '0';
      } else if (b == -1 || !isPrintableChar(b)) {
        return minus ? -n : n;
      } else {
        throw new NumberFormatException();
      }
      b = readByte();
    }
  }
}

Measured memory_bytes: 26288
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _176B
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = Console.ReadLine()?.ToCharArray();
            long sum = 0;
            foreach (var ni in N)
            {
                sum += (long)Char.GetNumericValue(ni);
            }

            if (sum % 9 == 0)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


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

int main()
{
    int a,p,n,ans;
    while(scanf("%d%d",&a,&p)!=EOF)
    {
        n=a*3+p;
        ans=n/2;
        printf("%d\n",ans);
    }
   return 0;
}


Measured memory_bytes: 256
N = int(input())
A1 = list(map(int,input().split(" ")))
A2 = list(map(int,input().split(" ")))

for i in range(N-1):
	A1[i+1] += A1[i]
	A2[i+1] += A2[i]

ans = A1[0] + A2[N-1]
for i in range(1,N):
	ans = max(ans,A1[i] + A2[N-1] - A2[i-1])

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int H = 0, W = 0, N = 0;
	int result = 0, calculator = 0, currentVal = 0;
	cin >> H;
	cin >> W;
	cin >> N;

	calculator = (H < W) ? W : H;
	while (currentVal < N) {
		currentVal+=calculator;
		result++;
	}
	cout << result << endl;
}

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

using namespace std;

int a[110] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int k;

int main(void)
{
	scanf("%d", &k);
	printf("%d", a[k - 1]);
	return 0;
}

Measured memory_bytes: 256
# C
k, n = map(int, input().split())
a = list(map(int, input().split()))

for i in range(n):
    a.append(a[i]-k) 
a.sort()
s = [0]*(n+1)
for i in range(n+1):
    s[i] = a[i+n-1] - a[i]
    
print(min(s))

Measured memory_bytes: 29028
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {
        int n = sc.nextInt();
        char[] arr = sc.next().toCharArray();

        int cnt = 1;

        for (int i=0; i<n-1; i++) {
            if (arr[i]!=arr[i+1]) cnt++;
        }

        System.out.println(cnt);
    }

}


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

int a[100010];
int b[100010];

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

    for (int i = 0; i < N; i++) {
        scanf("%d%d", &a[i], &b[i]);
    }
    int ans = 2e9;

    for (int i = 0; i < N; i++) {
        ans = min(ans, a[i] + b[i]);
    }

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mp(x,y) make_pair(x,y)
void solve(){
    ll x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    ll a1[a],b1[b],c1[c],d[b+c];
    for(int i=0;i<a;i++)
        cin>>a1[i];
    for(int i=0;i<b;i++){
        cin>>b1[i];
        d[i]=b1[i];
    }
    for(int i=0;i<c;i++){
        cin>>c1[i];
        d[i+b]=c1[i];
    }
    sort(d,d+b+c);
    reverse(d,d+c+b);
    sort(c1,c1+c);
    reverse(c1,c1+c);
    sort(b1,b1+b);
    reverse(b1,b1+b);
    sort(a1,a1+a);
    reverse(a1,a1+a);
    multiset<ll> m1,m2;
    ll s=0;
    for(int i=0;i<b+c;i++){
        if(i<y) {m1.insert(d[i]); s+=d[i];}
        else m2.insert(d[i]);
    }
    ll f[c+1];
    for(int i=0;i<c;i++){
        f[i]=s;
        if(m1.size()==0 || m2.size()==0) break;
        if(m1.find(c1[i]) != m1.end() && m2.find(c1[i])==m2.end()){
            m1.erase(m1.find(c1[i]));
            auto it=m2.end();
            it--;
            s+=*it-c1[i];
            m1.insert(*it);
            m2.erase(it);
        }
        else{
            m2.erase(m2.find(c1[i]));
        }
    }
    f[c]=s;
    ll ans=f[0];
    for(int i=0;i<x;i++){
        ans+=a1[i];
    }
    ll g=ans;
    for(int i=1;true;i++){
        if(i+y > b+c || i>x || i>c) break;
        g+=-a1[x-i]+c1[i-1];
        g+=f[i]-f[i-1];
        ans=max(ans,g);
    }
    cout<<ans<<'\n';
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int tc;
    tc=1;
    while(tc--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 14336
//abc172_b.cpp
//Sat Jun 27 20:54:52 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	string s,t;
	cin >> s >> t;

	int ans = 0;
	for (int i=0;i<s.length();i++){
		if (s[i]!=t[i]){
			ans++;
		}
	}


	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 3916
import collections

mod = 10**9 + 7
n = int(input())
a = list(map(int, input().split()))
fact = [1]*(n+1)
rfact = [1]*(n+1)
r = 1
for i in range(1, n+1):
  fact[i] = r = r * i % mod
rfact[n] = r = pow(fact[n], mod-2, mod)
for i in range(n, 0, -1):
  rfact[i-1] = r = r * i % mod

# nPk (mod MOD) を求める
def perm(n, k):
  return fact[n] * rfact[n-k] % mod

# nCk (mod MOD) を求める
def comb(n, k):
  return fact[n] * rfact[k] * rfact[n-k] % mod
already = [0] * (n+1)
k = 0
for key,v in enumerate(a):
  if already[v]:
    k = already[v] + n - key - 1
    break
  else:
    already[v] = key+1
for i in range(n+1):
  if i == n:
    print(1)
    exit()
  ans = comb(n,i) + comb(n,i+1)
  if i <= k:
    ans -= comb(k,i)
  ans %= mod
  print(ans)

Measured memory_bytes: 58092
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, m;
	cin >> n >> m;
	vector<int> r(n, 0);

	for(int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		if(x == 1) {
			r[y - 1]++;
		} else if(y == 1) {
			r[x - 1]++;
		} else {
			r[x - 1]++;
			r[y - 1]++;
		}
	}

	int flag = 0;
	for(int i = 0; i < n; i++) {
		if(r[i] % 2) {
			flag++;
			break;
		}
	}

	if(flag) {
		cout << "NO" << endl;
	} else {
		cout << "YES" << endl;
	}

	return 0;
}

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

using namespace std;

int main(void){
	int n;
	scanf("%d\n", &n);
	long long a[5] = {0};

	for(int i = 0;i < n;++i){
		char c;
		scanf("%c", &c);
		if(c == 'M'){
			a[0]++;
		}else if(c == 'A'){
			a[1]++;
		}else if(c == 'R'){
			a[2]++;
		}else if(c == 'C'){
			a[3]++;
		}else if(c == 'H'){
			a[4]++;
		}

		while(c != 10){
			scanf("%c", &c);
		}
	}

	long long s = 0;
	s += a[0] * a[1] * a[2];
	s += a[0] * a[1] * a[3];
	s += a[0] * a[1] * a[4];
	s += a[0] * a[2] * a[3];
	s += a[0] * a[2] * a[4];
	s += a[0] * a[3] * a[4];
	s += a[1] * a[2] * a[3];
	s += a[1] * a[2] * a[4];
	s += a[1] * a[3] * a[4];
	s += a[2] * a[3] * a[4];

	printf("%lld\n", s);
	return 0;
}

Measured memory_bytes: 384