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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define chmax(s, t) s=max(s,t);
#define chmin(s, t) s=min(s,t); 

#define deg2rad(deg) (((deg)/360)*2*M_PI)
#define rad2deg(rad) (((rad)/2/M_PI)*360)

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

/*素数判定*/
bool is_prime(ll n){
    if(n==1) return false;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0) return false;
    }
    return true;
}

/*約数列挙*/
vll enum_divisors(ll n){
    vll l;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            l.push_back(i);
            if(n/i != i) l.push_back(n/i);
        }
    }
   sort(all(l));
   return l;
}

/*素因数分解*/
vector<P> prime_factorize(ll n){
    vector<P> l;
    for(ll i=2;i*i<=n;i++){
        if(n%i!=0) continue;
        ll e = 0;
        while(n%i==0){
            e++;
            n /= i;
        }
        l.push_back({i, e});
    }
    if(n!=1) l.push_back({n, 1});
    return l;
}

/*最小公倍数*/
ll lcm(ll a, ll b){
    return a*b/__gcd(a,b);
}

/*最大公約数*/
ll gcd(ll a, ll b){
    return __gcd(a,b);
}

/*組み合わせ(Combination)*/
const ll CMAX = 1010000;
const ll CMOD = 1e9+7;
ll fac[CMAX], finv[CMAX], inv[CMAX];
// テーブルを作る前処理
void combinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < CMAX; i++) {
		fac[i] = fac[i - 1] * i % CMOD;
		inv[i] = CMOD - inv[CMOD%i] * (CMOD / i) % CMOD;
		finv[i] = finv[i - 1] * inv[i] % CMOD;
	}
}
// 二項係数計算
ll comb(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % CMOD) % CMOD;
}

/*階乗*/
ll factorial(ll n){
    const ll FMOD = 1e9+7;
    ll ret = n;
    for(ll i=n-1;i>0;i--){
        ret*=i;
        ret%=FMOD;
    }
    return (ret?ret:1);
}


int main(){

    ll n; cin >> n;
    ll ne=-INF, nw=INF, se=-INF, sw=INF;
    P nexy, nwxy, sexy, swxy;
    rep(i, n){
        ll x, y;
        cin >> x >> y;
        ll add = x+y;
        ll sub = x-y;
        if(ne<=add){
            nexy = {x, y};
            ne = add;
        }
        if(se<=sub){
            sexy = {x, y};
            se = sub;
        }
        if(nw>=sub){
            nwxy = {x, y};
            nw = sub;
        }
        if(sw>=add){
            swxy = {x, y};
            sw = add;
        }
    }

    ll ans = -INF;
    vector<P> xy = {nexy, nwxy, sexy, swxy};
    rep(i, 3){
        rep2(j, i+1, 4){
            ll xi = xy[i].first;
            ll xj = xy[j].first;
            ll yi = xy[i].second;
            ll yj = xy[j].second;

            ll mnh = abs(xi-xj)+abs(yi-yj);
            chmax(ans, mnh);
        }
    }

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

Measured memory_bytes: 3504
// author : ayush_nishad
// Road to Expert since : 30 Aug 2020
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define pb push_back
#define in insert
#define F first
#define S second
#define mod 1000000007
#define endl '\n'
#define all(x)  x.begin(),x.end()
#define w(x) int x;cin>>x; while(x-->0)
#define memset(a,b) memset(a,b,sizeof(a))
#define debug(x) cout << "[ " << #x  << " : " << x << " ]" << endl;

void fast()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);

}
/*
think fast
think simple
*/
void mysol()
{
	int v; cin >> v;
	int ans = 0;
	for (int i = 1; i < v; i++)
		for (int j = 1; i * j < v; j++)
			ans++;
	cout << ans << endl;
}

int32_t main()
{
	fast();
	// w(t)
	{
		mysol();
	}
	//cerr << sizeof(dp)*(1e-6) << " megabytes\n";
	return 0;
}


Measured memory_bytes: 3652
#include<stdio.h>
using namespace std;

int main(void)
{
	int X;
	int a=1;
	int ans=0;
	scanf("%d", &X);
	for (int i = 1; i <= X; i++) {
		a = i;
		for (int j=1; j<11 ; j++) {
			a =a*i;
			//printf("%d\n", a);
			if (a > X) {
				break;
				
			}
			if(ans<a)
			ans = a;
				
		}
		
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 760
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define ep emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

template<class T, class U> bool chmax(T &a, U b) { if (a < b) a = b; return true; }
template<class T, class U> bool chmin(T &a, U b) { if (a > b) a = b; return true; }

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);

  string s; cin >> s;
  set<char> se;

  rep(i, si(s)) {
    if (se.count(s[i])) {
      cout << "no" << endl;
      return (0);
    }

    se.emplace(s[i]);
  }

  cout << "yes" << endl;

  return (0);
}


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


class Queue:
    def __init__(self):
        self.l = []

    def enqueue(self, x):
        self.l.append(x)

    def dequeue(self):
        x = self.l[0]
        del self.l[0]
        return x

    def is_empty(self):
        return len(self.l) == 0


class Process:
    def __init__(self, name, time):
        self.name = name
        self.time = time


if __name__ == '__main__':
    n, q = map(int, raw_input().split())
    Q = Queue()
    i = 0
    while i != n:
        tmp = raw_input().split()
        Q.enqueue(Process(tmp[0], int(tmp[1])))
        i += 1
    cnt = 0
    while not Q.is_empty():
        p = Q.dequeue()
        if p.time > q:
            p.time -= q
            cnt += q
            Q.enqueue(p)
        else:
            cnt += p.time
            print p.name, cnt


