akhauriyash/Code-Regression huggingface dataset:
from collections import Counter

S = input()
MOD = 2019
div10 = 202  # modInverse(10, MOD). Note MOD is not prime so can't use FLT!


def solve1(S):
    # Naive implementation
    counts = [0 for i in range(MOD)]
    total = 0
    for d in S:
        d = int(d)
        nextCounts = [0 for i in range(MOD)]
        nextCounts[d] += 1
        for k, v in enumerate(counts):
            nextCounts[(10 * k + d) % MOD] += v
        counts = nextCounts
        total += counts[0]
    return total


def solve2(S):
    # Instead of shuffling the entire counts, update how we index into counts instead
    # The cumulative shuffle function forward is something like a * index + b for some calculable a, b
    # Then indexing into counts[t][x] is same as indexing into counts[0][(x - b) / a]

    negPowTen = 1  # our a
    prefix = 0  # our b
    counts = [0 for i in range(MOD)]
    total = 0
    for d in S:
        d = int(d)
        prefix = (10 * prefix + d) % MOD
        negPowTen = (negPowTen * div10) % MOD
        counts[((d - prefix) * negPowTen) % MOD] += 1
        total += counts[((0 - prefix) * negPowTen) % MOD]
    return total


def solve3(S):
    # Alternative solution, precompute prefixes, p[i+1] == (10 * p[i] + S[i]) % MOD
    # Then you have for S = '1817181712114'
    # p[1] = 1
    # p[2] = 18
    # p[3] = 181
    # p[4] = 1817
    # etc
    # Then want to count all i j such that:
    # (p[j] - p[i] * pow(10, j - i)) % M == 0
    # Which is equivalent to
    # (p[j] * pow(10, -j) - p[i] * pow(10, -i) % M == 0
    negPowTen = 1
    total = 0
    prefix = 0
    counts = [0 for i in range(MOD)]
    counts[0] = 1
    for d in S:
        prefix = (prefix * 10 + int(d)) % MOD
        key = (prefix * negPowTen) % MOD
        total += counts[key]
        counts[key] += 1
        negPowTen = (negPowTen * div10) % MOD

    return total


def solve4(S):
    # Compute all suffixes instead
    # S     = '1817181712114'
    # suf[1] =             4
    # suf[2] =            14
    # suf[3] =           114
    # suf[4] =          2114
    #
    # Difference of suffixes is almost correct but has extra 10s.
    # For example 2114 to 114 is the string 2 but our difference returns 2000.
    # Luckily 2 and 5 aren't divisible by 2019 so the extra 10s don't matter when counting.
    N = len(S)
    suf = 0
    powTen = 1
    counts = [0 for i in range(MOD)]
    total = 0
    counts[0] = 1
    for i in range(N):
        d = int(S[N - 1 - i])
        suf = (powTen * d + suf) % MOD
        total += counts[suf]
        counts[suf] += 1
        powTen = (powTen * 10) % MOD
    return total


#assert solve1(S) == solve2(S) == solve3(S) == solve4(S)
ans = solve4(S)
print(ans)


Measured memory_bytes: 68840
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception{
        try (Scanner sc = new Scanner(System.in)){
            int w = sc.nextInt();
            int n = sc.nextInt();
            int arr[] = new int[w];
            for (int i=0;i<w;i++){
                arr[i] = i+1;
            }
            for (int i=0;i<n;i++){
                String str=sc.next();
                String[] ab=str.split(",");
                int a = Integer.parseInt(ab[0]);
                int b = Integer.parseInt(ab[1]);
                int tmp;
                tmp = arr[a-1];
                arr[a-1] = arr[b-1];
                arr[b-1] = tmp;
            }
            for (int i=0;i<w;i++){
                System.out.println(arr[i]);
            }
        }
    }
}


Measured memory_bytes: 26192
#include<iostream>
using namespace std;
int main () {
  int n;
  cin >> n;
  int Large=-1000000;
  long long sum=0;
  int small=1000000;
  for (int i=1;i<=n;i=i+1){
    int t;
    cin >> t;
    sum=sum+t;
    if (Large<=t){
      Large = t;
    }
    if (small>=t){
      small = t;
    }
  }
  cout << small << " "  << Large << " " <<  sum << endl;
  return 0;
}



Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define EB emplace_back
#define MP make_pair
#define all(o) (o).begin(), (o).end()
#define mset(m,v) memset(m,v,sizeof(m))
#define fr(i,n) for(lli i=0;i<n;++i)
#define rep(i,a,b) for(lli i=a;i<=b;++i)
#define per(i,a,b) for(lli i=a;i>=b;i--)
#define remin(a,b) (a=min((a),(b)))
#define remax(a,b) (a=max((a),(b))) 
#define sz(x) (lli)(x).size()
#define endl '\n'
typedef long long lli;        typedef long double ld;
typedef pair<lli,lli> ii;     typedef vector<lli> vi;
typedef vector<ii> vii;       typedef vector<vi> graph;
long long MOD=1000000007;     long double EPS=1e-9;
#define debarr(a,n) cout<<#a<<" : ";for(int i=0;i<n;i++) cerr<<a[i]<<" "; cerr<<endl;
#define debmat(mat,row,col) cout<<#mat<<" :\n";for(int i=0;i<row;i++) {for(int j=0;j<col;j++) cerr<<mat[i][j]<<" ";cerr<<endl;}
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const unordered_set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const unordered_map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const multiset<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
lli binpow(lli b,lli p,lli mod){lli ans=1;b%=mod;for(;p;p>>=1){if(p&1)ans=ans*b%mod;b=b*b%mod;}return ans;}

