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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fr, to)    for (int i = fr; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = 2e5;
int n, a[nsz + 5], ans;

int inline add_one(int as, int pos, map<int, int> &s) {
    if (as == 1)  return 0;
    for (int i = pos; i >= 1; --i) {
        if (as == 1) {
            cerr << i << ln;
        }
        if (s[i] < as - 1) {
            ++s[i];
            return 1;
        }
        s[i] = 0;
    }
    return 0;
}

bool inline chk(int as) {
    map<int, int> s;
    cont (i, n) {
        int p = a[i], pp = a[i - 1];
        if (p <= pp) {
            if (!add_one(as, p, s))  return 0;
        }
        s.erase(s.upper_bound(p), s.end());
    }
    return 1;
}

void inline solve() {
    int l = 0, r = nsz + 1, mid = (l + r) >> 1;
    for (; r - l > 1; mid = (l + r) >> 1) {
        (chk(mid) ? r : l) = mid;
    }
    ans = r;
}

int inline read() {
    int res = 0;
    char c = getchar();
    for (; !isdigit(c); c = getchar());
    for (; isdigit(c); res *= 10, res += c ^ 48, c = getchar());
    return res;
}

void inline write(int a, char c) {
    int s = 0, d[10] = {0};
    for (; a; d[s++] = a % 10, a /= 10);
    for (s = s ? s : 1; s; putchar(d[--s] + 48));
    putchar(c);
}

int main() {
    n = read();
    cont (i, n) {
        a[i] = read();
    }
    solve();
    write(ans, ln);
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int N = int.Parse(str[0]);
		int M = int.Parse(str[1]);
		int[]A = new int[N];
		for(var i=0;i<N;i++){
			A[i] = -1;
		}
		int ans = 0;
		for(var i=0;i<M;i++){
			string[] str2 = Console.ReadLine().Split();
			int s = int.Parse(str2[0]);
			int c = int.Parse(str2[1]);
			if(A[s-1] >= 0 && A[s-1] != c){
				ans = -1;
			} else {
				A[s-1] = c;
			}
		}
		if(ans!=-1){
			if(N>=2 && A[0]==0){
				ans = -1;
			}
		}
		if(ans==-1){
			Console.WriteLine(ans);
		} else {
			for(var i=0;i<N;i++){
				if(A[i]==-1){
                 if(i==0 && N>=2){
                   A[i]=1;
                 } else{
                  A[i]= 0;
                 }
                }
				Console.Write(A[i]);
			}
		}
	}
}


Measured memory_bytes: 13140
N = int(input())
x,r = 1,0

while x*x < N:
	if N%x==0:
		if x>1 and N//(x-1)==N%(x-1):
			r += x-1
		t = N//x-1
		if N//t==N%t:
			r += t
	x += 1

print(r)

Measured memory_bytes: 63868
#include <iostream>

int main()
{
    std::ios_base::sync_with_stdio(0);
    int n;
    double s = 0;
    std::cin >> n;
    for (int i=1;i<=n;++i)
    {
        if (i&1)
            s += 1;
    }
    std::cout << s/n;
    return 0;
}

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

#define _GLIBCXX_DEBUG

//vector<int> A(M), B(M);
//vector<vector<char>> answer(N, vector<char>(N, '-'));

