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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pll> vp;
typedef vector<ll> vll;

int W, H;
string c[71];
string dp[71][71];

bool inside(int x, int y) {
    return 0 <= x && x < H && 0 <= y && y < W;
}

string maxString(string s, string t) {
    if (s.length() > t.length()) return s;
    if (s.length() < t.length()) return t;
    rep(i, s.length()) {
        if (s[i] > t[i]) return s;
        if (s[i] < t[i]) return t;
    }
    return s;
}


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

    while (cin >> W >> H && W) {
        rep(i, H) cin >> c[i];

        rep(i, H + 1) rep(j, W + 1) dp[i][j] = "";
        string ans = "";
        rep2(i, 1, H + 1) {
            rep2(j, 1, W + 1) {
                int ci = i - 1, cj = j - 1;
                if (!isdigit(c[ci][cj])) continue;
                string maxS = maxString(dp[i - 1][j], dp[i][j - 1]);
                if (maxS == "" && c[ci][cj] == '0') {
                    dp[i][j] = "";
                } else {
                    dp[i][j] = maxS + c[ci][cj];
                    ans = maxString(ans, dp[i][j]);
                }
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3240
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

public class Program {
	public static void Main() {
		new Calc().calc();
	}
	public class Calc {
		public Calc() { }
		public void calc() {
			long[] NM = Console.ReadLine().Split(' ').Select(_ => long.Parse(_)).ToArray();
			long count = NM[0] * 2 > NM[1] ? (NM[1] / 2) : (NM[0] + (NM[1] -NM[0]*2) / 4);
			Console.WriteLine(count);
		}
	}
}

Measured memory_bytes: 13396
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <cassert>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'
#define FIR first
#define SEC second
#define PB push_back
#define SZ(x) ((int)x.size())

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

void solveSingleCase(int caseNo)
{
    int N, X;
    cin >> N >> X;
    if (X == 1 || X == 2 * N - 1) {
        cout << "No" << endl;
        return;
    }

    cout << "Yes" << endl;
    int a = N - 2;
    VEC(int) v, v2;
    FOR(i, 1, 2 * N) {
        if (abs(X - i) > 1)
            if (SZ(v) >= a)
                v2.PB(i);
            else
                v.PB(i);
    }

    reverse(ALL(v2));
    for (int e : v)
        cout << e << endl;
    cout << X - 1 << endl;
    cout << X << endl;
    cout << X + 1 << endl;
    for (int e : v2)
        cout << e << endl;
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int T = 1;
    // cin >> T;
    FOR(tcase, 1, T + 1) {
        solveSingleCase(tcase);
    }
    return 0;
};


Measured memory_bytes: 2424
import math
from fractions import gcd
N, X = map(int,input().split())
x = list(map(int,input().split()))
L = []
for i in range(N):
    y = math.fabs(X-x[i])
    y = int(y)
    L.append(y)
ans = L[0]
for i in range(len(L)):
    ans = gcd(ans,L[i])
print(ans)

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

int D;
long long G;
vector<long long> p, c;

int main() {
  cin >> D >> G;
  p.resize(D); c.resize(D);
  for (int i = 0; i < D; ++i) cin >> p[i] >> c[i];

  long long res = 1<<29;
  for (int bit = 0; bit < (1<<D); ++bit) {
    long long sum = 0;
    long long num = 0;
    for (int i = 0; i < D; ++i) {
      if (bit & (1<<i)) sum += c[i] + p[i] * 100 * (i+1), num += p[i];
    }
    if (sum >= G) res = min(res, num);
    else {
      for (int i = D-1; i >= 0; --i) {
        if (bit & (1<<i)) continue;
        for (int j = 0; j < p[i]; ++j) {
          if (sum >= G) break;
          sum += 100 * (i+1);
          ++num;
        }
      }
      res = min(res, num);
    }
  }
  cout << res << endl;
}


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

int main() {
  int N;
  cin >> N;
  vector<double> x(N);
  vector<string> u(N);
  for (int i=0;i<N;i++) {
    cin >> x.at(i) >> u.at(i);
  }
  
  double sum=0;
  for (int i=0;i<N;i++) {
    if (u.at(i)=="JPY") {
      sum += x.at(i);
    }
    if (u.at(i)=="BTC") {
      sum += 380000.0*x.at(i);
    }
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
  int a, b, t;
  int bisket = 0;
  float time = 0;
  bool flg = true;
  
  std::cin >> a >> b >> t;
  
  while(true) {
    time += (float)a;
    if (time > ((float)t + 0.5)) break;
    
    bisket = bisket + b;
  }
  
  std::cout << bisket << std::endl;
  
  return 0;
}

  

Measured memory_bytes: 256
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
 
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
typedef int64_t ll;
 
#define endl '\n'
#define int ll
ll mod=1e9+7;
ll mod1=1e9+5;
ll power(ll a,ll b)
{
    if(b==0) return 1;
    else if(b%2==0)
        return power((((a%mod)*(a%mod))%mod),b/2)%mod;
    else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
}

int32_t main()
{
    IOS
    
    
    int a;
    cin>>a;
    string s;
    cin>>s;
    if(a>=3200)
    {
        cout<<s;

    }
    else
        cout<<"red";



}



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

char a[10],b[10],c[10];

using namespace std;

int main(void)
{
//    scanf("%c%c%c\n" ,&a[0] ,&a[1] ,&a[2]);
//    scanf("%c%c%c\n" ,&b[0] ,&b[1] ,&b[2]);
//    scanf("%c%c%c\n" ,&c[0] ,&c[1] ,&c[2]);
    cin >> a[0] >> a[1] >> a[2];
    cin >> b[0] >> b[1] >> b[2];
    cin >> c[0] >> c[1] >> c[2];
    cout << a[0] << b[1] << c[2];
    return 0;
}


Measured memory_bytes: 256
[<AbstractClass; Sealed>]
type Math private() =

    static let Module = 1000000007L

    static let rec pownPer (a:int64) n =
        let mutable r = 1L
        for i in 1 .. n do
            r <- (r * a) % Module
        r % Module 

    static member MOD = Module
    static member PownPerMod a n  = pownPer a n


let n = stdin.ReadLine() |> int
let (ans:int64) = (Math.PownPerMod 10L n - Math.PownPerMod 9L n - Math.PownPerMod 9L n + Math.PownPerMod 8L n) % Math.MOD

((ans + Math.MOD)%Math.MOD) |> printfn "%d"



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

using namespace std;

#define pan(i,n) for(int i=0;i<n;i++)
#define pans(i,n,a) for(int i=a;i<n;i++)
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define INF INT_MAX
#define PI 3.141592653
#define inf 1000007
#define pll pair<ll,ll>
#define pii pair<int,int>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

int main(){
    ll n,k,ans;
    cin>>n>>k;
    vl v(n+1),vis(n+1,0),cycle,a;
    pans(i,n+1,1) cin>>v[i];
    int i=v[1],count=0;
    if(k<=n){
        while (k--){
            ans=i;
            i=v[i];
        }
    }
    else{    
        while(count<400000){
            a.pb(i);
            if(vis[i]<2){
                if(vis[i]>=1) cycle.pb(i);
                vis[i]++,count++;
                i=v[i];
            }
            else 
                break;
        }
        count=0;
        // pan(j,6) cout<< a[j]<<endl;
        pan(j,(int)a.size()){
            if(a[j]!=cycle[0]) count++;
            else break;
        }
        k-=count;
        k%=(int)cycle.size();
        // cout<<"count ="<<count<<endl;
        // cout<<"k-1 : "<<k-1<<endl;
        if(k==0) ans=cycle[cycle.size()-1];
        else ans=cycle[k-1];
    }
    cout<<ans;
}

Measured memory_bytes: 12404
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> Pi;
typedef long long ll;
#define pii Pi
#define pll PL
#define Fi first
#define Se second
#define pb(x) push_back(x)
//#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<double, double> pdd;

const double PI = acos(-1);
const double EPS = 1e-9;

const int MX = 1<<18;
const int MM = 1000000007;

const int L = 90;

ll F[105];
vector<pll> GP[L];

int main()
{
	F[0] = F[1] = 1;
	for(int i = 2; i <= L; i++){
		F[i] = F[i-1] + F[i-2];
	}

	GP[1].emplace_back(1, 2);
	GP[1].emplace_back(1, 3);

	for(int t = 2; t <= L; t++){
		for(pll e : GP[t-1]){
			ll a = e.first, b = e.second;
			while(b+a <= F[t+2]){
				a += b;
				GP[t].emplace_back(b, a);
			}
		}
	}

	int Q;
	scanf("%d", &Q);
	for(int t = 1; t <= Q; t++){
		ll X, Y;
		scanf("%lld%lld", &X, &Y);
		if( X > Y ) swap(X, Y);
		if( X == 1 || X == 2 && Y == 2 ){
			printf("1 %lld\n", X*Y%MM);
			continue;
		}
		if( X == 2 ){
			printf("2 %lld\n", (Y-1)/2%MM);
			continue;
		}
		int k = min(upper_bound(F, F+L+1, X) - F, upper_bound(F, F+L+1, Y) - F-1) - 1;
		ll ans = 0;
		auto f = [&](ll X, ll Y){
			for(pll e : GP[k-1]){
				if( e.second <= X ){
					ans = (ans + (Y - e.first) / e.second) % MM;
				}
			}
		};
		f(X, Y); f(Y, X);
		printf("%d %lld\n", k, ans);
	}
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
typedef long long ll;
const int INF = 1000000000;
const long INF64 = 1000000000000000ll;
const int MOD = 1000000007;


int main(){
	int n;
	std::cin >> n;
	string s;
	std::cin >> s;
	int counter=0,ans=0;
	rep(i,n){
	if(s[i]=='I')counter++;
	else counter--;
	if(counter>ans)ans=counter;
	}
	std::cout << ans << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[110],ans=0;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%d",&a[i]);
	for(int i=1;i<=n;i+=2)
		if(a[i]%2==1)
			ans++;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 3732
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int N;
	cin >> N;
	if (N % 10 == N / 100) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
using namespace std;
 
 
int main(){
    int debt = 100000,n;
    scanf("%d",&n);
 
    for(int i=0;i<n;i++){
        debt=(debt/100)*105;
        if((debt%1000)>0){
            debt+=(1000-(debt%1000));
        }
    }
 
    printf("%d\n",debt);
 
    return 0;
}


Measured memory_bytes: 2580
import sys
input = sys.stdin.readline
N = int(input())
LR = [tuple(map(int,input().split())) for i in range(N)]

ltor = {}
rtol = {}
l_dup = set()
r_dup = set()
ans = 0
for i,(l,r) in enumerate(LR):
    ans = max(ans, r-l+1)
    if l in ltor:
        ltor[l] = min(r, ltor[l])
        l_dup.add(l)
    else:
        ltor[l] = r
    if r in rtol:
        rtol[r] = max(l, rtol[r])
        r_dup.add(r)
    else:
        rtol[r] = l
ls = list(ltor.keys())
ls.sort()
rs = list(rtol.keys())
rs.sort(reverse=True)

if ls[-1] <= rs[-1]:
    for l,r in LR:
        maxl = ls[-1] if l!=ls[-1] or l in l_dup else ls[-2]
        minr = rs[-1] if r!=rs[-1] or r in r_dup else rs[-2]
        ans = max(ans, r-l+1 + minr-maxl+1)

ll_ans = [0]
minr = 10**9+10
for l in ls:
    r = ltor[l]
    minr = min(r, minr)
    ll_ans.append(max(0, minr - l + 1))

lr_ans = [0]
maxl = 0
minr = 10**9+10
for l in reversed(ls):
    r = ltor[l]
    minr = min(r, minr)
    maxl = max(l, maxl)
    lr_ans.append(max(0, minr - maxl + 1))
lr_ans.reverse()

rr_ans = [0]
maxl = -10
for r in rs:
    l = rtol[r]
    maxl = max(l, maxl)
    rr_ans.append(max(0, r - maxl + 1))

rl_ans = [0]
minr = 10**9
maxl = -10
for r in reversed(rs):
    l = rtol[r]
    maxl = max(l, maxl)
    minr = min(r, minr)
    rl_ans.append(max(0, minr - maxl + 1))
rl_ans.reverse()

for l,r in list(zip(ll_ans, lr_ans))[1:-1]:
    ans = max(ans, l+r)
for l,r in list(zip(rl_ans, rr_ans))[1:-1]:
    ans = max(ans, l+r)

print(ans)

Measured memory_bytes: 54896
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

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

  if(N==1){
    cout << "Hello World" << endl;
  }
  else if(N==2){
    int A,B;
    cin >> A >> B;
    cout << A+B << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int amount,sum=0,a;
	while(1){
	cin>>amount;
	if(amount==0){
		break;
	}
	for(int i=0;i<9;++i){
		cin>>a;
		sum+=a;
	}
	cout<<amount-sum<<endl;
	sum=0;
	}
	return 0;
}

Measured memory_bytes: 3048
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k=0;
    char s[101], t[101];
    cin>>n;
    cin>>s>>t;
    for(int i =0; i<n; i++)
    {
        cout<<s[i]<<t[i];
    }
    return 0;
}


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

long long n, m, k;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> m >> k;

    for(int i=0; i<=n; i++) {
        for(int j=0; j<=m; j++) {
            long long cnt = i*m+j*n-2*i*j;
            if(cnt==k) {
                cout << "Yes" << '\n';
                return 0;
            }
        }
    }
    cout << "No" << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){

int a,b,d,r;

double f;

d=0,r=0,f=0.0;

scanf("%d",&a);

scanf("%d",&b);


d=a/b;

r=a%b;

f=(double)a/b;

printf("%d %d %lf\n",d,r,f);

return 0;

}

Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);

    ll n;
    cin>>n;
    ll a[n];
    ll sum[n+1]={};
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum[i+1] = sum[i] + a[i];
    }
    ll ans = 1e18;
    for(int m=2;m<n-1;m++){
        int l=1,rr=m;
        while(rr-l>1){
            int mid = (l+rr)/2;
            if(sum[mid]>sum[m]/2){
                rr=mid;
            }
            else l=mid;
        }

        int d=m+1,u=n;
        while(u-d>1){
            int mid = (u+d)/2;
            if(sum[mid]-sum[m]>(sum[n]-sum[m])/2){
                u=mid;
            }
            else d=mid;
        }
        ll p=sum[l],q=sum[m]-sum[l];
        ll r=sum[d]-sum[m],s=sum[n]-sum[d];
        ll dif = max(max(p,q),max(r,s)) - min(min(p,q),min(r,s));
        ans = min(ans,dif);
        if(l!=m-1){
            l++;
            p=sum[l],q=sum[m]-sum[l];
            r=sum[d]-sum[m],s=sum[n]-sum[d];
            dif = max(max(p,q),max(r,s)) - min(min(p,q),min(r,s));
            ans = min(ans,dif);
            l--;
        }
        if(d!=n-1){
            d++;
            p=sum[l],q=sum[m]-sum[l];
            r=sum[d]-sum[m],s=sum[n]-sum[d];
            dif = max(max(p,q),max(r,s)) - min(min(p,q),min(r,s));
            ans = min(ans,dif);
            d--;
        }
        if(l!=m-1 && d!=n-1){
            d++,l++;
            p=sum[l],q=sum[m]-sum[l];
            r=sum[d]-sum[m],s=sum[n]-sum[d];
            dif = max(max(p,q),max(r,s)) - min(min(p,q),min(r,s));
            ans = min(ans,dif);
            
        }

        //cerr<<l<<" "<<m<<" "<<d<<" "<<dif<<endl;
    }
    cout << ans << endl;
    

 
    
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e19;
const int MOD = 998244353;

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

    vector<int> w(n+1), b(n+1);
    REP(i, n)
    {
        w[i+1] = w[i] + (s[i] == '.' ? 1 : 0);
        b[i+1] = b[i] + (s[i] == '#' ? 1 : 0);
    }

    int a = INF;
    REP(i, n+1)
    {
        a = min(a, b[i] + w[n] - w[i]);
    }
    cout << a << endl;

}

Measured memory_bytes: 2704
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define rrep(i,n) for (int i = (n - 1);i >= 0;i--)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;

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

    string s,t;
    cin >> s >> t;
    cout << t + s << endl;
}

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

