akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;

typedef long long s64;

const int MaxN = 2000;
const int MaxM = 2000;
const int M = 1000000007;

inline int add(int a, const int &b)
{
	a += b;
	return a >= M ? a - M : a;
}
inline int dec(int a, const int &b)
{
	a -= b;
	return a < 0 ? a + M : a;
}

int n, m, nK;
int f[MaxN + MaxM][MaxN + 1];

int res = 0;

int main()
{
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);

	cin >> n >> m >> nK;

	int l = (n + m - 1) / --nK;
	int p = n % nK, q = (m - 1) % nK;

	f[0][0] = 1;
	for (int i = 1; i <= l; ++i)
	{
		int now = min(i * nK, n);
		for (int j = 0; j <= now; ++j)
		{
			int up = min(nK, j);
			for (int k = 0; k <= up; ++k)
				f[i][j] = add(f[i][j], f[i - 1][j - k]);
		}

		for (int j = 0; j <= now; ++j)
		{
			if (j % nK != p || (i * nK - j) % nK != q)
				continue;
			if (i * nK - j < m)
				res = add(res, dec(f[i][j], f[i - 1][j]));
		}
	}

	cout << res << endl;

	fclose(stdin);
	fclose(stdout);
	return 0;
}

Measured memory_bytes: 30592
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,ans=0;
  cin>>n;
  int k[2*n];
  for(int i=0;i<2*n;i++){
    cin>>k[i];
  }
  int m=2*n;
  sort(k,k+m);
  for(int i=0;i<2*n;i+=2){
    ans+=k[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, d: "List[int]"):
    d.sort()
    abc = d[int(N/2)-1]
    arc = d[int(N/2)]
    print(arc-abc)

    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    d = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, d)

if __name__ == '__main__':
    main()


Measured memory_bytes: 80976
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         sort(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  ll n; cin >> n;
  vector<ll> a(n); rep(i, n) cin >> a[i];
  vector<ll> sums(n + 1);
  for (int i = 1; i <= n; i++) {
    sums[i] = sums[i - 1] + a[i - 1];
    // debug2(i, sums[i]);
  }
  ll ans = __INT_MAX__;
  for (int i = 1; i < n; i++)
    ans = min(ans, abs(sums[n] - 2 * sums[i]));
  outl(ans);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 3328
#include<stdio.h>
#include<stdlib.h>
#include<math.h>


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

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

if(a<=5)
{
    c = 0;
}
else if(a<=12)
{
    c = b/2;
}
else
{
    c = b;
}

printf("%d",c);
return 0;
}

Measured memory_bytes: 128
K = input()
N = len(K)
D = int(input())
Y = [0] * D
P = 10**9+7
a = 0
for i in range(N):
    nY = [0] * D
    c = int(K[i])
    for j in range(10):
        if j < c:
            nk = (j+a) % D
            nY[nk] = (nY[nk] + 1) % P

        for k in range(D):
            nk = (j+k) % D
            nY[nk] = (nY[nk] + Y[k]) % P
        
    a = (a+c) % D
    Y = nY
print((Y[0] - 1 + (a==0)) % P)

Measured memory_bytes: 43292
#include<bits/stdc++.h>
using namespace std;
#define ll long long
vector<ll> g,v;
map<ll,ll> ANS,mp,mp1;
ll ans = 0,d,pw10[20],digit;
ll solve(int n,ll d) {
	if (n == 1)	{
		if (d == 0) return 10;
		return 0;
	}
	if (n == 0) return d == 0;
	ll x = pw10[n-1] - 1;
	for (int i = -9; i <= 9; i++) {
		if ( abs(d - x*i) < pw10[n-1] ) {
			if ((d - x*i)%10 == 0) {
				ll f = 0;
				if (digit == n) f = mp1[i];
				else f = mp[i];
			return solve(n-2,(d - x*i)/10)*f;
		}
		}
	}
	return 0;
}
main() {
	ll d;
	cin >> d;
	pw10[0] = 1;
	for (int i = 1; i <= 18; i++) 
		pw10[i] = pw10[i-1]*10;
	for (int i = 0; i <= 9; i++)
	for (int j = 0;j  <= 9; j++)
		mp[i-j]++;
	for (int i = 1; i <= 9; i++)
	for (int j = 1; j <= 9; j++) {
		mp1[i-j]++;
	}
	ll ans = 0;
	for (int i = 1; i <= 18; i++) {
		digit = i;
		ans += solve(i,d);
	}
	cout << ans;
}

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

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

int main() {
    ll n;cin>>n;
    vector<double> v;
    double a[n];
    for(ll i=0;i<n;i++){
        cin>>a[i];
        v.push_back(a[i]);
    }
    sort(v.begin(),v.end());
    double ans=v[0];
    for(ll i=1;i<n;i++){
        ans=(ans+v[i])/2;
    }
    cout<<ans<<endl;
    return 0;
}





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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;

typedef long long LL;
typedef long double ldouble;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

const int dx[] = {0, -1, 1, 0};
const int dy[] = {-1, 0, 0, 1};

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

