akhauriyash/Code-Regression huggingface dataset:
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.reverse()
ans=[]
for i in range(k,n):
    if a[i]<a[i-k]:
        ans.append("Yes")
    else:
        ans.append("No")
ans.reverse()
for s in ans:
    print(s)


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

typedef long long int lld;

int main()
{
    lld n, k, i, s=0;
    cin >> n >> k;
    lld a[n];
    for(i=0; i<n; i++){
        cin >> a[i];
        s += a[i];
    }
    if(k>=n) s = 0;
    else {
        sort(a, a+n);
        for(i=0; i<k; i++){
            n--;
            s -= a[n];
        }
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>

using namespace std;
#define For(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)


int main()
{
	int N;

	cin >> N;
	vector<int> d(N);

	rep(i, N) {
		cin >> d[i];
	}

	int sum = 0;

	rep(i, N - 1) For(j, (i + 1), N) {
		sum += (d[i] * d[j]);
	}

	cout << sum << endl;

	return 0;
}

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

int main() {
	string s;
    cin >> s;
    string t = "CODEFESTIVAL2016";
    int ans = 0;
    for (int i = 0; i < 16; ++i) {
        if(s[i] == t[i]) continue;
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3596
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS

main = do
  n <- getLine
  ws <- getIntList
  print $ func 1 (sum ws) ws
  
func p min ws 
  | temp > min = min
  | otherwise = func (p+1) temp ws
  
  where 
    (ls, rs) = splitAt p ws
    lSum = sum ls
    rSum = sum rs 
    temp = abs (lSum - rSum)

readInt = fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words
getIntList = readIntList <$> BS.getLine


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> Edge;

int N, M;
vector<Edge> E;

/*UnionFind木を作成*/
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 is_same(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 bridge(UnionFind uf){
  int cn = 0;  //数
  for(int i = 0; i < M; i++){  //使わない辺を選択
    uf.init(N+1);
    for(int j = 0; j < M; j++){
      if(i == j) continue;  //使わない橋は飛ばす
      Edge ne = E[j];
      uf.merge(ne.first, ne.second);  //E[i]除いて結合
    }

    /*前提が連結：uf.size(k) !=N => 非連結<=>∃橋*/
    if(uf.size(1) != N) ++cn;
  }
  return cn;
}

int main(){
  cin >> N >> M;
  UnionFind uf(N+1);
  uf.init(N+1);

  int a, b;
  for(int i = 0; i <M; i++){ 
    cin >> a >> b; E.push_back({a, b});
   }
  
  cout << bridge(uf) << endl;

  return 0;
}
    
    
    
    

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

map<char,int> order;
string S; size_t cur=0;
stack<int> num,rnum,tmpnum;
stack<char> op,rop,tmpop;

int digit(){
	int n=S[cur++]-'0';
	return n;
}

int number(){
	int n=digit();
	while(isdigit(S[cur]))
		n=n*10+digit();
	return n;
}

void calc(){
	for(int i=1;i<=2;i++){
		while(!rop.empty()){
			if(order[rop.top()]!=i){
				tmpop.push(rop.top());rop.pop();
				tmpnum.push(rnum.top());rnum.pop();
			}
			else{
				int a=rnum.top();rnum.pop();
				int b=rnum.top();rnum.pop();
				char o=rop.top();rop.pop();
				int c;
				switch(o){
					case '+' :
						c=a+b;
						break;
					case '-' :
						c=a-b;
						break;
					case '*' :
						c=a*b;
						break;
					case '/' :
						c=a/b;
						break;
					default :
						break;
				}
				rnum.push(c);
			}
		}
		tmpnum.push(rnum.top());rnum.pop();
		if(tmpnum.size()==1)
			break;
		while(!tmpop.empty()){
			rop.push(tmpop.top());tmpop.pop();
			rnum.push(tmpnum.top());tmpnum.pop();
		}
		rnum.push(tmpnum.top());tmpnum.pop();
	}
	num.push(tmpnum.top());tmpnum.pop();
	return ;
}

int exp(){
	cur =0;
	int smax=S.size();
	while(cur < smax-1){
		//cout << cur << endl;
		if(isdigit(S[cur])){
			int a=number();
			num.push(a);
		}else if(S[cur] == ')' ){
 			while(!op.empty()&&op.top()!='('){
				rop.push(op.top());op.pop();
				rnum.push(num.top());num.pop();
			}
			rnum.push(num.top());num.pop();
			calc();
			//cout << num.top() << endl;
			op.pop();cur++;
		}else{//ひとまず終了　演算記号のチェックも入れる
			//	cout << "come" << endl;
			op.push(S[cur++]);
		}
	}
	//cout << num.top() << endl;//
	//int tmp1=num.top();num.pop();
	//cout << num.top() << endl;//
	//int tmp2=num.top();num.pop();
	//cout << num.top() << endl;//
	//num.push(tmp2);
	//num.push(tmp1);

	while(!op.empty()&&op.top()!='('){
		rop.push(op.top());op.pop();
		rnum.push(num.top());num.pop();
	}
	rnum.push(num.top());num.pop();

	calc();
	//cout<< " check "  << op.empty() << endl;
	int ans=num.top();
	num.pop();
	return ans;
}

int main(void){
	order['+']=2;
	order['-']=2;
	order['*']=1;
	order['/']=1;
	//cout << order['('] << endl;
	int n;
	cin >> n;
	while(n--){
		cin >> S;
		cout << exp() << endl;
	}
	return 0;
}

Measured memory_bytes: 1220
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  string s;
  while (cin >> s) {
    int G = count(s.begin(), s.end(), 'g');
    int res = G - (s.size() + 1) / 2;
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
#define k 10000
using namespace std;

void countingSort(int A[], int B[], int n) {
  int C[k];
  for (int i=0; i<k; i++) {
    C[i] = 0;
  }
  // Count A[j]
  for (int j=0; j<n; j++) {
    C[A[j]] ++;
  }
  // Accumulate
  for (int i=1; i<k; i++) {
    C[i] += C[i-1];
  }
  // Sort
  for (int j=n-1; j>=0; j--) {
    B[--C[A[j]]] = A[j];
  }
}

int main() {
  int n;
  scanf("%d", &n);
  int A[n], B[n];
  for (int i=0; i<n; i++) {
    scanf("%d", &A[i]);
  }
  countingSort(A, B, n);
  for (int i=0; i<n; i++) {
    if (i<n-1) {
      printf("%d ", B[i]);
    } else {
      printf("%d\n", B[i]);
    }

  }
  return 0;
}



Measured memory_bytes: 18296
from itertools import accumulate as AC
n = int(input())
s = input()
    

w = [0]*n
e = [0]*n

for i in range(n):
    if s[i] == 'W':
        w[i] = 1
    else:
        e[i] = 1
        
aw = list(AC(w))
ae = list(AC(e))

ans = 1000000

for i in range(n):
    if i == 0:
        current = ae[n-1]-ae[0]
    elif 0 < i < n-1:
        current = aw[i-1]+ae[n-1]-ae[i]
    else:
        current = aw[i-1]
        
    if ans > current:
        ans = current
        

     
print(ans)

Measured memory_bytes: 32204
#include <stdio.h>
#include <iostream>
using namespace std;

int main(){
	int num;
	cin >> num;
	string stone;
	cin >> stone;

	int black = 0;
	int left_black = 0;
	for(int i = 0; i < num; i++){
		if(stone[i] == '#') black++;
	}
  	int ans = num - black;
	for(int i = 0; i < num; i++){
		if(stone[i] == '#')	left_black++;
      	if(ans > num - (i+1) - black + 2*left_black) ans = num - (i+1) - black + 2*left_black;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
using namespace __gnu_pbds;

const int maxn = 2e5 + 7;
const int mod = 104206969;

long long n,a,b;

int main()
{
	scanf("%lld%lld%lld",&n,&a,&b);
	printf("%lld\n",n/(a+b)*a + min(a,n%(a+b)));
	return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int n;
  cin>>n;
  ll a[n+1]={};
  ll sum=0;
  for(int i=1;i<=n;i++){
    cin>>a[i];
    a[i]-=i;
    sum+=a[i];
  }
  ll it=sum/n;
  ll ans=0,ans2=0;
  ll tmp=0;
  sort(a+1,a+n+1);
  //for(int i=1;i<=n;i++) cout<<a[i]<<endl;
  if(n%2==0){
    tmp=a[(n/2)]+a[(n/2)+1];
    tmp/=2;
    //cout<<tmp<<endl;
  }else{
    tmp=a[(n/2)+1];
  }
  for(int i=1;i<=n;i++){
    ans+=abs(a[i]-tmp);
  }
  cout<<ans<<endl;
  /*for(int i=1;i<=n;i++){
    ans+=(abs(a[i]-it));
    ans2+=(abs(a[i]-it+1));
  }*/

  //cout<<min(ans,ans2)<<endl;
  //cout<<sum<<endl;
  return 0;
}


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

#define int long long int
#define mp make_pair
using namespace std;

int n;
vector <double > v(3000);
double dp[3000][3000];
double fun(int pos , int count)
{
    if(pos == n){
        if(count >= (n+1) / 2){
            return 1.0;
        }
        else{
            return 0;
        }
    }
    if(dp[pos][count] != -1){
        return dp[pos][count];
    }
    dp[pos][count] = v[pos]*fun(pos + 1 , count + 1) + (1 - v[pos])*fun(pos + 1 , count);
    return dp[pos][count];
}

int32_t main() {
    scanf("%lld", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%lf", &v[i]);
    }
    for (int i = 0; i < 3000; ++i) {
        for (int j = 0; j < 3000; ++j) {
            dp[i][j] = -1;
        }
    }
    double ans = fun(0 , 0);
    printf("%0.9lf",ans);
    return 0;
}

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

int main() {

    long long n, c, x[100002], v[100002];

    cin >> n >> c;
    for(int i = 1; i <= n; i++) {
        cin >> x[i] >> v[i];
    }

    long long ans = 0;
    long long lsum = 0, rsum = 0;
    long long lmaxi[100002] = {0}, rmaxi[100002] = {0};
    for(int i = 1; i <= n; i++) {
        lsum += v[i];
        lmaxi[i] = max(lmaxi[i - 1], lsum - x[i]);
        ans = max(ans, lmaxi[i]);
    }
    for(int i = n; i > 0; i--) {
        rsum += v[i];
        rmaxi[i] = max(rmaxi[(i + 1) % (n + 1)], rsum - (c - x[i]));
        ans = max(ans, rmaxi[i]);
    }

    for(int i = 0; i <= n; i++) {
        ans = max(lmaxi[i] - x[i] + rmaxi[(i + 1) % (n + 1)], ans);
    }
    for(int i = n; i >= 0; i--) {
        ans = max(rmaxi[i] - (c - x[i]) + lmaxi[(i - 1 + n + 1) % (n + 1)], ans);
    }
    cout << ans << endl;
}


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

int main () {
    string s;
    cin >> s;
    if (s[0] == s[1] && s[1] == s[2] && s[2] == s[0]) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))
#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)
#define All(x) (x).begin(),(x).end()
#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))
#define Unique(v) v.resize(unique(All(v)) - v.begin())
#define End '\n'
#define Out(x) cout<<(x)<<End
#define OutP(p, sep, end) cout<<p.first<<sep<<p.second<<end
template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair
#define X first
#define Y second

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

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

	int a, b, c;

	cin >> a >> b >> c;

	Out((a * b) / 2);
	
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String []args){
		//????????£????????????
		Scanner sc =  new Scanner(System.in);
		//???????????£?????\???
		int n = sc.nextInt();
		//n???????????§??????
		for(int i = 1;  i <= n; i++){
			//?????¶??? 3?????°????????????????????¨???
			if(i % 3 ==0  || Integer.toString(i).contains("3")){
					//3????????°????????¨???
					System.out.print(" " + i);
			}
		}
		System.out.println("");
	}
}

Measured memory_bytes: 28928
import Control.Monad
import Control.Applicative
import qualified Data.Map as Map

main = do
    [h,w] <- map read . words <$> getLine :: IO [Int]
    d <- forM [1..h] $ \raw -> do
       line <- map f <$> getLine 
       return (g raw line)
    putStrLn $ solve (Map.fromList (concat d)) h w

solve :: Arr -> Int -> Int -> String
solve dict h w = if solvable dict h w
                    then "Yes"
                    else "No"

solvable :: Arr -> Int -> Int -> Bool
solvable dict h w = and $ map (okay dict h w) keys
    where keys = Map.keys dict 


type Arr = Map.Map (Int,Int) Bool

adj :: Int -> Int -> (Int,Int) -> [(Int,Int)]
adj h w (i,j) = filter fil [(i-1,j),(i+1,j),(i,j-1),(i,j+1)]
    where fil (x,y) = and [1<=x,x<=h,1<=y,y<=w]

okay :: Arr -> Int -> Int -> (Int,Int) -> Bool
okay dict h w (i,j) = if ok dict (i,j)
                         then or (map (ok dict) (adj h w (i,j)))
                         else True

ok dict (i,j) = dict Map.! (i,j)

dic :: Int -> Int -> Map.Map (Int,Int) Bool
dic h w= Map.fromList (zip keys falses)
    where falses = repeat False
          keys = [(i,j)| i <- [1..h], j <- [1..w]]

f :: Char -> Bool
f '#' = True
f '.' = False

g :: Int -> [Bool] -> [((Int,Int),Bool)]
g raw line = map h line'
    where h = \(col,b) -> ((raw,col),b)
          line' = zip [1..] line


Measured memory_bytes: 1404
#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>;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint
{
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += mod - a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const
    {
        if (!t)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1)
            a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint &operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream &operator>>(istream &is, const mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }

int main()
{
    int n;
    cin >> n;
    int zero = 0;
    map<pair<ll, ll>, P> mp;
    rep(i, n)
    {
        ll x, y;
        cin >> x >> y;
        if (x == 0 && y == 0)
        {
            zero++;
            continue;
        }
        ll g = __gcd(x, y);
        x /= g;
        y /= g;
        if (y < 0)
            x = -x, y = -y;
        if (y == 0 && x < 0)
            x = -x, y = -y;
        bool rot90 = (x <= 0);
        if (rot90)
        {
            ll tmp = x;
            x = y;
            y = -tmp;
        }
        if (rot90)
            mp[{x, y}].first++;
        else
            mp[{x, y}].second++;
    }

    mint ans = 1;
    for (auto p : mp)
    {
        int s = p.second.first;
        int t = p.second.second;
        mint now = 1;
        now += mint(2).pow(s) - 1;
        now += mint(2).pow(t) - 1;
        ans *= now;
    }
    ans -= 1;

    ans += zero;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 15912
#include<bits/stdc++.h>
#define ll long long
#define FOR(i, a, b) for(ll i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define MOD1 1000000007
#define MOD2 998244353
#define IOS std::ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define print(a) for(auto x : a)    cout<<x<<" "; cout<<"\n";
using namespace std;

int main(){

    // IOS;
    
    long double r;
    cin >> r;
    long double pi = 22.0/7.0;
    long double c = 2 * pi * r;

    cout<<setprecision(20)<<c<<"\n";

    


    return 0;
}
// string s;
//     cin >> s;
//     set<int> val;
//     if(s.length() < 4)
//         cout<<"0\n";
//     else
//     {
//         int n = s.length();
//         int arr[n] = {0};
//         FOR(i, 0, n)    arr[i] = s[i] - '0';

//         // FOR(i, 1, 101)  cout<<2019*i<<"\n";

//         for(int i = 1; i*i <= 2019; i++)
//         {
//             if(2019 % i == 0)
//                 val.insert(i);
//             if(i != 2019 / i)
//                 val.insert(2019 / i);

//         }
//         print(val);
//     }

Measured memory_bytes: 3752
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String[] formula = br.readLine().split(" ");
		
		Deque<String> deq = new ArrayDeque<String>();
		
		for(int i = 0; i < formula.length; i++){
			int tmp1; 
			int tmp2;
			
			switch(formula[i]){
			case "+":
				tmp1 = Integer.parseInt(deq.removeFirst());
				tmp2 = Integer.parseInt(deq.removeFirst());
				
				deq.addFirst(Integer.toString(tmp2 + tmp1));
				break;
				
			case "*":
				tmp1 = Integer.parseInt(deq.removeFirst());
				tmp2 = Integer.parseInt(deq.removeFirst());
				
				deq.addFirst(Integer.toString(tmp2 * tmp1));
				break;
				
			case "-":
				tmp1 = Integer.parseInt(deq.removeFirst());
				tmp2 = Integer.parseInt(deq.removeFirst());
				
				deq.addFirst(Integer.toString(tmp2 - tmp1));
				break;
				
			default:
				deq.addFirst(formula[i]);
				break;
			}
		}
		
		System.out.println(deq.removeLast());
	}

}

Measured memory_bytes: 24472
#include <bits/stdc++.h>
using namespace std;
string s, c1, c2;

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

    cin>>s;
    int Q, t, f, i, j=0;
    char c;
    cin>>Q;
    //vector<string>c1, c2;
    for(i=0;i<Q;i++)
    {
        cin>>t;
        if(t==1) j++;
        else
        {
            cin>>f>>c;
            if(j%2==1 && f==1) f=2;
            else if(j%2==1 && f==2) f=1;
            if(f==1) c1=c+c1;
            else c2=c2+c;
        }
    }
    if(j%2)
    {
        reverse(s.begin(), s.end());
        reverse(c1.begin(), c1.end());
        reverse(c2.begin(), c2.end());
        s=c2+s+c1;
    }
    else s=c1+s+c2;
    cout<<s;
    return 0;
}



Measured memory_bytes: 1320
//#pragma region ALL(include define etc)
#include <iostream>   // swap(a, b)
#include <string>
#include <cmath>      // abs(絶対値) sin cos tan(角度 / 180.0 * 3.141592)
#include <vector>     // vec.push_back(a) vec.pop_back()
#include <algorithm>  // max(a, b) min(a, b) reverse() sort()
#include <functional> // sort(a, a + N, greater<型>());
#include <limits>
#include <math.h>
#include <iomanip>
#define int long long
//#define int unsigned long long
#define ll long long
#define double long double
using namespace std;
//#pragma endregion

signed main()
{
	// 10^18 = 1000000000000000000

	//int h1, h2, m1, m2, k;
	//int box, box1,box2;

	//int N;
	int n;
	//char n;
	//int a, b, c;
	//int m;
	int h, w, x;
	int k;
	int d;
	//int t;
	//string s;
	//string t;
	//int m1, m2;
	//int a, b, c, k;
	//int x, y;

	string s;
	//string s[100000];
	//string c[7];
	//int a[100000];
	//int b[200000];
	//int a[2000000] = { 0 };
	//int b[2000000] = { 0 };
	//int a[20000] = { 0 };
	//int b[20000] = { 0 };
	//vector<int>a(2000000);
	//vector<int>b(2000000);

	//int aaa = 0;
	//int bbb = 0;

	//int box[20000] = { 0 };
	char box[20000];
	int a[2000000] = { 0 };
	//int box = 0;
	//int box[7][7] = { 0 };
	//int box2;
	//int p[1111];
	//int x[2000], y[2000];
	//int l[100];


	//long double aaa;

	int count = 0;
	//int k, d;
	//int a = 0;
	int all = 0;
	//double all;
	//double a, b;
	//double h, m;
	//int a[30000] = { 0 };
	//double c, d, e;

	//double mbox, hbox;
	//double box, box2;

	bool flag = true;
	//bool flag = false;

	//string str;

	//cin >> h1 >> m1 >> h2 >> m2 >> k;
	cin >> n;
	//cin >> a >> b >> c;
	//cin >> s;
	//cin >> h >> w >> k;
	//cin >> n >> x >> t;

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

	/*for (int i = 0;i<n; i++)
	{
		if (i == 0)
		{

		}
		else
		{
			for (int j = 0; a[i - 1] > a[i]; j++)
			{
				a[i]++;
				all++;
			}
		}
	}*/

	for (int i = 1; i < n; i++)
	{
		if (a[i - 1] > a[i])
		{
			all += (a[i - 1] - a[i]);
			a[i] = a[i - 1];
		}
	}

	//getline(cin, s);

	/*for (int i = 0; i < count; i++)
	{
		all += s[i] - '0';
	}*/

	//n = s.length();

	//sort(p, p + n);
	//n = n - 'Z';

	//box = n % 26;

	//for (int i = 0; i < k; i++)
	//{
	//	all += p[i];
	//}

	//all = n + (n * n) + (n * n * n);

	/*if (n > 0)
	{
		cout << "a\n";
	}
	else
	{
		cout << "A\n";
	}*/
	//n = t.length();

	/*cout << "AC x " << ac << "\n";
	cout << "WA x " << wa << "\n";
	cout << "TLE x " << tle << "\n";
	cout << "RE x " << re << "\n";*/

	//cout << x << "\n";
	cout << all << "\n";
	//cout << box << "\n";
	//cout << a << b << c << "\n";

	/*if (flag == true)
	{
		cout << "Yes\n";
	}
	else
	{
		cout << "No\n";
	}*/

	//cout << fixed << setprecision(111) << all;
	//return 0;
}


Measured memory_bytes: 19228
package main

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

var (
	N, answer int
	cnt       [10][10]int
)

func readVariables() {
	N = nextInt()
}

func main() {
	readVariables()
	preCalc()
	for i := 0; i < 10; i++ {
		for j := 0; j < 10; j++ {
			answer += cnt[i][j] * cnt[j][i]
		}
	}
	fmt.Println(answer)
}

func preCalc() {
	for i := 1; i <= N; i++ {
		head, tail := getHeadTail(i)
		cnt[head][tail]++
	}
}

func getHeadTail(x int) (head, tail int) {
	strX := strconv.Itoa(x)
	head, _ = strconv.Atoi(string(strX[0]))
	tail, _ = strconv.Atoi(string(strX[len(strX)-1]))
	return
}

func count(head, tail, maxValue int) (result int) {
	if head == 0 {
		return
	}
	if head == tail && head <= maxValue {
		result++
	}
	if head*10+tail <= maxValue {
		result++
	}
	if head*100+tail > maxValue {
		return
	}
	ok := 0
	ng := maxValue
	// fmt.Println(ok, ng)
	for AbsInt(ok-ng) > 1 {
		var count int
		count++
		mid := (ok + ng) / 2
		value := tail + mid*10 + head*powInt(10, digits(mid)+1)
		if count > 10 {
			fmt.Println(ok, ng, mid, maxValue, value)
		}
		if value <= maxValue {
			ok = mid
		} else {
			ng = mid
		}
	}
	result += ok + 1
	return
}

func digits(x int) int {
	return len(strconv.Itoa(x))
}

func powInt(x, p int) (result int) {
	result = 1
	for i := 0; i < p; i++ {
		result *= x
	}
	return
}

func AbsInt(x int) int {
	if x < 0 {
		return -x
	} else {
		return x
	}
}

var scanner *bufio.Scanner

func init() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
}

//nextInt converts next token from stdin and returns integer value.
//nextInt panics when conversion into an integer fails.
func nextInt() int {
	if !scanner.Scan() {
		panic("No more token.")
	}
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic("nextInt(): cannot convert to int: " + scanner.Text())
	}
	return num
}

//MinInt は、2つの整数を受け取り、最小値を返す。
func MinInt(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}

//MaxInt は、2つの整数を受け取り、最大値を返す。
func MaxInt(x, y int) int {
	if x < y {
		return y
	} else {
		return x
	}
}


Measured memory_bytes: 3840
#pragma warning(disable: 4996)

#include <iostream>
#include <iomanip>
#include <random>
#include <unordered_map>
#include <functional>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <vector>
#include <bitset>
#include <numeric>
#include <string>
#include <set>
#include <tuple>
#include <utility>
#include <regex>
#include <deque>
#include <map>
#include <queue>
using namespace std;

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

	int n, m;
	cin >> n >> m;
	vector<pair<int, int> > v(n + 1); // AC, WA
	int p;
	string s;
	int ac = 0, penalty = 0;
	for (int i = 0; i < m; ++i) {
		cin >> p >> s;
		if (s == "AC" && v[p].first == 0) {
			++ac;
			penalty += v[p].second;
		}

		if (s == "AC") ++v[p].first;
		else ++v[p].second;
	}
	cout << ac << " " << penalty;
	return 0;
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
def main():
    StringN = input();
    listA = input().split();
    listA.sort();
#    newlistA = sorted(listA);
#    print(newlistA);

    for i in range(int(StringN)-1):
#        print(newlistA[i]);
#        print(newlistA[i+1]);
        if listA[i] == listA[i+1]:
            print('NO');
#            print (i)
            return 0;
    print('YES');


main();


Measured memory_bytes: 20796
#include<iostream>
#include<vector>
#include<functional>
#include<algorithm>
#include<cmath>
#include<string>
#include<iomanip>
using namespace std;



int main()
{
	const int num=310;
	int n;
	cin>>n;
	int a[num];
	int rem[4]={};
	int cnt=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		rem[a[i]]++;
		cnt+=a[i];
	}
	double dp[num][num][num]={};//1,2,3
	int sum2=rem[3]+rem[2];
	for(int k=0;k<=rem[3];k++)
	{
		for(int j=0;j<=sum2;j++)
		{
			for(int i=0;i<=n;i++)
			{
				if(i+j+k==0)
					continue;
				if(i)	dp[i][j][k]+=dp[i-1][j][k]*i;
				if(j)	dp[i][j][k]+=dp[i+1][j-1][k]*j;
				if(k)	dp[i][j][k]+=dp[i][j+1][k-1]*k;
				dp[i][j][k]+=n;
				dp[i][j][k]=dp[i][j][k]/(i+j+k);
			}
		}
	}
	cout<<setprecision(15)<<dp[rem[1]][rem[2]][rem[3]]<<endl;
}
	


Measured memory_bytes: 233088
import java.util.Scanner;
public class Main {
	 public static void main(String[] args) {
	        Scanner sc = new Scanner(System.in);
	        int chcnt[] = new int[26];
	        String str = "";
	        while(sc.hasNext()){
	            str = sc.nextLine();
	            str = str.toLowerCase();
	            for(int i = 0; i < str.length(); i++ ){
	                char ch = str.charAt(i);
	                if(ch <= 'z' && ch >= 'a') chcnt[ch - 'a']++;
	            }
	        }
	        for(int i = 0; i < chcnt.length; i++){
	            System.out.println((char)('a' + i) + " : " + chcnt[i]);
	        }
	    }
	}


Measured memory_bytes: 26304
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <set>
#include <iostream>
using namespace std;
typedef long long ll;
class data{
public:
	string str[8];
	data(){}
};

bool operator<(const data &d1,const data &d2){
	for(int i=0;i<8;i++){
		if(d1.str[i]!=d2.str[i])return d1.str[i]<d2.str[i];
	}
	return d1.str[7]<d2.str[7];
}

string str[8];
set<data> dat;
int id[8];
bool used[8];
int next[24][8]={
	{0,1,2,3,4,5,6,7},
	{3,0,1,2,7,4,5,6},
	{2,3,0,1,6,7,4,5},
	{1,2,3,0,5,6,7,4},

	{4,7,6,5,0,3,2,1},
	{5,4,7,6,1,0,3,2},
	{6,5,4,7,2,1,0,3},
	{7,6,5,4,3,2,1,0},

	{0,4,5,1,3,7,6,2},
	{1,0,4,5,2,3,7,6},
	{5,1,0,4,6,2,3,7},
	{4,5,1,0,7,6,2,3},

	{7,3,2,6,4,0,1,5},
	{6,7,3,2,5,4,0,1},
	{2,6,7,3,1,5,4,0},
	{3,2,6,7,0,1,5,4},

	{0,3,7,4,1,2,6,5},
	{4,0,3,7,5,1,2,6},
	{7,4,0,3,6,5,1,2},
	{3,7,4,0,2,6,5,1},

	{1,5,6,2,0,4,7,3},
	{2,1,5,6,3,0,4,7},
	{6,2,1,5,7,3,0,4},
	{5,6,2,1,4,7,3,0},

};
void dfs(int v){
	if(v==8){
		bool ok=true;
		for(int i=0;i<24;i++){
			data dl;
			for(int j=0;j<8;j++){
				dl.str[j]=str[id[next[i][j]]];
			}
			if(dat.find(dl)!=dat.end()){
				ok=false;
				break;
			}
		}
		if(ok){
			data dl;
			for(int j=0;j<8;j++){
				dl.str[j]=str[id[j]];
			}
			dat.insert(dl);
		}
	}else{
		for(int i=0;i<8;i++){
			if(!used[i]){
				id[v]=i;
				used[i]=true;
				dfs(v+1);
				used[i]=false;
			}
		}
	}
}

int main(void){
	while(cin>>str[0]){
		ll res=0,res2=0;
		for(int i=1;i<8;i++){
			cin >> str[i];
		}
		dat.clear();
		dfs(0);
		printf("%d\n",dat.size());
	}
	return 0;
}

Measured memory_bytes: 1384
#include <iostream>
using namespace std;
signed main(){
  long long a , b , c , d , x , y , z;
  cin>>a>>b>>c>>d;
  x = max(c,d) , y = min(c,d) , z = x%y;
  while(z != 0){
    x=y;
    y=z;
    z=x%y;
  }
  
  y =(c*d)/y;
  a--;
  cout<<(b-a) - ( ( (b/c)+(b/d)-(b/y) ) - ( (a/c)+(a/d)-(a/y) ) ) <<endl;
  return(0);
}
  

Measured memory_bytes: 256
//84104971101048411497 - Can you guess what does this mean?
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
#define mapii map<int, int>
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) fto(i, l, r) cout << a[i] << " "; cout << endl
#define fdto(i, r, l) for(int i = (r); i >= (l); --i)
#define fto(i, l, r) for(int i = (l); i <= (r); ++i)
#define forit(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define forrit(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define maxN 305
#define oo 1000000007
#define MOD 1000000007
#define sz(a) (int)a.size()

