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

int main()
{
	string s;
	cin >> s;
	for(int i = 0;i<s.size();i++)
	{
		if(s[i]=='?')s[i] = 'D';
	}
	cout<<s<<endl;
}

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

int x, y;

int main() {
    cin >> x >> y;
    map<int, int> money;
    money[1] = 300000;
    money[2] = 200000;
    money[3] = 100000;
    int ans = money[x] + money[y];
    if ((x == 1) && (y == 1)) ans += 400000;
    cout << ans << endl;
}


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

using LL = long long int;

class Solution {
public:
    LL solve(vector<LL> &prefix) {
        return countPairs(prefix, 0, prefix.size());
    }

    LL countPairs(vector<LL> &prefix, int begin, int end) {
        if(begin + 1 >= end) {
            return 0;
        }
        int mid = (begin + end) / 2;
        LL left = countPairs(prefix, begin, mid);
        LL right = countPairs(prefix, mid, end);
        LL self = 0;
        for(int i = begin, j = mid; i < mid; ++ i) {
            for(; j < end && prefix[j] < prefix[i]; ++ j)
                ;
            self += end - j;
        }

        static vector<LL> cache;
        cache.resize(end - begin);
        merge(prefix.begin() + begin, prefix.begin() + mid,
              prefix.begin() + mid, prefix.begin() + end,
              cache.begin()
        );
        copy(cache.begin(), cache.end(), prefix.begin() + begin);
        return left + self + right;
    }
};

int main() {
    Solution s;
    int N;
    LL K;
    cin >> N >> K;
    vector<LL> prefix(N+1);
    for(int i = 1; i <= N; ++ i) {
        cin >> prefix[i];
        prefix[i] += prefix[i-1];
    }
    for(int i = 1; i <= N; ++ i) {
        prefix[i] -= K * i;
    }
    cout << s.solve(prefix) << endl;
    return 0;
}


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

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

    int N; cin >> N;
    int a[N];
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    ll ans[N];
    memset(ans,1e9+2,sizeof(ans));
    ans[0] = 0;
    for(int i=0;i<N;i++){
        if(i+1<N){
            ans[i+1] = min(ans[i+1],ans[i]+abs(a[i+1]-a[i]));
        }
        if(i+2<N){
            ans[i+2] = min(ans[i+2],ans[i]+abs(a[i+2]-a[i]));
        }

    }
    cout << ans[N-1];

    return 0;
}


Measured memory_bytes: 1408
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var s string
	fmt.Scan(&s)
	
	min := 753
	for i := 0; i < len(s)-2; i++ {
      if min > abs(753,digits(s[i:i+3])) {
			min = abs(753,digits(s[i:i+3]))
		}
	}
	fmt.Println(min)
}

func digits(num string)int {
	sum := 0
	multi := 100
	for i := 0; i < len(num); i++ {
    	tmp,_ := strconv.Atoi(string(num[i]))
     	sum += tmp * multi
		multi /= 10
	}
	return sum
}

func abs(a,b int)int {
	if a > b {
		return a - b
	} else {
		return b - a
	}
}

Measured memory_bytes: 512
from math import factorial

q = int(input())
mod = 1000003

fact = [0 for i in range(mod)]
fact[0] = 1
for i in range(1, mod):
    fact[i] = (fact[i - 1] * i) % mod


def query():
    x, d, n = map(int, input().split())
    if d == 0:
        return pow(x, n, mod)
    first = (x * pow(d, mod - 2, mod)) % mod
    if first + n - 1 >= mod:
        return 0
    return (fact[first + n - 1] * pow(fact[first - 1], mod - 2, mod) * pow(d, n, mod)) % mod


print("\n".join([str(query()) for i in range(q)]))


Measured memory_bytes: 114160
import qualified Data.Vector.Unboxed as U
import qualified Data.ByteString.Char8 as C
import Data.List


r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

mdl :: Num a => a
mdl = 10^9 + 7

t a b = a * b `mod` mdl

positivize x = if x < 0 then x + mdl else x

main :: IO ()
main = do
    [n,a,b] <- r' :: IO [Int]
    let al = powMod 2 n - 1
    let na = chooseOpt n a
    let nb = chooseOpt n b
    print $ positivize $ (al - na - nb) `mod` mdl

powMod :: Int -> Int -> Int
powMod cur 0 = 1
powMod cur n
    | even n = powMod (t cur cur) (div n 2)
    | odd n  = (t cur) $! powMod (t cur cur) (div n 2)

chooseOpt n i
    | n-i < i   = choose n (n-i)
    | otherwise = choose n i
    where
    choose :: Int -> Int -> Int
    choose n i = t (prod' $ U.generate i (+ (n-i+1)) ) $ modInv (prod' $ U.generate i succ)

prod' :: U.Vector Int -> Int
prod' = U.foldr' t 1

modInv :: Int -> Int
modInv a =  let (x,_,1) = eEA a mdl
            in  positivize x

