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

int main() {
    long long N, A, B;
    long long out;
    cin >> N >> A >> B;
    if(A > B) {
        out = 0;
    } else if(N == 1) {
        out = (A == B) ? 1 : 0;
    } else {
        out = (N - 2) * (B - A) + 1;
    }
    cout << out << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;


int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
ll a[10100];
int main() {
	int N;
	cin >> N;
	ll ans = 0;
	REP(i, N) {
		ll c;
		cin >> c;
		while (c % 2 == 0) {
			ans++;
			c /= 2;
		}
	}
	cout << ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,x;
  cin >> n >> x;
  vector<int> l(n);
  for(int i = 0;i<n;i++) cin >> l[i];
  int ans = 1;
  int p = 0;
  for(int i = 0;i<n;i++){
    p += l[i];
    if(p <= x) ans++;
  }
  cout << ans << endl; 
}


Measured memory_bytes: 256
//lamia 2k19
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
#define ll          long long int
#define T           long long int t;scanf("%lld",&t);while(t--)
#define CS          cout<<"Case "<<cs++<<": "
#define nd          endl
#define dd          double
#define ss          string
#define Y           cout<<"YES"<<endl
#define N           cout<<"NO"<<endl
#define for0(i,n)   for( i=0;i<n;i++)
#define forn(n,i)   for( i=n-1;i>=0;i--)
deque<ll>dq;
vector<ll>v;
map<ll,ll>m;

int main()
{
	long long int n,a;
	cin>>n;
	cin>>a;
	ll gcd=a;
	n--;
    while(n--)
    {
        cin>>a;
        gcd=__gcd(gcd,a);
        
    }
    cout<<gcd<<nd;
	return 0;
}



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

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

  int n;
  cin >> n;
  if (n % 2) {
    cout << n * 2 << "\n";
  } else {
    cout << n << "\n";
  }
}


Measured memory_bytes: 384
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		for(int i = 1; i <= n; i++) {
			if(i%3 == 0) {
				System.out.print(" " + i);
			}else {
				int x = i;
				while(x >= 1) {
					if(x%10 == 3) {
						System.out.print(" " + i);
						break;
					}
					x /= 10;
				}
			}
		}
		System.out.println();
	}
}



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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll n;
  cin>>n;
  vll a(n*3);
  REP(i,n*3)cin>>a[i];

  priority_queue<ll,vll,greater<ll>> ql;
  priority_queue<ll> qr;
  ll lsum=0;
  ll rsum=0;
  REP(i,n){
    ql.push(a[i]);
    lsum += a[i];
  }
  REP(i,n){
    qr.push(a[i+2*n]);
    rsum+=a[i+2*n];
  }

  ll sum=lsum;
  vll s(n+1);
  s[0]+=lsum;
  REP(i,n){
    ll p=ql.top();
    ql.push(a[i+n]);
    ql.pop();
    sum+=a[i+n];
    sum-=min(p,a[i+n]);

    s[i+1]+=sum;
  }

  sum=rsum;
  //cout<<s[n]<<":"<<sum<<endl;
  s[n]-=rsum;
  ll ans=s[n];
  REP(i,n){
    ll p=qr.top();
    qr.push(a[2*n-1-i]);
    qr.pop();
    sum+=a[2*n-1-i];
    sum-=max(a[2*n-1-i],p);

    //cout<<s[n-1-i]<<":"<<sum<<endl;
    s[n-1-i]-=sum;
    ans = max(s[n-1-i], ans);
  }

  cout<<ans<<endl;


}


Measured memory_bytes: 5108
module Main where

import Data.List
import Control.Monad
import Debug.Trace
import Data.Bits

solve :: Integer -> Integer -> Integer
solve a b = 
    if a `mod` 2 == 0 && b `mod` 2 == 0 then
        (b-a) `div` 2 `mod` 2 `xor` b
    else if a `mod` 2 == 0 && b `mod` 2 == 1 then
        (b-a+1) `div` 2 `mod` 2
    else if a `mod` 2 == 1 && b `mod` 2 == 0 then
        (b-a-1) `div` 2 `mod` 2 `xor` a `xor` b
    else 
        (b - a) `div`2 `mod` 2 `xor` a

main = do
    [a,b] <- fmap read . words <$> getLine
    print $ solve a b






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

#define ALL(a) (a).begin(), (a).end()
#define ll long long

using namespace std;

signed main(){
    while(true){
        int x,y,s;cin >> x >> y >> s;
        if(x == 0)break;
        int ans = 0;
        for(int i = 1; i < s; i++){
            for(int j = i; j < s; j++){
                int sum = (i * (100+x))/100;
                sum += (j*(100+x))/100;
                if(sum == s){
                    ans = max(ans, (i*(100+y))/100 + (j*(100+y))/100);
                }
            }
        }
        cout << ans << endl;
    }

    return 0;
}




Measured memory_bytes: 3096
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
    int N;
    string S;
    cin>>N>>S;
    int ans=1;
    for(int i=0;i<N-1;i++){
        if(S[i]!=S[i+1])ans++;
    }
    cout<<ans<<endl;
    return 0;
}


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

int main() {
	long long k, m, ans = 1;
	cin >> k;
	m = 7;
	if (k % 2 == 0 || k % 5 == 0) {
		cout << -1 << "\n";
	} else {
		while (m % k) {
			m = 10 * m + 7;
			m = m % k;
			ans++;
		}
		cout << ans << "\n";
	}
	return 0;
}

