akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<algorithm> 
#define N 123456
using namespace std;
int n,a[N],ans;
int main()
{
	scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	for(int i=1;i<=n;i++)
		if(a[i] == a[i-1]) ans++;
	if(ans & 1) ans++;
	printf("%d\n",n-ans);
	return 0;
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template <typename P, typename Q>
ostream& operator<<(ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T> v)
{
  os << "(";
  each (i, v)
    os << i << ",";
  os << ")";
  return os;
}

int main(int argc, char* argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n, x;
  while (cin >> n >> x) {
    vector<int> v(n);
    each (i, v)
      cin >> i;
    sort(v.begin(), v.end());
    if (n == 1) {
      cout << abs(v[0] - x) << endl;
      continue;
    }
    int a = v[1] - v[0];
    for (int i = 1; i < v.size(); ++i) {
      a = __gcd(a, v[i] - v[0]);
    }
    int mx = 0;
    each (i, v) {
      mx = max(mx, __gcd(a, abs(x - i)));
    }
    cout << mx << endl;
  }

  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
int main(void){
  char s1[11];
  char s2[11];
  char s3[11];
  scanf("%s %s %s",s1,s2,s3);
  printf("%c%c%c",s1[0] - 'a'+'A',s2[0] - 'a'+'A',s3[0] - 'a'+'A');
}


Measured memory_bytes: 256
public class Main {
	public static void main(String[] args){
		Toi junbi = new Junbi1();
		junbi.solve();
	}
}

interface Toi{
	public void solve();
}

class Junbi1 implements Toi{
	public void solve(){
		for (int i = 1; i <= 9; i++) {
			for (int j = 1; j <= 9; j++) {
				System.out.println(i + "x" + j + "=" + i * j);
			}
		}
	}
}


Measured memory_bytes: 24196
#include <bits/stdc++.h>
using namespace std;
using ll= long long ;
using P = pair<ll,ll>;
#define rep(i,n) for (ll i = 0; i<(ll)(n); i++)
#define mod 1000000007
#define pi 3.141592653589793
typedef vector<ll> vcl;

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a, ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t =rep_jijo(n,x/2);
        return t*t%mod;
  }
  return n*rep_jijo(n,x-1)%mod;
}
ll c2(ll n){
    return n*(n-1)/2;
}

int main() {
ll n;
cin>>n;
vector<ll>a(n);
rep(i,n)cin>>a[i];
rep(i,n)a[i]--;
vector<ll>cnt(n);
rep(i,n)cnt[a[i]]++;

ll total;
rep(i,n)total +=c2(cnt[i]);
ll ans=0;
rep(i,n){
    ans=total;
    ans-=c2(cnt[a[i]]);
    ans+=c2(cnt[a[i]]-1);
    cout<<ans<<endl;
}
return 0;
}