void pre(){

}

ld dp[3001][3001];

void solve(){
	lli n;
	cin>>n;
	ld p[n];
	fr(i,n)cin>>p[i];
	dp[0][0]=1;
	rep(i,0,n-1){
		rep(j,0,i){
			dp[i+1][j+1]+=p[i]*dp[i][j];
			dp[i+1][j]+=(1-p[i])*dp[i][j];
		}
	}
	ld ans=0;
	rep(i,0,n){
		if(i>n-i){
			ans+=dp[n][i];
		}
	}
	cout<<fixed<<setprecision(15)<<ans<<endl;
}

signed main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("in.txt","r",stdin);//freopen("out.txt","w",stdout);
	pre();lli t=1;//cin>>t;
	for(lli i=1;i<=t;i++){
		//cout<<"Case #"<<i<<": ";
		solve();
	}
}

Measured memory_bytes: 139136
//AtCoder ABC115 A - Christmas Eve Eve Eve
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
int main() {
    ll D; cin>>D;
    if (D==25) cout<<"Christmas"<<endl;
    else if(D==24) cout<<"Christmas Eve"<<endl;
    else if(D==23) cout<<"Christmas Eve Eve"<<endl;
    else if(D==22) cout<<"Christmas Eve Eve Eve"<<endl;
    return 0;
}

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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;

// container util
// -----------------------------------------------------------------------------
#define ALL(c)  (c).begin(),(c).end()
#define SZ(c) ((ll)(c).size())
#define MAX(c) *max_element(ALL(c))
#define MIN(c) *min_element(ALL(c))
#define SORT(c) sort((c).begin(),(c).end())

// repetition
// -----------------------------------------------------------------------------
#define FOR(i, a, b) for(ll i= (a); i < (ll)(b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
// -----------------------------------------------------------------------------
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    string a, b; cin >> a >> b;
    int res = stoi(a + b);
    bool ans = pow(floor(sqrt(res)), 2) == res;
    cout << ((ans) ? "Yes" : "No") << "\n";
}

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

int main(void){
    int n, tmp;
    int ans = 0;
    while(cin >> n && n) {
        vector<int> in;
        rep(i, n) {
            cin >> tmp;
            in.push_back(tmp);
        }
        sort(in.begin(), in.end());
        ans = 0;
        for(int i=1; i<n-1; ++i) ans += in[i];
        cout << ans/(n-2) << endl;
    }
}

Measured memory_bytes: 1220
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>  // sort, 二分探索, etc
#include <iomanip>  // setprecision (浮動小数点の出力の誤差)
#include <map>
#include <queue>
#include <set>
#include <stack>

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=a,i##_len=(b);i<i##_len;++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define cauto const auto&
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

using namespace std;
using ui = unsigned int;
using ll = long long;
using ull = unsigned long long;

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

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

ll comb(int n, int r) {
    vector<vector<ll> > v(n+1, vector<ll>(r+1, 0));
    for(int i=0;i<n+1;i++) {v[i][0]=1; if(i < r+1)v[i][i]=1; }
    for(int i=1;i<n+1;i++) {for(int j=1;j<min(i,r+1);j++) {v[i][j]=v[i-1][j-1]+v[i-1][j];}}
    return v[n][r];
}

// CHAR_MAX  = 127
// INT_MAX   = 2.1e+09 (2147483647)
// LONG_MAX  = 9.2e+18 (9223372036854775807)
// LLONG_MAX = 9.2e+18 (9223372036854775807)


int main() {
    int r;
    cin >> r;

    cout << setprecision(10) << r * 2.0 * 3.14159265358979 << '\n';


    return 0;
}


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

using ll = long long;
using ld = long double;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main(){
    FIN;
    ll n,q;
    cin >> n >> q;
    dsu d(n);
    for(ll i=0;i<q;i++){
        ll t,u,v;
        cin >> t >> u >> v;
        if(t == 0) d.merge(u,v);
        else cout << d.same(u,v) << endl;
    }

    return 0;
}

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



int cd=250000;

int d,c[26],s[366][26];
int t[366];
ll r;

void init(){
    cin>>d;
    REP(i,26)cin>>c[i];
    REP(i,d)REP(j,26)cin>>s[i][j];
}

void greedy(){
    REP(i,d)REP(j,26)t[i]=s[i][j]>s[i][t[i]]?j:t[i];
}