int dp[1 << 12];

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

    int n, m;
    cin >> n >> m;
    vector<P> v(m);
    for(int i = 0; i < m; ++i) {
        int b;
        cin >> v[i].F >> b;
        while(b--) {
            int c;
            cin >> c;
            c--;
            v[i].S += 1 << c;

        }
    }

    for(int i = 1; i < (1 << n); ++i) {
        dp[i] = INF;

    }

    for(int i = 0; i < m; ++i) {
        for(int j = 0; j < (1 << n); ++j) {
            if(dp[j] == INF) {
                continue;

            }
            dp[j | v[i].S] = min(dp[j | v[i].S], dp[j] + v[i].F);

        }
    }
    if(dp[(1 << n) - 1] == INF) cout << -1 << endl;
    else cout << dp[(1 << n) - 1] << endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] d = new int[n];
		for(int i = 0; i < n; i++) {
			d[i] = sc.nextInt();
		}
		Arrays.sort(d);
		int ans = d[n/2] - d[n/2 - 1];
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 50896
#include <stdio.h>
int is_prime(int x){
	int i;
	if(x==2) return 1;
	if(x<2 || x%2==0) return 0;
	
	i=3;
	while(i*i<=x){
		if(x%i==0) return 0;
	i++;
	}
	return 1;
}

int main(){
	int n;
	int i;
	int a[10001];
	int count=0;
	scanf("%d",&n);
	for(i=0;i<n;i++) {
		scanf("%d",&a[i]);
		if(is_prime(a[i])) count++;
	}
	printf("%d\n",count);
return 0;
}

Measured memory_bytes: 628
#include <iostream>

const int MAX_NUM = 1000000000 + 1;

long long merge(int arr[], const int begin, const int mid, const int end)
{
  int arr_left[mid - begin + 1];
  for (int i = 0; i < mid - begin; ++i)
  {
    arr_left[i] = arr[begin + i];
  }
  arr_left[mid - begin] = MAX_NUM;

  int arr_right[end - mid + 1];
  for (int i = 0; i < end - mid; ++i)
  {
    arr_right[i] = arr[mid + i];
  }
  arr_right[end - mid] = MAX_NUM;

  int i_l = 0;
  int i_r = 0;
  long long count = 0;
  for (int i = begin; i < end; ++i)
  {
    if (arr_left[i_l] <= arr_right[i_r])
    {
      arr[i] = arr_left[i_l];
      ++i_l;
    }
    else
    {
      arr[i] = arr_right[i_r];
      ++i_r;
      count += ((mid - begin) - i_l); // Count up the gap
    }
  }

  return count;
}

long long merge_sort(int arr[], const int begin, const int end)
{
  long long count = 0;

  if (begin < end - 1)
  {
    int mid = (begin + end) / 2;
    count += merge_sort(arr, begin, mid);
    count += merge_sort(arr, mid, end);
    count += merge(arr, begin, mid, end);
  }

  return count;
}

int main()
{
  int n;
  std::cin >> n;

  int arr[n];
  for (int i = 0; i < n; ++i)
  {
    std::cin >> arr[i];
  }

  std::cout << merge_sort(arr, 0, n) << std::endl;

  return 0;
}



Measured memory_bytes: 4644
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int>A(n);
	vector<ll>sum(n + 1);

	rep(i, n) {
		scanf("%d", &A[i]);
		A[i] -= (i + 1);
	}
	sort(all(A));
	sum[0] = 0;
	ll Sum = 0;
	rep(i, n) {
		Sum += A[i];
		sum[i + 1] = Sum;
	}
	ll ans = 1e20;
	FOR(ite, n/2, n/2+1) {
		ll tmp = (ll)(n - 2 * ite)*A[ite] * (-1) + (sum[n] - 2 * sum[ite]);
		ans = min(ans, tmp);
	}
	cout << ans << endl;

}


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

using namespace std;

int main() {
  int x, n;
  cin >> x >> n;
  if (n == 0) {
    cin.ignore();
    cin.ignore();
    cout << x;
    return 0;
  }
  vector<int> p(n);
  vector<int> ans;
  vector<pair<int, int>> tmp;
  for (int i = 0; i < n; i++) cin >> p.at(i);
  for (int i = -200; i <= 200; i++) {
    int flag = 0;
    for (int j = 0; j < n; j++) {
      if (i == p.at(j)) flag = 1;
    }
    if (flag == 0) {
      ans.push_back(i);
    }
  }
  int mi = 1000;
  for (int i = 0; i < ans.size(); i++) {
    if (mi > abs(x - ans.at(i))) {
      tmp.push_back(make_pair(abs(x - ans.at(i)), ans.at(i)));
    }
  }
  sort(tmp.begin(), tmp.end());
  cout << tmp.at(0).second;
  return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;
 
#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592
 
const double EPS = 1e-10;
 
using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
    ll n,k; cin >> n >> k;
    vector<ll> ans(n+2);
    repr(i,1,n+2){
        ll m = (ll)i*(i-1)/2;
        ll M = i*n;
        M -= (ll)i*(i-1)/2;
        ans[i] = M-m+1;
    }
    ll ans2 = 0;
    repr(i,k,n+2){
        ans2 += ans[i];
        ans2 %= MOD;
    }
    cout << ans2 << endl;
}


Measured memory_bytes: 4840
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
//#define MOD 1000000007LL
#define int long long
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

bool s(int n){
    int a=n%10;
    while(n){
        if(n%10!=a)return 0;
        n/=10;
    }
    return 1;
}

signed main (){
    vector<string> v;
    int h,w;cin>>h>>w;
    rep(i,0,h){
        string s;cin>>s;
        bool ok=true;
        rep(j,0,s.size()){
            if(s[j]=='#')ok=false;
        }
        if(!ok)v.push_back(s);
    }
    // rep(i,0,v.size()){
    //     rep(j,0,w)cout<<v[i][j];
    //     cout<<endl;
    // }
    vector<int> reject;
    rep(i,0,w){
        bool ok=true;
        rep(j,0,v.size()){
            if(v[j][i]=='#')ok=false;
        }
        if(!ok)reject.push_back(i);
    }
    rep(i,0,v.size()){
        rep(j,0,w){
            if(find(all(reject),j)!=reject.end())cout<<v[i][j];
        }
        cout<<endl;
    }


    
}
/*
1-21-2
*/


