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


int main()
{
    int N;
    cin >> N;
    vector<long long> A(N), B(N);
    for( int i = 0; i < N; ++i ) cin >> A[i] >> B[i];


    long long ans = 0;
    for( int i = 0; i < N; ++i ){
        ans -= B[i];
        A[i] += B[i];
    }

    sort( A.begin(), A.end(), greater<long long>() );
    for( int i = 0; i < N; i += 2 ) ans += A[i];
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>

int main(void)
{
	int n,m,i,j;
	int A[100][100] = {{0}};
	int b[100] = {0};
        int c[100] = {0};

	scanf("%d %d",&n, &m);
	for(i = 0;i < n;i++){
		for(j = 0;j < m;j++){
			scanf("%d",&A[i][j]);
		}
	}
	for(j = 0;j < m;j++){
		scanf("%d",&b[j]);
	}
        for(i = 0;i < n;i++){
		for(j = 0;j < m;j++){
			c[i] += A[i][j] * b[j];
		}
	}
	for(i = 0;i < n;i++){
		printf("%d\n",c[i]);
	}
	return 0;
}

Measured memory_bytes: 648
#include <iostream>
#include <cmath>
using namespace std;
int main() {
int n,a=0,b=0;
string s;
cin>>n>>s;
for(int i=0;i<n;i++){
  if(s[i]=='R'){
    a+=1;
  }
}
for(int i=a;i<n;i++){
  if(s[i]=='R'){
b+=1;
  }
}
cout<<b;
}

Measured memory_bytes: 3720
# abc123_a.py
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())

l=[]
# l=[a,b,c,d,e]
l.append(a)
l.append(b)
l.append(c)
l.append(d)
l.append(e)

size=len(l)
for i in range(size):
 for j in range(i,size):
  if i == j:
   continue
  if (l[j]-l[i]) > k:
   print(":(")
   exit()

print("Yay!")


Measured memory_bytes: 3064
#B

n = int(input())

a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

a.insert(0,0)
b.insert(0,0)
c.insert(0,0)
ans = sum(b)

for i in range(n+1):
    if a[i] - a[i-1] ==1:
        ans += c[a[i-1]]
print(ans)
    

Measured memory_bytes: 3064
Imports System.Console
Module Module1
    Dim ans As Int64
    Dim n, k As Int64
    Sub Main()
        Dim d, x As Int64
        Dim s() As String = ReadLine().Split
        x = s(0)
        k = s(1)
        d = s(2)
        x = Math.Abs(x)
        If x / d >= k Then
            ans = x - (k * d)
        Else
            d *= 2
            If d < x Then
                ans = x Mod d
            Else
                ans = x
            End If
            If ans >= d - ans Then
                ans = d - ans
            End If
            If k Mod 2 = 1 Then
                ans += d \ 2
                If ans >= Math.Abs(ans - d) Then
                    ans -= d
                    ans = Math.Abs(ans)
                End If
            End If
        End If
        WriteLine(ans)
        ReadLine()
    End Sub
End Module


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

int main(){
  int a,c;
  cin>>a;
  vector<int> b(a);
  for(int i=0;i<a;i++)
    cin>>b.at(i);
  sort(b.begin(),b.end());
  b.at(b.size()-1)/=2;
  c=0;
  for(int i=0;i<a;i++)
    c+=b.at(i);
  cout<<c<<endl;
}

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

using namespace std;

using ll = long long;

int main() {
   ios_base::sync_with_stdio(false); cin.tie(nullptr);
   int N;
   cin >> N;
   vector<ll> V(N + 1), W(N + 1);
   for (int i = 1; i <= N; ++i) {
      cin >> V[i] >> W[i];
   }
   const int lg = __lg(N) / 2;
   vector<int> dists(N + 1);
   for (int i = 2; i <= N; ++i) {
      dists[i] = dists[i / 2] + 1;
   }
   vector<vector<ll>> dp(N + 1);
   for (int v = 1; v <= N; ++v) {
      if (dists[v] > lg) continue;
      vector<int> pars = {v};
      while (pars.back() > 1) pars.emplace_back(pars.back() / 2);
      int sz = pars.size();
      dp[v].resize(100100);
      for (int mask = 0; mask < 1 << sz; ++mask) {
         ll totV = 0;
         ll totW = 0;
         for (int i = 0; i < sz; ++i) {
            if (mask & (1 << i)) {
               totV += V[pars[i]];
               totW += W[pars[i]];
            }
         }
         if (totW < dp[v].size()) {
            dp[v][totW] = max(dp[v][totW], totV);
         }
      }
      for (int i = 1; i < 100100; ++i) dp[v][i] = max(dp[v][i], dp[v][i - 1]);
   }
   int Q;
   cin >> Q;
   for (int i = 0; i < Q; ++i) {
      int v; ll L; cin >> v >> L;
      if (dists[v] <= lg) {
         cout << dp[v][L] << "\n";
      } else {
         vector<int> pars = {v};
         while (dists[pars.back()] > lg + 1) {
            pars.emplace_back(pars.back() / 2);
         }
         int up = pars.back() / 2;
         int sz = pars.size();
         ll ans = 0;
         for (int mask = 0; mask < (1 << sz); ++mask) {
            ll totV = 0;
            ll totW = 0;
            for (int i = 0; i < sz; ++i) {
               if (mask & (1 << i)) {
                  totV += V[pars[i]];
                  totW += W[pars[i]];
               }
            }
            if (totW <= L) {
               ans = max(ans, dp[up][L - totW] + totV);
            }
         }
         cout << ans << "\n";
      }
   }
}