ll score(int *t){
    ll ans=0;vector<int>cnt(26,0);
    REP(i,d){
        cnt[t[i]]=-1;
        ans+=s[i][t[i]];
        REP(j,26)cnt[j]++,ans-=cnt[j]*c[j];
    }
    return ans;
}

void crt_new(){
    int idx=rand()%d;
    int q=rand()%26;
    while(q==t[idx])q=rand()%26;
    int tmp=t[idx];
    t[idx]=q;
    ll res=score(t);
    if(res>r)r=res;
    else t[idx]=tmp;
}

void solve()
{

    init();
    // ll begin_t=clock();
    greedy();
    r=score(t);
    while(cd--)crt_new();
    // REP(i,d)cout<<t[i]<<" ";cout<<endl;
    REP(i,d)cout<<t[i]+1<<endl;
    // cout<<r<<endl;

    // ll end_t=clock();cout<<end_t-begin_t<<"ms"<<endl;
}

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

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

namespace ProjectContest
{
    class Test
    {
        static void Main()
        {
            char[] c = Console.ReadLine().ToCharArray();
            if (c[0] == c[1] || c[1] == c[2] || c[2] == c[3])
                Console.WriteLine("Bad");
            else Console.WriteLine("Good");

        }
    }
}

Measured memory_bytes: 11092
import sys

sys.setrecursionlimit(10**7)

n = int(input())
ls = list(map(int, input().split()))

used = [False] * n
res = []


def f(index):
    for j in range(n):
        for i in reversed(range(index, n)):
            if not used[i] and ls[i] == sum(used[:i]) + 1:
                used[i] = True
                res.append(ls[i])
                f(i)
        if sum(used[index:]) == n - index:
            break


f(0)
if len(res) == n:
    print(*res, sep='\n')
else:
    print(-1)

Measured memory_bytes: 3064
#pragma GCC optimize("03")
#include <bits/stdc++.h>
#define ll long long 
#define fi first
#define se second

using namespace std;


int n, m, x, y;
string sol[100100];
vector <pair <int, int> > v[100100];

void solve(int p, int idx, int cnt) {
	string unu = "";
	string doi = "";
	while (p != 0) {
		int dig = p % 10;
		unu += char(dig + 48);
		p /= 10;
	}
	reverse(unu.begin(), unu.end());
	while (unu.size() < 6) {
		unu = '0' + unu;
	}
	while (cnt != 0) {
		int dig = cnt % 10;
		doi += char(dig + 48);
		cnt /= 10;
	}
	reverse(doi.begin(), doi.end());
	while (doi.size() < 6) {
		doi = '0' + doi;
	}
	sol[idx] = unu + doi;
}

int main() {
	//ifstream cin("tst.in");
	//ofstream out("tst.out");
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cin >> n >> m;
	for (int i = 1; i <= m; i++) {
		cin >> x >> y;
		v[x].push_back({y, i});
	}
	for (int i = 1; i <= n; i++)
		sort(v[i].begin(), v[i].end());
	for (int i = 1; i <= n; i++) {
		int cnt = 0;
		for (auto j : v[i])
			solve(i, j.second, ++cnt);
	}
	for (int i = 1; i <= m; i++)
		cout << sol[i] << '\n';
	return 0;
}

Measured memory_bytes: 12416
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, a[100008], b[100008], outside, ans;

const ll MOD = 1e9+7;
const ll MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];
void choiceinit() {
    fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i-1]*i%MOD;
        inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i] = finv[i-1]*inv[i]%MOD;
    }
}
ll choice(ll allnum, ll choicenum){
    if(allnum < choicenum || allnum < 0 || choicenum < 0) return 0;
    return fac[allnum]*(finv[choicenum]*finv[allnum-choicenum]%MOD)%MOD;
}