long solve(int* weights, int* values, int n, int W, int index, long** dp){
    if(index==n-1){
        if(W>=weights[index]){
            return values[index];
        }else{
            return 0;
        }
    }
    if(index>=n){
        return 0;
    }
    if(W<=0){
        return 0;
    }
    if(dp[index][W]!=-1){
        return dp[index][W];
    }

    //without including this weight
    long ans1=solve(weights, values, n, W, index+1, dp);

    //including this weight
    long ans2=0;
    if(W-weights[index]>=0)
        ans2=values[index]+solve(weights, values, n, W-weights[index], index+1, dp);

    long res=max(ans1, ans2);
    dp[index][W]=res;
    return res;
}

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

    int W;
    cin>>W;

    int* weights=new int[n];
    int* values=new int[n];

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

    long** dp=new long*[n+1];
    for(int i=0; i<=n; i++){
        dp[i]=new long[W+1];
    }
    for(int i=0; i<=n; i++){
        for(int j=0; j<=W; j++){
            dp[i][j]=-1;
        }
    }

    long maxprofit=solve(weights, values, n, W, 0, dp);
    cout<<maxprofit<<endl;


}

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

int main() {
    int n;
    cin >> n;
    vector<int> s(n);
    vector<int> notTen;
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
        if (s[i] % 10 != 0) notTen.emplace_back(s[i]);
    }
    if (notTen.empty()) cout << 0 << endl;
    else {
        if (accumulate(s.begin(), s.end(), 0) % 10 == 0) cout << accumulate(s.begin(), s.end(), 0) - *min_element(notTen.begin(), notTen.end()) << endl;
        else cout << accumulate(s.begin(), s.end(), 0) << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) {
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

int main() {
  ll MOD = 2019;
  ll ans = 2019;
  ll L, R; cin>>L>>R;
  if(R-L<3000)  {
    for(ll i = L; i <= R; i++) {
      for(ll j = i+1; j <= R; j++) {
	ll tmp = (i * j) % MOD;
	ans = min(ans, tmp);
      }
    }
  } else {
    ans	= 0;
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 888
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    ll x;
    vector<ll> a(3, -1);
    ll ans = 1;
    for(int i=0;i<n;i++){
    	cin >> x;
    	ll ret = 0;
    	for(int j=0;j<3;j++) if(a[j] == x - 1) ret++;
    	ans *= ret;
        for(int j = 0;j<3;j++) {
        	if(a[j] == x - 1) {
        		a[j]++;
        		j = 1919;
        	}
        }
        ans %= mod;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3548
#include <stdio.h>          // printf(), scanf()
#include <stdlib.h>         // abs()
#include <string.h>         // memset()
#include <stdbool.h>

#define MAX_N 15
#define MAX_S (1 << MAX_N)

const double INF = 1e10;

int n;
int s[MAX_N], l[MAX_N], v[MAX_N];
double dp[MAX_N][MAX_S];
int w[MAX_N][MAX_S];
short prev[MAX_N][MAX_S][2];
int ord[MAX_N];

int
main(int argc, char **argv)
{
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
		scanf("%d%d%d", &s[i], &l[i], &v[i]);

	memset(prev, -1, sizeof(prev));
	int S = 1;
	for (int i = 0; i < n; i++, S <<= 1)
		w[i][S] = v[i];

	int e = 1 << n;
	for (int k = 0; k < e; ++k)
	{
		S = 1;
		for (int i = 0; i < n; ++i, S <<= 1)
		{
			if (k & S)
				continue;

			int t = k | S;
			for (int j = 0; j < n; ++j)
			{
				if (i == j || w[j][k] == 0)
					continue;

				int d = abs(l[i] - l[j]);
				double x = dp[j][k] + (d * (70 + 20.0 * w[j][k])) / 2000.0;
				if (dp[i][t] == 0 || x < dp[i][t])
				{
					dp[i][t] = x;
					w[i][t] = w[j][k] + v[i];
					prev[i][t][0] = j;
					prev[i][t][1] = k;
				}
			}
		}
	}

	double min = INF;
	int u = 0;
	for (int i = 0; i < n; ++i)
	{
		double y = dp[i][e - 1];
		if (y == 0)
			continue;

		if (y < min)
		{
			min = y;
			u = i;
		}
	}

	ord[0] = u;
	int v = e - 1;
	for (int k = 1; k < n; ++k)
	{
		ord[k] = prev[u][v][0];
		v = prev[u][v][1];
		u = ord[k];
	}

	for (int i = n - 1; i >= 0; --i)
		printf("%d%c", s[ord[i]], (i != 0) ? ' ' : '\n');

	return 0;
}

Measured memory_bytes: 8688
N = int(input())
ab = [[int(_) for _ in input().split()] for n in range(N - 1)]

ns = [[] for _ in range(N + 1)]

for a, b in ab:
    ns[a].append(b)
    ns[b].append(a)

from heapq import *

queue = []
heappush(queue, (0, 1))
heappush(queue, (1, N))

counts = [0, 0]

while queue:
    i, index = heappop(queue)
    if ns[index]:
        counts[i % 2] += 1
        for t in ns[index]:
            if ns[t]:
                heappush(queue, (i + 2, t))
    ns[index] = None

if counts[0] > counts[1]:
    print("Fennec")
else:
    print("Snuke")


Measured memory_bytes: 33060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;
  cin >> N >> M;
  vector<int> v_a(M);
  vector<int> v_b(M);
  vector<int> ans(N);
  for(int i=0;i<M;i++){
    cin >> v_a.at(i);
    cin >> v_b.at(i);
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      if(v_a.at(j)==i+1){
        ans.at(i) += 1;
      }
      if(v_b.at(j)==i+1){
        ans.at(i) += 1;
      }
    }
  }
  for(int i=0;i<N;i++){
    cout << ans.at(i) << endl;
  }
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> V(N);
  for (int i = 0; i < N; i++) 
    cin >> V.at(i);
  
  vector<int> W(N,200000);
  W.at(0) = 0;
  
  for (int j = 1; j < N; j++) {
    W.at(j) = W.at(j - 1) + abs(V.at(j) - V.at(j - 1));
    if (j > 1 && W.at(j - 2) + abs(V.at(j) - V.at(j - 2)) < W.at(j))
      W.at(j) = W.at(j - 2) + abs(V.at(j) - V.at(j - 2));
  }
  
  cout << W.at(N - 1) << endl;
                              
}


Measured memory_bytes: 4024
# 最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


# 最小公倍数
def lcm(a, b):
    return a * b // gcd(a, b)


def main():
    n = int(input())
    a = list(map(int, input().split()))
    x = 1
    for i in a:
        x = lcm(x, i)
    x -= 1
    ans = 0
    for i in a:
        ans += x % i
    print(ans)


main()


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

l=[input() for i in range(n)]

x=l.count("AC")
y=l.count("WA")
z=l.count("TLE")
zz=l.count("RE")

print("AC x "+str(x))
print("WA x "+str(y))
print("TLE x "+str(z))
print("RE x "+str(zz))



Measured memory_bytes: 16292
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>


int main() {
	int a, b, k; std::cin >> k >> a >> b;
	std::cout << ((b / k * k) >= a ? "OK\n" : "NG\n");
}

Measured memory_bytes: 3620
N,M,C = map(int,input().split())
B = list(map(int,input().split()))
cnt = 0
for _ in range(N):
  A = list(map(int,input().split()))
  if sum([a*b for a,b in zip(A,B)]) + C > 0:
    cnt += 1
print(cnt)

Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

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

ll solve(ll n) {
  ll ret = 0;
  ll cap = n - (n&3);
  for(ll i = n; i >= cap; i--) {
    ret ^= i;
  }
  return ret;
}

void solve() {
  ll a, b;
  cin >> a >> b;
  cout << (solve(b) ^ solve(a-1)) << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  /*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
  */
}


Measured memory_bytes: 256
// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv
#include <bits/stdc++.h>
using namespace std; using ll = long long; using P = pair<ll, ll>;
const ll linf = 1e18; const double eps = 1e-12, pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define each(i,a) for (auto&& i : a)
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
#define min(x,y) (x < y ? x : y)
#define max(x,y) (x < y ? y : x)
template<typename Head> void out(Head h) { cout << h << endl; } template<typename Head, typename... Tail>void out(Head h, Tail... t) { cout << h << " "; out(t...); }
template<typename T> istream& operator>>(istream& is, vector<T>& v) { each(x,v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
ostream& operator<<(ostream& os, const vector<string>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
struct yes_no : std::numpunct<char> { string_type do_truename() const { return "YES"; } string_type do_falsename() const { return "NO"; } };
void solve(); int main() {
  ios::sync_with_stdio(false); cin.tie(0); locale loc(locale(), new yes_no); cout.imbue(loc); cout << fixed << setprecision(10) << boolalpha;
  solve();
}
// ^^^^^^^^^^^^ TEMPLATE ^^^^^^^^^^^^

void solve() {
  ll n, C, K; cin >> n >> C >> K;
  vector<ll> T(n); cin >> T;
  sort(all(T));
  ll ans = 0;
  ll pos = 0;
  while (pos < n) {
    ll cnt = 0;
    ll npos = pos;
    while (npos < n && T[npos] <= T[pos] + K && npos < pos + C) {
      ++npos;
    }
    ++ans;
    assert(npos > pos);
    pos = npos;
    // cout << pos << endl;
  }
  cout << ans << endl;
}


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

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

const int INF = 1e9;
const int mod = 1e9+7;

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

    ll sub = 0,ans = 0;
    int x[n];
    cin >> x[0];
    for(int i = 1; i < n; i++){
        cin >> x[i];
        if(x[i]-x[i-1] >= t){
            ans += sub + t;
            sub = 0;
        }else{
            sub += x[i] - x[i-1];
        }
    }
    cout << ans + sub + t << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int A, B;
	cin >> A >> B;
	if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) {
		cout << "Possible" << endl;
	}
	else {
		cout << "Impossible" << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793

int main(){
  int n,m;
  cin >> n >> m;
  int d=n-m;
  vector<vector<char>> a(n,vector<char>(n));
  vector<vector<char>> b(m,vector<char>(m));
  rep(i,n){
      rep(j,n){
          cin >> a.at(i).at(j);
      }
  }
  rep(i,m){
      rep(j,m){
          cin >> b.at(i).at(j);    
      }
  }
  bool e=false;
  rep(k,d+1){
      rep(l,d+1){
          bool c=true;
          rep(i,m){
              rep(j,m){
                  if(a.at(k+i).at(l+j)!=b.at(i).at(j)){
                      c=false;
                      break;
                  }
              }
              if(c==false)break;
          }
        if(c){
            e=true;
            break;
        }
      }
      if(e)break;
  }
    if(e)cout << "Yes" << endl;
    else cout << "No" << endl;
}



Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  
  int n, k;

  cin >> n >> k;

  if(n % k){
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }

  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#include <string>
using namespace std;
 
long long int search(string s1,long long int presum){
	int i;
  	long long int k,sum;
  	sum = 0;
  	for (i=1;i<=s1.size();i++){
      	std::string s2 = s1.substr(0,i);
      	std::string s3 = s1.substr(i);
      	if (s3==""){
        	s3 = "B";
        }
      	if(i == s1.size()){
        	sum += stoll(s1)+presum;
        }else{
            k = stoll(s2);
            if (s3=="B"){
            	sum += k + presum;
            }else{
            	sum += search(s3,k + presum);
            }
        }
    }
  	return sum;
}
int main(void){
	long long int sum;
  	std::string s;
  	cin >> s;
  	sum = search(s,0);
  	cout << sum;
  	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#include <cassert>
#include <list>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define Cout(x) cout << x << endl;
#define check(v) rep(i,v.size()) cout << v[i] << endl;
#define vint(x) vector<int> x
#define vll(x) vector<long long> x
#define vstr(x) vector<string> x
const long long LLINF = 1LL<<60;
const int INF = 1e9;
const long long MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
#define pint pair<int,int>
#define pll pair<ll,ll>
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

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

    string s; cin >> s;
    int q; cin >> q;
    list<char> V;
    rep(i,s.size()) V.push_back(s[i]);

    int flag = 1;
    rep(i,q) {
        int t; cin >> t;
        if(t==2) {
            int f; cin >> f;
            char c; cin >> c;
            if(flag) {
                if(f==1) V.insert(V.begin(),c);
                else V.push_back(c);
            }
            else {
                if(f==2) V.insert(V.begin(),c);
                else V.push_back(c);
            }
        }
        else {
            flag ^= 1;
        }
    }

    if(!flag) {
        reverse(ALL(V));
    }
    for(auto val : V) cout << val;
    cout << endl;

    return 0;
}

Measured memory_bytes: 10064
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  // ll n;
  // cin >> n;
  // ll n, m;
  // cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  char a[51], b[51];
  cin >> a >> b;
  int sa = strlen(a), sb = strlen(b);
  for(int i = sa - 1; i >= sb - 1; --i) {
    int ok = 1;
    fj(0, sb) {
      int ix = i - sb + j + 1;
      if(a[ix] != b[j] && a[ix] != '?') {
        ok = 0;
        break;
      }
    }
    if(ok) {
      fj(0, sb) {
        int ix = i - sb + j + 1;
        a[ix] = b[j];
      }
      fj(0, sa + 1) {
        if(a[j] == '?')
          a[j] = 'a';
      }
      cout << a << endl;  
      return 0;
      
    }
  }
  cout << "UNRESTORABLE\n";
  // cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <map>
#include <list>
#include <vector>
#include <string>
#include <stack>
#include <limits>
#include <climits>
#include <cassert>
#include <fstream>
#include <cstring>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <ciso646>
#include <set>
#include <array>

using namespace std;

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

#define inf 0x3f3f3f3f
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 2*acos(0.0)
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE()freopen("out0.txt","w",stdout)
#define ll long long
#define ull unsigned long long
#define eps 1e-14
#define FST first
#define SEC second
#define SETUP cin.tie(0), ios::sync_with_stdio(false), cout << setprecision(15)

namespace {
	struct input_returnner {
		int N; input_returnner(int N_ = 0) :N(N_) {}
		template<typename T> operator vector<T>() const { vector<T> res(N); for (auto &a : res) cin >> a; return std::move(res); }
		template<typename T> operator T() const { T res; cin >> res; return res; }
		template<typename T> T operator - (T right) { return T(input_returnner()) - right; }
		template<typename T> T operator + (T right) { return T(input_returnner()) + right; }
		template<typename T> T operator * (T right) { return T(input_returnner()) * right; }
		template<typename T> T operator / (T right) { return T(input_returnner()) / right; }
		template<typename T> T operator << (T right) { return T(input_returnner()) << right; }
		template<typename T> T operator >> (T right) { return T(input_returnner()) >> right; }
	};
	template<typename T> input_returnner in() { return in<T>(); }
	input_returnner in() { return input_returnner(); }
	input_returnner in(int N) { return std::move(input_returnner(N)); }
}

void solve();
/// ---template---

signed main(void) {
	SETUP;
	solve();
	return 0;
}

void solve() {
	int N = in();
	string s, t; cin >> s >> t;
	int cnt = 0;
	REP(j, N) {
		bool ok = true;
		REP(i, N-j) {
			if (s[j + i] != t[i]) {
				ok = false;
				break;
			}
		}
		if (ok) {
			cout << j*2+(N-j) << endl;
			return;
		}
	}
	cout << N * 2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0);
#define fio freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define dsc [](int a,int b)->bool {return a>b;}
#define pb push_back
#define test int t; cin>>t;
#define MOD 1000000007LL
#define all(x) (x).begin(),(x).end()

using namespace std;

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

int main()
{
    #ifndef ONLINE_JUDGE
        fio
    #endif
    IOS

    ll n = nxt();
    ll ALL = 1;
    for(int i = 0; i<n; i++){
        ALL = ((ALL%MOD)*10)%MOD;
    }
    ll NO_ZERO = 1;
    for(int i = 0; i<n; i++){
        NO_ZERO = ((NO_ZERO%MOD) * 9)%MOD;
    }
    ll NO_90 = 1;
    for(int i = 0; i<n; i++){
        NO_90 = ((NO_90%MOD)*8)%MOD;
    }

    cout<<((ALL%MOD) - (NO_ZERO%MOD) - (NO_ZERO)%MOD + (NO_90%MOD) + MOD + MOD + MOD)%MOD<<endl;

    return 0;
}


Measured memory_bytes: 3592
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));

console.log(main());
function main(){
  var a = o.a();
  var b = o.a();
  if(b % a)return b - a;
  else return a + b;
}

Measured memory_bytes: 21064
S = input()
N = len(S)

MOD = 10 ** 9 + 7

def nLeftA(S, A):
    """(S[:i]の'A'の選び方, S[:i]の'?'の埋め方)"""
    l = [(0, 1)]
    for s in S:
        a, q = l[-1]
        if s == A:
            a = q + a      # S[i-1]を選ぶ + S[:i]のどれかを選ぶ
        elif s == '?':
            a = q + a * 3  # S[i-1]を選ぶ + S[:i]のどれかを選ぶ(?に3通り)
            q = q * 3
        l.append((a % MOD, q % MOD))
    return l

l = nLeftA(S, 'A')
r = nLeftA(reversed(S), 'C')
r.reverse()
r = r[1:]

n = 0
for i in range(N):
    if S[i] in 'B?':
        n += l[i][0] * r[i][0] % MOD

print(n % MOD)


Measured memory_bytes: 30964
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int n; cin >> n;
	int count = 0;
	int arr[30];
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	for (int i = 1; i < n - 1; i++) {
		if ((arr[i - 1] > arr[i] && arr[i] > arr[i + 1]) || (arr[i - 1] < arr[i] && arr[i] < arr[i + 1])) {
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
package main

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

const mod int = 1e9 + 7

var memo [][]int

func main() {
	nextReader = newScanner()
	n, k := nextInt(), nextInt()

	initComb(n)
	for i := 1; i <= k; i++ {
		fmt.Println(comb(n-k+1, i) * comb(k-1, i-1) % mod)
	}
}

func initComb(n int) {
	memo = make([][]int, n+1)
	for i := range memo {
		memo[i] = make([]int, n+1)
		memo[i][0] = 1
	}
	for i := 1; i < n+1; i++ {
		for j := 1; j <= i; j++ {
			memo[i][j] = (memo[i-1][j-1] + memo[i-1][j]) % mod
		}
	}
}

func comb(x, y int) int {
	if x < y {
		return 0
	}
	return memo[x][y]
}

// ---------------------------------------------------------------
// I/O
// ---------------------------------------------------------------
var nextReader func() string

func newScanner() func() string {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 1024), int(1e11))
	sc.Split(bufio.ScanWords)
	return func() string {
		sc.Scan()
		return sc.Text()
	}
}

func nextInt() int { n, _ := strconv.Atoi(nextReader()); return n }

Measured memory_bytes: 21760
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> ipair;
typedef tuple<int, int, int> ituple;

// const ll INF = LLONG_MAX;
// const int MOD = (int)1e9 + 7;
// const double EPS = 1e-10;
#define PI acosl(-1)
#define MAX_N 100 + 2

void exec(){
  int n, m;
  cin >> n >> m;
  cout << (n-1) * (m-1) << endl;

}

void solve(){
  int t = 1;
  // scanf("%d", &t);
  for (int i = 0; i < t; i++){
    exec();
  }
}

int main(){
  solve();
  return 0;
}


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

using namespace std;

void Trace(int A[], int N){
    for(int i=0;i<N;++i){
        if(i>0) cout << " ";
        cout << A[i];
    }
    cout << endl;
}

int BubbleSort(int A[],int N){
    int sw=0;
    bool flag = 1;
    for(int i=0;flag;++i){
        flag = 0;
        for(int j=N-1;j>=i+1;--j){
            if(A[j]<A[j-1]){
                swap(A[j], A[j-1]);
                flag = 1;
                sw++;
            }
        }
    }
    return sw;
}

int main(){
    int N,sw;
    cin >> N;
    int A[N];
    for (int i = 0; i < N; ++i)
        cin >> A[i];
    sw = BubbleSort(A, N);
    Trace(A, N);
    cout << sw << endl;

    return 0;

}


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


int main(int argc, char const *argv[])
{
	int n; cin >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	vector<ll> b(n + 1, 0);
	rep(i, n) b[i + 1] += a[i] + b[i];

	vector<int> left(n, 0);
	for (int i = 2; i <= n - 2; ++i) {
		ll sum = b[i] - b[0];
		// printf("i %d sum %lld\n", i, sum);
		int idx = left[i - 1];
		while(b[idx] - b[0] < sum / 2) idx++;
		if (abs(sum/2 - (b[idx - 1] - b[0])) < abs(sum/2 - (b[idx] - b[0]))) left[i] = idx - 1;
		else left[i] = idx;
		// printf("idx %d\n", idx);
	}
	// printf("\n");
	vector<int> right(n, n);
	for (int i = n - 2; i >= 2; --i) {
		ll sum = b[n] - b[i];
		// printf("i %d sum %lld\n", i, sum);
		int idx = right[i + 1];
		while(b[n] - b[idx] < sum / 2) idx--;
		if (abs(sum/2 - (b[n] - b[idx + 1])) < abs(sum/2 - (b[n] - b[idx]))) right[i] = idx + 1;
		else right[i] = idx;
		// printf("idx %d\n", idx);
	}

/*
	printf("left\n");
	rep(i, n) printf("%d ", left[i]);
	printf("\n");
	printf("right\n");
	rep(i, n) printf("%d ", right[i]);
	printf("\n");
*/

	ll ans = 1e18;
	for (int i = 2; i <= n - 2; ++i) {
		ll l1 = b[left[i]] - b[0];
		ll l2 = (b[i] - b[0]) - l1;
		ll r1 = b[right[i]] - b[i];
		ll r2 = (b[n] - b[i]) - r1;
		// printf("%lld %lld %lld %lld\n", l1, l2, r1, r2);
		ans = min(ans, max<ll>({l1, l2, r1, r2}) - min<ll>({l1, l2, r1, r2}));
	}

	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 4992