akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Scanner;
public class Main {
    static Scanner in = new Scanner(System.in);
    public static void main(String[] args) {
        int[] c={0,0,0,0,0,0,0,0,0};
        for(int i=in.nextInt(); i>0;c[Math.min(in.nextInt()/400, 8)]++,i--);
        int s=(int)Arrays.stream(Arrays.copyOf(c, 8)).filter(a -> a > 0).count();
        System.out.println((s>0?s:1)+" "+(s+c[8]));
    }
}

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

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

#define PI 3.14159265358979323846264338327950

int main(){

  int a,b,h,m;
  scanf("%d%d%d%d",&a, &b, &h, &m);

/*  double angle = abs( ((double)h + (double)m/60.0) * 30.0 - (double)m * 6.0 );

  double rad = (angle /180.0)* PI;*/

  double rad = (( ((double)h + (double)m/60.0) * 30.0 - (double)m * 6.0 ) / 180.0) * M_PI;

  //printf("%.10f ",h);
  double ans = sqrt((double)a*a + (double)b*b -(double)2*a*b*cos(rad));
  printf("%.11f",ans);

  return 0;
}


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

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

    ll a = 0, b = 0, c = 0;
    ll ans = 0;
    if(k % 2 == 1){
        // kが奇数の時、k以上n以下でkの倍数の個数を探し、個数を数える
        a = n / k;
        ans = pow(a, 3);
    }else{
        // kが偶数の時、n以下でkで割ってk/2余る数を探し、個数を数える
        for(ll i = k / 2; i <= n; i += k / 2){
            if(i%k == 0){
                b++;
            }else{
                c++;
            }
        }
        ans = pow(b, 3) + pow(c, 3);
    }

    cout << ans << endl;

    return 0;

}



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

int main()
{
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    long long ans = LONG_LONG_MIN;
    if (a <= 0 && b >= 0)
    {
        ans = max(ans, 0ll);
    }
    if (c <= 0 && d >= 0)
    {
        ans = max(ans, 0ll);
    }
    ans = max(ans, a * c);
    ans = max(ans, a * d);
    ans = max(ans, b * c);
    ans = max(ans, b * d);
    cout << ans << endl;
}


Measured memory_bytes: 3628
#include <cstdio>
#include <algorithm>
#define INF 2147483647
#define max_n 1000000
using namespace std;
int a[max_n+1];
long long psm[max_n+2],nsm[max_n+2];
long long calc(long long a,long long b,long long c,long long d){
	a>b&&(swap(a,b),1),c>d&&(swap(c,d),1);
	return max(b,d)-min(a,c);
}
template<typename T>void minify(T&x,const T&y){
	y<x&&(x=y);
}
int main(){
	int n,i;
	scanf("%d",&n),psm[0]=0;
	for(int i=0; ++i<=n; psm[i]=psm[i-1]+a[i])
		scanf("%d",a+i);
	nsm[n+1]=0;
	for(int i=n+1; --i; nsm[i]=nsm[i+1]+a[i]);
	long long x,y,ans=INF;
	for(int j=0,i=0,k=0; ++j<=n; minify(ans,calc(psm[i],psm[j]-psm[i],psm[k]-psm[j],psm[n]-psm[k]))){
		for(y=(x=psm[j])>>1; psm[++i]<=y; );
		y-psm[i-1]<psm[i]-y&&(--i);
		for(y=(x=nsm[j+1])>>1; nsm[++k+1]>y; );
		nsm[k]-y<=y-nsm[k+1]&&(--k);
//		printf("*(%d,%d,%d)\n",i,j,k);
	}
	printf("%lld\n",ans);
	return 0;
}

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

using namespace std;

#ifndef aa
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef long double ld;
#define double long double
#define pii pair<int,int>
#define pdd pair<double,double>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define frev(a,b,c) for(int a=c; a>=b; a--)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
#define deb(x) cout << x << endl
#define done(x) {cout << x << endl;return;}
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
//const int mod = 998244353;
const int mod = 1e9 + 7;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vpii;
typedef map<int, int> mii;
typedef set<int> si;
typedef set<pair<int,int>> spii;
typedef queue<int> qi;


const int N = 2e5+5;

void solve() {

  char c;
  cin>>c;
  if(c>='A'&&c<='Z')
   cout<<'A';
  else
   cout<<'a';
  
}


signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    //srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    cout << fixed << setprecision(15);
    int t = 1;
   //cin >> t;

    while (t--)
        solve();
#ifdef aa
    cout << endl << endl << endl << endl << "Time elapsed: " << (double)(clock() - clk) / CLOCKS_PER_SEC << endl;
#endif
    return 0;
}