eEA :: Int -> Int -> (Int, Int, Int)
eEA a 0 = (1, 0, a)
eEA a b =   let (q, r) = a `quotRem` b
                (s, t, g) = eEA b r
            in  (t, s-q*t, g)

Measured memory_bytes: 7036
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int ch(int x){
  if(x < 0){x *= (-1);}
  return x;
}

int main()
{
    // 入力
    int n; // 都市数
    cin >> n;
    vector<vector<int> > v(2, vector<int>(n)); 
    for (int i = 0; i < 2; ++i) {
      for(int j = 0; j < n; j++){
        cin >> v[i][j];
      } 
    }

    // 初期順列
    vector<int> order(n);
    for (int i = 0; i < n; ++i) order[i] = i+1;


    // 探索
    
    int q = 0;
    int a = 0;
    int b = 0;
    do {
      bool fp = true;
      bool fq = true;
      for(int i = 0; i < n; i++){
        if(v[0][i] != order[i]){fp = false;}
        if(v[1][i] != order[i]){fq = false;}
      }
      if(fp){a = q;}
      if(fq){b = q;}
      q = q+1;
    } while (next_permutation(order.begin(), order.end()));

    // 答えを出力
    cout << ch(a-b) << endl;
}

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

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define vecst   vector<string>
#define vecb    vector<bool>

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << var << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt((ok ? "Yes" : "No"));}
//----------------------------------------------------------------
int divi[1001];

int main(void) {
  string s;
  cin >> s;

  int a=0, b=0;
  rep(i,s.size()){
    if(s[i]=='A'){
      a=i;
      break;
    }
  }

  rep(i,s.size()){
    if(s[s.size()-i-1]=='Z'){
      b=s.size()-i-1;
      break;
    }
  }
  prt(b-a+1);

}


Measured memory_bytes: 640
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
// aiが不必要ならajも不必要
bool dp[5050][5050];
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N,K;
  cin>>N>>K;
  int a[N];
  FOR(i,0,N)cin>>a[i];
  sort(a,a+N);
  // iが必要かどうか
  int l=-1,r=N;
  while(r-l>1){
    int med = (l + r) / 2;
    vector<int> b;
    FOR(j,0,N){
      if(med==j)continue;
      b.push_back(a[j]);
    }
    CLR(dp);
    dp[0][0]=true;
    FOR(i,0,N-1){
      FOR(j,0,K+1){
        // 加える
        if(j+b[i]<=K)
        dp[i+1][j+b[i]] |= dp[i][j];
        // 加えない
        dp[i+1][j] |= dp[i][j];
      }
    }
    bool need = false;
    FOR(j,max(0,K-a[med]),K){
      if(dp[N-1][j]){
        need = true;
        break;
      }
    }
    if(need){
      r = med;
    } else {
      l = med;
    }
  }
  cout<<r<<endl;
}

Measured memory_bytes: 25216
#ステップについて
#順列の全列挙(N!通り)をする
#平均移動距離を求める

import math

#入力受付
n=int(input())
xy=[]
for _ in range(n):
    #map(関数, イテラブル) ＜＝高階関数
	x,y=map(int,input().split())
	xy.append([x,y])

# print(xy)

ans=0
for i in range(n):
	for j in range(n):
		ans+=math.sqrt((xy[i][0]-xy[j][0])**2+(xy[i][1]-xy[j][1])**2)
print(ans/n)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <functional>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define mk make_pair

template <class key, class cmp = std::less<key>>
using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
const ll mod = 1e9 + 7;

/*
    if you have any question about any part of my code,
    please don't shy to ask anytime :)
*/


void solve()
{
    ll n;
    cin>>n;
    ll lol=0;
    for(int i=0;i<n;i++)
    {
        (lol = (lol*10+7))%=n;
        if(lol%n==0)
        {
            cout<<i+1<<endl;
            return ;
        }
    }

    cout<<"-1"<<endl;
}

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

    // ll t;
    // cin >> t;
    // while (t--)
    // {
    //     solve();
    // }
    solve();
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll a, b, t;
    cin >> a >> b >> t;
    cout << b*(t/a) << endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdint>
#include <math.h>
#include <vector>

using namespace std;

void koch_curve(vector<pair<double, double>> &vec, uint32_t num)
{
  if (num == 0) {
  } else {
    vector<pair<double, double>> v;
    for (uint32_t i = 0; i < vec.size() - 1; i++) {
      pair<double, double> left = vec[i];
      pair<double, double> right = vec[i + 1];
      pair<double, double> s;
      pair<double, double> t;
      pair<double, double> u;
      s.first = (2 * left.first + 1 * right.first) / 3;
      s.second = (2 * left.second + 1 * right.second) / 3;
      t.first = (1 * left.first + 2 * right.first) / 3;
      t.second = (1 * left.second + 2 * right.second) / 3;
      u.first = (t.first - s.first) * cos(M_PI / 3.0) - (t.second - s.second) * sin(M_PI / 3.0) + s.first;
      u.second = (t.first - s.first) * sin(M_PI / 3.0) + (t.second - s.second) * cos(M_PI / 3.0) + s.second;
      v.push_back(left);
      v.push_back(s);
      v.push_back(u);
      v.push_back(t);
    }
    v.push_back(vec[vec.size() - 1]);

    vec.clear();
    for (uint32_t i = 0; i < v.size(); i++) {
      vec.push_back(v[i]);
    }

    koch_curve(vec, num - 1);
  }
}

