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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define rep(i, k, n) for (int i = (int)(k); i < (int)(n); ++i)
#define rrep(i, k, n) for (int i = (int)(n) - 1; i >= (int)(k); --i)

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vv_ii;
typedef pair<int,ii> i_ii;
typedef vector<i_ii> vi_ii;

template <class T>
inline ostream& operator<<(ostream & o, vector<T> const& v) {
    for (int i = 0; i < (int)(v.size()) - 1; ++i)
        o << v[i] << ' ';
    if (!v.empty())
        o << v.back();
    return o;
}

template <class T, class Q>
inline ostream& operator<<(ostream & o, pair<T,Q> const& p) {
    o << "(" << p.fi << "," << p.se << ")";
    return o;
}


int main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

    int n, m;
    cin >> n >> m;
    cout << ((n * (n-1)) >> 1) + ((m * (m-1)) >> 1) << '\n';

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
#include<cmath>
typedef unsigned long long ll;
using namespace std;
int main(){
  ll n,num,sum=0,cnt=1;
  cin >> n;
  for(ll i=1;i<=sqrt(n);i++){
    if(n%i==0){
      num = n/i -1;
      if(i<num) sum+=num;
    }
  }

  cout << sum <<endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int N;
    cin>>N;
    long long arr[N],contador=0;
    for(int i=0; i<N; ++i)
        cin>>arr[i];
    for(int i=0; i<N; ++i)
    {
        if(arr[i]>0)
        {
            if(arr[i]/2>0)
            contador+=arr[i]/2;
            if(i<N-1&&arr[i]%2>0&&arr[i+1]>0)
            {
                ++contador;
                arr[i+1]=arr[i+1]-arr[i]%2;
            }
        }
    }
    cout<<contador;
    return 0;
}


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

public class Main {

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

    System.out.println(1.0 / Arrays.stream(A).mapToDouble(i -> 1.0 / i).sum());
  }
}

Measured memory_bytes: 27092
#include<cstdio>
    #include<map>
    #include<cstring>
    #include<iostream>
    using namespace std;
    #define N 1000005
    #define ll long long
    int n,ans,tmp[N];
    int ch[N][30],fa[N],sum[N][30],cnt[N],tot=1,ed[N];
//    void update(int x){
////    	for(int i=0;i<26;i++) sum[x][i]=0;
//    	for(int i=0;i<26;i++){
//    		int y=ch[x][i];
//    		if(!y) continue;
//    		sum[x][i]+=cnt[y];
//    		for(int j=0;j<26;j++)
//    			sum[x][j]+=sum[y][j];
//    	}
//    }
    void insert(string s){
    	int len=s.length(),cur=1;
    	for(int i=0;i<len;i++){
    		int y=ch[cur][s[i]-'a'];
    		if(!y) y=ch[cur][s[i]-'a']=++tot,fa[y]=cur;
    		cur=ch[cur][s[i]-'a'];
    		cnt[cur]++;
    	}
    	ed[cur]++;
//    	while(cur){
//    		update(cur);
//			cur=fa[cur];
//		}
    }
    void pushdown(int x){
    	for(int i=0;i<26;i++){
    		int y=ch[x][i];
    		if(!y) continue;
    		pushdown(y);
//    		sum[x][i]+=cnt[y];
			if(ed[y]) sum[x][i]+=ed[y];
    		for(int j=0;j<26;j++)
    			sum[x][j]+=sum[y][j];
    	}
	}
//    void print(int x){
//    	printf("%d\n",x);
//    	for(int i=0;i<26;i++){
//    		if(sum[x][i]) printf("%c %d\n",'a'+i,sum[x][i]);
//		}
//		for(int i=0;i<26;i++)
//			if(ch[x][i]) print(ch[x][i]);
//	}
    void calc(string s){
    	int cur=1,len=s.length();
    	for(int i=0;i<26;i++) tmp[i]=0;
    	for(int i=0;i<len;i++)
    		tmp[s[i]-'a']++;
    	
    	for(int i=0;i<len;i++){
    		if(!ch[cur][s[i]-'a']) return;
    		for(int j=0;j<26;j++)
				if(tmp[j])
    				ans+=ed[ch[cur][j]];
    		tmp[s[i]-'a']--;
    		cur=ch[cur][s[i]-'a'];
		}
//		cout<<s<<" "<<sum[cur][s[len-1]-'a']<<edl; 
		ans+=sum[cur][s[len-1]-'a'];
	}
//    char s[N];
    string S[N];
    int main(){
    	scanf("%d",&n);
    	for(int i=1;i<=n;i++){
    		cin>>S[i];
    		int len=S[i].length();
    		for(int j=0;j<len-j-1;j++)
    			swap(S[i][j],S[i][len-j-1]);
//    		cout<<"insert "<<S[i]<<edl;
    		insert(S[i]);
    	}
//    	pushdown(1);
//    	print(1);
//    	puts("");
    	for(int i=1;i<=n;i++)
    		calc(S[i]);
    	printf("%d",ans-n);
    }

Measured memory_bytes: 164200
import sys

N,M=map(int,input().split())
s=[list(map(int,input().split())) for _ in range(N)]
c=[list(map(int,input().split())) for _ in range(M)]
inf=10**9
def findcp(st):
    dist=inf
    i=0
    for j in range(M):
        if abs(st[0]-c[j][0])+abs(st[1]-c[j][1])<dist:
            dist=abs(st[0]-c[j][0])+abs(st[1]-c[j][1])
            i=j
    return i+1

for i in range(N):
    print(findcp(s[i]))




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