Measured memory_bytes: 3644
object Main {
  def main(args: Array[String]): Unit = {
    def score(inputs: String, b: List[Int], c: Int): Int = {
      inputs.split(" ").map(_.toInt).zip(b).foldLeft(0)((s, x) => s + x._1 * x._2) + c
    }

    val Seq(n, m, c) = io.StdIn.readLine().split(" ").map(_.toInt).toSeq
    val bList = io.StdIn.readLine().split(" ").map(_.toInt).toList
    val count = Iterator.continually(io.StdIn.readLine()).take(n)
      .count(inputs => score(inputs, bList, c) > 0)

    println(count)
  }
}


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

const int MAX = 1 << 30;


int main(void){
    // Your code here!
    int n;
    cin >> n;
    vector<int> A(n);
    vector<int> dp(n);
    for(int i=0;i<n;i++){
      cin >> A[i];
      dp[i] = MAX;
    }
    
    /// 1 2 3
    /// 2 3 1 -> [2] -> [2][3] -> [1][3]
    /// 1 1 1 -> [1] -> [1]
    
    /*
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        if(A[i]<=dp[j]){
          dp[j] = A[i];
          break;
        }
      }
    }
    */
    for(int i=0;i<n;i++){
      vector<int>::iterator it = lower_bound(dp.begin(), dp.end(), A[i]);
      *it = A[i];
    }
    
    /*
    for(int i=0;i<n;i++){
      cout << dp[i] << " ";
    }
    cout << endl;
    */
    
    int count = 0;
    for(int i=0;i<n;i++){
      if(dp[i]<MAX){
        count++;
      } else{
        break;
      }
    }
    
    cout << count << endl;
}



Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
 
const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
}
ll lcm(ll x,ll y){
  ll g=gcd(x,y);
  return x/g*y;
}