Measured memory_bytes: 25152
N = int(input())
S = list(input())
r = S.count('R')
g = S.count('G')
b = S.count('B')
p = r*g*b
a = 0
for i in range(N):
    for j in range(min(i,N-i-1)):
        if S[i] != S[i-j-1] and S[i] != S[i+j+1] and S[i-j-1] != S[i+j+1]:
            a += 1
print(p-a)


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

using ll = long long int;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

#define pi 3.14159265358979323846

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }




ll cnt_rep = 0;
ll powmod(ll N, ll P, ll M){
  cnt_rep++;
  if(P == 0) return 1;
  if(P%2 == 0){
    ll t = powmod(N, P/2, M);
    return t*t % M;
  }
  return (N * powmod(N, P-1, M)) % M;
}


ll gcd(ll a, ll b){
  ll resi, g, l;
  if(a > b){
    g = a; l = b;
  }else if(b > a){
    g = b; l = a;
  }else{
    return a;
  }
  resi = g % l;
  if(resi != 0){
    return gcd(l, resi);
  }else{
    return l;
  } 
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

int ans = 0;
int N, M, Q;

template<typename T>
void showall(vector<T> v){
  rep(i, 0, v.size()){
    cout << v[i] << " ";
  }
  cout << endl;
}

template<typename T>
ll com(T n, T m, T mod){
  ll a = 1, b = 1, ans;
  if(n == m || m == 0){
    ans = 1;
  }else{
    for(ll i = 0;i < m; i++){
      a *= n-i;
      a %= mod;
      b *= i+1;
      b %= mod;
    }
    ans = (a * powmod(b, mod-2, mod)) % mod;
  }
  
  return ans;
}



 
int main() {
  ll A, V, B, W, T;

  cin >> A >> V;
  cin >> B >> W;
  cin >> T;

  ll diff = abs(A - B);

  ll v_diff = V - W;

  if(v_diff <= 0){
    cout << "NO" << endl;
    return 0;
  }

  if(v_diff * T >= diff){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }



  // cout << setprecision(8) << ans << endl;  // For double
}



Measured memory_bytes: 3636
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect, heapq
input = lambda: sys.stdin.buffer.readline()
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,q=map(int,input().split())
STX=[tuple(map(int,input().split())) for i in range(n)]
D=[int(input()) for i in range(q)]
event=[]
for si,ti,xi in STX:
  event.append((si-xi,0,xi))
  event.append((ti-xi,-1,xi))
for di in D:
  event.append((di,1,di))
event.sort()
hq=[]; S=set()
ans = []
for time, query, number in event:
  if query == 0:
    heapq.heappush(hq,number)
    S.add(number)
  elif query == -1:
    S.remove(number)
  else:
    while hq and hq[0] not in S:
      heapq.heappop(hq)
    if not hq:
      ans.append(-1)
    else:
      ans.append(hq[0])
print(*ans,sep="\n")




Measured memory_bytes: 120636
#include<cstdio>
#include<iostream>
using namespace std;
int main(void){
	int n,min,max,i,a[100],flg[8];
	for(i=0;i<8;i++) flg[i]=0;
	cin>>n;
	for(i=0;i<n;i++) cin>>a[i];
	min=0; max=0;
	for(i=0;i<n;i++){
		if(a[i]<=399&&flg[0]!=1){
			flg[0]=1;
			min++; max++;
		}
		if(a[i]>=400&&a[i]<=799&&flg[1]!=1){
			flg[1]=1;
			min++; max++;
		}
		if(a[i]>=800&&a[i]<=1199&&flg[2]!=1){
			flg[2]=1;
			min++; max++;
		}
		if(a[i]>=1200&&a[i]<=1599&&flg[3]!=1){
			flg[3]=1;
			min++; max++;
		}
		if(a[i]>=1600&&a[i]<=1999&&flg[4]!=1){
			flg[4]=1;
			min++; max++;
		}
		if(a[i]>=2000&&a[i]<=2399&&flg[5]!=1){
			flg[5]=1;
			min++; max++;
		}
		if(a[i]>=2400&&a[i]<=2799&&flg[6]!=1){
			flg[6]=1;
			min++; max++;
		}
		if(a[i]>=2800&&a[i]<=3199&&flg[7]!=1){
			flg[7]=1;
			min++; max++;
		}
		if(a[i]>=3200) max++;
	}
	if(min==0) min=1;
	cout<<min<<' '<<max<<endl;
	return 0;
}

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

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(ReadLine());
        }

        public static long[] Reads()
        {
            return ReadLine().Split().Select(long.Parse).ToArray();
        }


        public static long gcd(long x,long y)
        {
            if (y < x) gcd(y, x);
            while (y != 0)
            {
                var z = x % y;
                x = y;
                y = z;
            }
            return x;
        }

        public static long C(long n,long k)
        {
            long x=1;
            for (long i = 1; i <=k; i++)
            {
                x *= n - i + 1;
                x /= i;
            }
            return x;
        }
        static void Main(string[] args)
        {
            var sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var n = Read();
            var a = new long[n+2];
            a[0] = 0;
            var q = Reads();
            for (int i = 1; i < n+1; i++)
            {
                a[i] = q[i - 1];
            }
            a[n + 1] = 0;
            long ans = 0;
            for (int i = 0; i < n+1; i++)
            {
                ans += Math.Abs(a[i + 1] - a[i]);
            }
            for (int i = 1; i < n+1; i++)
            {
                long memo = ans;
                memo += Math.Abs(a[i - 1] - a[i + 1]) - Math.Abs(a[i - 1] - a[i]) - Math.Abs(a[i + 1] - a[i]);
                WriteLine(memo);
            }
            

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 31360
import java.util.Scanner;
fun main(args: Array<String>) {
  var sc=Scanner(System.`in`)
  var s=sc.next()
  var t=sc.next()
  var i=0
  var c=0
  while(i<3){
    if(s[i]==t[i]){
      c++
    }
    i++
  }
  println(c)
}

Measured memory_bytes: 29352
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    //i =  1, 2, 3
    //P =  2, 3, 1
    ll n;
    cin >> n;
    cout << n*(n-1)/2 << endl;
    return 0;
}



Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007ll
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define db(x) cout << #x << " = " << x << '\n'
#define sep cout << "********************************************\n"
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL)
int main(int argc, char const *argv[])
{
	fast;
	ll n, m;
	cin >> n >> m;
	vll ac(n, 0), wa(n, 0);
	for (int i = 0; i < m; ++i)
	{
		ll id;
		string vd;
		cin >> id >> vd;
		id --;
		if (vd == "AC")
		{
			ac[id] = 1;
		}
		else
		{
			if (ac[id] == 0)
				wa[id] ++;
		}
	}
	ll r  = 0, w = 0;
	for (int i = 0; i < n; ++i)
	{
		if (ac[i])
		{
			r ++;
			w += wa[i];
		}
	}
	cout << r << ' ' << w;
	return 0;
}