int main(){
    int N;
    cin >> N;
    int P[N];
    int min;
    int count = 0;
    min = 2 * (pow(10, 5));
    for (int i = 0; i < N; i++){
        cin >> P[i];
        if(min >= P[i]){
            min = P[i];
            count++;
        }
            
    }
    cout << count << endl;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#define N 1048576
inline int min(int x,int y){return x<y?x:y;}
inline int max(int x,int y){return x<y?y:x;}
char G[3500000],*H=G;
inline int read()
{
	int x=0;
	while(*H<48||57<*H)H++;
	while(47<*H&&*H<58)x=(x<<1)+(x<<3)+(*H++^48);
	return x;
}
int S[6],T;
inline void print(int x)
{
	int y;
	do y=x/10,S[T++]=x-y*10,x=y;while(x);
	while(T)*H++=S[--T]^48;
}
int a[N],b[N],g[N],h[N],i,j,k,m,n,o;
inline void up(int u){g[u]=min(g[u<<1],g[u<<1|1]);}
inline void add(int u,int v){g[u]+=v,h[u]+=v;}
inline void down(int u){if(h[u])add(u<<1,h[u]),add(u<<1|1,h[u]),h[u]=0;}
inline void push(int u){for(j=o;j;j--)down(u>>j);}
inline void add(int u,int v,int w)
{
	for(push(u+=m-1),push(v+=m+1);u^v^1;up(u>>=1),up(v>>=1))
	{
		if(~u&1)add(u^1,w);
		if(v&1)add(v^1,w);
	}
	while(u>>=1)up(u);
}
inline int query()
{
	int u=1;
	for(;u<m;u=u<<1|(g[u<<1]>0))down(u);
	return u^m;
}
inline void add(int u){while(u<=n)h[u]++,u+=u&-u;}
inline void del(int u){while(u<=n)h[u]--,u+=u&-u;}
inline int sum(int u)
{
	int x=0;
	while(u)x+=h[u],u^=u&-u;
	return x;
}
int main()
{
	fread(G,1,3500000,stdin),n=read(),k=read();
	for(i=1;i<=n;i++)b[a[i]=read()]=i;
	for(m=1;m<n+2;m<<=1)o++;
	for(i=1;i<=n;i++)g[m|b[i]]=sum(min(n,b[i]+k-1))-sum(max(0,b[i]-k)),add(b[i]);
	for(i=g[m]=n+1,memset(h+1,0,n<<2);i<m;i++)g[m|i]=n+1;
	for(i=m,H=G;--i;)up(i);
	for(i=1;i<=n;i++)a[b[i]=query()]=i,add(b[i],b[i],n+1),add(max(1,b[i]-k+1),min(n,b[i]+k-1),-1);
	for(i=1;i<=n;*H++='\n',i++)print(a[i]);
	return 0&fwrite(G,1,H-G,stdout);
}

Measured memory_bytes: 19072
#include<bits/stdc++.h>
 
using namespace std;
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(vector<vector<T>> x){cerr<<"\n{"; int f=x.size();for(int i=0;i<f;i++){cerr<<"("; int g=x[i].size(); for(auto j:x[i]){cerr<<j; (--g!=0)?cerr<<",":cerr<<"";}cerr<<")\n";}cerr<<"}";}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void __print(vector<bool> x){cerr<<"{";int f=x.size();for(auto i:x){cerr<<i;(--f !=0)?cerr<<",":cerr<<"";}cerr<<"}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
 
#ifndef ONLINE_JUDGE
#define trace(x...) cerr << "[" << #x << "] = [", _print(x)
#else
#define trace(x...)
#endif
 
template<typename... T>
void read(T&... args) {
    ((cin >> args), ...);
}
 
template<typename... T>
void writ(T&&... args) {
    ((cout << args << " "), ...);
}
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define INF (ll)1e18
#define IINF (int)1e9
#define EPS 1e-9

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s; cin>>s;
    if(s.at(s.length()-1)=='s'){
        string x="es";
        s=s+x;
    }
    else{
        string x="s";
        s=s+x;
    }
    cout<<s<<endl;
    return 0;
}



Measured memory_bytes: 3668
K=list(map(int,input().split()))
ans=0
num_list=[]
for i in range(1,min(K[0],K[1])+1):
    if K[0]%i==0 and K[1]%i==0:num_list.append(i)
num_list.reverse()
print(num_list[K[2]-1])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
     
using namespace std;
using namespace __gnu_pbds;
     
     
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
#define resz resize
#define ini ll_MAX
#define inl LLONG_MAX
#define MOD 1000000007
#define sz(x) ll((x).size())
#define all(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define F0R(i, a) for (ll i = 0; i < (a); i++)
#define FORR(i, a, b) for (ll i = a; i >= (b); i--)
#define F0RR(i, a) for (ll i = a; i >= 0; i--)
#define trav(a, x) for (auto& a : x)
#define pbds tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
     
using ll = long long;
using vi = vector<ll>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
     
using pii = pair<ll, ll>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
     
using vpii = vector<pii>;
using vvpii = vector<vpii>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
using vpdd = vector<pdd>;
using vvpdd = vector<vpdd>;
     
ll mod(ll a,ll b)
{
    return (b+a%b)%b;
}
     
ll gcd(ll a,ll b)
{
    if(b==0)return a;
    else return gcd(b,a%b);
}
ll po(ll a,ll b)
{
    ll ans = 1;
    while(b--)
        ans*=a;
    return ans;
}
ll pom(ll a,ll b,ll mod)
{
    if(b==0)return 1;
    ll k = pom(a,b/2,mod);
    if(b%2==0)return (k*k)%mod;
    else return ((k*k)*mod*a)%mod;
}
     
ll sqdist(ll a,ll b,ll c,ll d)
{
    return (a-c)*(a-c)+(b-d)*(b-d);
}
ll fact(ll n)
{
    if(n==0)return 1;
    ll ans = 1;
    FOR(i,1,n+1)ans*=i;
    return ans;
}

ll n,k,p;
ll visited[100];
vll vec[100];
void dfs(ll k)
{
    visited[k]++;
    p++;
    FOR(i,0,vec[k].size())
    {
        if(!visited[vec[k][i]])
            dfs(vec[k][i]);
    }
}


     
void solve()
{
    ll n;
    cin>>n;
    ll ans = 0;
    vector<pair<ll,ll>> vec;
    FOR(i,0,n)
    {
        ll x,l;
        cin>>x>>l;
        vec.pb(mp(x+l,x-l));
    }
    sort(all(vec));
    ans = 0;
    ll mi = LLONG_MIN;
    FOR(i,0,vec.size())
    {
        if(vec[i].s>=mi)
        {
            ans++;
            mi = vec[i].f;
        }
    }
    cout<<ans<<endl;
}
     
     
main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    solve();
}