using Graph=vector<vector<int>>;
Graph G;
ll solve(ll n){
  if(n%2==1) return 0;
  ll res=0;
  n/=2;
  while(n){
    res+=n/5;
    n/=5;
  }
  return res;
}
int main(){
  int n;
  cin >> n;
  int sum=n/100;
  n-=n/100*100;
  if(n>sum*5)cout<<0<<endl;
  else cout<<1<<endl;
}
    


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s;
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> s;
if (s=="SUN") cout << 7;
if (s=="MON") cout << 6;
if (s=="TUE") cout << 5;
if (s=="WED") cout << 4;
if (s=="THU") cout << 3;
if (s=="FRI") cout << 2;
if (s=="SAT") cout << 1;
return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	long long int h, num = 1, cut = 0, num_2 = 2;

	scanf("%lld", &h);

	while (h > 1) {
		cut++;
		h /= 2;
	}

	for (long long int i = 0; i < cut; i++) {
		num += num_2;
		num_2 *= 2;
	}

	printf("%lld", num);

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int n,k,a,ans,s,g,m;
vector<int> v;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        v.push_back(a);
    }
    sort(v.begin(),v.end());
    cin>>k;
    for(int i=0;i<k;i++){
        cin>>a;
        s=0;
        g=n+1;
        while(g-s>1){
            m=(s+g)/2;
            if(v[m]==a){
                s=m;
                break;
            }
            else if(v[m]>a)g=m;
            else s=m;
        }
        if(v[s]==a)ans++;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 3364
#define LOCAL
#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 rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	int n; cin >> n;

	int ynum = n / 15;

	cout << n * 800 - ynum * 200 << endl;

	return 0;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
#ifndef LOCAL
#pragma GCC optimize(3)
#else
#endif
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
#define ls (rt<<1)
#define rs (rt<<1|1)
typedef long long ll;
const double eps=1e-6;
const int inf=0x3f3f3f3f;
const int maxn=1e5+100;
struct node {
    int a, b;
    bool operator < (const node& aa) const {
        // if (a!=aa.a) return a>aa.a;
        return b>aa.b;
    }
    void in() {
        cin >> a >> b;
    }
}e[maxn];
bool vis[maxn];
int main() {
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif // LOCAL
    IOS;
    int n, m;
    cin >> n >> m;
    for (int i=0; i<n; i++) {
        e[i].in();
    }
    sort(e, e+n);
    ll ans=0;
    set<int> fr;
    for (int i=0; i<m; i++) fr.insert(i);
    for (int i=0; i<n; i++) {
        if (fr.size()==0) break;
        if (e[i].a<=m) {
            if (!fr.count(m-e[i].a)) {
                set<int>::iterator plc=fr.lower_bound(m-e[i].a);
                if (plc==fr.begin()) continue;
                plc--;
                fr.erase(plc); ans+=e[i].b;
            } else {
                ans+=e[i].b; fr.erase(m-e[i].a);
            }
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    char str[50],ttr[50];ll flag=0;
    cin>>str>>ttr;
    for(ll i=0;i<strlen(str);i++)
    if(str[i]!=ttr[i])
        flag=1;
    if(flag==1)
        cout<<"No";
    else
        cout<<"Yes";
}


Measured memory_bytes: 3588
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

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



Measured memory_bytes: 592
#include <stdio.h>
int main(void)
{
  int x,y;
  int a,b;
  int i;
  int j;
  int ans;
  int temp;
  
  scanf("%d",&x);
  scanf("%d",&y);

  if (x>y) {a=x; b=y;}
  else {a=y; b=x;} 

  while(1) {
    if (b==0) break;
    else {
      temp=a%b;
      a=b;
      b=temp;
    }
  }
      

  printf("%d\n",a);
  return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    double T, X;
    cin >> T >> X;
    cout << T / X << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=(a);i<=(b);++i)
#define rep(i,n) rep2(i,0,n-1)
#define pii pair<int,int>
#define ti3 tuple<int,int,int>
int MOD=1000000000+7;
int INF=1e6;

using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");

main(){
    int n,a[300000];
    cin>>n;
    rep(i,n){
        cin>>a[i];
    }
    int i=n-1;
    ll int ans=0,res=0;
    while(1){
        if(i==0){
            if(a[i]==0) {cout<<ans; break;}
            else {cout<<-1; break;}
        }
        if(res){
            if(a[i]<res-1) {cout<<-1; return 0;}
            if(a[i]>=res){ans+=a[i];}
        }
        else{ans+=a[i];}
        res=a[i];
        i--;
    }
    return 0;
}

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

int main() {

    int A, B, C;
    cin >> A >> B >> C;

    if (A == B && A != C) {
        cout << "Yes" << endl;
        return 0;
    }

    if (A == C && A != B) {
        cout << "Yes" << endl;
        return 0;
    }

    if (B == C && B != A) {
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;

    return 0;
}


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

int main(void)
{
    using namespace std;
    int X;
    scanf("%d", &X);
    int c_500 = X / 500;
    int c_5 = (X % 500) / 5;

    printf("%d\n", (c_500 * 1000) + (c_5 * 5));
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define ct(string) cout << string << endl
#define all(s) (s).begin(), (s).end()

int main() {
    string s;
    cin >> s;
    int size = s.size();
    vector<int> ans(size, 0);
    int r;
    rep(re,2) {
        // solve R
        r = 0;
        rep(i,size) {
            if (s.at(i) == 'R') r++;
            else {
                ans.at(i) += r/2;
                ans.at(i-1) += (r != 0 ? (r+1)/2 : 0);
                r=0;
            }
        }
        reverse(all(s));
        reverse(all(ans));
        rep(ree,size) s.at(ree) = (s.at(ree) == 'R' ? 'L' : 'R');
    }
    rep(i,size-1) cout << ans.at(i) << " ";
    ct(ans.at(size-1));
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rep2(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define rev(i, n) for (int (i) = (n)-1; (i) >= 0; (i)--)
#define rev2(i, a, b) for (int (i) = (a)-1; (i) >= (b); (i)--)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Pll = pair<long long, long long>;
template<class T> using Vec = vector<T>;
template<class T> using VVec = vector<vector<T>>;
long long TEN(int i) {return !i ? 1 : TEN(i-1)*10LL;}
template<class T, class U> 
bool chmin(T& a, const U& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T, class U> 
bool chmax(T& a, const U& b) {if (a < b) {a = b; return 1;} return 0;}

struct IoSetup {
	IoSetup() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(10);
	}
} iosetup;

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//

int N, M;
ll x[1005], y[1005], z[1005];

bool same(int mask, ll val) {
	if ((ll)mask * val >= 0) return true;
	return false;
}

void solve() {
	ll ans = 0;
	for (int sig_x : {1, -1}) for (int sig_y : {1, -1}) for (int sig_z : {1, -1}) {
		ll xyz[N] = {0};
		rep (i, N) {
			if (same(sig_x, x[i])) xyz[i] += abs(x[i]);
			else xyz[i] -= abs(x[i]);
			if (same(sig_y, y[i])) xyz[i] += abs(y[i]);
			else xyz[i] -= abs(y[i]);
			if (same(sig_z, z[i])) xyz[i] += abs(z[i]);
			else xyz[i] -= abs(z[i]);
		}
		sort(xyz, xyz + N);
		ll sum = 0;
		rep (i, M) sum += xyz[N - i - 1];
		chmax(ans, sum);
	}
	cout << ans << endl;
}

int main() {
	cin >> N >> M;
	rep (i, N) cin >> x[i] >> y[i] >> z[i];
	solve();
	
	return 0;
}

Measured memory_bytes: 3508
#include <bits/stdc++.h>
#define inf 1000000007
#define mod 1000000007
//#pragma GCC optimize(2)
//#define int long long
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
template <typename T> void write(T x) {
	if (x<0) x=-x,putchar('-');
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
string s;
int a[1000005];
signed main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>s;
	s.insert(0,"0");
	for(int i=1;i<=s.size();i++)
		a[i]=s[s.size()-i]-'0';
	int ans=0;
	for(int i=1;i<=s.size();i++)
	{
		if(10-a[i]+min(a[i+1]+1,9-a[i+1])<a[i]+min(a[i+1],10-a[i+1]))
		{
			a[i+1]++;
			a[i]=10-a[i];
		}
		ans+=a[i];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 5276
//============================================================================
//Everyone has a different way of thinking, so God Created us
//   Hope You Respect My Way..,Thank You ):
// Author      : Murad
// Online Judge: Codeforces.cpp & Atcoder.cpp
// Description : Problem name
//============================================================================
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
using namespace std;
#define pi 3.1415926536
#define forn(i,a,b)for(int i=a;i<b;i++)
#define ULL unsigned long long
#define MP make_pair
#define ff first
#define ss second
#define endl '\n'
#define INF LL(1e18);
#define _INF INT32_MIN
#define pq priority_queue
#define MM multimap
#define PB push_back
#define EMPP emplace_back
#define vii vector<int>
#define vll vector<LL>
#define ipair pair<int,int>
#define lpair pair<LL,LL>
#define El3zba ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define modd 1000000007
#define sf1(v) scanf("%I64d",&v);
#define sf2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sf3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
typedef long long LL;
//std::transform(s1.begin(), s1.end(), s1.begin(),::tolower);
char alphz[27] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };
float Euclidean(LL x1, LL x2, LL y1, LL y2) {
	return sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
}
LL gcd(LL a,LL b) {
	return !b ? a : gcd(b, a % b);
}
LL LCM(LL a, LL b) {
	return (a*b) / gcd(a, b);
}
void PrimeFactor(LL n)
{
	while (n % 2 == 0) {
		//printf("%d ", 2);
//		aa.insert(2);
		n /= 2;
	}
	for (int i = 3; i <= sqrt(n); i += 2)
	{
		if (n%i == 0) {
			//printf("%d ", i);
			//aa.insert(i);
			n /= i;
		}
	}
	if (n > 2){
		//printf("%d ", n);
	//	aa.insert(n);
	};
}
bool is_square(LL x) {
	LL l = 0, r = x;
	while (l <= r) {
		LL mid = l + (r - l) / 2;
		if (mid*mid == x)return true;
		if (mid*mid > x)r = mid - 1;
		else l = mid + 1;
	}
	return false;
}
LL power(LL x, LL y)
{
	LL temp;
	if (y == 0)return 1;
	temp = power(x, y / 2);
	if (y % 2 == 0)
		return temp*temp;
	else return x*temp*temp;
}
bool is_Prime(int x) {
	if (x == 2)return 1;
	else if (x % 2 == 0 || x < 2)return 0;
	for (int i = 3; i*i <= x; i += 2)
		if (x%i == 0)return 0;
	return 1;
}
int main()
{
	El3zba;
	/***  بسم الله الرحمن الرحيم   ***/
	LL n;
	cin >> n;
	vector<LL>a;
	for (LL i = 1; i*i <= n; i++) {
		if (n%i == 0) {
			a.push_back(i);
			if (n / i != i)a.push_back(n / i);
		}
	}
	LL ans = INF;
	for (LL i = 0; i<a.size(); i++) {
		for (LL j = 0; j<a.size(); j++) {
			if (a[i] * a[j] == n)ans = min(ans, a[i] + a[j] - 2);
		}
	}
	cout << ans<<endl;
	return 0;
}

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


int main()
{
    int x;
    cin>>x;
    ll ans =1;

    for(int i=2;i<=sqrt(x) ;i++)
    {
        ll temp =i;
        while( temp <= x)
            temp = temp*i;
        temp = temp/i;

        ans = max(ans , temp);
    }
    cout<<ans;
}

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

int N;
int W;
long long w[110];
long long v[110];
long long dp[110][100010];

int main() {
  cin >> N >> W;
  for (int i = 0; i < N; ++i) cin >> w[i] >> v[i];
  for (int i = 0; i < N; ++i) for (int j = 0; j <= W; ++j) dp[0][j] = 0;

  for (int i = 0; i < N; ++i) {
    for (int w_limit = 0; w_limit <= W; ++w_limit) {
      if (w[i] <= w_limit) {
        dp[i + 1][w_limit] = max(dp[i][w_limit - w[i]] + v[i], dp[i][w_limit]);
      } else dp[i + 1][w_limit] = dp[i][w_limit];
    }
  }

  cout << dp[N][W] << endl;
  return 0;
}

Measured memory_bytes: 80128
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)

	n := nextInt()
	h0 := nextInt()
	count := 0
	maxCount := 0

	for i := 0; i < n-1; i++ {
		h := nextInt()
		if h <= h0 {
			count++
			if count > maxCount {
				maxCount = count
			}
		} else {
			count = 0
		}
		h0 = h
	}

	fmt.Println(maxCount)
}


Measured memory_bytes: 4440
def binSearch(N, A, key):
    left = 0
    right = N - 1
    memo = [-1 for _ in range(N)]
    k = (left + right) // 2
    while True:
        if memo[k] == -1:
            memo[k] = 1 if key(A[k]) else 0
        if memo[k] == 1:
            right = k
        else:
            left = k
        _k = (left + right) // 2
        if _k == k:
            if memo[left] == -1:
                memo[left] = key(A[left])
            if memo[right] == -1:
                memo[right] = key(A[right])
            if memo[right] == 0 or memo[left] == 1:
                return -1
            else:
                return right
        else:
            k = _k


def trisum(n):
    return n * (n + 1) // 2


def calc(S):
    t = []
    b = 0
    i = S.find('><', b)
    result = 0
    while i != -1:
        if i - b == 0:
            result += 0
        elif i - b == 1:
            result += 1
        else:
            t += [S[b:i + 1]]
        b = i + 1
        i = S.find('><', b)
    t += [S[b:]]
    for u in t:
        nu = len(u)
        l = binSearch(nu, u, lambda c: c == '>')
        if l != -1:
            result += trisum(max(l, nu - l)) + trisum(min(l, nu - l) - 1)
        else:
            result += trisum(nu)
    return result


S = input()
print(calc(S))

Measured memory_bytes: 9500
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
#include <unordered_set>
using namespace std;
constexpr int64_t MOD = 1e9 + 7;

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

  int64_t N;
  cin >> N;
  int64_t pow = 26;
  int64_t p = N;
  int cnt = 1;
  while (pow <= N ) {
    if (p <= pow) {
      break;
    } else {
      p -= pow;
      pow *= 26;
      cnt++;
    }
  }

  pow /= 26;

  bool mod0 = false;
  while (pow > 0) {
    int div = p / pow;
    p = p % pow;
    if (mod0 == false) {
      if (p == 0) {
        mod0 = true;
        char c = 'a' + div - 1;
        cout << c;
      } else {
        char c = 'a' + div;
        cout << c;
      }
    } else {
      cout << "z";
    }
    pow /= 26;
  }
  cout << endl;
  
  return 0;
}


Measured memory_bytes: 3648
class UnionFind():
    def __init__(self,n):
        self.n=n
        self.root=[-1]*n
        self.rank=[-1]*n

    def Find_Root(self,x):
        if self.root[x]<0:return x
        else:
            self.root[x]=self.Find_Root(self.root[x])
            return self.root[x]

    def Unite(self,x,y):
        x=self.Find_Root(x)
        y=self.Find_Root(y)

        if x==y:return
        elif self.rank[x]>self.rank[y]:
            self.root[x] +=self.root[y]
            self.root[y]=x
        else:
            self.root[y] +=self.root[x]
            self.root[x]=y
            if self.rank[x]==self.rank[y]:
                self.rank[y] +=1

    def isSameGroup(self,x,y):
        return self.Find_Root(x)==self.Find_Root(y)

    def Count(self,x):
        return -self.root[self.Find_Root(x)]

    def members(self,x):
        root=self.Find_Root(x)
        return [i for i in range(self.n) if self.Find_Root(i)==root]

    def address(self):
        return[i for i,j in enumerate(self.root) if j<0]

    def group_members(self):
        return {i:self.members(i) for i in self.address()}

    def size(self,x):
        return -self.root[self.Find_Root(x)]

    def same(self,x,y):
        return self.Find_Root(x)==self.Find_Root(y)


n,m=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(m)]
UnionFind=UnionFind(n)
N=n*(n-1)//2
count=[N]

for a,b in AB[::-1]:
    if UnionFind.same(a-1,b-1):
        count.append(count[-1])
    else:
        s,t=UnionFind.size(a-1),UnionFind.size(b-1)
        count.append(count[-1]-s*t)
    UnionFind.Unite(a-1,b-1)

for i in count[::-1][1:]:
    print(i)

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

int main() {
  int W, H, N;
  cin >> W >> H >> N;
  vector<vector<int>> v(N, vector<int>(3));
  for (int i = 0; i < N; i++) cin >> v[i][0] >> v[i][1] >> v[i][2];

  vector<vector<int>> m(H, vector<int>(W, 0));
  for (int i = 0; i < N; i++) {
    int x = v[i][0];
    int y = v[i][1];
    int a = v[i][2];
    switch (a) {
      case 1:
        for (int j = 0; j < H; j++) {
          for (int k = 0; k < x; k++) m[j][k] = 1;
        }
        break;

      case 2:
        for (int j = 0; j < H; j++) {
          for (int k = x; k < W; k++) m[j][k] = 1;
        }
        break;

      case 3:
        for (int j = 0; j < y; j++) {
          for (int k = 0; k < W; k++) m[j][k] = 1;
        }
        break;

      case 4:
        for (int j = y; j < H; j++) {
          for (int k = 0; k < W; k++) m[j][k] = 1;
        }
        break;
    }
  }

  int ans = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) if (m[i][j] == 0) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
function Main(input) {
    var rows = input.split("\n");
    var K = parseInt(rows[0], 10);
    var S = rows[1];
    var sub = '';
    if (S.length <= K) {
        sub = S;
    } else {
        sub = S.substr(0, K) + '...';
    }
    console.log('%s', sub);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29628
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
string s;
int a;
int func();//+-
int num();
int func2();//*/
int func3();//()
int num(){
    int out=0;
    while(isdigit(s[a])){
        out*=10;out+=s[a]-'0';
        a++;
    }
    return out;
}
int func3(){
    int out;
    if(s[a]=='('){
        a++;
        out=func();
        a++;
    }else out=num();
    return out;
}
int func2(){
    int out=func3();
    while(1){
        if(s[a]=='*'){
            a++;
            out*=func3();
        }else if(s[a]=='/'){
            a++;
            out/=func3();
        }else break;
    }
    return out;
}   
int func(){
    int out=func2();
    while(1){
        if(s[a]=='+'){
            a++;out+=func2();
        }else if(s[a]=='-'){
            a++;out-=func2();
        }else break;
    }
    return out;
}
int main(){
	int q;
	cin>>q;
	while(q--){
		cin>>s;
		a=0;
		cout<<func()<<endl;
	}
}
 
 

Measured memory_bytes: 1204
#include<bits/stdc++.h>
using namespace std;
int n,o,x;
int main()
{
    cin>>n>>o;
    int ans=1;
    for(int i=2;i<=n;i++){
        cin>>x;
        if(x>=o)ans++,o=x;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
char s[10001];
int main()
{
    cin>>s;
    if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I')
        cout<<"Yes\n";
    else
        cout<<"No\n";
}

Measured memory_bytes: 256
def main():
    from collections import deque

    h, w = map(int, input().split())
    ch, cw = map(lambda x: int(x) - 1, input().split())
    dh, dw = map(lambda x: int(x) - 1, input().split())

    m = [list(input()) for _ in range(h)]
    vis = [[False for _ in range(w + 2)] for _ in range(h + 2)]

    def walk(i, j):
        q = deque()
        q.append((i, j))
        edge = []
        while q:
            y, x = q.popleft()
            if vis[y][x]:
                continue
            vis[y][x] = True
            for s, t in [(1, 0), (0, 1), (-1, 0), (0, -1)]:
                if 0 <= y + s <= h - 1 and 0 <= x + t <= w - 1:
                    if m[y + s][x + t] == '#':
                        edge.append((y, x))
                        continue
                    q.appendleft((y + s, x + t))
        return edge

    def jump(i, j, c):
        q = walk(i, j)
        if vis[dh][dw]:
            return c
        nx = []
        c += 1
        while q:
            y, x = q.pop()
            for s in range(-2, 3):
                for t in range(-2, 3):
                    if vis[y + s][x + t]:
                        continue
                    if 0 <= y + s <= h - 1 and 0 <= x + t <= w - 1:
                        if m[y + s][x + t] == '#':
                            continue
                        nx += walk(y + s, x + t)
                        if vis[dh][dw]:
                            return c
            if len(q) == 0:
                c += 1
                q = nx
                nx = []

    ans = jump(ch, cw, 0)
    print(ans if ans is not None else -1)


if __name__ == '__main__':
    main()


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

using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
ll n,m;
ll x[100004];
ll y[100004];
int main() {
  cin >> n >> m;

  for(int i = 1; i <= n; i++) cin >> x[i];

  for(int j = 1; j <= m; j++) cin >> y[j];

  ll sum_x = 0;
  for(ll k = 1; k <= n; k++) {
    sum_x += (k * 2 - n - 1) * x[k] % mod;
  }
  ll sum_y = 0;
  for(ll k = 1; k <= m; k++) {
    sum_y += (k * 2 - m - 1) * y[k] % mod;
  }

  cout << (sum_x % mod) * (sum_y % mod)  % mod <<endl;
}
  


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5;
const int MD = 998244353;
int f[N], fac[N], inv[N];
int quick_pow(int x, int y) {
    int ans = 1;
    while(y) {
        if(y & 1) ans = 1LL * ans * x % MD;
        y >>= 1;
        x = 1LL * x * x % MD;
    }
    return ans;
}
void init() {
    fac[0] = 1;
    for(int i = 1; i < N; i++) fac[i] = 1LL * fac[i - 1] * i % MD;
    inv[N - 1] = quick_pow(fac[N - 1], MD - 2);
    for(int i = N - 2; i >= 0; i--) inv[i] = 1LL * inv[i + 1] * (i + 1) % MD;
}
int C(int n, int m) {
    return 1LL * fac[n] * inv[m] % MD * inv[n - m] % MD;
}
int main() {
    init();
    int n, m, k;
    scanf("%d%d%d", &n, &m ,&k);
    f[0] = 1;
    for(int i = 1; i <= n; i++) {
        f[i] = 1LL * f[i - 1] * (m - 1) % MD;
    }
    int ans = 0;
    for(int i = 0; i <= k; i++) {
        ans = (ans + 1LL * C(n - 1, i) * f[n - i - 1] % MD) % MD;
    }
    ans = 1LL * ans * m % MD;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 6148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

int main()
{
    int n, q; cin >> n; int arr[n]; ll sum = 0;
    int pos[100001]; memset(pos, 0, sizeof(pos));
    for (int i = 0; i < n; i++)
    {
        cin >> arr[i];
        pos[arr[i]]++;
        sum+=arr[i];
    }
    cin >> q;
    for (int i = 0; i < q; i++)
    {
        int b, c; cin >> b >> c;
        ll add = c - b; add *= pos[b];
        pos[c] += pos[b]; pos[b] = 0;
        sum += add;
        cout << sum << '\n';
    }
    return 0;
}

Measured memory_bytes: 4412
#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 rrng(a) a.rbegin(), a.rend()
#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 eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#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 tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}


void solve(int n){
  ll dp[400][400];
  Fill(dp,-n);
  vl w(n);
  rep(i,n)cin >> w[i];
  rep(i,n+1){
    dp[i][i] = 0;
    // 半開区間なので、[i][i+1]は積木が1個しか存在しないため、0にする
    if(i<n) dp[i][i+1] = 0;
  }

  for(int bet = 2; bet<=n;bet++){
    for(int i = 0;i+bet<=n;i++){
      int j = i+bet;
      if(dp[i+1][j-1] == j-i-2){
        if(abs(w[i]-w[j-1]) <= 1) maxs(dp[i][j],(ll)(j-i));
        else maxs(dp[i][j],(ll)(j-i-2));
      }
      for(int k = i+1;k<=j-1;k++){
        maxs(dp[i][j],dp[i][k]+dp[k][j]);
      }
    }
  }
  cout<<dp[0][n]<<endl;
}
int main() {
  while(1){
  int n;
  cin >> n;
  if(!n)break;
  else{
    solve(n);
  }
  }
  return 0;
}


Measured memory_bytes: 4328
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;
int main(void){
    int a,b,ans=0;cin>>a>>b;
    if(a>b){
        ans+=a;a--;
    }else{
        ans+=b;b--;
    }
    cout<<ans+max(a,b)<<endl;
    return 0;
}


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

#define lint long long
#define P pair<int, lint>

const lint INF = 1E15;

int main() {
    int N;
    cin >> N;
    char S[N];

    set<char> cnt;

    for(int i = 0; i < N; ++i){
        cin >> S[i];
        cnt.insert(S[i]);
    }

    if(cnt.size() == 3){
        cout << "Three" << endl;
    } else {
        cout << "Four" << endl;
    }

    

}


Measured memory_bytes: 256
import java.io.*;
import java.io.ObjectInputStream.*;
import java.util.*;
import java.util.regex.*;


public class Main {

	final static long MOD = 1000000007;
	//final static long MOD = 998244353;

	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static long cnt=0;
	public static PrintWriter pw = new PrintWriter(System.out);
	public static void main(String[] args) throws Exception {
		solutionA(args);
		if(in!=null){
			in.close();
		}
		pw.flush();
		pw.close();
	}

	public static void solutionA(String[] args) throws Exception{

		int H = nextInt();
		int W = nextInt();
		char[][] s = new char[H+2][W+2];
		Arrays.fill(s[0],'#');
		Arrays.fill(s[H+1],'#');
		for(int i=1;i<=H;i++) {
			s[i]=("#"+nextString()+"#").toCharArray();
		}

		//白石の数
		int cnt=0;
		int[][] c = new int[H+2][W+2];
		for(int h=0;h<s.length;h++) {
			for(int w=0;w<s[0].length;w++) {
				if(s[h][w]=='.') {
					cnt++;
					c[h][w]=0;
				}else {
					c[h][w]=-1;
				}
			}
		}

		ArrayDeque<int[]> q = new ArrayDeque<int[]>();
		//4方向の場合はx[i+around[n]][k+around[n+1]]n<4,8方向はn<8でループ
		int[] around = { -1, 0, 1, 0, -1, 1, 1, -1, -1 };

		q.push(new int[] {1,1});
		while(!q.isEmpty()) {
			int[] p = q.poll();
			if(p[0]==W&&p[1]==H) {
				pw.println(cnt-c[H][W]-1);
				return ;
			}

			for(int n=0;n<4;n++) {
				int nextX=p[0]+around[n];
				int nextY=p[1]+around[n+1];
				if(c[nextY][nextX]==0) {
					q.offer(new int[] {nextX,nextY});
					c[nextY][nextX]=c[p[1]][p[0]]+1;
				}
			}
		}
		pw.println(-1);
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}



Measured memory_bytes: 21204
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] X = new int[5];
        for (int i = 0; i < 5; i++) {
            X[i] = sc.nextInt();
        }

        if (X[0] == 0) {
            System.out.println("1");
        }
        if (X[1] == 0) {
            System.out.println("2");
        }

        if (X[2] == 0) {
            System.out.println("3");
        }

        if (X[3] == 0) {
            System.out.println("4");
        }

        if (X[4] == 0) {
            System.out.println("5");
        }

    }
}

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

int main(){
    int n;
    cin >> n;
    bool flag = true;
    rep(i,n){
        int x;
        cin >> x;
        if(x % 2 == 0 && (x % 3 != 0 && x % 5 != 0)) flag = false;
    }

    cout << (flag ? "APPROVED" : "DENIED") << endl;
}


Measured memory_bytes: 256
def z_algorithm(s):
    n = len(s)
    z = [0] * n
    z[0] = n

    i = 1
    lcp = 0
    while i < n:
        while i+lcp < n and s[i+lcp] == s[lcp]:
            lcp += 1
        z[i] = lcp

        if lcp == 0:
            i += 1
            continue

        k = 1
        while i+k < n and k+z[k] < lcp:
            z[i+k] = z[k]
            k += 1
        i += k
        lcp -= k

    return z



n = int(input())
s = input()

ans = 0
for i in range(n):
    z = z_algorithm(s[i:])
    for j in range(1, n-i):
        ans = max(ans, min(j, z[j]))

print(ans)


Measured memory_bytes: 49244
import numpy as np

H,W = map(int,input().split())
maze = [list(input())for _ in range(H)]
for i in range(H):
  for j in range(W):
    if maze[i][j]=="#":
      maze[i][j]=0
    else:
      maze[i][j]=float('INF')
maze=np.array(maze)
for i in range(1,H):
	maze[i,:]=np.minimum(maze[i,:],maze[i-1,:]+1)
for i in range(1,W):
	maze[:,i]=np.minimum(maze[:,i],maze[:,i-1]+1)
for i in range(H-2,-1,-1):
	maze[i,:]=np.minimum(maze[i,:],maze[i+1,:]+1)
for i in range(W-2,-1,-1):
	maze[:,i]=np.minimum(maze[:,i],maze[:,i+1]+1)
print(int(np.max(maze)))

Measured memory_bytes: 52564
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int H,N;
    cin>>H>>N;

    int A[N],B[N];
    rep(i,N){
        cin>>A[i]>>B[i];
    }

    vector<int> dp(2*10000,INF);

    dp[0]=0;
    rep(i,H){
        rep(j,N){
            dp[i+A[j]]=min(dp[i]+B[j],dp[i+A[j]]);
        }
    }
    int ans=INF;
    for(int i=H;i<20000;i++){
        ans=min(ans,dp[i]);
    }
    cout << ans << endl;

    



}


Measured memory_bytes: 384
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

k = int(input())
ans = 0

for i in range(1,k+1):
    ans += i #数1種類
    for j in range(i+1,k+1):
        ans += gcd(i,j) * 6 #数2種類
        for k in range(j+1,k+1):
            ans += gcd(i, j, k) * 6 #数3種類
    
print(ans)

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

int main(){
	string s;
	cin >> s;
	int k = s.size() / 2;
	int count = k;
	rep(i, k) {
		if (s[i] == s[s.size()-1-i]) {
			count--;
		}
	}

	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
package main

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


var sc = bufio.NewScanner(os.Stdin)


func main() {
	sc.Split(bufio.ScanWords)
	k := nextInt()
	a := nextInt()
	b := nextInt()
	result := "NG"
	for i := a; i <= b; i++ {
		if i % k == 0 {
			result = "OK"
		}
	}
	fmt.Println(result)
}


func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 1760
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

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

	Int N, a, b;
	cin >> N >> a >> b;

	vector<Int> A(2);
	A[0] = a;
	A[1] = b;

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

	if ((A[1] - A[0]) % 2 == 0) {
		cout << (A[1] - A[0]) / 2 << "\n";
	}
	else {
		Int ans = (A[0] - 1) + 1 + (A[1] - A[0] - 1) / 2;
		ans = min(ans, (N - A[1]) + 1 + (A[1] - A[0] - 1) / 2);
		cout << ans << "\n";
	}

}


Measured memory_bytes: 256
package main

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

func main() {
	var (
		In = ReadLineInt()
	)

	sort.Ints(In)

	var (
		A = In[0]
		B = In[1]
		C = In[2]
	)

	if (A%2 == 0) || (B%2 == 0) || (C%2 == 0) {
		fmt.Println("0")
		return
	}

	fmt.Println(A * B)
}

/////////////////////////////////////////

func fln(format string, elements ...interface{}) {
	fmt.Printf(format+"\n", elements...)
}

var BufReader = bufio.NewReaderSize(os.Stdin, 1e6)

func ReadLine() string {
	a, _, _ := BufReader.ReadLine()
	return string(a)
}

func ReadLineInt() (result []int) {
	in := strings.Split(ReadLine(), " ")
	result = make([]int, 0, 2)
	for _, v := range in {
		t, _ := strconv.Atoi(v)
		result = append(result, t)
	}
	return
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define pllll pair<long long, long long>
#define ll long long
#define fi first
#define se second
using namespace std;
int main() {
    int N;
    cin >> N;
    vector<pllll> G[N+1];
    for(int i = 1; i <= N; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        G[a].emplace_back(b, c);
        G[b].emplace_back(a, c);
    }

    queue<int> Q;
    ll dist[N+1];
    for(int i = 1; i <= N; i++) dist[i] = numeric_limits<ll>::max();

    Q.push(1);
    dist[1] = 0;
    while(!Q.empty()) {
        int s = Q.front();
        Q.pop();
        
        for(auto adj: G[s]) {
            if(dist[adj.fi] > dist[s]+adj.se) {
                Q.push(adj.fi);
                dist[adj.fi] = dist[s]+adj.se;
            }
        }
    }

    for(int i = 1; i <= N; i++) {
        cout << dist[i]%2 << endl;
    }
}

Measured memory_bytes: 8704
#!/usr/bin/env python3
import numpy as np

def main():
    H,W = map(int,input().split())
    a = [list(input()) for _ in range(H)]

    ok_i = []
    ok_j = []
    for i in range(H):
        for j in range(W):
            if a[i][j] == '#':
                ok_i.append(i)
                break

    for i in range(W):
        for j in range(H):
            if a[j][i] == '#':
                ok_j.append(i)
                break

    answer = []

    b = [aa for idx, aa in enumerate(a) if idx in ok_i]
    for i in range(len(b)):
        temp = []
        for j in range(W):
            if j in ok_j:
                temp.append(b[i][j])
        answer.append(temp)
    
    for i in range(len(answer)):

        print(''.join(answer[i]))





if __name__ == '__main__':
    main()


Measured memory_bytes: 12536
#include <stdio.h>
int main(void)
{
	int n, l;
	int i;
	int sum=0;
	int flag=0;
	scanf("%d %d",&n, &l);
	
	for(i=1; i<=n; i++){
		if(l-1+i == 0) flag=1;//味に0がある
		sum += l-1+i;
	}
	//味が全て負(2)
	if(l-1+n < 0) flag = 2;
	if(flag == 1) printf("%d\n", sum);
	else if(flag == 2) printf("%d\n", sum - (l-1+n));
	else printf("%d\n", sum - l);
	
	return 0;
}

Measured memory_bytes: 128