Measured memory_bytes: 1792
using System;
using System.Linq;
class Dice
{
    public  int [,] cube;
    
    
    public Dice(int [] s)
    {
        cube=new int [6,5]
        {
            {s[0],s[3],s[1],s[2],s[4]},
            {s[1],s[3],s[5],s[2],s[0]},
            {s[2],s[4],s[0],s[1],s[5]},
            {s[3],s[5],s[1],s[0],s[4]},
            {s[4],s[3],s[0],s[2],s[5]},
            {s[5],s[2],s[1],s[3],s[4]}
        };
    }
    
}


public class Hello{
    public static void Main(){
        string[] str=Console.ReadLine().Split(' ');
        int [] saikoro=str.Select(int.Parse).ToArray();
        Dice d=new Dice(saikoro);
        
        int kaisu =int.Parse(Console.ReadLine());
        for(int i=0;i<kaisu;i++)
        {
            str=Console.ReadLine().Split(' ');
            int ue=int.Parse(str[0]);
            int mae=int.Parse(str[1]);
            
            for(int j=0;j<6;j++)
            {
                if(d.cube[j,0]==ue)
                {
                    for(int w=1;w<5;w++)
                    {
                        if(d.cube[j,w]==mae)
                        {
                            if(w==4)Console.WriteLine(d.cube[j,1]);
                            else Console.WriteLine(d.cube[j,w+1]);
                        }
                    }
                }
            }
        }
    }
}


Measured memory_bytes: 16380
#include <iostream>
#include <string>
#include <utility>
#include <vector>
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<string> a(N);
	cout << 0 << endl;
	cin >> a.front();
	cout << N - 1 << endl;
	cin >> a.back();
	if (a.front() != "Vacant" && a.back() != "Vacant") {
		pair<int, int> b{ 0, N };
		while (true) {
			cout << (b.first + b.second) / 2 << endl;
			cin >> a[(b.first + b.second) / 2];
			if (a[(b.first + b.second) / 2] == "Vacant") break;
			if (a[b.first] == a[(b.first + b.second) / 2]) {
				if (((b.first + b.second) / 2 - b.first) % 2) b.second = (b.first + b.second) / 2;
				else b.first = (b.first + b.second) / 2;
			}
			else {
				if (((b.first + b.second) / 2 - b.first) % 2) b.first = (b.first + b.second) / 2;
				else b.second = (b.first + b.second) / 2;
			}
		}
	}
}

Measured memory_bytes: 1620
using System;
using System.Collections.Generic;
using System.Linq;
using static AtCoder.Io;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var s = ReadString();
            var replased = s.Replace("eraser", "").Replace("erase", "").Replace("dreamer", "").Replace("dream", "");
            Console.WriteLine(replased == "" ? "YES" : "NO");
        }
    }

    public static class Io
    {
        public static string ReadString() => Console.ReadLine();
        public static string[] ReadStringArray() => ReadString().Split(' ');
        public static int ReadInt() => int.Parse(ReadString());
        public static long ReadLong() => long.Parse(ReadString());
        public static int[] ReadIntArray() => ReadStringArray().ParseInt().ToArray();
        public static long[] ReadLongArray() => ReadStringArray().ParseLong().ToArray();
        public static IEnumerable<int> ParseInt(this IEnumerable<string> source) => source.Select(int.Parse);
        public static IEnumerable<long> ParseLong(this IEnumerable<string> source) => source.Select(long.Parse);
    }
}


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

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  vector<int> d(3);
  d.at(0) = A;
  d.at(1) = B;
  d.at(2) = C;
  sort(d.begin(),d.end());
  cout << d.at(2)*10+d.at(1)+d.at(0) << endl;
}

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

int main()
{

  int a,b,c,d = 0;
  for(int i=1; i>0;){
    cin >> a >> b;
    if(a == 0 && b == 0){
      break;
    }
    else{
    if(a < b){
      cout << a << " " << b << endl;
    }
    else{
      cout << b << " " << a << endl;
    }
    }
  }
}
      

Measured memory_bytes: 1160
macro_rules! scan_sub {
    ( $itr:ident, $t:ty ) => {
        let mut buf = String::new();
        let $itr = {
            while buf.trim().len() == 0 {
                buf = String::new();
                std::io::stdin().read_line(&mut buf).unwrap();
            }
            buf.split_whitespace().map(|n| n.parse::<$t>().unwrap())
        };
    };
}