const double PI = acos(-1.0);

double fRand(double fMin, double fMax)
{
    double f = (double)rand() / RAND_MAX;
    return fMin + f * (fMax - fMin);
}

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

string s;
int n, k, dp[maxN][maxN][maxN];

int Solve(int i, int j, int k) {
    if (k < 0) return -oo;
    if (i > j) return 0;
    if (i == j) return 1;
    if (dp[i][j][k] != -1) return dp[i][j][k];

    int res;
    if (s[i] == s[j]) res = Solve(i+1, j-1, k)+2;
    else res = max(Solve(i+1, j-1, k-1)+2, Solve(i+1, j, k), Solve(i, j-1, k));

    return dp[i][j][k] = res;
}

int main () {
    cin >> s;
    n = s.length();
    scanf("%d", &k);

    fto(i, 0, n-1) fto(j, 0, n-1) fto(k, 0, n) dp[i][j][k] = -1;

    cout << Solve(0, n-1, k);

    return 0;
}



Measured memory_bytes: 110848
#include <iostream>
#include <string.h>
using namespace std;
int main()
{
   char str[21];
  while(cin>>str)
{
   int len=strlen(str);
   for(int i=len-1;i>=0;i--)
   cout<<str[i];
   cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 1132
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  int check=0;
  
  for(int i=0; i<N; i++){
    string s;
    cin >> s;
    if (s == "Y"){
      check++;
    }
  }
  
  if (check == 0){
    cout << "Three" << endl;
  }
  else{
    cout << "Four" << endl;
  }
       
 }

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

using namespace std;

using ll = long long;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout 
    << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

const int CMBMAX = 510000;
ll fac[CMBMAX], finv[CMBMAX], inv[CMBMAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i=2;i<CMBMAX;++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 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() {
    cin.tie(0);
    cout << fixed << setprecision(10);


    ll n, m, k; cin >> n >> m >> k;
    COMinit();

    ll sumx = 0;
    for(int i=1;i<n;++i) {
      ll tmp = m * m % MOD;
      tmp *= n - i;
      tmp %= MOD;
      sumx += i * tmp;
      sumx %= MOD;
    }
    sumx *= COM(n * m - 2, k - 2);

    ll sumy = 0;
    for(int i=1;i<m;++i) {
      ll tmp = n * n % MOD;
      tmp *= m - i;
      tmp %= MOD;
      sumy += i * tmp;
      sumy %= MOD;
    }
    sumy *= COM(n * m - 2, k - 2);

    cout << (sumx + sumy) % MOD << endl;
}

Measured memory_bytes: 12288
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ull = long long unsigned;
using P = pair<int,int>;
const int INF=1001001;
const int NMAX=8;


int main()
{
	int n;
	cin>>n;
	int x[20][20];
	int y[20][20];
	int a[20];
	rep(i,n){
		cin>>a[i];
		rep(j,a[i]){
			cin>>x[i][j];
			cin>>y[i][j];
			x[i][j]--;
				}
	}

	int ans=0;
	rep(i,1<<n){
	//	cout<<i<<'i'<<endl;
		int cnt=0;
		bool ok=true;
		rep(j,n){
			if (i & (1<<j)){
		//		cout<<j<<'j'<<endl;
				//cout<<j<<endl;
				cnt++;
				rep(k,a[j]){
			//		cout<<x[j][k]<<"xjk"<<endl;
					if (y[j][k]==0){
						if(i & (1<<x[j][k])){
					//		cout<<x[j][k]<<'x'<<endl;
							ok=false;
						}
					}
					if (y[j][k]==1){
						if(!(i & (1<<x[j][k]))){
							ok=false;
						//	cout<<"f"<<endl;
						}
					}
				}

			}

		}
	//	cout<<i<<'i'<<(ok==true)<<endl;


		if (ok==true){
			ans=max(ans,cnt);
			//cout<<'o'<<endl;
		}


	}
	cout<<ans;



}


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

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

	vector<int> kind(m);

	for(int i = 0; i < n; i++){
		int x;cin>>x;
		for(int j = 0; j < x; j++){
			int tmp;cin>>tmp;
			kind[tmp-1]++;
		}
	}

	int res = 0;
	for(int i = 0; i < m; i++){
		if(kind[i]==n) res++;
	}
	cout<<res;

}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <tuple>
#include <iomanip>

using namespace std;
#define MAX 1LL << 60

typedef long long ll;

#define rep(i, s, e) for(ll i = s; i < e; i++)
#define reft0(i, j) setfill('0') << setw(i) << j

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

int main(){
    ll N, W;
    ll w[110], v[110];


    cin >> N >> W;
    rep (i, 0, N){
        cin >> w[i] >> v[i];
    }

    ll ans[110][100010] = {0};
    rep(cntN, 0, N){
        rep(sum_w, 0, W + 1){
            if (sum_w - w[cntN] >= 0){
                chMax(ans[cntN + 1][sum_w], ans[cntN][sum_w - w[cntN]] + v[cntN]);
            }
            chMax(ans[cntN + 1][sum_w], ans[cntN][sum_w]);
        }
    }

    cout << ans[N][W] << endl;

    return 0;
}

Measured memory_bytes: 86272
# -*- coding:utf-8 -*-
import sys
import heapq


def solve():
    N, K = list(map(int, sys.stdin.readline().split()))
    Vs = list(map(int, sys.stdin.readline().split()))

    ans = 0
    for i in range(0, K+1):
        for j in range(0, K+1):
            if i+j > K: break
            if i+j > N: break

            _Vs = Vs[::-1]
            have = Vs[0:i]+_Vs[0:j]
            have.sort(reverse=True)

            M = i+j
            while M < K:
                if len(have) == 0: break
                if have[-1] < 0:
                    have.remove(have[-1])
                    M += 1
                    continue
                break

            ans = max(ans, sum(have))

    print(ans)



if __name__ == "__main__":
    solve()


Measured memory_bytes: 3188
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)     (x).begin(),(x).end()
# define UNIQ(c)    (c).erase(unique(ALL((c))), end((c)))
# define mp         make_pair
# define eb         emplace_back
# define FOR(i,a,b) for(int i=(a);i<(b);++i)
# define REP(i,n)   FOR(i,0,n)
# define INIT       std::ios::sync_with_stdio(false);std::cin.tie(0);