Measured memory_bytes: 415044
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x -> left != NIL){
    x = x -> left;
  }
  return x;
}

Node treeSearch(Node u, int k){
  if(u == NIL || k == u -> key){
    return u;
  }
  if(k < u -> key){
    return treeSearch(u -> left,k);
  }
    else return treeSearch(u -> right,k);
}

Node treeSuccessor(Node x){
  Node y;
  if(x -> right != NIL){
    return treeMinimum(x -> right);
  }
    y = x -> parent;
    while(y != NIL && x == y -> right){
      x = y;
      y = y -> parent;
    }
    return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(x != NIL){
    y = x;
    if(z -> key < x -> key){
      x = x -> left;
    }
    else x = x -> right;
  }
  z -> parent = y;
  if(y == NIL){
    root = z;
  }
  else if(z -> key < y -> key){
    y -> left =z;
  }
  else y -> right = z;
}

void inorder(Node u){
  if(u -> left != NIL){
    inorder(u -> left);
  }
  printf(" %d",u -> key);

  if(u -> right != NIL){
    inorder(u -> right);
  }
}

void preorder(Node u){
  printf(" %d",u ->key);

  if(u -> left != NIL){
    preorder(u -> left);
  }
  if(u -> right != NIL){
    preorder(u -> right);
  }
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

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

#define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* short */
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define ALL(v) begin(v), end(v)

/* REPmacro */
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define RFOR(i, s, n) for (int i = (s); i >= (n); i--)
#define rep(i, n) FOR(i, 0, n)
#define repi(i, n) FOR(i, 1, n + 1)
#define rrep(i, n) RFOR(i, n - 1, 0)
#define rrepi(i, n) RFOR(i, n, 1)

/* debug */
#define pp(v) cerr << #v "=" << (v) << endl;

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using vs = vector<string>;
using Graph = vvi;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* iostream */
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
#define UNIQUE(v) v.erase( unique(ALL(v)), v.end() );
#define TIME system("date +%M:%S.%N")
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }
template<class T> T div_ceil(const T &a, const T &b) { return (a + b - 1) / b; }

int solve(int n, int m) {
  if (2*n > m) return m/2; // Sが余っている

  int ans = n;
  m -= 2*n;
  ans += m/4;
  return ans;
}

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

  int ans = solve(n,m);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
const int mm=2e5+100;
ll d[mm];
ll vis[mm];
int main()
{
	ll n,m,i,j,x,k;
    string s;
    cin>>n;
    cin>>s;
    if(s.size()<=n)
    {
    	cout<<s<<endl;
	}
	else
	{
    for(i=0;i<n;i++)
    cout<<s[i];
    cout<<"..."<<endl; 
}}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string btos(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int s;cin>>s;
  cout<<"ABC"<<s<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner
import scala.collection.Searching._

import scala.annotation.tailrec

class IUnionFind(val size: Int) {

  private case class Node(var parent: Option[Int], var treeSize: Int)

  private val nodes = Array.fill[Node](size)(new Node(None, 1))

  def union(t1: Int, t2: Int): IUnionFind = {
    if (t1 == t2) return this

    val root1 = root(t1)
    val root2 = root(t2)
    if (root1 == root2) return this

    val node1 = nodes(root1)
    val node2 = nodes(root2)

    if (node1.treeSize < node2.treeSize) {
      node1.parent = Some(t2)
      node2.treeSize += node1.treeSize
    } else {
      node2.parent = Some(t1)
      node1.treeSize += node2.treeSize
    }
    this
  }

  def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)

  @tailrec
  private def root(t: Int): Int = nodes(t).parent match {
    case None => t
    case Some(p) => root(p)
  }
}


object Main {
  def solve(sc: => Scanner): Unit = {
    val S = sc.next
    var ans = 0
    var now = 'A'
    for (i <- 0 until S.length) {
      if (S(i) <= now) {
        ans += 1
      }
      now = S(i)
    }
    println(ans)
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)

    solve(sc)
  }
}

Measured memory_bytes: 45088
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


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;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll 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;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

vector<pair<char,ll>> runlength(string s,vector<pair<char,ll>> p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
    return p;
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
  return p;
}


ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}



/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll a,b;
  cin>>a>>b;
  cout<<a*b<<' '<<(a+b)*2<<endl;
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{  ll n,m=0,i,la=0;

   cin>>n;
  for(i=1;i<pow(10,9);i++)
 { m=m+i;la++;
    if(m>=n)break;

 }
  cout<<la<<endl;



}


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

int main() {
	int K;
	cin >> K;
	string S;
	cin >> S;
	if ((int)S.size() <= K) {
		cout << S << endl;
	} else {
		string T = S.substr(0, K);
		cout << T << "..." << endl;
	}
}

Measured memory_bytes: 3604
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;
string str[52];
int w[52][30];
int main(){
    cin.sync_with_stdio(false);
    int n;
    while(cin>>n){
        for(int i=0;i<n;i++){
            cin>>str[i];
        }
        memset(w,0,sizeof(w));
        for(int i=0;i<n;i++){
            for(int j=0;j<str[i].length();j++){
                w[i][str[i][j]-'a']++;
            }
        }
        for(int i=0;i<26;i++){
            w[51][i]=10000000;
            for(int j=0;j<n;j++){
                w[51][i]=min(w[51][i],w[j][i]);
            }
        }
        string ans="";
        for(int i=0;i<26;i++){
            while(w[51][i]){
                ans+=char('a'+i);
                w[51][i]--;
            }
        }
        cout<<ans<<endl;
    }
return 0;
}