#if !defined(TEST)
#include <cstdio>

int32_t main()
{
  int32_t num;
  scanf("%d", &num);

  vector<pair<double, double>> vec{{0.0, 0.0}, {100.0, 0.0}};
  koch_curve(vec, num);
  for (uint32_t i = 0; i < vec.size(); i++) {
    printf("%.8f %.8f\n", vec[i].first, vec[i].second);
  }

  return 0;
}
#endif

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

int main() {
    int64_t n, h;
    cin >> n >> h;
    vector<int64_t> a(n), b(n);
    for (int64_t i = 0; i < n; i++) cin >> a[i] >> b[i];
    sort(begin(a), end(a), greater<>());
    sort(begin(b), end(b), greater<>());
    auto itr = upper_bound(begin(b), end(b), a[0], greater<>());
    partial_sum(begin(b), itr, begin(b));
    auto bor = lower_bound(begin(b), itr, h);
    if (bor == itr) bor--;
    int64_t ans = bor - begin(b) + 1l + (max(0l, h - *bor) + a[0] - 1l) / a[0];
    cout << ans << endl;
}


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

int main() {
	int h, w;
	vector<string> str(100);
	cin >> h >> w;
	for (int i = 0; i < h; i++) cin >> str[i];
	for (int i = 0; i < w + 2; i++) cout << '#';
	cout << endl;
	for (int i = 0; i < h; i++) cout << '#' + str[i] + '#' << endl;
	for (int i = 0; i < w + 2; i++) cout << '#';
	cout << endl;
}


Measured memory_bytes: 256
/* template.cpp {{{ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)(s))
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)(s))
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
/* }}} */

int main(){
  ll n, k;
  cin >> n >> k;
  ll lb = 0, ub = 1e18 + 10;
  while (ub - lb > 1){
    ll md = (lb + ub) / 2;
    ll x = md;
    bool f = false;
    rep(n){
      if (x == 0) f = true;
      if (x % k == 0) x++;
      x = x - 1 - x / k;
    }
    (f ? lb : ub) = md;
  }
  cout << lb << endl;
}

Measured memory_bytes: 3188
import java.util.Scanner;

