akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define SZ(a) (int)((a).size())
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef double db;
typedef pair <int, int> Pii;
typedef pair <ll, int> Pli;
typedef unsigned long long ull;
const double eps = 1e-8;
const int mod = (int)(1e9) + 7;
const int inf = 0x7fffffff;
const int N = 5000 + 7;

ll c[N], k;
int n, p[N], vis[N];
vector <ll> v;

int main() {

    // freopen("in.in", "r", stdin);
    scanf("%d%lld", &n, &k);
    for (int i = 1; i <= n; ++i) scanf("%d", &p[i]);
    for (int i = 1; i <= n; ++i) scanf("%lld", &c[i]);
    ll res = -inf;
    for (int i = 1; i <= n; ++i) {
        if (vis[i]) continue;
        v.clear();
        int x = i;
        ll sum = 0;
        while (!vis[x]) {
            v.pb(c[x]);
            sum += c[x];
            vis[x] = 1;
            x = p[x];
        }
        sum = max(0LL, sum);// 是负数不如不选(赋值为0)
        ll si = SZ(v);
        for (int j = 0; j < si; ++j) {// 从 j 开始循环选
            ll cur = 0;
            for (int stp = 1; stp <= min(k, si * 2); ++stp) {
                cur += v[(j + stp) % si];
                res = max(res, (k - stp) / si * sum + cur);// 剩下的整圈整圈的选, 取最值
                // printf("(%lld, %lld)", res, cur);
            }
        }
    }
    printf("%lld\n", res);

    return 0;
}

Measured memory_bytes: 3968
#include <iostream>
#include <algorithm>

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

int main(void){
  int N;
  cin >> N;
  int a[N];
  rep(i, N)
    cin >> a[i];
  //入力終了

  sort(a, a+N, greater<int>());

  int Alice_p = 0, Bob_p = 0;

  //大きい点から順に足していく
  rep(i, N){
    Alice_p += a[i++];
    //Nが奇数だとBobの番が最後は来ない
    if(i<N)
      Bob_p += a[i];
  }

  //解答
  cout << Alice_p - Bob_p << endl;
  

  return 0;
}


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

//オーバーフロー
//コーナーケース

typedef long long ll;

vector<int> G[1<<18];
pair<int,int> p[1<<18];
map<pair<int,int>, int> mp;

void dfs(int node, int used) {
    int cnt = 1;
    for (int i = 0; i < G[node].size(); i++) {
        if (cnt == used) cnt++;
        if (mp.count({node, G[node][i]}) || mp.count({G[node][i], node})) continue;
        mp[{node, G[node][i]}] = cnt;
        mp[{G[node][i], node}] = cnt;
        dfs(G[node][i], cnt++);
    }
}

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n - 1; i++) {
        int a,b;
        cin >> a >> b;
        p[i] = {a,b};
        G[a].push_back(b);
        G[b].push_back(a);
    }
    int ans = 0;
    int id = 0;
    for (int i = 1; i <= n; i++) {
        if (G[i].size() > ans) {
            ans = G[i].size();
            id = i;
        }
    }
    int cnt = 1;
    for (int i = 0; i < ans; i++) {
        mp[{id,G[id][i]}] = cnt;
        mp[{G[id][i],id}] = cnt;
        dfs(G[id][i], cnt++);   
    }
    cout << ans << endl;
    for (int i = 0; i < n - 1; i++) {
        cout << mp[{p[i].first, p[i].second}] << endl;
    }
    return 0;
}


Measured memory_bytes: 23424
/*
Sharif Hasan - CSE, PUST
Sep 01,2019 06:05 PM
*/
#include<bits/stdc++.h>
#define br cout<<"\n"
#define FOR(i,n) for(i=0;i<n;i++)
#define FROM(a,i,n) for(i=a;i<n;i++)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;
int main()
{
int n;
cin>>n;
int i;
int arr[n],cnt=0,ma=0;
FOR(i,n) cin>>arr[i];
FOR(i,n-1)
{
    if(arr[i]<arr[i+1])
    {
        cnt=0;//br;
        continue;
    }
    else
    {
        cnt++;
       // cout<<arr[i]<<" ";
    }
    ma = max(cnt,ma);
}
cout<<ma;
return 0;
}

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

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


Measured memory_bytes: 3096
from operator import itemgetter
n,m = map(int,input().split())
stu = list(list(map(int,input().split())) for i in range(n))
cp = list(list(map(int,input().split())) for i in range(m))

for sx,sy in stu:
    dis = {}
    cnt = 1
    for cx,cy in cp:
        dis[cnt] = (abs(sx - cx) + abs(sy - cy))
        cnt += 1
    print(min(dis.items(), key = itemgetter(1))[0])

Measured memory_bytes: 9124
import sys
from collections import defaultdict
from collections import deque
import numpy as np
import heapq
from heapq import heappush, heappop


sys.setrecursionlimit(10 ** 7)

N, K = map(int, input().split())
H = list(map(int, input().split()))

H.sort(reverse=True)

if N == K:
    print(0)
else:
    a = sum(H[K:])
    print(a)


Measured memory_bytes: 34208
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

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

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int e = (c * d) / gcd(c, d);
    a--;
    int x = b - b / c - b / d + b / e;
    int y = a - a / c - a / d + a / e;
    cout << x - y << endl;
}

Measured memory_bytes: 256
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

// CHECK THE LIMITS
typedef long long ll;

const int MOD = 1000000007;
const ll INFLL = 1e18;
const int INF = 1e9;
const int NMAX = 1000001;