macro_rules! scan {
    ( $x:ident; Vec<$t:ty> ) => {
        scan_sub!(itr, $t);
        let $x = itr.collect::<Vec<_>>();
    };
    ( $( $x:ident ),*; $t:ty ) => {
        scan_sub!(itr, $t);
        let mut itr = itr;
        $(
            let $x = itr.next().unwrap();
        )*
    };
}

fn main() {
    scan!(l; f64);
    let t: f64 = l / 3.0;

    println!("{}", t * t * t);
}


Measured memory_bytes: 4352
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000


int main() {
	char a[N][20];
	f(i, N) {
		f(j, 20)a[i][j] = 0;
	}
	int n, k;
	int x, y, z, w;
	long long s, ans;
	bool v = true;
	ans = 0;
	scanf("%d", &n);
	f(i, n)scanf("%s", a[i]);
	x = 0;
	y = 0;
	z = 0;
	f(i, n) {
		k = strlen(a[i]);
		if (a[i][0] == 'B'&&a[i][k - 1] == 'A')z++;
		else if (a[i][0] == 'B')x++;
		else if (a[i][k - 1] == 'A')y++;
		f(j, k - 1) {
			if (a[i][j] == 'A'&&a[i][j + 1] == 'B')ans++;
		}
	}
	if (x == 0 && y == 0&&z>0)ans += (z - 1);
	else ans += min(x + z, y + z);
	printf("%lld\n", ans);
	return 0;
}


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

int main() {
	int n, k, q;
	std::cin >> n >> k >> q;
	std::vector<int> a(n, 0);
	for (int i = 0; i < q; i++) {
		int p;
		std::cin >> p;
		a[p - 1]++;
	}
	for (int i = 0; i < n; i++) {
		if (a[i] > q - k) {
			std::cout << "Yes" << "\n";
		} else {
			std::cout << "No" << "\n";
		}
	}
	return 0;
}

Measured memory_bytes: 3760
#include<stdio.h>

int main(){
  int a, b;
  char op;
  int ans;

  while(1){
    scanf("%d %c %d", &a, &op, &b);

    if(op == '?'){
      break;
    }

    if(op == '+'){
      ans = a + b;
    }
    else if(op == '-'){
      ans = a - b;
    }
    else if(op == '*'){
      ans = a * b;
    }
    else if(op == '/'){
      ans = a / b;
    }
    printf("%d\n", ans);
  }
  
  return 0;
}



Measured memory_bytes: 2036
# n, l = list(map(int, input().split()))
o = input()
e = input()

ans = [""] * (len(o) + len(e))
ans[0] = "a"

for i in range(len(e)):
    ans[i*2] = o[i]
    ans[i*2+1] = e[i]

if len(o) != len(e):
    ans[len(e)*2] = o[len(o)-1]

print("".join(ans))


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

using namespace std;

int main() {
	int N;
	vector<int> A,B, C;
	cin >> N;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		A.push_back(a);
	}
	for (int i = 0; i < N; i++) {
		int b;
		cin >> b;
		B.push_back(b);
	}
	for (int i = 0; i < N-1; i++) {
		int c;
		cin >>c;
		C.push_back(c);
	}
	int ans;
	int before = A[0];
	ans = B[A[0]-1];
	for (int i = 1; i < N; i++) {
		if (before == A[i] - 1) {
			ans += B[A[i] - 1] + C[before-1];
		}else{
			ans += B[A[i] - 1];
		}
		before = A[i];
	}
	cout << ans;

	return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        int[] arr = Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();
        int a = arr[0];
        int b = arr[1];
        double a_min = arr[0] / 0.08;
        double b_min = arr[1] / 0.1;
        double a_max = (arr[0] + 1) / 0.08;
        double b_max = (arr[1] + 1) / 0.1;
        int ans = -1;
        for (int i = Math.Min((int)a_min, (int)b_min); i <= Math.Max((int)a_max, (int)b_max) ; i++)
        {
            if(a_min <= i && i < a_max && b_min <= i && i < b_max)
            {
                ans = i;
                break;
            }
        }
        Console.WriteLine(ans);

    }


}





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

int main(){
  int ans=0;
  int n;
  cin >> n;
  vector<int> a(120,0);
  for(int i=1;i<=n;i++){
    cin >> a[i];
  }
  
  for(int i=1;i<=n;i++){
    if(i%2==1&&a[i]%2==1) ans++;
  }
  
  cout << ans << endl;
}



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

using namespace std;

int main(void)
{
    int ref_count;
    int oven_count;
    int discount_count;

    vector<int> ref_prices;
    vector<int> oven_prices;

    int lowest;

    cin >> ref_count >> oven_count >> discount_count;

    for(int i = 0; i < ref_count; i++){
        int rp;
        cin >> rp;
        ref_prices.push_back(rp);
    }
    for(int i = 0; i < oven_count; i++){
        int op;
        cin >> op;
        oven_prices.push_back(op);
    }

    int ref_lowest = ref_prices[0];
    for(auto itr = ref_prices.begin(); itr != ref_prices.end(); itr++){
        if(ref_lowest > *itr){
            ref_lowest = *itr;
        }
    }

    int oven_lowest = oven_prices[0];
    for(auto itr = oven_prices.begin(); itr != oven_prices.end(); itr++){
        if(oven_lowest > *itr){
            oven_lowest = *itr;
        }
    }
    lowest = ref_lowest + oven_lowest;

    for(int i = 0; i < discount_count; i++){
        int ref_index;
        int oven_index;
        int discount;
        cin >> ref_index >> oven_index >> discount;

        int discounted_price = ref_prices[ref_index - 1] + oven_prices[oven_index - 1] - discount;

        if(discounted_price < lowest){
            lowest = discounted_price;
        }
    }

    cout << lowest << endl;

    return 0;
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i, n) for (int i = 0; i < n; i++)