int powm(int a, int b) {
    int res = 1;
    while (b) {
        if (b & 1)
            res = (res*a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return res;
}

int divide(int a, int b) {
    return (a % mod) * powm(b, mod - 2) % mod;
}

int norm(int a) {
    while (a >= mod) a -= mod;
    while (a < 0) a += mod;
    return a;
}


int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}


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

int main(){

	int a[100];
	int i;
	int n;
	cin >> n;

	for (i = 0; i < n; i++){
		cin >> a[n - i - 1];
	}
	for (i = 0; i < n; i++){
		cout << a[i];
		if (i != n - 1){
			cout << " ";

		}
		else{
			cout<<endl;
		}
	}


}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1000000007;
string alp="abcdefghijklmnopqrstuvwxyz";

int main(){
    int H,W,K;
    cin >> H >> W >> K;
    vector<vector<vector<ll>>> pos1(W,vector<vector<ll>>(W,vector<ll>(W,0)));
    vector<vector<vector<ll>>> pos2(W,vector<vector<ll>>(W,vector<ll>(W,0)));
    rep(i,W){
        rep(j,W){
            pos2[i][j][0]=1;
            if (i==0&&j==0){
                pos1[i][j][0]=1;
                pos2[i][j][0]=0;
            }
            rep(k,W-1){
                if (k+1==i||k+1==j){
                    if (i==j){
                        pos1[i][j][k+1]=0;
                        pos2[i][j][k+1]=(pos1[i][j][k]+pos2[i][j][k])%MOD;
                        if (k+2<=W-1){
                            pos1[i][j][k+2]=0;
                            pos2[i][j][k+2]=pos2[i][j][k+1];
                            k++;
                        }
                    }
                    else if ((i==0&&j==1)||(i==1&&j==0)){
                        pos1[i][j][k+1]=1;
                        pos2[i][j][k+1]=0;
                    }
                    else {
                        pos1[i][j][k+1]=0;
                        pos2[i][j][k+1]=(pos1[i][j][k]+pos2[i][j][k])%MOD;
                        if (k+2<=W-1){
                            pos1[i][j][k+2]=pos2[i][j][k+1];
                            pos2[i][j][k+2]=0;
                            k++;
                        }
                    }
                }
                else {
                    pos1[i][j][k+1]=pos2[i][j][k];
                    pos2[i][j][k+1]=(pos1[i][j][k]+pos2[i][j][k])%MOD;
                }
            }
        }
    }
    vector<vector<ll>> dp(H+1,vector<ll>(8,0));
    dp[0][0]=1;
    rep(i,H){
        rep(j,W){
            dp[i+1][j]+=dp[i][j]*(pos1[j][j][W-1]+pos2[j][j][W-1]);
            if (j>0){
                dp[i+1][j]+=dp[i][j-1]*(pos1[j-1][j][W-1]+pos2[j-1][j][W-1]);
            }
            if (j<W-1){
                dp[i+1][j]+=dp[i][j+1]*(pos1[j+1][j][W-1]+pos2[j+1][j][W-1]);
            }
            dp[i+1][j]%=MOD;
        }
    }
    cout << dp[H][K-1] << endl;
}

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

#define int         long long int
#define all(a)      (a).begin(),(a).end()
#define f           first
#define s           second
#define endl        '\n'
#define MOD         1000000007

const int N = 1E6 + 6 ;
int fact[N] ;
int iFact[N] ;

int modExpo(int a, int b, int mod = MOD)
{
    int res = 1 ;
    while(b > 0)
    {
        if(b & 1)
        {
            res = res * a % mod ;
        }
        a = a * a % mod ;
        b >>= 1 ;
    }
    return res ;
}

void init()
{
    fact[0] = 1 ;
    for(int i = 1 ; i < N ; i++)
    {
        fact[i] = i * fact[i-1] % MOD ;
    }
    iFact[N-1] = modExpo(fact[N-1], MOD - 2, MOD) ;
    
    for(int i = N - 2 ; i >= 0 ; i--)
    {
        iFact[i] = (1LL * (i+1) * iFact[i + 1]) % MOD ;
    }
}

int C(int n, int r)
{
    if(n < 0 or r < 0 or n < r)
        return 0 ;
        
    return (1LL*((1LL*fact[n]*iFact[r]) % MOD) * iFact[n-r]) % MOD ;
}

void solve()
{
    int x, y ;
    cin >> x >> y ;
    if((x + y) % 3 != 0)
    {
        cout << 0 << endl ;
        return ;
    }
    
    int n = 0, m = 0 ;  // n + 2 * n + m + 2*m = x + y
    
     // n + 2 * m = x
     // m + 2 * n = y 
     
     int a = (x + y) / 3 ;
     int b = (x - y) ;  
     
     m = (a+b)/2 ;
     n = a  - m ;
     if(n < 0 or m < 0)
     {
         cout << 0 << endl ;
         return ;
     }
     
     cout << C(n+m, m) << endl ;
}

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

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

Measured memory_bytes: 16000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))


