akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

typedef pair<int, int> pii;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int N, r[1010], w[1010];
bool dp[1010][1010];

signed main() {
    while(cin >> N, N) {
        rep(i,0,N) cin >> r[i] >> w[i];
        int readmax = *max_element(r, r+N);
        int idx = max_element(r, r+N) - r;
        int sum = accumulate(r, r+N, 0LL) - readmax;
        int wsum = accumulate(w, w+N, 0LL);

        if(readmax <= sum) {
            cout << readmax + sum + wsum << endl;
        }
        else {
            int ans = 2 * readmax;
            memset(dp, false, sizeof(dp));
            dp[0][0] = true;

            int rest = readmax - sum;
            rep(i,0,N) repq(j,0,rest) {
                dp[i+1][j] |= dp[i][j];
                if(i == idx) continue;
                if(j-w[i] < 0) continue;
                dp[i+1][j] |= dp[i][j-w[i]];
            }

            int ma = -1;
            repq(i,0,rest) if(dp[N][i]) ma = i;
            ans += wsum - ma;
            cout << ans << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 4084
N, K = map(int, input().split())
S = input()

count = [1]
for i in range(N-1):
    if S[i] == S[i+1]:
        count[-1] += 1
    else:
        count.append(1)
# print(count)

if len(count) - (2*K + 1) > 0:
    print(sum(count)-len(count)+2*K)
else:
    print(sum(count)-1)


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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const int MAX = 1e5 + 10;

ll dp[MAX];

int main() {
  int N;
  cin >> N;
  ll h[N];
  for (int i = 0; i < N; i++) scanf("%lld", h + i);

  dp[0] = 0;
  dp[1] = llabs(h[0] - h[1]);
  for (int i = 2; i < N; i++) {
    dp[i] = min(dp[i-1] + llabs(h[i] - h[i-1]), dp[i-2] + llabs(h[i] - h[i-2]));
  }

  cout << dp[N-1] << endl;
  return 0;
}


Measured memory_bytes: 1792
x1, y1, x2, y2 = [int(n) for n in input().split()]

w = abs(x1-x2)
h = abs(y1-y2)

if x1 <= x2 and y1 > y2:
  print(x2 + h, y2 + w, x1 + h, y1 + w)
elif x1 <= x2 and y1 <= y2:
  print(x2- h, y2 + w, x1 - h, y1 + w)
elif x1 > x2 and y1 > y2:
  print(x2 + h, y2 - w, x1 + h, y1 - w)
else:
  print(x2 - h, y2 - w, x1 - h, y1- w)


Measured memory_bytes: 3060
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール
template <class RandomAccessIterator>
vector<ll> common_prefix(RandomAccessIterator first, RandomAccessIterator last) {
    const size_t sz = last - first;
    vector<ll> prefix(sz, 0);
    for (ll i = 1, j = 0; i < sz; i++) {
        if (i + prefix[i-j] < j + prefix[j]) {
            prefix[i] = prefix[i-j];
        } else {
            ll k = max(0LL, j + prefix[j] - i);
            while (i + k < sz && *(first + k) == *(first + (i+k))) k++;
            prefix[i] = k;
            j = i;
        }
    }
    prefix[0] = sz;
    return prefix;
}

// 処理内容
int main() {

    ll n; cin >> n;
    string s; cin >> s;
    
    ll ans = 0;
    REP(k, n) {
        vector<ll> prefix = common_prefix(s.begin() + k, s.end());
        REP(i, prefix.size()) {
            if (prefix[i] >= i) {
                prefix[i] -= prefix[i] - i;
            }
        }
        chmax(ans, *max_element(ALL_OF(prefix)));
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            while (true)
            {
                int n = int.Parse(Console.ReadLine());

                if (n == 0) break;

                int x = 5, count = 0;

                while (x <= n)
                {
                    count += n / x;
                    x *= 5;
                }
                sb.AppendLine(count.ToString());
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 9232
#include <algorithm>
#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
    long long n,k,ans=0;
    cin >> n>> k;
    if(k==0) ans=n*n;
    else
    {
        for(int b=k+1;b<=n;b++)
        {
        ans+=(n/b)*(b-k);
        if(n%b>=k) ans+=n%b-k+1;
        }
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 256
import numpy as np

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

b = np.array(b)

count = 0
for _ in range(n):
    a = list(map(int, input().split()))
    a = np.array(a)

    if np.dot(a, b) + c > 0:
        count += 1
else:
    print(count)

Measured memory_bytes: 12420
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main()
{
    // freopen("b.07.in","r",stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin >> s;
    vi a(256);
    rep(i, 0, s.length())
    {
        if (a[s[i]] == 1)
        {
            cout << "no" << endl;
            return 0;
        }
        else
        {
            a[s[i]] = 1;
        }
    }
    cout << "yes" << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000000)
N, Q = map(int, input().split())

ARR = []

for i in range(N-1):
    ARR.append(list(map(int, input().split())))

BRR = []

for i in range(Q):
    BRR.append(list(map(int, input().split())))


def prepare(n, q, arr, brr):
    nodePoints = [0 for i in range(n)]
    for i in range(q):
        nodeIndex = brr[i][0] - 1
        nodePoints[nodeIndex] += brr[i][1]

    nodes = [[] for i in range(n)]

    for i in range(n - 1):
        startNode = arr[i][0] - 1
        endNode = arr[i][1] - 1

        nodes[startNode].append(endNode)
        nodes[endNode].append(startNode)

    return nodes, nodePoints


nodes, nodePoints = prepare(N, Q, ARR, BRR)


def dfs(currentNode, nodes, parentNode=-1, parentPoint=0):
    nodePoints[currentNode] = nodePoints[currentNode] + parentPoint
    childNodes = nodes[currentNode]
    for childNode in childNodes:
        if childNode == parentNode:
            continue
        dfs(childNode, nodes, currentNode, nodePoints[currentNode])


dfs(0, nodes)

print(" ".join([str(nodePoints[i]) for i in range(N)]))


Measured memory_bytes: 352804
#include<stdio.h>
#include<string.h>
char x[101];
int main(){
	scanf("%s",x);
	int len=strlen(x)-1;
	int count=0;
	for(int i=0;i<=len;i++){
		if(x[i]!=x[len-i])count=1;
	}
	int len1=len/2-1;
	for(int i=0;i<=len1;i++){
		if(x[i]!=x[len1-i])count=1;
	}
	for(int i=len1+2;i<=len;i++){
		if(x[i]!=x[len-(i-len1-2)])count=1;
	}
	if(count==1)printf("No");
	else printf("Yes");
}

Measured memory_bytes: 128
package main

import (
	"fmt"
)

func gcd(a, b uint64) uint64 {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func main() {
	var k uint64
	fmt.Scan(&k)
	var totalsum uint64 = 0
	var i, ii, iii uint64
	for i = 1; i < k+1; i++ {
		for ii = 1; ii < k+1; ii++ {
			for iii = 1; iii < k+1; iii++ {
				totalsum += gcd(gcd(i, ii), iii)
			}
		}
	}
	fmt.Println(totalsum)
}


Measured memory_bytes: 1776
n = int(input())
dict = {'a':0}
for i in range(n):
    str = input()
    dict[str] = dict.get(str,0) + 1
m = int(input())
for i in range(m):
    str = input()
    dict[str] = dict.get(str,0) - 1
print(max(dict.values()))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

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

  typedef pair<ll, ll> P;
  vector<P> AB(N);

  rep(i, N) cin >> AB[i].fi >> AB[i].se;

  sort(all(AB));

  ll cost = 0;
  ll res = M;
  rep(i, N) {
    ll buy = min(res, AB[i].se);
    cost += buy * AB[i].fi;
    res -= buy;
    if (res == 0) break;
  }
  cout << cost << endl;
}

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

int main() {
  int n; cin >> n;
  if (n%10 == 3) cout << "bon";
  else if (n%10 == 0 || n%10 == 1 || n%10 == 6 || n%10 == 8) cout << "pon";
  else cout << "hon";
  cout << endl;
  return 0;
}

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

int main() {
	int N;
	cin >> N;
	int k = 0;
	for(int i = 1;i < 10;i++)
	{
		N /= 2;
		if(N == 0)
		{
			k = pow(2,i-1);
			break;
		}
	}
    cout << k << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N, count=0;
	cin >> N;
	vector<int> L(N);
	for (int i = 0; i < N; i++) {
		cin >> L.at(i);
	}
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			for (int k = j + 1; k < N; k++) {
				if (L.at(i) != L.at(j) && L.at(j) != L.at(k)&&L.at(k)!=L.at(i)) {
					vector<int> L2(3);
					L2.at(0) = L.at(i);
					L2.at(1) = L.at(j);
					L2.at(2) = L.at(k);
					sort(L2.begin(), L2.end());
					if (L2.at(2) < (L2.at(0) + L2.at(1))) {
						count++;
					}
				}
			}
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 3628
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
import itertools
import math

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


def resolve():
    n = int(input().rstrip())
    max_n = n
    max_n = math.sqrt(max_n)
    max_n = math.ceil(max_n)

    ans = [0] * 10050

    for i in range(1, max_n+1):
        for j in range(1, max_n+1):
            for k in range(1, max_n+1):
                v = i*i + j*j + k*k + i*j + j*k + k*i
                if v < 10050:
                    ans[v] += 1

    for i in range(n):
        print(ans[i+1])

    """
    p = itertools.combinations_with_replacement(range(1, max_n), 3)

    #print(len(list(p)))
    ans_list = []


    for v in p:

        x, y, z = v
        ans_cnt = 0
        ans_list.append(x * x + y * y + z * z + x * y + y * z + z * x)



        if ans == m:
            if x == y == z:
                ans_cnt += 1
            elif x == y or y == z or x == z:
                ans_cnt += 3
            else:
                ans_cnt += 6
    """


    """
    for m in range(1, n+1):

        max_n = math.sqrt(m)
        max_n = math.ceil(max_n)
        p = itertools.combinations_with_replacement(range(1,max_n), 3)

        ans_cnt = 0
        for v in p:
            #print(v)
            x, y, z = v
            ans = x*x + y*y + z*z + x*y + y*z + z*x

            if ans == m:
                if x == y == z:
                    ans_cnt += 1
                elif x == y or y == z or x == z:
                    ans_cnt += 3
                else:
                    ans_cnt += 6

        print(ans_cnt)
    """


if __name__ == "__main__":
    resolve()



Measured memory_bytes: 69244
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;
#define fst first
#define snd second

const int N = 2005;
const int mod = 1e9 + 7;
int choose[N][N];

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
//  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  for (int n = 0; n < N; n++) {
    choose[n][0] = choose[n][n] = 1;
    for (int r = 1; r < n; r++) {
      choose[n][r] = (choose[n - 1][r] + choose[n - 1][r - 1]) % mod;
    }
  }

  int n; cin >> n;
  ll ways = 0;
  for (int l = 1; 3 * l <= n; l++) {
    int s = n - 3 * l;
    ways += choose[s + l - 1][l - 1];
  }
  ways %= mod;
  cout << ways << endl;

  return 0;
}


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

#define MOD 1000000007ll
#define all(v) v.begin() , v.end()
#define allr(v) v.rbegin(), v.rend()
#define for0(i,n) for(__typeof(n) i = 0; i < n ; i++) 
#define forab(i,a,b) for(__typeof(a) i = a ; i < b ; i++) 
#define forba(i,b,a) for(__typeof(a) i = b ; i > a ; i--) 
#define forc(c,it) for(__typeof(c.begin()) it = c.begin(); it != c.end(); it++)
#define pb     push_back
#define mp     make_pair
#define MAX 100005

int n , d;
ll ans;
vector<int> a;

int main(int argc, char const *argv[])
{
  ios_base::sync_with_stdio(false);
  ans = 0;

  scanf("%d" , &n);

  for0(i , 3*n)
  {
  	scanf("%d" , &d);
  	a.pb(d);
  }

  sort(all(a));
  int turns = n;

  for(int i = 3*n - 2 ; i >= 0 && turns > 0 ; i = i - 2)
  {
  	// printf("%d\n" , i);
  	turns--;
  	ans += a[i];
  }

  printf("%lld" , ans);


  return 0;
} 

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

using namespace std;

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

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

    int m;
    cin >> m;
    for(int i=0; i<m; i++){
        int p, x;
        cin >> p >> x;

        cout << sum - t[p-1] + x << "\n";
    }

    
    return 0; 
} 

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

using ll = long long int;
typedef long double ld;
typedef pair<ll,ll> pll;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<ll ,null_type,less<ll >,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//K-th smallest element(0-based)=> cout << k << "kth smallest: " << *A.find_by_order(k-1) << endl;
//NO OF ELEMENTS < X => cout << "No of elements less than " << X << " are " << A.order_of_key(X) << endl;

#define sz(v) (ll)v.size()
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<fixed<<setprecision(10);
	ld l;
	cin>>l;
	cout<<(l/3)*(l/3)*(l/3)<<"\n";
	return 0;
}

Measured memory_bytes: 256
N = int(input())

# A = list(map(int, input().split()))
# print(N, A)
A = []
l = input().split()
total = 0
sub = 0
for i in range(len(l)):
    v = int(l[i])
    A.append(v)
    total += v
    if i % 2 == 1:
        sub += v

M = [0]*N
# total = sum(A)
# sub = 0
# for i in range((N-1)//2):
#     sub += A[2*i + 1]
# print(total, sub)
M[0] = total - 2 * sub
for i in range(1, N):
    m = 2 * A[i - 1] - M[i - 1]
    M[i] = m
# print(M)
ans = " ".join(map(str, M))
print(ans)


Measured memory_bytes: 84580
#!/usr/bin python3
# -*- coding: utf-8 -*-

from bisect import bisect_left, bisect_right

def main():
    N = int(input())
    L = list(map(int, input().split()))
    L.sort()
    ret = 0
    for a in range(N-2):
        for b in range(a+1,N-1):
#            a<b+c => a-b<c
#            b<c+a => b-a<c
#            c<a+b
# b-a<c<a+b
            rr = bisect_right(L[b+1:], L[a]+L[b]-1)
            ll = 0
            ret += rr - ll

    print(ret)

if __name__ == '__main__':
    main()


Measured memory_bytes: 74784
N,M,C=map(int,input().split())
A=[]
c=0
B=list(map(int,input().split()))
for i in range(1,N+1):
    A.append(list(map(int,input().split())))
    if sum(A[i-1][k-1]*B[k-1] for k in range(1,M+1))+C>0:
        c=c+1
print(c)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int pad(int x){
    return x + (10 - (x % 10)) % 10;
}

int main(){
    int A, B, C, D, E;
    cin >> A >> B >> C >> D >> E;

    vector<int> sum(5);
    sum[0] = A + pad(B) + pad(C) + pad(D) + pad(E);
    sum[1] = pad(A) + B + pad(C) + pad(D) + pad(E);
    sum[2] = pad(A) + pad(B) + C + pad(D) + pad(E);
    sum[3] = pad(A) + pad(B) + pad(C) + D + pad(E);
    sum[4] = pad(A) + pad(B) + pad(C) + pad(D) + E;

    sort(sum.begin(), sum.end());

    cout << sum[0] << endl;

    return 0;
}

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

/*
*/

using vi = vector<int>;
using vvi = vector<vi>;
using P = pair<int,int>;

signed main() {

  int n;
  cin >> n;

  vvi a(n, vi(n));
  rep(i, 0, n) rep(j, 0, n) cin >> a[i][j];

  vvi b(n, vi(n));
  rep(k, 0, n) rep(i, 0, n) rep(j, 0, n){
    if(a[i][k] + a[k][j] < a[i][j]){
      cout << -1 << endl;
      return 0;
    }

    if(a[i][k] and a[k][j] and a[i][k] + a[k][j] == a[i][j]){
      b[i][j] = 1;
    }
  }

  int ans = 0;
  rep(i, 0, n) rep(j, i+1, n){
    if(!b[i][j]) ans += a[i][j];
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1664
// finish date: 2019/06/09

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 998244353;
const int INF = 1050000000;
const long long INFll = 100000000000000000;


int main() {
    int N;
    cin >> N;
    vi W(N);
    vi cum(N, 0);
    rep(i, N) {
        cin >> W[i];
        cum[i] = W[i];
        if (i > 0) cum[i] += cum[i - 1];
    }
    int ans = cum[N - 1];
    rep(i, N) {
        ans = min(ans, abs(cum[i] -( cum[N - 1] - cum[i])));
    }
    cout << ans << endl;


    return 0;
}


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

int main()
{
    int N, M; cin >> N >> M;
    vector<int> x(M),sub(M+1);
    for(int i=0;i<M;i++) cin >> x[i];
    sort(x.begin(),x.end());
    int ans = 0;
    if(N < M){
        for(int i=0;i<M-1;i++){
            sub[i] = x[i+1]-x[i];
            ans += sub[i];
        }
        sort(sub.begin(),sub.end(),greater<int>());
        for(int i=0;i<N-1;i++) ans -= sub[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
from collections import Counter
S = Counter(list(input()))
T = Counter(list(input()))
if len(S) != len(T):
    print("No")
else:
    Sv = []
    Tv = []
    for v in S.values():
        Sv.append(v)
    for v in T.values():
        Tv.append(v)
    Svc = Counter(Sv)
    Tvc = Counter(Tv)
    if Svc == Tvc:
        print("Yes")
    else:
        print("No")

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

int main() {
	string s,t;
	cin>>s>>t;
	int maxcount=1e9;
	for(int i=0 ; i <= s.length()-t.length() ; i++){
	    int count=0;
	    for(int j=0;j<t.length();j++){
	       if(s[i+j]!=t[j])
	       count++;
	    }
	    if(count<maxcount){
	        maxcount=count;
	    }
	}
	cout<<maxcount;
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
const int md = 1e9+7;
const int mx = 100005;
int n, m, a;
long long ans[mx] = {1};
bool x[mx];
int main(){
    scanf("%d%d", &n, &m);
    rep(i,m){
        scanf("%d", &a);
        x[a] = true;
    }
    rep(i,n){
        if(x[i]) ans[i] = 0;
        (ans[i+1] += ans[i]) %= md;
        (ans[i+2] += ans[i]) %= md;
    }
    printf("%lld\n", ans[n]);
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/






int N;
vector<pair<int, int>> E[101010];
int Q, K;
//---------------------------------------------------------------------------------------------------
ll dp[101010];
void dfs(int cu, int pa = -1, ll d = 0) {
	dp[cu] = d;
	fore(p, E[cu]) if (pa != p.first) dfs(p.first, cu, d + p.second);
}
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 0, N - 1) {
		int a, b, c; cin >> a >> b >> c;
		E[a].push_back({ b,c });
		E[b].push_back({ a,c });
	}
	cin >> Q >> K;

	dfs(K);

	rep(q, 0, Q) {
		int x, y; cin >> x >> y;
		ll ans = dp[x] + dp[y];
		printf("%lld\n", ans);
		
	}
}

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

#define debug(x) cout << x << "\n";
#define debug2(x,y) cout << x << " " << y << "\n"
#define fi first
#define se second
#define pb push_back
#define ll long long 
const ll mod = 1e9+7;
const int MAX = 2e5+5;

int main() {
    string str;
    cin >> str;
    map<char,int> mp;
    for(char c : str)
        mp[c]++;
    if(mp.size() == 2){
        for(auto i : mp){
            // debug2(i.fi,i.se);
            if(i.second != 2){
                cout << "No" << "\n";
                return 0;
            }
        }
        cout << "Yes" << "\n";
    }else{
        cout << "No" << "\n";
    }
}






Measured memory_bytes: 3604
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
#include<stack>
using namespace std;
#define int long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
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; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));

bool isPrime(int x) {
    int i;
    if (x < 2)return 0;
    else if (x == 2) return 1;
    if (x % 2 == 0) return 0;
    for (i = 3; i * i <= x; i += 2) if (x % i == 0) return 0;
    return 1;
}

signed main() {
	int N;
	cin >> N;
    if (N == 1) {
        cout << 0;
        return 0;
    }
    if (isPrime(N)) {
        cout << 1;
        return 0;
    }

    int ans = 0;
    for (int i = 2; i <= N; i++) {
        if (N % i == 0) {
            int cnt = 0;
            while (N % i == 0) {
                cnt++;
                N /= i;
            }
            int a = sqrt(1 + 8 * cnt);
            int b = (-1 + a) / 2;
            ans += b;
        }
        else {
            if (i * i > N) {
                ans++;
                break;
            }
        }
    }
    cout << ans;
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using i128 = boost::multiprecision::int128_t;
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int fLog2(const int x) { return 31-__builtin_clz(x); } // floor(log2(x))
inline int fLog2(const ll x) { return 63-__builtin_clzll(x); }
inline int cLog2(const int x) { return (x == 1) ? 0 : 32-__builtin_clz(x-1); } // ceil(log2(x))
inline int cLog2(const ll x) { return (x == 1) ? 0 : 64-__builtin_clzll(x-1); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const ld PI    = acos(-1.0);
const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;

void ng() {
  cout << "No\n";
  exit(0);
}


int main() {
  ll n; cin >> n;
  V x(n); cin >> x;
  rep(i, n) --x[i];

  vector<P> xi(n);
  rep(i, n) xi[i] = {x[i], i};
  sort(all(xi));

  int N = n*n;
  V ans(N);
  rep(i, n) ans[x[i]] = i+1;

  int z = 0;
  while (ans[z]) ++z;
  for (auto [y, i] : xi) {
    rep(j, i) {
      if (z > y) ng();
      ans[z] = i+1;
      ++z;
      while (ans[z]) ++z;
    }
  }

  reverse(all(xi));
  z = N-1;
  while (ans[z]) --z;
  for (auto [y, i] : xi) {
    rep(j, n-1-i) {
      if (z < y) ng();
      ans[z] = i+1;
      --z;
      while (ans[z]) --z;
    }
  }

  cout << "Yes\n";
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 4616
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef vector<lint> vlint;

#define inf 1e+9
#define endl "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define rep_rev(i, n) for (int i = n-1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()

#define pb push_back
#define eb emplace_back
#define Size(c) (int)(c).size()

#define lb(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define ub(c, x) distance((c).begin(), upper_bound(all(c), (x)))

template <class T> using pq = priority_queue<T>;
template <class T> using pqg = priority_queue<T, vector<T>, greater<T>>;

template <class T, class S> inline bool chmax(T &a, S b) {
    if(a < b) {a = b;return 1;} return 0;
}
template <class T, class S> inline bool chmin(T &a, S b) {
    if(a > b) {a = b;return 1;} return 0;
}
template <class T>
void line(vector<T> &x){for (auto&& xi : x) cin >> xi;}

inline void IN(void){ return;}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){ cin >> first; IN(rest...); return;}

#define INT(...) int __VA_ARGS__; IN (__VA_ARGS__)
#define LINT(...) lint __VA_ARGS__; IN (__VA_ARGS__)
#define STR(...) string __VA_ARGS__; IN(__VA_ARGS__)

template <class T> void UNIQUE(vector<T> &x) {
    sort(all(x)); x.erase(unique(all(x)), x.end());
}
template <class T> void print_vec(T first, T end){
    for (auto i = first; i < end - 1; i++) cout << *i << " ";
    cout << *(end-1) << endl;
}

template<class... T>
void debug_print(T... args){
    vector<lint> tmp = initializer_list<lint>{args...};
    print_vec(all(tmp));
}
template<class T>
void print(T a){ cout << a << endl;}

vector<string> Yes = {"No", "Yes"};
vector<string> YES = {"NO", "YES"};

int ord(char x){ return (int)(x - 'a');}
char chr(lint x){ return (char)(x + (lint)('a'));}
lint mod = 1e9+7;
// lint mod = 

lint sum(vlint a){lint ret = 0; for(auto&& v:a) ret += v; return ret;}
lint vmini(vlint a, lint &index){
    lint ret = LLONG_MAX;
    rep(i, Size(a)){ if (chmin(ret, a[i])) index = i;}
    return ret;
}
lint vmaxi(vlint a, lint &index){
    lint ret = -LLONG_MAX;
    rep(i, Size(a)){ if (chmax(ret, a[i])) index = i;}
    return ret;
}

lint vmin(vlint a){
    lint ret = LLONG_MAX; for (auto && v : a) chmin(ret, v); return ret;
}
lint vmax(vlint a){
    lint ret = -LLONG_MAX; for (auto && v : a) chmax(ret, v); return ret;
}

int main(){
    INT(n); vlint a(n); line(a);
    lint cash = 1000; lint tmp;
    rep1(i, n){
        if (a[i] > a[i-1]){
            tmp = cash / a[i-1];
            cash -= tmp * a[i-1];
            cash += tmp * a[i];
        }
    }
  	print(cash);
}


Measured memory_bytes: 3624
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        try (BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

            StringBuilder out = new StringBuilder();
            while (true) {
                String[] line = in.readLine().split(" ");
                int n = Integer.parseInt(line[0]);
                int x = Integer.parseInt(line[1]);

                if (n == 0 && x == 0) break;

                int cnt = 0;
                for (int i = n; i >= 3; i--) {
                    for (int j = i - 1; j >= 2; j--) {
                        int rest = x - i - j;
                        if (rest <= 0) continue;
                        else if (j <= rest) break;
                        else cnt++;
                    }
                }

                out.append(cnt);
                out.append("\n");
            }
            System.out.print(out);
        } catch (IOException e) {
            e.printStackTrace();
        }
        System.exit(0);
    }
}



Measured memory_bytes: 24440
#include <iostream>
#include <vector>

using namespace std;

using ll = long long;

const int LGA = 40;

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

    int n;
    ll a, b, x = 0;
    cin >> n;
    cin >> a >> b;
    for (int i = 2; i < n; i++) {
        ll t;
        cin >> t;
        x ^= t;
    }

    if (a + b < x || (a + b - x) % 2 == 1) {
        cout << -1 << endl;
        return 0;
    }

    ll d = (a + b - x) / 2;
    if (d > a) {
        cout << -1 << endl;
        return 0;
    }

    ll ans = d;
    for (int i = LGA - 1; i >= 0; i--) {
        int xi = x >> i & 1, di = d >> i & 1;

        if (xi && di) {
            ans = 0;
            break;
        } else if (xi) {
            if ((ans ^ 1ll << i) <= a) {
                ans ^= 1ll << i;
            }
        }
    }

    cout << (ans == 0 ? -1 : a - ans) << endl;

    return 0;
}


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

#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
#define CININIT cin.tie(0),ios::sync_with_stdio(false)
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

constexpr ll mod = 1e9+7;

struct UnionFind{
    vector<int> p;

    UnionFind(int n) : p(n) {
        for(int i=0;i<n;i++) p[i]=-1;
    }
    int root(int a){
        if(p[a]<0) return a;
        else return p[a]=root(p[a]);
    }
    void merge(int a,int b){
        a=root(a);
        b=root(b);
        if(a==b) return;
        if(p[a]>p[b]) swap(a,b);
        p[a] += p[b];
        p[b] = a;
        return;
    }
    bool same(int a,int b){
        return root(a)==root(b);
    }
};

int main(){
    int ans=0;
    int N;cin>>N;
    vector<string> a(N);
    vi x(N);
    map<string,int> dic;
    rep(i,N){
        cin>>a[i]>>x[i];
        dic[a[i]]=i;
    }
    int M;cin>>M;
    vector<string> s(M),t(M);
    rep(i,M) cin>>s[i]>>t[i];

    UnionFind uf(N);
    rep(i,M) uf.merge(dic[s[i]],dic[t[i]]);

    vi pr(N);
    rep(i,N) pr[i]=x[i];
    rep(i,N) pr[uf.root(i)]=min(pr[uf.root(i)],x[i]);
    rep(i,N) ans += pr[uf.root(i)];
    cout << ans << endl;
}

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

using namespace std;

bool solve(int X) {
  int m = X / 100;
  int r = X % 100;

  int c = 5;
  while (r > 0 && m > 0 && c > 0) {
    int d = r / 5;
    r = r % c;
    m -= d;
    --c;
  }

  return (r == 0 && m >= 0);
}

int main() {
  int X;
  cin >> X;
  if (solve(X)) {
    cout << '1' << endl;
  } else {
    cout << '0' << endl;
  }

  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();
		int M = sc.nextInt();
		int[] cost = new int[N];
		int[] point = new int[N];
		for(int i = 0; i < N; i++) cost[i] = sc.nextInt();
		for(int i = 0; i < M; i++) {
			int border = sc.nextInt();
			for(int j = 0; j < N; j++) {
				if(cost[j] <= border) { point[j]++; break;}
			}
		}
		int best = 0;
		int bestidx = 0;
		for(int i = 0; i < N; i++) {
			if(i == 0 || best < point[i]) { best = point[i];bestidx = i;}
		}
		System.out.println(bestidx+1);
	}
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n;
    cin>>n;
    string s;
    cin>>s;

    int ans=1;
    char curcol = s[0];
    FOR(i,1,n){
        if(curcol != s[i]){
            ans++;
            curcol = s[i];
        }
    }

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

Measured memory_bytes: 512
# coding:utf-8


def inpl(): return list(map(int, input().split()))


N = int(input())
A = inpl()

ans = 1
prev = A[0]
state = 0  # 1: 増加, 0: 横ばい, -1: 減少
for i in range(1, N):
    if state == 0:
        if A[i] > prev:
            state = 1
        elif A[i] < prev:
            state = -1

    elif state == 1:
        if A[i] < prev:
            ans += 1
            state = 0

    else:
        if A[i] > prev:
            ans += 1
            state = 0

    prev = A[i]

print(ans)


Measured memory_bytes: 14252
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
ll INF = 500000000000000;
int main(){
  int N;
  cin >> N;
  ll a[N];

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

  ll sum = 0;
  for(int i=0;i<N;i++){
  	sum += a[i];
  }

  ll ans = INF;
  ll sunuke = 0;
  for(int i=0;i<N-1;i++){
  	sunuke += a[i];
  	ll error = abs(sum - 2*sunuke);
  	ans = min(ans, error);
  }

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

Measured memory_bytes: 1792
#include<stdio.h>

int hantei(int x){
  int i;
  if(x < 2)
    return 0;

  else if(x == 2)
    return 1;
  
  if(x % 2 == 0)
    return 0;

  for(i = 3;i*i <= x;i += 2){
    if(x % i==0)
      return 0;
  }
  return 1;
}

int main()
{
  int answer = 0;
  int n, x, i; 

  scanf("%d", &n);

  for(i = 0;i < n;i++){
    scanf("%d", &x);
    if( hantei(x) )answer++;
  }
  printf("%d\n",answer);
  return 0;
}

Measured memory_bytes: 1844
#include <iostream>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <algorithm>

using namespace std;

using ll = long long;

unordered_map<ll, ll> fracDP;

void initFracDP(ll n, ll p)
{
	fracDP[0] = 1;
	for (ll i = 1; i <= n; i++)
	{
		fracDP[i] = fracDP[i - 1] * i % p;
	}
}
// initFracDP(n, p);

ll fractorial(ll n)
{
	return fracDP[n];
}

ll pow(ll a, ll b, ll p)
{
	ll ans = 0;
	if (b == 0)
	{
		ans = 1 % p;
	}
	else if (b == 1)
	{
		ans = a % p;
	}
	else
	{
		if (b % 2 == 0)
		{
			ll tmp = pow(a, b / 2, p) % p;
			ans = (tmp * tmp) % p;
		}
		else
		{
			ans = a * pow(a, b - 1, p) % p;
		}
	}
	return ans;
}

ll inverse(ll n, ll p)
{
	return pow(n, (p - 2), p);
}

ll combination(ll n, ll r, ll p)
{
	return (fractorial(n) * inverse(fractorial(r), p) % p) * inverse(fractorial(n - r), p) % p;
}

ll mod = 1000000007;
int main()
{
	int h, w, a, b;
	cin >> h >> w >> a >> b;
	ll ans = 0;

	initFracDP(h + w, mod);

	for (int i = b + 1; i <= w; i++)
	{
		ll before = combination(((h - a - 1) + (i - 1)), (h - a - 1), mod);
		ll after = combination(((a - 1) + (w - i)), (a - 1), mod);
		// cout << "before: " << before << endl;
		// cout << "after: " << after << endl;
		ans += (before * after) % mod;
		ans = ans % mod;
	}

	cout << ans << endl;
}

Measured memory_bytes: 10440
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<deque>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<iomanip>
#include<sstream>
using namespace std;
#define pi acos(-1.0) 
#define ms(x,n) memset(x,n,sizeof(x));
#define pb push_back
typedef long long ll;//string::npos
typedef long long iint;
ll gcd(ll a,ll b){ return a%b==0?b:gcd(b,a%b); }
const int inf=0x3f3f3f3f;
const int maxn=2e5+5;
const int mod=998244353;
//priority_queue<ll,vector<ll>,greater<ll> > q;//小根堆 
//vector<int> vt;
//pair<int,int> p;
//map<int,int> m; 
int main() {
	ios::sync_with_stdio(false);
	
	long long n,sum=0;
	long long ij,ijk;
	cin>>n;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			ij=gcd(i,j);
			for(int k=1;k<=n;k++){
				ijk=gcd(ij,k);
				sum+=ijk;
			}
		}
	}
	cout<<sum<<endl;
	
}

Measured memory_bytes: 3612
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	//cout << std::numeric_limits<double>::max_digits10;
	int n,m,d;
	cin>>n>>m>>d;
	LL t=1LL*(n-d)*(m-1);
	if(d!=0)t*=2;
	//cerr<<t<<endl;
	LD ans=1.*t/n/n;

	cout << fixed;
  cout << setprecision(10)<<ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <tuple>
#include <complex>
#include <cassert>
#include <exception>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << "\n"
static const int INF = 1e+9+7;
static const ll INFL = 1e+18+7;
int n,m,l;
int p;
string s,t;
ll d[200010],dp[300][300];
char field[200][200];

int main(){
  vc vec;
  cin >> s;
  rep(i,0,s.sz)vec.pb(s[i]);
  rep(i,0,vec.sz-1){
    if(vec[i] == 'S' && vec[i+1] == 'T'){
      vec.erase(vec.begin() + i);
      vec.erase(vec.begin() + i);
      i -= 2;
    }
  }
  rep(i,1,vec.sz){
    if(vec[i-1] == 'S' && vec[i] == 'T'){
      vec.erase(vec.begin() + (i-1));
      vec.erase(vec.begin() + (i-1));
      i = 0;
    }
  }
  // rep(i,0,vec.sz)cout << vec[i];
  // puts("");
  print(vec.sz);
  return 0;
}

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

int main(){
    string t,s;
    cin>>s>>t;
    cout<<t+s<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    static long mod = 1000000007;

    public static double calc(double x) {
        if (x <= 1.0) {
            return 1.0;
        } else {
            return Math.pow(0.5, Math.ceil(Math.log(x) / Math.log(2)));
        }
    }

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

        for (int i = 1; i <= n; ++i) {
            // System.out.println(String.format("%d: %f", i, Math.log(k / (double)i) / Math.log(2)));
            res += (calc(k / (double)i) / n);
        }
        System.out.println(res);
    }
}


Measured memory_bytes: 21204
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
#define rep2(x,from,to) for(int x = (from); x < (to); ++(x))
#define rep(x,to) rep2(x,0,to)
int main() {
	double q;
	while(cin >> q && q != -1) {
		double x = q/2;
		while(abs(x*x*x-q) >= 0.00001*q) {
			x = x - (x*x*x-q)/(3*x*x);
		}
		printf("%.6lf\n", x);
	}
	return 0;
}

Measured memory_bytes: 1236
/*input
*/
#define debug 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; typedef double db;
const int N = 1e7 + 5, M = 1e9 + 7; const db eps = 1e-8;
typedef vector<ll> vi; typedef vector<vi> vii;
void solve();
void print(){cout<<'\n';}template<class T,class ...U>void print(T x, U ...y){cout<<x<<' ';print(y...);}
int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  cout << setprecision(2) << fixed;
  if(debug){freopen("main.cpp","r",stdin);string x;cin>>x;}
  solve();
}
//

void solve() {
  int n, x, mi = 1e9; cin >> n;
  int ans = 0;
  while (n--) {
    cin >> x;
    if (x < mi) ans++;
    mi = min(x, mi);
  }
  cout << ans;
}


Measured memory_bytes: 256