akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <memory.h>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <ctime>
#include <iostream>
#include <functional>
#include <random>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<pii, int> p3i;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<p3i> v3i;
typedef vector<vii> vvii;
typedef vector<p3i> vp3i;
typedef long double ld;
typedef vector<ld> vld;


#define pb push_back
#define mp make_pair
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define REPD(i, n) for (int (i) = (n) - 1; (i) >= 0; (i)--)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define FORD(i,a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define sz(v) (int)(v).size()
#define all(v) (v).begin(), (v).end()
#define rv(v) reverse(all(v))
#define CL(v, val) memset((v), (val), sizeof((v)))
#define SORT(a) sort(all(a))
#define un(v) SORT(v), (v).resize(unique(all(v)) - (v).begin())
#define eps 1.0e-9
#define X first
#define Y second
#define bit(n) (1 << (n))
#define bit64(n) (ll(1) << (n))
#define sqr(x) ((x) * (x))
#define sq5(x) ((x) * (x) * (x) * (x) * (x))
#define N 105

int D[N][2];

int main(void) {
	int n;
	scanf("%d", &n);
	REP(i, n) {
		scanf("%d%d", &D[i][0], &D[i][1]);
	}

	FOR(i, 2, n) {
		int cnt = 0;
		if (D[i - 2][0] == D[i - 2][1]) {
			cnt++;
		}

		if (D[i - 1][0] == D[i - 1][1]) {
			cnt++;
		}

		if (D[i][0] == D[i][1]) {
			cnt++;
		}

		if (cnt == 3) {
			printf("Yes\n");
			return 0;
		}
	}

	printf("No\n");
	return 0;
}

Measured memory_bytes: 3656
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
using namespace std;
typedef long double float128;
typedef long long i64;
const int MAXN = 2e5 + 10;
const float128 PI = acos(float128(-1));

int X1, X2, Y1, Y2;
int N;
int flagX, flagY;
float128 answer;
int stk[MAXN], top;	

pair<int, int> p[MAXN];

int main(int argc, char **argv)
{
	//cerr << (sizeof (float128)) << endl;
	cin >> X1 >> Y1 >> X2 >> Y2 >> N ;
	flagX = flagY = 1;
	if(X1 > X2)
		flagX = -1, X1 = -X1, X2 = -X2;
	if(Y1 > Y2)
		flagY = -1, Y1 = -Y1, Y2 = -Y2;

	for(int i = 1; i <= N; i++)
	{
		cin >> p[i].first >> p[i].second ;
		p[i].first *= flagX, p[i].second *= flagY;

		if(!(X1 <= p[i].first && p[i].first <= X2 && Y1 <= p[i].second && p[i].second <= Y2))
			N --, i --;
	}
	cerr << N << endl ;
	sort(p + 1, p + 1 + N);
	for(int i = 1; i <= N; i++)
		if(top == 0 || p[i].second > stk[top])
			stk[++top] = p[i].second;
		else
			*(upper_bound(stk + 1, stk + top + 1, p[i].second)) = p[i].second;
	cerr << top << endl ;
	answer = 100.0L * (X2 - X1 + Y2 - Y1) + (PI - 4) * 5 * top;
	if(top == min(X2 - X1 + 1, Y2 - Y1 + 1))
		answer += PI * 5;
	cout << fixed << setprecision(20) << answer << endl ;
}



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

using namespace std;

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

    vector<int> h(N);
    for (int i = 0; i < N; ++i) {
        cin >> h[i];
    }
    sort(h.begin(), h.end());

    int ans = INT32_MAX;
    for (int i = 0; i + K - 1 < N; ++i) {
        ans = min(ans, h[i + K - 1] - h[i]);
    }

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

Measured memory_bytes: 640
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        string s = Console.ReadLine();
        for(int i = 0; i < 26; i++)
        {
            char c = Convert.ToChar('a' + i);
            if (!s.Contains(c))
            {
                Console.WriteLine(c);
                return;
            }
        }
        Console.WriteLine("None");
    }
}


Measured memory_bytes: 13340
#include<bits/stdc++.h>
using namespace std;
int c[25],v[25];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",&v[i]);
	for(int i=0;i<n;i++)
		scanf("%d",&c[i]);
	int sum=0;
	for(int i=0;i<n;i++){
		if(v[i]-c[i]>0)
			sum+=(v[i]-c[i]);
	}
	printf("%d\n",sum);
}

Measured memory_bytes: 256
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
	int a, b;
	cin >> a >> b;
	if((a*b)% 2 == 0) cout << "No" << endl;
	else cout << "Yes" << endl;
}

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