int main(){
    int n;  cin >> n;
    vector<ll> a(n);
    REP(i, n)   cin >> a.at(i);
    bool flag=false;
    REP(i, n){
        if(a[i]&1) flag = true;
    }
    string ans="first";
    if(!flag) ans = "second";    
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

int N;

int main()
{
    cin >> N;
    char c;
    lint sum, now, msum = 0;
    cin >> sum;
    lint tmp = 0;
    vector<lint> mlst;
    for (int i=1; i<N; i++)
    {
        cin >> c >> now;
        sum += now;
        if (c == '-') {
            mlst.push_back(tmp);
            msum += now;
            tmp = msum;
        }
        else {
            tmp += now;
        }
    }
    if (!mlst.empty()) mlst[0] = -1; else mlst.push_back(-1);
    mlst.push_back(msum);
    sort(mlst.begin(), mlst.end());
    cout << sum - mlst[1] * 2 << endl;
}


Measured memory_bytes: 1400
#include<iostream>
int main() {
	int w,h;
	while (true){
	std::cin >> w >> h;
	if(w==0 && h==0){break;}
	int wc=1;
	int hc=1;
	while(wc<=w){
		while(hc<=h){
			std::cout <<"#";
			hc++;
		}
		hc=1;
		std::cout << std::endl;
		wc++;
	}
	std::cout << std::endl;
}
	return 0;
}

Measured memory_bytes: 3096
#![allow(non_snake_case)]

#[allow(unused_macros)]
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

fn main() {
    input!{
        S: chars,
    }
    println!(
        "{}",
        (0..1 << S.len() - 1)
            .map(|i| {
                let mut total = 0;
                let mut snip = 0;
                for j in 0..S.len() {
                    snip += S[j] as usize - 48;
                    if i >> j & 1 == 0 {
                        total += snip;
                        snip = 0;
                    } else {
                        snip *= 10;
                    }
                }
                total
            }).sum::<usize>()
    );
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000000007;

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  while(a>0 && b>0){
    c-=b;
    if(c<=0){
     cout << "Yes" << endl;
     return 0;
    }
    a-=d;
    if(a<=0){
     cout <<  "No" << endl;
     return 0;
    }
    
    
  }
}


Measured memory_bytes: 3636
/*DavitMarg*/
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <stack>
#include <cassert>
#include <iterator>
#include <bitset>
#include <fstream>
#define mod 1000000007ll
#define LL long long
#define LD long double
#define MP make_pair
#define PB push_back
#define all(v) v.begin(),v.end()
using namespace std;

int n,a;
map<int,int> used;

int main()
{
	cin>>n;
    for(int i=1;i<=n;i++)
	{
		scanf("%d",&a);
        used[a]++;
	}
    if(used.size()>3)
	{
        cout<<"No"<<endl;
        return 0;
	}
    else if(used.size()==1)
	{
        if(!used[0])
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	else
	{
        vector<pair<int,int>> v;
		for(auto it=used.begin();it!=used.end();++it)
            v.PB(MP(it->second,it->first));
		sort(all(v));
        reverse(all(v));

		if(used.size()==2)
		{
			v.PB(MP(v[0].first/2,v[0].second));
            v[0].first-=v[0].first/2;
			sort(all(v));
			reverse(all(v));
		}

        if((v[0].second ^ v[1].second ^ v[2].second)!=0)
        {
			cout<<"No"<<endl;
			return 0;
        }
		v[0].first-=v[2].first;
		v[1].first-=v[2].first;
		v[2].first-=v[2].first;
        if(v[0].first-v[1].first>1)
        {
			cout<<"No"<<endl;
			return 0;
        }

        if(v[0].first-v[1].first==1 && v[1].first==1)
        {
			cout<<"No"<<endl;
			return 0;
        }

        if(v[1].first>1)
        {
			cout<<"No"<<endl;
			return 0;
        }
	}
	cout<<"Yes"<<endl;
	return 0;
}


/*

6
1 4 5 5 4 4



*/


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)

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

    string s, t;
    cin >> s >> t;
    int m = s.size(), n = t.size();
    vector<vector<int>> dp(m + 1, vector<int>(n + 1));
    rep(i, 0, m) rep(j, 0, n) {
        dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
        if (s[i] == t[j])
            dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1);
    }
    string ans;
    int k = dp[m][n];
    int i = m, j = n;
    while (k > 0) {
        while (dp[i - 1][j] == k)
            i--;
        while (dp[i][j - 1] == k)
            j--;
        ans.push_back(s[i - 1]);
        k--;
        i--;
        j--;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl; /*
     rep(i, 0, m + 1) rep(j, 0, n + 1) {
         cout << dp[i][j] << ((j != n + 1 - 1) ? ' ' : '\n');
     }*/
    return 0;
}


Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
int64_t M = 1e9 + 7;
int main()
  {int N; cin >> N;
  vector<int64_t> A(N); for (auto &a : A) cin >> a;
  auto ans = 0LL, p = 1LL;
  for (int k = 0; k < 60; ++k)
    {auto z = 0LL; for (auto a : A) if (!(a >> k & 1)) ++z;
    ans = (ans + z * (N - z) % M * p % M) % M;
    p = p * 2 % M;}
  cout << ans << endl;}

Measured memory_bytes: 5612
N = int(input())
a = []
for i in range(N):
    x,y = map(int, input().split())
    a.append((x,y))

ls = []
from itertools import permutations
Ns = [i for i in range(N)]
perms = permutations(Ns)
perms = list(perms)

for perm in perms:
    cnt = 0
    for i in range(1,N):
        x1, y1 = a[perm[i-1]]
        x2, y2 = a[perm[i]]
        cnt += ((x1-x2)**2+(y1-y2)**2)**0.5
    ls.append(cnt)


#     for j in range(i+1,N):
#         x1,y1 = a[i]
#         x2,y2 = a[j]
print(sum(ls)/len(ls))


# print(perms)

Measured memory_bytes: 9460
#include<stdio.h>
#include<math.h>
 
int main(){
    double x[100],y[100],abs[100];
    int n;
    double d_1,d_2,d_22,d_3,d_33,d_in,max=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%lf",&x[i]);
    }
     for(int i=0;i<n;i++){
        scanf("%lf",&y[i]);
    }
    for(int i=0;i<n;i++){
        abs[i]=fabs(x[i]-y[i]);
        d_1+=abs[i];
        d_22+=pow(abs[i],2);
        d_33+=pow(abs[i],3);
        if(abs[i]>max) 
            max=abs[i];
    }
    d_2=pow(d_22,1.0/2);
    d_3=pow(d_33,1.0/3);
    d_in=max;
     
    printf("%lf\n%lf\n%lf\n%lf\n",d_1,d_2,d_3,d_in);
    return 0;
}


Measured memory_bytes: 2932
#include<iostream>
using namespace std;
int selectionSort(int *num,int n){
	int minn,ans=0;
	for(int i=0;i<n-1;i++){
		minn=i;
		for(int j=i;j<n;j++){
			if(num[j]<num[minn]) minn=j;
		}
		swap(num[i],num[minn]);
		if(i!=minn) ans++;
	}
	return ans;
}
int main(){
	int num[110];
	int n;
	while(cin>>n){
		for(int i=0;i<n;i++) cin>>num[i];
		int ans=selectionSort(num,n);
		for(int i=0;i<n;i++){
			if(i) cout<<' ';
			cout<<num[i];
		}
		cout<<endl<<ans<<endl;
	}
}

Measured memory_bytes: 3104
#include <stdio.h>