int gcd(int a, int b) {
  return b ? gcd(b, a%b) : a;
} 

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int x;
    cin >> x;
    int aux = x / 100;
	int rest = x % 100;
	
	vector<int> dp(100,INF);
	dp[0] = 0;
	for(int i = 1; i<= 99; ++i)
	{
		for(int j = 1; j <= 5; ++j)
		{
			if(i - j>=0)
			{
				dp[i] = min(dp[i], dp[i-j] + 1);
			}
		}
	}
    if(dp[rest] <= aux)
		cout << 1;
	else
		cout << 0;

    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
	string S; cin >> S;
	int ans = 0, cnt = 0;
	for(int i = 0; i < 3; i++) {
		if(S[i] == 'R') cnt++;
		else {
			ans = max(cnt, ans);
			cnt = 0;
		}
	}
	ans = max(cnt, ans);
	cout << ans << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

	ll lucas[100];
	int N; cin >> N;

	lucas[0] = 2;
	lucas[1] = 1;

	for (int i = 2;i <= N;i++){
		lucas[i] = lucas[i-1]+lucas[i-2];
	}

	cout << lucas[N] << endl;

	return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#define ll long long
using namespace std;

const int N=100005;
const int mod=1000000007;
const ll inf=1000000000000000000ll;

int n,ans,l,r;
ll A,B;
int dp[N],s[N];
ll a[N];

int gs(int l,int r){
	if (l>r) return 0;
	if (l==0) return s[r];
	return (s[r]-s[l-1]+mod)%mod;
}

int main(){
	int i,j;
	scanf("%d%lld%lld",&n,&A,&B);
	if (A>B) swap(A,B);
	for (i=1;i<=n;i++) scanf("%lld",&a[i]);
	for (i=3;i<=n;i++)
		if (a[i]-a[i-2]<A){
			printf("0\n");
			return 0;
		}
	a[0]=-inf;
	dp[0]=dp[1]=1; s[1]=2; s[0]=1; l=r=0;
	for (i=2;i<=n;i++){
		while (a[i]-a[r+1]>=B) r++;
		if (a[i-1]-a[i-2]<A) l=i-2;
		dp[i]=gs(l,r);
		s[i]=(s[i-1]+dp[i])%mod;
	}
	r=n-1;
	while (a[r+1]-a[r]>=A) r--;
	printf("%d\n",gs(r,n));
	return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<tuple>

#define DIV 998244353
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	ll N, Z, W; cin >> N >> Z >> W;
	vector<ll> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}

	if (N == 1) cout << abs(a[0] - W) << endl;
	else cout << max(abs(a[N - 1] - W), abs(a[N - 1] - a[N - 2]));
	
}

Measured memory_bytes: 3548
n, k = map(int, input().split())

MOD = 10**9 + 7
MAX = n + 10
fact = [1] * (MAX + 1)  # i!
finv = [1] * (MAX + 1)  # (i!)^{-1}
iinv = [1] * (MAX + 1)  # i^{-1}
for i in range(2, MAX + 1):
    fact[i] = fact[i - 1] * i % MOD
    iinv[i] = MOD - iinv[MOD % i] * (MOD // i) % MOD
    finv[i] = finv[i - 1] * iinv[i] % MOD


def comb(n: int, k: int) -> int:
    if n < k or n < 0 or k < 0:
        return 0
    return (fact[n] * finv[k] % MOD) * finv[n - k] % MOD


ans = 0
for i in range(k, n + 2):
    ans += n * i - i * (i - 1) + 1
    # print(i,
    # i * (i - 1) // 2, n * i - i * (i - 1) // 2, n * i - i * (i - 1) + 1)
    ans %= MOD

print(ans)


Measured memory_bytes: 32608
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
  #include "_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

signed main(){

  int a; cin >> a;
  cout << (a + a*a + a*a*a) << endl;

  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

const int inf = (int) 1e9;

int main() {
  int n, w;
  cin >> n >> w;
  int val[n], we[n];
  for (int i = 0; i < n; i++) {
    cin >> we[i] >> val[i];
  }
  long long dp[n][w + 1];
  memset(dp, 0, sizeof dp);
  for (int j = we[0]; j <= w; j++) {
    dp[0][j] = val[0];
  }
  for (int i = 1; i < n; i++) {
    for (int j = 0; j <= w; j++) {
      if (j < we[i]) {
        dp[i][j] = dp[i - 1][j];
      } else {
        dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - we[i]] + val[i]);
      }
    }
  }
  cout << dp[n - 1][w] << endl;
  return 0;
}


Measured memory_bytes: 78336
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    int n,m,sum=0,x,c=0;
    cin>>n>>m;
    vector<int>v;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        v.push_back(x);
        sum+=x;
    }
    double y=sum*1.00/(4*m);
    for(int i=0;i<n;i++)
    {
        if(v[i]>=y) c++;
    }
    if(c>=m) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(long long k, long long n, std::vector<long long> a){
    for(int i = 0; i < n; ++i)
        a.push_back(a[i] + k);
    i64 ans = INF;
    for(int i = 0; i < n; ++i)
        chmin(ans, a[i + n - 1] - a[i]);
    cout << ans << endl;
}


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


Measured memory_bytes: 4864
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
 
#include<bits/stdc++.h>
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/detail/standard_policies.hpp>*/
 
#define sz(s) (int)(s.size())
#define all(s) s.begin(), s.end()
#define rep(a, b, c) for(int a = b; a <= c; ++a)
#define per(a, b, c) for(int a = b; a >= c; --a)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 
using namespace std;
//using namespace __gnu_pbds;
 
typedef unsigned long long ull;
typedef long long ll;
/*typedef tree<pair<int, int>, 
null_type, less<pair<int, int>>, 
rb_tree_tag, tree_order_statistics_node_update>
ordered_set;*/
//find_by_order() order_of_key()
 