Measured memory_bytes: 2420
macro_rules! scan_sub {
    ( $itr:ident, $t:ty ) => {
        let mut buf = String::new();
        let $itr = {
            while buf.trim().len() == 0 {
                buf = String::new();
                std::io::stdin().read_line(&mut buf).unwrap();
            }
            buf.split_whitespace().map(|n| n.parse::<$t>().unwrap())
        };
    };
}

macro_rules! scan {
    ( $x:ident; Vec<$t:ty> ) => {
        scan_sub!(itr, $t);
        let $x = itr.collect::<Vec<_>>();
    };
    ( $( $x:ident ),*; $t:ty ) => {
        scan_sub!(itr, $t);
        let mut itr = itr;
        $(
            let $x = itr.next().unwrap();
        )*
    };
}

use std::collections::HashMap;

fn main() {
    scan!(n; usize);
    scan!(array; Vec<usize>);

    let mut l_book = HashMap::new();
    let mut r_book = HashMap::new();

    let mut max = 0;
    for i in 0..n {
        if i > array[i] {
            let l = i - array[i];
            if l > max { max = l; }
            let lb = l_book.entry(l)
                .or_insert(0);
            *lb += 1;
        }
        let r = i + array[i];
        let rb = r_book.entry(r)
            .or_insert(0);
        *rb += 1;
    }

    let mut res:usize = 0;
    for i in 0..=max {
        let rw = r_book.get(&i);
        let lw = l_book.get(&i);
        if rw.is_none() || lw.is_none() {
            continue;
        }

        let r = *(rw.unwrap());
        let l = *(lw.unwrap());

        res += r * l;
    }

    println!("{}", res);
}


Measured memory_bytes: 15316
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
# from fractions import gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

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