int main(){
  int A,B,sum=0;
  cin>>A>>B;
  if (A>B){
    sum+=A;
    A--;
    if (A>B){
      sum+=A;
    }
    else {
      sum+=B;
    }
    cout<<sum<<endl;
  }
  else {
    sum+=B;
    B--;
    if (A>B){
      sum+=A;
    }
    else {
      sum+=B;
    }
    cout<<sum<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <cassert>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
#define pi 3.141592653589793
using namespace std;
int sdkys(int a,int b){
    if(b==0) return a;
    return sdkys(b,a%b);
}
int sskbs(int a,int b){
    return a*b/sdkys(a,b);
}
int sosu(int a){
    if(a==2){
        return 1;
    }
    for(int i=2;i<sqrt(a)+1;i++){
        if(a%i==0){
            return 0;
        }
    }
    return 1;
}
struct UnionFind{
    vector<int> r;
    UnionFind(int N){
        r=vector<int>(N,-1);
    }
    int root(int x){
        if(r[x]<0) return x;
        return r[x]=root(r[x]);
    }
    bool unite(int x,int y){
        x=root(x);
        y=root(y);
        if(x==y) return false;
        if(r[x]>r[y]) swap(x,y);
        r[x]+=r[y];
        r[y]=x;
        return true;
    }
    int size(int x){
        return -r[root(x)];
    }
};
vector<int> v;
int n,m,cnt=0,ans=0,aa[220000],ab[220000];
pair<int,int> pp[220000];
string s,ss[220000];
queue<int> que;
signed main(){
    cin>>n>>m;
    UnionFind UF(n);
    rep(i,m){
        int a,b;
        cin>>a>>b;
        a-=1;
        b-=1;
        UF.unite(a,b);
    }
    rep(i,n){
        ans=max(ans,UF.size(i));
    }
    cout<<ans;
}

Measured memory_bytes: 11684
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+7;
int n,e,b,cnt=10,a;
int arr[N];
string s ;
int main()
{
    cin>>s;
for (int i= 0 ; i <s.size()-1;i++ )

         if (s[i] == s[i+1])
        return cout<<"Bad" , 0 ;


    return cout<<"Good" , 0 ;


}


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

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

Measured memory_bytes: 4000
#include<bits/stdc++.h>
using namespace std;
int n;
long long ans=0;
string a;
map<string,int>mp;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a;
		sort(a.begin(),a.end());
		ans+=mp[a];
		mp[a]++;
	}
	cout<<ans;
}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<int,int>
#define poly vector<ll>
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=100005;
ll sum,d[N];
map<ll,int> M;
int q[N],sz[N],vis[N],fa[N];
vector<int> v[N];
void GG(){
	puts("-1"); exit(0);
}
bool cmp(int a,int b){
	return d[a]<d[b];
}
void dfs(int p,int dep){
	vis[p]=1; sum+=dep;
	for(auto i:v[p])if(!vis[i])dfs(i,dep+1);
}
int main(){
	int n=read();
	For(i,1,n)M[d[q[i]=i]=read()]=i;
	sort(q+1,q+n+1,cmp);
	Rep(i,n,2){
		sz[q[i]]++;
		auto it=M.find(d[q[i]]-n+2*sz[q[i]]);
		if(it==M.end())GG();
		fa[q[i]]=it->second;
		sz[fa[q[i]]]+=sz[q[i]];
		v[fa[q[i]]].pb(q[i]);
	}
	dfs(q[1],0);
	For(i,1,n)if(!vis[i])GG();
	if(sum!=d[q[1]])GG();
	For(i,2,n){wri(fa[q[i]]); writeln(q[i]);}
}

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

using namespace std;

int N,x[110],y[110],h[110],i,X,Y,H,hoge;

int main(void) {
    cin >> N;
    for (i=0 ; i<N ; i++) {
        cin >> x[i] >> y[i] >> h[i];
        if (h[i]) hoge = i;
    }

    for (X=0 ; X <=100 ; X++) {
        for (Y=0 ; Y <=100 ; Y++) {
            H = abs(X-x[hoge])+abs(Y-y[hoge])+h[hoge];
            for (i=0 ; i<N ; i++) {
                if(max(H-abs(X-x[i])-abs(Y-y[i]), 0) != h[i]) goto hoge;
            }
            cout << X << " " << Y << " " << H << "\n";
            return 0;
            hoge:;
        }
    }




}

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