const double eps = 1e-7;
const int mod = 1e9+7, MXN = 1e3+17;
const int dx[] = {0,0,1,-1}, dy[] = {1,-1,0,0};
 
template<typename T>inline bool updmin(T &a, const T &b) {return a > b ? a = b,1 : 0;}
template<typename T>inline bool updmax(T &a, const T &b) {return a < b ? a = b,1 : 0;}
 
int n, k;
int d[15];
 
inline bool is_good(int x) {
	while(x) {
		rep(i,1,k)
			if(x%10 == d[i])
				return 0;
		x /= 10;
	}
	return 1;
}
 
int32_t main() { _
#ifdef DanQQQQQ
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	cin >> n >> k;
	rep(i,1,k) cin >> d[i];
	while(!is_good(n)) ++n;
	cout << n;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int linearSearch(int A[], int n, int key){
    int i = 0;
    A[n] = key;
    while(A[i] != key) i++;
    return i != n;
}

int main(){
    int n, A[10000+1], q, key, sum = 0;
    
    scanf("%d", &n);
    for (int i = 0; i < n; i++) scanf("%d", &A[i]);
    
    scanf("%d", &q);
    for (int i = 0; i < q; i++){
        scanf("%d", &key);
        if (linearSearch(A, n, key)) sum++;
    }
    printf("%d\n", sum);
    
    return 0;
}


Measured memory_bytes: 2744
/*
        Oink!Oink!!
▂╱▔▔╲╱▔▔▔▔╲╱▔▔╲▂
╲┈▔╲┊╭╮┈┈╭╮┊╱▔┈╱
┊▔╲╱▏┈╱▔▔╲┈▕╲╱▔┊
┊┊┊┃┈┈▏┃┃▕┈┈┃┊┊┊
┊┊┊▏╲┈╲▂▂╱┈╱▕┊┊┊

*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <stack>
#include <sstream>
#include <cstring>
#include <numeric>
#include <ctime>
#include <cassert>
#include <random>
#include <valarray>
#include <unordered_map>
//#include <fstream>
#define re return
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) ((int)(x).size())
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define y0 y32479
#define y1 y95874
#define next next239
#define prev prev239
#define fill(x, y) memset(x, y, sizeof(x))
#define sqr(x) ((x) * (x))
#define sqrt(x) sqrt(abs(x))
#define unq(x) (x.resize(unique(all(x)) - x.begin()))
#define ba back()
#define popcount __builtin_popcountll
#define fastIO()                 \
    {                            \
        ios::sync_with_stdio(0); \
        cin.tie(0);              \
        cout.tie(0);             \
    }
#define in(x) \
    int x;    \
    cin >> x;
#define in1(x) \
    int x;     \
    cin >> x;  \
    x--;
#define inll(x) \
    ll x;       \
    cin >> x;
#define ins(x) \
    string x;  \
    cin >> x;

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef pair<double, double> pdd;
typedef long double LD;
typedef double D;

int main()
{
    int n;
    cin>>n;
    vector<int> v(n,0);
    unordered_map<int,long long int> m;
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
        m[v[i]]++;
    }
    
    long long int total=0;
    for(auto x:m)
    {   
        total+=x.second*(x.second-1)/2;
    }
    for(int i=0;i<n;i++)
    {
       long long int temp;
       temp=total;

        temp=temp-m[v[i]]+1;

        cout<<temp<<"\n";
    }


    return 0; 
}

Measured memory_bytes: 8392
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <stdio.h>
#include <cmath>
#include <string.h>
#include <vector>

#define ll long long
#define inf 0x3f3f3f3f
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    if(n * 500 >= m)    cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 256
using System;
using static System.Console;
using static System.Int32;
using static System.Math;
using System.Linq;
using System.Collections.Generic;

class Solution
{
    static void Main()
    {
    lb:
        var k = Parse(ReadLine());
        int r = 0;
        for(int a = 1; a <= k; ++a)
        {
            for(int b = 1; b <= k; ++b)
            {
                for(int c = 1; c <= k; ++c)
                {
                    r += gcb(a, b, c);
                }
            }
        }
        WriteLine(r);
    }

    static int gcb(int a, int b, int c) => gcb(gcb(a, b), c);
    static int gcb(int a, int b)
    {
        if (a < b) (b, a) = (a, b);
        while (true)
        {
            var jy = a % b;
            if (jy == 0) return b;
            (a, b) = (b, jy);
        }
    }
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

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

const int INTINF = 1e9;
const LL LLINF = 1e18;

void solve()
{
    int N;
    cin >> N;

    // リーダの左側
    int L_W = 0; // 向きを変える
    // リーダーの右側
    int R_E = 0; // 向きを変える

    vector<char> S(N);
    REP0(i, N)
    {
        cin >> S[i];
        // はじめリーダーは左端にいるとする
        if (i and S[i] == 'E')
            R_E++;
    }

    int ans = R_E;

    REP1(i, N - 1)
    { // i 番目をリーダーにする場合
        if (S[i - 1] == 'W')
            L_W++;
        if (S[i] == 'E')
            R_E--;
        ans = min(ans, L_W + R_E);
    }

    cout << ans << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}

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

int main(int argc, char *argv[])
{
  string s;
  int zero = 0, one = 0;
  cin >> s;
  for(int i = 0; i < s.length(); i++) {
    if(s.at(i) == '0') zero++;
    else one++;
  }

  cout << 2*min(zero, one) << endl;
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  vec a(3);
  for(ll i=0;i<3;i++) cin >> a[i];
  sort(a.begin(),a.end());
  if(a[0]==5&&a[1]==5&&a[2]==7) {
    cout << "YES" << endl;
  }
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	unsigned long long n,a,b,c,d,e,k,x;
	cin >> n >> a >> b;
	//int c;
	c = a + b;
	//int d, e;
	d = n / c;
	e = n % c;
	//int k;
	if (e >= a) {
		k = a;
	}
	else {
		k = e;
	}
	//int x;
	x = d * a + k;
	cout << x;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <iomanip>
#include <utility>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <queue>
#include <string>

using namespace std;

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

#define rep(i, n) for (int i = 0; i < n; i++)
#define repext(i, a, b) for (int i = a; i < b; i++)
#define reprev(i, n) for (int i = n - 1; i >= 0; i--)
#define repextrev(i, a, b) for (int i = b - 1; i >= a; i--)

#define vec_all(vec) vec.begin(), vec.end()
#define sum(vec) accumulate(vec_all(vec), 0)
#define srt(vec) sort(vec_all(vec))

// vectorデバッグ
template <typename T>
void dump_vec(vector<T> vec)
{
    rep(i, vec.size())
    {
        cout << i << ": " << vec[i] << endl;
    }
}

ll int_sum (ll n) {
    return n * (n + 1) / 2;
}

// --- notice ---
// intの和はllにしろ

int main()
{
    int x;
    cin >> x;
    int cnt = 1;
    while (true) {
        if (int_sum(cnt - 1) < x && x <= int_sum(cnt)) {
            break;
        }
        cnt++;
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<=(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<si> vsi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<int> qi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 文字変換　
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
// a内でx以上　auto iter = lower_bound(ALL(a), x);
// a内でxより大きい　auto iter = upper_bound(ALL(a), x);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned Euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return Euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int digit_sum(int n) {
  int sum=n%10;
  while(n!=0) {
    n/=10;
    sum+=n%10;
  }
  return sum;
}

vpll PrimeFactorization(ll n) {
  vpll res;
  for (ll i=2; i*i<=n; i++) {
    if(n%i!=0) continue;
    ll ex=0;
    while(n%i==0) {
      ex++;
      n/=i;
    }
    res.push_back(pll(i,ex));
  }
  if(n!=1) res.push_back(pll(n,1));
  return res;
}




int main() {
  int n,k;
  cin >> n >> k;
  int ans=k;
  REP(i,n-1) {
    ans*=k-1;
  }
  cout << ans << endl;
  return 0;
}


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

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N+1);
    vector<ll> B(N);
    ll count = 0;

    

    for(ll i = 0; i <= N; i++)
    {
        cin >> A.at(i);
        count += A.at(i);
    }
    for(ll i = 0; i < N; i++)
    {
        cin >> B.at(i);
    }

    for(ll i = 0; i < N; i++)
    {
        if(A.at(i) < B.at(i))
        {
            B.at(i) -= A.at(i);
            A.at(i) = 0;
            if(A.at(i+1) < B.at(i))
            {
                A.at(i+1) = 0;
            }
            else
            {
                A.at(i+1) -= B.at(i);
            }   
        }
        else
        {
            A.at(i) -= B.at(i);
        }
        
    }
    for(ll i = 0; i <= N; i++)
    {
        count -= A.at(i);
    }

    cout << count << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <cstring>
using namespace std;
long long int n,maxw,w0;
int v[101],w[101],mem[101][101][1001];
int din(int a, int weight, int surplus) {
	if (mem[a][weight][surplus] != -1) return mem[a][weight][surplus];
	if (a >= n) return 0;
	int res = din(a+1,weight,surplus);
	if (((weight+1)*w0 + surplus+w[a]) <= maxw) {
		res = max(res,v[a]+din(a+1,weight+1,surplus+w[a]));
	}
	mem[a][weight][surplus] = res;
	return res;
}
int main() {
	memset(mem,-1,sizeof mem);
	cin >> n >> maxw;
	for (int i = 0; i < n; i++) {
		cin >> w[i] >> v[i];
		if (i == 0) {
			w0 = w[i];
		}
		w[i] = w[i]-w0;
	}
	cout << din(0,0,0);
	return 0;
}

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

int main(void)
{	
	int M,D;
	int i,j;
	int one,ten = 0;
	int ans = 0;
	scanf("%d%d",&M,&D);
	for(i=1;i <= M;i++){
		for( j = 2;j<=D;j++){
			one = j;
			if(j >= 10){
				ten = j/10;
				one = j-ten*10;
			}
			if(ten * one == i&& ten != 1&& one != 1){
				ans++;
			}
			ten = 0;
		}
	}
	printf("%d",ans);
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <vector>
#include <cmath>
using namespace std;
int main(void){
    int N; cin >> N;
    int i = 0;
    int max = 0;
    int min = 1 + pow(10, 9);
    vector<int> a(N);
    while(a.size() > i){
        cin >> a[i];
        if (a[i] > max) {
            max = a[i];
        } 
        if (a[i] < min) {
            min = a[i];
        }
        i++;
    }
    cout << max - min << endl;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<string,int>;
using T = tuple<string,int,int>;

int main(){
  ll a,b,c;
  cin >> a >> b >> c;
  ll x = c-a-b;
  if(x < 0){
    cout << "No" << endl;
    return 0;
  }
  if(4*a*b < x*x) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
N=int(input())
W=[tuple(input().split()) for _ in range(N)]
U=[]
R=[]
D=[]
L=[]
for x,y,u in W:
 x,y = int(x),int(y)
 if u=="U":
  U.append((x,y))
 elif u=="D":
  D.append((x,y))
 elif u=="L":
  L.append((x,y))
 else:
  R.append((x,y))
r=10**9
def z(A):
 global r
 A.sort()
 n=p=-10**9
 for k,c,a in A:
  if k!=n:
   if a==1:
    n=k
    p=c
   continue
  if a==1:
   p=c
   continue
  if (c-p)*5<r:
   r=(c-p)*5
z([(x,y,1) for x,y in U]+[(x,y,-1) for x,y in D])
z([(y,x,1) for x,y in R]+[(y,x,-1) for x,y in L])
z([(x+y,x-y,1) for x,y in R]+[(x+y,x-y,-1) for x,y in U])
z([(x+y,x-y,1) for x,y in D]+[(x+y,x-y,-1) for x,y in L])
z([(x-y,x+y,1) for x,y in U]+[(x-y,x+y,-1) for x,y in L])
z([(x-y,x+y,1) for x,y in R]+[(x-y,x+y,-1) for x,y in D])
print("SAFE" if r>=10**9 else r)

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

class Solution
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var a = new long[n];
        for (int i = 0; i < n; i++)
        {
            a[i] = int.Parse(Console.ReadLine());
        }

        var winner = "first";
        if (a.All(aa => aa % 2 == 0))
        {
            winner = "second";
        }

        Console.WriteLine(winner);
    }
}

Measured memory_bytes: 15840
#include <bits/stdc++.h>
using namespace std;
#warning do not forget to change size of N and M 
#define popcnt(a) __builtin_popcount(a)
#define gcd(a,b) __gcd(a,b)
#define IO() assert(freopen("in.in", "rt", stdin)), assert(freopen("out.out", "wt", stdout))
#define FastIO() ios::sync_with_stdio(false),cin.tie(0);
#define debug(x) cout << __LINE__ << ": " << #x << " = " << (x) << endl


typedef long long ll;

const ll MOD = 1e9 + 7;
const int N = 1e7 + 9, M = 1e5 + 9, OO = 0x3f3f3f3f;
const double EPS = 1e-10,PI=acos(-1.0);

//Number Theory
inline bool dCMP(const long double &a, const long double &b) { return fabsl(a - b) < EPS;}

//Geometry 
inline double MintoDeg(double min){return min/60;}
inline double to_Radian(double deg){return deg*PI/180.0;}
inline double to_Degree(double radian){if(radian<0) radian+=2*PI; return radian*180/PI ;}
inline double fixAngle(double A){return A>1 ? 1 : (A<-1 ? -1 : A);}
int freq[N];
int main()
{
  
  int n;
  scanf("%d",&n);
  for(int i=0;i<n;++i)
  {
    int y;
    scanf("%d",&y);
    freq[y]++;
  }
  ll x=1;
  if(n&1)
  {
    if(freq[0]!=1) x=0; 
    else
      for(int i=2;i<n;i+=2)
        if(freq[i]!=2)
        {
          x=0;
          break;
        }
        else x=(x*2)%MOD;
  }
  else
  {
    for(int i=1;i<n;i+=2)
      if(freq[i]!=2)
      {
        x=0;
        break;
      }
      else x=(x*2)%MOD;
  }  
  printf("%lld",x);
  
  return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

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

        int X = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();

        System.out.println(solve(X, A, B));

        sc.close();
    }

    static int solve(int X, int A, int B) {
        return (X - A) % B;
    }
}

Measured memory_bytes: 21844
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();

    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let mut card: [[u32; 3]; 3] = [[0; 3]; 3];
    let mut count: u32 = 0;
    let mut bingo: String = "No".to_string();

    for i in 0..3 {
        for j in 0..3 {
            card[i][j] = read();
        }
    }
    let n: usize = read();

    let b: Vec<u32> = (0..n).map(|_| read()).collect();

    for i in 0..3 {
        for j in 0..3 {
            if b.contains(&card[i][j]) {
                count += 1;
            }
        }
        if count == 3 {
            bingo = "Yes".to_string();
            break;
        }
        count = 0;
    }

    for i in 0..3 {
        for j in 0..3 {
            if b.contains(&card[j][i]) {
                count += 1;
            }
        }
        if count == 3 {
            bingo = "Yes".to_string();
            break;
        }
        count = 0;
    }

    for i in 0..3 {
        if b.contains(&card[i][i]) {
            count += 1;
        }
    }
    if count == 3 {
        bingo = "Yes".to_string();
    } else {
        count = 0;
    }

    for i in 0..3 {
        if b.contains(&card[i][2 - i]) {
            count += 1;
        }
    }
    if count == 3 {
        bingo = "Yes".to_string();
    }

    println!("{}", bingo);

}


Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (3e9)

using namespace std;
typedef long long int ll;
int A[3][3];
int N, b;
int res[3][3];
int main(void){
    REP(i, 3) cin >> A[i][0] >> A[i][1] >> A[i][2];
    cin >> N;
    REP(i,N){
        cin >> b;
        REP(row,3) REP(col,3){
            if(A[row][col] == b) res[row][col] = 1;
        }
    }

    int q = 0;
    q |= (res[0][0] & res[0][1] & res[0][2]);
    q |= (res[1][0] & res[1][1] & res[1][2]);
    q |= (res[2][0] & res[2][1] & res[2][2]);

    q |= (res[0][0] & res[1][0] & res[2][0]);
    q |= (res[0][1] & res[1][1] & res[2][1]);
    q |= (res[0][2] & res[1][2] & res[2][2]);

    q |= (res[0][0] & res[1][1] & res[2][2]);
    q |= (res[0][2] & res[1][1] & res[2][0]);

    if(q==1) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 384
# -*- coding: utf-8 -*-
from sys import setrecursionlimit
setrecursionlimit(10000000)

N = int(input())
C = [[] for _ in range(N+1)]

for i in range(1, N):
    C[int(input())-1].append(i)

def cal(x):
    if len(C[x]) == 0:
        return 0
    else:
        D = sorted([cal(a) for a in C[x]], reverse=True)
        res = 0
        for i, d in enumerate(D, start=1):
            res = max(res, i+d)
        return res

print(cal(0))

Measured memory_bytes: 228048
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int N;
  cin >> N;
  long long int A[N];
  for(long long int i=0;i<N;i++) cin >> A[i];
  map<long long int,long long int> M;
  for(long long int i=0;i<=N;i++) M[i]=0;
  for(long long int i=0;i<N;i++){
    M[A[i]]++;
  }
  long long int sum=0;
  for(long long int i=0;i<=N;i++){
    sum+=M[i]*(M[i]-1)/2;
  }
  for(long long int i=0;i<N;i++){
    long long int ans=sum;
    ans-=M[A[i]]*(M[A[i]]-1)/2.0;
    M[A[i]]--;
    ans+=M[A[i]]*(M[A[i]]-1)/2.0;
    M[A[i]]++;
    cout << ans << endl;
  }
}


Measured memory_bytes: 16640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<string,ll>;
using Map = map<string,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;


int main(){
    ll N;
    cin >> N;
    ll W;
    cin >> W;
    vector<ll> w(N+1,0);
    vector<ll> v(N+1,0);
    for(ll i=0;i<N;i++){
        cin>>w[i+1]>>v[i+1]
    ;}
    //dp[j]は重さj以下で買える最大の価値
    vector<ll> dp(W+1,0);
    
    //1つずつ品物を解禁
    for(ll i=1;i<=N;i++){
     for(ll j=W;j>=w[i];j--){
         dp[j]=max(dp[j-w[i]]+v[i],dp[j])
     ;}
    ;}
    cout<<dp[W]<<endl;
return 0;
}


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

int main(){
  int N;
  int i,j,k;
  cin >> N;
  int Amax = 1000001;
  vector<bool> s(Amax,false);
  vector<int> c(Amax,0);

  for(i=0;i<N;i++){
    cin >> j;
    c[j]++;
    s[j] = true;
  }

  for(i=0;i<Amax;i++){
    if (s[i] && (c[i] > 0))
      for(j=i*2;j<Amax;j+=i)
        s[j] = false;
    if (c[i] > 1)
      s[i] = false;
  }

  int ct = 0;
  for(i=0;i<Amax;i++)
    if (s[i])
      ct++;
  cout << ct << endl;
}

Measured memory_bytes: 7224
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

int main(void)
{
    int k, x;
    cin >> k >> x;

    for(int i = x - k + 1; i <= x + k -1; i++)
    {
        cout << i << endl;
    }
    return 0;
}

Measured memory_bytes: 256
a=10**9

list = []
(-1000).upto(1000) do |i|
  list << [i**5, i]
end

x = gets.to_i
list.each do |v1|
  list.each do |v2|
    if (v1[0] - v2[0]) == x
      printf("%d %d\n",v1[1], v2[1])
      exit
    end
  end
end



Measured memory_bytes: 14360
s=input()
p=input()

s_l=[]
p_l=[]

for i in s:
    s_l.append(i)

for i in p:
    p_l.append(i)

for i in range(len(s_l)):
    j=0
    while j<len(p_l):
        k=i+j
        if k>=len(s_l):
            k=k-len(s_l)

        if s_l[k]==p_l[j]:
            j=j+1
        else:
            break
    if j==len(p_l):
        print("Yes")
        break
            
if j<len(p_l):
    print("No")



Measured memory_bytes: 5564
n, tmax = (int(i) for i in input().split())
costs=[]
for i in range(0,n):
    c, t = (int(i) for i in input().split())
    if t<=tmax:
        costs.append(c)
        
if len(costs)==0:
    print("TLE")
else:
    print(min(costs))


Measured memory_bytes: 2940
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int h = in.nextInt();
            int w = in.nextInt();

            out.println((n - h + 1) * (n - w + 1));
        }

    }

    static class InputReader {
        private BufferedReader br;
        private StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
            st = new StringTokenizer("");
        }

        public String nextString() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

    }
}



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

#define ll long long

int main(void){
    int n; cin >> n;
    vector<int>a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
        a[i]--;
    }
    cout << accumulate(a.begin(),a.end(),0) << endl;
    return 0;
}

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

#define maxn 100005
#define inf (int) 2e9
#define ll long long
#define ii pair <int, int>
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define REP(i, a, b) for(int i = a; i >= b; i--)

int n, k;
int a[maxn], b[maxn], c[maxn], f[maxn][5];

int main() {
    //freopen("main.inp", "r", stdin);
    cin >> n;
    FOR(i, 1, n)
        cin >> a[i] >> b[i] >> c[i];
    FOR(i, 1, n) {
        f[i][1] = max(f[i - 1][2] + b[i], f[i - 1][3] + c[i]);
        f[i][2] = max(f[i - 1][1] + a[i], f[i - 1][3] + c[i]);
        f[i][3] = max(f[i - 1][1] + a[i], f[i - 1][2] + b[i]);
    }
    int ans = 0;
    FOR(i, 1, 3) ans = max(ans, f[n][i]);
    cout << ans;
}


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

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

	if (a < 10 && b < 10)
	{
		cout << a * b << endl;
	}
	else
	{
		cout << -1 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include"math.h"

using namespace std;
string strRev(string s){
    reverse(s.begin(), s.end());
    return s;
}
int main(){
    int n;
    string s, sr;
    cin >> s;
    n = s.length();
    sr = strRev(s);
    if(s.compare(sr) == 0){
        string sub = s.substr(0, (n-1)/2);
        string subr = strRev(sub);
        if(sub.compare(subr) == 0){
            string back = s.substr((n+3)/2-1, n);
            string backr = strRev(back);
            if(back.compare(backr) == 0){
                cout << "Yes\n" ;
            }else{
                cout << "No\n";
            }
        }else{
            cout << "No\n";
        }
    }else{
        cout << "No\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  vi a(m), dp(n + 1, -1);
  bool ok = true;
  rep(i, m){
    cin >> a[i];
    dp[a[i]] = 0;
    if(i && a[i - 1] + 1 == a[i]) ok = false;
  }
  if(!ok){
    cout << 0 << endl;
    return 0;
  }
  dp[0] = 1;
  for(int i = 1; i <= n; i++){
    if(!dp[i]) continue;
    if(i >= 2) dp[i] = (dp[i - 1] + dp[i - 2]) % mod;
    else dp[i] = dp[i - 1];
  }
  cout << dp[n] << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define pii pair<int, int>
#define mp make_pair
#define mem(x) memset(x,0,sizeof(x))
using namespace std;
class Solution
{
public:
    void solve()
    {
        int n, q;
        cin >> n >> q;
        vector<vector<ll> > v;
        v.resize(n + 1);
        while(q--)
        {
            int t;
            cin >> t;
            if(!t)
            {
                ll x, y;
                cin >> x >> y;
                v[x].push_back(y);
            }
            else if(t & 1)
            {
                ll x;
                cin >> x;
                for(int i = 0; i < v[x].size(); ++i)
                {
                    if(!i)cout << v[x][i];
                    else cout << ' ' << v[x][i];
                }
                cout << endl;
            }
            else
            {
                ll x;
                cin >> x;
                v[x].clear();
            }
        }
    }
};
int main()
{
    Solution s;
    s.solve();
    return 0;
}



Measured memory_bytes: 8844
n = int(input())
a = list(map(int, input().split()))
mini = 10000001
maxi = -10000001
sumi = 0
for i in range(n):
    if  a[i] < mini:
        mini = a[i]
    if a[i] > maxi:
        maxi = a[i]
    sumi += a[i]
print("{} {} {}".format(mini, maxi, sumi))


Measured memory_bytes: 6596
#include <bits/stdc++.h>
using namespace std;
int main( ){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> dp(3, 0);
    for(int i = 0; i < n; i++){
        vector<int> num(3), sub_dp(3, 0);
        for(int j = 0; j < 3; j++)
            cin >> num[j];
        for(int j = 0; j < 3; j++)
            for(int k = 0; k < 3; k++)
                if(j != k)
                    sub_dp[j] = max(sub_dp[j], num[j] + dp[k]);
        dp = sub_dp;
    }
    int ans = 0;
    for(int i = 0; i < 3; i++)
        ans = max(ans, dp[i]);
    cout << ans << '\n';
    return 0;
}

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

using namespace std;

#define ll long long

bool vec[3000][3000];
long double res[3000][3000];

long double pro(vector<long double> v,ll n,ll m)
{
	if(vec[n][m]!=0)
	{
		return vec[n][m];
	}
	res[1][1]=v[0];
	double k=1;
	for(ll i=1;i<=n;i++)
	{
		k*=(1-v[i-1]);
		res[i][0]=k;
	}
	for(ll i=2;i<=n;i++)
	{
		for(ll j=1;j<=i;j++)
		{
			res[i][j]=v[i-1]*res[i-1][j-1]+(1-v[i-1])*res[i-1][j];
		}
	}
	
	return res[n][m];
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll a,b,c,d;
	long double p;
	vector<long double> v;
	cin >> a;
	for(ll i=0;i<a;i++)
	{
		cin >> p;
		v.push_back(p);
	}
	ll out=pro(v,a,a);
	long double op=0;
	for(ll i=(a+1)/2;i<=a;i++)
	{
		op+=res[a][i];
	}
	cout << setprecision(12) <<op;
//	cout << pro(v,a,2);
}

Measured memory_bytes: 139904
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,i;
    cin>>a>>b;
    if(a<=b)
    {
        for(i=1;i<=b;i++)
        {
            cout<<a;
        }
    }
    else
    {

        for(i=1;i<=a;i++)
        {
            cout<<b;
        }
    }
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,flg;
	scanf("%d %d",&a,&b);
	flg=0;
	if(a==b){
		printf("Draw\n"); flg=1;
	}	
	else if(a==1&&b>1){
		printf("Alice\n"); flg=1;
	}	
	else if(b==1&&a>1){
		printf("Bob\n"); flg=1;
	}
	if(flg==0){
		if(a>b) printf("Alice\n");
		else printf("Bob\n");
	}	
	return 0;
}	

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c;
  cin >> a >> b >> c;

  vector<int> n{a, b, c};
  sort(n.begin(), n.end());
  
  cout << n[2] * 10 + n[0] + n[1] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS                \
  ios::sync_with_stdio(0); \
  cin.tie(0);              \
  cout.tie(0);
#define int long long
const unsigned int M = 1000000007;
using namespace std;
int res[10000007];
void fun(int n)
{
  for (int i = 1; i <= n; i++)
    for (int j = i; j <= n; j += i)
      res[j]++;
}

int32_t main()
{
  IOS int n;
  cin >> n;
  memset(res, 0, sizeof(res));
  fun(n);
  int ans = 0;
  for (int i = 1; i <= n; i++)
  {
    ans += i * res[i];
  }
  cout << ans << endl;

  return 0;
}


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

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

int main(){
    long N;
    lint tempA;
    multimap <lint,lint> mp;

    cin >> N;
    for(long i = 0;i < N;i++){
        cin >> tempA;
        mp.insert(P(tempA,1));
    }

    while(mp.size() > 1){
        auto itr = mp.begin();
        lint temp_size = itr->first;
        lint temp_cand = itr->second;
        itr = mp.erase(itr);
        if(temp_size*2 >= itr->first){
            mp.insert(P(temp_size + itr->first,temp_cand + itr->second));
        }
        else{
            mp.insert(P(temp_size + itr->first,itr->second));
        }
        mp.erase(itr);
    }

    auto itr = mp.begin();
    cout << itr->second << endl;

    return 0;
}

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

// @@ !! LIM(sieve)
// --> sieve
// ---- inserted library file sieve.cc

// sieve(upto) returns the list of prime numbers up to upto.
//   Size: upto(1e8).size() ... 5.7e6,  upto(1e9).size() ... 5.1e7
//   Performance: upto(1e8) ... 0.7sec,   upto(1e9) ... 9.2sec
vector<int> sieve(int upto) {
  vector<int> res;
  vector<bool> tbl(upto+1);
  ll lim = (int)(sqrt((double)upto)) + 1;
  for (int x = 2; x <= upto; x++) {
    if (tbl.at(x))  continue;
    res.push_back(x);
    if (x > lim)  continue;
    for (int y = x * 2; y <= upto; y += x) tbl.at(y) = true;
  }
  return res;
}

/*
  Prime Factorization
    Two versions:
      - prfac(n)
      - prfac(n, primes)
 */

vector<pair<ll, int>> prfac(ll n, const vector<int>& primes) {
  //      primes should contain prime numbers at least up to sqrt(n)
  vector<pair<ll, int>> res;
  ll x = n;
  for (ll p : primes) {
    if (x == 1)  break;
    if (p * p > x)  break;
    if (x % p != 0)  continue;
    int c = 1;
    x /= p;
    while (x % p == 0) {
      c += 1;
      x /= p;
    }
    res.push_back(make_pair(p, c));
  }
  if (x != 1)  res.push_back(make_pair(x, 1));
  return res;
}

vector<pair<ll, int>> prfac(ll n) {
  return prfac(n, sieve((int)(sqrt((double)n)) + 1));
}

/*
    List of divisors
      - getDivisors(n)
    Note: the results are NOT sorted
 */

// gdsub ... aux function used in getDivisors()
vector<ll> gdsub(int i, int n, auto fs) {
  if (i == n) { return vector<ll>({1}); }
  auto part = gdsub(i+1, n, fs);
  ll p  = fs.at(i).first;
  int r = fs.at(i).second;
  ll pp = p;    // pp = p^m, for m \in [1, r]
  int partOrigLen = part.size();
  for (int m = 1; m <= r; m++) {
    for (int j = 0; j < partOrigLen; j++) {
      part.push_back(pp * part.at(j));
    }
    pp *= p;
  }
  return part;
}

vector<ll> getDivisors(ll n) {
  auto fs = prfac(n);
  return gdsub(0, fs.size(), fs);
}

// ---- end sieve.cc
// @@ !! LIM  -- end mark --

ll keta(ll x) {
  stringstream ss;
  ss << x;
  return ss.str().size();
}

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N; cin >> N;
  ll ans = 10000;
  for (ll x: getDivisors(N)) {
    ll y = N / x;
    if (x < y) swap(x, y);
    ans = min(ans, keta(x));
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 384
y, x = map(int, input().split())
arr = [list(input()) for _ in range(y)]
for i in range(y):
    for j in range(x):
        if arr[i][j] == '#':
            continue
        num = 0
        for yi in range(-1, 2):
            for xj in range(-1, 2):
                if 0 <= j + xj < x and 0 <= i + yi < y:
                    xn = j + xj
                    yn = i + yi
                    if arr[yn][xn] == '#':
                        num += 1
        arr[i][j] = str(num)
for a in arr:
    print("".join(a))

Measured memory_bytes: 3188
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import itertools
import numpy as np

H,W = map(int,readline().split())
A = [list(map(int,readline().split())) for _ in range(H)]
B = [list(map(int,readline().split())) for _ in range(H)]

X = (H + W) * 80
L = X + X + 1
# X点持った状態から始める
dp = [[0] * W for _ in range(H)]
d = abs(A[0][0] - B[0][0])
dp[0][0] = np.zeros(L,np.bool)
dp[0][0][X+d] = 1
for h in range(H):
    for w,(a,b) in enumerate(zip(A[h],B[h])):
        if h == w == 0:
            continue
        d = abs(a - b)
        x = np.zeros(L,np.bool)
        if h != 0:
            x[d:] |= dp[h-1][w][:L-d]
            x[:L-d] |= dp[h-1][w][d:]
        if w != 0:
            x[d:] |= dp[h][w-1][:L-d]
            x[:L-d] |= dp[h][w-1][d:]
        dp[h][w] = x

dp = dp[-1][-1]
can_make = np.where(dp)[0] - X

answer = np.abs(can_make).min()
print(answer)

Measured memory_bytes: 173476
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
bool w[10];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int main() {
    int n,k;
    cin>>n>>k;
    while(k--) w[gi()]=1;
    for(int i=n;;i++) {
	int x=i;
	while(x) {
	    if(w[x%10]) break;
	    x/=10;
	}
	if(!x) {cout<<i;break;}
    }
    return 0;
}

Measured memory_bytes: 256