def main():
    H, W = MAP()
    print(ceil(H*W/2) if H != 1 and W != 1 else 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38640
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <locale>
#include <iomanip>
#include <cstring>

#define nl '\n'

using namespace std;

double n, k, p, s, w;

double max(vector<double> v, double n, double k){
    s = 0;
    for(int i = 0; i < k; i++){
        s = s + (v[i]+1)/2;
    }
    w = s;
    for(int i = k; i < n; i++){
        w = w + ((((v[i]+1)/2) - ((v[i - k]+1)/2)));
        s = max(s, w);
    }

    return s;
}

int main(){

    vector<double> v;

    cin >> n >> k;

    for(int i = 0; i < n; i++){
        cin >> p;
        v.push_back(p);
    }

    cout << fixed << setprecision(10) << max(v, n, k);
}

//g++ -std=c++14 comp.cpp -o b; ./b.exe
//g++ -std=c++14 comp.cpp && ./a.out

Measured memory_bytes: 3440
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  int a, b, x;
  cin >> a >> b >> x;
  if(x - a < 0) {
    cout << "NO" << endl;
    return 0;
  }
  if(x - a > b) {
    cout << "NO" << endl;
    return 0;
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;

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

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

int main()
{
    int a, b, c;
    cin >> a >> b >> c;

    if (a + b == c || b + c == a || c + a == b) { cout << "Yes" << endl; }
    else { cout << "No" << endl; }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
int main()
{
    lint a, b, c;
    cin >> a >> b >> c;
    if(c < a + b) {
        cout << "No" << endl;
        return 0;
    }
    if((c-a-b)*(c-a-b) > 4*a*b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

#define MAX 100000
#define INF 2140000000
#define MOD 1000000007

int main() {
	int n, d;
	cin >> n >> d;
	vector<vector<int> > v(n);

	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < d; ++j) {
			int k;
			cin >> k;
			v[i].push_back(k);
		}
	}

	int cnt = 0;

	for (int i = 0; i < n; ++i) {
		for (int j = i + 1; j < n; ++j) {
			long long t = 0;
			for (int k = 0; k < d; ++k) {
				t += (v[i][k] - v[j][k]) * (v[i][k] - v[j][k]);
			}

			long long p = pow(t, .5);

			if (p * p == t) {
				cnt++;
			}
		}
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
ll const 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;}

int N,K;
int A[100000];

int main(){
    cin>>N>>K;
    rep(i,N) cin>>A[i];

    int maxi=0;
    rep(i,N) maxi=max(maxi,A[i]);
    
    int g=0;
    rep(i,N) g=gcd(g,A[i]);

    string ans;
    if(maxi<K || K%g!=0) ans="IMPOSSIBLE";
    else ans="POSSIBLE";

    cout<<ans<<endl;
}

Measured memory_bytes: 3924
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define P pair<ll,ll> 
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll l;cin>>l;
  double x=(l/3.0);
  double ans=x*x*x;
  printf("%.10f\n",ans);
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int sum = 0, max = 0;
        for (int i = 0; i < n; i++) {
            int temp = sc.nextInt();
            sum += temp;
            max = Math.max(max, temp);
        }
        System.out.println(sum-(max/2));

    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
static const ll MOD = 1000000007;

ll nPr(ll n,ll r,ll mod){
  ll ret = 1;
  for(ll i=n;i>=n-r+1;i--){
    ret = ret * (i % mod) % mod;
  }
  return ret;
}

int main(){
  ll n,m;
  cin >> n >> m;

  if(n+1 < m){
    cout << "0" << endl;
    return 0;
  }
  if(n > m+1){
    cout << "0" << endl;
    return 0;
  }

  if(n==m){
    ll ans = ((nPr(n,n,MOD)*nPr(m,m,MOD))*2)%MOD;
    cout << ans << endl;
    return 0;
  }else{
    ll ans = (nPr(n,n,MOD)*nPr(m,m,MOD))%MOD;
    cout << ans << endl;
    return 0;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
    int sum=0,sum2=0;
    string s,f1,f2;
    cin>>s;
    for(int i=0;i<s.length();i++){
        if(i%2==0){
            f1+='0';
            f2+='1';
        }
        else{
            f1+='1';
            f2+='0';
        }
    }
    for(int i=0;i<s.length();i++){
        if(s[i]!=f1[i]){
            sum++;
        }
        else if(s[i]!=f2[i]){
            sum2++;
        }
    }
    cout<<min(sum2,sum)<<endl;
    return 0;
}


Measured memory_bytes: 768
#ifndef Local
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx")
#endif

#include <bits/stdc++.h>

using namespace std;

#define popCnt(x) (__builtin_popcountll(x))
#define sz(x) ((int)(x.size()))
#define all(v) begin(v), end(v)
#define rall(v) rbegin(v), rend(v)
typedef long long Long;
typedef double Double;

template <class U, class V>
istream& operator>>(istream& is, pair<U, V>& p) {
  is >> p.first >> p.second;
  return is;
}
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (auto& x : v) {
    is >> x;
  }
  return is;
}

template <class T>
ostream& operator<<(ostream& os, vector<T>& v) {
  for (auto& x : v) {
    os << x << " ";
  }
  return os;
}
const int N = 1e5 + 6;
int cnt[N];
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifdef Local
  freopen("test.in", "r", stdin);
#else
#define endl '\n'
#endif

  char c;
  cin >> c;
  cout << (isupper(c) ? 'A' : 'a') << endl;
  return 0;
}

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

int main() {
	int n,k;
	cin>>n >> k;
	int t=n;
	set<int>s;
	while(k--){
		int d;
		cin>>d;
		for(int i =0;i<d;i++){
			int h;
			cin>>h;
			s.insert(h);
		}
	}
	int j=s.size();
	cout<<t-j;
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>

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

using namespace std;

int main(){
	int n,k,q; cin>>n>>k>>q;

	int cnt[100000]={};
	rep(i,q){
		int a; cin>>a; a--;
		cnt[a]++;
	}

	rep(i,n) cout<<(k-q+cnt[i]>0?"Yes":"No")<<endl;

	return 0;
}


Measured memory_bytes: 1024
//
// D - Mixing Experiment
//

#include <iostream>

using namespace std;

const int INF = 1 << 29;
int dp[41][401][401];

int main() {

    int N, Ma, Mb;
    cin >> N >> Ma >> Mb;

    fill(dp[0][0], dp[41][0], INF);
    dp[0][0][0] = 0;
    int Ta = 0, Tb = 0;

    for (int i = 0; i < N; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        for (int j = 0; j <= Ta; j++) {
            for (int k = 0; k <= Tb; k++) {
                dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]);
                dp[i + 1][j + a][k + b] = min(dp[i + 1][j + a][k + b], dp[i][j][k] + c);
            }
        }
        Ta += a;
        Tb += b;
    }

    int ans = INF;

    for (int i = Ma, j = Mb; i <= Ta && j <= Tb; i += Ma, j += Mb) {
        ans = min(ans, dp[N][i][j]);
    }

    cout << (ans != INF ? ans : -1) << endl;
}

Measured memory_bytes: 25984
#include <stdio.h>
int main(void){

    int A, B, C, D;
    int tATK,aATK;

    scanf("%d %d %d %d", &A, &B, &C, &D);

    aATK = (A-1) / D;
    tATK = (C-1) / B;

    if(aATK>=tATK){
        printf("Yes");
    }else{
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pb  push_back
#define  F   first
#define  S   second
const ll N=2e5+3;
set<ll>s;
ll n,a[]={3,5,7};
bool C(ll m)
{
    set<ll>ss;
    while(m!=0)
    {
        ss.insert(m%10);
        m/=10;
    }
    return ((ll)ss.size()==3)? true: false;
}
void go(ll v)
{
    if(v>n || s.find(v)!=s.end())
    {
        return;
    }
    else
    {
        if(C(v)==true)
        {
            s.insert(v);
        }
        go(v*10+3);
        go(v*10+5);
        go(v*10+7);
    }
}
int main()
{
    ft
    ll t,i,j,m,l,r;
    cin>>n;
    go(0);
    cout<<(ll)s.size()<<"\n";
    return 0;
}



Measured memory_bytes: 1536
#include <iostream>

int main()
{
	int n;
	std::cin >> n;
	
	for (int i=1; i<=n; i++) {
		if (i%3==0) {
			std::cout << " " << i; continue;
		}
		for (int x=i; x>0; x/=10) {
			if (x%10==3) {
				std::cout << " " << i; break;
			}
		}
	}
	std::cout << std::endl;
	
	return 0;
}




Measured memory_bytes: 3104
N = int(input())
A = list(map(int, input().split()))
 
 
def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    return gcd(b, a % b)
 
 
L = [0] * (N + 1)
R = [0] * (N + 1)
for i in range(N):
    L[i+1] = gcd(L[i], A[i])
 
for i in range(N-1, -1, -1):
    R[i] = gcd(R[i+1], A[i])
 
ans = 1
for i in range(N):
    ans = max(ans, gcd(L[i], R[i+1]))
 
print(ans)

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

using namespace std;

int main( )
{	
    int n;
    cin>>n;
    
    vector<int> A(n);
    
    for( int i=0; i<n; i++ ) {
    	cin>>A[i];
    }
    int cnt = 0;
    for( int i=0; i<n; i++ ) {
    	for( int j=n-1; i<j; j-- ) {
    		if( A[j] < A[ j-1 ] ) {
    			int t = A[j];
    			A[j] = A[ j-1 ];
    			A[ j-1] = t;
    			cnt++;
    		}
    	}
    }
    for( int i=0; i<n; i++ ) {
    	cout<<A[i];
    	if( i != n-1 ) { cout<<" "; }
    }
    cout<<"\n"<<cnt<<endl;
	
	return 0;
}

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

int main(){
  double a,b,c,d,e,f;
  cin>>a>>b>>c>>d>>e>>f;
  
  double res=0;
  double ans=0;
  rep(i,31)rep(j,31){
    double p=min(f-100*(a*i+b*j),e*(a*i+b*j));
    if(p<0) continue;
 
    double q=0;
    rep(k,int(p/c)+1){
      q=max(c*k+d*(int((p-c*k)/d)),q);
    }
    if(ans<q/(100*(a*i+b*j)+q)){
      res=100*(a*i+b*j)+q;
      ans=q/(100*(a*i+b*j)+q);
    }
  }
  if(res!=0) cout<<res<<" "<<res*ans<<endl;
  else cout<<100*a<<" "<<0<<endl;
}

Measured memory_bytes: 256
n = int(input())

buttons = []

for i in range(n):
    a = int(input())
    buttons.append(a)

next = 0
cnt = 1
for i in range(n):
    next = buttons[next] - 1
    if next == 1:
        print(cnt)
        exit()
    cnt += 1
print(-1)



Measured memory_bytes: 7340
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <climits>
#include <cmath>
#include <functional>
#include <map>
#include <queue>
#include <set>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const int MOD = 1e9 + 7;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

const int maxi = 1e6+10;
string s;
ll n,k;

int main () {
  cin >> n >> k >> s;
  std::vector<int> v;
  int score = 0;
  rep(i,n) {
    if(i==0) v.push_back(1);
    else if(s[i] == s[i-1]) {
      v.back() += 1;
      score += 1;
    }
    else v.push_back(1);
  }
  ll result = 0;
  ll siz = v.size();
  if(siz - 2 * k <= 0) result = n - 1;
  else result = score + 2 * k;
  cout << result << endl;
}


Measured memory_bytes: 1020
n,m = map(int,input().split())
x = list(map(int,input().split()))
x.sort()

if n >= m:
    print(0)
    exit()
else:
    l = []
    for i in range(m-1):
        l.append(x[i+1]-x[i])
    l.sort()

t = []
t = l[:len(l)-(n-1)]
print(sum(t))


Measured memory_bytes: 13968
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF =1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define pb push_back
int main(){
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(c, b / a) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long d[109][100009],a[100009],b[100009],i,n,w;
long long dp(int i,int w){
    if(i==n) return 0;
    if(d[i][w]!=-1) return d[i][w];
    d[i][w]=dp(i+1,w);
    if(w>=a[i]) d[i][w]=max(d[i][w],b[i]+dp(i+1,w-a[i]));
    return d[i][w];
}
int main()
{
    cin>>n>>w;
    memset(d,-1,sizeof d);
    for(i=0;i<n;i++) cin>>a[i]>>b[i];
    cout<<dp(0,w);
    return 0;
}


Measured memory_bytes: 85376
import itertools
N,C = map(int,input().split())
D = [input().split() for l in range(C)]
c = [input().split() for l in range(N)]
F = list(range(C))
B = list(itertools.permutations(F, 3))
ans = 0
kotae = float("inf")
moto1 = [0] * C 
moto2 = [0] * C 
moto3 = [0] * C 
for i in range(N):
    for j in range(N):
        if (i+j+2) %3 == 1:
                moto1[int(c[i][j])-1] += 1
        if (i+j+2) %3 == 2:
                moto2[int(c[i][j])-1] += 1
        if (i+j+2) %3 == 0:
                moto3[int(c[i][j])-1] += 1
for e,f,g in B:
    for i in range(C):
        ans += moto1[i] * int(D[i][e])
        ans += moto2[i] * int(D[i][f])
        ans += moto3[i] * int(D[i][g])
    kotae = min(ans,kotae)
    ans = 0
print(kotae)

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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
char orr(char A){
  if(A=='1')
    return '0';
  else
    return '1';
}
int main(){
  string S;
  cin>>S;
  char A[S.size()],B[S.size()];
  A[0]='0';
  B[0]='1';
  for(int i=1;i<S.size();i++){
    A[i]=orr(A[i-1]);
    B[i]=orr(B[i-1]);
  }
  int countA=0,countB=0;
  //  rep(i,S.size())
  // cout<<A[i];
     
  rep(i,S.size()){
    if(A[i]!=S[i])
      countA++;
    if(B[i]!=S[i])
      countB++;

  }
  cout<<min(countA,countB)<<endl;

  return 0;
}
  


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

int main() {
    ll x, a, b; cin >> x >> a >> b;
    string ans;
    if(b <= a) ans = "delicious";
    else if(b - a > x) ans = "dangerous";
    else ans = "safe";
    cout << ans << endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

int main( void ) {
    int n, a, b;
    std::cin >> n >> a >> b;

    std::vector< int > hs;
    for( size_t i = 0; i < n; ++i ) {
        int h;
        std::cin >> h;
        hs.push_back( h );
    }

    // とりあえずbでx回攻撃して削ったとみなして
    // 残ったヒットポイントは
    // 「実は必要な分はこの怪物をaで攻撃してたから0になってるんだよ！」
    // と後付けでいう。
    // それが全ての怪物で問題なく言えるなら、x回の攻撃で倒せる
    // その上で最小のxを二分探索で探す

    // 一番少ないものを、aだけで倒せばOKの時が最小
    size_t min = std::floor( *std::min_element(hs.begin(), hs.end()) / (double)a );
    // 初期上限としては、最大のものをbだけで吹き飛ばすほどの回数で十分
    size_t max = std::ceil( *std::max_element(hs.begin(), hs.end()) / (double)b );

    // 二分探索で確定するまで調べる
    while( min != max ) {
        // 二分探索する
        const size_t mid = (min + max) / 2;

        size_t a_attacks = 0;
        const int base = mid * b;
        for( size_t i = 0; i < hs.size(); ++i ) {
            // 何回分のa攻撃が必要なのか求める。
            // b攻撃してきた中にa攻撃であるものが実はある程度あった、、、という計算は
            // hs[i] - baseでb攻撃分のhを削ったあと、a-bだけダメージが増す攻撃があったということ
            const int attacks = std::ceil( (double)(hs[ i ] - base) / (a - b) );
            // 0を下回る場合、もうb攻撃だけで死んでいるからa攻撃しない
            if( attacks <= 0 ) continue;
            // この怪物で必要なa攻撃の回数を集計にいれておく
            a_attacks += attacks;
        }

        if( a_attacks <= mid ) {
            // mid回の攻撃でa攻撃を分配することで間に合うなら、もっと少ない攻撃回数で十分
            max = mid;
        } else {
            // mid回の攻撃でa攻撃を分配しても間に合わないなら、もっとたくさんの攻撃回数が必要
            min = mid + 1;
        }
    }

    // minに結果が出てる
    std::cout << min << std::endl;
    
    return 0;
}

Measured memory_bytes: 892
// This code wrote by chtholly_micromaker(MicroMaker)
#include <bits/stdc++.h>
#define reg register
#define int long long
using namespace std;
template <class t> inline void read(t &s)
{
	s=0;
	reg int f=1;
	reg char c=getchar();
	while(!isdigit(c))
	{
		if(c=='-')
			f=-1;
		c=getchar();
	}
	while(isdigit(c))
		s=(s<<3)+(s<<1)+(c^48),c=getchar();
	s*=f;
	return;
}
int a[2050];
signed main(void)
{
	int x;
	cin>>x;
	for(int i=-1000;i<=1000;++i)
		a[i+1000]=i*i*i*i*i;
	for(int i=-1000;i<=1000;++i)
		for(int j=-1000;j<=1000;++j)
			if(a[i+1000]-a[j+1000]==x)
			{
				printf("%lld %lld\n",i,j);
				return 0;
			}
	return 0;
}




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

int main()
{
    int n,m;
    int a[10005];
    long long sum=0;
    scanf("%d %d",&n,&m);
    for(int i=0;i<m;i++)
    {
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    if(sum>n)
    {
        printf("-1\n");
    }
    else
    {
        printf("%lld\n",n-sum);
    }
    return 0;
}


Measured memory_bytes: 3848
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
using P=pair<int,int>;
int main() {
    int n,k;cin>>n>>k;
    vector<ll> h(n);
    rep(i,n) cin>>h[i];
    sort(h.begin(),h.end());
    ll mini=10000000000;
    for(int i=0;i<n-k+1;i++){
        ll dev=h.at(i+k-1)-h.at(i);
        mini=min(mini,dev);
    }
    cout<<mini<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <climits>

long long int N;
long long int a[200001] = {};
long long int least = INT_MAX;
long long int b = 0;
long long int c = 0;

using namespace std;

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> a[i];
		c += a[i];
	}
	for (int i = 1; i < N; i++) {
		b += a[i];
		c -= a[i];
		if (least > abs(b - c))least = abs(b - c);
	}
	cout << least << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>

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

     scanf("%d %d %d",&a,&b,&c);

     if(a <= b&&b <= c){
       printf("%d %d %d\n",a,b,c);
     }else if(a <= c&&c <= b){
       printf("%d %d %d\n",a,c,b);
     }else if(b <= a&&a <= c){
       printf("%d %d %d\n",b,a,c);
     }else if(b <= c&&c <= a){
       printf("%d %d %d\n",b,c,a);
     }else if(c <= a&&a <= b){
       printf("%d %d %d\n",c,a,b);
     }else if(c <= b&&b <= a){
       printf("%d %d %d\n",c,b,a);
     }
     
      return 0;
}

Measured memory_bytes: 1780
<?php

while (TRUE) {
    $s = rtrim(fgets(STDIN));
    if ($s === '') {
        break;
    }
    $n = strlen($s);
    while (TRUE) {
        for ($i = 0; $i < $n; $i++) {
            if ($s[$i] < 'a' || $s[$i] > 'z') {
                continue;
            }
            $s[$i] = chr(ord($s[$i]) + 1);
            if ($s[$i] > 'z') {
                $s[$i] = 'a';
            }
        }
        if (preg_match('/(^| )(the|this|that)( |\.)/', $s)) {
            echo $s . PHP_EOL;
            break;
        }
    }
}

Measured memory_bytes: 6708
// created by mtnshh
 
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
 
#define ll long long
#define ld long double
 
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
 
#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl
 
#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)    A.rbegin(),A.rend()
#define ft first
#define sd second
 
#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V>
#define Vpll vector<pll>
 
#define endl "\n"
 
const ll logN = 20;
const ll M = 1000000007;
const ll INF = 1e12;
#define PI 3.14159265
 
const ll N = 100005;

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll n,m;
	cin>>n>>m;
	if(n==m){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
    return 0;
}

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

int h,w,c;
int board[8][8];
bool vis[8][8];
int dy[] = {-1,0,1,0}, dx[] = {0,1,0,-1};

int dfs(int y,int x, int col){
  if(vis[y][x] || board[y][x] != col)return 0;
  vis[y][x] = true;

  int res = 1;
  for(int i=0;i<4;i++){
    int ny = y+dy[i], nx = x+dx[i];
    if(ny<0 || nx<0 || ny>=h || nx>=w)continue;
    res += dfs(ny,nx,col);
  }
  return res;
}

int rec(int depth){
  if(depth==5){
    if(board[0][0] != c)return 0;

    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++)vis[i][j] = false;
    }
    return dfs(0,0,c);
  }

  int tmp[8][8];
  bool local_vis[8][8];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      vis[i][j] = false;
      tmp[i][j] = board[i][j];
    }
  }
  
  dfs(0,0,board[0][0]);

  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++)local_vis[i][j] = vis[i][j];
  }

  int res = 0;
  for(int col=1;col<=6;col++){
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	if(local_vis[i][j])board[i][j] = col;
      }
    }
    res = max(res,rec(depth+1));
  }

  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      board[i][j] = tmp[i][j];
    }
  }
  return res;
}