int main()
{
    string s;
    cin >> s;
    if (s.length() == 2) {
        cout << s << "\n";
    } else {
        reverse(s.begin(), s.end());
        cout << s << "\n";
    }
}

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

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define mp make_pair
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

vector<vector<int> > a;
int N, M, X;

void dfs(int res, vector<int> v) {
  if (res == N)
    a.pb(v);
  else {
      v.pb(res);
      dfs(res+1, v);
      v.pop_back();
      dfs(res+1, v);
  }
}

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

  cin >> N >> M >> X;
  vector<int> C(N);
  vector<vector<int> > A(N, vector<int>(M));
  vector<int> s;
  rep (i, N) {
    cin >> C[i];
    rep (j, M) {
      cin >> A[i][j];
    }
  }
  dfs(0, s);
  int ans = INF;
  rep (i, a.size()-1) {
    int sum = 0;
    bool flag = true;
    vector<int> sum1(M, 0);
    rep (j, a[i].size()) {
      sum += C[a[i][j]];
      rep(k, M) {
        sum1[k] += A[a[i][j]][k];
        if (j == a[i].size()-1) {
          // cout << sum1[k] << ' ';
          if (sum1[k] < X) {
            flag = false;
          }
        }
        // cout << sum1[k] << ' ';
      }
      // cout << endl;
      // cout << sum;
      // cout << endl;
    }
    if (flag)
      ans = min(ans, sum);
      // cout << ans  << ' '<< sum << endl;
  }
  if (ans < INF)
    cout << ans << endl;
  else
    cout << "-1" << endl;
  // rep(i, a.size()) {
  //   rep(j, a[i].size())
  //     cout << a[i][j] << ' ';
  //   cout << endl;
  // }
  // cout << a.size() << endl;
}


Measured memory_bytes: 3924
#include<stdio.h>
int main(){

  int a[100],i,n;

  scanf("%d",&n);

  for( i = 0; i < n; i++ ){
    scanf("%d",&a[i]);
  }

  for( i = n-1; i >= 0; i-- ){
    
    printf("%d",a[i]);
    if(i!=0)printf(" ");
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int[] arr = new int[5];
		int minIndex = 0;
		int ans = 0;
		for (int i = 0; i < 5; i++) {
			arr[i] = reader.nextInt();
			if (arr[minIndex] % 10 > arr[i] % 10 && arr[i] % 10 != 0 || arr[minIndex] % 10 == 0) {
				minIndex = i;
			}
		}
		for (int i = 0; i < 5; i++) {
			if (i == minIndex || arr[i] % 10 == 0) {
				ans += arr[i];
			} else {
				ans += arr[i] / 10 * 10 + 10;
			}
		}

		System.out.print(ans);
		reader.close();
	}
}





Measured memory_bytes: 21972
#include<iostream>
#include<algorithm>
#include <vector>
#include<cmath>
#include<cstdio>

using namespace std;
vector<pair<double, double> > v(51);
int main(void){
    int n;
    for(int __i = 1;cin >> n, n; __i++){
        for(int i = 0; i < n; i++){
            double a, b;
            cin >> a >> b;
            v[i] = make_pair(a, b);
        }
        v[n] = v[0];
        double area = 0;
        for(int i = 0;i < n; i++){
            area += v[i].first * v[i + 1].second - v[i + 1].first * v[i].second;
        }
        area = fabs(area)/2;
        printf("%d %.1f\n", __i, area);
    }
    return 0;
}

Measured memory_bytes: 3152
import java.util.*;

fun main(){
  val sc = Scanner(System.`in`)
  val n = Integer.parseInt(sc.next())
  val m = Integer.parseInt(sc.next())
  val k = Integer.parseInt(sc.next())
  var num = 0
  for (i in 0..n){
    for (j in 0..m){
      num = i*m+j*n-2*i*j;
      if(num==k){
        println("Yes")
        return
      }
    }
  }
  println("No")
  
}

Measured memory_bytes: 35980
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

int main() {
	int H, W;
	cin >> H >> W;

	vector<string> v(H);
	for (int i = 0; i < H; i++) cin >> v[i];

	vector<vector<int>> L(H, vector<int>(W)), R(H, vector<int>(W)),
		U(H, vector<int>(W)), D(H, vector<int>(W));

	for (int i = 0; i < H; i++) {
		int c = 0;
		for (int j = 0; j < W; j++) {
			char ch = v[i][j];
			if (ch == '#') c = 0;
			else c++;
			L[i][j] = c;
		}
	}

	for (int i = 0; i < H; i++) {
		int c = 0;
		for (int j = W - 1; j >= 0; j--) {
			char ch = v[i][j];
			if (ch == '#') c = 0;
			else c++;
			R[i][j] = c;
		}
	}

	for (int i = 0; i < W; i++) {
		int c = 0;
		for (int j = 0; j < H; j++) {
			char ch = v[j][i];
			if (ch == '#') c = 0;
			else c++;
			U[j][i] = c;
		}
	}

	for (int i = 0; i < W; i++) {
		int c = 0;
		for (int j = H - 1; j >= 0; j--) {
			char ch = v[j][i];
			if (ch == '#') c = 0;
			else c++;
			D[j][i] = c;
		}
	}

	int ret = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			int n = L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3;
			ret = max(ret, n);
		}
	}

	cout << ret << endl;
}