int main () {
	
	int n, s[10000],t[500], i, j, q;
	int count = 0 ;

	
	scanf ("%d",&n) ;
	for ( i = 0 ; i < n ; i ++ ) {
		scanf("%d", &s[i] ) ;
	}
	scanf ("%d",&q) ;
	for ( i = 0 ; i < q ; i ++ ) {
		scanf("%d", &t[i] ) ;
	}
	
	for ( j = 0 ; j < q ; j++) {
		for ( i = 0 ; i < n ; i++) {
			if ( s[i] == t[j] ) {
				count++ ;
				break;
			}
		}
	}
	
	printf("%d\n",count);
	
return 0;
}


 

Measured memory_bytes: 640
#include <stdio.h>
int main(void){
int n;
int A[2*n];
int i;
int temp;
temp=0;
scanf("%d",&n);
for (i=0;i<2*n;i++){
    scanf("%d",&A[i]);
}
for (i=0;i<2*n-5;){
    if (((A[i]==A[i+1])&&(A[i+2]==A[i+3]))&&(A[i+4]==A[i+5]))
        temp=1;
    i+=2;
}
if (temp==1)
    printf("Yes");
else
    printf("No");
}


Measured memory_bytes: 1744
#139
N = int(input())
H = list(map(int, input().split()))

count = 0
count_new = 0
flag = 0

for i in range(N-1):
    if H[i] >= H[i + 1]:
#         print("i", i)
        count_new += 1
#         print(count)
        if i == N - 2 and flag == 0:
            flag = 1
            count = count_new 
#             print(count, "k")
        elif i == N - 2 and count_new > count:
            count = count_new
#             print(count)
    else:
        flag = 1
        if count_new > count:
            count = count_new
        count_new = 0