int main(){
  while(cin >> h >> w >> c, h){
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++)cin >> board[i][j];
    }

    cout << rec(0) << endl;
  }
}

Measured memory_bytes: 1160
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

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

    int D;
    cin >> D;
    vector<int> c(26), cc(26);
    rep(i, 26) {
        cin >> c[i];
        cc[i] = c[i];
    }
    vector<vector<int>> s(D);
    rep(i, D) {
        s[i].resize(26);
        rep(j, 26) cin >> s[i][j];
    }

    vector<int> lst(26);

    vector<bool> held(26);

    rep(d, D) {
        if (d % 26 == 0) {
            rep(i, 26) held[i] = false;
        }
        int x = -1;
        int best = -1000000;
        rep(i, 26) {
            if (held[i]) continue;
            int tmp = s[d][i] - cc[i];
            if (best < tmp) {
                x = i;
                best = tmp;
            }
        }
        held[x] = true;
        cout << (x+1) << endl;

        int v = s[d][x];
        lst[x] = d+1;
        rep(i, 26) {
            v -= ((d+1)-lst[i]) * c[i];
            cc[i] = ((d+1)-lst[i]) * c[i];
        }
        // cerr << "d = " << d << ", v = " << v << endl;    
    }

    return 0;
}




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

#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;