Measured memory_bytes: 256
#![allow(unused_imports)]
use itertools::Itertools;
use proconio::{input, marker::*};
use std::cmp::*;
use std::collections::*;
use superslice::*;

fn main() {
    input! {
        n: Chars,
    }

    if n.iter().any(|&c| c == '7') {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2140
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,const P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o<<endl;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>F,R;void setF(int n,int mod){F=R=V<ll>(++n);F[0]=1;FOR(i,1,n)F[i]=F[i-1]*i%mod;R[n-1]=modInv(F[n-1],mod);FORR(i,n-1,1)R[i-1]=R[i]*i%mod;}
//ll comb(int a,int b,int m){return a<b||b<0?0:F[a]*R[b]%m*R[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7; //998244353;
const int N = 10000;
int n;
V<string> u, d;
string t;
main(){
  cin.tie(0);
  cin >> n;
  FOR(_, 0, n){
    string s, _u, _d;
    cin >> s;
    _u = _d = s;
    FOR(i, 0, sz(s)) if(s[i]=='?'){
      _u[i] = 'a';
      _d[i] = 'z';
    }
    u.pb(_u);
    d.pb(_d);
  }
  sort(all(u));
  sort(all(d));
  cin >> t;
  int uu = upper_bound(all(u), t)-u.begin();
  int dd = lower_bound(all(d), t)-d.begin();
  FOR(i, dd, uu+1) cout << i+1 << (i==uu ? '\n' : ' ');
}

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

int main() {
    int N, count = 0;
    cin >> N;

    for (int i = 0; i < N; i++) {
        int l, r;
        cin >> l >> r;

        count += r - l + 1;
    }
    cout << count << endl;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for( int i = 0; i < N; i++ ){
    cin >> A.at(i);
  }
  
  int All = 0; //Ｗ１～ＷＮの総和
  for( int i = 0; i < N; i ++ ){
    All += A.at(i);
  }
  
  vector<int> sum(N);

  for( int i = 0; i < N; i ++ ){
    int count = 0, W;
    for( int j = 0; j <= i; j ++ ){
      count += A.at(j);
    }
    if( All - count <= count ){
      W = count * 2 - All;
    }
    else if( All - count > count ){
      W = All - count * 2;
    }
    sum.at(i) = W;
  }
  
  sort(sum.begin(), sum.end());
  
  cout << sum.at(0) << endl;
} 

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

using namespace std;

int main(){
    string s;
    cin >> s;
    string ans = "No";
    bool a[3] = { false,false,false};
    for(int i=0;i<3;i++){
        if(s[i] == 'a'){
            a[0] = true;
        }
        if(s[i] == 'b'){
            a[1] = true;
        }
        if(s[i] == 'c'){
            a[2] = true;
        }
    }
    if(a[0] == true && a[1] == true && a[2] == true){
        ans = "Yes";
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
import fractions
input = lambda: sys.stdin.readline().rstrip()

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

def main():
    a, b = map(int, input().split())
    print(lcm(a, b))

if __name__ == '__main__':
    main()

Measured memory_bytes: 5692
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main() {
  int R[MAX], n;

  cin >> n;
  for (int i = 0; i < n; i++) cin >> R[i];

  // Initialize maximum profit and minimum value
  int maxp = -2000000000;
  int minv = R[0];

  // Update maximum profit and minimum value
  for (int i = 1; i < n; i++){
    maxp = max(maxp, R[i]-minv);
    minv = min(minv, R[i]);
  }

  cout << maxp << endl;
  return 0;
}



Measured memory_bytes: 3852
#include<bits/stdc++.h>
// iteration and input/output stream
#define rep(i,a,b) for(int i = int(a);i<=int(b);i++)
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define printarr(x) rep(i,0,x.size()-1) cout<<x[i]<<" "; cout<<endl;
#define all(v) v.begin(),v.end()
 
#define si(x) int x; scanf("%d", &x)
#define sll(x) ll x; scanf("%lld", &x)
#define pi(x) printf("%d", x)
#define pll(x) printf("%lld", x)
#define nl printf("\n")
#define tr(cont,it) \
for(decltype(cont.begin()) it = cont.begin(); it!= cont.end() ; it++)
 
#define endl "\n"
#define tc() int t; cin >> t ; while (t--)
//STL shortcuts
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define F first
#define S second
#define MP make_pair
 
// Error detection
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
 
using namespace std;
 
typedef long long int ll; // 64 bit integer
typedef unsigned long long int  ull; // 64 bit unsigned integer
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<int,ll> pill;
 
inline void smax(int &x , int y) { x = max(x , y) ; }
inline void smin(int &x , int y) { x = min(x , y) ; }
 
#define MOD 1000000007
#define inf 4000000000000000000LL
#define SYNC std::ios::sync_with_stdio(false);  cin.tie(NULL);
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    freopen("err.txt","w",stderr);
    #endif
    SYNC
    
    int a;
    cin>>a;
    cout<<a*(1+a+a*a)<<"\n";
    return 0;
}

Measured memory_bytes: 3608
c = [list(map(int, input().split())) for _ in range(3)]

a = [0] * 3
b = [0] * 3
ans = "Yes"
for a1 in range(101):
    a[0] = a1
    b[0] = c[0][0] - a1
    b[1] = c[0][1] - a1
    b[2] = c[0][2] - a1
    a[1] = c[1][0] - b[0]
    a[2] = c[2][0] - b[0]
    for i in range(3):
        for j in range(3):
            if a[i] + b[j] != c[i][j]:
                ans = "No"

print(ans)


Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

int main() {
  int N;
  cin >> N;
  print(N*(N+1)/2);
}


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

int main() {
    int N, M;
    cin >> N >> M;
    int k[M], s[M][N], p[M];
    for (int i = 0; i < M; i++) {
        cin >> k[i];
        for (int j = 0; j < k[i]; j++) {
            cin >> s[i][j];
        }
    }
    for (int i = 0; i < M; i++) {
        cin >> p[i];
    }
    int ans = 0;
    for (int bit = 0; bit < (1 << N); ++bit) {
        bool switch_on[N];
        for (int i = 0; i < N; ++i) {
            if (bit & (1 << i)) {
                switch_on[i] = true;
            } else {
                switch_on[i] = false;
            }
        }

        bool is_all_lights_on = true;
        for (int i = 0; i < M; i++) {
            int total = 0;
            for (int j = 0; j < k[i]; j++) {
                if (switch_on[s[i][j] - 1]) {
                    total++;
                }
            }
            if (total % 2 != p[i]) {
                is_all_lights_on = false;
            }
        }
        if (is_all_lights_on) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
using namespace std; 

//しゃくとり方でとく//
int main(void){
 int N,K;
 string S;

 vector<int> A;

 cin>>N>>K;
 cin>>S;

 int cnt=0;
 int now=0;

 for(int i=0; i<S.length();i++){
  if(S[i]==(char)('1'-now)){
   cnt++;
  }
  else{
   now=1-now;
   A.push_back(cnt);
   cnt=1;
  }
 }
 A.push_back(cnt);          
 
 if(A.size()%2==0)A.push_back(0);
 
 int sum,left,right,ans,nextleft,nextright;
 sum=0;
 left=0;
 right=0;
 nextleft=0;
 nextright=0;
 ans=0;
 
 for(int i=0; i<A.size();i+=2){
  nextleft=i;
  nextright=min(i+2*K+1,(int)A.size());

  while(nextleft>left){
   sum-=A[left];
   left++;
  }
  while(nextright>right){
   sum+=A[right];
   right++;
  }
  ans=max(sum,ans);
 }

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

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

#if __has_include(<local.h>)
#include <local.h>
#endif

using namespace std;

typedef long long int LL;
typedef long long int LLint;

//Faster Program
#define endl "\n"

//Faster Coding
#define ED return
#define GET(a) int a;cin >> a
#define DGET(a) double a;cin >> a
#define SGET(a) string a;cin >> a
#define CGET(a) char a;cin >> a
#define PRINT(a) cout << a << "\n"
#define ANS(a,b) int a;cin >> a;cout << b << "\n"
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define SORT(vec) sort(vec.begin(),vec.end())
#define REV(vec) reverse(vec.begin(),vec.end())
#define ALL(x) (x).begin(),(x).end()

//As Function
#define UP(a,b) ((a+(b-1))/b)
#define IPOW(x,y) LL(pow(x,y))

//Debug
#ifdef LOCAL_H
#define TEST cout << "OK\n"
#define DEBUG(a) a
#else
#define TEST
#define DEBUG(a)
#endif

#ifdef LOCAL_H
[[maybe_unused]]
#endif
const double PI = M_PI;
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const int INF = int(999999999);
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const long long MOD = int(1000000007);

//Settings
#ifdef LOCAL_H
const bool DO_BENCHMARK = true;
#endif
const int DOUBLE_ACCURACY = 15;

#ifndef LOCAL_H
    const bool DO_BENCHMARK = false;
#endif

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(DOUBLE_ACCURACY);
    void solve();
    if(DO_BENCHMARK){
        clock_t clock_start = clock();
        solve();
        clock_t clock_end = clock();
        const double time = static_cast<double>(clock_end-clock_start)/CLOCKS_PER_SEC*1000.0;
        cout << "\n" << time << "[ms]\n";
    }
    else solve();
}

/************************************************************************************************************************************************/

void solve(){
    LL H;
    cin >> H;
    LL ans = 0;
    for(int i = 0;H != 0;i++){
        H /= 2;
        ans += pow(2,i);
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int h = sc.nextInt();
    int m = sc.nextInt();
    double m_angle = 6.0 * m;
    double h_angle = (30.0 * h) + (0.5 * m);
    double mh_angle = Math.abs(h_angle - m_angle);
    //余弦定理
    double cc = (a * a) + (b * b) - 2 * a * b * Math.cos(Math.toRadians(mh_angle));
    System.out.println(Math.sqrt(cc));
  }
}

Measured memory_bytes: 36032
#include <stdio.h>
#include <string.h>
#include <deque>
#include <iostream>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#define lp(i, b) for(int i = 0; i < b; ++i) 
using namespace std;
bool is_prime(int k)
{
	if (k == 1) return false;
	if (k % 2 == 0) return k == 2;
	for (int i = 3; i * i <= k; i += 2)
	{
		if (k % i == 0) return false;
	}
	return true;
}
int main()
{
	vector<int> prime2017(pow(10, 5), 0);
	int n = 0;
	function<bool(int)> judge = [&](int x)
	{
		if (is_prime(x) && is_prime((x + 1) / 2))
		{
			return true;
		}
		return false;
	};
	lp(i, pow(10, 5))
	{
		if (!judge(i)) prime2017[i] = n;
		else
		{
			prime2017[i] = ++n;
		}
	}
	int m;
	int l, r;
	cin >> m;
	lp(i, m)
	{
		cin >> l >> r;
		cout << prime2017[r] - prime2017[l - 1] << endl;
	}
}

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int main(){
int x,y,z;
cin >> x >> y >> z;
if(-y+z<=0) {
    cout << "delicious" << endl;
}else if(-y+z<=x){
    cout << "safe" << endl;
}else{
    cout << "dangerous" << endl;
}
return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int i;
  int k,x;

  scanf("%d %d", &k, &x);

  if(k==1){
    printf("%d\n", x);
  }else{
    for(i=x-k+1; i<=x+k-1; i++){
      if(i!=x+k-1) printf("%d ", i);
      else printf("%d\n", i);
    }
  }

  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int h,w;
	cin >> h >> w;
	int srow,scol,erow,ecol;
	cin >> srow >> scol;
	cin >> erow >> ecol;
	--srow,--scol,--erow,--ecol;
	string grid[h];
	for(int i = 0; i < h;++i){
		cin >> grid[i];
	}
//	bool ok = false;
	deque<pair<int,int> > dq;
	int dist[h][w];
	for(int i = 0; i < h;++i){
		for(int j = 0; j < w;++j){
			dist[i][j] = 1e7;
		}
	}
	dist[srow][scol] = 0;
	dq.push_back({srow,scol});
	while(!dq.empty()){
		pair<int,int> cur_node = dq.front();
		dq.pop_front();
		int row = cur_node.first;
		int col = cur_node.second;
//		if(row == erow && col == ecol){
//			ok = true;
//			break;
//		}
		for(int dx = -2;dx <= 2;++dx){
			for(int dy = -2;dy <= 2;++dy){
				int nrow = row + dx;
				int ncol = col + dy;
				if(nrow == row && ncol == col)
					continue;
				if(nrow < 0 || ncol < 0 || nrow >= h || ncol >= w)
					continue;
				int w = 1;
				if(grid[nrow][ncol] == '#')
					continue;
				if((abs(nrow-row) == 1 && abs(ncol-col) == 0) || (abs(ncol-col) == 1 && abs(nrow-row) == 0))
					w = 0;
				if(dist[nrow][ncol] > dist[row][col] + w){
					dist[nrow][ncol] = dist[row][col] + w;
					if(w == 0)
						dq.push_front({nrow,ncol});
					else
						dq.push_back({nrow,ncol});
				}
			}
		}
	}
//	if(!ok)
//		dist[erow][ecol] = -1;
//	cout << dist[erow][ecol] << "\n";
    cout<<(dist[erow][ecol] == 1e7?-1: dist[erow][ecol]);
    return 0;
}


Measured memory_bytes: 8704
fun main(arr:Array<String>) {
    val itemCount = readLine()!!.toInt()
    val ans = readLine()!!.split(" ").map { getDiv2Count(it.toLong()) }.sum()
    println(ans)
}

fun getDiv2Count(num:Long):Long {
    var ans = 0L
    var tmp = num
    while (tmp % 2 == 0L) {
        tmp /= 2
        ans++
    }
    return ans
}

Measured memory_bytes: 40264
#define _GIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double EPS = 1e-10;


int main(void) {
  string S;
  cin >> S;

  // BWの並びをWBに変える操作は何回できるか

  // Bから見て右にある、次のBまでのWの個数分、操作できる
  // 入れ替えるとWは左に移るため、操作できる回数も変わる
  // 一番右端から確認する

  // 操作がすべて反転
  reverse(S.begin(), S.end());

  ll ans = 0;
  ll count = 0; // Wの個数
  for (int i = 0; i < S.length(); ++i) {
    if (S[i] == 'W') {
      count++;
    } else {
      ans += count;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3688
using System;
using System.Collections.Generic;//list用
using System.Text;//StringBuilder用
using System.Collections;//ハッシュテーブル用
using System.Linq;

class Program
{
    //Hashtable ht = new Hashtable();
    static List<int> s = new List<int>();
      static List<int> a = new List<int>();
      static List<int> b = new List<int>();
      static List<int> c = new List<int>();
    static decimal result;
    static int N,K;
    //StringBuilder strresult= new StringBuilder("");//Append(str ○○)関数で文字を追加していく


    static void Main()
    {
        //Modular mo = new Modular(0);//素数で割った余りを出せで使う。()内が初期値。★使い方：Modular型で宣言すると、その時点でのその素数で割った余りを保持する変数になる（powべき乗、Fac累乗、nCr組み合わせも関数として存在）
        //Node<> no = new Node<>();//UnionFind★Find関数で根っこの値を返す（根っこの値が一緒なら同グループ）、Unite関数で二つの木をくっつける
        //Permutation<> pe = new Permutation<>();//配列＆リストを並べ替えた場合の全ケースを出力★All関数でリスト形式で返す。
        //Treap<> tr = new Treap<>();//平衡二分木★Insert()関数で挿入、FindIndex()関数で該当する大きさの物が入るべき配列番号を返す。
        //PriorityQueue<int,int> pr = new PriorityQueue<int,int>();//優先度付キュー★Add(key,value)で格納、Dequeue()で取りだし。keyが小さいものから取り出す。
Read1();
      for(int i=1;i<10;i++){
        for(int j=1;j<10;j++){
if(N==i*j){Console.WriteLine("Yes");return;}
        }
      }
        Console.WriteLine("No");

    }
  
    static void Read1()//1項
    {
        string tmp = Console.ReadLine();
        N = int.Parse(tmp);
    }

    static void Read2()//複数項（項目数Ｎ）
    {
        string[] tmp = Console.ReadLine().Split(' ');
        for (int i = 0; i < N; i++) { s.Add(int.Parse(tmp[i])); }
    }
    static void Read3()//1行複数項
    {
        string[] tmp = Console.ReadLine().Split(' ');
        for (int i = 0; i < tmp.Length; i++) { s.Add(int.Parse(tmp[i])); }
    }
    static void Read4()//NK１行
    {
        string[] tmp = Console.ReadLine().Split(' ');
        N = int.Parse(tmp[0]);
        K = int.Parse(tmp[1]);
    }
    static void Read5()//N行K項
    {
      for(int i=0;i<K;i++)
      {
        string[] tmp = Console.ReadLine().Split(' ');
        a.Add(int.Parse(tmp[0]));
        b.Add(int.Parse(tmp[1]));
        c.Add(0);
        string[] tmp2 = Console.ReadLine().Split(' ');
        for(int j=0;j<b[i];j++){c[i]+=(int)Math.Pow(2,int.Parse(tmp2[j])-1);}
      }
    }
}


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

using namespace std;

int a[2001][2001];
int s[2001][2001];
int c[2001][2001];
int b[2001][2001];
int pref1[2001][2001];
int pref2[2001][2001];

int main () {
	int n, m, q;
	cin >> n >> m >> q;
	for (int i = 1;i <= n;i ++) {
		for (int j = 1;j <= m;j ++) {
			char x;
			cin >> x;
			a[i][j] = x - '0';
			s[i][j] = s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1] + a[i][j];
			b[i][j] = b[i - 1][j];
			if (a[i][j] && a[i - 1][j]) b[i][j] ++;
			c[i][j] = c[i][j - 1];
			if (a[i][j] && a[i][j - 1]) c[i][j] ++;
		}
	}
	for (int i = 1;i <= n;i ++) {
		for (int j = 1;j <= m;j ++) {
			pref1[i][j] = pref1[i][j - 1] + b[i][j];
			pref2[i][j] = pref2[i - 1][j] + c[i][j];
		}
	}         
	while (q --) {
		int x1, x2, y1, y2;
		cin >> x1 >> y1  >> x2 >> y2;
		int ans = s[x2][y2] - s[x2][y1 - 1] - s[x1 - 1][y2] + s[x1 - 1][y1 - 1];
		int cur1 = pref1[x2][y2] - pref1[x2][y1 - 1] - (pref1[x1][y2] - pref1[x1][y1 - 1]);
		int cur2 = pref2[x2][y2] - pref2[x1 - 1][y2] - (pref2[x2][y1] - pref2[x1 - 1][y1]);
		cout << ans - cur1 - cur2 << endl;
	}
	return 0;
}

Measured memory_bytes: 95616
str = Array.new
gets.chomp.chars {|c| str.push(c)}


mid = str.size / 2
if str.size.even? then
    i = 0
    while(str[mid - 1 - i] == str[mid + i])
        i += 1
    end
    puts mid + i
    exit
else
    i = 0
    while(str[mid - i] == str[mid] && str[mid] == str[mid + i])
        i += 1
    end
    puts mid + i
    exit
end

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

int main() {
    int N;
    cin >> N;
    vector<char> stone(N);
    int W,R;
    W=0;
    R=0;
    for(int i=0; i<N; i++) {
        cin >> stone.at(i);
        if (stone.at(i)=='R') R++;
    }
    int ans=R;
    for(int i=0; i<N; i++){
        if(stone.at(i)=='R'){
            R=R-1;
            ans=min(ans,max(R,W));
        }
        else{
            W++;
            ans=min(ans,max(R,W));
        }
    }
    cout << ans <<endl;

  }

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,d,i,j;
	cin>>a>>b>>c>>d;
	for(i=1;i<=a;i++)
	{
		for(j=1;j<=b;j++)
		{
			putchar('1'-((i<=d)^(j<=c)));
		}
		puts("");
	}
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

long long int INF = 1e18;
long long int mod = 1000000007;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(15)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll abc,ll bed){
    //abcのbed乗を計算する
    if(bed==0){return 1;}
    else{
        ll ced = rui(abc,bed/2);
        ced *= ced;
        ced %= mod;
        if(bed%2==1){ced*=abc; ced%=mod;}
        return ced;
    }
}
ll gcd(ll number1,ll number2){
	if(number1 > number2){
		swap(number1,number2);
	}
	if(number1 == 0 || number1 == number2){
		return number2;
	}else{
		return gcd(number2 % number1,number1);
	}
}

ll i,j,k,ii,jj,r,l;
ll n,m,num,sum,ans;
ll a,b,c,d,e,g,h,w;
ll x[500005],y[500005],z[1000005];
bool flag,dame;
char s[1000005];

int main(){
	cin >> n >> a >> b;
	for(i=0;i<n;i++){
		cin >> x[i];
	}
	if(n == 1){
		p(abs(b - x[0]));
	}else{
		ans = max(abs(x[n-1] - x[n-2]),abs(b-x[n-1]));
		p(ans);
	}
	
	return 0;

}

Measured memory_bytes: 25984
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod=1000000007;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m,c;cin >> n >> m >> c;
	vector<vector<int>> a(n,vector<int>(m));
	vector<int> b(m);
	rep(i,m) cin >> b.at(i);
	rep(i,n) rep(j,m) cin >> a[i][j];
	int ans=0;
	rep(i,n){
		int sum=c;
		rep(j,m) sum+=a[i][j]*b[j];
		if(sum>0) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#define N 2105
#define M 1005
#include <cstdlib>
#define fi(a, b, c) for(int a = (b); a < (c); a++)
#define FI(a, b, c) for(int a = (b); a <= (c); a++)
using namespace std;

int n, m, d, s[N][N], cnt;
char *c = "BGYR";
bool vis[N][N];

void fill(int y, int x, int col){
	int l = d / 2 - 1;
	
	if(y + l < 0 || y - l >= n || x >= m || x + d - 1 < 0) return;
	
	FI(i, -l, l){
		int ny = y + i;
		FI(j, abs(i), d - 1 - abs(i)){
			int nx = x + j;
			if(ny < 0 || nx < 0 || ny >= n || nx >= m) continue;
			s[ny][nx] = col;
		}
	}
}

void dfs(int y, int x){
	if(y < -d - d || x < -d - d || y > n + d || x > m + d) return;
	if(vis[y + M][x + M]) return;
	vis[y + M][x + M] = 1;
	
	fill(y, x + d, 1);
	fill(y + d / 2, x + d / 2, 2);
	fill(y + d / 2, x - d / 2, 3);
	
	dfs(y - 1, x - d - d + 1);
	dfs(y + 1, x + d + d - 1);
	dfs(y + d + 1, x + d - 1);
	dfs(y - d - 1, x - d + 1);
}


int main(){
	scanf("%d %d %d", &n, &m, &d);
	
	if(d % 2){
		fi(i, 0, n) fi(j, 0, m){
			s[i][j] = (i + j) % 2;
		}
	}else{
		dfs(0, 0);
	}
	
	fi(i, 0, n) fi(j, 0, m){
		FI(k, 0, d){
			int sgn[2] = {-1, 1};
			
			fi(l, 0, 2){
				int ny = i + sgn[l] * (d - k);
				int nx = j + k;
				if(ny < 0 || ny >= n || nx >= m) continue;
				
				if(s[ny][nx] == s[i][j]){
					printf("fail %d %d %d %d\n", i, j, ny, nx);
				}
			}
		}
	}
	
	fi(i, 0, n){
		fi(j, 0, m) printf("%c", c[s[i][j]]);
		puts("");
	}
	
}

/*
??2??
?222
222221
3222111
33211111
3330111
330001
300000
--000
---0

1003311
0000111
3002211
3322223
3112233

33322
33222233
011223333
1111003311
 110000111100
  330022110000
 3333222233
  3311223333
   111100
    110000
	  00
	 0000  
  33000000
 33330000
33333300
    
int l = d / 2 - 1;

FI(i, -l, l){
	int ny = y + i;
	FI(j, abs(i), d - 1 - abs(i))
		int nx = x + j;
		s[ny][nx] = col;
	}
}
    
  133333
 111333
111113
 111
  1
022201333
002311130
0133312000
111302220
 1200023
 22201333
  2 1113
*/

Measured memory_bytes: 9216
#include<bits/stdc++.h>
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
#define Reg register
#define RI Reg int
#define Con const
#define CI Con int&
#define I inline
#define W while
#define N 18
#define X 998244353
#define I2 499122177LL
using namespace std;
int n,P,p[1<<N],_[1<<N];
I int QP(RI x,RI y) {RI t=1;W(y) y&1&&(t=1LL*t*x%X),x=1LL*x*x%X,y>>=1;return t;}
I void FWT(int *s,CI op)
{
	for(RI i=1,j,k,x,y;i^P;i<<=1) for(j=0;j^P;j+=i<<1) for(k=0;k^i;++k) x=s[j+k],y=s[i+j+k],
		s[j+k]=(x+y)%X,s[i+j+k]=(x-y+X)%X,!~op&&(s[j+k]=I2*s[j+k]%X,s[i+j+k]=I2*s[i+j+k]%X);
}
int main()
{
	RI i,s=0;for(scanf("%d",&n),P=1<<n,i=0;i^P;++i) scanf("%d",p+i),s+=p[i];
	for(s=QP(s,X-2),i=0;i^P;++i) p[i]=1LL*p[i]*s%X;p[0]?--p[0]:(p[0]=X-1);
	for(_[0]=P-1,i=1;i^P;++i) _[i]=X-1;
	FWT(p,1),FWT(_,1);for(RI i=0;i^P;++i) _[i]=1LL*_[i]*QP(p[i],X-2)%X;FWT(_,-1);
	for(i=0;i^P;++i) printf("%d%c",(_[i]-_[0]+X)%X," \n"[i==P-1]);return 0;
}

Measured memory_bytes: 5764
def main():
    bingo=[list(map(int,input().split())) for i in range(3)]
    n=int(input())
    b={int(input()) for i in range(n)}
    
    X=[[0]*3 for _ in range(3)]
    for i in range(3):
        for j in range(3):
            if bingo[i][j] in b:
                X[i][j]=1
    
    flag=False
    for i in range(3):
        if (X[i][0]&X[i][1]&X[i][2])==1:
            flag=True
            print('Yes')
            exit()
        if (X[0][i]&X[1][i]&X[2][i])==1:
            flag=True
            print('Yes')
            exit()
    if (X[0][0]&X[1][1]&X[2][2])==1:
        flag=True
        print('Yes')
        exit()
    
    if (X[0][2]&X[1][1]&X[2][0])==1:
        flag=True
        print('Yes')
        exit()
    print('No')

if __name__=='__main__':
    main()

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>

typedef struct{
  int value;
  char pattern;
}Card;

void BubbleSort(Card *, int);
void SelectionSort(Card *, int);

int main(void){

  int n,i,flagb=1,flags=1;
  Card cb[36],cs[36];
  char tmp;

  scanf("%d%c",&n,&tmp);

  for(i = 0 ; i < n ; i++)
    scanf("%c%d%c",&cb[i].pattern,&cb[i].value,&tmp);

  
  for(i = 0 ; i < n ; i++){
    cs[i] = cb[i];
  }

  SelectionSort(cs, n);
  BubbleSort(cb, n);

  for(i = 0 ; i < n ; i++){
    printf("%c%d",cb[i].pattern,cb[i].value);
    if(i!=n-1) printf(" ");
    if(cb[i].pattern != cb[i].pattern || cb[i].value != cb[i].value) flagb=0;

  }

  printf("\n");

  if(flagb==1) printf("Stable\n");
  else printf("Not stable\n");

 for(i = 0 ; i < n ; i++){
    printf("%c%d",cs[i].pattern,cs[i].value);
    if(i!=n-1) printf(" ");
    if(cs[i].pattern != cb[i].pattern || cs[i].value != cb[i].value) flags=0;
  }

  printf("\n");

  if(flags==1) printf("Stable\n");
  else printf("Not stable\n");

  return 0;
}

void BubbleSort(Card *c, int n){

  int i,j;
  Card tmp;

  for(i = 0 ; i <= n-1 ; i++){
    for(j = n-1 ; j > i ; j--){
      if(c[j].value < c[j-1].value){
	tmp = c[j];
	c[j] = c[j-1];
	c[j-1] = tmp;
      }
    }
  }

  return;

}


void SelectionSort(Card *c, int n){

  int i,minj,j;
  Card tmp;

  for(i = 0 ; i <= n-1 ; i++){
    minj = i;
    for(j = i ; j <= n-1 ; j++){
      if(c[j].value < c[minj].value){ 
	minj = j;
      }
    }
    tmp = c[i];
    c[i] = c[minj];
    c[minj] = tmp;
    
  }

  return;

}

Measured memory_bytes: 612
N = int(input())
gift = []

for i in range(N):
    gift.append((input().split()))

sum = 0
for i in range(N):
    if gift[i][1] == "JPY":
        sum += float(gift[i][0])
    else:
        sum += float(gift[i][0]) * 380000

print(sum)


Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<list>
#include<cmath>
using namespace std;
using ll = long long;
int main() {
	int N;
	cin >> N;
	string str = "";
	while (N != 0) {
		int r = N % 2;
		if (r < 0)r += 2;
		N = (N - r) / (-2);
		str += (char)('0' + r);
	}
	reverse(str.begin(), str.end());
	if (str == "")str = "0";
	cout << str << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int A, B, C, D, ans = 0;
    cin >> A;
    cin >> B;
    cin >> C;
    cin >> D;
    if (A >= B) {
        ans += B;
    } else {
        ans += A;
    }
    if (C >= D) {
        ans += D;
    } else {
        ans += C;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int main(int argc, char const *argv[]) {

        long long int A, B, D1, D2;
        unsigned long long V, W, T;
        cin >> A >> V >> B >> W >> T;
        D1 = abs(A-B);
        D2 = (V-W)*T;
        puts(D1<=D2 ? "YES" : "NO");
        return 0;
}


Measured memory_bytes: 3640
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod =  998244353

def power(x, n, p):
	ans = 1
	while n:
		if n%2:
			ans = ans*x%p
		x = x*x%p
		n >>= 1
	return ans

lim = 2*10**5
fact = [1]*(lim+1)
for n in range(1, lim+1):
	fact[n] = n*fact[n-1]%mod

fact_inv = [1]*(lim+1)
fact_inv[lim] = power(fact[lim], mod-2, mod)
for n in range(lim, 0, -1):
	fact_inv[n-1] = n*fact_inv[n]%mod

def C(n, r):
	return (fact[n]*fact_inv[r]%mod)*fact_inv[n-r]%mod


N, M, K = MAP()

ans = 0
for i in range(K+1):
	a = M*power(M-1, N-1-i, mod)%mod*C(N-1, i)%mod
	ans = (ans+a)%mod

print(ans)


Measured memory_bytes: 25588
#include <stdio.h>
int main(void){
    int n;
    int a[1000];
    int i;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        if(a[i]%2 == 0){
            if(a[i]%3 != 0 && a[i]%5 != 0){
                printf("DENIED");
                return 0;
            }
        }
    }
    printf("APPROVED");
    return 0;
}

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

int main()
{
    int N, D, x, y;
    int count = 0;
    cin >> N;
    cin >> D;
    for (int i = 0; i < N; i++)
    {
        cin >> x;
        cin >> y;
        if ((pow(x, 2.) + pow(y, 2.)) <= pow(D, 2.))
        {
            count += 1;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3636
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N int
	fmt.Scan(&N)
	
	slice := make([]int,N)
	
	var sumA,sumB = 0,0
	for i := 0; i < len(slice); i++ {
		fmt.Scan(&slice[i])
	}
	
	sort.Sort(sort.Reverse(sort.IntSlice(slice)))
	
	for i := 0; i < len(slice); i++ {
		if i % 2 == 0 {
			sumA += slice[i]
		} else {
			sumB += slice[i]
		}
	}
	fmt.Println(sumA - sumB)
}

Measured memory_bytes: 512
#include <stdio.h>

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

int main(void)
{
	int a, b;
	int gcd, lcm;
	
	while (scanf("%d %d", &a, &b) != EOF){
		if (a < b){
			int tmp = a;
			a = b;
			b = tmp;
		}
		gcd = GCD(a, b);
		lcm = LCM(a, b, gcd);
		printf("%d %d\n", gcd, lcm);
	}
	
	return 0;
}

Measured memory_bytes: 596
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
long long A[110000];
long long B[110000];
long long C[110000];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%lld",A+i);
	for(int i=0;i<a;i++)scanf("%lld",B+i);
	long long req=0;

	int ret=0;
	for(int i=0;i<a;i++){
		req+=max(0LL,B[i]-A[i]);
		C[i]=-max(0LL,A[i]-B[i]);
		if(A[i]<B[i])ret++;
	}
	std::sort(C,C+a);
	for(int i=0;i<a;i++){
		if(req<=0)break;
		req+=C[i];ret++;
	}
	if(req>0)ret=-1;
	printf("%d\n",ret);

}

Measured memory_bytes: 2560