Measured memory_bytes: 73692
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cmath>
#include <cstdlib>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
#define ALL(x) x.begin(), x.end()
#define INF (1001000000)
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i:c)
#define EXIST(cs,v) (find(ALL(cs),(v))!=cs.end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define UNIQ(c) (c).erase(unique((c).begin(),(c).end()), (c).end());
#define P(p) cout<<(p)<<endl;

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

    int n;
    cin >> n;

    for(int i = 111; i <= 999; i+=111) {
        if (i >= n) {
            P(i);
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 256
q, h, s, d=map(int, raw_input().split())
n=input()*4
h=min(h, q*2)
s=min(s, h*2)
d=min(d, s*2)
result=n/8*d
n-=n/8*8
result+=n/4*s
n-=n/4*4
result+=n/2*h
n-=n/2*2
result+=n*q
print result

Measured memory_bytes: 2692
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        char[] N = new char[100];
        int M = in.read(N, 0, N.length);
        int K = in.i();
        out.println(solve(0, K, N, M, false));
    }

    static int solve(int i, int k, char[] N, int M, boolean mode) {
        if (M < i + k) return 0;
        if (k == 0) return 1;
        else if (mode) return 9 * solve(i + 1, k - 1, N, M, true) + solve(i + 1, k, N, M, true);
        else if (N[i] == '0') return solve(i + 1, k, N, M, false);
        else return (N[i] - '1') * solve(i + 1, k - 1, N, M, true) + solve(i + 1, k, N, M, true) + solve(i + 1, k - 1, N, M, false);
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    void back() {
        head--;
    }

    boolean minus() {
        boolean minus;
        while (true) {
            char c = next();
            if (!isDelimiter(c)) {
                if (!(minus = c == '-')) back();
                return minus;
            }
        }
    }

    void skip() {
        while (isDelimiter(next()));
        back();
    }

    char[] s(int N) {
        char[] cbuf = new char[N];
        read(cbuf, 0, N);
        return cbuf;
    }

    public int read(char[] cbuf, int off, int len) {
        skip();
        int i;
        for (i = 0; i < cbuf.length; i++) {
            char c = next();
            if (isDelimiter(c)) {
                break;
            }
            cbuf[i] = c;
        }
        return i;
    }

    boolean isDelimiter(char c) {
        return c == ' ' || c == '\n' || c == '\r';
    }

    int i() {
        boolean minus = minus();
        int n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        boolean minus = minus();
        long n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }
}


Measured memory_bytes: 32684
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
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; }
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    fastcin();

    LL t1, t2;
    cin >> t1 >> t2;
    LL a1, a2, b1, b2;
    cin >> a1 >> a2 >> b1 >> b2;
    if(b1 > a1){
        swap(a1, b1);
        swap(a2, b2);
    }

    if(a1*t1+a2*t2 == b1*t1+b2*t2){
        cout << "infinity" << endl;
        return 0;
    }

    LL d1 = a1*t1 - b1*t1;
    LL d2 = d1 + a2*t2 - b2*t2;
    d2 *= -1;
    if(d2 < 0){
        cout << 0 << endl;
        return 0;
    }
    cout << (d1/d2) + (d1+d2-1)/d2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>

int n;
int h[100005];
int memo[100005];

int main()
{
    std::cin>>n;
    for(int i=0;i<n;i++) std::cin>>h[i];
    for(int i=0;i<n;i++)memo[i]=-1;
    memo[0]=0;
    for(int i=0;i<n;i++)
    {
        if(memo[i+1]==-1)memo[i+1]=abs(h[i]-h[i+1])+memo[i];
        else
        {
            if(memo[i+1]>abs(h[i]-h[i+1])+memo[i])memo[i+1]=abs(h[i]-h[i+1])+memo[i];
        }
        if(memo[i+2]==-1)memo[i+2]=abs(h[i]-h[i+2])+memo[i];
        else
        {
            if(memo[i+2]>abs(h[i]-h[i+2])+memo[i])memo[i+2]=abs(h[i]-h[i+2])+memo[i];
        }
    }
    printf("%d\n",memo[n-1]);
}

Measured memory_bytes: 4492
import java.util.*;

public class Main {
    private class Data {
        int src, dst;

        public Data(int src, int dst) {
            this.src = src;
            this.dst = dst;
        }
    }