string s;
int ans=700;

int main() {
   io;
   cin >> s;
   for(int i = 0 ; i < 3 ; i++)
        if(s[i] == 'o')
            ans += 100;
   cout << ans;
}


Measured memory_bytes: 256
def main():
    n, a, b = input().split()
    n, a, b = int(n), int(a), int(b)
    syou = int(n / (a + b))
    amari = n % (a + b)
    
    if amari - a < 0:
        print(a * syou + amari)
    else:
        print(a * syou + a)

if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
const ll mod = 1e9+7;
const ll INF = (ll)1e18+1;

ll x, y;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    //freopen("A.txt", "r", stdin);
    #endif
    cin >> x >> y;
    cout << (abs(x-y)<=1?"Brown":"Alice");
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <climits>

using namespace std;

char solve() {
    int a, b;
    cin >> a >> b;
    if (a+b==15) return '+';
    if (a*b==15) return '*';
    return 'x';
}

int main() {
    cout << solve();
    return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
if N>=M: print(0)
else:
    X=list(map(int,input().split()))
    X.sort()
    sub=[]
    for i in range(M-1):
        sub.append(X[i+1]-X[i])
    print(sum(sorted(sub)[:M-N]))

Measured memory_bytes: 13968
import java.util.*;
 
class Main{
  public static void main(String[] args){
    Scanner scan=new Scanner(System.in);
    int in=scan.nextInt();
    int price=0;
    price+=in/500*1000;
    in%=500;
    price+=in/5*5;
    System.out.println(price);
  }
}

Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;

int main(){
    string S,T;
    cin >> S >> T;
    
    cout << T + S << endl;
}


Measured memory_bytes: 256
import fractions

a, b, c, d = map(int, input().split())
lcm_cd = (c * d) // fractions.gcd(c, d)
total = b - a + 1
d_c = b // c - (a - 1) // c
d_d = b // d - (a - 1) // d
d_cd = b // lcm_cd - (a - 1) // lcm_cd
print(int(total - (d_c + d_d - d_cd)))

Measured memory_bytes: 5304
#include <iostream>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <algorithm>
#include <functional>
#include <limits.h>
#include <bitset>

#include <tuple>
#include <unordered_map>

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

const int INF = 1 << 29;
const double EPS = 1e-9;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
const int MAX_HW = 1500;
int dp[MAX_HW][MAX_HW];
int board[MAX_HW][MAX_HW];
int H, W;
int main() {
	scanf("%d %d", &H, &W);
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
    	scanf("%d", &board[i][j]);
    }
  }
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      dp[i][j] = (board[i][j] + 1) % 2;
    }
  }
  int res = 0;
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      if (board[i][j] == 0) {
        dp[i][j] = min(dp[i - 1][j - 1], min(dp[i - 1][j], dp[i][j - 1])) + 1;
      }
      res = max(res, dp[i][j]);
    }
  }
  printf("%d\n", res * res);
  return 0;
}