const int MOD = 100000;


int h, w;
int dp[5][1010][1010];

int main() {
	while (cin >> w >> h&&w&&h) {
		for (int i = 0; i < h; i++)dp[0][i][0] = 1;
		for (int i = 0; i < w; i++)dp[1][0][i] = 1;
		for (int i = 1; i < h; i++) {
			for (int j = 1; j < w; j++) {
				dp[0][i][j] = (dp[0][i - 1][j] + dp[2][i - 1][j]) % MOD;
				dp[1][i][j] = (dp[1][i][j - 1] + dp[3][i][j - 1]) % MOD;
				dp[2][i][j] = dp[1][i - 1][j];
				dp[3][i][j] = dp[0][i][j - 1];
			}
		}
		int ans = 0;
		for (int i = 0; i < 4; i++) {
			ans += dp[i][h - 1][w - 1];
		}
		cout << ans%MOD << endl;
	}
}

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

int n, ans;
map<int, int> h;

int main()
{
	int i, x, y;
	cin >> n;
	
	for (i=0; i<n; ++i)
	{
		cin >> x;
		++h[x];
	}
	
	for (auto j=h.begin(); j!=h.end(); ++j)
	{
		x=j->first;
		y=j->second;
		
		if (y<x) ans+=y;
		if (y>x) ans+=y-x;
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4736
program hrn;
 var
  s,t:string;
  l,i,c,x,a,b:longint;
 begin
  read(s);
  l:=length(s);
  for i:=1 to l do
   if(s[i]='+')or(s[i]='-')then c:=i;
  for i:=1 to c-2 do t:=t+s[i];
  val(t,a);t:='';
  for i:=c+2 to l do t:=t+s[i];
  val(t,b);t:='';
  if s[c]='+'then writeln(a+b)else writeln(a-b);
 end.

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

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    ll n,k,ans;
    while(cin >> n >> k)
    {
        if(k == 0)
        {
            cout << n*n << '\n';
            continue;
        }
        
        ans = 0;
        for(ll i = k+1; i <= n; i++)
        {
            ll aux = i-k;
            ans += aux * (n/i);
            aux = n%i;
            if(aux > 0)
                ans += max(0LL, aux - k + 1);
        }
        cout << ans << '\n';
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=1e9+7;
int dx[]={-1,0,1,-1,0,1,-1,0,1};
int dy[]={-1,-1,-1,0,0,0,1,1,1};
int main(){
    ll a,b;cin>>a>>b;
    vector<vector<bool> >c(101,vector<bool>(101));
    bool f;
    if(a<=b)f=1;
    else f=0;
    ll x=min(a,b),y=max(a,b);
    ll k=(x-1)/50,l=(x-1)%50;
    rep(i,k+1){
        rep(j,100){
            c[i][j]=(i+j)%2;
        }
    }
    ll cnt=0;
    rep(i,100){
        if(cnt==l){
            c[k][i]=1;
        }
        else if(c[k][i]==0){
            cnt++;
        }
        c[k+1][i]=1;
    }
    ll cnt2;
    if(k==0)cnt2=1;
    else cnt2=50*k+cnt+1-50;
    REP(i,1,99){
        REP(j,1,99){
        bool d=1;
        rep(t,9){
            if(c[i+dx[t]][j+dy[t]])d=0;
        }
        if(d){
            c[i][j]=1;
            cnt2++;
        }
        if(cnt2==y)break;
        }
        if(cnt2==y)break;
    }
    cout<<100<<' '<<100<<endl;
    rep(i,100){
        rep(j,100){
            if(f){
                if(c[i][j])cout<<'#';
                else cout<<'.';
            }else{
                if(c[i][j])cout<<'.';
                else cout<<'#';
            }
        }
        cout<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int main() {
  int a,b,c;
  int N = 10000;
  cin>>a>>b>>c;
  int cnt = 0;
  repn(i,c){
    if (c%i == 0){
      if (a<=i && i<=b){
        cnt++;
      }
    }
  }
  cout << cnt << endl;
}


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

using namespace std;

int c = 0;
void bubbleSort(int a[], int n)
{
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n - 1; j++)
        {
            if (a[j] > a[j + 1])
            {
                swap(a[j], a[j + 1]);
                c++;
            }
        }
    }
}

int a[110];
int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
    }
    bubbleSort(a, n);
    for (int i = 0; i < n-1; i++)
    {
        cout << a[i] << " ";
    }
    cout << a[n-1] << endl;
    cout << c << endl;

    return 0;
}


Measured memory_bytes: 3228
n=int(input())
f=[list(map(int,input().split())) for _ in range(n)]
p=[list(map(int,input().split())) for _ in range(n)]
inf=float("inf")
ans=-inf
for i in range(1,2**10):
    cc=0
    for k in range(n):
        c=0
        for j in range(10):
            if ((i>>j)&1) and f[k][j]:
                c+=1
        cc+=p[k][c]
    ans=max(ans,cc)
print(ans)


Measured memory_bytes: 42092
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //d
  int h, w;
  cin >> h >> w;
  vector<string> g(h);
  int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};
  for (int i = 0; i < h; i++) cin >> g[i];
  int ans = 0;
  for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) {
    if (g[i][j] == '#') continue;
    vector<vector<int>> dist(h, vector<int>(w, -1));
    dist[i][j] = 0;
    queue<pair<int, int>> que;
    que.emplace(i, j);
    while (que.size()) {
      auto cur = que.front();
      que.pop();
      for (int k = 0; k < 4; k++) {
        int x = cur.first + dx[k];
        int y = cur.second + dy[k];
        if (x < 0 || x >= h || y < 0 || y >= w || g[x][y] == '#') continue;
        if (dist[x][y] == -1) {
          dist[x][y] = dist[cur.first][cur.second] + 1;
          que.emplace(x, y);
        }
      }
    }
    int d = 0;
    // for (int ii = 0; ii < h; ii++) {
    //   for (int jj = 0; jj < w; jj++) {
    //     cerr << setw(3) << dist[ii][jj];
    //   }
    //   cerr << endl;
    // }
    // cerr << endl;
    for (int ii = 0; ii < h; ii++) for (int jj = 0; jj < w; jj++) {
      d = max(dist[ii][jj], d);
    }
    ans = max(d, ans);
  }
  cout << ans << '\n';
  return 0;
}

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

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <int, ii> iii;
typedef pair<ll, ll> pll;
typedef pair<double, int> pdi;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
#ifdef VC
#define scanf scanf_s
#endif
#define iINF (1<<30)
#define INF (1LL<<59)
#define forn(i) for(int i = 0;i < n; ++i)
#define form(i,n) for(int i = 0 ;i < n; ++i)
#define NIL -1