    public void main(Scanner sc) {
        int n = sc.nextInt();
        int m = sc.nextInt();
        Data data[] = new Data[m];
        for (int i = 0; i < m; i++) {
            data[i] = new Data(sc.nextInt(), sc.nextInt());
        }

        Arrays.sort(data, (o1, o2) -> o1.dst - o2.dst);

        int ans = 0;
        Data tmp = new Data(0, 0);
        for (int i = 0; i < m; i++) {
            if (!(data[i].src <= tmp.src && tmp.dst <= data[i].dst)) {
                ans++;
                tmp = new Data(data[i].dst - 1, data[i].dst);
            }
        }

        System.out.println(ans);
    }

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


Measured memory_bytes: 91036
n = int(input())
p = list(map(int, input().split()))
lis = [0] * (n + 1)
for i in range(n):
    lis[p[i]] = i
l = list(range(-1, n - 1)) + [-1, -1]
r = list(range(1, n + 1)) + [n, n]
ans = 0
for i in range(n):
    ans += (i + 1) * ((lis[i + 1] - l[lis[i + 1]]) * (r[r[lis[i + 1]]] - r[lis[i + 1]]) + (l[lis[i + 1]] - l[l[lis[i + 1]]]) * (r[lis[i + 1]] - lis[i + 1]))
    r[l[lis[i + 1]]] = r[lis[i + 1]]
    l[r[lis[i + 1]]] = l[lis[i + 1]]
print(ans)

Measured memory_bytes: 25412
n = int(input())
list_A = list(map(int, input().split()))
m = pow(10, 10)
s = 0
cnt = 1

for a in list_A:
    m = min(m, abs(a))
    if a < 0:
        cnt *= -1
    s += abs(a)

if cnt == 1:
    print(s)
else:
    print(s - 2 * m)

Measured memory_bytes: 20028
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")
#pragma GCC optimize("Os")
#pragma GCC target("avx2,fma")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("Os")
*/
#include <bits/stdc++.h>

typedef long long ll;
typedef long double ld; 

#define X first
#define Y second
#define MP make_pair

using namespace std;
    
const int N = 2e3 + 123;
const ll mod = 1e9 + 7;
const ll INF = 1e18;

int n, m;
int a[N][N], b[N][N], c[N][N];

int main () {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int n, m;
	cin >> n >> m;
	for(int i = 1;i <= n;i++){
		a[i][1] = 1;
		b[i][m] = 1;
		if(i & 1){
			for(int j = 1;j <= m - 1;j++){
				a[i][j] = 1;
			}
		}
		else{
		    for(int j = 2;j <= m;j++){
		    	b[i][j] = 1;
		    }
		}
	}

	for(int i = 1;i <= n;i++){
		for(int j = 1;j <= m;j++){
			char x;
			cin >> x;
			if(x == '#'){
				if(j == m){
					a[i][j] = '#';
				}
				else if(j == 1){
					b[i][1] = '#';
				}
				else{
					if(i % 2 == 0){
						a[i][j] = '#';
					}
					else{
						b[i][j] = '#';
					}
				}
			}
		}
	}

	for(int i = 1;i <= n;i++){
		for(int j = 1;j <= m;j++){
			if(a[i][j])
				cout << "#";
			else
				cout << ".";
		}
		cout << "\n";
	}
	cout << "\n";

	for(int i = 1;i <= n;i++){
		for(int j = 1;j <= m;j++){
			if(b[i][j])
				cout << "#";
			else
				cout << ".";
		}
		cout << "\n";
	}
	cout << "\n";

	return 0;
}

Measured memory_bytes: 13056
#include<stdio.h>
#include<string.h>
int main(void){
  int ns=0,we=0;
  char s[1001];
  scanf("%s",s);
  if(strchr(s,'N'))ns++;
  if(strchr(s,'S'))ns++;
  if(strchr(s,'W'))we++;
  if(strchr(s,'E'))we++;
  puts(ns%2+we%2?"No":"Yes");
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int nax = 1e9+7;
#define fo(i,a,b) for(int i = int(a); i <= int(b); i++)

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    string s, t;
    cin >> s >> t;
    int change = t.length();
    for(int i = 0; i + (int)t.length() < (int)s.length() + 1; i++) {
        string x = s.substr(i, (int)t.length());
        int counter = 0;
        for(int j = 0; j < (int)t.length(); j++) {
            if(x[j] != t[j]) {
                counter++;
            }
        }
        debug(x, t, counter);
        change = min(change, counter);
    }
    cout << change << endl;

    
    return 0;
}


Measured memory_bytes: 3640
import sys


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

def main():
    n = int(input())
    p = list(map(int, input().split()))
    count = 0
    for i in range(n):
        if p[i] != i+1:
            count += 1
            if count == 3:
                print("NO")
                return
    if count == 2 or count == 0:
        print("YES")
        return
    print("NO")
        
        
    
main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*invkaijo[a-b]%mod*invkaijo[b]%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
int n,d,ans;
string s;
int p[110];
void func(int i,int D,int ret){
    if(i==(n+1)/2-1){
        if(D==0){
            if(n%2)ret*=10;
            ans+=ret;
        }
        return;
    }
    {
        //+
        int m=(D+INF)%10;
        int cnt=10-m;
        if(i==n-1)cnt--;
        func(i-1,(D-p[i]*m)/10,ret*cnt);
    }
    {
        //-
        if((D+INF)%10==0)return;
        int m=10-(D+INF)%10;
        int cnt=10-m;
        //if(i==n-1)cnt--;
        func(i-1,(D+p[i]*m)/10,ret*cnt);
    }
}
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>d;
    if(d%9){
        puts("0");
        return 0;
    }
    d/=9;
    for(n=2;n<=18;n++){
        fill(p,p+17,0);
        p[(n+1)/2]=(n%2?11:1);
        for(int i=(n+1)/2+1;i<n;i++)p[i]=(p[i-1]*10+1)*10+1;
        func(n-1,d,1);
        //cout<<d<<" "<<ans<<endl;
        /*if(n==5){
            cout<<p[n-3]<<" "<<p[n-2]<<" "<<p[n-1]<<endl;
        }*/
    }
    cout<<ans<<endl;
    return 0;
}


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


int main()
{
	long int n, i;

	scanf("%ld", &n);

	long int min = n, min_new;

	for (i = 1; i*i <= n; i++)
	{
		if (n%i == 0)
		{
			min_new = i + (n / i) - 2;
			
			if (min_new < min)
			{
				min = min_new;
			}
		}
	}

	printf("%ld\n", min);

	system("pause");

	return 0;
}


Measured memory_bytes: 376
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<iomanip>
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;
typedef long long ll;
typedef double Def;
typedef pair<Def,string> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<string> vs;
Def inf = sizeof(Def) == sizeof(ll) ? 2e18:1e9+10;
int main(){
	int n;
	while(cin>>n,n){
		vp in(n);
		rep(i,n){
			string S;cin>>S;
			double a,b,c,d,e,f,s,m,p;
			cin>>p>>a>>b>>c>>d>>e>>f>>s>>m;
			double t=(m*f*s-p)/((a+b+c+d+e)+(m-1)*(d+e));
			in[i]={-t,S};
		}
		sort(all(in));
		rep(i,n)cout<<in[i].second<<endl;
		cout<<"#"<<endl;
	}
}