Measured memory_bytes: 18168
// E - Simple String Queries
// Segment Tree version
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using vi = vector<int>;
using vvi = vector<vi>;

// Segment Tree (sum)
template<class T> struct SegmentTree{//(0_origin)
private:
	int n;//最下段データ数
	T node;//セグ木
public:
	SegmentTree(const T &v){// データ配列 v をセグ木にする。
		int size = v.size();
		for(n=1; n<size; n<<=1);//最下段領域数
		node.resize(2*n-1, 0);//セグ木領域
		for(int i=0; i<size; ++i) node[n-1 + i] = v[i];//最下段データ設定
		for(int i=n-2; i>=0; --i) node[i] = node[2*i+1] + node[2*i+2];//ボトムアップで初期設定(sum)
	}
	void update(int ix, int val){
		ix += n-1;//最下段のindex
		if(node[ix] == val) return;
		node[ix] = val;//ボトムアップで更新
		while(ix){
			ix = (ix-1)/2;
			node[ix] = node[2*ix+1] + node[2*ix+2];//(sum)
		}
	}
	int sum(int a, int b, int k=0, int l=0, int r=-1){// data:[a,b) segT:[l,r) k:self index
		if(r<0) r = n;//first call [l,r)=[0,n)
		if(r<=a || b<=l) return 0;//unmatch: !(l<b & a<r)
		if(a<=l && r<=b) return node[k];//finish
		int retL = sum(a, b, 2*k+1, l, (l+r)/2);//left(sum)
		int retR = sum(a, b, 2*k+2, (l+r)/2, r);//right(sum)
		return retL + retR;//(sum)
	}
};