Measured memory_bytes: 256
import Control.Monad
import Control.Applicative

swap :: (Int, Int, Int) -> Int -> Int
swap (x, y, z) n
  | x' == y' && y' == z'        = -1
  | odd x' || odd y' || odd z'  = n + 1
  | otherwise                   = swap (x', y', z') (n + 1)
  where x' = (x + y) `div` 2
        y' = (y + z) `div` 2
        z' = (z + x) `div` 2

main = do
  [a, b, c] <- map read . words <$> getLine
  let taple = (a, b, c)
  if odd a || odd b || odd c then putStrLn "0"
                             else putStrLn $ show $ swap taple 0


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

long long MOD=1000000007;

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

void COMinit(){
	fac[0]=fac[1]=1;
	finv[0]=finv[1]=1;
	inv[1]=1;
	for(int i=2;i<2000002;i++){
		fac[i]=fac[i-1]*i%MOD;
		inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
		finv[i]=finv[i-1]*inv[i]%MOD;
	}
}
 
long long COM(int n,int k){
	if(n<k)return 0;
	if(n<0 || k<0)return 0;
	return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

int main(){
	COMinit();
	int n,k;
	cin >> n >> k;
	
	long long ans=0;
	
	for(int i=0;i<=min(n,k);i++){
		long long add=COM(n,i);
		add*=COM(n-i-1+i,i);
		add%=MOD;
		ans+=add;
		ans%=MOD;
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 47104
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<cstring>
#include<string>
#include<iomanip>
#include<map>
#include<fstream>
#include<queue>

using namespace std;

int main()
{
	char s[3][11];
	for (int i = 0; i < 3; i++) {
		cin >> s[i];
	}
	for (int i = 0; i < 3; i++) {
		cout << (char)toupper(s[i][0]);
	}
	cout << endl;
}

Measured memory_bytes: 256
prime=(2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997)

n=int(input())
ans=1
for p in prime:
    k=1
    m=0
    while p**k <=n:
        m += n//p**k

        k +=1

    ans *= m+1

print(ans % (10**9+7))


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
#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 << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define pr(s) cout << (s) << '\n'
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s, t;
    cin >> s >> t;
    int ns = s.size();
    int nt = t.size();
    int ans = 1001001001;
    rep(i, ns) {
        int z = i + nt - 1;
        if (z>=ns) continue;
        int res = 0;
        rep(j, nt) {
            if (t[j]!=s[j+i]) res++;
        }
        chmin(ans, res);
    }
    
    
    pr(ans);
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

int main() {
    int a;
    cin >> a;

    int b = a % 10;

    if (b == 2 || b == 4 || b == 5 || b == 7 || b == 9) {
        cout << "hon";
    } else if (b == 0 || b == 1 || b == 6 || b == 8) {
        cout << "pon";
    } else {
        cout << "bon";
    }


    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define endl '\n';
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------

struct SegmentTree{
  private:
  int n;
  vector<int> node;
  public:
  SegmentTree(vector<int> v){
    int sz = v.size();
    n = 1;
    while(n<sz) n *= 2;
    node.resize(2*n-1,INT_MAX);
    for(int i=0; i<sz; i++) node[i+n-1] = v[i];
    for(int i=n-2; i>=0; i--) node[i] = min(node[2*i+1],node[2*i+2]);
  }
  void update(int x,int val){
    x += (n-1);
    node[x] = val;
    while(x>0){
      x = (x-1)/2;
      node[x] = min(node[2*x+1],node[2*x+2]);
    }
  }
  int getmin(int a,int b,int k=0,int l=0,int r=-1){
    if(r < 0) r = n;
    if(r <= a || b <= l) return INT_MAX;
    if(a <= l && r <= b) return node[k];
    int vl = getmin(a,b,2*k+1,l,(l+r)/2);
    int vr = getmin(a,b,2*k+2,(l+r)/2,r);
    return min(vl,vr);
  }
};

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,q;
  cin >> n >> q;
  SegmentTree seg(vector<int>(n,(1LL<<31)-1));
  for(int i=0; i<q; i++){
    int id;
    cin >> id;
    if(id == 1){
      int x,y;
      cin >> x >> y;
      cout << seg.getmin(x,y+1) << endl;
    }else{
      int x,y;
      cin >> x >> y;
      seg.update(x,y);
    }
  }
  return 0;
}



Measured memory_bytes: 4084
using Atcoder;
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var secondLine = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            int result = int.MaxValue;
            for (int i = 0; i < N; i++)
            {
                var s1 = secondLine.Take(i + 1).Sum();
                int s2 = 0;
                for (int j = i + 1; j < N; j++)
                {
                    s2 += secondLine[j];
                }

                if (Math.Abs(s1 - s2) <= result)
                {
                    result = Math.Abs(s1 - s2);
                }
            }
            Console.WriteLine(result);
        }

    }

    //var N = int.Parse(Console.ReadLine());
    //var S = Console.ReadLine();
    //var K = Console.ReadLine().Split(' ');
    //var N = int.Parse((K[0]));
    //var M = int.Parse((K[1]));
    //var firstLine = Console.ReadLine().Split(' ').Select(int.Parse);
}

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

int n,a[105],b[105];
int ans;

int main()
{
	cin>>n;
	for(int i=1;i<n;cin>>b[i++]);
	ans = b[1];
	for(int i=2;i<n;i++)
	{
		a[i] = min(b[i],b[i-1]);
		ans += a[i];
	}
	ans += b[n-1];
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    int S,h,m,s;
    cin>>S;
    h=S/3600;
    m=(S-3600*h)/60;
    s=(S-3600*h-60*m);
    cout<<h<<":"<<m<<":"<<s<<endl;
    return 0;
}



Measured memory_bytes: 3108
def func (x):
	if x:
		return int(x)*func(x-1)
	else:
		return (1)
def comb (x,y):
	return func(x)//func(x-y)//func(y)

import sys
sys.setrecursionlimit(10000)
w,h,ax,ay,bx,by=map(int,input().split())
dx=min(w-abs(ax-bx),abs(ax-bx))
dy=min(h-abs(ay-by),abs(ay-by))
ans=1
if dx*2==w:ans*=2
if dy*2==h:ans*=2
ans*=comb(dx+dy,dx)
print(ans%100000007)

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

int main(){
    int n;
    while (cin >> n){
        if(n==0)
            break;
        int a[n][2];
        for(int i=0;i<n;i++){
            cin >> a[i][0] >> a[i][1];
        }

        //ハント開始
        int x=10; int y=10; //ロボットの座標
        char c;
        int l;
        int f=0;
        int m; cin >> m;
        for(int i=0;i<m;i++){
            cin >> c >> l;
            switch (c){
                case 'N': for(int j=1;j<=l;j++){
                            for(int k=0;k<n;k++){
                                if(a[k][0]==x && a[k][1]==y+j){
                                    f++;
                                    a[k][0]=100;
                                }
                            }
                        }
                        y+=l;
                        break;
                case 'S': for(int j=1;j<=l;j++){
                            for(int k=0;k<n;k++){
                                if(a[k][0]==x && a[k][1]==y-j){
                                    f++;
                                    a[k][0]=100;
                                }
                            }
                        }
                        y-=l;
                        break;
                case 'E': for(int j=1;j<=l;j++){
                            for(int k=0;k<n;k++){
                                if(a[k][0]==x+j && a[k][1]==y){
                                    f++;
                                    a[k][0]=100;
                                }
                            }
                        }
                        x+=l;
                        break;
                case 'W': for(int j=1;j<=l;j++){
                            for(int k=0;k<n;k++){
                                if(a[k][0]==x-j && a[k][1]==y){
                                    f++;
                                    a[k][0]=100;
                                }
                            }
                        }
                        x-=l;
                        break;
            }

        }
        if(n==f)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
}

Measured memory_bytes: 1152
#include <iostream>

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

using namespace std;

int main() {
	int X, Y;

	cin >> X >> Y;
	bool flg = false;
	rep(i, X+1) {
		if (i * 2 + (X - i) * 4 == Y) {

			cout << "Yes";
			flg = true;
			break;
		}

	}

	if (!flg)cout << "No";


	return 0;
}

Measured memory_bytes: 3628
N, Y = list(map(int, input().split()))
resx = -1
resy = -1
resz = -1
for x in range(N+1):
    for y in range(N+1-x):
        z = N -x -y
        total = 10000*x + 5000*y + 1000*z
        if total == Y:
            resx = x
            resy = y
            resz = z
print(resx, resy, resz, sep=' ')

Measured memory_bytes: 9200
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()

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

const ll inf = 2e18;
const ll mod = 1e9 + 7;
const ll N = 3e3 + 1;
const ll M = 2e5 + 5;

int r, c, k, v[N][N];
ll dp[N][N][4];

ll solve(int i, int j, int num) {
    if (i == r or j == c) return 0;
    if (dp[i][j][num] != -1) return dp[i][j][num];

    ll ans = 0;
    ans = max(ans, solve(i + 1, j, 0));
    ans = max(ans, solve(i, j + 1, num));

    if (num < 3 and v[i][j] != 0) {
        ans = max(ans, solve(i + 1, j, 0) + (ll)v[i][j]);
        ans = max(ans, solve(i, j + 1, num + 1) + (ll)v[i][j]);
    }

    return dp[i][j][num] = ans;
}

void code() {
    cin >> r >> c >> k;

    for (int i = 1; i <= k; i++) {
        int x, y, cst;
        cin >> x >> y >> cst;
        v[x - 1][y - 1] = cst;
    }

    memset(dp, -1, sizeof(dp));

    cout << solve(0, 0, 0) << "\n";

}

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

    int t = 1;
    // cin>>t;

    while (t-- > 0) {
        code();
    }
}

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



int main() {

    int n; cin >> n;
    int count = 0;
    vector<int> m(3,0);
    vector<ll> a(n);
    rep(i,n) cin >> a[i];

    rep(i,n){
        if(a[i]%2 != 0) m[0] ++;
        else if(a[i]%4 == 0) m[1]++;
        else m[2] ++;
    }

    if(m[2] != 0) m[0] ++;
    if(m[1] >= m[0]-1) cout << "Yes";
    else cout << "No";
    return 0;
}











Measured memory_bytes: 3972
#include <iostream>
#include <stack>
#include <string.h>
using namespace std;

int main () {
  stack<char> box;
  string h;
  cin >> h;
  box.push(h[0]);
  for (int i = 1; i < h.size(); i++) {  
    if (box.empty() == false) {
      char top = box.top();
      if ((top == '1' && h[i] == '0') || (h[i] == '1' && top == '0')) {
        box.pop();  
      }
      else {
        box.push(h[i]);  
      } 
    }
    else {
      box.push(h[i]);  
    }
  }
  cout << h.size() - box.size() << endl;
}

Measured memory_bytes: 1144
import sys
import math
import itertools
import collections

def solve(N,M,K,A,B):
    accumA = [0,A.pop(0)]
    accumB = [0,B.pop(0)]
    for a in A:
        accumA.append(accumA[-1] + a)
    for b in B:
        accumB.append(accumB[-1] + b)
    ans = 0
    j = M
    for i in range(N + 1):
        if accumA[i] > K:
            break
        while accumB[j] > K - accumA[i]:
            j -= 1
        ans = max(ans,i + j)
    return ans

def main():
    N,M,K = map(int,input().split())
    A = list(map(int,input().split()))
    B = list(map(int,input().split()))
    # solve()
    print(solve(N,M,K,A,B))

if __name__ == "__main__":
    main()




Measured memory_bytes: 47832
def isYear(s):
    if 0 <= int(s) <= 99:
        return True
    else:
        return False

def isMonth(s):
    if 1 <= int(s) <= 12:
        return True
    else:
        return False

S = input()
f_s = S[:2]
b_s = S[2:]

YYMM = False
MMYY = False

if isYear(f_s) and isMonth(b_s):
    YYMM = True
if isMonth(f_s) and isYear(b_s):
    MMYY = True

if YYMM and MMYY:
    res = "AMBIGUOUS"
elif YYMM:
    res = "YYMM"
elif MMYY:
    res = "MMYY"
else:
    res = "NA"

print(res)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
const ll M = 1e15 + 7;
int si[] = {-1, 0, 1, 0};
int sj[] = {0, -1, 0, 1};

int main() {
  int n;
  cin >> n;
  vector<ll> a(3*n);
  rep(i,3*n) cin >> a[i];

  priority_queue<ll,vector<ll>,greater<ll>> q1;
  ll s1 = 0;
  rep(i,n){
    q1.push(a[i]);
    s1 += a[i];
  }

  vector<ll> v1;
  v1.push_back(s1);
  for (int k = n; k < 2*n; k++){
    if (q1.top() < a[k]){
      s1 -= q1.top();
      s1 += a[k];
      q1.pop();
      q1.push(a[k]);
    }
    v1.push_back(s1);
  }

  priority_queue<ll> q2;
  ll s2 = 0;
  for (int i = 2*n; i < 3*n; i++) {
    q2.push(a[i]);
    s2 += a[i];
  }

  vector<ll> v2;
  v2.push_back(s2);
  for (int k = 2*n-1; k > n-1; k--){
    if (q2.top() > a[k]){
      s2 -= q2.top();
      s2 += a[k];
      q2.pop();
      q2.push(a[k]);
    }
    v2.push_back(s2);
  }

  reverse(v2.begin(), v2.end());

  ll ans = -1 * M;
  rep(i,v1.size()) ans = max(ans, v1[i]-v2[i]);
  cout << ans << endl;

  return 0;
}


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

using namespace std;

#define forn(i, s, f) for(int i = (s); i <= (f); ++i)
#define for1(i, f, s) for(int i = (f); i >= (s); --i)
#define fora(i, x) for (auto i : x)
#define show(x) cout << #x << " = " << x << " ";
#define skip continue;
#define pb push_back
#define _1 first
#define _2 second

typedef long long ll;

const int N3 = 1e3 + 5;
const int N4 = 1e4 + 5;
const int N5 = 1e5 + 5;
const int N6 = 1e6 + 5;
const int N7 = 1e7 + 5;
const int N8 = 1e8 + 5;
const int N9 = 1e9 + 5;
const int mod = N9 + 2;

int a, b, c;

int main()
{
//    freopen("knight.in", "r", stdin);
//    freopen("knight.out", "w", stdout);
    cin >> a >> b >> c;
    cout << min({a, b, c}) + ((a + b + c) - max({a, b, c}) - min({a, b, c})); 
}


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

int main(){
    long long int  a, v, i;
    cin>>i>>a>>v;
    if(a==v || a+i==v || a+i>v || a>v || a+i+1==v || a+i+1>v)
        cout<<a+v<<endl;
    else if (a+i+1<v)
        cout<<a+i+1+a<<endl;
    
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int dp[100005][13];
char s[100005];
const int mod=1000000007;
int main(){
	int a,b;
//	while(scanf("%d",&a)!=EOF){
//		cout<<a%13<<endl;
//	}
//	for(int i=0;i<=99;++i){
//		cout<<i<<"       "<<i%13<<endl;
//		if(i%10==9) cout<<endl<<endl;
//		
//	}
	scanf("%s",s+1);	
	int lens=strlen(s+1);
	memset(dp,0,sizeof(dp));
	dp[0][0]=1;
	
	for(int i=1;i<=lens;++i){
		for(int j=0;j<=12;++j){
			if(dp[i-1][j]){
				if(s[i]=='?'){
					int x;
					for(int g=0;g<=9;++g){
						x=(j*10+g)%13;
						dp[i][x]+=dp[i-1][j];
						dp[i][x]%=mod;
					}
					
				}
				else{
					int x=(j*10+s[i]-'0')%13;
						dp[i][x]+=dp[i-1][j];	
						dp[i][x]%=mod;
				}
			}			
		}
		
	}
	cout<<dp[lens][5]<<endl;
	
	return 0;
}

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

int main(){
    int n;
    scanf("%d", &n);
    char s[200];
    scanf("%s", s);
    n = strlen(s);
    char a[100], b[100];
    if (n%2 == 0){
        for(int i = 0; i < n; ++i){
            if (i < n/2){
                a[i] = s[i];
                //printf("AAA %c %c\n", a[i],s[i]);
            } else{
                b[i-(n/2)] = s[i];
                //printf("BBB %c %c\n", b[i-(n/2)],s[i]);
                //printf("%d %d\n", i-(n/2), i);
            }
        }
        a[n/2] = '\0';
        b[n/2] = '\0';

    }
    if (n%2 == 0){
        if (strcmp(a,b) == 0){
            printf("Yes\n");
        } else{
            printf("No\n");
        }
    } else{
        printf("No\n");
    }
    //printf("%d\n",~strcmp(a,b));
    return 0;
}


Measured memory_bytes: 128
#include <iostream>


using namespace std;
int a[100000000];
int largest,n,l,r;
int i,x;
int maxHeapify(int a[],int i){
    l=2*i+1;
    r=2*i+2;
    if(l<=n && a[l]>a[i]){
        largest =l;
    }
    else{
        largest =i;
    }
    if(r<=n && a[r]>a[largest]){
        largest =r;
    }
    if(largest!=i){
        x=a[i];
        a[i]=a[largest];
        a[largest]=x;
        maxHeapify(a,largest);
    }
    return 0;
}
void buildMaxHeap(int a[]){
    for(int i=n/2;i>=0;i--){
        maxHeapify(a,i);
    }
}
int insert(int a[],int k){
    int i=n++;
    a[i]=k;
    while(i&&a[(i-1)/2]<a[i]){
        swap(a[(i-1)/2],a[i]);
        i=(i-1)/2;
        }
    return 0;
}
int extract(int a[]){
    int ans=a[0];
    a[0]=a[--n];
    maxHeapify(a,0);
    return ans;
}
int main(void){
    string s;
    int n=0;
    int k;
    while(1){
        cin>>s;
        if(s=="insert"){
            cin >> k;
            insert(a,k);
        }
        if(s=="extract"){
            cout << extract(a) << endl;
        }
        if(s=="end") break;
    }
}


Measured memory_bytes: 7124
import math

nums = []
last_pos = 0
total = 0

def score(n):
    # 1, 2, 3, ... 9, 0
    if n % 10 == 0:
        return 10
    return n % 10

def ceil(n):
    return math.ceil(n / 10) * 10

for i in range(5):
    t = int(input())
    nums.append(t)
    if score(t) < score(nums[last_pos]):
        last_pos = i

for i in range(5):
    if i == last_pos:
        continue
    total += ceil(nums[i])

total += nums[last_pos]

print(total)


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

int main(){
    long long l,r;
    cin >> l >> r;
    r = min(r,l+2019);
    int ans = 2019;
    for (long long i = l;i <= r;i++){
        for (long long j = i+1;j <= r;j++){
            int m = (i*j)%2019;
            ans = min(ans,m);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

void cal(int dp[],int visited[],vector<int > v[],int start){
	visited[start] = 1;
	for(int i=0;i<v[start].size();i++){
		// if(visited[v[start][i]] == 1 && dp[v[start][i]]<dp[start]+1){
		// 	dp[v[start][i]] = max(dp[v[start][i]],dp[start]+1);
		// 	cal(dp,visited,v,v[start][i]);
		// }
		if(visited[v[start][i]]!=1){
			cal(dp,visited,v,v[start][i]);
		}
		dp[start] = max(dp[v[start][i]]+1,dp[start]);
	}
}

int main(){
	fast;
	int n,m;
	cin>>n>>m;
	int x[m+1],y[m+1];
	vector<int > v[n+1];
	for(int i=1;i<=m;i++){
		cin>>x[i]>>y[i];
		v[x[i]].push_back(y[i]);
	}
	int dp[n+1] = {0};
	int visited[n+1] = {0};
	dp[0] = 0;
	for(int i=1;i<=n;i++){
		if(visited[i]!=1){
			cal(dp,visited,v,i);
		}
		// dp[y[i]] = max(dp[y[i]],dp[x[i]] + 1);
	}
	int ans = 0;
	for(int i=1;i<=n;i++){
		ans = max(ans,dp[i]);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 10752
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String x = sc.nextLine();

        if (x.charAt(0) == x.charAt(2))
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}


Measured memory_bytes: 35632
//Bismillahir Rahmanir Rahim
#include <bits/stdc++.h>
#define ll long long int
#define li long int
#define ld long double
using namespace std;
const ll mod = 1e9 + 7;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

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

    best = arr[0];
    ll sum = 0;
    for(int i = 0; i < n; i++){
        best = max(best, arr[i]);
        sum += best - arr[i];
    }
    cout << sum;
}


Measured memory_bytes: 4428
#include<bits/stdc++.h>
using namespace std;
int main(){
string S;
  cin>>S;
  int n=S.size();
  int count=0;
  for(int i=0;i<n;i++){
  if(S.at(i)!=S.at(n-1-i)){
  count++;
  }
  
  }
  cout<<count/2<<endl;

}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
constexpr int kMod = 1000000007;
typedef long long LL;

std::pair<int, int> GetPair(int n) {
  int lower = n%10;
  while(n>9) n /= 10;
  int upper = n;
  return {lower, upper};
}

int main() {
  int N; std::cin >> N;
  std::map<std::pair<int, int>, LL> key;

  for (int i = 1; i <= N; ++i) {
    std::pair<int, int> p = GetPair(i);
    if (p.first == 0) continue;
    ++key[p];
  }

  LL sum = 0;
  for (const auto& p : key) {
    int lower = p.first.first;
    int upper = p.first.second;
    LL v = key[{lower, upper}] * key[{upper, lower}];
    sum += v;
  }
  std::cout << sum << std::endl;
}


Measured memory_bytes: 256
n = int(input())
s = [sorted(input()) for _ in range(n)]

words = list(set(s[0]))
d = {}
for i in words:
  t = float('inf')
  for j in range(n):
    p = s[j].count(i)
    if p < t:
      d[i] = p
      t = p

ans = ""
for i in sorted(d.items(), key = lambda x: x[0]):
  ans += i[0]*i[1]
print(ans)

Measured memory_bytes: 9200
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int N=1e5;
int main()
{
    FASTINOUT;
    int x;
    cin>>x;
    int y[x];
    for (int i=0;i<x;i++)
        cin>>y[i];
    sort(y,y+x);
    int mx=y[x-1];
    int l=(mx+1)/2,op=1e9;
    for (int i=0;i<x-1;i++){
        if (abs(y[i]-l)<abs(op-l)){
            op=y[i];
        }
    }
    cout<<mx<<" "<<op<<endl;
    return 0;
}


Measured memory_bytes: 640
N,A,B=map(int,input().split())
vlist=list(map(int,input().split()))
vlist.sort(reverse=True)

dp=[[0]*(N+1) for _ in range(N+1)]

for i in range(1,N+1):
  for j in range(1,N+1):
    dp[i][j]=dp[i-1][j]
    dp[i][j]=max(dp[i][j],dp[i-1][j-1]+vlist[i-1])

max_value_avg=0
for j in range(A,B+1):
  #print(j,dp[-1][j])
  value_avg=dp[-1][j]/j
  max_value_avg=max(max_value_avg,value_avg)
  
max_avg_size=[]
for j in range(A,B+1):
  value_avg=dp[-1][j]/j
  if value_avg==max_value_avg:
    max_avg_size.append(j)
#print(max_avg_size)    

def comb(n,r):
  r=min(r,n-r)
  nPr=1
  fact_r=1
  for i in range(r):
    nPr*=n-i
    fact_r*=r-i
  return nPr//fact_r

answer=0
for m in max_avg_size:
  border=vlist[m-1]
  n1=n2=n3=0
  for v in vlist:
    if v>border:
      n1+=1
    elif v==border:
      n2+=1
    else:
      n3+=1
  answer+=comb(n2,m-n1)

print(max_value_avg)
print(answer)

Measured memory_bytes: 3064
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int, input().split()))

    S = 0
    min_ = 10**9 + 1
    neg = 0
    for a in A:
        S += abs(a)
        min_ = min(min_, abs(a))

        if a < 0:
            neg += 1

    if neg % 2 == 0:
        return S
    else:
        return S - 2 * min_


if __name__ == '__main__':
    print(main())


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

auto itrMinInVector(vector<int>::iterator itr_first, vector<int>::iterator itr_last){
    auto itr_min = itr_first;
    for(auto itr=itr_first;itr!=itr_last;++itr){
        if(*itr_min>*itr) itr_min = itr;
    }
    return itr_min;
}

int cnt=0;
std::vector<int> ssrot(std::vector<int> vec){ 
    for(auto i=vec.begin();i!=vec.end();++i){
        auto j = itrMinInVector(i,vec.end());
        if (*i<=*j) continue;
        swap(*i,*j);
        cnt++; 
    }
    return vec;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int nb; cin>>nb;
    std::vector<int> lines; lines.resize(nb);
    for(auto& a:lines) cin>>a;

    auto sorted = ssrot(lines);
    for(auto& a:sorted) cout<<a<<(&a!=&sorted.back()?" ":"\n");
    cout<<cnt<<"\n";
}

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

int main(){
    double x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    double ans;
    ans = (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
    printf("%.8lf\n",sqrt(ans));
}


Measured memory_bytes: 3212
n,m=map(int,input().split())
c=[[]for i in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    c[a-1].append(b)
    c[b-1].append(a)
for a in c[0]:
    if n in c[a-1]:
        print("POSSIBLE")
        break
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 38368
#include<iostream>
using namespace std;
int main() {
	int A[3][3], N, b[10];
	for (int i = 0; i < 3; i++) {
		for (int k = 0; k < 3; k++) {
			cin >> A[i][k];
		}
	}
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> b[i];

	}
	for (int a = 0; a < N; a++) {
		for (int i = 0; i < 3; i++) {
			for (int k = 0; k < 3; k++) {
				if (b[a] == A[i][k])A[i][k] = 0;
			}
		}
	}
	for(int i=0;i<3;i++){
		if (A[0][i] == A[1][i] && A[1][i] == A[2][i]) {

			cout << "Yes" << endl;
			return 0;
		}
}
	for (int i = 0; i < 3; i++) {
		if (A[i][0] == A[i][1] && A[i][1] == A[i][2]) {

			cout << "Yes" << endl;
			return 0;
		}
	}
	
		if (A[0][0] == A[1][1] && A[1][1] == A[2][2]) {

			cout << "Yes" << endl;
			return 0;
		}
		if (A[0][2] == A[1][1] && A[1][1] == A[2][0]) {

			cout << "Yes" << endl;
			return 0;
		}
		cout << "No" << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define MIN(a,b) (a<b)?a:b
#define MAX(a,b) (a>b)?a:b
#define EMIN(a,b) (a<=b)?a:b
#define EMAX(a,b) (a>=b)?a:b
#define REP(a) for(int i=0; i<a; i++)
#define RREP(a) for(int j=0; j<a; j++)

int main()
{
    std::string col1;
    std::string col2;

    std::cin >> col1;
    std::cin >> col2;

    bool flag = true;
    REP(3)
    {
        if(col1.at(i) == col2.at(2-i))
        {
            continue;
        }
        else
        {
            flag = false;
            break;
        }
    }
    
    if(flag)
        std::cout << "YES";
    else
        std::cout << "NO";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int main(){
  int b, r, g, c, s, t;
  while(cin >> b >> r >> g >> c >> s >> t){
    if(b == 0 && r == 0 && g == 0 && c == 0 && s == 0 && t == 0) break;
    int m = 100;
    m -= t * 3;
    m += s * 3;
    m += c * 2;
    m += b * 15;
    m += (b*5) * 15 + (b*5);
    m += r * 15;
    m += (r*3) * 15 + (r*3);
    m += g * 7;

    cout << m << endl;
  }
  return 0;
}

    

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
#include <vector>
#include <chrono>
#include <cstdlib>
#include <bitset>
using namespace std;
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>

using namespace std;

const int N=(int) 2e5+7;
int n,cb[N],v[N];
string s;
int p1[N];
int p2[N];

int mo(int x,int y) {
  if (y==0) return 0;
  x%=y;
  if (x<0) x+=y;
  return x;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin>>n>>s;
  for (int i=1;i<N;i++) {
    cb[i]=cb[i-(i&(-i))]+1;
    v[i]=1+v[i%cb[i]];
  }
  reverse(s.begin(),s.end());
  int cnt=0;
  for (int i=0;i<n;i++) {
    if (s[i]=='1') {
      cnt++;
    }
  }
  p1[0]=mo(1,cnt-1);
  p2[0]=mo(1,cnt+1);
  for (int i=1;i<=n;i++) {
    p1[i]=mo(2*p1[i-1],cnt-1);
    p2[i]=mo(2*p2[i-1],cnt+1);
  }
  int h1=0,h2=0;
  for (int i=0;i<n;i++) {
    h1=mo(h1+p1[i]*(s[i]-'0'),cnt-1);
    h2=mo(h2+p2[i]*(s[i]-'0'),cnt+1);
  }
  for (int i=n-1;i>=0;i--) {
    if (s[i]=='0') {
      /// 0 bec 1, cnt++
      int val=mo(h2+p2[i],cnt+1);
      cout<<1+v[val]<<"\n";
    } else {
      /// 1 bec 0, cnt--
      if (cnt==1) {
        cout<<"0\n";
      } else {
        int val=mo(h1-p1[i],cnt-1);
        cout<<1+v[val]<<"\n";
      }
    }
  }
  return 0;
}


Measured memory_bytes: 6860
n,k = map(int,input().split())
a = list(map(int, input().split()))
s = dict()
for x in a:
  if x in s:
    s[x] += 1
  else:
    s[x] = 1
s_l = sorted(s.values())[0:max(0, len(s)-k)]
print(sum(s_l))

Measured memory_bytes: 33152
#include<bits/stdc++.h>
using namespace std;
int n,i,j,temp=1;
int main()
{
cin>>n;
for(i=n;;i++)
{   temp=1;
    for(j=2;j<n/2;j++)
    {
        if(i%j==0)
        {
        temp=0;    
        }
    }
    if(temp)
    {
        cout<<i;
        break;
    }
    
}
}

Measured memory_bytes: 256
//ABC110 A-maximize the fomula
#include<bits/stdc++.h>
using namespace std;
int main(){
vector<int> a(3);
for(int i = 0; i < 3;i++){
    cin >> a.at(i);
}
sort(a.begin(),a.end());
cout << a.at(2) * 10 + a.at(1) + a.at(0) << endl;
return 0;
}

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

const ll MOD = 1e9 + 7;
const int MAX_H = 1000, MAX_W = 1000;
int H, W;
string G[MAX_H];

int main(){
    cin >> H >> W;
    for (int i = 0; i < H; i++)
    {
        cin >> G[i];
    }

    ll dp[MAX_H][MAX_W] = {0};
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            if(G[i][j] == '#') continue;
            if(i == 0 && j == 0) dp[i][j] = 1;
            else if(i == 0) dp[i][j] = dp[i][j-1];
            else if(j == 0) dp[i][j] = dp[i-1][j];
            else{
                dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % MOD ;
            }
        }
    }
    /* for(int i = 0; i < H; i++){
        for (int j = 0; j < W; j++)
        {
            cout << dp[i][j] << " ";
        }
        cout << endl;
    } */
    cout << dp[H-1][W-1] << endl;
    
    
}

Measured memory_bytes: 9088