int main() {
	cin >> n;
	for(ll i = 1; i <= n+1; i++){cin >> a[i]; b[i] = 0;}
	for(ll i = 1; i <= n+1; i++){
		if(b[a[i]] > 0){outside = (n+1)-(i-b[a[i]]+1); break;}
		else{b[a[i]] = i;}
	}
	choiceinit();
	for(ll i = 1; i  <= n+1; i++){
		ans = choice(n+1, i)-choice(outside, i-1);
		if(ans < 0){ans += MOD;}
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 14720
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <algorithm>
const int mod=1e9+7;
using LL=long long;
using std::cout;using std::endl;using std::cin;
using std::vector;using std::string;using std::set;using std::multiset;
using std::pair;using std::map;
using std::min;using std::max;
using std::make_pair;
std::ostream& operator<<(std::ostream& os,std::map<int,int>& obj){for(std::map<int,int>::iterator itr=obj.begin();itr!=obj.end();itr++){os<<itr->first<<"^"<<itr->second<<" ";}return os;}
std::ostream& operator<<(std::ostream& os,std::vector<std::map<int,int>>& obj){for(auto itr=obj.begin();itr!=obj.end();itr++){os<<*itr<<std::endl;}return os;}
std::ostream& operator<<(std::ostream& os,std::vector<int>& obj){for(auto itr=obj.begin();itr!=obj.end();itr++){os<<*itr<<" ";}return os;}

namespace ndifix{
}

int main(){
  int n,m;cin>>n>>m;
  vector<pair<int,int>> xy(m);for(int i=0;i<m;i++){cin>>xy[i].first>>xy[i].second;xy[i].first--;xy[i].second--;}
  const int red=1000000;
  vector<int> ball(n,1);ball[0]=red+1;

  for(int i=0;i<m;i++){
    if(ball[xy[i].first] < red){ball[xy[i].first]--;ball[xy[i].second]++;}
    else if(ball[xy[i].first]==red+1){ball[xy[i].first]=0;
      if(ball[xy[i].second]<red)ball[xy[i].second]+=red+1;
      else ball[xy[i].second]++;
    }
    else {
      ball[xy[i].first]--;
      if(ball[xy[i].second]<red)ball[xy[i].second]+=red+1;
      else ball[xy[i].second]++;
    }
  }
  int cnt=0;
  for(int i=0;i<n;i++)if(ball[i]>=red)cnt++;
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>
#include <string.h>
int main() {
  char S[100];
  scanf("%s", S);
  
  if (strcmp(S, "Sunny") == 0) {
    printf("Cloudy");
  }
  else if (strcmp(S, "Cloudy") == 0) {
    printf("Rainy");
  }
  else if (strcmp(S, "Rainy") == 0) {
    printf("Sunny");
  }
  
  return 0;
}

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

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

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

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

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

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

signed main() {
  init();
  ll N;
  cin >> N;

  ll ans1 = 0;
  ll ans2 = 0;
  ll current_num1 = 0;
  ll current_num2 = 0;
  rep(i, N) {
    ll a;
    cin >> a;
    current_num1 += a;
    current_num2 += a;
    if (i % 2 == 0) {
      if (current_num1 >= 0) {
        ans1 += abs(current_num1) + 1;
        current_num1 = -1;
      }
      if (current_num2 <= 0) {
        ans2 += abs(current_num2) + 1;
        current_num2 = 1;
      }
    } else {
      if (current_num1 <= 0) {
        ans1 += abs(current_num1) + 1;
        current_num1 = 1;
      }
      if (current_num2 >= 0) {
        ans2 += abs(current_num2) + 1;
        current_num2 = -1;
      }
    }
  }

  ll ans = min(ans1, ans2);
  ANS;

  return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <functional>
#include <map>
#include <math.h>
#include <list>

using namespace std;

int main(void) {

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

	long long int n; cin >> n;
	long long int sum = 0;
	for (int i = 1; i <= n; i++) {
		if (i % 3 && i % 5) sum += i;
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>

int main()
{
	int a[100][100];
	int b[100];
	int n, m;
	scanf("%d %d", &n, &m);
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < m; j++)
		{
			scanf("%d", &a[i][j]);
		}
	}  
	for(int i = 0; i < m; i++)
	{
		scanf("%d", &b[i]);
	}
	int c[100] = {0};
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < m; j++)
		{
			c[i]+= a[i][j]*b[j];
		}
	}
	for(int i = 0; i < n; i++)
	{
		printf("%d\n", c[i]);
	}
	return 0;
}
 


Measured memory_bytes: 2772
//file_name:ABC81_B.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    int n;
    scanf("%d",&n);
    int ans = 99999;
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    rep(i,n){
        int c =0;
        while(a[i]>0){
            if(a[i]%2==0){
                c++;
                a[i]/=2;
            }else{
                break;
            }
        }
        mins(ans,c);
    }




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



Measured memory_bytes: 256
import java.lang.Math

fun main(args: Array<String>)
{
    val n = readLine()!!.toLong()

    var min = Long.MAX_VALUE
    for (i in 1..Math.floor(Math.sqrt(n.toDouble())).toInt()) {
        val r = n % i.toLong()

        if (r == 0L) {
            val can = i.toLong() + n / i.toLong() - 2L
            min = if (min > can) can else min
        }
    }

    println(min)
}


Measured memory_bytes: 31964
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x ,n) for(int i = x; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){
    int w,a,b;
    cin >> w >> a >> b;
    if(abs(a-b)<w){
        cout << 0;
        return 0;
    }
    
    cout << abs(a-b)-w;
    
	return 0;
}

Measured memory_bytes: 3524
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<double, long long> pdl;

const long double pi = 3.141592653589793;

#define debug(x) cerr << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007

ll CS[1<<20];
ll CT[1<<20];

int main() {
  	//freopen("input.in","r",stdin);
  	//freopen("output.out","w",stdout);
	string S, T;
	cin>>S>>T;

	rep(i, S.size()) {
		CS[i+1] = S[i] - 'A' + 1;
		CS[i+1] += CS[i];
	}

	rep(i, T.size()) {
		CT[i+1] = T[i] - 'A' + 1;
		CT[i+1] += CT[i];
	}

	int q, a, b, c, d;cin>>q;
	while (q--) {
		cin>>a>>b>>c>>d;
		if((CS[b]-CS[a-1])%3 == (CT[d]-CT[c-1])%3) {
			std::cout << "YES" << '\n';
		} else {
			std::cout << "NO" << '\n';
		}
	}

	return 0;
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'a' = 97

int main()
{
    int n;
    cin >> n;
    int a[n];
    rep(i, 0, n) cin >> a[i];
    for (int i = n - 1; i >= 1; i--) cout << a[i] << " ";
    cout << a[0] << endl;

}



Measured memory_bytes: 3124
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a=nxt(),b=nxt(),c=nxt();
    if(a+b==c||a+c==b||b+c==a)
        cout<<"Yes\n";
    else
        cout<<"No\n";

    
    return 0;   
}




 
 


Measured memory_bytes: 256
h,w = map(int,input().split())
s=[]
for _ in range(h):
  s.append(str(input()))
for i in range(h):
  for j in range(w):
    flag=False
    if s[i][j]!="#":
      continue
    for k in [-1,1]:
      if 0<=i+k<h:
        if s[i+k][j]=="#":
          flag=True
      if 0<=j+k<w:
        if s[i][j+k]=="#":
          flag=True
    if not flag:
      print("No")
      exit()
print("Yes")

Measured memory_bytes: 3064
from sys import stdin, stdout
import math,sys
from itertools import permutations, combinations
from collections import defaultdict,deque,OrderedDict
import bisect as bi
import heapq 
'''
#------------------PYPY FAst I/o--------------------------------#

def I():return (int(stdin.readline()))
def In():return(map(int,stdin.readline().split()))
'''
#------------------Sublime--------------------------------------#

#sys.stdin=open('input.txt','r');sys.stdout=open('output.txt','w');
def I():return (int(input()))
def In():return(map(int,input().split()))

def find_gt(a, x):
    #'Find leftmost value greater than x'
    i = bi.bisect_right(a, x)
    if i != len(a):
        return i
    else:
        return -1


def main():
    try:
        n=I()
        n=math.pi*n*2
        print(round(n,2))

            
    except:
        pass
M = 998244353
P = 1000000007

if __name__ == '__main__':
    main()


Measured memory_bytes: 9492
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() {
  string S, T;
  cin >> S >> T;
  reverse(S.begin(), S.end());
  reverse(T.begin(), T.end());
  REP(i, S.size() - T.size() + 1) {
    bool b = true;
    REP(j, T.size()) {
      if (S[i + j] == '?') continue;
      if (S[i + j] != T[j]) b = false;
    }
    if (!b) continue;
    string st = S;
    REP(j, T.size()) { st[i + j] = T[j]; }
    REP(j, st.size()) {
      if (st[j] == '?') st[j] = 'a';
    }
    reverse(st.begin(), st.end());
    cout << st << endl;
    return 0;
  }
  cout << "UNRESTORABLE " << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main(){
    cout << fixed << setprecision(8);
    int n;
    while (cin >> n) {
        if (n == 0)
            break;
        double ar[n], al = 0;
        for (int i = 0; i < n; i++) {
            cin >> ar[i];
            al += ar[i];
        }
        al /= n;
        double a = 0;
        for (int i = 0; i < n; i++)
            a += (ar[i] - al) * (ar[i] - al) / n;
        cout << sqrt(a) << '\n';
    }
    return 0;
}



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

#define ran 202202

int n;
int a[ran], b[ran];

int main() {
	scanf("%d", &n);
	for(int i=0;i<n;i++) scanf("%d%d", &a[i], &b[i]);
	sort(a, a+n);
	sort(b, b+n);
	
	int lo = a[n/2], hi = b[n/2];
	if(n%2==0) {
		lo += a[n/2-1];
		hi += b[n/2-1];
	}
	printf("%d\n", hi-lo+1);
	
	return 0;
}

Measured memory_bytes: 5280
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
ll bit[200010], num;
ll n;

ll sum(ll i)
{
	ll s = 0;
	while (i > 0)
	{
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

void add(ll i, ll x)
{
	while (i <= num)
	{
		bit[i] += x;
		i += i & -i;
	}
}

ll po(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2)
	{
		return po(x, y - 1) * x % mod;
	}
	else
	{
		ll yyy = po(x, y / 2);
		return yyy * yyy % mod;
	}
}

ll div(ll x)
{
	return po(x, mod - 2);
}

int main(void)
{
	cin >> n;
	cout << (n - 2) * 180 << endl;
	int www;
	cin >> www;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int a, b, c, k, m, s;
int main() {
	cin>>a>>b>>c>>k;
	m = max(a, max(b,c));
	s = a+b+c - m;
	while(k--) m *= 2;
	cout<<s+m;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <climits>
#define SIZE 100002
#define INF INT_MAX >> 1

using namespace std;

typedef long long ll;

ll dp[101][SIZE];//dp[n][w] := max_value

int main(void){
	ll n, w; cin >> n >> w;
	pair <ll, ll> p[101]; //(w, v)
	for(int i=0; i<n; i++){
		cin >> p[i].first >> p[i].second;
	}

	for(int i=0; i<n; i++){
		for(int j=0; j<=w; j++){
			if(j-p[i].first >= 0){
				dp[i+1][j] = max(dp[i+1][j], dp[i][j-p[i].first] + p[i].second);
			}
			dp[i+1][j] = max(dp[i+1][j], dp[i][j]);

		}
	}

	ll ans = dp[n][w];
	//for(int i=0; i<=w; i++){// <=であることに注意
	//	ans = max(ans, dp[n][i]);
	//}
	cout << ans << endl;
}

Measured memory_bytes: 78336
import math
n = int(input())


a = 1 #aはnの約数の中で大きい奴
b = 1 #bはaと対応する奴（a*b=nの意味）

for i in range(1, math.floor(math.sqrt(n))+1):
  if n % i == 0:
    a = i
b = n // a
print(max([len(list(str(int(a)))), len(list(str(int(b))))]))

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
const int INF = 1e9;

signed main(){
  int N; cin >> N;
  string s; cin >> s;
  int Q; cin >> Q;
  vector<set<int> > alp(26, set<int> {INF});
  for(int i = 0; i < N; i++) alp[s[i] - 'a'].insert(i);
  
  for(int i = 0; i < Q; i++){
    int t; cin >> t;
    if(t == 1){
      int i; char c; cin >> i >> c; --i;
	  if(s[i] != c) alp[s[i] - 'a'].erase(i);
        s[i] = c;
		alp[c - 'a'].insert(i);
    }
    if(t == 2){
      int ans = 0;
      int l, r; cin >> l >> r; --l;
      for(int c = 0; c < 26; c++){
        if(alp[c].empty()) continue;
        if(*alp[c].lower_bound(l) < *alp[c].lower_bound(r)) ans++;
      }
      cout << ans << endl;
    }
  }
}


Measured memory_bytes: 26244
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n,W=map(int,input().split())
    w0,v=map(int,input().split())
    V=[[] for _ in range(4)]
    V[0].append(v)
    for _ in range(n-1):
        w,v=map(int,input().split())
        V[w-w0].append(v)
    for i in range(4):
        V[i].sort(reverse=1)
        for j in range(len(V[i])-1):
            V[i][j+1]+=V[i][j]
    for i in range(4):
        V[i].insert(0,0)

    ans=0
    from itertools import product
    for a,b,c,d in product(range(len(V[0])),range(len(V[1])),range(len(V[2])),range(len(V[3]))):
        v=V[0][a]+V[1][b]+V[2][c]+V[3][d]
        if(a*w0+b*(w0+1)+c*(w0+2)+d*(w0+3)<=W): ans=max(ans,v)
    print(ans)
resolve()

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

using namespace std;
#define ll long long
#define ld long double
#define PI 3.141592653L
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll INF = (ll)1e18;
const int N = 2e6 + 5;
const ll MOD = 998244353;

int parent[N];

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

ll pow(ll x, ll y, ll p) {
    if(y == 0) return 1;
    ll res = 1;
    x %= p;
    if(x == 0) return 0LL;
    while(y > 0) {
        if(y & 1) res = (res*x) % p;
        y >>= 1;
        x = (x*x) % p;
    }
    return res;
}

int find(int x) {
    return x == parent[x] ? x : parent[x] = find(parent[x]);
}

void Union(int x, int y) {
    int xPar = find(x), yPar = find(y);
    if(xPar != yPar) parent[xPar] = yPar;
}

void solve() {
    string a, b;
    cin >> a >> b;
    int n = a.length();
    int res = 0;
    for(int i=0;i<n;i++) {
        if(a[i] != b[i]) res++;
    }
    cout << res << endl;
    return;
}

int main()
{
    IOS
    //int t;
    //cin >> t;
    //while(t--) 
    solve();
    return 0; 
}


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

int main(){
    int N,flag=0;
    cin >> N;
    for(int i=1;i<=9;++i){
        if(flag==1){break;}
        for(int j=i;j<=9;++j){
            if(N==i*j){
                flag=1;
                break;
            }
        }
    }
    if(flag==1){
        cout << "Yes" <<endl;
    }else{
        cout << "No" <<endl;
    }
}


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

bool prime(long long x) {
	if (x <= 1LL) return false;
  	if (x == 2LL) return true;
  	for (long long i = 2LL; i * i <= x; ++i) {
    	if (x % i == 0LL) return false;  
    }
  	return true;
}

int main() {
	long long n; cin >> n;
  	map<long long, long long> m;
  	for (long long i = 1LL; i * i <= n; ++i) {
      	if (prime(i)) {
        	long long nn = n;
          	while (nn % i == 0LL) {
            	++m[i], nn /= i;  
            }
        }
      	if (i != n / i && prime(n / i)) {
        	long long nn = n;
          	while (nn % (n / i) == 0LL) {
            	++m[n/i], nn /= n / i;  
            }
        }
    }
  	set<long long> s;
    for (auto tr : m) {
      	//cout << tr.first << " " << tr.second << endl;
    	long long cr = tr.second, mi = 1LL, po = tr.first;
      	while (cr >= mi) {
        	s.insert(po);
          	cr -= mi++;
          	po *= tr.first;
        }
    }
  	long long ans = 0LL;
	for (long long x : s) {
      	//cout << x << endl;
    	if (n % x == 0LL) {
        	++ans, n /= x;  
        }
    }
  	cout << ans << endl;
  	return 0;
}

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

#define fore(i, a, b) for(int i = a; i < b; i++)
#define forn(i, n) fore(i, 0, n)
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ford(i, n) for(int i = n - 1; i >= 0; i--)

using namespace std;

typedef long long ll;

const int N = 4000006;

int n;
ll v[N];

int main(){

	scanf("%d", &n);

	for(int i = 0; i < n; ++i)
		scanf("%lld", v+i);

	ll a = 2, b = 2, c, d;

	for(int i = n-1; i >= 0; i--){
		a = (a + v[i] - 1) / v[i] * v[i];
		b = b / v[i] * v[i] + v[i] - 1;
	}
	c = a, d = b;

	for(int i = 0; i < n; i++)
		c -= c % v[i], d -= d % v[i];

	if(c != 2 || d != 2) return printf("-1\n"), 0;

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

    return 0;
}


Measured memory_bytes: 1152
#include <stdio.h>
#include <iostream>

using namespace std;

int main(void)
{
  int a,b,c;
  
  cin >> a;
  cin >> b;
  
  c = a*b;
  if ( c%2 == 0 ) {
    cout << "Even";
  } else {
    cout << "Odd";
  }
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for(int i = 0; i < n; i++)  a[i] = (n+1)*(i+1);
    for(int i = 0; i < n; i++)  b[i] = (n+1)*(n-i);
    vector<int> r(n);
    for(int i = 0; i < n; i++){
        int x;  cin >> x;
        r[x-1] = i+1;
    }
    for(int i = 0; i < n; i++)  cout << a[i] << " \n"[i+1==n];
    for(int i = 0; i < n; i++)  cout << b[i]+r[i] << " \n"[i+1==n];
    return 0;
}

Measured memory_bytes: 896
#include<iostream>	// 入出力
#include<stdio.h>	// printf()が使える 小数は%fで
#include<math.h>	// 数学の関数
#include<vector>	// 配列
#include<string>	// 文字列
#include<map>		// 連想配列
#include<stack>		// スタック
#include<queue>		// キュー
#include<algorithm> // ソートとか

using namespace std;

using ll = long long;


int main()
{

	string s;

	cin >> s;

	for(int i=0;i<s.length()-8;++i)
	{
		cout << s[i] << flush;
	}

	cout << endl;

}

Measured memory_bytes: 256
local n, m  = io.read("*n", "*n")
local l, r = 1, n
local mmi, mma = math.min, math.max
for i = 1, m do
  local a, b = io.read("*n", "*n")
  l = mma(l, a)
  r = mmi(r, b)
end
print(mma(0, r - l + 1))


Measured memory_bytes: 888
n = int(input())

d = {}
for _ in range(n):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d[s] = 1

MAX = 0
ans = []
for k, v in d.items():
    if v > MAX:
        ans = [k]
        MAX = v
    elif v == MAX:
        ans.append(k)


ans.sort()
for a in ans:
    print(a)

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

int main(){
	int n;
	string s, t;
	cin >> n >> s >> t;

	for (int i = 0;i < n;i++) {
		bool b = true;
		for (int j = 0;i + j < n;j++) {
			if (s[i + j] != t[j]) {
				b = false;
				break;
			}
		}
		if (b) {
			cout << n + i << endl;
			return 0;
		}
	}
	cout << 2 * n << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <unordered_map>
using namespace std;

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  cout << min(a, b) << " " << max(0, a + b - n) << endl;
}


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

int main(){
    int n,m; cin>>n>>m;
    vector<int> dig(n,-1);
    for(int i=0; i<m; i++){
        int s,c; cin>>s>>c;
        if(n!=1 && s==1 && c==0){
            cout << -1 << endl;
            return 0;
        }
        else{
            if(dig[s-1]==-1) dig[s-1]=c;
            else if(dig[s-1] != c){
                cout << -1 << endl;
                return 0;
            }
        }
    }
    for(int i=0; i<n; i++){
        if(dig[i]==-1 && n!=1 && i==0){
            cout << 1;
        }
        else{
            if(dig[i]==-1) cout << 0;
            else cout << dig[i];
        }
    }
    cout << endl;
}

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

using ll = long long;
using G = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;

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

int main() {
	int n; cin >> n;
	cout << n*n*n << endl;
	return 0;
}

Measured memory_bytes: 256
n,k,s = [list(map(int, s.split())) for s in open(0)][0]

hoge = s + 1
if s == 1e9:
    hoge = 1
ans = [s] * k
if n != k:
    ans += [hoge] * (n-k)
for x in ans:
    print(x, end=" ")

Measured memory_bytes: 4980
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<queue>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)
#define INF 1000000000

int main() {
	int Q;
	string N[101];
	cin >> Q;
	REP(i, 0, Q) cin >> N[i];

	REP(i, 0, Q) {
		int cnt = 0;
		string val = N[i];
		while (1) {
			if (val.size() == 1) {
				cout << cnt << endl;
				break;
			}
			if (cnt > 10000) {
				cout << -1 << endl;
				break;
			}

			int maxi = 0;
			REP(j, 1, val.size()) {
				int l = stoi(val.substr(0, j));
				int r = stoi(val.substr(j));
				maxi = max(maxi, l*r);
			}
			val = to_string(maxi);
			cnt++;
		}
	}

	return 0;
}

Measured memory_bytes: 3232
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
using _loop_int = 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--)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
    int N, tmp;
    float ans=0;
    cin >> N;
    vector<int> v;
    REP(i, N){
        cin >> tmp;
        v.push_back(tmp);
    }
    std::sort(v.begin(), v.end());
    REP(i, N-1){
        ans+=float(v[N-1-i]/std::pow(2, i+1));
    }
    ans += float(v[0]/std::pow(2, N-1));
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
n,m=gets.split.map(&:to_i)
a=[0]*(n+1)
w=[0]*(n+1)
m.times do |i|
  p,s=gets.chomp.split
  p=p.to_i
  if s=="AC"&&a[p]<1
    a[p]=1
  elsif s=="WA"&&a[p]<1
    w[p]+=1
  end
end
(n+1).times do |i|
  if a[i]==0&&w[i]>0
    w[i]=0
  end
end
puts a.inject(:+)
puts w.inject(:+)


Measured memory_bytes: 3324
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N,H = (int(_) for _ in input().split())
    a = []
    b = []
    for i in range(N):
        s1,s2 = (int(_) for _ in input().split())
        a.append(s1)
        b.append(s2)
    a_max = max(a)
    b.sort()
    b = b[::-1]
    ans = 0
    
    i = 0
    while i<N:
        if(b[i]<=a_max):
            break
        if(H<=0):
            break
        ans += 1
        H -= b[i]
        i += 1
    if H>0:
        ans += math.ceil(H/a_max)
    print(ans)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 12388
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<string>
#include<numeric>

#define INF 100000001
using namespace std;
typedef long long ll;

int max6(int a) {
	int b = 1;
	int x = a / 6;
	while (x > 0) {
		b *= 6;
		x /= 6;
	}
	return b;
}
int max9(int a) {
	int b = 1;
	int x = a / 9;
	while (x > 0) {
		b *= 9;
		x /= 9;
	}
	return b;
}

int ans = 0;
int main() {
	int n ;
	cin >> n;
	vector<int> dp(n + 10, 0);
	for (int i = 0; i < 6; i++) {
		dp[i] = i;
	}
	dp[6] = 1;

	for (int i = 7; i < n + 1; i++) {
		int x = max6(i);
		int max6 = i / x;
		dp[i] = dp[i - 1] + 1;
		for (int j = 0; j <= max6; j++) {
			int res = (i - j * x);
			int y = max9(res);
			int min9 = res / y;
			for (int k = 0; k <= min9; k++) {
				dp[i] = min(dp[i], dp[res - k * y] + k + j);
			}
		}
	}

	cout << dp[n];

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back
#define mp make_pair
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<30)
#define LLINF (1<<60)
#define MOD 1000000007
#define rep(i, n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;

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

    int n, a[100005] = {}, c[100005] = {};
    ll ansa = 0, ansb = 0, ans;
    cin >> n;
    for (int i = 0; i < n; i++)cin >> a[i];
    sort(a, a+n);
    if (n % 2 == 0) {
        int t = n / 2;
        c[0] = a[t - 1];
        c[n - 1] = a[t];
        for (int i = 1; i < n - 1; i++) {
            if (i % 2 == 1)c[i] = a[i/2];
            else c[i] = a[t + i / 2];
        }
        for (int i = 0; i < n-1; i++) {
            ansa += abs(c[i] - c[i + 1]);
        }
        for (int i = 1; i < n - 1; i++) {
            if (i % 2 == 1)c[i] = a[t + (i+1) / 2];
            else c[i] = a[(i-1) / 2];
        }
        for (int i = 0; i < n - 1; i++) {
            ansb += abs(c[i] - c[i + 1]);
        }
        ans = max(ansa, ansb);
    }
    else {
        int t = n / 2;
        c[0] = a[t];
        for (int i = 1; i < n; i++) {
            if (i % 2 == 1) c[i] = a[i / 2];
            else c[i] = a[n - i / 2];
        }
        for (int i = 0; i < n - 1; i++) {
            ansa += abs(c[i] - c[i + 1]);
        }
        for (int i = 1; i < n; i++) {
            if (i % 2 == 1) c[i] = a[n - (i+1) / 2];
            else c[i] = a[i / 2 - 1];
        }
        for (int i = 0; i < n - 1; i++) {
            ansb += abs(c[i] - c[i + 1]);
        }
        ans = max(ansa, ansb);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024