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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<char, ll> pcl;
typedef pair<string, ll> psl;

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for(int i = (s); i < (int)(n); i++)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(mp(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
#define mp make_pair
#define pb push_back
#define INF (1 << 29)
const int mod = 1000000007;

int main() {
    ll N, M, Q;
    cin >> N >> M >> Q;

    vector<ll> a(Q), b(Q), c(Q), d(Q);
    REP(i, Q) cin >> a[i] >> b[i] >> c[i] >> d[i];

    vector<ll> m(N);
    ll ans = 0;
    REP(i1, M) {
        FOR(i2, i1, M) {
            FOR(i3, i2, M) {
                FOR(i4, i3, M) {
                    FOR(i5, i4, M) {
                        FOR(i6, i5, M) {
                            FOR(i7, i6, M) {
                                FOR(i8, i7, M) {
                                    FOR(i9, i8, M) {
                                        FOR(i10, i9, M) {
                                            vector<ll> m = {i1, i2, i3, i4,
                                                            i5, i6, i7, i8,
                                                            i9, i10};
                                            ll sum = 0;
                                            REP(i, Q) {
                                                if(m[b[i] - 1] - m[a[i] - 1] ==
                                                   c[i])
                                                    sum += d[i];
                                            }
                                            ans = max(ans, sum);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define setbits(x)  __builtin_popcount(x)
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;

//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
ll modexpo(ll a,ll b)
{
     ll ans=1LL;
     while(b>0)
     {
          if(b&1)ans=(ans*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return ans;
}
 
 
 
 
 
 
 







int last[200005];
int main()
{
     string s;
     cin>>s;
     for(int i=0;i<s.length();i++){
          if(i+1<s.length()&&s[i]==s[i+1]){
               cout<<i+1<<" "<<i+2;return 0;
          }
          else if(i+2<s.length()&&s[i]==s[i+2]){
               cout<<i+1<<" "<<i+3;return 0;
          }
     }
     cout<<-1<<" "<<-1;
}
































Measured memory_bytes: 3700
from sys import stdin, setrecursionlimit
from math import factorial

setrecursionlimit(10 ** 9)
INF = 1 << 60


def input():
    return stdin.readline().strip()


def main():
    N, M, K = map(int, input().split())
    MOD = 998244353
    COM_MAX = N

    fac, finv, inv = [0] * (COM_MAX + 1), [0] * (COM_MAX + 1), [0] * (COM_MAX + 1)
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1

    for i in range(2, COM_MAX + 1):
        fac[i] = fac[i - 1] * i % MOD
        inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD

    def mod_com(n, k):
        if n < k:
            return 0
        if n < 0 or k < 0:
            return 0
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD

    ans = 0
    power = M % MOD
    for k in range(N - 1, -1, -1):
        if k <= K:
            ans += mod_com(N - 1, k) * power % MOD
        power = power * (M - 1) % MOD

    print(ans % MOD)

    return


if __name__ == '__main__':
    main()


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  int n, M;cin>>n>>M;
  vector<vector<int>> c(n, vector<int>(M));
  rep(i, n)rep(j, M){cin>>c[i][j]; c[i][j]--; }

  int result = n;

  rep(i, M){
    map<int, int> m;
    rep(i, n){
      m[c[i][0]]++;
    }
    pi t = {0,0};
    for(pi p: m){
      if(t.second<p.second)t = p;
    }
    rep(i, n)rep(j, c[i].size()){
      if(c[i][j]==t.first) c[i].erase( (c[i].begin()+j) );
    }
    result = min(result, t.second);

//rep(i, n){ rep(j, c[i].size())cout<<c[i][j]<<' ';cout<<endl; } cout<<endl;

  }

  cout<<result<<endl;

  return 0;
}

Measured memory_bytes: 640
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
using P = pair<ll, ll>;
typedef vector<int> vi;
const int MOD = (int)1e9 + 7;
const ll INF = 1LL << 60;
const int inf = 1<<30;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
template <typename T>
ostream& operator<<(ostream& os, vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, pair<T,T> const&P){
    os << P.first;
    os << " ";
    os << P.second;
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
    for(auto it=q.begin();it<q.end();it++){
        os<<*it;
        os<<" ";
    }
     os<<endl;
    return os;
}
//fixed<<setprecision(10)<<ans<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    string S;
    cin >> N >> S;
    set<string> C,ans;
    C.insert("");
    REP(i,N){
        auto C_copy = C;
        for(auto c:C_copy){
            auto res = c+S[i];
            if (res.size() == 3){
                ans.insert(res);
            }else if (res.size()<3){
                C.insert(res);
            }
        }
    }
    cout << ans.size() << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  char a, b;
  cin >> a >> b;

  if (a == 'H') {
    COUT(b);
    return 0;
  }

  if (b == 'H') {
    COUT("D");
    return 0;
  }
  COUT("H");
  return 0;
}


Measured memory_bytes: 3628
#include <cstdio>
int main(void){
int a,d,g,j,m;
scanf("%d%d%d%d%d",&a,&d,&g,&j,&m);
d=(d+j-1)/j;
g=(g+m-1)/m;
if(d<g)d=g;
printf("%d\n",a-d);
return 0;
}

Measured memory_bytes: 1024
///
// File:  d.go
// Author: ymiyamoto
//
// Created on Sun Mar 11 21:36:29 2018
//
package main

import (
	"fmt"
)

var N, K int

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func main() {
	fmt.Scan(&N, &K)

	count := 0
	for b := 1; b <= N; b++ {

		count += (N/b)*max(0, b-K) + max(0, (N%b)-K+1)
		if K == 0 {
			count--
		}
	}

	fmt.Println(count)
}


Measured memory_bytes: 512
import Data.Array.IO
import Control.Applicative
import Control.Monad

main = do
  (n:m:_) <- (map read) . words <$> getLine
  dat <- (map ((map read) . words)) . lines <$> getContents
  arr <- newArray (1,n) 0 :: IO (IOArray Int Int)

  forM_ dat $ \(a:b:_) -> do
    incr arr a
    incr arr b
  
  mapM_ print =<< getElems arr

  where
    incr arr n = do
      r <- readArray arr n
      writeArray arr n (r+1)


Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
// 邻接表转化为邻接矩阵
int mat[105][105]; 
int main(){
//	freopen("a.txt","r",stdin);
	memset(mat,0,sizeof(mat));
	int n;
	cin>>n;
	int u,k,v;
	for(int i=0;i<n;i++){
		cin>>u>>k;
		for(int j=0;j<k;j++){
			cin>>v;
//			mat[u-1][v-1]=1;
			mat[u][v]=1;
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n-1;j++){
			cout<<mat[i][j]<<' ';
		}cout<<mat[i][n]<<endl;
	}
	return 0;
}


Measured memory_bytes: 3152
fun main(args: Array<String>) {
    val xyzk = readLine()!!.split(" ").map { it.toInt() }
    val x = xyzk[0]
    val y = xyzk[1]
    val z = xyzk[2]
    val K = xyzk[3]
    val a = readLine()!!.split(" ").map { it.toLong() }.sortedDescending()
    val b = readLine()!!.split(" ").map { it.toLong() }.sortedDescending()
    val c = readLine()!!.split(" ").map { it.toLong() }.sortedDescending()

    val ans = mutableListOf<Long>()

    for(i in 0 until x){
        for(j in 0 until y){
            for(k in 0 until z){
                val rank = (i+1)*(j+1)*(k+1)
                if(rank>K) break
                ans.add(a[i]+b[j]+c[k])
            }
        }
    }

    println( ans.sortedDescending().take(K).joinToString("\n") )

}


Measured memory_bytes: 54168
S = str(input())
 
Ans = True
for i in range(0, len(S)):
  if (i + 1) % 2 == 0:
    if S[i] != 'L' and S[i] != 'U' and S[i] != 'D':
      Ans = False
      break
  if (i + 1) % 2 == 1:
    if S[i] != 'R' and S[i] != 'U' and S[i] != 'D':
      Ans = False
      break
  
if Ans == False:
  print('No')
else:
  print('Yes')

Measured memory_bytes: 9136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void)
{
  ll n,k,q;
  cin >> n >> k >> q;
  ll s[n];
  for(int i = 0;i<n;i++) s[i] = k-q;
  for(int i = 0;i<q;i++)
  {
      int a;
      cin >> a;
      s[a-1]++;
  }
  for(int i = 0;i<n;i++)
  {
      if(s[i]<=0) cout<<"No\n";
      else cout<<"Yes\n";
  }
  return 0;
}



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

using namespace std;

typedef long long ll;

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

	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;

#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define INFINITO 1000000000
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define vvi vector<vi>
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )


int main() {

    int x, n;
    cin >> x >> n;
    set<int> s;
    fo(i, n) {
        int p;
        cin >> p;
        s.insert(p);
    }

    int menor = INFINITO;
    fo(i, 102) {
        if ( s.find(i) == s.end() and abs(x - i) < abs(x - menor) ) menor = i;
    }

    cout << menor << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define LL long long
#define st first
#define nd second
using namespace std;
int main(){
	string s;
	cin>>s;
	for(int i=0;i<4;++i)
		cout<<s[i];
	cout<<" ";
	for(int i=4;i<s.size();++i)
		cout<<s[i];
	cout<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a,b,c;
  while(cin >>a>>b>>c){
    bool f[11]={};
    int ans = 0;
    f[a] = f[b] = f[c] = true;
    for(int i=1; i<11; i++) if(!f[i] && (i+a+b)<=20) ans++;
    if(ans>3) cout <<"YES"<<endl;
    else cout <<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int W,H,x,y,r;
  cin >> W >> H >> x >> y >> r;
  if(x-r < 0 | x+r > W | y-r < 0 | y+r > H){
      cout << "No" << endl;
  }
  else{
      cout << "Yes" << endl;
  }
}


Measured memory_bytes: 3104
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<set>
using namespace std;
typedef long long LL;
const int INF=0x3f3f3f3f;
const int MAXN=1e5+5;
int a[MAXN];
int G[105][105];

int main()
{
    int h,w;
    while(scanf("%d%d",&h,&w)!=EOF)
    {
        int n;
        scanf("%d",&n);
        for(int i=1;i<=n;++i)
            scanf("%d",&a[i]);
        int cnt=1;
        for(int i=1;i<=h;++i)
        {
            if(i&1)
            {
                for(int j=1;j<=w;++j)
                {
                   if(a[cnt]>0) {G[i][j]=cnt;--a[cnt];}
                   else if(a[cnt]==0) {++cnt;G[i][j]=cnt;--a[cnt];}
                }
            }else
            {
                for(int j=w;j>=1;--j)
                {
                    if(a[cnt]>0) {G[i][j]=cnt;--a[cnt];}
                    else if(a[cnt]==0) {++cnt;G[i][j]=cnt;--a[cnt];}
                }
            }
        }
        for(int i=1;i<=h;++i)
        {
            for(int j=1;j<=w;++j)
            {
                if(j!=w) printf("%d ",G[i][j]);
                else printf("%d\n",G[i][j]);
            }
        }
    }
///ajvnajk.vnafnv
    return 0;
}

Measured memory_bytes: 384
class Node
  attr_accessor :state, :depth
  attr_reader :parent

  def initialize(state, parent)
    @state = state
    @parent = parent
    @depth = parent.nil? ? 0 : parent.depth + 1
  end

  def goal?(limit, max)
    nums.size == limit && sum == max
  end

  def bad_end?(limit, max)
    nums.length > limit || sum > max
  end

  def nums
    parent.nil? ? [state] : parent.nums << state
  end

  def sum
    nums.inject(:+)
  end
end

def bfs
  while gets
    limit, max = $_.split.map(&:to_i)

    next if limit == 0 && max == 0

    goals = []
    10.times do |i|
      init_node = Node.new(i, nil)
      queue = [init_node]
      black_list = [init_node.nums.sort]

      loop do
        break if queue.empty?

        elem = queue.shift

        goals << elem if elem.goal?(limit, max)

        next if elem.bad_end?(limit, max)

        10.times do |j|
          next if elem.nums.include?(j)
          new_node = Node.new(j, elem)
          new_nums = new_node.nums.sort
          next if black_list.include?(new_nums)
          black_list << new_nums
          queue.unshift new_node
        end
      end
    end

    puts goals.map { |e| e.nums.sort }.uniq.size
  end
end

bfs

Measured memory_bytes: 10840
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
const int mod=998244353;
inline int ad(int x){return x>=mod?x-mod:x;}
inline int power(int a,int b)
{
	int ans=1;
	while(b)
	{
		if(b&1)ans=1LL*ans*a%mod;
		a=1LL*a*a%mod;
		b>>=1;
	}return ans;
}
int f[410][410],inv[410],fac[410];
int main()
{
    //freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	fac[0]=1;
	for(int i=1;i<=400;i++)fac[i]=1LL*fac[i-1]*i%mod;inv[400]=power(fac[400],mod-2);
	for(int i=400;i>=1;i--)inv[i-1]=1LL*inv[i]*i%mod;
	int n=read(),sa=0,sb=0;
	f[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		int a=read(),b=read();
		for(int j=sa;j>=0;j--)
		{
			for(int k=sb;k>=0;k--)
			{
				int bin=1;
				for(int u=0;u<b;u++)
				{
					f[j+a][k+u]=ad(f[j+a][k+u]+ad(mod-1LL*f[j][k]*bin%mod*inv[u]%mod));
					bin=1LL*bin*a%mod;
				}
			}
		}sa+=a,sb+=b;
	}
	int ans=0;
	for(int i=0;i<=sa;i++)
	{
		int uf=power(i,mod-2);
		for(int j=0;j<=sb;j++)ans=ad(ans+ad(mod-1LL*fac[j]*power(uf,j)%mod*f[i][j]%mod*sa%mod*uf%mod));
	}pr2(ans);
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define setbits(x) __builtin_popcountll(x)
#define zerobits(x) __builtin_ctzll(x)
#define MOD 1000000007
#define inf 1e18
#define deb(x) cout << #x << " -> " << x << "\n";

#ifdef LOCAL_DEFINE
	mt19937 rng(228);
#else 
	mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

using ll = long long;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);	
	cout.precision(10);
	cout << fixed;
	int n, ans = 0;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i += 2) {
		if (a[i] % 2 != 0) ans++;
	}	
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 3684
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <set>
#include <map>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
typedef long long ll;

const int MOD = 1000000007;  // 1 000 000 007


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

    // input
    int N, H, W;
    cin >> N >> H >> W;
    
    // calculation
    cout << (N-H+1)*(N-W+1) << "\n";
    
    return 0;
}


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

int main(){
    long int N,M=10,X=0;
    cin>>N;
    for (int i=1;N>=M;i++){
        X+=N/M;
        M=M*5;
    }
    if (N%2==0) cout<<X<<endl;
    else cout<<0<<endl;
    return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, a[100000][3], dp[100000][3];

int main() {
	cin >> n;
	inc(i, n) {
	inc(j, 3) {
		cin >> a[i][j];
	}
	}
	
	inc(i, n) {
		if(i == 0) {
			inc(j, 3) { dp[i][j] = a[i][j]; }
		} else {
			inc(j, 3) {
			inc(k, 3) {
				if(j == k) { continue; }
				setmax(dp[i][k], dp[i - 1][j] + a[i][k]);
			}
			}
		}
	}
	
	int ans = 0;
	inc(j, 3) { setmax(ans, dp[n - 1][j]); }
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 2560
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)
	a := []int{111, 222, 333, 444, 555, 666, 777, 888, 999}

	for i := 0; i < len(a); i++ {
		if a[i]-N >= 0 {
			fmt.Println(a[i])
			return
		}
	}
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define LL long long
#define maxn 200010
using namespace std;

int n[maxn];

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

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

int main(){
	int N,K;
	cin>>N>>K;
	vector<int>l(N);
	int ans=0;
	rep(i,N){
		cin>>l.at(i);
	}
	sort(l.begin(),l.end());
	/*rep(i,N){
		cout<<l.at(i)<<endl;
	}*/
	reverse(l.begin(),l.end());
	/*rep(i,N){
		cout<<l.at(i)<<endl;
	}*/
	rep(i,K){
		ans+=l.at(i);
	}
	cout<<ans;
return 0;}

/*compile
g++ code.cpp
./a.out
run*/

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
result = 1
target = 10**18
 
if a.count(0) >= 1:
  result = 0
else:
  for an in a:
    result = an*result
    if result > target:
      result = -1
      break
 
print(result)

Measured memory_bytes: 21464
input = input().split()
# inputList = list(input[0])

a = int(input[0])
b = int(input[1])
# c = int(input[2])

ans = 0
if a > 12:
    ans = b
elif a>=6:
    ans = int(b/2)
else:
    ans = 0

print(ans)

# inputList.sort()
#
# list = [a+b, b+c ,c+a]
#
# ans = min(list)
# print(ans)



# flg = 1
# for i in range(0, len(inputList)-1):
#     if inputList[i] == inputList[i + 1]:
#         flg = 0
#         break
#
# if flg == 0:
#     print("Bad")
# else:
#     print("Good")


Measured memory_bytes: 38256
S = input()
S1 = len(S)
S3 = 0
S4 = 0
while S1 != 0:
    S2 = S[0:1]
    S1 = S1 - 1
    S = S[1:]
    if S2 == "A" or S2 == "C" or S2 == "G" or S2 == "T":
        S3 = S3 + 1
    else:
        if S3 > S4:
            S4 = S3
            S3 = 0
if S3 > S4:
    S4 = S3
    S3 = 0
print(str(S4))

Measured memory_bytes: 3064
process.stdin.resume();
process.stdin.setEncoding('utf8');


process.stdin.on('data', function (chunk) {
    let n = chunk.toString() // 文字列化する
        .split("\n") // \nで分割
        .map(x => Number(x))
        .filter(x => x !== 0);

    let roop1 = true;
    let kokugoday = 0;
    let roop2 = true;
    let sansuday = 0;
    let kekka1 = n[1] - n[3];
    let kekka2 = n[2] - n[4];;
    while (roop1) {
        kekka1 = kekka1 - n[3];
        kokugoday += 1;
        if (kekka1 <= 0) {
            roop1 = false;
            kokugoday += 1;
        }
    }

    while (roop2) {
        kekka2 = kekka2 - n[4];
        sansuday += 1;
        if (kekka2 <= 0) {
            roop2 = false;
            sansuday += 1;

        }
    }
    if (kokugoday <= sansuday) {
        const ans = n[0]-sansuday;
        console.log(ans);
    }else if(kokugoday >= sansuday){
        const ans = n[0]-kokugoday;
        console.log(ans);
    }


});


Measured memory_bytes: 15312
#include <iostream>

using namespace std;

int main() {
    int a,b;
    cin>>a>>b;
    if(a > b)
    cout<<"a > b"<<endl;
    else if(a < b)
     cout<<"a < b"<<endl;
     else if(a == b)
     cout<<"a == b"<<endl;

}


Measured memory_bytes: 3096
#import sys
#import math
#import numpy as np
'''a,b= map(int,input().split())'''
#a, b, c = [list(map(int, input().split())) for _ in range(3)]
#li0= [int(x) for x in input().split()]
#n,l= map(int, input().split())
#x = [list(map(int, input().split())) for _ in range(n)] 
N=int(input())
li= [int(x) for x in input().split()]
li1=[int(x) for x in input().split()]
ans=0

for i in range(N):
  if li[i]>=li1[i]:
    ans+=li[i]-li1[i]
print(ans)


Measured memory_bytes: 3060
#include <stdio.h>

int main() {
	int a, b, c, d, n, p=0;
	while(scanf("%d",&n)!=EOF) {
		p=0;
		for(a=0;a<10;a++) {
			for(b=0;b<10;b++) {
				for(c=0;c<10;c++) {
					for(d=0;d<10;d++) {
						if (a+b+c+d==n) {
							p++;
						}
					}
				}
			}
		}
		printf("%d\n",p);
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    double sum=0;
    cin>>n;
    while(n--)
    {
        double k;
        cin>>k;
        sum+=(double)1/(double)k;
        
    }
    cout<<fixed<<setprecision(10)<<(double)1/(double)sum;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
const int INF=1e+9;
int n,k;
int h[100010];
int dp[100010];
int main()
{
  cin >> n >> k;
  for(int i=0;i<n;++i){
    cin >> h[i];
  }
  for(int i=0;i<n;++i){
    dp[i]=INF;
  }
  dp[0]=0;
  for(int i=0;i<n;++i){
    for(int j=1;j<=k;++j){
      if(i+j>=n) break;
      dp[i+j]=min(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
    }
  }
  cout << dp[n-1] << "\n";
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
vector<pair<LL,LL>> v;
vector<pair<LL,LL>> u;

int main(){
    int N,M;
    cin >> N >> M;
    for(int i=0;i<N;i++){
        LL x,y;
        cin >> x >> y;
        v.push_back(make_pair(x,y));
    }
    for(int i=0;i<M;i++){
        LL a,b;
        cin >> a >> b;
        u.push_back(make_pair(a,b));
    }
    for(int i=0;i<N;i++){
        LL mini=1000000000;
        int count=0;
        for(int j=0;j<M;j++){
            LL x,y;
            x=abs(v[i].first-u[j].first);
            y=abs(v[i].second-u[j].second);
            if(x+y<mini){
                count = j + 1;
                mini=x+y;
            }
        }
        cout << count << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    cout << fixed << setprecision(10);
    
    string S; cin >> S;
    string ans;
    rep(i, S.size()) {
        if (S[i] == 'B' && ans.size()) { 
            ans.erase(ans.size()-1);
        } else if (S[i] != 'B') {
            ans += S[i];
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(void)
{
    char s1[100], s2[100];
    int n, i, a, b;

    scanf("%d", &n);

    a = b = 0;

    for (i = 0; i < n; i++){
        scanf("%s %s", s1, s2);

        if (strcmp(s1, s2) == 0){
            a++;
            b++;
        } else if (strcmp(s1, s2) > 0){
            a = a + 3;
        } else if (strcmp(s1, s2) < 0){
            b = b + 3;
        }
    }

    printf("%d %d\n", a, b);

    return (0);
}


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

ll v[3100][3100], dp[3100][3100][4];
int main(){
    ll r,c,k;
    cin >> r >> c >> k;
    for(int i=0; i<3100; i++){
        for(int j=0; j<3100; j++){
            v[i][j]=0;
            for(int k=0; k<4; k++){
                dp[i][j][k]=0;
            }
        }
    }
    for(int i=0; i<k; i++){
        int a,b,c;
        cin >> a >> b;
        a--;b--;
        cin >> c;
        v[a][b]=c;
    }
    if(v[0][0]>0) dp[0][0][1]=v[0][0];
    for(int i=0; i<3100; i++){
        for(int j=0; j<3100; j++){
            for(int k=0; k<4; k++){
                if(i-1>=0){
                    dp[i][j][0]=max(dp[i][j][0], dp[i-1][j][k]);
                    dp[i][j][1]=max(dp[i][j][1], dp[i-1][j][k]+v[i][j]);
                }
                if(j-1>=0){
                    dp[i][j][k]=max(dp[i][j][k], dp[i][j-1][k]);
                    if(k>=1){
                        dp[i][j][k]=max(dp[i][j][k], dp[i][j-1][k-1]+v[i][j]);
                    }
                }
            }
        }
    }
    ll ans=0;
    for(int k=0; k<4; k++){
        ans = max(ans, dp[r-1][c-1][k]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 379016
using System;
using System.Linq;
using System.Collections.Generic;




namespace ConsoleApplication1 {

    

    class ClassMain {

        public static bool[] primes = Enumerable.Repeat(true, 1500000 + 1).ToArray();

        public static void sieve() {
            primes[0] = false; primes[1] = false;
            for (int i = 2; i < primes.Length / 2 + 1; i++) {
                if (primes[i]) {
                    for (int j = 2; j * i < primes.Length; j++) {
                        primes[i * j] = false;
                    }
                }
            }
        }


        public static void Main(String[] args) {
           string line;
           sieve();
            while ((line = Console.ReadLine()) != null) {
                //int[] ints = line.Split(' ').Select(int.Parse).ToArray();
                //int n = ints[0];
                int n = int.Parse(line);                
                if (n == 0) { break; }
                if (primes[n]) {
                    Console.WriteLine(0);
                }
                else {
                    int moreThanCnt = 0;
                    int lessThanCnt = 0;
                    for (int i = 1; i + n < 1500000 + 1; i++) {
                        if (primes[i + n] == false) { moreThanCnt++; }
                        else { break; }
                    }
                    for (int i = 1;  n - i  > 1; i++) {
                        if (primes[n - i] == false) { lessThanCnt++; }
                        else { break; }
                    }
                    Console.WriteLine(moreThanCnt + lessThanCnt + 2);
                }
            }
        }

    }

    


}

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
#define Size(n) (n).size()

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 9e18;

//long long int kaizyo(long long int hh){
  //  cmp=1;
    //while(hh>1){
      //  cmp=(cmp*hh)%MOD;
        //hh--;
    //}
    //return cmp;
//}
//long long int ruizyo(long long int aa, long long int bb){
  //  if(aa==0){
    //    return 1;
    //}
    //else if(aa%2==0){
      //  long long int tt=ruizyo(aa/2,bb);
        //return (tt*tt)%MOD;
    //}
    //else{
      //  return (ruizyo(aa-1,bb)*bb)%MOD;
    //}
//}フェルマ－のア


//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

//visited=vector<vector<bool>>(10,vector<bool>(10,false));アを全部falseに


long long int n,cnt=0,ans,a,b,c,cmp,cmpp,m,k,h,w,x[10000000],xx[10000000],y[10000000],yy[10000000],sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true;

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

       cin >>n>>k;
       rep(i,n){cin>>x[i]>>y[i];xx[i]=x[i];yy[i]=y[i];}
       sort(x,x+n);
       sort(y,y+n);
       ans=(x[n-1]-x[0])*(y[n-1]-y[0]);
       rep(i,n){
           rrep(j,i+1,n){
               rep(kk,n){
                   rrep(q,kk+1,n){
                       cnt=0;
                       rep(pp,n){
                           if(x[i]<=xx[pp]&&xx[pp]<=x[j]&&y[kk]<=yy[pp]&&yy[pp]<=y[q]){
                               cnt++;
                           }
                       }
                       if(cnt>=k){
                           pos=(x[j]-x[i])*(y[q]-y[kk]);
                            ans=min(ans,pos);
                       }
                   }
               }
           }
       }
       Cout(ans);
       
return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;
}
int64_t abs(int64_t n) {
  if (n < 0) {
    n = -n;
  }
  return n;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}

int main() {
  int n;
  cin >> n;
  int n1 = 0, n2 = 0, n3 = 0, n4 = 0, n5 = 0, n6 = 0, n7 = 0, n8 = 0, n9 = 0;
  rep(i, n) {
    int a;
    cin >> a;
    if (a < 400) {
      n1 = 1;
    } else if (a < 800) {
      n2 = 1;
    } else if (a < 1200) {
      n3 = 1;
    } else if (a < 1600) {
      n4 = 1;
    } else if (a < 2000) {
      n5 = 1;
    } else if (a < 2400) {
      n6 = 1;
    } else if (a < 2800) {
      n7 = 1;
    } else if (a < 3200) {
      n8 = 1;
    } else {
      n9++;
    }
  }
  int min, max;
  if (n1+n2+n3+n4+n5+n6+n7+n8 == 0) {
    min = 1;
  } else {
    min = n1+n2+n3+n4+n5+n6+n7+n8;
  }
  max = n1+n2+n3+n4+n5+n6+n7+n8+n9;
  cout << min << ' ' << max << endl;
}

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

int main(){
    int n;
    cin>>n;
    int count = 0;
    for(int a=1;a<n;a++){
        count += n/a;
        //cが0になる場合はダメ
        if(n%a==0){
            count --;
        }
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;

int main() { 
	int n;
	cin >> n;
	bool d = 0; // 7 11 15
	for (int i = 0; i <= 17; ++i) {
		for (int j = 0; j <= 25; ++j) {
			if (i * 7 + j * 4 == n) {
				d = 1;
			}
		}
	}
	if (d) {
		cout << "Yes";
	}else {
		cout << "No";
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1 << 28;
const ll LLINF = 1LL << 60;
int main()
{
    int N, X;
    int A[2005];
    int minv[2005][2005];
    ll ans = LLINF;
    cin >> N >> X;
    for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = 0; i < N; i++) {
        minv[0][i] = A[i];
        for(int j = 1; j < N; j++) {
            minv[j][i] = min(minv[j - 1][i], A[(i - j + N) % N]);
        }
    }
    for(int i = 0; i < N; i++) {
        ll sum = (ll)X * i;
        for(int j = 0; j < N; j++) sum += minv[i][j];
        ans = min(sum, ans);
    }
    cout << ans << endl;
    return (0);
}

Measured memory_bytes: 15872
import java.util.*;

public class Main {


    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();

        long[] a = new long[n];
        for(int i=0; i<n; i++) {
            a[i] = sc.nextInt();
        }


        long l = 0;
        long r = 1000000000;
        while(r-l>1) {
            long mid = (l+r)/2;
            long num = 0;
            for(int i=0; i<n; i++) {
                long div = a[i]/mid;
                long rem = a[i]%mid;
                long add = 0;
                if(rem == 0) {
                    add = div-1;
                } else {
                    add += div;
                }
                num += add;
            }
            if(num <= k) {
                r = mid;
            } else {
                l = mid;
            }
        }
        System.out.println(r);

    }
}

Measured memory_bytes: 60876
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String st = sc.next();
		int num = st.length();
		boolean isBlack[] = new boolean[st.length()];
		for(int i = 0; i < num; i ++) {
			isBlack[i] = st.charAt(i) == 'B';
		}
		ArrayList<Integer> sameColor = new ArrayList<Integer>();
		int tmp = 0;
		boolean tmpIsBlack = true;
		for(int i = 0; i < num; i ++) {
			if(isBlack[i] != tmpIsBlack) {
				sameColor.add(tmp);
				tmp = 0;
				tmpIsBlack = !tmpIsBlack;
			}
			tmp ++;
		}
		sameColor.add(tmp);
		long count = 0;
		while(sameColor.size() >= 2) {
			if(sameColor.size() <= 1) {
				break;
			}
			count += (long) sameColor.get(0) * sameColor.get(1);
			sameColor.remove(1);
			if(sameColor.size() <= 1) {
				break;
			}
			sameColor.set(1, sameColor.get(0) + sameColor.get(1));
			sameColor.remove(0);
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 28808
import math
def ip():return int(input())
def inp():return map(int,input().split())
def inpstr():return map(str,input().split())
def linp():return list(map(int,input().split()))
def linpstr():return list(map(str,input().split()))

n,m,c=inp()
b=linp()
ans=0
for _ in range(n):
    a=linp()
    s=0
    for i in range(m):s=s+b[i]*a[i]
    if s+c>0:ans+=1
print(ans)


Measured memory_bytes: 3064
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#pragma GCC target ("sse4")
#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

#define deb(x) cout << #x << " is " << x << "\n";
#define int long long
#define mod 1000000007

const double PI = 2 * acos(0.0);
const long long INF = 1e18L + 5;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, m;
	cin >> n >> m;
	vector<int> arr(m);
	for (int i = 0; i < m; i++)
		cin >> arr[i];
	int s = accumulate(arr.begin(), arr.end(), 0);
	int diff = n - s;
	cout << (diff < 0 ? -1 : diff);
	return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int N;
	string S;
	cin >> N >> S;
	int ans = 1;
	for (int i = 1; i < N; i++) {
		if (S[i] != S[i - 1]) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
using namespace std;


typedef long long ll;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)

const int mod = 1000000007;



int main(){

  int n;
  cin >> n;
  vector<string> s(n);
  vector<int> p(n);

  rep(i, n){
    cin >> s[i] >> p[i];
  }


  vector<int> ans(n);


  rep(i, n){
    int cityRank = 0;
    int scoreRank = 0;
    bool existCity = false;
    rep(j, n){
      if(i == j)  continue;
      if(s[i] == s[j]) existCity = true;
      if(s[i] > s[j]) cityRank++;
    }
  
    if(existCity){
      rep(j, n){
        if(s[i] == s[j]){
          if(p[i] < p[j]) scoreRank++;
        }
      }
    }
    ans[cityRank + scoreRank] = i + 1; 
  }


  rep(i, n) cout << ans[i] << endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define MOD 1000000007

int main(){
  int n,k;
  cin>>n>>k;
  ll x[n], y[n], x2[n], y2[n];
  for(int i=0;i<n;i++){
    cin>>x[i]>>y[i];
    x2[i]=x[i], y2[i]=y[i];
  }
  sort(x2, x2+n);
  sort(y2, y2+n);
  ll ans=LLONG_MAX;
  for(int xi=0;xi<n;xi++){
    for(int xi2=xi+1;xi2<n;xi2++){
      for(int yi=0;yi<n;yi++){
        for(int yi2=yi+1;yi2<n;yi2++){
          int sum=0;
          for(int i=0;i<n;i++){
            if( x[i]>=x2[xi]&&x[i]<=x2[xi2] && y[i]>=y2[yi]&&y[i]<=y2[yi2] ) sum++;
          }
          if(sum>=k){
            ans=min(ans, (x2[xi2]-x2[xi])*(y2[yi2]-y2[yi]) );
          }
        }
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)


struct UnionFind {
    vector<int> par;

    UnionFind(int n): par(n, -1) {};
    
    void init(int n) { par.assign(n, -1); }

    int root(int x){
        if(par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y){
        return root(x) == root(y);
    }

    bool merge(int x, int y){
        x = root(x);
        y = root(y);

        if(x == y) return false;
        if(par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x){
        return -par[root(x)];
    }
};




int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n, m; cin >> n >> m;
    ll a[m], b[m];
    rep(i, m){
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
    }

    ll ans[m+1];
    ans[m] = n*(n-1)/2;

    UnionFind uf = UnionFind(n);

    repr(i, m){

        if(uf.issame(a[i], b[i])){
            ans[i] = ans[i+1];
        }
        else{
            ll size1 = uf.size(a[i]);
            ll size2 = uf.size(b[i]);
            ans[i] = ans[i+1] - size1*size2;
        }
        uf.merge(a[i], b[i]);
    }

    reps(i, 1, m+1){
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 4096
import math

N, X = list(map(lambda n:int(n), input().split(" ")))
x = list(map(lambda y:int(y), input().split(" ")))
x.append(X)
x.sort()
d = list(filter(lambda r: r != 0, [abs(x[i + 1] - x[i]) for i in range(len(x) - 1)]))

gcd = d[0]
for i in range(len(d)):
  gcd = math.gcd(d[i], gcd)

print(gcd)


Measured memory_bytes: 20704
#include <stdio.h>

int main()
{
        int  a=1,b=0,c=0;
        char x,y;

        while(~scanf("%c,%c\n",&x,&y)){
                if((x=='A'&&  y=='B')||(x=='B'&&y=='A')){
                        b^=a;a^=b;b^=a;
                }
                if((x=='B' && y=='C')||(x=='C'&&y=='B')){
                        c^=b;b^=c;c^=b;
                }
                if((x=='C' && y=='A')||(x=='A'&&y=='C')){
                        a^=c;c^=a;a^=c;
                }
        }
                if(a==1)puts("A");
                else if(b==1)puts("B");
                else puts("C");
        return 0;
}

Measured memory_bytes: 528
X, Y = map(int, input().split())

a, b = divmod(2*X-Y, 3)
c, d = divmod(2*Y-X, 3) 
if (not b == d == 0) or (2*X < Y) or (2*Y < X):
  print(0)
else:
  m, n = 1, 1
  mod = 10**9+7
  for i in range(1, min(a, c)+1):
    m = (m * (a+c-i+1)) % mod
    n = (n * i) % mod
  ans = (m * pow(n, mod-2, mod)) % mod
  print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define alll(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it;}cout<<endl;}

int main() {
    ll q;
    cin>>q;
    vector<ll> v(q),v2(q);
    rep(i, q){
        ll tmp;
        cin>>tmp;
        v[i]=tmp;
        v2[i]=tmp;
    }
    sort(alll(v));
    ll mid1 = v[v.size()/2-1];
    ll mid2 = v[v.size()/2];
    rep(i, q){
        if (v2[i] <= mid1) {
            pr(mid2);
        }else pr(mid1);
    }
    
}



Measured memory_bytes: 5376
n,a=map(int,input().split())
X=list(map(int,input().split()))

def card(n,a):
	dp=[[[0]*(n*a+1) for i in range(n+1)] for j in range(n+1)]
	dp[0][0][0]=1
	
	for i in range(n):
		for j in range(n):
			for k in range(n*a+1):
				if k<X[i]:
					dp[i+1][j][k]=dp[i][j][k]
				else:# k>=X[i]:
					dp[i+1][j+1][k]=dp[i][j+1][k]+dp[i][j][k-X[i]]
	
	r=0
	for i in range(1,n+1):
		r+=dp[n][i][i*a]
		
	return r
		
print(card(n,a))
	

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

int main()
{
    int h, r;

    cin >> h >> r;

    if( h + r == 0 )
        cout << 0 << endl;
    else if( h + r > 0 )
        cout << 1 << endl;
    else
        cout << -1 << endl;

    return 0;
}


Measured memory_bytes: 3104