/**
 *
 * @author cs18097
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int count = 0;
        for(int i = 1;i < n+1;i++){
            if(i != sc.nextInt())count++;
        }
        if(count<3){
            System.out.print("YES");
        } else {
            System.out.print("NO");
        }
    }
    
}


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

using namespace std;
using ll =long long;
using db = double;
using vll = vector<long long>;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(a) {SORT(a);(a).erase(unique((a).begin(),(a).end()),(a).end());}
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
#define debug(x)  cout << #x << " = " << (x) << endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;
const ll INF = 1LL << 60;
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//グラフ用
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};	
//ここから書き始める

int main()
{
	cout <<setprecision(10);
int r ;
cin >> r;
cout << r * r << endl;

}


Measured memory_bytes: 256
import math
while True:
    n=int(input())
    if n==0:
        break
    else:
        s=list(map(int,input().split()))
        S=sum(s)
        m=S/n
        i=0
        a=[]
        for i in range(n):
            i+=1
            ai=float((s[i-1]-m)**2)
            a.append(ai)
        A2=sum(a)/n
        A=math.sqrt(A2)
        print(f'{A:.8f}')


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long N, std::vector<long long> A){
    sort(ALL(A), greater<LL>());
    LL ans = 0;
    REP(i, N-1) {
        if(A[i] == A[i+1]) {
            if(ans == 0) {
                ans = A[i];
                i++;
            } else {
                ans *= A[i];
                cout << ans << endl;
                return;
            }
        }
    }

    cout << 0 << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


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

int main()
{
    int N, D;

    cin >> N >> D;
    int count = 0;

    double X, Y;
    for(int i = 0; i < N; i++) {
        cin >> X >> Y;
        if(sqrt(pow(X, 2) + pow(Y, 2)) <= D) {
            count += 1;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3840
from itertools import groupby
N = int(input())
v_list = list(map(int, input().split()))
v1 = [v_list[2*i] for i in range(N//2)]
v2 = [v_list[2 * i + 1] for i in range(N // 2)]

v1.sort()
first = 0
second = 0
firstkey = 0
secondkey = 0
for key, group in groupby(v1):
    count = len(list(group))
    # print(key, count)
    if count >= first:
        first, second = count, first
        firstkey, secondkey = key, firstkey
    elif count >= second:
        second = count
        secondkey = key
v1_dict = {firstkey: first, secondkey: second}

v2.sort()
first = 0
second = 0
firstkey = 0
secondkey = 0
for key, group in groupby(v2):
    count = len(list(group))
    # print(key, count)
    if count >= first:
        first, second = count, first
        firstkey, secondkey = key, firstkey
    elif count >= second:
        second = count
        secondkey = key
v2_dict = {firstkey: first, secondkey: second}


# print("1，2番目に多い要素の数", first, second)
v1_dict.pop(0, "")
v2_dict.pop(0, "")

# print(v1_dict)
# print(v2_dict)

if len(v1_dict) == len(v2_dict) == 1 and v1_dict == v2_dict:  # 双方に1種類の値しかなく、中身が同じ(入力＝同じ文字N個)
    print(N // 2)
else:
    min_change = 10**10
    for key1, value1 in v1_dict.items():
        for key2, value2 in v2_dict.items():
            # print(key1, key2, "  ", value1, value2)
            if key1 == key2:
                continue
            rest = N-value1-value2
            if value1 > N // 2:
                temp = rest + value1 - N // 2
            elif value2 > N // 2:
                temp = rest + value2 - N // 2
            else:
                temp = rest

            if temp < min_change:
                min_change = temp
    print(min_change)


Measured memory_bytes: 14104
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

int N=1<<18;
class StarrySkyTree{
public:
  ll Ma[555555],A[555555];
  void init(){memset(Ma,0,sizeof(Ma)),memset(A,0,sizeof(A));}
  void add(int a,int b,ll x,int k=0,int l=0,int r=N) {
    if(r<=a||b<=l) return;
    if(a<=l&&r<=b){
      A[k]+=x;
      while(k){
        k=(k-1)/2;
        Ma[k]=max(Ma[k*2+1]+A[k*2+1],Ma[k*2+2]+A[k*2+2]);
      }
      return;
    }
    add(a,b,x,k*2+1,l,(l+r)/2);
    add(a,b,x,k*2+2,(l+r)/2,r);
  }
  ll getMax(int a,int b,int k=0,int l=0,int r=N) {
    if(r<=a||b<=l)return -LLONG_MAX;if(a<=l&&r<=b)return Ma[k]+A[k];
    ll left=getMax(a,b,k*2+1,l,(l+r)/2),right=getMax(a,b,k*2+2,(l+r)/2,r);
    return max(left,right)+A[k];
  }
};

StarrySkyTree t,r;

void Main() {
  t.init(),r.init();
  ll n,k,c;
  string s;
  cin >> n >> k >> c >> s;
  rep(i,n) {
    ll x=t.getMax(0,max(0LL,i-c)+1);
    t.add(i+1,i+2,x+(s[i]=='o'));
  }
  rrep(i,n) {
    ll x=r.getMax(min(n,i+c+1),n+1);
    r.add(i,i+1,x+(s[i]=='o'));
  }
  vector<ll> v;
  rep(i,n) {
    ll x=t.getMax(i+1,i+2);
    ll y=t.getMax(0,max(0LL,i-c)+1);
    ll z=r.getMax(min(n,i+c+1),n+1);
    if(y+z+1==k&&s[i]=='o') v.pb(i+1);
  }
  rep(i,v.size()) {
    ll x=-MAX,y=MAX;
    if(i) x=v[i-1];
    if(i+1<v.size()) y=v[i+1];
    if(abs(x-v[i])>c&&abs(y-v[i])>c) pr(v[i]);
  }
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

bool	is_describable(const set<int> &resi_set, int C)
{
	if (C == 0)
		return true;
	for (int x : resi_set) {
		if (x > C) break;
		if (is_describable(resi_set, C - x))
			return true;
	}
	return false;
}

int	main()
{
	int	A, B, C;
	cin >> A >> B >> C;
	set<int>	resi_set;
	int	residual;
	for (int i = 1; i < B; ++i) {
		residual = (A * i) % B;
		if (residual == 0) continue;
		if (resi_set.count(residual))
			break;
		resi_set.insert(residual);
	}
	if (is_describable(resi_set, C))
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}	


Measured memory_bytes: 256
use std::io::Read;
use std::io::{stdout, BufWriter, Write};

fn main() {
    let mut buf = String::new();

    // stdinから全てbufに読み込む
    std::io::stdin().read_to_string(&mut buf).unwrap();

    // 読み込んだ文字列をスペースで分解する
    let mut iter = buf.split_whitespace();

    // about n
    let n: u64 = iter.next().unwrap().parse().unwrap();

    // ans
    let mut ans: u64 = 0;
    
    let mut q = 1;
    while q * q < n {
        if n / q > 0 && n % q == 0 {
            let m = n / q - 1;
            if n / m == n % m {
                ans += m;
            }
        }
        q += 1;
    }

    // 出力
    let out = stdout();
    let mut out = BufWriter::new(out.lock());
    writeln!(out, "{}", ans).unwrap();
}

Measured memory_bytes: 4352
#include <stdio.h>
int main()
{
    int a,b,c;

    scanf("%d %d %d",&a,&b,&c);

    if(a<b){
        if(b<c){
            printf("Yes\n");
        }else{
            printf("No\n");
        }
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 1756
from bisect import bisect_right

N, M = map(int, input().split())
S = [-i for i, s in enumerate(input()) if s == '0']
S = S[:: -1]

ans = []
now = 0
while S[now] != 0:
    to = bisect_right(S, S[now] + M) - 1

    if to == now:
        print('-1')
        exit()
    ans.append(S[to] - S[now])
    now = to

ans = ans[:: -1]
print(*ans)

Measured memory_bytes: 10248
n = int(input())
w = list(map(int, input().split()))
a, b = [], []
a.append(w.pop(0))
b.append(w.pop(-1))

while(len(w)>0):
    if sum(a) < sum(b):
        a.append(w.pop(0))
        continue
    else:
        b.append(w.pop(-1))

print(abs(sum(a)-sum(b)))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef long double ldb;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

char s[3001],t[3001],f[3001];
int main() {
	scanf("%s",s);
	scanf("%s",t);
	int a=strlen(s),b=strlen(t);
	int dp[a+1][b+1];
	rep(i,0,a+1){
		rep(j,0,b+1) dp[i][j]=0;
	}
	int mx=-1;
	rep(i,1,a+1){
		rep(j,1,b+1){
			if(s[i-1]==t[j-1]) dp[i][j]=dp[i-1][j-1]+1;
			else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			mx=max(mx,dp[i][j]);
		}
	}
	int x=a,y=b;
	int start=mx-1;
	while(x>0 && y>0){
		if(dp[x][y]==dp[x-1][y]) --x;
		else if(dp[x][y]==dp[x][y-1]) --y;
		else{
			f[start--]=s[x-1];
			--x;
			--y;
		}
	}
	printf("%s\n",f);
}


Measured memory_bytes: 38776
#include<cstdio>
#include<algorithm>
#include<math.h>
using namespace std;
long long n, m, d;

int main()
{
    scanf("%lld %lld %lld", &n, &m, &d);
    double ret;
    ret = m - 1;
    if (d == 0) {
        ret *= 1.0 / n;
    } else {
        ret *= 2.0 * (n - d) / n / n;
    }

    printf("%.12lf\n", ret);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define fr first
#define sc second
#define ll long long
#define rg register
#define gc getchar()
#define mp make_pair
#define rp(i,x,y) for(rg int i=x;i<=y;++i)
#define my(i,x,y) for(rg int i=x;i>=y;--i)

const int N=300+10;const ll mod=1e9+7;
ll f[N][N][N],as;
int n,m;
vector< pair<int,int> >lim[N];

il int read()
{
    rg char ch=gc;rg int x=0;rg bool y=1;
    while(ch!='-' && (ch>'9' || ch<'0'))ch=gc;
    if(ch=='-')ch=gc,y=0;
    while(ch>='0' && ch<='9')x=(x<<1)+(x<<3)+(ch^'0'),ch=gc;
    return y?x:-x;
}

int main()
{
// 	freopen("rs.in","r",stdin);freopen("rs.out","w",stdout);
	n=read();m=read();
	rp(i,1,m){int l=read(),r=read(),x=read();lim[r].push_back(mp(l,x));}
	f[1][0][0]=1;
	rp(i,1,n)
	{
		int sz=lim[i].size();
		rp(j,0,sz-1)
		{
			int l=lim[i][j].fr,x=lim[i][j].sc;
			rp(k,0,i-1)
			{
				rp(p,0,max(0,k-1))
				{
					
					if(x==1 && l<=k)f[i][k][p]=0;
					if(x==2 && (k<l || l<=p))f[i][k][p]=0;
					if(x==3 &&p<l)f[i][k][p]=0;
				}
			}
		}
		if(i==n)continue;
		rp(j,0,i-1)
		{
			rp(k,0,max(0,j-1))
			{
				if(!f[i][j][k])continue;
				f[i+1][j][k]=(f[i+1][j][k]+f[i][j][k])%mod;
				f[i+1][i][k]=(f[i+1][i][k]+f[i][j][k])%mod;
				f[i+1][i][j]=(f[i+1][i][j]+f[i][j][k])%mod;
			}
		}
	}
	rp(j,0,n-1)rp(k,0,max(0,j-1))as=(as+f[n][j][k])%mod;
	printf("%lld\n",(ll)as*3%mod);
    return 0;
}


Measured memory_bytes: 225536
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18) + 1;
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int n, m;
vector<int> a;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    for (int i = 0; i < 3; i++)
    {
        int temp;
        cin >> temp;
        a.push_back(temp);
    }
  sort(ALL(a));
    cout << a[2]-a[0] << "\n";
}


Measured memory_bytes: 256
import java.util.*;


public class Main {
    public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int list[] = new int[n];
		double sum = 0;
		for (int i = 0; i < n; i++) {
		    list[i] = sc.nextInt();
		    sum += list[i];
		}
		//Arrays.sort(list, Collections.reverseOrder());
		
		int ans = 0;
		
		for (int j = 0; j < n; j++) {
		    if(list[j] >= sum / (4*m) ) {
		        ans++;
		    }
		        
		}
		
		if (ans >= m) {
		    System.out.println("Yes");
		} else {
		    System.out.println("No");
		}
	
		    
		
    }
}


Measured memory_bytes: 35980
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(ll, N, X);
  VEC(ll, a, N);

  ll ans = 0;
  rep(i, 0, N - 1) {
    ll d = a[i] + a[i + 1] - X;
    if (d > 0) {
      ll d1 = min(a[i + 1], d);
      a[i + 1] -= d1;
      a[i] -= d - d1;
      ans += d;
    }
  }

  print(ans);
}


Measured memory_bytes: 1024
#[derive(Default)]
//NOTE
//declare variables to reduce the number of parameters for dp and dfs etc.
struct Solver {}

impl Solver {
    fn solve(&mut self) {
        let stdin = std::io::stdin();
        let mut scn = Scanner {
            stdin: stdin.lock(),
        };
        let n: usize = scn.read();
        let mut result = 0_usize;
        for i in 1..=n {
            result += i * (i + 1) / 2;
        }
        for i in 0..n-1 {
            let mut u: usize = scn.read();
            let mut v: usize = scn.read();
            if  u > v {
                std::mem::swap(&mut u, &mut v);
            }
            result -= u * (n - v + 1);
        }
        println!("{}", result);
    }
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| {
            let mut solver = Solver::default();
            solver.solve()
        })
        .unwrap()
        .join()
        .unwrap();
}
pub mod utils {
    const DYX: [(isize, isize); 8] = [
        (0, 1),   //right
        (1, 0),   //down
        (0, -1),  //left
        (-1, 0),  //top
        (1, 1),   //down right
        (-1, 1),  //top right
        (1, -1),  //down left
        (-1, -1), //top left
    ];

    pub fn try_adj(y: usize, x: usize, dir: usize, h: usize, w: usize) -> Option<(usize, usize)> {
        let ny = y as isize + DYX[dir].0;
        let nx = x as isize + DYX[dir].1;
        if ny >= 0 && nx >= 0 {
            let ny = ny as usize;
            let nx = nx as usize;
            if ny < h && nx < w {
                Some((ny, nx))
            } else {
                None
            }
        } else {
            None
        }
    }
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 2244
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using pii=pair<int,int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define INF 1e9

using vi=vector<int>;
using vvi=vector<vi>;

int main(){
	int n,m,a[3];
	while(cin>>n>>m>>a[0]>>a[1]>>a[2]){
		vvi z(n,vi(n,0));
		auto e=z;
		rep(_,m){
			int p,q; cin>>p>>q;
			e[p-1][q-1]=1;
		}

		vector<vvi> d(3);
		auto f=e;
		rep(l,*max_element(a,a+3)){
			rep(p,3) if(l==a[p]-1) d[p]=f;
			auto next=z;
			rep(k,n)rep(i,n)rep(j,n){
				next[i][j]|=(f[i][k] and e[k][j]);
			}
			f=next;
		}
		
		unordered_set<int> g;
		g.insert(n-1);
		rep(t,1000){
			unordered_set<int> ng;
			rep(i,n) if(!g.count(i)){
				bool ok=1;
				rep(p,3) [&]{bool r=0; rep(j,n) r|=(g.count(j) and d[p][i][j]); ok&=r;}();
				if(ok) ng.insert(i);
			}
			if(ng.size()==0){
				cout<<"IMPOSSIBLE"<<endl;
				break;
			} else if(ng.count(0)){
				cout<<t+1<<endl;
				break;
			}
			g.insert(all(ng));
		}
	}
	return 0;
}



Measured memory_bytes: 3232
H, W, K = map(int, input().split())
C = [input() for i in range(H)]

ans = 0
for i in range(1 << H):
    for j in range(1 << W):
        c = 0
        for h in range(H):
            if i >> h & 1 == 1:
                continue
            for w in range(W):
                if j >> w & 1 == 1:
                    continue
                if C[h][w] == '#':
                    c += 1
        if c == K:
            ans += 1
print(ans)


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

int main() 
{
	int n = 0;
	cin >> n;

	set<string> dic;

	for (int i = 0; i < n; i++) 
	{
		string buf1, buf2;
		cin >> buf1 >> buf2;
		if (buf1 == "insert") 
		{
			dic.insert(buf2);
		}
		else
		{
			if (dic.find(buf2) != dic.end()) 
			{
				cout << "yes" << '\n';
			}
			else 
			{
				cout << "no" << '\n';
			}
		}
	}
	return 0;
}

Measured memory_bytes: 32148
#include<stdio.h>

int main(void){
    int kuku[] = {1,2,3,4,5,6,7,8,9,10,12,14,16,18,15,21,24,27,20,28,32,36,25,30,35,40,45,36,42,48,54,49,56,63,64,72,81};
    int n;
    scanf("%d",&n);
    int kukuSize = sizeof(kuku)/sizeof(kuku[0]);
    int i;
    for(i=0;i<kukuSize;i++){
        if(n == kuku[i]){
            printf("Yes");
            return 0;
        }
    }
    printf("No");
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <math.h>

double stdev(int s[], int n) {

  // calculate mean
  int sum = 0;
  for (int i = 0; i < n; i++)
    sum = sum + s[i];
  double m = (double)sum / n;

  // calculate variance
  double sum2 = 0;
  for (int i = 0; i < n; i++)
    sum2 = sum2 + pow(s[i]-m, 2);
  double v = sum2/n;
  
  return sqrt(v);
}

int main() {
  int n, s[1000];

  do {
    scanf("%d", &n);
    if (n > 0) {
      for (int i = 0; i < n; i++) {
        scanf("%d", &s[i]);
      }
      double sd = stdev(s, n);
      printf("%.6lf\n", sd);
    }
  } while (n > 0);
  
  return 0;
}


Measured memory_bytes: 2040
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

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; }

int main() {
  int k;
  cin >> k;
  queue<ll> q;
  FORe(i, 1, 9) q.push(i);
  int count = 1;
  while (k!=count) {
    ll num = q.front(); q.pop();
    ll iti = num % 10;
    FORe(i, -1, 1) {
      if((iti+i)<0||(iti+i)>9) continue;
      ll add = num*10+iti+i;
      q.push(add);
    }
    count++;
  }
  ll ans = q.front();
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1792
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

ll gcd(ll a, ll b){
  ll tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, M, A, B, C, D, K,W, H, Q, X, Y;
  ll ans;
  string S, T;
  cin >> N >> M >> C;
  ll b[M], a[N][M];
  rep(i, M) cin >> b[i];
  ll ans_now=0;
  ans = 0;
  rep(i, N){
    ans_now=0;
    rep(j, M){
      cin >> a[i][j];
      ans_now += b[j]*a[i][j];
    }
    if (ans_now+C>0) ans++;
  }
  

  cout << ans << endl;
  
  

  
  //cout << ans << endl;
  

}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define REPI(i,a,b) for (ll i=(a);i<(b);i++)
#define REP(i,n) REPI(i,0,n)

typedef long long int ll;

int SURP = 1000000007;


int N,A,B;
int h[100004] = {0};

bool isSat(ll i){
	ll tmp = 0;

	ll add = A - B;
	REP(j,N){
		if ( h[j] - B*i > 0) tmp += (h[j] - B*i + add - 1 )/ add;
		if (tmp > i) {
			return false;
		}
	}
	return true;
}

ll binary_search(){
	ll left = -1;
	ll right = 1000000001;

	while (right - left > 1){
		ll mid = left + (right - left) /2;

		if(isSat(mid)) right = mid;
		else left = mid;
	}
	return right;
}

int main(){
	cin >> N >> A >> B;
	REP(i,N) {
		cin >> h[i];
	}

	cout << binary_search() << endl;

	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define pb push_back
#define F first
#define S second
#define vi vector<int>
#define pi pair<int, int>
#define PI 3.14159265
#define all(x) x.begin(),x.end()
#define er(n) cout << "error " << n << endl;
#define pbds tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>
#define mod 1000000007

void Abhay(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int32_t main(){
   
    int a, b; cin>>a>>b;
    cout<<a*b;
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    vector<int> c(n);
    for(int i = 0; i < n; i++)
    {
        cin >> v[i];
    }
    for(int i = 0; i < n; i++)
    {
        cin >> c[i];
    }
    int ans = 0;
    for(int i = 0; i < n; i++)
    {
        if(v[i] > c[i])
        {
            ans += v[i] - c[i];
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
using namespace std;
#define SIZE 100000
int main() {
    int n, m, dp[SIZE], num1, num2; 
    char ch1, ch2,ans[SIZE];
    while (1) {
        for (int i = 0; i < SIZE; i++) {
            dp[i] = -1;
        }
        cin >> n;
        if (n == 0) {
            break;
        }
        for (int i = 0; i < n; i++) {
            cin >> ch1 >> ch2;
            num1 = ch1;
            num2 = ch2;
            dp[num1] = num2;
        }
        cin >> m;
        for (int i = 0; i < m; i++) {
            cin >> ch1;
            num1 = ch1;
            if (dp[num1] != -1) {
                ans[i] = dp[num1];
                
            }
            else {
                ans[i] = ch1;
                
            }
        }
        for (int i = 0; i < m; i++) {
             cout << ans[i];
        }
         cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3544
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<stack>
#include<queue>
using namespace std;
typedef long long ll;

const int maxn = 1010;

int n,sum;
int a[maxn];

priority_queue<int,vector<int>,greater<int> > q;

ll read(){ ll s=0,f=1; char ch=getchar(); while(ch<'0' || ch>'9'){ if(ch=='-') f=-1; ch=getchar(); } while(ch>='0' && ch<='9'){ s=s*10+ch-'0'; ch=getchar(); } return s*f; }

int main(){
	sum=0;
	n=read();
	
	for(int i=1;i<=n;i++){
		a[i] = read();
		sum += a[i];
		if(a[i]%10!=0)
			q.push(a[i]);
	}
	
	int cnt=0;
	while(sum%10==0 && !q.empty()){
		sum-=q.top();
		q.pop();
	}
	
	if(sum%10==0){
		printf("0\n");
	}else{
		printf("%d\n",sum);	
	}

	return 0;
}

Measured memory_bytes: 3728
#include <bits/stdc++.h> 
using namespace std; 
  
int MinimumNumIncreasingSubsequences(int arr[], int n) 
{ 
    multiset<int> last; 

    for (int i = 0; i < n; i++) { 
  
        multiset<int>::iterator it = last.lower_bound(arr[i]); 
  
        if (it == last.begin()) 
            last.insert(arr[i]); 
  
        else { 
            it--; 
            last.erase(it);
            last.insert(arr[i]);
        } 
    } 
    return last.size();
} 
  
int main() 
{ 
    int ln;
    cin>>ln;
    int arr[ln];
    for(int i=0;i<ln;i++){
        cin>>arr[i];
    }
    int n = sizeof(arr) / sizeof(int);
    cout << MinimumNumIncreasingSubsequences(arr, n); 
    return 0; 
} 

Measured memory_bytes: 5376
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <random>
#include <utility>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <algorithm>
#include <vector>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<int> G[200005];
vector<int> H[200005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
ll i,j;
ll n,k,l;
ll x,y;
ll num=0;

ll g[200005],h[200005];
ll p[200005];

void dfsg(ll k,ll a){
	g[k]=a;
	for(int j=0;j<G[k].size();j++){
		if(g[G[k][j]]==-1)
		dfsg(G[k][j],a);
	}
}

void dfsh(ll kkk,ll b){
	h[kkk]=b;
	for(int j=0;j<H[kkk].size();j++){
		if(h[H[kkk][j]]==-1)
		dfsh(H[kkk][j],b);
	}
}



int main(){
	cin>>n>>k>>l;
	memset(g,-1,sizeof(g));
	memset(h,-1,sizeof(h));
	for(i=0;i<k;i++){
		cin>>x>>y;
		G[x].push_back(y);
		G[y].push_back(x);
	}
	for(i=0;i<l;i++){
		cin>>x>>y;
		H[x].push_back(y);
		H[y].push_back(x);
	}
	num=1;
	for(i=1;i<=n;i++){
		if(g[i]==-1){
			dfsg(i,num);
			num++;
		}
	}
	num=1;
	for(i=1;i<=n;i++){
		if(h[i]==-1){
			dfsh(i,num);
			num++;
		}
	}
	for(i=1;i<=n;i++){
		p[i]=300000*g[i]+h[i];
	}
	sort(p+1,p+n+1);
	for(i=1;i<=n;i++){
		cout<<upper_bound(p+1,p+n+1,300000*g[i]+h[i])-lower_bound(p+1,p+n+1,300000*g[i]+h[i])<<" ";
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 23808
#!/usr/bin/env python3

def II(): return int(input())
def MII(): return map(int, input().split())
def LII(): return list(map(int, input().split()))

def main():
    N, M = MII()
    A = []
    for _ in range(N):
        A.append(list(input()))

    B = []
    for _ in range(M):
        B.append(list(input()))

    f = True
    for i in range(N-M+1):
        for j in range(N-M+1):
            for k in range(M):
                if A[i+k][j:j+M] != B[k]:
                    f = False
                    break
                f = True
            if f:
                print('Yes')
                return
    
    print('No')

if __name__ == '__main__':
    main()


Measured memory_bytes: 9200
#include<stdio.h>
int main(void)
{
  double w,h;
  double a;
  double x,y;
  int b;
  
   scanf("%lf %lf %lf %lf",&w,&h,&x,&y);
  a=w*h/2;
   printf("%lf",a);
  
  if(w/2==x && h/2==y)
    b=1;
  else 
    b=0;
  printf(" %d",b);
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
using namespace std;
using lint = long long;
const int MAXN = 250005;
const int MAXV = 1000005;

map<lint, int> mp;

int main(){
	int n; scanf("%d",&n);
	lint sum = 0;
	mp[sum]++;
	lint ret = 0;
	for(int i=1; i<=n; i++){
		int x; scanf("%d",&x);
		sum += x;
		ret += mp[sum];
		mp[sum]++;
	}
	cout << ret << endl;
}


Measured memory_bytes: 15976