using SEGT = SegmentTree<vi>;
using VSEG = vector<SEGT>;

int main(){
	int N,Q;
	string S;
	cin>>N>>S>>Q;

	VSEG segT(26,SEGT(vi(N)));
	rep(i,N) segT[S[i]-'a'].update(i, 1);

	while(Q--){
		int t;
		cin>>t;
		if(t-1){//type2 out
			int l,r,ans=0;
			cin>>l>>r;
			rep(i,26){
				int ret = segT[i].sum(l-1, r);//[l,r)
				if(ret) ans++;
			}
			printf("%d\n",ans);
		}
		else{//type1 update
			int i; char c;
			cin>>i>>c;
			segT[S[i-1]-'a'].update(i-1, 0);//del
			S[i-1] = c;
			segT[S[i-1]-'a'].update(i-1, 1);//add
		}
	}
}

Measured memory_bytes: 113540
/**
 author : clones
**/

#include <bits/stdc++.h>

using namespace std;

int a, b, c;
long long res = 0;

int main() {
  cin >> a >> b >> c;
  if (a < c) {
    res += (a+1);
    c -= (a+1);
  }
  else {
    res += c;
    c = 0;
  }
  if (c == 0) res += b;
  else {
    if (b >= c) res += (b+c);
    else res += 2*b;
  }
  cout << res << '\n';
  return 0;
}


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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = x ; i < n ; ++i)
#define rep(i, n) for(int i = 0 ; i < n ; ++i)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())

const int IINF = 1e9 + 10;
const long long LLINF = (long long)1e18 + 10;
const long long MOD = (long long)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

int main(){
    int n;
    cin >> n;
    vector< vector<int> > v(3);
    rep(i, 3){
        v[i].resize(n);
    }
    rep(j, n){
        rep(i, 3){
            cin >> v[i][j];
        }
    }
    int dp[3][100010] = {0};
    rep(k, n){
        rep(i, 3){
            rep(j, 3){
                if(i == j){
                    continue;
                }
                dp[i][k + 1] = max(dp[i][k + 1], dp[j][k] + v[i][k]);
            }
        }
    }
    int ans = 0;
    rep(i, 3){
        ans = max(ans, dp[i][n]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
//#define INF 1e18
#define MOD 1000000007

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

const int MAX = 1000005;

long long fac[MAX], finv[MAX], inv[MAX]; //n!, 1/n!, 1/n

// テーブルを作る前処理
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(){
  int x,y,a,b;
  cin >> x >> y;
  if((x+y)%3 !=0 || ((x+y)/3+x-y)%2!=0 || ((x+y)/3+y-x)%2!=0){
    cout << 0 << endl;
    return 0;
  }
  a = ((x+y)/3+x-y)/2;
  b = ((x+y)/3-x+y)/2;
  COMinit();
  cout << COM(a+b,a) << endl;

  return 0;
}


Measured memory_bytes: 23680