Measured memory_bytes: 5760
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define INF 0x3f3f3f3f
using namespace std;
void close(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
}
const int maxn=2e5+5;
int a[maxn];
int n;
int main(){
	close();
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	int t=a[0];
	int cnt=1;
	for(int i=1;i<n;i++){
		if(a[i]<=t){
			cnt++;
			t=a[i]; 
		}
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <vector>
#include <algorithm>

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

using namespace std;

typedef vector<int> S;

S a(S s){
    return {s[1], s[5], s[2], s[3], s[0], s[4]};
}

S b(S s){
    return {s[0], s[3], s[1], s[4], s[2], s[5]};
}

S s, t;

bool solve(){
    rep(i, 6){
        rep(j, 4){
            if(s == t){
                return true;
            }
            s = a(s);
        }

        if(i <= 2){
            s = b(s);
        }
        if(i == 3){
            s = b(a(b(s)));
        }
        if(i == 4){
            s = b(b(s));
        }
    }
    return false;
}

int main(){
    s.resize(6);
    t.resize(6);
    rep(i, 6){
        scanf("%d", &s[i]);
    }
    rep(i, 6){
        scanf("%d", &t[i]);
    }

    printf("%s\n", solve() ? "Yes" : "No");
    return 0;
}



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

double dist(pair<int, int> p1, pair<int, int> p2){
	return 1.0 * sqrt(1.0*((p1.first-p2.first)*(p1.first-p2.first)+ (p1.second-p2.second)*(p1.second - p2.second)));
}

signed main(){
	int n;
	cin >>n;
	vector<pair<int, int> > p(n);
	for(int i=0; i< n; ++i){
		cin >> p[i].first >> p[i].second;
	}
	
	double u = 1.0; for(int i=1; i<= n; ++i) u *= (1.0*i);
	double ans= 0.0;
	sort(p.begin(), p.end());
	for(int i=0; i<n-1; ++i){
		ans += dist(p[i], p[i+1])/u;
	}
	while(next_permutation(p.begin(), p.end())){
		for(int i=0; i<n-1; ++i){
		 ans += dist(p[i], p[i+1])/u;
		}

	}
	cout << fixed << setprecision(7) <<  ans << "\n";
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

void solve() {
    ll a, b, c;
    cin >> a >> b >> c;
    cout << min(a*b, c) << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


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

int main(){
  string S;
  cin >> S;
  int A=S.size();
  long long sum_all=0;
  for(int bit=0;bit<(1<<(A-1));bit++){
    long long sum=0;
    for(int i=0;i<A-1;i++){
      sum*=10;
      int B=S.at(i)-'0';
      sum+=B;
      if(bit & (1<<i)){
        sum_all+=sum;
        sum=0;
      }
    }
    sum*=10;
    int B=S.at(A-1)-'0';
    sum+=B;
    sum_all+=sum;
  }
  cout << sum_all << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n; cin >> n;
  	int mx = 0, ret = 0;
  	for (int i = 0; i < n; i++) {
    	int x; cin >> x;
      	if (x >= mx) ret++;
      	mx = max(x,mx);
    }
  	cout << ret << endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define _abs(x)((x) < 0 ? (x) * -1 : (x))
#define _max(x, y)(max(0, max((x), (y))))
#define _min(x, y)(max(0, min((x), (y))))
template<typename T> inline bool __max__(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool __min__(T &x, const T &y) { return x > y ? x = y, 1 : 0; }

#define pb push_back
#define mp make_pair

static const ll MOD = 1e9 + 7;

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //freopen("debug.txt", "w", stderr);

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

    string s;

    cin >> s;

    char prev = s[0];
    int n = 1;
    bool isYes = false;

    int i;

    for (i = 1; i < 4; i++) {
        if (prev == s[i]) {
            n++;

            if (3 <= n) isYes = true;
        } else {
            n = 1;
        }

        prev = s[i];
    }

    if (isYes) cout << "Yes" << '\n';
    else cout << "No" << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int Maxs=1e5;
char s[Maxs+5];
int main() {
	#ifdef LOACL
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	scanf("%s",s+1);
	int len=strlen(s+1);
	if(len<2) {
		printf("-1 -1");
		return 0;
	}
	for(int i=2;i<=len;i++) {
		if(s[i]==s[i-1]||s[i-1]==s[i-2]||s[i-2]==s[i]) {
			if(i==2)printf("1 2");
			else printf("%d %d",i-2,i);
			return 0;
		}
	}
	puts("-1 -1");
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <iostream>

using namespace std;

int n;
typedef long long LL;
const int maxn = 1e5 + 5;
LL B, A;
LL h[maxn];
LL a[maxn];

int main(){
    cin >> n;
    cin >> A >> B;
    LL l = 0, r = 0;
    for(int i = 1;i <= n;i++){
        scanf("%lld", &h[i]);
        r = max(r, h[i]);
    }
    while(l < r){
        LL mid = (l + r) / 2;
        LL sum = 0;
        for(int i = 1;i <= n;i++){
            a[i] = h[i];
            a[i] -= mid * B; 
            if(a[i] > 0){
                sum += (a[i] + A - B - 1) / (A - B);
            }
        } 
        if(sum <= mid){
            r = mid;
        }else{
            l = mid + 1;
        }
    }
    cout << l << endl;
    return 0;
}


Measured memory_bytes: 1792
n, m, q = map(int, input().split())
a = [0]*q
b = [0]*q
c = [0]*q
d = [0]*q

A= [1] * n
for i in range(q):
    a[i], b[i], c[i], d[i] = map(int, input().split())

ans = 0
while A[0] <= m:
    tmp = 0
    for i in range(q):
        if (A[b[i]-1] - A[a[i]-1]) == c[i]:
            tmp += d[i]
    if tmp > ans:
        ans = tmp
    
    A[-1] +=1
    for i in range(n-1,0,-1):
        if A[i] == m+1:
            A[i-1] +=1
            for j in range(len(A[i:])):
                A[i+j] = A[i-1]
print(ans)


Measured memory_bytes: 9240
#define _GLIBCXX_DEBUG
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < int(n); ++i)

void solve() {
    int n, a = 0, b = 0;
    string s, t;
    cin >> n;
    rep(i, n) {
        cin >> s >> t;
        if (s > t) {
            a += 3;
        } else if (s < t) {
            b += 3;
        } else {
            a++;
            b++;
        }
    }
    cout << a << " " << b << "\n";
}
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 3120
#include <stdio.h>
#include <math.h>
int mbk(long long a,int n,int m){return n?(mbk((a*a)%m,n/2,m)*(n%2?a:1))%m:1;}
int main(void){
    // Your code here!
    int  i,j,N,K,count;
    int mod = 1e9+7;
    long long sum;
    long long del[100020];
    sum = 0;
    scanf("%d %d",&K,&N);
    for(i=N;i>0;i--){
        count = N/i;
        del[i] = mbk(count,K,mod);
        if(count >1){
        for(j=2;j<=count;j++){
            del[i]= (del[i] + mod - del[i*j] )%mod;
        }
        }
        sum = (sum + mod +( i*del[i]))%mod;
    //printf ("i%d del%d %d\n",i,del[i],sum);
    }
    printf ("%lld",sum);
    return 0;
}

Measured memory_bytes: 2468
/*  -*- coding: utf-8 -*-
 *
 * e.cc: E - Coins Respawn
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 2500;
const int MAX_K = 12;
const int INF = 1 << 30;

/* typedef */

typedef queue<int> qi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;

/* global variables */

vpii nbrs[MAX_N], rnbrs[MAX_N];
bool used[MAX_N];
int cs[MAX_N], ds[MAX_N], prts[MAX_N][MAX_K];

/* subroutines */

bool ancestor(int u, int v) { // true if u is an ancestor of v
  if (ds[u] > ds[v]) return false;
  int d = ds[v] - ds[u];
  for (int k = MAX_K - 1, bk = 1 << k; k >= 0; k--, bk >>= 1)
    if (d & bk) v = prts[v][k];
  return (u == v);
}

/* main */

int main() {
  int n, m, p;
  scanf("%d%d%d", &n, &m, &p);

  for (int i = 0; i < m; i++) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    a--, b--;
    c -= p;
    nbrs[a].push_back(pii(b, c));
    rnbrs[b].push_back(pii(a, c));
  }

  int st = 0, gl = n - 1;
  used[gl] = true;
  qi q;
  q.push(gl);

  while (! q.empty()) {
    int u = q.front(); q.pop();
    vpii &rnbru = rnbrs[u];
    for (vpii::iterator vit = rnbru.begin(); vit != rnbru.end(); vit++) {
      int &v = vit->first;
      if (! used[v]) {
	used[v] = true;
	q.push(v);
      }
    }
  }
  //for (int i = 0; i < n; i++) putchar('0' + used[i]); putchar('\n');

  fill(cs, cs + n, -INF);
  cs[st] = 0;
  ds[st] = 0;
  prts[st][0] = -1;

  priority_queue<pii> pq;
  pq.push(pii(0, st));

  while (! pq.empty()) {
    pii u = pq.top(); pq.pop();
    int &uc = u.first, &ui = u.second;
    if (uc != cs[ui]) continue;

    for (int k = 0; k < MAX_K - 1; k++)
      prts[ui][k + 1] = (prts[ui][k] >= 0) ? prts[prts[ui][k]][k] : -1;
    int vd = ds[ui] + 1;

    vpii &nbru = nbrs[ui];
    for (vpii::iterator vit = nbru.begin(); vit != nbru.end(); vit++) {
      int &vi = vit->first, vc = uc + vit->second;
      if (used[vi]) {
	if (cs[vi] <= -INF) {
	  cs[vi] = vc;
	  ds[vi] = vd;
	  prts[vi][0] = ui;
	  pq.push(pii(vc, vi));
	}
	else if (cs[vi] < vc) {
	  if (ancestor(vi, ui)) {
	    puts("-1");
	    return 0;
	  }
	  cs[vi] = vc;
	  ds[vi] = vd;
	  prts[vi][0] = ui;
	  pq.push(pii(vc, vi));
	}
      }
    }
  }

  printf("%d\n", (cs[gl] > 0) ? cs[gl] : 0);
  return 0;
}


Measured memory_bytes: 768
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int count = 0;
        
        for(int i = A; i <= B; i++){
            String num = Integer.toString(i);
            if(num.charAt(0) == num.charAt(4) && num.charAt(1) == num.charAt(3)) count++;
        }
        System.out.println(count);
    }
}


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

int main() {
  int N;
  cin >> N;
  vector<int>a(N);
  for(int i=0;i<N;i++){
    cin >> a.at(i);
  }
  
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  int alice=0;
  int bob=0;
  for(int i=0;i<N;i++){
    if(i%2==0)
      alice+=a.at(i);
    else
      bob+=a.at(i);
  }
  int k;
  if(alice<bob)
    k=bob-alice;
  else
    k=alice-bob;
  cout << k << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    vector<int> v;
    string s;
    cin>>s;
    int i,d,j,sum=0,cnt,a,b,c;
    for(i=0; i<s.size()-2; i++)
    {

            a=s[i]-48;
            b=s[i+1]-48;
            c=s[i+2]-48;
             sum=a*100+b*10+c;
             //cout<<sum<<endl;
             sum=abs(753-sum);
           v.push_back(sum);

    }
    sort(v.begin(),v.end());
    cout<<v[0]<<endl;



    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <queue>

using namespace std;

priority_queue<int, vector<int>, greater<int> > que;
priority_queue<int> que2;

long long int A1[500000], A2[500000], a[500000];

int main(){
	
	int N;
	
	cin >> N;
	
	for(int i = 0; i < 3 * N; i++){
		cin >> a[i];
	}
	
	long long int sum = 0;
	
	for(int i = 0; i < N; i++){
		A1[i] = 0;
		sum += a[i];
		que.push(a[i]);
	}
	
	A1[N - 1] = sum;
	
	for(int i = N; i < 3 * N; i++){
		if(a[i] > que.top()){
			sum += a[i] - que.top();
			que.pop();
			que.push(a[i]);
		}
		A1[i] = sum;
	}
	
	sum = 0;
	
	for(int i = 3 * N - 1; i >= 2 * N; i--){
		A2[i] = 0;
		sum += a[i];
		que2.push(a[i]);
	}
	
	A2[2 * N] = sum;
	
	for(int i = 2 * N - 1; i >= 0; i--){
		if(a[i] < que2.top()){
			sum += a[i] - que2.top();
			que2.pop();
			que2.push(a[i]);
		}
		A2[i] = sum;
	}
	/*
	for(int i = 0; i < 3 * N; i++){
		cout << A1[i] << " ";
	}
	cout << endl;
	
	for(int i = 0; i < 3 * N; i++){
		cout << A2[i] << " ";
	}
	cout << endl;
	*/
	long long int ans = -1000000000000000000;
	
	for(int i = N - 1; i < 2 * N; i++){
		ans = max(ans, A1[i] - A2[i + 1]);
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 11640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

ll a[8];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  for (int i = 0; i < 7; i++) {
    cin >> a[i];
  }  
  ll tmp = 0;
  tmp += (a[0]/2)*4;
  tmp += (a[3]/2)*4;
  tmp += (a[4]/2)*4;

  if (a[0] && a[3] && a[4]) {
    ll tmp2 = 6;
    tmp2 += ((a[0]-1)/2)*4;
    tmp2 += ((a[3]-1)/2)*4;
    tmp2 += ((a[4]-1)/2)*4;
    tmp = max(tmp, tmp2);
  }
  
  ll ans = a[1]*2 + tmp;
  cout << ans/2 << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=1e5+5;

int n, ans=0;
int a[N];

int32_t main()
{
	IOS;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		ans=__gcd(ans, a[i]);
	}
	cout<<ans;
	return 0;
}


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

const int ALPHABET = 'z' - 'a' + 1;

int main(){
    int n;
    std::cin >> n;
    std::vector<std::vector<int>> alphabet(n, std::vector<int>(ALPHABET, 0));
    for(int i = 0; i < n; i++){
        std::string S;
        std::cin >> S;
        for(int j = 0; j < S.size(); j++){
            alphabet[i][S[j] - 'a']++;
        }
    }

    // 共通しているものを探す
    std::string out;
    for(int j = 0; j < ALPHABET; j++){
        int minCnt = 50 * 50;
        for(int i = 0; i < n; i++){
            minCnt = std::min(minCnt, alphabet[i][j]);
            if(minCnt == 0) break;
        }

        if(minCnt != 0){
            out += std::string(minCnt, 'a' + j);
        }
    }

    if(out.size() > 0){
        std::cout << out << std::endl;
    }else{
        std::cout << std::endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace C_IrohasObsession
{
    class MainClass
    {
        
        public static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(' ');
            var n = int.Parse(inputs[0]);
            var k = int.Parse(inputs[1]);

            var dislikeNumbers = Console.ReadLine().Split(' ').
                Select(s => int.Parse(s)).ToArray();
            var payment = n;

            do
            {
                if (!isIncludeDislikeNumbers(payment, dislikeNumbers))
                {
                    break;
                }
                payment++;
            } while (true);
            Console.WriteLine(payment);
        }

        private static bool isIncludeDislikeNumbers(int payment, int[] dislikeNumbers)
        {
            var paymentNumbers = payment.ToString().ToCharArray()
                .Select(c => int.Parse(c.ToString()));
            foreach (var paymentNumber in paymentNumbers)
            {
                foreach (var dislikeNumber in dislikeNumbers)
                {
                    if (paymentNumber == dislikeNumber)
                    {
                        return true;
                    }
                }
            }
            return false;
        }
    }
}


Measured memory_bytes: 15432
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Comparator;
import java.util.InputMismatchException;

public class Main {

	InputStream is;
	PrintWriter out;
	String INPUT = "";

	void solve() {

		int a = ni();
		int b = ni();
		int t = ni();
		out.println(t / a * b);

	}

	void run() throws Exception {
		is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		if (!INPUT.isEmpty())
			tr(System.currentTimeMillis() - s + "ms");
	}

	public static void main(String[] args) throws Exception {
		new Main().run();
	}

	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte() {
		if (lenbuf == -1)
			throw new InputMismatchException();
		if (ptrbuf >= lenbuf) {
			ptrbuf = 0;
			try {
				lenbuf = is.read(inbuf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (lenbuf <= 0)
				return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) {
		return !(c >= 33 && c <= 126);
	}

	private int skip() {
		int b;
		while ((b = readByte()) != -1 && isSpaceChar(b))
			;
		return b;
	}

	private double nd() {
		return Double.parseDouble(ns());
	}

	private char nc() {
		return (char) skip();
	}

	private String ns() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != '
									// ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n) {
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while (p < n) {
			if (!(isSpaceChar(b)))
				buf[p++] = (char) b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m) {
		char[][] map = new char[n][];
		for (int i = 0; i < n; i++)
			map[i] = ns(m);
		return map;
	}

	private int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private int[][] na(int n, int m) {
		int[][] a = new int[n][];
		for (int i = 0; i < n; i++)
			a[i] = na(m);
		return a;
	}

	private int ni() {
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl() {
		long num = 0;
		int b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private static void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
}


Measured memory_bytes: 21972
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

const int MAX = 100001;

ll N, K;
ll R, S, P;
string T;
bool is_wins[MAX];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> K;
  cin >> R >> S >> P;
  cin >> T;

  ll ans = 0;
  for (int i = 0; i < N; i++) {
    if (i < K) {
      is_wins[i] = true;
      switch (T[i]) {
      case 'r':
        ans += P;
        break;
      case 's':
        ans += R;
        break;
      case 'p':
        ans += S;
        break;
      }
    } else {
      if (T[i] != T[i - K] || !is_wins[i - K]) {
        is_wins[i] = true;
        switch (T[i]) {
        case 'r':
          ans += P;
          break;
        case 's':
          ans += R;
          break;
        case 'p':
          ans += S;
          break;
        }
      }
    }
  }

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

Measured memory_bytes: 592
use std::io::*;
use std::str::FromStr;
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
fn main(){
    let (a, b) = (read::<i32>(), read::<i32>());
    println!("{}", if a <= b {a} else {a-1})    
}

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

typedef long long ll;

int main() {
    ll r, g, b, n;
    cin >> r >> g >> b >> n;

    ll limitr = ceil(n / r);
    ll limitg = ceil(n / g);
    ll ans =0;
    for (int i = 0; i <= limitr; i++)
    {
        for(int j=0;j<=limitg ;j++)
        {
            if( n - i*r - j*g >=0 )
            {
                if( (n - i*r - j*g )%b==0 )
                    ans++;
            }
        }
    }
    cout<<ans;
}

Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll; 
typedef pair<ll, ll> PL;

ll n, ans = 0, o = 0, b = 0, k = 0;
string s;

int main(){
	cin >> n;
	while (cin >> s&&n){
		if (s == "HIT"){
			k++;
			if (k > 3){
				k--;
				ans++;
			}
		}
		else if (s == "HOMERUN"){
			ans += (k + 1);
			k = 0;
		}
		else{
			o++;
		}
		if (o == 3){
			cout << ans << endl;
			ans = 0;
			o = 0;
			k = 0;
			n--;
		}
	}
}

Measured memory_bytes: 1204
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <map>

using namespace std;

template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

template< typename T >
vector< T > dijkstra(WeightedGraph< T > &g, int s) {
  const auto INF = numeric_limits< T >::max();
  vector< T > dist(g.size(), INF);

  using Pi = pair< T, int >;
  priority_queue< Pi, vector< Pi >, greater< Pi > > que;
  dist[s] = 0;
  que.emplace(dist[s], s);
  while(!que.empty()) {
    T cost;
    int idx;
    tie(cost, idx) = que.top();
    que.pop();
    if(dist[idx] < cost) continue;
    for(auto &e : g[idx]) {
      auto next_cost = cost + e.cost;
      if(dist[e.to] <= next_cost) continue;
      dist[e.to] = next_cost;
      que.emplace(dist[e.to], e.to);
    }
  }
  return dist;
}

int main(void) {
    int N, M, S;
    cin >> N >> M >> S;
    WeightedGraph<int64_t> g(4000*N);
    while(M--) {
        int U, V, A, B;
        cin >> U >> V >> A >> B;
        --U; --V;
        for(int j=0; j<4000; j++) {
            if(j < A) continue;
            g[4000*U+j].emplace_back(4000*V+j-A, B);
            g[4000*V+j].emplace_back(4000*U+j-A, B);
        }
    }
    for(int i=0; i<N; i++) {
        int C, D;
        cin >> C >> D;
        for(int j=0; j<4000; j++) {
            g[4000*i+j].emplace_back(4000*i+min(j+C,3999), D);
        }
    }

    vector<int64_t> dist = dijkstra(g, min(S, 3999));
    for(int i=1; i<N; i++) {
        int64_t ans = numeric_limits<int64_t>::max();
        for(int j=0; j<4000; j++) {
            ans = min(ans, dist[4000*i+j]);
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 34924
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    string s,t,u;
    int a,b;
    in>>s>>t>>a>>b>>u;
    if(s==u) --a;
    if(t==u) --b;
    cout<<a<<" "<<b<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
ll n,k;
ll ans=1;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n>>k;
	for(ll i=k;i<=n;i++){
		ans=(ans+(n+1)*i-i*i+1)%mod;
//		ans=(ans%mod+((n+1)%mod*i%mod)%mod-(i%mod*i%mod)%mod+1)%mod;
	}
	cout<<ans;
	return 0;
} 

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

typedef long long ll;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

const char nl = '\n';

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
    int h, w; cin >> h >> w;
    int canvas[h + 2][w + 2];
    FOR(i, 1, h + 1) {
        string s; cin >> s;
        FOR(j, 1, w + 1) canvas[i][j] = s[j];
    }
    bool ok = true;
    F0R(i, h) {
        F0R(j, w) {
            if (canvas[i][j] == '#') {
                if (canvas[i+1][j] == '.' && canvas[i - 1][j] == '.' && canvas[i][j + 1] == '.' && canvas[i][j - 1] == '.') {
                    ok = false;
                    break;
                }
            }
        }
    }
    cout << (ok ? "Yes\n": "No\n");
}

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

int main(){
	while(1){
		int n;
		cin>>n;
		if(n==0)
			break;
		int a[1000];
		for(int i=0;i<n;i++){
			cin>>a[i];
		}
		int s=1000001;
		for(int i=0;i<n-1;i++){
			for(int j=i+1;j<n;j++){
				if(s>abs(a[i]-a[j])){
					s=abs(a[i]-a[j]);
				}
			}
		}
		cout<<s<<endl;
	}
	return 0;
}

Measured memory_bytes: 3016
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
#define PI acos(-1)
#define oo LLONG_MAX
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*

*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  ll X, N; cin >> X >> N;
  map<ll, ll> use;
  rep(i, N){
    ll p; cin >> p;
    use[p]++;
  }
  rep(i, 101){
    if (use[X-i] == 0){
      cout << X-i << endl;
      return 0;
    }
    else if (use[X+i] == 0){
      cout << X+i << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;


public class Main {
	private	static	BufferedReader	br = null;

	static {
		br = new BufferedReader(new InputStreamReader(System.in));
	}
 
    /**
     * @param args
     */
	public static void main(String[] args) {
	// TODO Auto-generated method stub
		int[]	params = null;
		String	out    = "";

		while ((params = parseParams()) != null) {
	        ArrayList<Integer>	player = new ArrayList<Integer>();
			int					curr   = 0;

			for (int n = 1; n <= params[0]; n++) {
				player.add(n);
			}
			
			while(player.size() > 1) {
				curr = (curr + params[1] - 1) % player.size();
				player.remove(curr);
			}

			out += String.format("%d\n", player.get(0));
		}

		System.out.print(out);
	}

	private static  int[] parseParams() {
		int[]		params = null;
		String[]	split  = null;
		String		strIn  = null;
 
		if ((strIn = parseStdin()) != null) {
			split  = strIn.split(" ");
			params = new int[split.length];
			for (int n = 0; n < split.length; n++) {
				params[n] = Integer.parseInt(split[n]);
			}

			if (params[0] == 0 && params[1] == 0) {
				params = null;
			}
		}
		 
		return params;
	}
 
	private static String parseStdin() {
		String	strNum = null;
 
		try {
			String line = br.readLine();
			if (line != null) {
				if (!line.isEmpty()) {
					strNum = line;
				}
			}
		}
		catch (IOException e) {}
 
		return strNum;
	}
}

Measured memory_bytes: 17012
#include<stdio.h>

int main(){
  long a,b,c,k,ans=0;
  scanf("%ld%ld%ld%ld",&a,&b,&c,&k);
  
  if(k-a>0){
    ans=a;
    if(k-a-b>0){
      ans=a-(k-a-b);
    }
  }else{ans=k;}
  
  printf("%ld",ans);
  return 0;
}


Measured memory_bytes: 1724
#include<stdio.h>
#include<cstring>
#include<iostream>
#include<stdlib.h>
using namespace std;
int a[101];
char s[10000000];
int main()
{
    int top=0;
    while(scanf("%s",s)!=EOF)
    {
        if(s[0]=='+')
        {
            top--;
            int x=a[top--];
            int y=a[top];
            a[top++]=x+y;
        }
       else if(s[0]=='-')
        {
            top--;
            int x=a[top--];
            int y=a[top];
            a[top++]=y-x;
        }
        else if(s[0]=='*')
        {
            top--;
            int x=a[top--];
            int y=a[top];
            a[top++]=x*y;
        }
        else
        {
          a[top++]=atoi(s);
        }
    }
    printf("%d\n",a[--top]);
    return 0;
}

Measured memory_bytes: 3232
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

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


signed main(void) {
    int n;
    cin >> n;
    vi a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));
    int sum = 0;
    rep(i,n-1)sum += a[i];
    if(a.back() < sum)cout << "Yes" << endl;
    else cout << "No" << endl;

}


Measured memory_bytes: 256
object Main extends App {
  val coin = Array(500,100,50)
  val Array(a, b, c, x) = Iterator.continually(io.StdIn.readLine.toInt)
    .take(4).toArray

  val ans = {
      for {
        i <- 0 to a
        if coin(0)*i <= x
        j <- 0 to b
        if coin(0)*i + coin(1)*j <= x
        k <- 0 to c
        if coin(0)*i + coin(1)*j + coin(2)*k == x
      } yield  true
    }.size

  println(ans)
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll H, W, K;
    cin >> H >> W >> K;
    vector<string> m(H);
    rep(i, H) cin >> m[i];
    ll ans = 0;
    rep(i, 1LL << H) {
        rep(j, 1LL << W) {
            ll k = 0;
            rep(h, H) {
                rep(w, W) {
                    if(!(((i >> h) & 1) || ((j >> w) & 1))) {
                        if(m[h][w] == '#') k++;
                    }
                }
            }
            if(k == K) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF = 2e9
#define LINF = 1e18
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << = << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO")
#define Yes(n) cout << ((n) ? "Yes" : "No")

int main(){

    int r,c;    
    cin >> r >> c;

    vector<int> a(c);

    rep(i, r){
        int sum = 0;
        rep(j, c){
            int n;
            cin >> n;
            cout << n << " ";
            a[j] += n;
            sum += n;
        }
        cout << sum << endl;
    }
    int rc = 0;
    rep(i, c){
        cout << a[i] << " ";
        rc += a[i];
    }

    cout << rc << endl;

}


Measured memory_bytes: 3092
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        char[] a = scan.next().toCharArray();
        int ans = 0;
        int i = 0, j = n - 1;
        while (i < j) {
            while (i < j && a[i] == 'R') i++;
            while (i < j && a[j] == 'W') j--;
            if (i < j) {
                ans++;
                i++; j--;
            }
        }
        System.out.println(ans);
    }
}


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

int main(){
    int x, y;
     
    
    
     while (1){
        cin >> x >> y;
        if (x ==0 && y ==0){
            break;
        }
     
        if (x < y)
            cout << x << " " << y << endl;
        else
            cout << y << " " << x << endl;
     }
    return 0;
}


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

const int MAX_LENGTH = 1 << 10;

bool isYes(char input[]);

int main()
{
	char Input[MAX_LENGTH];
	int i=0;
	while(true){
		cin.getline(Input, sizeof(Input));
		if(Input[0] == '.') break;
		if(isYes(Input)){
			cout << "yes" << endl;
		} else {
			cout << "no" << endl;
		}
	}
	return 0;
}

bool isYes(char Input[])
{
	enum __FLAG{NONE, PARE, BLAC};
	int prep[MAX_LENGTH], prepnum=0, p=NONE;
	for(int i=0; Input[i]!='.'; i++){
		if(Input[i] == '('){
			if(p != NONE){
				prep[prepnum] = p;
				prepnum++;
			}
			p=PARE;
		} else if(Input[i] == '['){
			if(p != NONE){
				prep[prepnum] = p;
				prepnum++;
			}
			p=BLAC;
		} else if(Input[i] == ')'){
			if(p!=PARE){
				return false;
			} else {
				if(prepnum==0) p=NONE;
				else {
					p = prep[prepnum-1];
					prepnum--;
				}
			}
		} else if(Input[i] == ']'){
			if(p!=BLAC){
				return false;
			} else {
				if(prepnum==0) p=NONE;
				else {
					p = prep[prepnum-1];
					prepnum--;
				}
			}
		}
	}
	return p==NONE;
}

Measured memory_bytes: 1124
from bisect import *
n = int(input())
a = [int(input()) for i in range(n)]

color = [-a[0]]
for i in range(1,n):
    if -a[i] >= color[-1]:
        color.append(-a[i])
    else:
        idx = bisect_right(color,-a[i])
        color[idx] = -a[i]

print(len(color))

Measured memory_bytes: 11032
package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt(sc)
	set := make(map[int]int, n)
	for i := 0; i < n; i++ {
		set[nextInt(sc)]++
	}
	m := nextInt(sc)
	var v int
	for i := 0; i < m; i++ {
		v = nextInt(sc)
		if _, ok := set[v]; !ok {
			set[v]++
		} else {
			set[v]--
		}
	}
	wtr := bufio.NewWriter(os.Stdout)
	// fmt.Fprintln(wtr, "debug set ", set)
	ans := make([]int, 0, max(n, m))
	for k, v := range set {
		if v == 1 {
			ans = append(ans, k)
		}
	}
	sort.Ints(ans)
	for _, v := range ans {
		fmt.Fprintln(wtr, v)
	}
	wtr.Flush()
}



Measured memory_bytes: 29940
import itertools
n = str(input())
a = ["","+"]
l = list(itertools.product(a,repeat=len(n)-1))
l_n = list(n)
ans=0
for i in l:
    l_a = [None]*(len(n)*2-1)
    l_a[::2] = l_n
    l_a[1::2] = i
    ans+=eval("".join(l_a))
print(ans)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
 
 
int main() {
  string S;
  cin >> S;
  

string result;
if ((S[0]!=S[1])|(S[0]!=S[2])|(S[1]!=S[2]))
  result = "Yes";
else
  result = "No";


cout << result << endl;
}
 

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
const double eps = 1e-8;
const int MOD = 1000000007;
// int main() {
//     cin.tie(0);
//     ios::sync_with_stdio(false);
//     cout << fixed << setprecision(10);
//
// }
struct UnionFind
{
    vector<int> par, sz;
    UnionFind(int n) : par(n), sz(n, 1) {
        for (int i = 0; i < n; ++i) par[i] = i;
    }
    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
    void merge(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (sz[x] < sz[y]) swap(x, y);
        par[y] = x;
        sz[x] += sz[y];
        sz[y] = 0;
    }
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    int size(int x) {
        return sz[root(x)];
    }
};
int main() {
    int N, Q;
    cin >> N >> Q;
    UnionFind uf(N);
    while (Q--) {
        int t, x, y;
        cin >> t >> x >> y;
        if (t == 0) uf.merge(x, y);
        else printf("%d\n", uf.root(x) == uf.root(y));
    }
}



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

int n, z = 0;
double t, a, h[100005];


int main (){

    long long x = 2147483647;
    cin >> n;
    cin >> t >> a;
    for(int i = 0; i<n; i++) {
        cin >> h[i];
        if (abs(a-(t-(0.006*h[i]))) < abs(a-(t-(0.006*h[z])))) z = i;
    }


    cout << z+1;
}

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

#define mx 100005
#define ll long long 

void IO()
{
     #ifndef ONLINE_JUDGE
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
    #endif
}

int ar[mx];
char ch[mx];

int m,n,k,ii;


void solve()
{
    string s,t;
    cin>>s>>t;
    n=s.size();
    m=t.size();
    int re=mx;
    for(int i=0;i<n;i++)
    {
        if(i+m>n)break;
        int tem=0;
        for(int j=0;j<m;j++)
        {
           if(s[i+j]!=t[j])tem++;
        }
        re=min(re,tem);
    }
    cout<<re<<endl;
}

int main()
{
    IO();

    int t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}

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

#include <string.h>

#define N_MIN       (1)
#define N_MAX       (100)
#define A_MIN       (0)
#define A_MAX       (1000)

typedef enum
{
    ERROR  =-1,
    SUCCESS= 0
} ResultType;

static ResultType checkRangeOfNum(int, int, int);
static void insertionSort(int *, int);
static void printArray(int *, int);

int main(void)
{
    int A[N_MAX], N, i;
    ResultType eResult;

    /* input line 1 */
    scanf("%d",&N);
    eResult = checkRangeOfNum(N, N_MIN, N_MAX);
    if(eResult < SUCCESS)
    {
        printf("Err: %d is out of range.", N);
        return eResult;
    }

    /* input line 2 */
    for(i=0; i<N; i++)
    {
        scanf("%d",&A[i]);
        eResult = checkRangeOfNum(A[i], A_MIN, A_MAX);
        if(eResult < SUCCESS)
        {
            printf("Err: %d is out of range.", A[i]);
            return eResult;
        }
    }

    /* exec insertionSort */
    insertionSort(A, N);

    return SUCCESS;
}

static ResultType checkRangeOfNum(int n, int nMin, int nMax)
{
    if((n < nMin) || (nMax < n))
    {
        return ERROR;
    }
    return SUCCESS;
}

static void insertionSort(int A[], int N)
{
    int  i, j, v;

    printArray(A, N);

    for(i=1; i<N; i++)
    {
        v = A[i];
        j = i - 1;
        while((j>=0) && (A[j] > v))
        {
            A[j+1] = A[j];
            j--;

        }
        A[j+1] = v;
        printArray(A, N);
    }
}

static void printArray(int A[], int N)
{
    int i;

    for(i=0; i<N-1; i++)
    {
        printf("%d ", A[i]);
    }
    printf("%d\n", A[N-1]);
}

Measured memory_bytes: 1848
#include <iostream>
#include <math.h>
using namespace std;

int main() {
	int x;
	cin >> x;
	bool beki[1001]={false};
	int power = 2;
	for(int j=0;j<10;j++){
		if(power < 1001){
			beki[power] = true;
		}
	}
	for(int i=1;i<35;i++){
		int power = i;
		for(int j=0;j<5;j++){
			power = power * i;
			if(power < 1001){
				beki[power] = true;
			}
		}
	}
	for(int i=x;i>0;i--){
		if(beki[i]==true){
			cout << i << endl;
			break;
		}
	}
	return 0;
	
}

Measured memory_bytes: 256
N = int(input())
A = [int(a) for a in input().split()]
av = sum(A)/N

choose = 0
dist = abs(A[0] - av)
for i in range(1, N):
    if abs(A[i]-av) < dist:
        choose = i
        dist = abs(A[i]-av)
print(choose)


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

using namespace std;

#define ll long long

ll l, k, dp[205][5];

ll calc(ll x ,bool dark){
    if(x > l) return 0;
    if(dp[x][dark] != -1) return dp[x][dark];
    ll res = dark;
    if(dark) res += calc(x + 1, false);
    else res += calc(x + 1, true) + calc(x + k, true);
    return dp[x][dark] = res;

}
int main()
{
    cin >> l >> k;
    for(int i = 0;i <= l;i++) dp[i][0] = dp[i][1] = -1;
    cout << calc(1, true) + calc(k, true) << endl;
    return 0;
}



Measured memory_bytes: 3124
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<utility>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = 1001001001;

ll pow_mod(ll x, ll y) {
	ll res = 1;
	for (ll i = 0; i < y; i++) res = res * x % mod;
	return res;
}

ll gcd(ll x, ll y) {
	if (y == 0) {
		return x;
	}
	return gcd(y, x % y);
}

int main() {
	int n, m;
	cin >> n >> m;
	vector<pair<int, int>> p(m);
	for (int i = 0; i < m; i++) cin >> p[i].first >> p[i].second;

	for (int i = 0; i < 1000; i++) {
		int i_copy = i;
		vector<int> v_i;
		if (i_copy == 0) v_i.push_back(0);
		else {
			while (i_copy != 0) {
				v_i.push_back(i_copy % 10);
				i_copy /= 10;
			}
		}
		reverse(v_i.begin(), v_i.end());
		int keta = v_i.size();
		if (keta != n) continue;
		bool flag = true;
		for (int j = 0; j < m; j++) {
			if (v_i[p[j].first - 1] != p[j].second) flag = false;
		}
		if (flag) {
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 3632
n = int(input())
s = list(map(int, input().split()))
r = 0
csum = 0
ans = 0
for l in range(n):
  if l >= r:
    r = l+1
    csum = s[l]
  while r < n and csum+s[r] == csum^s[r]:
    csum += s[r]
    r += 1
  ans += r-l
  csum -= s[l]
print(ans)

Measured memory_bytes: 23560
#include <iostream>
#include <numeric>
#include <string>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <utility>
#include <functional>

#define repd(i,a,b); for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define ll long long int
 
 
using namespace std;
int main() {
  int n,ans; cin >> n;
  int a[n];
  rep(i,n){
    cin >> a[i];
      rep(j,32){
        if(a[i]%2 == 0){
          ans++;
          a[i] = a[i]/2;
        } else {
          break;
        }
      }
  }
 cout << ans;
 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  string s;
  cin >> s;
  if(s <= "2019/04/30") cout << "Heisei" << endl;
  else cout << "TBD" << endl;
}

Measured memory_bytes: 256
var x = require('fs').readFileSync('/dev/stdin', 'utf8');
input = x.split(/[\n|\s]/);
i = 0;
while (!((input[i] == "0")&&(input[i+1] == "0"))) {
  if (parseInt(input[i]) > parseInt(input[i+1])) {
    temp = input[i];
    input[i] = input[i+1]
    input[i+1] = temp;
  }
  console.log(input[i] + " " + input[i+1]);
  i = i+2;
}



Measured memory_bytes: 18780