print(count)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define all(x) (x).begin(),(x).end()
#define pushb push_back()
#define popb pop_back()
#define makep make_pair
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
int main(){
    char b;cin>>b;
    if(b=='A'){
        cout<<'T'<<endl;
    }else if(b=='C'){
        cout<<'G'<<endl;   
    
    }else if(b=='G'){
        cout<<'C'<<endl;
    }else{
        cout<<'A'<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

type segmentTree struct {
	offset int
	data   []int
	op     func(x, y int) int
	e      int
}

func newSegmentTree(n int, op func(x, y int) int, e int) segmentTree {
	var result segmentTree
	t := 1
	for t < n {
		t *= 2
	}
	result.offset = t - 1
	result.data = make([]int, 2*t-1)
	for i := 0; i < len(result.data); i++ {
		result.data[i] = e
	}
	result.op = op
	result.e = e
	return result
}

func (st segmentTree) build(a []int) {
	for i, v := range a {
		st.data[st.offset+i] = v
	}
	for i := st.offset - 1; i > -1; i-- {
		st.data[i] = st.op(st.data[i*2+1], st.data[i*2+2])
	}
}

func (st segmentTree) update(index, value int) {
	i := st.offset + index
	st.data[i] = value
	for i >= 1 {
		i = (i - 1) / 2
		st.data[i] = st.op(st.data[i*2+1], st.data[i*2+2])
	}
}

func (st segmentTree) query(start, stop int) int {
	result := st.e
	l := start + st.offset
	r := stop + st.offset
	for l < r {
		if l&1 == 0 {
			result = st.op(result, st.data[l])
		}
		if r&1 == 0 {
			result = st.op(result, st.data[r-1])
		}
		l = l / 2
		r = (r - 1) / 2
	}
	return result
}

func main() {
	defer flush()

	N := readInt()
	Q := readInt()

	A := make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = readInt()
	}

	st := newSegmentTree(N, max, -1)
	st.build(A)

	for i := 0; i < Q; i++ {
		T := readInt()
		if T == 1 || T == 3 {
			X := readInt()
			V := readInt()
			if T == 1 {
				st.update(X-1, V)
			} else if T == 3 {
				ok := N + 1
				ng := X - 1
				for ok-ng > 1 {
					m := ng + (ok-ng)/2
					if st.query(X-1, m) >= V {
						ok = m
					} else {
						ng = m
					}
				}
				println(ok)
			}
		} else if T == 2 {
			L := readInt()
			R := readInt()
			println(st.query(L-1, R))
		}
	}
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

var stdoutWriter = bufio.NewWriter(os.Stdout)

func flush() {
	stdoutWriter.Flush()
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdoutWriter, args...)
}


Measured memory_bytes: 13532
using System;
public class Hello{
    public static void Main(){
      int n=int.Parse(Console.ReadLine());
      int[] a= new int[n];
      var line=Console.ReadLine();
      int ans=0;
      for(int i=0;i<n;i++){
       a[i]=int.Parse(line.Split()[i]); 
      }
      Array.Sort(a);
      Array.Reverse(a);
      for(int i=0;i<n;i++){
        if(i%2==0)ans+=a[i];
        else ans-=a[i];
      }
      
      Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11476
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <climits>
using namespace std;

#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
#define mkp make_pair

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
static const int INF=1<<24;


int main(){
	int n;
	cin>>n;
	rep(i,n){
		string s;
		map<string,int> ma;
		cin>>s;
		int ans=0;
		//cout<<ma["aa"]<<endl;
		rep(j,s.size()-1){
			string s1,s2;
			s1=s.substr(0,j+1);
			s2=s.substr(j+1);
			//cout<<s1<<" "<<s2<<endl;
			string st;
			string ss1=s1,ss2=s2;
			//cout<<st<<endl;
			//string sss[4];
			rep(k,s1.size()){
				ss1[k]=s1[s1.size()-1-k];
			}
			rep(k,s2.size()){
				ss2[k]=s2[s2.size()-1-k];
			}
			//cout<<s1<<" "<<ss1<<endl;
			//cout<<s2<<" "<<ss2<<endl;
			st=s1+s2;
			if(ma[st]==0){
				ma[st]=1;
				ans++;
			}
			st=s1+ss2;
			if(ma[st]==0){
				ma[st]=1;
				ans++;
			}
			st=ss1+s2;
			if(ma[st]==0){
				ma[st]=1;
				ans++;
			}
			st=ss1+ss2;
			if(ma[st]==0){
				ma[st]=1;
				ans++;
			}
			st=s2+s1;
			if(ma[st]==0){
				ma[st]=1;
				ans++;
			}
			st=s2+ss1;
			if(ma[st]==0){
				ma[st]=1;
				ans++;
			}
			st=ss2+s1;
			if(ma[st]==0){
				ma[st]=1;
				ans++;
			}
			st=ss2+ss1;
			if(ma[st]==0){
				ma[st]=1;
				ans++;
			}
		}
		cout<<ans<<endl;
		
	}
	return 0;
}

Measured memory_bytes: 1312
// https://atcoder.jp/contests/panasonic2020/tasks/panasonic2020_d
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
#define ip(arr, n) for(int i=0; i<n; i++) cin>>arr[i];
#define ip1(arr, n) for(int i=1; i<=n; i++) cin>>arr[i];
#define op(arr, n) for(int i=0; i<n; i++) cout<<arr[i]<<" ";
#define fstIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define debug(x) cout<<x<<"\n";
#define inf 1e9
#define INF 1e16
#define MOD 1000000007

int n;

void stringEquivalence(int i, string t, char max_char){
    if(i==n){
        cout<<t<<endl;
        return;
    }
    for(char c='a'; c<=max_char; c++){
        t += c;
        if(c==max_char){
            stringEquivalence(i+1, t, max_char+1);
        }
        else stringEquivalence(i+1, t, max_char);
        t.pop_back();
    }
}

void solve(){
    cin>>n;
    stringEquivalence(0, "", 'a');
}

int main(){

    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

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

Measured memory_bytes: 3640
#include <bits/stdc++.h>
    using namespace std;
    typedef long long lint;
    typedef pair<int,int> pint;
    typedef vector<int> vint;
    #define rep(i, n) for(int i = 0; i < n; i++)
    #define rep2(i, m, n) for(int i = m; i < n; i++)
    #define rep3(elem, vec) for(auto elem: vec)
    #define SORT(V) sort((V).begin(),(V).end())
    #define RSORT(V) sort((V).rbegin(), (V).rend())
    #define COUT(N) cout<<fixed<<setprecision(N)
    lint gcd(int a,int b){return b?gcd(b,a%b):a;}
    lint lcm(int a,int b){return a*b/gcd(a,b);}
    lint comb(int a,int b){return b?comb(a-1,b-1)*a/b:1;}
    int dx[4] ={1,0,-1,0},dy[4] = {0,1,0,-1};
    int MOD = 1e9+7;

int main(){
    string S;
    cin >> S;
    if(S == "ARC")cout <<"ABC";
    else cout << "ARC";
    return 0;
}

Measured memory_bytes: 3620
def resolve():
    a, b = map(int, input().split())
    input_data = [int(_) for _ in input().split()]
    input_data.sort(reverse=True)
    sum_data = sum(input_data)
    converge = sum_data * (1 / (4 * b))

    if(converge > input_data[b - 1]):
        print("No")
    else:
        print("Yes")


resolve()

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    double N;
    cin >> N;

    vector<double> A(N), x(N), y(N);

    rep(i, N) {
        A[i] = i;
        cin >> x[i] >> y[i];
    }

    double ans = 0.0;
    do {
        double d = 0;
        repd(i, 1, N) {
            double tmp = (x[A[i - 1]] - x[A[i]]) * (x[A[i - 1]] - x[A[i]]) + (y[A[i - 1]] - y[A[i]]) * (y[A[i - 1]] - y[A[i]]);
            tmp = sqrt(tmp);
            d += tmp;
        }
        //cout << d << endl;
        ans += d;
    } while (next_permutation(all(A)));

    double div = 1;
    repd(i, 1, N + 1) div *= i;
    ans = ans / div;
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
(* O(h w) *)
Scanf.scanf " %d %d" @@ fun h w ->
  let ss = Array.init h @@ fun _ -> Scanf.scanf " %s" @@ fun s -> s in
  let f a b =
    let c = ref 0 in
    for y = -1 to 1 do
      for x = -1 to 1 do
        let a_y, b_x = a + y, b + x in
        if 0 <= a_y && a_y < h && 0 <= b_x && b_x < w then
          if ss.(a_y).[b_x] = '#' then incr c
      done
    done;
    !c in
  for y = 0 to h - 1 do
    for x = 0 to w - 1 do
      if ss.(y).[x] = '.' then print_int @@ f y x else print_char '#'
    done;
    print_newline ()
  done

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std; typedef long long  ll;
#define all(a) a.begin() , a.end()
#define print(x)   cout<<x<<"\n";
const ll M = ll(1e9 + 7);
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{os << "["; for (int i = 0; i < v.size(); ++i) { os << v[i]; if (i != v.size() - 1) os << ", "; } os << "]\n"; return os;}
template <typename T>
ostream& operator<<(ostream& os, const set<T>& v)
{os << "["; for (auto it : v) {os << it; if (it != *v.rbegin())os << ", ";} os << "]\n"; return os;}
template <typename T, typename S>
ostream& operator<<(ostream& os, const map<T, S>& v)
{for (auto it : v)os << it.first << " : " << it.second << "\n"; return os;}
template <typename T, typename S>
ostream& operator<<(ostream& os, const pair<T, S>& v)
{os << "("; os << v.first << ", " << v.second << ")"; return os;}
/***********************************************************************/
const int mod = 1e9 + 7;
vector<int> adj[100005];
int dp[100005];
int n, m;
int vis[100005];
int dfs(int node)
{
    if (dp[node] != -1)
        return dp[node];
    int ans = 0;
    for (auto x : adj[node])
    {
        ans = max(ans, dfs(x));
    }
    return dp[node] = 1 + ans;
}
int32_t main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        int x, y;
        cin >> x >> y;
        adj[x].push_back(y);
    }
    for (int i = 0; i < 100005; i++)   dp[i] = -1;
    int ans = 0;
    for (int i = 1; i <= n; i++)
    {
        ans = max(ans, dfs(i));
    }
    print(ans - 1);
}

Measured memory_bytes: 8192
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

bool prime[1000010];

void set_prime() {
	prime[0] = 1;
	prime[1] = 1;
	for (int i = 2; i < 2000; i++) {
		int j = 2;
		while (i * j <= 1000000) {
			prime[i*j] = 1;
			j++;
		}
	}
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    set_prime();
    REP(i, N, 1000000) {
        if (prime[i] == 0) {
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
	for(int n,S;cin>>n>>S,n|S;){
		vector<int> r(n);
		for(int i=0;i<n;i++)
			cin>>r[i];
		sort(r.begin(),r.end());
		
		int res=0;
		for(int i=0;i<n;i++)
			res+=r.end()-upper_bound(r.begin()+i+1,r.end(),S-r[i]);
		cout<<res<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1252
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<cstring>
using namespace std;
int min(int a,int b);
int main()
{
	int n;
	cin>>n;
	int a;
	int i;
	int flag=1;
	for(i=1;i<=n;i++)
	{
		cin>>a;
		if(a%2==0)
		{
			if(a%3==0 || a%5==0)
			{
				continue ;
			}
			flag=0;
			break ;
		}
	}
	if(flag)
		cout<<"APPROVED"<<endl;
	else
		cout<<"DENIED"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
#define invp(a,p)pom(a,p-2,p)

#define MOD (7*(1<<26)+1)
#define SIZE (1<<18)

//非再帰fft
void fft(ll*f,int n,ll g){
	ll yy[SIZE];
	ll*x=f,*y=yy,*temp;
	for(int t=1;n>>t;t++){
		ll s=1;
		ll gg=pom(g,n>>t,MOD);
		rep(k,0,1<<(t-1)){
			rep(j,0,n>>t){
				y[(j<<t)+k           ]= (x[(j<<(t-1))+k]+s*x[(j<<(t-1))+n/2+k])%MOD;
				y[(j<<t)+k+(1<<(t-1))]=((x[(j<<(t-1))+k]-s*x[(j<<(t-1))+n/2+k])%MOD+MOD)%MOD;
			}
			s=s*gg%MOD;
		}
		temp=x;x=y;y=temp;
	}
	if(x!=f)rep(i,0,n)f[i]=x[i];
}


ll c2[6][SIZE];
ll aa[2][SIZE];
ll*dp=aa[0],*temp=aa[1],*t;
ll n;

int main(){
	scanf("%lld",&n);
	
	for(int r=1;!c2[0][r];r=r*10%n)c2[0][r]=1;
	if(c2[0][0]){
		puts("1");
		return 0;
	}
	c2[0][0]=1;
	
	ll g=pom(3,(MOD-1)/SIZE,MOD);
	ll ig=invp(g,MOD);
	ll iSIZE=invp(SIZE,MOD);
	fft(c2[0],SIZE,g);

	int ng=1,idx=0;
	for(int k=1;k<=5;k++){
		//掛け算
		rep(i,0,SIZE)c2[k][i]=c2[k-1][i]*c2[k-1][i]%MOD;
		//ifft
		fft(c2[k],SIZE,ig);
		if((c2[k][0]+c2[k][n])*iSIZE%MOD==1)ng=1<<k,idx=k;
		//次数下げ
		rep(i,0,n)c2[k][i]=!!((c2[k][i]+c2[k][i+n])%MOD),c2[k][i+n]=0;
		//fft
		fft(c2[k],SIZE,g);
	}
	//c2[k]は2^k個でできるやつをfftしたやつ
	
	//ngはngで、ng+(1<<idx)はOK
	rep(i,0,SIZE)dp[i]=c2[idx][i];
	while(idx--){
		rep(i,0,SIZE)temp[i]=dp[i]*c2[idx][i]%MOD;
		//ifft
		fft(temp,SIZE,ig);
		if((temp[0]+temp[n])*iSIZE%MOD==1){
			//次数下げ
			rep(i,0,n)temp[i]=!!((temp[i]+temp[i+n])%MOD),temp[i+n]=0;
			//fft
			fft(temp,SIZE,g);
			t=dp;dp=temp;temp=t;
			ng+=1<<idx;
		}
	}
	printf("%d\n",ng+1);
}

Measured memory_bytes: 18688
//ITP1_6_D
//????????????  ???

using System;
using System.Collections.Generic;

class ITP1_6_D
{
    static void Main(string[] args)
    {

        int[] st = Array.ConvertAll<string, int>((Console.ReadLine().Split(' ')), delegate (string value)
        {
            return int.Parse(value);
        });

        int n = st[0], m = st[1], sum;
        int[ , ] iarray = new int[ n + 1, m ];

        for (int row = 0;row < n; row++)
        {
             //????????\????????????
            int [] colarray = Array.ConvertAll<string, int>((Console.ReadLine().Split(' ')), delegate (string value)
            {
                return int.Parse(value);
            });

            for (int col = 0; col < m; col++)
                iarray[row, col] = colarray[col];
        }

        //??????????????\????????????
        for(int col = 0; col < m; col++)
            iarray[n , col] = int.Parse(Console.ReadLine());

        //?¨????
        for(int row = 0;row < n; row++)
        {
            sum = 0;
            for(int col = 0;col < m; col++)
            {
                sum += iarray[row, col] * iarray[n, col];
            }
            Console.WriteLine(sum);
        }
    }
}

Measured memory_bytes: 9200
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>
#include <regex>
using namespace std;
int main(void) {
	int n;
	cin >> n;
	int n_500, n_5;
	int m;
	n_500 = (int)(n / 500);
	m = n % 500;
	n_5 = (int)(m / 5);
	int ret = n_500 * 1000 + n_5 * 5;
	cout << ret << endl;
}

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

const int MOD = (int)1e9+7;

int main(){
	int A,B;
	cin >> A >> B;

	if(A>=13)	cout << B << endl;
	else if(A>=6)	cout << B/2 << endl;
	else cout << 0 << endl;

	return 0;
}


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

int main(){
    ll n,m;
    cin >> n >> m;
    vector<ll> a(m);
    ll sum = 0;
    rep(i,m){
        cin >> a[i];
        sum += a[i];
    }
    if(sum > n){
        cout << "-1" << endl;
        return 0;
    }

    cout << n - sum << endl;
    return 0;
}

Measured memory_bytes: 3704
n = int(input())
b = list(map(int, input().split()))

a = []
for i in range(n):
    if i == 0:
        a.append(b[i])
    elif i == n - 1:
        a.append(b[i - 1])
    else:
        a.append(min(b[i], b[i - 1]))
print(sum(a))


Measured memory_bytes: 9072
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [long(input_raw[0])]
    R = []
    R_ = []
    for i in range(N):
        input_raw = read_func().strip().split()
        [a, b] = [long(input_raw[0]), long(input_raw[1])]
        R.append((a, b))

    B = []
    for i in range(N):
        input_raw = read_func().strip().split()
        [a, b] = [long(input_raw[0]), long(input_raw[1])]
        B.append((a, b))
    B.sort()
    count = 0
    already_set = set([])
    for i in range(len(B)):
        max_y = -1
        max_y_idx = -1
        for j in range(len(R)):
            if j not in already_set and B[i][0] > R[j][0] and B[i][1] > R[j][1]:
                if R[j][1] > max_y:
                    max_y = R[j][1]
                    max_y_idx = j
        if max_y_idx != -1:
            already_set.add(max_y_idx)
            count += 1


    print count




##    for i in range(N):
##        input_raw = read_func().strip().split()
##        [a, b] = [long(input_raw[0]), long(input_raw[1])]
##        R.append((a, b, i))
##        R_.append((b, a, i))
##    sortedR = sorted(R)
##    R_.sort()
##    Rx_order=[0]*N
##    Ry_order=[0]*N
##    for i in range(N):
##        Rx_order[sortedR[i][2]]=i
##        Ry_order[R_[i][2]]=i
##
##    B = []
##    B_ = []
##    for i in range(N):
##        input_raw = read_func().strip().split()
##        [a, b] = [long(input_raw[0]), long(input_raw[1])]
##        B.append((a, b, i))
##        B_.append((b, a, i))
##    sortedB = sorted(B)
##    B_.sort()
##    Bx_order=[0]*N
##    By_order=[0]*N
##    for i in range(N):
##        Bx_order[sortedB[i][2]]=i
##        By_order[B_[i][2]]=i

##
##    count = 0
##    already_set = set([])
##    for i in range(len(B)):
##        min_dist = sys.maxint
##        min_dist_idx = -1
##        for j in range(len(R)):
##            if j not in already_set and B[i][0] > R[j][0] and B[i][1] > R[j][1]:
##                dist = min(abs(Bx_order[i] - Rx_order[j]), abs(By_order[i] - Ry_order[j]))
##                if dist < min_dist:
##                    min_dist = dist
##                    min_dist_idx = j
##        if min_dist_idx != -1:
##            already_set.add(min_dist_idx)
##            count += 1
##        print i, min_dist_idx, min_dist, Bx_order[i], Rx_order[min_dist_idx],By_order[i], Ry_order[min_dist_idx]

    #print count




if __name__ == '__main__':
    main()


Measured memory_bytes: 2936
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

int main() {
  int N, M, Q;
  cin >> N >> M >> Q;
  vector<int> a(Q), b(Q), c(Q), d(Q);
  for (int i = 0; i < Q; i++) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }
  vector<int> comb(M - 1 + N);
  for (int i = 0; i < N; i++) {
    comb[i] = 1;
  }
  sort(comb.begin(), comb.end());
  int mx = 0;
  int left = 1;
  do {
    vector<int> A;
    int tmp = 0;
    for (int i = 0; i < M - 1 + N; i++) {
      if (comb[i] == 1) A.push_back(left);
      if (comb[i] == 0) left++;
    }
    for (int i = 0; i < Q; i++) {
      if (A[b[i] - 1] - A[a[i] - 1] == c[i]) {
        tmp += d[i];
      }
    }
    mx = max(tmp, mx);
  } while (next_permutation(comb.begin(), comb.end()));
  cout << mx << endl;
  return 0;
}

Measured memory_bytes: 3616
#include<iostream>
using namespace std;
int a[105];
int main(void)
{
    int n;
    bool flag=false;
    cin >> n;
    for(int i=1;i<=n;i++)
        cin >> a[i];
    for(int i=1;i<=n;i++)
    {
        if(a[i]%2==0)
        {
            if(a[i]%3==0 || a[i]%5==0);
            else
                flag=true;
        }
    }
    if(flag==true)
        cout << "DENIED";
    else
        cout << "APPROVED";
    return 0;
}


Measured memory_bytes: 256
from heapq import heappop as pop
from heapq import heappush as push
INF = 10 ** 20

def main():
  n, k = map(int, input().split())
  
  clst = []
  rlst = []
  
  for i in range(n):
    c, r = map(int, input().split())
    clst.append(c)
    rlst.append(r)
  
  edges = [[] * n for i in range(n)]
  
  for i in range(k):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    edges[a].append(b)
    edges[b].append(a)
  
  costs = [INF for i in range(n)]
  costs[0] = 0
  used = [False for i in range(n)]
  
  def make_to_lst(s_num):
    loop = rlst[s_num]
    temp = set(edges[s_num])
    ret = set()
    while loop:
      new = set()
      for p in temp:
        pto = set(edges[p])
        new = new | pto
      ret = ret | temp
      temp = new - ret
      if not temp:
        break
      loop -= 1
    return ret
  
  used[0] = True
  costs[0] = 0
  break_flag = 0
  que = [(clst[0], 0)]
  
  while que and not break_flag:
    next_cost, s_num = pop(que)
    to_lst = make_to_lst(s_num)

    for num in to_lst:
      costs[num] = next_cost
      if num == n - 1:
        break_flag = 1
        break
      if not used[num]:
        push(que, (costs[num] + clst[num], num))
        used[num] = True
  
  print(costs[n - 1])

main()


Measured memory_bytes: 7936
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;
const int N = 100005;

LL a[N];
int b[N];
LL pre[N];
int main() {
    LL n, m, x;
    cin >> n >> x >> m;
    LL ans = pre[1] = a[1] = x;
    b[x] = 1;
    for (int i = 2; i <= n; i++) {
        a[i] = a[i - 1] * a[i - 1] % m;
        ans = pre[i] = pre[i - 1] + a[i];
        if (b[a[i]] > 0) {
            LL t1 = (n - b[a[i]]) / (i - b[a[i]]), t2 = (n - b[a[i]]) % (i - b[a[i]]);
            ans = pre[b[a[i]] + t2] + (pre[i] - pre[b[a[i]]]) * t1;
            break;
        }
        b[a[i]] = i;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4740
N, M = [int(_) for _ in input().split()]
ks = [[int(_) for _ in input().split()] for _ in range(M)]
p = [int(_) for _ in input().split()]

binary = [format(num, "0" + str(N) + "b") for num in range(2 ** N)]

count = 0

for bin in binary:
    for i in range(1, M + 1):
        condition = ks[i - 1]
        parity_i = sum([int(bin[j - 1]) for j in condition[1:]]) % 2
        if parity_i != p[i - 1]:
            break
    else:
        count += 1

print(count)

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

int main() {
  int h, w, n;
  cin >> h >> w >> n;

  int val = max(h, w);
  int ans = (n + (val - 1)) / val;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
int main()
{
  ios_base::sync_with_stdio;
  cin.tie(0);
  cout.tie(0);
  vector<ll>arr;
  vector<ll>cost;
  ll n,g,i,j,k;
  cin>>n>>k;
  for(i=0;i<n;i++)
  {
    cost.push_back(-1);
  }
  cost[0]=0;
  for(i=0;i<n;i++)
  {
    cin>>g;
    arr.push_back(g);
  }
  for(i=0;i<n-1;i++)
  {
    for(j=i+1;j<i+k+1;j++)
    {
        if(cost[j]!=-1)
        {cost[j]=min(cost[j],abs(arr[j]-arr[i])+cost[i]);}
        else if(cost[j]==-1)
        {
          cost[j]=abs(arr[j]-arr[i])+cost[i];
        }
        if(j==n-1)
        {
          break;
        }
    }
  }
  cout<<cost[n-1]<<endl;
}

Measured memory_bytes: 5564
import numpy as np

a=[input() for i in range(2)]
a1=a[0].split()
a2=a[1].split()
x=int(a1[0])
n=int(a1[1])

p=[int(i) for i in a2]

d_list=[]

for i in np.arange(-1,102):
	if i not in p:
		d=abs(i-x)
		d_list.append(d)

sa=min(d_list)

an=x-sa
an2=x+sa

if an in p:
	print(an2)

else:
	print(an)




Measured memory_bytes: 27144
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << '\n'
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define pr(s) cout << (s) << '\n'
const ll mod = 998244353;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
const int INF = 1001001001;
const ll INFll = 1E+18;
using mint = static_modint<mod>;

struct combination {
    vector<mint> fact, ifact, fact2;
    combination(int n):fact(n+1),ifact(n+1), fact2(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
        fact2[0] = 1; fact2[1] = 1;
        for (int i=2; i<=n; ++i) fact2[i] = fact2[i-2]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
    mint per(int n, int k) {
        return fact[n]*ifact[n-k];
    }
};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    map<int, int> mp;
    combination comb(2*n+5);
    vector<int> a;
    rep(i, 2*n) {
        int h;
        cin >> h;
        mp[h]++;
    }
    for (auto m: mp) {
        a.pb(m.se);
    }
    
    vector<vector<mint>> v(a.size());
    rep(i, a.size()) {
        int s = a[i]/2 + 1;
        v[i].resize(s);
        rep(j, s) {
            v[i][j] = comb(a[i], 2*j);
            if (j>0) v[i][j] *= comb.fact2[2*j-1];
        }
    }
    
    while(v.size()>1) {
        vector<vector<mint>> prev;
        swap(prev, v);
        rep(i, prev.size()) {
            if (i%2==1) continue;
            if (i==prev.size()-1) {
                v.pb(prev[i]);
                continue;
            }
            v.pb(convolution(prev[i], prev[i+1]));
        }
    }
    mint ans = 0;
    rep(i, v[0].size()) {
        int rem = 2*n-i*2;
        mint res = v[0][i];
        if (rem>0) res *= comb.fact2[rem-1];
        if (i%2==0) ans += res;
        else ans -= res;
    }
    
    pr(ans.val());
    return 0;
}


Measured memory_bytes: 17684