const int mod = 1e9+7;
int n;
int m;
int p[100000 + 10];
int par[100000 + 10];
int rnk[100000 + 10];

void init() {
	forn(i) {
		par[i] = i;
		rnk[i] = 1;
	}
}

int findp(int c) {
	if (c == par[c])return c;
	else return findp(par[c]);
}

bool isU(int l, int r) {
	return findp(l) == findp(r);
}

void unite(int l, int r) {
	int pl, pr;
	pl = findp(l);
	pr = findp(r);
	if (pl == pr)return;
	if (rnk[pl] < rnk[pr]) {
		par[pl] = pr;
	}
	else {
		par[pr] = pl;
		if (rnk[pl] == rnk[pr])rnk[pl]++;
	}
}
int main() {
	cin >> n >> m;
	forn(i)cin >> p[i];
	init();
	form(i, m) {
		int x, y;
		cin >> x >> y;
		unite(x, y);
	}
	int ans = 0;
	forn(i) {
		if (isU(i + 1, p[i]))ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int MOD = 1e9+7;
int h, w;
vector< vector<char> > amap(1010, vector<char>(1010, '.'));
int dp[1010][1010];

int main() {
    cin >> h >> w;
    for(int i = 0; i < h; ++i) {
        for(int j = 0; j < w; ++j) {
            cin >> amap.at(i).at(j);
        }
    }

    dp[1][1] = 1;
    for(int i = 0; i < h; ++i) {
        for(int j = 0; j < w; ++j) {
            if(i == 0 && j == 0) {

            }else {
                if(amap.at(i).at(j) != '#') {
                    dp[i+1][j+1] = dp[i][j+1] + dp[i+1][j];
                    dp[i+1][j+1] %= MOD;
                }else {
                    dp[i+1][j+1] = 0;
                }
            }
        }
    }

    cout << dp[h][w] << endl;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int N; cin >> N;
    vector<ll> A(N);
    REP(i, 0, N) cin >> A[i];
    sort(ALL(A));

    ll ans = 0;;
    if (N % 2 == 0) {
        ans = 2 * accumulate(A.begin() + N / 2, A.end(), 0LL) - 2 * accumulate(A.begin(), A.begin() + N / 2, 0LL) - A[N / 2] + A[N / 2 - 1];
    } else {
        ans = max(ans, 2 * accumulate(A.begin() + N / 2, A.end(), 0LL) - 2 * accumulate(A.begin(), A.begin() + N / 2, 0LL) - A[N / 2] - A[N / 2 + 1]);
        ans = max(ans, 2 * accumulate(A.begin() + (N + 1) / 2, A.end(), 0LL) - 2 * accumulate(A.begin(), A.begin() + (N + 1) / 2, 0LL) + A[N / 2] + A[N / 2 - 1]);
    }

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

Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <iomanip>
#include <cmath>
#include <queue>
#include <bitset>
#include <numeric>
#include <array>
#include <cstring>
#include <random>
#include <chrono>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() {

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

  int n = 0;

  cin >> n;

  int ans = 0;

  for(int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    ans += (i % 2 && x % 2);
  }

  cout << ans;

  return 0;
}
/*

*/


Measured memory_bytes: 3580