using namespace std;
long long n,W;
const int MAXV=100500;
long long  dp[MAXV];
int main()
{
	cin>>n>>W;
	long long  w,v;
	
	
	for(int i=1;i<MAXV;++i) dp[i]=1e16;
	
	for(int i=1;i<=n;++i)
	{
		cin>>w>>v;
		for(int j=100000-v;j>=0;--j)
		{
			dp[j+v]=min(dp[j]+w,dp[j+v]);
		}
	}
	for(int i=100000;i>=0;--i)
	{
		if(dp[i]<=W)
		{
			cout<<i<<endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 1024
#pragma GCC optimize ("-O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<bitset>
#include<complex>
#include<deque>
#include<fstream>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<utility>
#include<valarray>
#include<vector>
#include<array>
#include<forward_list>
#include<random>
#include<ratio>
#include<tuple>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
 
using namespace std;
using Int = long long; using uint = unsigned; using uInt = unsigned Int;
typedef pair<int,int> Pi; typedef pair<Int,Int> Pl;
const int mod = 1e9+7;
const Int Inf = 1e17;
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define mp make_pair
#define Pr(t) priority_queue<t>
#define gPr(t) priority_queue<t,vector<t>,greater<t>>
#define V(t) vector<t>
#define rep(i,n) for(int(i)=0; i<n; ++i)
#define rer(i,l,r) for(int i=l; i<=r; i++)
#define gnr(i,l,r) for(int i=r; i>=l; i--)
#define eb emplace_back
#define pri1(a) cout<<(a)<<'\n'
#define pri2(a,n) {rep(pri2i,n-1)cout<<a[pri2i]<<' '; cout<<a[n-1]<<'\n';}
#define prip(p) cout<<p.fi<<' '<<p.se<<'\n'
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int n,m,q,_,x,y;
string s,sb;
bool key;
char ch;

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

  int ans=1; cin>>n;
  rep(i,n){
    cin>>x; ans=ans*x/(__gcd(ans,x));
  }
  END
}


Measured memory_bytes: 3224
from sys import exit
INF = 10**21
N = int(input())
AB = [0 for i in range(N)]

for i in range(N):
    AB[i] = [int(n) for n in input().split()]
AB = sorted(AB, key=lambda x: x[0])
AB = sorted(AB, key=lambda x: -x[1])

now = AB[0][1]
for i in range(len(AB)):
    now = min(AB[i][1], now)
    now -= AB[i][0]
if now < 0:
    print("No")
    exit()
else:
    print("Yes")


Measured memory_bytes: 92236
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#define N 200001

long long int parent(long long int i)
{
  return (i-1)/2;
}
long long int left(long long int i)
{
  return 2*i+1;
}
long long int right(long long int i)
{
  return 2*i+2;
}

void maxheapify(long long int arr[], int n, int i)
{
  int j, r,la,temp;
  j = left(i);
  r = right(i);

  	if(j<n && arr[j] > arr[i]) {la = j;}
  	else {la = i;}
  	if(r<n && arr[r] > arr[la]) {la = r;}
  	if(la != i)
  	{
    	temp = arr[i];
    	arr[i] = arr[la];
    	arr[la] = temp;
    	maxheapify(arr,n,la);
  	}
}

int main()
{
  long long int arr[500000];
  int n;
  scanf("%d", &n);
  for(int i=0; i<n; i++){scanf("%lld", &arr[i]);}
  for(int i=(n-1)/2; i>=0; i--){maxheapify(arr,n,i);}
  for(int i=0;i<n;i++){printf(" %lld",arr[i]);}
	puts("");
  
 }



Measured memory_bytes: 5600
#include <bits/stdc++.h>
#include <stdlib.h>
#include <string>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    ll r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}

int main(){
    double a,b;
    int ans=-1;
    cin >> a >>b;
    for(int i=1;i<=1250;i++){
        if(floor(i*0.08)==a&&floor(i*0.1)==b){
            ans=i;
            break;
        }
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.BitSet;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int N, M, D;

	public static void main(String[] args) {
		while (true) {
			M = sc.nextInt();
			N = sc.nextInt();
			D = sc.nextInt();
			if (M == 0) break;
			System.out.println(solve() ? 1 : 0);
		}
	}

	static boolean solve() {
		BitSet[] mat = new BitSet[M * N];
		for (int i = 0; i < N * M; ++i) {
			mat[i] = new BitSet(N * M + 1);
		}
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < M; ++j) {
				if (sc.nextInt() == 1) mat[i * M + j].set(M * N);
				mat[i * M + j].set(i * M + j);
				for (int k = -D; k <= D; ++k) {
					if (j + k < 0 || M <= j + k) continue;
					int dy = D - Math.abs(k);
					if (i - dy >= 0) mat[i * M + j].set((i - dy) * M + j + k);
					if (i + dy < N) mat[i * M + j].set((i + dy) * M + j + k);
				}
			}
		}
		boolean[] used = new boolean[N * M];
		for (int i = 0; i < N * M; ++i) {
			int pivot = -1;
			for (int j = 0; j < N * M; ++j) {
				if (used[j]) continue;
				if (mat[j].get(i)) {
					pivot = j;
					break;
				}
			}
			if (pivot == -1) continue;
			used[pivot] = true;
			for (int j = 0; j < N * M; ++j) {
				if (j == pivot || !mat[j].get(i)) continue;
				mat[j].xor(mat[pivot]);
			}
		}
		for (int i = 0; i < N * M; ++i) {
			if (!mat[i].get(N * M)) continue;
			mat[i].clear(N * M);
			if (mat[i].isEmpty()) return false;
		}
		return true;
	}

}

Measured memory_bytes: 55064
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 998244353


def resolve():
    """ 愚直解 """
    dp = [[0] * (s + 1) for _ in range(n + 1)]
    dp[0][0] = 1
    for i in range(1, n + 1):
        a = A[i - 1]
        for prev in range(i):
            for j in range(s + 1):
                dp[i][j] += dp[prev][j]
                if a + j > s:
                    continue
                dp[i][a + j] += dp[prev][j]
                dp[i][a + j] %= mod
    print(dp)
    res = 0
    for i in range(1, n + 1):
        res += dp[i][-1]
        res %= mod
    print(res)


def resolve2():
    """ DP + 累積和 """
    dp = [[0] * (s + 1) for _ in range(n + 1)]
    dp[0][0] = 1
    cnt_num = [0] * (s + 1)
    cnt_num[0] = 1
    res = 0
    for i in range(1, n + 1):
        a = A[i - 1]
        for j in range(s + 1):
            dp[i][j] += cnt_num[j]
            dp[i][j] %= mod
            if a + j > s:
                continue
            dp[i][a + j] += cnt_num[j]
            dp[i][a + j] %= mod
        for k in range(s + 1):
            cnt_num[k] = cnt_num[k] + dp[i][k]
            cnt_num[k] %= mod
        res += dp[i][-1]
        res %= mod
    print(res)


if __name__ == '__main__':
    n, s = map(int, input().split())
    A = list(map(int, input().split()))
    resolve2()


Measured memory_bytes: 135060
# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter
import math
# stdin = open("sample.txt")

a = list(map(int,[int(x) for x in stdin.readline().rstrip().split()]))

if a[0]+a[1] == a[2] or a[1]+a[2] == a[0] or a[2]+a[0] == a[1]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int h,w;
  cin>>h>>w;
  vector<string> t(h);
  REP(i,h)cin>>t[i];
  ll ans = 0;
  REP(i,w-1) {
    vector<vecint> cst(h+1, vecint(h+1, 0));
    REP(d,h) {
      int s0 = 0;
      int s1 = 0;
      REP(j,h-d) {
        cst[j][j+d] = s0;
        cst[j+d][j] = s1;
        if (t[j][i] == t[j+d][i+1]) ++s0;
        if (t[j+d][i] == t[j][i+1]) ++s1;
      }
      cst[h-d][h] = s0;
      cst[h][h-d] = s1;
    }
    FOR(j,1,h+1)FOR(k,1,h+1) {
      cst[j][k] += min(cst[j][k-1], cst[j-1][k]);
    }
    ans += cst[h][h];
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 792
/*Whose woods these are I think I know.
His house is in the village though;
He will not see me stopping here
To watch his woods fill up with snow.

My little horse must think it queer
To stop without a farmhouse near
Between the woods and frozen lake
The darkest evening of the year.

He gives his harness bells a shake
To ask if there is some mistake.
The only other sound’s the sweep
Of easy wind and downy flake.

The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
const int maxn= 100010;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=0,m=0,x=0,res=INT_MAX;
    cin>>n>>m>>x;
    int c[n];
    int a[n][m];
    for(int i=0;i<n;++i)
    {
        cin>>c[i];
        for(int j=0;j<m;++j)
            cin>>a[i][j];
    }
    for(int i=0;i<(1<<n);++i)
    {
        vector<int> aux(m,0);
        int sum=0;
        for(int j=0;j<n;++j)
        {
            if(i>>j&1)
            {
                sum+=c[j];
                for(int k=0;k<m;++k)
                    aux[k]+=a[j][k];
            }
        }
        bool ok=true;
        for(int j=0;j<m;++j)
            ok=ok&&(aux[j]>=x);
        if(ok)
            res=min(res,sum);
    }
    if(res==INT_MAX)
        cout<<"-1";
    else
        cout<<res;
    cout<<endl;
}

Measured memory_bytes: 3672
#include <iostream>
#include <string>

using namespace std;

int main(){
    string b;
    cin >> b;
    if(b == "A"){
        cout << "T";
    }else if (b == "T"){
        cout << "A";
    }else if (b == "G"){
        cout << "C";
    }else if (b == "C"){
        cout << "G";
    }
    return 0;
}


Measured memory_bytes: 256
/******************************************
* AUTHOR : Ashish Joshi* 
* INSTITUTION : NIT Hamirpur *
******************************************/
#include <bits/stdc++.h>
using namespace std;

#define N 100005
#define MOD 1000000007
#define PI 3.141592653589793

#define dd double
#define loop(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
#define set(b,i) (b|(1<<i))
#define unset(b,i) (b&!(1<<i))
#define cbit(b,i) bool(b&(1<<i))

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<long long,long long> > vpll;
typedef vector<vector<ll> > vvll;

int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//ios_base& scientific (ios_base& str);
ll n;
cin>>n;
ll h[n];
for(int i=0;i<n;i++)cin>>h[i];
ll dp[n]={0};
dp[0]=0;
dp[1]=abs(h[1]-h[0]);
for(int i=2;i<n;i++){
	dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
}
cout<<dp[n-1]<<endl;

return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

struct UnionFind {
  const int n;
  V<> t; // root ? -sz : par
  UnionFind(int n) : n(n), t(n, -1) {}
  int find(int v) { return t[v] < 0 ? v : t[v] = find(t[v]); }
  void unite(int u, int v) {
    if ((u = find(u)) == (v = find(v))) return;
    if (-t[u] < -t[v]) swap(u, v);
    t[u] += t[v];
    t[v] = u;
  }
  bool same(int u, int v) { return find(u) == find(v); }
  int size(int v) { return -t[find(v)]; }
};

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  while (true) {
    int h, w, c; cin >> h >> w >> c, --c;
    if (!h) break;
    VV<> p(h, V<>(w)); for (auto&& v : p) for (auto&& e : v) cin >> e, --e;
    int res = 0;
    V<> v;
    V<> di{1, 0, -1, 0}, dj{0, 1, 0, -1};
    auto in = [&](int i, int j) -> bool { return 0 <= i and i < h and 0 <= j and j < w; };
    auto _ = [&](int i, int j) -> int { return i * w + j; };
    UnionFind uf(h * w);
    for (int i = 0; i < h; ++i) for (int j = 0; j < w; ++j) {
      if (i + 1 < h and p[i][j] == p[i + 1][j]) uf.unite(_(i, j), _(i + 1, j));
      if (j + 1 < w and p[i][j] == p[i][j + 1]) uf.unite(_(i, j), _(i, j + 1));
    }
    auto dfs = [&](const auto& dfs) -> void {
      if (v.size() == 5) {
        if (v.back() != c) return;
        auto nuf = uf;
        for (int e : v) {
          for (int i = 0; i < h; ++i) for (int j = 0; j < w; ++j) if (!nuf.same(0, _(i, j)) and p[i][j] == e) {
            for (int d = 0; d < 4; ++d) {
              int ni = i + di[d], nj = j + dj[d];
              if (!in(ni, nj)) continue;
              if (nuf.same(0, _(ni, nj))) {
                nuf.unite(0, _(i, j));
                break;
              }
            }
          }
        }
        res = max(res, nuf.size(0));
        return;
      }
      for (int i = 0; i < 6; ++i) {
        v.push_back(i);
        dfs(dfs);
        v.pop_back();
      }
    };
    dfs(dfs);
    cout << res << '\n';
  }
}


Measured memory_bytes: 3184
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,ar[110],c=0,t,max=0,p;
    cin>>n;
    if(n==1)cout<<"1"<<endl;
    else
    {
     for(int i=1;i<=n;i++)
    {
        c=0;
        if(i%2==0)
        {
            t=i;
            //c++;
         while(t%2==0)
         {
             t=t/2;
             //cout<<t<<endl;
             c++;
             //cout<<c<<endl;
         }
        }
        ar[i]=c;
    }
    for(int i=1;i<=n;i++)
    {
        if(ar[i]>max)
        {
            max=ar[i];
            p=i;

        }
    }
    cout<<p<<endl;
    }

    return 0;
}


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