int main() {
  int a1, a2, a3;
  string ans;
  
  cin >> a1 >> a2 >> a3;
  
  if(a1 + a2 + a3 >= 22) ans = "bust";
  else ans = "win";
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, Q = map(int, readline().split())
    S = readline().strip()
    (*LR,) = map(int, read().split())

    vec = [0] * (N + 1)
    for i in range(N - 1):
        vec[i + 1] = vec[i]
        if S[i] == 'A' and S[i + 1] == 'C':
            vec[i + 1] += 1

    ans = [0] * Q
    for i, (l, r) in enumerate(zip(*[iter(LR)] * 2)):
        l -= 1
        r -= 1
        ans[i] = vec[r] - vec[l]

    print('\n'.join(map(str, ans)))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 32336
Module Module1

    Sub Main()
        Dim arr() As Integer = Array.ConvertAll(Of String, Integer)(Console.ReadLine().Split(" "), AddressOf Integer.Parse)
        Dim N As Integer = arr(0)
        Dim Y As Integer = arr(1)
        Dim a, b, c As Integer
        a = -1 : b = -1 : c = -1
        For i As Integer = 0 To N
            For j As Integer = 0 To N
                Dim k As Integer = N - i - j
                If k >= 0 AndAlso i * 10000 + j * 5000 + k * 1000 = Y Then
                    a = i : b = j : c = k
                End If
            Next
        Next

        Console.WriteLine(a.ToString + " " + b.ToString + " " + c.ToString)
    End Sub

End Module

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

int main() {
    int s;
    cin>>s;
    int ans = 1;
    
    if(s==1 || s==2||s==4){
        cout << 4 << endl;
        return 0;
    }
    while(s!=4){
        if(s%2==0) s/=2;
        else s = 3*s+1;
        ans ++;
    }
    cout << ans+3 << endl;
    
    return 0;
}



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

#define endl '\n'

using namespace std;

struct custom_hash 
{
    static unsigned long long splitmix64(unsigned long long x) 
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(unsigned long long x) const 
    {
        static const unsigned long long FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

template <int mod> 
long long fast_pow(long long x, int deg)
{
	long long ans = 1, y = x;
	while (deg)
	{
		if (deg & 1)
			ans = ans * y % mod;

		deg >>= 1; 
		y = y * y % mod;
	}

	return ans; 
}

const int maxn = 2e5 + 3; 	

int n, m, v, p;
int a[maxn];
void read()
{
	cin >> n >> m >> v >> p;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
}

bool can(int idx)
{
	int curr = a[idx] + m;
	int curr_v = v, curr_p = p-1; 
	curr_v--;

	int cnt_greater = 0;
	for (int i = 1; i <= n; i++)
		if (a[i] > curr)
			cnt_greater++;

		if (cnt_greater >= p)
			return false;
    
    curr_p -= cnt_greater;
    curr_v -= cnt_greater; 
    if (curr_v <= 0)
    	return true;

    long long sum = 0;
    for (int i = n; i >= 1; i--)
    	if (i != idx && a[i] <= curr)
    	{
    		if (curr_p)
    		{
    			curr_v--;
    			curr_p--;
    			continue;
    		}

    		sum += min(curr-a[i], m);
    	}

    if (curr_v <= 0)
    return true;    

    return sum / curr_v >= m;
}

void solve()
{
	sort (a + 1, a + n + 1);
	int low = 1, high = n;
	while (low < high)
	{
		int mid = (low + high) / 2;
		if (can(mid))
			high = mid; 

		else 
			low = mid + 1; 
	}
     
	cout << n - low + 1 << endl; 
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	
	read();
	solve();
}

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

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

int main() {
    string str;
    cin >> str;
    char prec = str.at(0);
    int count = 0;
    for(int i=1;i<str.length();i++){
        if(prec != str.at(i)){
            prec = str.at(i);
            count++;
        }
    }

    cout << count;

    return 0;
}

Measured memory_bytes: 512
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>

#define ll long long
#define test(t) ll int t; cin>>t; while(t--)
#define F(i,L,R) for(ll int i=L;i<R;i++)
#define F2(i,L,R) for(ll int i=L;i>=R;i--)
#define get1(a) ll int a; cin>>a;
#define get2(a,b) ll int a,b; cin>>a>>b;
#define get3(a,b,c) ll int a,b,c; cin>>a>>b>>c;
#define pb push_back
#define mp make_pair
#define MAX 1000000001
using namespace std;



int main()
{ 
 

 ios_base::sync_with_stdio(0);

 

 get1(a);

 cout<<( 1000 * (a/500) + 5 * ( (a%500)/5 ) ) ;

  return 0;
 
}


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

int main()
{
    string s;
    cin >> s;
    if(s == "Sunny") {cout << "Cloudy" << endl; return 0;}
    else if(s == "Cloudy"){cout << "Rainy" << endl; return 0;}
    else if(s == "Rainy"){cout << "Sunny" << endl; return 0;}
    
}

Measured memory_bytes: 3604
// template {{{

#include <bits/stdc++.h>
using namespace std;

#define loop(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) loop(i, 0, n)
#define rloop(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i--)
#define rrep(i, n) rloop(i, 0, n)
#define eb emplace_back
#define ef emplace_front
#define pb pop_back
#define pf pop_front
#define all(c) std::begin(c), std::end(c)
#define mp std::make_pair
#define mt std::make_tuple
#define fi first
#define se second
#define popcnt __builtin_popcountll

using uint = unsigned;
using ll = long long;
using ull = unsigned long long;
using ld = long double;

template<typename T>
using max_pq = priority_queue<T, vector<T>, less<T>>;

template<typename T>
using min_pq = priority_queue<T, vector<T>, greater<T>>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 10;
const ll LLINF = 1e18 + 10;

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

template<typename T>
inline T sq(T x){ return x * x; }

template<typename T, typename U>
inline bool chmax(T &x, U y){ if (x >= y) return false; x = y; return true; }

template<typename T, typename U>
inline bool chmin(T &x, U y){ if (x <= y) return false; x = y; return true; }

template<typename T>
inline void sort(T &c){ std::sort(std::begin(c), std::end(c)); }

template<typename T>
inline void reverse(T &c){ std::reverse(std::begin(c), std::end(c)); }

template<typename T>
inline void unique(T &c){ std::sort(std::begin(c), std::end(c)); c.erase(std::unique(all(c)), std::end(c)); }

// }}}

using tp = tuple<int, int, int>;

int n;
tp a[1000];
int dp[2][366][366];

/* MLE tsurai.
int calc(int i, int j, int k)
{
	if (i == n) return 0;
	int &res = dp[i][j][k];
	if (~res) return res;
	
	int x, y, z;
	tie(x, y, z) = a[i];

	chmax(res, calc(i + 1, j, k));
	if (x >= j) chmax(res, z + calc(i + 1, y, k));
	if (x >= k) chmax(res, z + calc(i + 1, j, y));

	return res;
}
*/

int main()
{
	while (cin >> n, n){
		rep(i, n){
			int x, y, z;
			cin >> x >> y >> z;
			a[i] = tie(--x, y, z);
		}
		sort(a, a + n);
		
		/* memoka saiki shitai.
		memset(dp, -1, sizeof(dp));
		cout << calc(0, 0, 0) << endl;
		*/
		
		// kanashimi.
		memset(dp, 0, sizeof(dp));
		rep(i, n){
			int src = i & 1, dst = ~i & 1;
			memset(dp[dst], 0, sizeof(dp[dst]));
			int x, y, z;
			tie(x, y, z) = a[i];
			rep(j, x + 1) rep(k, 366){
				chmax(dp[dst][y][k], dp[src][j][k] + z);
				chmax(dp[dst][k][y], dp[src][k][j] + z);
			}
			rep(j, 366) rep(k, 366){
				chmax(dp[dst][j][k], dp[src][j][k]);
			}
		}

		int res = 0;
		rep(i, 366) rep(j, 366){
			chmax(res, dp[n & 1][i][j]);
		}

		cout << res << endl;
	}
}

Measured memory_bytes: 4076
use whiteread::parse_line;

fn main() {
    let (_n, k): (u32, usize) = parse_line().unwrap();
    let mut ps: Vec<u32> = parse_line().unwrap();
    ps.sort();
    let s = ps.iter().take(k).sum::<u32>();

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


Measured memory_bytes: 2156
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n,x = map(int,ipt().split())
    a = [int(i) for i in ipt().split()]
    pm = a*1
    mi = sum(a)
    for i in range(1,n):
        mii = x*i
        pp = pm*1
        for j in range(n):
            pm[n-1-j] = min(pp[n-1-j],a[n-1-j-i])
            mii += pm[n-1-j]
        if mi > mii:
            mi = mii
    print(mi)

    return

if __name__ == '__main__':
    main()


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

int main(void){
  char a[500],b[500];
  int lengtha,lengthb;

  scanf("%s %s",a,b);

  lengtha=strlen(a);
  lengthb=strlen(b);

  if(lengtha>lengthb){
    printf("GREATER\n");
    return 0;
  }else if(lengtha<lengthb){
    printf("LESS\n");
    return 0;
  }

  if(strcmp(a,b)>0){
    printf("GREATER\n");
  }else if(strcmp(a,b)<0){
    printf("LESS\n");
  }else{
    printf("EQUAL\n");
  }

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
int main() {
	string a, b, c;
	double nroot;
	cin >> a >> b;
	c = a + b;
	int n = stoi(c);
	
	nroot = sqrt(n);
	
	if(nroot == (int)sqrt(n)){
	    std::cout << "Yes" << std::endl;
	}else{
	    std::cout << "No" << std::endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include "Local_Debug.h"
using namespace std;
#define Endl endl
#define debug(x) cout << #x << " = " << (x) << endl
typedef long long ll;
const int MOD = (int)1e9 + 7;
const int MAXN = (int)2e5 + 5;
ll a, b;
int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	while (cin >> a >> b)
	{
		if (a > 9 || b > 9)
			cout << -1 << endl;
		else
			cout << a*b << endl;
	}
}


Measured memory_bytes: 256
#include <cstdio>
#define MAXN 14

int main(void)
{

	long long i,c0,c1,c2,N,m[5]={0};
	long long s;
	char name[MAXN];
	const char sign[7]="MARCH";
	scanf("%lld",&N);
	for(i=0;i<N;i++)
	{
		scanf("%s",name);
		for(int j=0;j<5;j++)
			if(name[0]==sign[j])
				m[j]++;
	}
	s=0;
	for(c0=0;c0<5;c0++)
		for(c1=c0+1;c1<5;c1++)
			for(c2=c1+1;c2<5;c2++)
				s+=m[c0]*m[c1]*m[c2];
	printf("%lld\n",s);
	return 0;

}

Measured memory_bytes: 128
import std.stdio;
import std.algorithm;
import std.conv;
import std.datetime;
import std.numeric;
import std.math;
import std.string;

string my_readln() { return chomp(readln()); }

void main()
{
	auto tokens = split(my_readln());
	auto X = to!ulong(tokens[0]);
	auto Y = to!ulong(tokens[1]);

	writeln(X + Y / 2);
	stdout.flush();
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007LL
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000000000000LL
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 20
#define off 2
#define sq(x) ((x)*(x))

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define maxn 300005

typedef pair<i64, i64> pii;

char s[maxn] ;

int main()
{
    int i , j , k , l , m , n ;

    scanf("%s",s) ;

    n = strlen(s) ;

    for(i=n ; i>=1 ; i--) s[i] = s[i-1] ;

    for(i=1 ; i<n ; i++)
    {
        if( s[i]!=s[n-i]  )
        {
            printf("-1\n") ;
            return 0 ;
        }
    }

    if( s[1]=='0' || s[n]=='1' )
    {
        printf("-1\n") ;
        return 0 ;
    }

    int root = n ;

    while( root > 1 )
    {
        for(i=root-1 ; i>=1 ; i--)
        {
            printf("%d %d\n",root,i) ;
            if(s[i]=='1')
            {
                break ;
            }
        }
        root = i ;
    }

    return 0 ;
}


Measured memory_bytes: 1536
// by Balloons
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define mpr make_pair
#define debug() puts("okkkkkkkk")
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)

using namespace std;

typedef long long LL;
#define int LL

const int inf = 1e9;
int a;
int s(int x){int r=0;while(x){r+=x%10;x/=10;}return r;}
int check(int x){for(int i=x+1;i<=x+10000;i++)if(x*s(i)>i*s(x))return 0;return 1;}
LL f[21];
signed main(){
	int n;scanf("%lld",&n);
	f[0]=1;for(int i=1;i<=18;i++)f[i]=f[i-1]*10ll;
	LL ans=1,cd=0;while(n--){
		printf("%lld\n",ans);
		if((ans+f[cd])*s(ans+f[cd]*2)>(ans+f[cd]*2)*s(ans+f[cd]))++cd;
		ans+=f[cd];
	}

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
    int youso[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int i=0;
    int *p;
    p=youso;
    scanf("%d",&i);
    printf("%d",*(p+i-1));
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int INF = 1001001001;
const ll mod = 1e+9 + 7;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

template<typename Monoid>
struct SegmentTree{
    using F = function<Monoid(Monoid, Monoid)>;

    int sz;
    vector<Monoid> seg;

    const F f;      // モノイドに対して二項演算を行う関数オブジェクト
    const Monoid M1;

    SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1){
        sz = 1;
        while(sz < n)   sz <<= 1;
        seg.assign(2 * sz, M1);
    }

    void set(int k, const Monoid &x){
        seg[k + sz] = x;
    }

    void build(){
        for(int k = sz - 1; k > 0; --k){
            seg[k] = f(seg[k << 1], seg[k << 1 | 1]);
        }
    }

    void update(int k, const Monoid &x){
        k += sz;
        seg[k] = x;
        while(k >>= 1){
            seg[k] = f(seg[k << 1], seg[k << 1 | 1]);
        }
    }

    Monoid query(int a, int b){
        Monoid L = M1, R = M1;
        for(a += sz, b += sz; a < b; a >>= 1, b >>= 1){
            if(a & 1)   L = f(L, seg[a++]);
            if(b & 1)   R = f(seg[--b], R);
        }
        return f(L, R);
    }

    Monoid operator[](const int &k) const{
        return seg[k + sz];
    }
};

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

    int h, n;
    cin >> h >> n;
    vector<int> a(n), b(n);
    for(int i = 0; i < n; ++i){
        cin >> a[i] >> b[i];
    }
    
    vector<SegmentTree<ll>> dp(n+1, SegmentTree<ll>(h+1, [](ll a, ll b){return min(a, b);}, 1e+12));
    dp[0].update(h, 0);

    for(int i = 0; i < n; ++i){
        for(int j = h; j >= 0; --j){
            if(dp[i+1][j] > dp[i][j])   dp[i+1].update(j, dp[i][j]);

            ll min_e = dp[i+1].query(j, min(h + 1, j + a[i] + 1));
            if(dp[i+1][j] > min_e + b[i]){
                dp[i+1].update(j, min_e + b[i]);
            }
        }
    }
    cout << dp[n][0] << endl;
}

Measured memory_bytes: 262652
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define x first
#define y second
#define pb push_back
#define pf push_front
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;
const int MAX = 510000;
const int MOD = 1000000007;

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

// テーブルを作る前処理
void COMinit()
{
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++)
	{
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k)
{
	if (n < k)
		return 0;
	if (n < 0 || k < 0)
		return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

bool isprime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
void solve()
{
	int a,b,c;
	cin>>a>>b>>c;
	bool ok=false;
	if(a==b&&b==c){
		ok=false;
	}else if(a==b or b==c or c==a){
		ok=true;
	}
	if(ok){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
}

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


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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  int n;
  cin >> n;
  vi a(n);
  rep(i, n) cin >> a[i];
  int ans = 0;
  rep(i, n) {
    if ((i + 1) % 2 == 1 && a[i] % 2 == 1)
      ans++;
  }
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 3568
def enum_div_pairs(n):
    res = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            res.append((i, n // i))
            if i != n // i:
                res.append((n // i, i))
    return res


pairs = enum_div_pairs(int(input()))
print(min(i + j - 2 for i, j in pairs))


Measured memory_bytes: 3700
import java.io.*;
import java.util.*;

public class Main{
    static MyReader in = new MyReader();
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args){
        String S = in.s();
        int N = S.length();
        int n = N/2;
        int ans = 0;
        for(int i = 0; i < n; i++){
            if(S.charAt(i) != S.charAt(N-1-i)){
                ans++;
            }
        }
        out.println(ans);
        out.flush();
    }

    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s(){
            try{return readLine();}catch(IOException e){return "";}
        }

        String[] ss(){
            return s().split(" ");
        }

        int i(){
            return Integer.parseInt(s());
        }

        int[] ii(){
            String[] ss = ss();
            int[] ii = new int[ss.length];
            for(int j = 0; j < ss.length; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }

        ArrayList<Integer> li(){
            String[] ss = ss();
            ArrayList<Integer> li = new ArrayList<>();
            for(int j = 0; j < ss.length; j++) li.add(Integer.parseInt(ss[j]));
            return li;
        }

        long l(){
            return Long.parseLong(s());
        }

        long[] ll(){
            String[] ss = ss();
            long[] ll = new long[ss.length];
            for(int j = 0; j < ss.length; j++) ll[j] = Long.parseLong(ss[j]);
            return ll;
        }
    }
}


Measured memory_bytes: 22868
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task
    {
        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            int N = in.nextInt();
            int M = in.nextInt();
            int K = in.nextInt();
            int A[] = CPUtils.readIntArray(N, in);
            int B[] = CPUtils.readIntArray(M, in);
            long[] prefix_sum_A = getPrefixSum(A);
            long[] prefix_sum_B = getPrefixSum(B);

            long max = 0;
            for (int i = 0; i < A.length; i++)
            {
                if (prefix_sum_A[i] <= K)
                {
                    int books = i + 1;
                    int low = lowerBound(prefix_sum_B, K - prefix_sum_A[i] + 1);
                    if (low - 1 >= 0)
                        books += low;
                    max = Math.max(max, books);
                }
            }
            for (int i = 0; i < B.length; i++)
            {
                if (prefix_sum_B[i] <= K)
                {
                    int books = i + 1;
                    int low = lowerBound(prefix_sum_A, K - prefix_sum_B[i] + 1);
                    if (low - 1 >= 0)
                        books += low;
                    max = Math.max(max, books);
                }
            }

            if (K >= prefix_sum_B[M - 1])
            {
                max = Math.max(max, M);
            }
            if (K >= prefix_sum_A[N - 1])
            {
                max = Math.max(max, N);
            }
            out.println(max);
        }

        private long[] getPrefixSum(int A[])
        {
            long[] prefix_sum = new long[A.length];
            prefix_sum[0] = A[0];
            for (int i = 1; i < A.length; i++)
            {
                prefix_sum[i] = prefix_sum[i - 1] + A[i];
            }
            return prefix_sum;
        }

        public static int lowerBound(long[] array, long value)
        {
            int low = 0;
            int high = array.length;
            while (low < high)
            {
                int mid = (low + high) / 2;
                if (value <= array[mid])
                {
                    high = mid;
                } else
                {
                    low = mid + 1;
                }
            }
            return low;
        }

    }

    static class CPUtils
    {
        public static int[] readIntArray(int size, Scanner in)
        {
            int[] array = new int[size];
            for (int i = 0; i < size; i++)
            {
                array[i] = in.nextInt();
            }
            return array;
        }

    }
}



Measured memory_bytes: 51824
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define pi pair<ll,ll>
#define pii pair<ll,pi>
#define pb push_back
#define mk make_pair
int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll x, y;
	cin >> x >> y;
	if (abs(x - y) <= 1)
		cout << "Brown" << endl;
	else
		cout << "Alice" << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<map>
#include<set>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
const ll maxn=500500;

int main()
{
   ll r,c,m,man=maxn;
   cin>>r>>c>>m;
   for(ll i=0;i<=c;i++)
    for(ll j=0;j<=r;j++)
    if(i*r+j*c-i*j>=m)
    if(j+i<man)
    man=i+j;
   cout<<man<<endl;

}
/*
2

6
-45 22 42 -16
-41 -27 56 30
-36 53 -37 77
-36 30 -75 -46
26 -38 -10 62
-32 -54 -6 45

6
-45 22 42 -16
-41 -27 56 30
-36 53 -37 77
-36 30 -75 -46
26 -38 -10 62
-32 -54 -6 45
*/


Measured memory_bytes: 256
import std.algorithm;
import std.math;
import std.stdio;

immutable int MOD = 1_000_000_007;
immutable int limit = 100_005;

int [] f;

static this ()
{
	f = new int [limit];
	f[0] = 1;
	foreach (i; 1..limit)
	{
		f[i] = (f[i - 1] * 1L * i) % MOD;
	}
}

int solve (int a, int b)
{
	if (abs (a - b) > 1)
	{
		return 0;
	}
	if (a > b)
	{
		swap (a, b);
	}
	return (f[a] * (1L + (a == b)) * f[b]) % MOD;
}

void main ()
{
	int n, m;
	while (readf (" %s %s", &n, &m) > 0)
	{
		writeln (solve (n, m));
	}
}


Measured memory_bytes: 636
a, b =map(int,input().split())
n=int(input())
m=0
for i in range(n):
    c,d=map(int,input().split())
    if d<=a or c>=b:
        pass
    else:
        m=m+1
if m != 0:
    print(1)
else:
    print (0)


Measured memory_bytes: 5596
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	static class Dropping_Ink {
		void print_FieldNum() {
			int[][] field = new int[10][10];
			for(int[] fi:field) {
				for(int f:fi) {f = 0;}
			}

			while(sc.hasNext()) {
				String[] diInfo = sc.nextLine().split(",", 0);
				int x = Integer.parseInt(diInfo[0]);
				int y = Integer.parseInt(diInfo[1]);
				int inkSize = Integer.parseInt(diInfo[2]);

				switch(inkSize) {
					case 3:
						int[][] point_largeInk =
						{{x, y-2},{x+2, y},{x, y+2},{x-2, y}};
						point_dropInk(field, point_largeInk);
					case 2:
						int[][] point_middleInk =
						{{x+1, y-1},{x+1, y+1},{x-1, y+1},{x-1, y-1}};
						point_dropInk(field, point_middleInk);
					case 1:
						int[][] point_smallInk =
						{{x, y-1},{x+1, y},{x, y+1},{x-1, y}};
						point_dropInk(field, point_smallInk);
				}
				field[y][x]++;
			}

			int num_clearField = 0;
			int max_inkField = 0;
			for(int[] fi:field) {
				for(int f:fi) {
					if(f == 0) num_clearField++;
					if(f > max_inkField) max_inkField = f;
				}
			}
			System.out.println(num_clearField);
			System.out.println(max_inkField);
		}

		void point_dropInk(int[][] field, int[][] dropPoint) {
			for(int i=0; i<4; i++) {
				if(dropPoint[i][0] >= 0 && dropPoint[i][1] >= 0 &&
				   dropPoint[i][0] < 10 && dropPoint[i][1] < 10)
					field[dropPoint[i][1]][dropPoint[i][0]]++;
			}
		}
	}

	public static void main(String[] args) {
		Dropping_Ink di = new Dropping_Ink();
		di.print_FieldNum();
	}
}

Measured memory_bytes: 12000
N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))
A.sort(reverse = True)
F.sort()

max_f = A[0] * F[-1]

def binary_search(min_f, max_f):
	if min_f == max_f:
		return min_f

	mid_f = min_f + (max_f - min_f)//2
	tmp = 0
	for i in range(N):
		tmp += max(0,A[i] - mid_f // F[i])
	
	if tmp <= K:
		return binary_search(min_f, mid_f)
	else:
		return binary_search(mid_f+1, max_f)

print(binary_search(0, max_f))

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


int main() {
    ll n, a[5], r[5], sum=0, cnt2=0;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a[i];
        sum += a[i];
        if(a[i]==2) cnt2++;
    }
    sort(a,a+n);
    if(n <= 3 || a[0] >= n-1){
        cout << sum - n*(n-1)/2 << endl;
    }
    else if(n == 4){
        cout << sum - (3 + (cnt2<4 ? 2:1)) << endl;
    }
    else{
        if(cnt2 == 5){
            cout << 4 << endl;
        }
        else if(cnt2 == 4){
            cout << max(5LL, a[4]+1) << endl;
        }
        else if(1 <= cnt2){
            n -= cnt2;
            cout << sum-cnt2*2-n*(n-1)/2 << endl;
        }
        else if(a[4]==3||a[3]==3){
            cout << sum - 8 << endl;
        }
        else{
            cout << sum - 9 << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3160
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define RREP(i, n) for(int i = n; i >= n; i--)

#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))

#define endl "\n"
#define pb push_back
#define rtn return
#define elif else if

#define INF 2000000000	//int型は2 * 10^9ぐらいまで
#define MOD 1000000007
 
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};

typedef long long ll;
typedef unsigned long long ull;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	int r;
   cin >> r;
   if(r < 1200) cout << "ABC" << endl;
   elif(r < 2800) cout << "ARC" << endl;
   else cout << "AGC" << endl;
   rtn 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
using namespace std;

int combination(int n, int r)
{
    if (r == 0 || r == n)
        return (1);
    else if (r == 1)
        return (n);
    return (combination(n - 1, r - 1) + combination(n - 1, r));
}

int main() {
    long n,m;
    cin >> n >> m;
    int ans=0;
    if(n>=2){
        ans+=combination(n,2);
    }if(m>=2){
        ans+=combination(m,2);
    }
    if(n==2&&m==1){
        printf("1");
        return 0;
    }if(n==1&&m==2){
        printf("1");
        return 0;
    }if(n==1&&m==1){
        printf("0");
        return 0;
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

string dow[] = {
  "Monday",
  "Tuesday",
  "Wednesday",
  "Thursday",
  "Friday",
  "Saturday",
  "Sunday"
};
int month[] = {
  31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
};

int main() {
  int m, d;
  while (cin >> m >> d) {
    if (m == 0) break;
    m--; d--;

    int day = 0;
    for (int i = 0; i < m; i++) {
      day += month[i];
    }
    day += d;
    day += 3;
    day %= 7;

    cout << dow[day] << endl;
  }

  return 0;
}

Measured memory_bytes: 0
{
  const process = (n: number, m: number, gates: number[][]): string => {
    let min = 0
    let max = 100000

    gates.forEach((e) => {
      if (e[0] > min) {
        min = e[0]
      }
      if (e[1] < max) {
        max = e[1]
      }
    })

    if (max - min <= n) {
      if (max - min + 1 < 0) {
        return "0"
      }
      return (max - min + 1).toString()
    }
    return n + ""
  }

  const Main = (input: string): string => {
    const aa: string[] = input.split("\n")
    const [n, m]: number[] = aa[0].split(" ").map((e) => parseInt(e))
    const secondLast: number[][] = aa.slice(1).map((e) => e.split(" ").map((e) => parseInt(e)))

    const res = process(n, m, secondLast)
    console.log(res)
    return res
  }

  Main(require("fs").readFileSync("/dev/stdin", "utf8"))
}



Measured memory_bytes: 50860
#include <stdio.h>

#define MAX(x, y) (((x) > (y)) ? (x) : (y)) //Dont input function with side effect
#define MIN(x, y) (((x) < (y)) ? (x) : (y)) //Dont input function with side effect

int main(){
  long long n, a, b, tp1, tp2, out;
  scanf("%lld %lld %lld",&n,&a,&b);
  if((b-a) % 2 == 0){
    out = (b-a) / 2;
  }
  else {
    tp1 = (b-a-1) / 2;
    tp2 = MIN(a-1, n-b);
    out = tp1 + tp2 + 1;
  }
  printf("%lld", out);
  return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int W, H, N;
  cin >> W >> H >> N;
  vector<vector<int>> xy(W + 1, vector<int>(H + 1, 0));
  for(int i = 0; i < N; i++) {
    int x, y, a;
    cin >> x >> y >> a;
    if(a == 1) {
      for(int i = 0; i < x; i++) {
        for(int j = 0; j < H; j++) {
          xy[i][j] = 1;
        }
      }
    } else if(a == 2) {
      for(int i = x; i < W; i++) {
        for(int j = 0; j < H; j++) {
          xy[i][j] = 1;
        }
      }
    } else if(a == 3) {
      for(int i = 0; i < W; i++) {
        for(int j = 0; j < y; j++) {
          xy[i][j] = 1;
        }
      }
    } else {
      for(int i = 0; i < W; i++) {
        for(int j = y; j < H; j++) {
          xy[i][j] = 1;
        }
      }
    }
  }

  int cnt = 0;
  REP(i, W) REP(j, H) {
    // cout << i << ' ' << j << ' ' << xy[i][j] << endl;
    if(xy[i][j] == 0) cnt++;
  }

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
int main(){
  int n,m;
  cin >> n >> m;
  if(n == m)cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVSORT(v) sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 998244353
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

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

ll modpow(ll n,ll k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(k%2==0){
    ll memo = modpow(n,k/2)%MOD;
    return memo*memo%MOD;
  }else{
    return n * modpow(n,k-1)%MOD;
  }
}

int main(){

  int n;cin>>n;
  int d[n];
  int maxD = 0;

  REP(i,n){
    cin>>d[i];
    maxD = max(maxD,d[i]);
  }

  if(d[0] != 0){
    //cout<<"ji"<<endl;
    cout<< 0;
    return 0;
  }


  int sum[n];

  REP(i,n){
    sum[i] = 0;
  }

  REP(i,n){
    sum[d[i]]++;
  }

  if(sum[0] >1){
    //cout<<"LI"<<endl;
    cout<< 0 ;
    return 0;
  }
  ll ans = 1;

  REP(i,maxD+1){
    if(sum[i]==0){
      //cout<<"KK"<<endl;
      cout<<0;
      return 0;
    }
  }

  /*REP(i,maxD+1){
    cout<<d[i]<<"    "<<sum[i]<<endl;;
  }*/

  REP(i,maxD + 1){
    if(i!=0){
      ans *= modpow(sum[i-1],sum[i]);
      ans %= MOD;
    }
  }
  cout<<ans<<endl;
 

  return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main(void){
    long a,b;
    scanf("%ld %ld", &a, &b);
    if((a+b)%2 == 1){
        printf("IMPOSSIBLE\n");
    }else {
        printf("%ld\n", (a+b)/2);
    }
    return 0;
}

Measured memory_bytes: 128
fun main(args : Array<String>) {
        val l1 = mutableListOf<String>()
        val l2 = mutableListOf<String>()
        val l3 = mutableListOf<String>()
        var c1 = readLine()!!.split(" ").map { it.toInt() }
        var c2 = readLine()!!.split(" ").map { it.toInt() }
        var c3 = readLine()!!.split(" ").map { it.toInt() }
        (0..100).forEach {
            if (!c1.contains(-1)) {
                l1.add(c1.joinToString(""))
                c1 = listOf(c1[0] - 1, c1[1] - 1, c1[2] - 1)
            }
            if (!c2.contains(-1)) {
                l2.add(c2.joinToString(""))
                c2 = listOf(c2[0] - 1, c2[1] - 1, c2[2] - 1)
            }
            if (!c3.contains(-1)) {
                l3.add(c3.joinToString(""))
                c3 = listOf(c3[0] - 1, c3[1] - 1, c3[2] - 1)
            }
        }
        print(if (l1.intersect(l2).intersect(l3).isEmpty()) "No" else "Yes")
}

Measured memory_bytes: 37836
n = int(input())
v = list(map(int,input().split()))

v1 = [0] * (10**5)
v2 = [0] * (10**5)
v1_max_1 = 0
v1_max_2 = 0
v2_max_1 = 0
v2_max_2 = 0

for i in range(0,n,2):
	v1[v[i]-1] += 1

for i in range(1,n,2):
	v2[v[i]-1] += 1

v1_max_index = v1.index(max(v1))
v2_max_index = v2.index(max(v2))

v1.sort(reverse=True)
v2.sort(reverse=True)
v1_max_1 = v1[0]
v2_max_1 = v2[0]
v1_max_2 = v1[1]
v2_max_2 = v2[1]

ans = n - ( v1_max_1 + v2_max_1 )

if ans == 0:
	if v[0] == v[1]:
		print(n//2)
		exit()

if v1_max_index == v2_max_index:
	print(min( n - ( v1_max_2 + v2_max_1 ),n  - ( v1_max_1 + v2_max_2 ) ))
else:
	print(ans)

Measured memory_bytes: 14404
s = input()
MOD = 2019
cnt = [0]*MOD
cnt[0] = 1
cum = 0
for n, x in enumerate(reversed(s)):
    cum = (cum + int(x)*pow(10, n, MOD)) % MOD
    cnt[cum] += 1
print(sum(v*(v-1)//2 for v in cnt))


Measured memory_bytes: 9264
n = int(input())
l = list(input())
r = 0
g = 0
b = 0
for i in range(n):
  r += 1 if l[i] == "R" else 0
  g += 1 if l[i] == "G" else 0
  b += 1 if l[i] == "B" else 0
       
ans = 0
for j in range(n):
  for i in range(j):
    tmp = j-i+j
    if tmp >= n:
      continue
    if l[i] != l[j] and(l[i] != l[tmp]) and(l[j] != l[tmp]):
      ans -= 1
      
print(r * b * g + ans)

Measured memory_bytes: 9252
import java.util.*;

public class Main {

    private static long[] vim;
    private static int n;
    private static int k;
    private static PriorityQueue<Long> p;
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        k = in.nextInt();
        p = new PriorityQueue<>();
        vim = new long[n];
        for(int i=0;i<n;i++){
            vim[i] = in.nextLong();
        }
        long max=0;
        //i表示左边取的操作的次数
        for(int i=0;i<=k;i++){
            //j表示右边取操作的次数，左右两边取的次数最多不超过k次，或者不超过数的个数
            for(int j=0;(i+j)<=Math.min(n,k);j++){
                max=Math.max(max,solute(i,j));
            }
        }
        System.out.println(max);
    }
    public static long solute(int l,int r){
        p.clear();
        long sum = 0;
        for(int i=0;i<l;i++){//放入左边的l个数字
            p.add(vim[i]);
            sum +=vim[i];
        }
        for(int j=0;j<r;j++){//放入右边的r个数字
            p.add(vim[n-j-1]);
            sum+=vim[n-j-1];
        }
        //考虑放的操作，因为取用了l+r次，所以最多可以放(k-l-r）次，直接选择最小的(k-l-r)个负数放
        int i = 0;
        while(!p.isEmpty() && p.peek()<0 && i<k-l-r){
            sum-=p.poll();
            i++;
        }
        return sum;
    }

}


Measured memory_bytes: 24276
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1LL << 60;
const int MOD = 1000000007;

template <typename T>
void print(const T &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

const int MAX = 100010;

int n;
int h[MAX];
int dp[MAX];
bool seen[MAX];

ll f(ll n)
{
    if (seen[n])
    {
        return dp[n];
    }
    seen[n] = true;
    if (n == 0)
    {
        return dp[0] = 0;
    }
    else if (n == 1)
    {
        return dp[1] = abs(h[1] - h[0]);
    }
    else
    {
        return dp[n] = min(f(n - 2) + abs(h[n] - h[n - 2]), f(n - 1) + abs(h[n] - h[n - 1]));
    }
}

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> h[i];
    }
    cout << f(n - 1) << endl;
    return 0;
}

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


int main() {
    vector<vector<int>> v(3,vector<int>(3,0));
    rep(i,3){
        rep(j,3){
            cin >> v.at(i).at(j);
        }
    }
    int n=v.at(0).at(1)-v.at(0).at(0);
    int l=v.at(0).at(2)-v.at(0).at(1);
    string ans="Yes";
    rep2(i,3){
        if(n!=v.at(i).at(1)-v.at(i).at(0)) {
            ans="No";
            cout << ans << endl;
            return 0;
        }
    }
    rep2(i,3){
        if(l!=v.at(i).at(2)-v.at(i).at(1)) {
            ans="No";
            cout << ans << endl;
            return 0;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String args[]){
		 Scanner sc = new Scanner(System.in);	   
		int result=0;
		 for(int i=0;i<5;i++){
			int a=sc.nextInt();
			if(a<40) a=40;
			 result+=a;
		}
		 System.out.println(result/5);
		}
}

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

int main() {
  int N,K;
  string S;
  cin >> N >> S >> K;
  char a = S.at(K-1);
  for(int i=0;i<N;i++){
    if(S.at(i) != a){
      S.at(i) = '*';
    }
  }
  cout << S << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <math.h>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
#include <random>
#include <deque>
#include <bitset>
#include <string>
#include <queue>
#include <complex>

//#define int long long

#define mp(a, b) make_pair(a, b)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

#define endl '\n'

using namespace std;
typedef long long ll;
typedef long double ld;

mt19937 mrand(random_device{}());

double PI = acos((double)-1);
const ld eps = 1e-7;
const ll inf0 = 1023 * 1024 * 1024;
const ll inf = inf0 * inf0;
//const ll mod = 1e9 + 9;
const ll mod = 998244353;

void solve();
void scan();

signed main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
	cout << fixed; cout.precision(15);
	solve();
	return 0;
}

void solve() {
	string s; cin >> s;
	if (s[2] == s[3] && s[4] == s[5]) cout << "Yes\n";
	else cout << "No\n";
	return;
}

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

#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<ll,ll>
using namespace std;

const ll maxn=1e5+500;
const ll inf=1e17+7;
const ll mod=998244353;


ll find_d(ll n){
    ll ans=0;
    while(n){
        ans+=n%10;
        n/=10;
    }
    return ans;
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n;
    cin>>n;
    ll ans=inf;
    for(ll i=1;i<n;i++){
        ans=min(ans,find_d(i)+find_d(n-i));
    }
    cout<<ans;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define dbug(x) cout<<#x<<"="<<x<<endl
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
int n,a;
double ans;
int main() {
	//freopen("1.txt","r",stdin);
	read(n);
	while (n--) {
		read(a);
		ans+=1.0/a;
	}
	printf("%.7lf\n",1.0/ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define RI register int
typedef long long LL;
#define int LL

#define FILEIO(name) freopen(name".in", "r", stdin), freopen(name".out", "w", stdout);

using namespace std;

char buf[1000000], *p1 = buf, *p2 = buf;
inline char gc() {
  if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin);
  return p1 == p2 ? EOF : *(p1++);
}
template <class T> inline void read(T &n) {
  n = 0; RI ch = gc(), f;
  while ((ch < '0' || ch > '9') && ch != '-') ch = gc();
  f = (ch == '-' ? ch = gc(), -1 : 1);
  while (ch >= '0' && ch <= '9') n = n * 10 + (ch ^ 48), ch = gc();
  n *= f;
}

int const MAXN = 2e5 + 5;
int a[MAXN];
map <int, int> mp;

signed main() {

#ifdef LOCAL
  FILEIO("a");
#endif

  int n; read(n);
  for (RI i = 1; i <= n; ++i) read(a[i]);
  LL ans = 0;
  for (RI i = 1; i <= n; ++i) {
    ans += mp[i - a[i]];
    ++mp[a[i] + i];
  }
  printf("%lld\n", ans);

  return 0;
}

// created by Daniel yuan


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

int main(void){
    int x,y;
    cin >> x >> y;
    bool flag = false;
    rep(i,x){
        rep(j,x){
            if(i*2 + j*4 == y && i+j == x){
                flag = true;
                cout << "Yes" << endl;
                break;
            }else if(i*2 == y && i == x){
                flag = true;
                cout << "Yes" << endl;
                break;
            }else if(j*4 == y && j == x){
                flag = true;
                cout << "Yes" << endl;
                break;
            }
        }
        if(flag == true){
            break;
        }
    }    
    if(flag == false){
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3624