Measured memory_bytes: 3240
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);

        int n, x, x1, x2, x3;
        int counter;
        while(true){
            counter = 0;
            n = scanner.nextInt();
            x = scanner.nextInt();
            if(n == 0 && x == 0)break;
            for(int i = 1; i <= n; i++){
                x1 = x;
                x1 -= i;
                if(x1 > 1){
                    for(int j = i+1; j <= n; j++){
                        x2 = x1;
                        x2 -= j;
                        if(x2 > 0){
                            for(int k = j+1; k <= n; k++){
                                x3 = x2;
                                x3 -= k;
                                if(x3 == 0)counter++;
                            }
                        }
                    }
                }
            }
            System.out.println(counter);
        }
    }
}



Measured memory_bytes: 26520
#include <map>
#include <iostream>
#include <string>

using namespace std;

int main(){
  map<string, int> mp;
  int N, M, i;
  string s;
  cin >> N;
  for(i=0;i<N;i++){
    cin >> s;
    auto itr = mp.find(s);
    if(itr != mp.end()){
      mp[s]++;
    }
    else{
      mp[s] = 1;
    }
  }
  cin >> M;
  for(i=0;i<M;i++){
    cin >> s;
    auto itr = mp.find(s);
    if(itr != mp.end()){
      if(mp[s]>0) mp[s]--;
    }
  }
  int ans = 0;
  for(auto itr = mp.begin(); itr != mp.end(); ++itr){
    if(itr->second>ans) ans = itr->second;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
        int n,m,s;
        scanf("%d",&n);
        m=n;
        s=n%10;
        while(n!=0){
                n/=10;
                s+=n%10;
        }
        if(m%s==0) printf("Yes\n");
        else printf("No\n");
        return 0;
}


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


using lli = long long int;
template <class T> using Vec = std::vector<T>;
template <class T> using Wec = std::vector<Vec<T>>;


int main(void){
    int n; scanf("%d", &n);
    Vec<int> A(n); for(int i = 0; i < n; ++i) scanf("%d", &A[i]);
    int cnt = 0;
    int idx = 0;
    while(idx < n){
        while(idx + 1 < n and A[idx + 1] == A[idx]) idx++;
        if(idx + 1 >= n){cnt++; break;}
        if(A[idx+1] > A[idx]) while(idx + 1 < n and A[idx+1] >= A[idx]) idx++;
        else while(idx + 1 < n and A[idx+1] <= A[idx]) idx++;
        cnt++; idx++;
    }
    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int k, N;
  cin >> k >> N;
  
  vector<int> a(N);
  for(int i = 0; i < N; i++){
    cin >> a.at(i);
  }
  
  priority_queue<int> dis;
  for(int i = 0; i < N; i++){
    if(i == 0){
      dis.push(a.at(0) + k - a.at(N-1));
    }
    else{
      dis.push(a.at(i) - a.at(i-1));
    }
  }
/*  
  for(int i = 0; i < N; i++){
    cout << dis.top() << " ";
    dis.pop();
  }
  cout << endl;
*/  
  cout << k - dis.top() << endl;
}

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

int main(){
    constexpr long MOD = 1000000007;
    long N, X;
    cin >> N >> X;
    vector<long> S(N);
    for(auto& i : S)cin >> i;
    sort(S.begin(), S.end());
    vector<long> v(X + 1), u(X + 1);
    iota(v.begin(), v.begin() + *S.begin(), 0L);
    long cnt{0};
    for(const auto& i : S) {
        transform(v.begin(), v.end(), u.begin(), [&cnt](auto a) { return a * cnt; });
        ++cnt;
        for (unsigned long j = 0, k = 0; j <= X; ++j) {
            u[j] += v[k];
            if (++k == i)k = 0;
        }
        for (auto &j : u)j %= MOD;
        swap(u, v);
    }
    cout << v.back() << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <set>

using namespace std;

int main() {
  int s;
  set<int> se;
  cin >> s;
  for (int i = 1; i <= 1000000; ++i) {
    if (se.count(s)) {
      cout << i << endl;
      return 0;
    }
    se.insert(s);
    s = s % 2 ? s * 3 + 1 : s / 2;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<int,int>
#define PI 3.141592653589793
const int INF = 1001001001;
const ll MX = 1e18;
const int mod = 1000000007;

int main() {
	int n;
	cin >> n;
	int q;
	cin >> q;
	if((n+q)%2==1) cout<<"IMPOSSIBLE"<<endl;
  	else cout<<(n+q)/2<<endl;
}

Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;

int main()
{
    vector<int> nums(3);
    for (int i = 0; i < 3; i++)
        cin >> nums.at(i);
    int K;
    cin >> K;

    sort(nums.begin(), nums.end());
    for (int i = 0; i < K; i++)
    {
        nums.at(2) *= 2;
    }

    cout << nums.at(0) + nums.at(1) + nums.at(2) << endl;
}

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

string temp;
vector<char> ans;

int main()
{
	cin >> temp;
	int len = temp.size();
	for(int i = 0; i < len; ++i)
	{
		if(temp[i] == 'B')
		{
			if(ans.size())
				ans.pop_back();
			else 
				continue;
		}
		else 
			ans.push_back(temp[i]);
	}
	for(int i = 0; i < ans.size(); ++i)
		cout << ans[i];
	cout << endl;
}

Measured memory_bytes: 256