int main(void){
    int s;
    cin >> s;
    
    int count = 1;
    vector<bool> d(100000000);
    while(1){
        if(!d.at(s)) d.at(s) = true;
        else break;
        
        if(!(s%2)) s /= 2;
        else s = 3*s+1;

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

Measured memory_bytes: 12416
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main{
	public static void main (String[] args){
		Scanner sc = new Scanner (System.in);
		int N = sc.nextInt();
		int T = sc.nextInt();
		int[] c = new int[N];
		int[] t = new int[N];
		int p = 1001;
		for (int i = 0; i < N; i++) {
			c[i] = sc.nextInt();
			t[i] = sc.nextInt();
		}
		for (int i = 0; i < N; i++) {
			if ((t[i] <= T) && (c[i] < p)) {
				p = c[i];
			}
		}
		if (p == 1001) {
			System.out.println("TLE");
		} else {
			System.out.println(p);
		}
	}
}

Measured memory_bytes: 23764
#ABC-132-C
N = int(input())
D = list(map(int, input().split()))
sorted_D = sorted(D)
ans = 0

half = (len(D) // 2) - 1

if sorted_D[half] != sorted_D[half+1]:
    ans = sorted_D[half+1] - sorted_D[half]
else:
    ans = 0
    
print(ans)

Measured memory_bytes: 14556
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define reps(i, n) for (int i = 1; i <= (n); ++i)
#define repd(i, n) for (int i = (n)-1; i >= 0; --i)
#define repds(i, n) for (int i = (n); i > 0; --i)
#define loop(i, x, n) for (int i = (x); i < (n); ++i)
#define loops(i, x, n) for (int i = (x); i <= (n); ++i)
#define loopd(i, x, n) for (int i = (x); i > (n); --i)
#define loopds(i, x, n) for (int i = (x); i >= (n); --i)
#define itrep(i, a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i, a) for (auto i = rbegin(a); i != rend(a); ++i)
#define each(i, x) for (auto &&i : x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(a) ((int)a.size())
#define pow2(n) (n * n)
#define int ll
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
template <class T>
using priority_queuel = priority_queue<T, vector<T>, greater<T>>;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
constexpr double eps = 1e-9;
ll mod = static_cast<ll>(1e9 + 7);
template <class T, class... Args>
constexpr void mins(T &a, Args... args) { a = min<T>({a, args...}); }
template <class T, class... Args>
constexpr void maxs(T &a, Args... args) { a = max<T>({a, args...}); }
template <class F>
class FixPoint : private F {
public:
    explicit constexpr FixPoint(F &&f) : F(std::forward<F>(f)) {}
    template <class... Args>
    constexpr decltype(auto) operator()(Args &&... args) const { return F::operator()(*this, std::forward<Args>(args)...); }
};
template <class F>
constexpr decltype(auto) funcs(F &&f) { return FixPoint<F>{std::forward<F>(f)}; }
template <class T>
std::vector<T> vecs(int n, T &&val) { return std::vector<T>(std::forward<int>(n), std::forward<T>(val)); }
template <class... Args>
decltype(auto) vecs(int n, Args &&... args) { return std::vector<decltype(vecs(std::forward<Args>(args)...))>(std::forward<int>(n), vecs(std::forward<Args>(args)...)); }
template <class V, class T>
void fill(V &x, const T &val) { x = val; }
template <class V, class T>
void fill(vector<V> &vec, const T &val) {
    for (auto &&v : vec)
        fill(v, val);
}

void solve() {
    vector<int> x(5);
    rep(i, 5) cin >> x[i];
    rep(i, 5) {
        if (x[i] == 0) {
            cout << i + 1 << endl;
            break;
        }
    }
}

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

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define sz(x) (int)(x).size()
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
    int k, x;
    cin >> k >> x;
    if (k * 500 >= x)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}

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

int main() {
    string s;
    getline(cin,s);
    int l=s.length();
    char n=s[l-1]-'0';
    if(n==2||n==4||n==5||n==7||n==9)
        cout << "hon" << endl;
    if(n==0||n==1||n==6||n==8)
        cout << "pon" << endl;
    if(n==3)
        cout << "bon" << endl;

    return 0;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define repc2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define inf 2e9
#define linf 9000000000000000000ll
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
#define M 1'000'000'007

ll modinv(ll a) {
    ll b = M, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= M;
    if (u < 0) u += M;
    return u;
}
ll com[2000009];
ll comb_l(ll n, ll k) {
    if (com[k] != 0) return com[k];
    com[0] = 1;
    reps(i, k) { com[i] = ((((n - i + 1) * modinv(i)) % M) * com[i - 1]) % M; }
    return com[k];
}
int x, y;

int main() {
    cin >> x >> y;
    int n = (x + y) / 3;
    if ((x + y) % 3 == 0 && n <= x && x <= n * 2 && n <= y && y <= n * 2) {
        cout << comb_l(n, x - n) << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 4352
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author test
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        abc177_a solver = new abc177_a();
        solver.solve(1, in, out);
        out.close();
    }

    static class abc177_a {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int D = in.nextInt();
            int T = in.nextInt();
            int S = in.nextInt();

            if (((D / S) + (D % S == 0 ? 0 : 1)) <= T) {
                out.println("Yes");
            } else {
                out.println("No");
            }
        }

    }
}



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

int main(int argc, char** argv) {
    int a,b,c,count;
    while( scanf("%d %d",&a,&b)!=EOF){
        fflush(stdin);       
        c=a+b;
        count=0;
        while(c>0){
            count++;
            c=c/10;
        }
        printf("%d\n",count);
    }
 return 0;   
}

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

int main(){
  int k;
  cin>>k;
  if(k%2==0)cout<<(k/2)*(k/2)<<endl;
  else cout<<(k/2)*((k+1)/2)<<endl;
  return 0;
}

Measured memory_bytes: 3616
#include <iostream>

//https://atcoder.jp/contests/abc081/tasks/abc081_a

using namespace std;

int main(){
    int s1,s2,s3;
    int s123;

    cin >>  s123;

    s1 = s123 / 100 ;
    s2 = s123 % 100 / 10 ;
    s3 = s123 % 100 % 10 / 1;

    cout << s1 + s2 + s3 << endl; 

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
	int A,B;
	cin>>A>>B;
	vector<int> res;
	res.push_back(A+B);
	res.push_back(2*A-1);
	res.push_back(2*B-1);
	sort(res.begin(),res.end());
	cout<<res[2]<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for (int i = 0; i < (int)(a); i++)
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
typedef long long ll;
template<typename T>istream& operator>>(istream&i,vector<T>&v){rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v){stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v){if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v){return i>>v.first>>v.second;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v){return o<<v.first<<","<<v.second;}
template<typename T>bool mins(T& x,const T&y){if(x>y){x=y;return true;}else return false;}
template<typename T>bool maxs(T& x,const T&y){if(x<y){x=y;return true;}else return false;}
template<typename T>ll suma(const vector<T>&a){ll res(0);for(auto&&x:a)res+=x;return res;}

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template <typename Head> void dump(Head &&head) {
  cerr << head;
  dump();
}
template <typename Head, typename... Tail>
void dump(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  dump(forward<Tail>(tail)...);
}
#define debug(...)                                                               \
  do {                                                                         \
    cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = ";                        \
    dump(__VA_ARGS__);                                                         \
  } while (false)
#else
#define dump(...)
#define debug(...)
#endif

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

const ll LINF = 1LL << 60;
const int INF = 1001001001;

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

const string yes = "Yes";
const string no = "No";

int main()
{
  ll n; cin >> n;
  vector<ll> a(n);
  for (int i=0; i<n; i++){
    cin >> a[i];
  }
  vector<ll> b(n);
  for (int i=0; i<n; i++){
    cin >> b[i];
  }
  map<ll, ll> mp;
  rep(i, n) mp[a[i]]++;
  rep(i, n) mp[b[i]]++;
  for (auto v:mp) {
    if (v.second > n) {
      cout << no << endl;
      return 0;
    }
  }

  reverse(b.begin(), b.end());
  ll st = -1;
  ll ed = -1;
  rep(i, n) if (a[i] == b[i]) { st = i; break; }
  for (int i=n-1; i>=0; i--) if (a[i] == b[i]) { ed = i; break; }
  if (st > -1) {
    int idx = 0;
    for (int i=st; i<=ed; i++) {
      while (b[idx] == b[i] || b[i] == a[idx]) idx++;
      swap(b[idx], b[i]);
      if (st <= idx && idx <= ed) idx = ed+1;
    }
  }

  cout << yes << endl;
  cout << b << endl;

  return 0;
}


Measured memory_bytes: 22616
#include <iostream>
#include <string>

using namespace std;

int main() {
  string str;
  cin >> str;

  int ans = 0;
  for (int i = 0; i < str.length(); i++) {
    char c = str[i];
    if (c == '+') {
      ans += 1;
    }
    else {
      ans -= 1;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
S = input()

if S[0] == 'R' and S[1] == 'R' and S[2] == 'R':
  print(3)
elif S[0] == 'R' and S[1] == 'R' and S[2] == 'S':
  print(2)
elif S[0] == 'S' and S[1] == 'R' and S[2] == 'R':
  print(2)
elif S[0] == 'S' and S[1] == 'S' and S[2] == 'S':
  print(0)
else:
  print(1)

Measured memory_bytes: 9128
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include <set>
#define ll long long
using namespace std;


int main()
{
    ll a,b,c;
    cin>>a>>b>>c;
    if(c>=b)
    {
        int k=(a*(b-1)/b)-a*((b-1)/b);
        cout<<k;
    }
    else
    {
        int k=(a*(c)/b)-a*((c)/b);
        cout<<k<<endl;
    }
       return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<unordered_set>
#include<unordered_map>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod;
ll po(ll x,ll y){
    ll res=1;
    for(;y;y>>=1){
	if(y&1)res=res*x%mod;
	x=x*x%mod;
    }
    return res;
}
int main(){
  string s;cin>>s;
  ll ans=0,cnt=0;
  for(int i=0;i<s.size();i++){
      if(s[i]=='0')continue;
      cnt++;
      mad(ans,po(2,cnt-1)*po(3,s.size()-1-i)%mod);
  }
  mad(ans,po(2,cnt));
  cout<<ans<<endl;
  //cout<<ans*500000004%mod<<endl;
  return 0;
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main()
{
  int n,a,b,c;
  cin >> n;
  for(int i = 0;i < n;i++){
    cin >> a >> b >> c;
    if(a*a + b*b == c*c ||
       b*b + c*c == a*a ||
       c*c + a*a == b*b){
      cout << "YES" << endl;
    }
    else cout << "NO" << endl;
  }
}

Measured memory_bytes: 1152
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
int main()
{
	int a,b,c;
	int ans,ans1,ans2,ans3;
	scanf("%d%d%d",&a,&b,&c);
	ans1 = a + b;
	ans2 = a + c;
	ans3 = b + c;
	ans = min(min(ans1,ans2),ans3);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
import java.math.BigInteger
import java.util.*

fun main(args: Array<String>) {
    val inputs = readLine()!!.split(" ").map { BigInteger.valueOf(it.toLong()) }
    val (a, b, x) = inputs
    val d1 = a.div(x)
    var d2 = b.div(x)
    if (a.mod(x).compareTo(BigInteger.ZERO) == 0) {
        d2 = d2.add(BigInteger.ONE)
    }
    println(d2.minus(d1))
}


Measured memory_bytes: 38124
#include <iostream>
#include <cmath>
#include <stdint.h>
#include <iomanip>
#include <vector>
#include <queue>
using namespace std;
 
#define int long long
#define INF 1001001001

int arr[200001];
 
int nChoosek( int n, int k )
{
    if (k > n) return 0;
    if (k * 2 > n) k = n-k;
    if (k == 0) return 1;

    int result = n;
    for( int i = 2; i <= k; ++i ) {
        result *= (n-i+1);
        result /= i;
    }
    return result;
}

int32_t main() {
	
 	int N;
 	
 	cin >> N;
 	vector<int> v(N+1);
 	for(int i=1; i<=N; i++){		
 		int tmp;		
 		cin >> tmp;		
 		arr[tmp]++;	
 		v[i] = tmp;
	}
	
	int sum = 0;
	for(int i=1; i<=N; i++){		
		sum += nChoosek(arr[i],2);	
		
	}
    int ans = sum;
    for(int i=1; i<=N; i++){
    	ans = sum;
    	ans -= nChoosek(arr[v[i]],2);	
    	
    	ans += nChoosek(arr[v[i]]-1, 2);
    	
    	cout << ans << endl;
	}
    
 	
 	
}

Measured memory_bytes: 5908
#include<bits/stdc++.h>
#include<cmath>
#define  debug(x)   cout << '>' << #x << ':' << x << endl;

#define  fo(i,n)    for(ll i=0;i<n;i++)
#define  all(x)     (x).begin(), (x).end()
#define  unq(vec)   sort(all(vec)); vec.resize(unique(all(vec)) - vec.begin());
typedef long long ll;


using namespace std;
const int     MO = int(1e9) + 7;



int main()
{ ios::sync_with_stdio(false);
  cin.tie(0);
  ll x;
  cin>>x;
  ll y=100;
  ll ans=0;
  for(ll i=1; ;i++){
      y+=y/100;
      if(y>=x){
        ans=i;
        break;
      }
  }
  cout<<ans;

}



Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;



int main(){

    string s;
    cin >> s;
    long long int l = s.length();
    if(l==1){
        cout << s << endl;
    }else{
        long long int result=0,tmp=0;
        vector<long long int> v(l);
        REP(i,l){
            v[i] = (long long int)(s[i] - '0');
        }

        

        for (long long int bit = (long long int)pow(2, l-1) - 1; bit >= 0;bit--){
            tmp =v[0];
            FOR(i,0,l-1){
                if(bit&(long long int)pow(2,i)){
                    result += tmp;
                    tmp = v[i+1];
                }else{
                    tmp = 10 * tmp + v[i+1];
                }
            }
            result += tmp;

        }
        cout << result << endl;
    }

    

    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,-1,0,0,1,1,-1,-1 }, dy[9] = { 0,0,0,1,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222


ll a[MAX], dp[MAX], num[MAX];



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


  cin >> n;
  rep(i, n) cin >> a[i];
  dp[0]++;
  FOR(i, 1, n) {
    dp[i] = dp[i - 1];
    if (a[i] != a[i - 1]) {
      (num[a[i - 1]] = dp[i - 1]) %= mod;
      (dp[i] += num[a[i]]) %= mod;
    }
  }
  cout << dp[n - 1] << endl;


  return 0;
}

Measured memory_bytes: 5120
import java.util.*;

public class Main {
    public static void main(String arg[]) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int M = scan.nextInt();
        int X = scan.nextInt();
        int Y = scan.nextInt();

        int x;
        int max_x = scan.nextInt();
        for (int i = 1; i < N; i++) {
            x = scan.nextInt();
            if (max_x < x) {
                max_x = x;
            }
        }
        int y;
        int min_y = scan.nextInt();
        for (int i = 1; i < M; i++) {
            y = scan.nextInt();
            if (min_y > y) {
                min_y = y;
            }
        }

        Boolean war = true;
        for (int Z = X + 1; Z <= Y; Z++) {
            if (max_x < Z && min_y >= Z) {
                war = false;
                break;
            }
        }

        if (war) {
            System.out.println("War");
        }
        else {
            System.out.println("No War");
        }

        scan.close();
    }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define mp make_pair
#define inf 1000000009
using namespace std;
set<ll> place[27];
int main(){
	string s,t;
	cin>>s;
	cin>>t;
	int ss, tt;
	ss = s.size();
	tt = t.size();
	ll cur = -1;
	for(int i=0;i<ss;i++){
		int idx = s[i] - 'a';
		place[idx].insert(i);
	}
	ll ans = 0;
	for(int i=0;i<tt;i++){
		int nse = t[i] - 'a';
		if(place[nse].size() == 0){
			cout<<-1<<endl;
			return 0;
		}
		set<ll>::iterator it = place[nse].upper_bound( cur );
		if( it != place[nse].end() ){
			ll nep = *it;
			ans += nep - cur;
			cur = nep;
		}
		else{
			it = place[nse].upper_bound( -1 );
			ll nep = *it;
			ans += nep + ss - cur;
			cur = nep;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
 
using namespace std;
 
typedef long long int       lint;
typedef vector<int>         vi;
typedef vector<lint>        vl;
typedef pair<int, int>      pii;
typedef vector<pii>         vii;
typedef set<int>            si;
typedef map<string, int>    msi;
 
#define pb(n)           push_back(n)
#define ALL(n)          (n.begin(), n.end())
#define SORT(n)         (n.begin(), n.end(), greater<lint>())       
#define db(a)           cout<<#a<<" = "<<a<<endl;
#define FIN             freopen("in.txt","r",stdin);
#define FOUT            freopen("out.txt","w",stdout);
#define M               10000000
#define MOD             10000007
#define INF             10000000000000000
#define REP(i,a,b)      for(int i = int(a); i <= int(b); i++)
#define REPL(i,a,b)     for(lint i = lint(a); i <= lint(b); i++)
#define fastIO()        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int main()
{
    map<char, int>mp;
    string s;
    cin>>s;

    REP(i, 0, s.size() - 1) mp[s[i]]++;

    bool ok = true;
    for(auto i : mp){
        if(i.second & 1){
            ok = false;
            break;
        }
    }
    puts(ok? "Yes":"No");

    return 0;
}


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


int main(){
  
  
  long long x;
  cin>>x;
  int flag = 0;
  int A,B;
  for(int i=-150 ;i<=150;i++){
   for(int j=-150;j<=150;j++){
    long long a=i,b=j;
	A = a;
	B = b;
     for(int k=1;k<=4;k++){
      a = a*i;
       b = b*j;
     }
	 //A =a;
	 //B = b;
     if(a - b == x){
      cout<<A<<" "<<B<<endl;
       return 0;
     }
   }
  }
  //cout<<A<<" "<<B<<endl;
  
  
  
  
 //return 0; 
  
  
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include<cstdio>
 
#define gc getchar
#define db double
#define ll long long int
#define ull unsigned long long int
#define sc(x) scanf("%d", &x)
#define scl(x) scanf("%lld", &x)
#define sclu(x) scanf("%llu", &x)
#define scd(x) scanf("%lf", &x)
#define pass cout<<"pass\n"
#define vi vector<int>
#define pb push_back
#define vec vector
#define vi vector<int>
#define el "\n"
#define pii pair<int, int>
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define f(i,x,y) for(int i=x;i<y;++i)
#define ff(i,x,y) for(int i=x;i<=y;++i)
#define MOD 1000000007
#define MAX2 1000001
#define MAX 103
#define pbb pair<bool,bool>

using namespace std;


int main() {
	ll a[3];
	f(i,0,3) scl(a[i]);
	sort(a, a+3);
	ll ans =0;
	ans = a[1]-a[0];
	ans += a[2]-a[1];
	cout << ans << el; 
	
	return 0;
}





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

int main(){
    int n, i, x;
    
    cin >> n;
    
    for(i = 1; i <= n; i++){
        if(i % 3 == 0)
            cout << " " << i;
        else{
            x = i;
            while(x){
                if(x % 10 == 3) {
                    cout << " " << i;
                    break;
                }
                x /= 10;
            }
        }
    }
    
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 3084
using System;

namespace ConsoleApp21
{
    class ProgramA
    {
        static void Main(string[] args)
        {

            while(true)
            {
                string[] str = Console.ReadLine().Split(' ');
                int a = int.Parse(str[0]);
                char op = char.Parse(str[1]);
                int b = int.Parse(str[2]);
                if (op == '+')
                {
                    Console.WriteLine(a + b);
                }
                else if (op == '-')
                {
                    Console.WriteLine(a - b);
                }
                else if (op == '*')
                {
                    Console.WriteLine(a * b);
                }
                else if (op == '/')
                {
                    Console.WriteLine(a / b);
                }
                else
                {
                    break;
                }
            }
        }
    }
}

Measured memory_bytes: 9220
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main(){
  int n,k;
  string s;
  cin >> n >> s >> k;
  string temp = s.substr(k-1,1);
  char c = *temp.c_str();
  rep(i,n){
    if(c != s[i]){
      s[i]='*';
    }
  }
  cout << s <<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

int main() {
	int a;
	string c;
	cin >> a >> c;
	int b = stoi(c);
	a *= pow(10, c.length());
	int ab = a + b;
	if (pow(int(sqrt(ab)), 2) == ab) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256