akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;
using pll=pair<ll,ll>;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 1000000007

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

int main() {

	int N;
	cin >> N;
	vector<int> C(N),S(N),F(N);
	rep(i,N) cin >> C[i] >> S[i] >> F[i];
	rep(i,N) {
		ll ans = 0;
		ll ct = 0;
		for(int j=i; j<N-1; j++) {
			//cout << ct << " ";
			if(ct <= S[j]) {
				ct = S[j] + C[j];
			}
			else {
				if((ct-S[j])%F[j] == 0) {
					ct += C[j];
				}
				else {
					ct = S[j] + (ct - S[j]) / F[j] * F[j] + F[j] + C[j];
				}
			}
		}
		//cout << endl;
		cout << ct << endl;
	}
  return 0;
}


Measured memory_bytes: 256
def swap(i, j, arr):
    a = arr[:]
    temp = a[i]
    a[i] = a[j]
    a[j] = temp
    return a

n = int(input())
p = [int(i) for i in input().split()]
a = [int(i) for i in range(1, n+1)]
found = False
if p == a:
    found = True
    print('YES')
else:
    for i in range(n):
        for j in range(i+1, n):
            if swap(i, j, p) == a:
                found = True
                print('YES')
                break
if not found:
    print('NO')

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <deque>
#include <numeric>
#include <map>
#define rep(i,n) for (int i = 0; i < (n); ++i)
 
using namespace std;
 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
 
int main () {
	int n;
	string ans;
    cin >> n >> ans;
	ans += ans;
	const char *v[4] = {"SS", "SW", "WS", "WW"};
	vector<char> zoo(2*n);
	rep(k,4) {
		zoo[0] = v[k][0];
		zoo[1] = v[k][1];
		for (int i = 1; i <= n; ++i) {
			if ((zoo[i] == 'S' && ans[i] == 'o') || (zoo[i] == 'W' && ans[i] == 'x')) {
				zoo[i+1] = zoo[i-1];
			} else {
				if (zoo[i-1] == 'S')
					zoo[i+1] = 'W';
				else
					zoo[i+1] = 'S';
			}
		}
		if (zoo[0] == zoo[n] && zoo[1] == zoo[n+1]) {
			string ans = "";
			rep(i,n) ans += zoo[i];
			cout << ans << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 988
#include <bits/stdc++.h>
#define ll long long
#define p pair<ll, ll>
using namespace std;

int used[100005];
int main(){
    int n, k;
    cin >> n >> k;
    vector<p> v;
    for(int i = 0; i < n; i++){
        ll t, d;
        cin >> t >> d;
        v.push_back(p(d, t));
    }
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    priority_queue<ll, vector<ll>, greater<ll>> que;
    ll res = 0;
    for(int i = 0; i < k; i++){
        if(used[v[i].second]) que.push(v[i].first);
        used[v[i].second] = 1;
        res += v[i].first;
    }
    ll cnt = 0;
    for(int i = 0; i <= n; i++){
        if(used[i]) cnt++;
    }
    ll ans = res + cnt * cnt;
    for(int i = k; i < n; i++){
        if(used[v[i].second]) continue;
        if(que.empty()) break;
        used[v[i].second] = 1;
        cnt++;
        res -= que.top(); que.pop();
        res += v[i].first;
        ans = max(ans, res + cnt * cnt);
    }
    cout << ans << endl;
    return 0;
}

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

int main(void) {
	string s; cin >> s;
	int i;
	for (i = 0; i < s.size() - 1; i++) {
		if (s.find(s[i], i+1 ) != -1 ) {
			cout << "no" << endl; return 0;
		}
	}

	cout << "yes" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const ll MOD = 1e9 + 7;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")




int main() {

    ll n,n1,n2; cin >> n;
    ll count = 0;

    rep(i,n){
        cin >> n1 >> n2;
        if(n1 == n2) count ++;
        else count = 0;

        if(count == 3) {
            cout << "Yes";
            return 0;
        }
    }

    cout << "No";
}


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

using namespace std;

int memo[100] = {0};

int main() {
	map<int, bool> m;
	for (int a = 0; a < 10; ++a)
		for (int b = 0; b < 10; ++b)
			for (int c = 0; c < 10; ++c)
				for (int d = 0; d < 10; ++d) {
					vector<int> v;

					v.push_back(a);
					v.push_back(b);
					v.push_back(c);
					v.push_back(d);

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

					int code = 0;
					for (int i = 0, k = 1; i < v.size(); ++i, k *= 10)
						code += v[i] * k;

					if ( !m[code] ) ++memo[a+b+c+d];
					else m[code] = true;
				}

	int n;
	while (scanf("%d", &n) != EOF) {
		cout << memo[n] << endl;
	}
}

Measured memory_bytes: 1260
/*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*
$                                                                      $
$                      SAHADAT HOSSASIN SHAHIN                         $
$ 	     Department of CSE, Jagannath University, Dhaka, Bangladesh.   $
$           cf & hr & uva & lightoj & stopstalk ID: shahincsejnu       $
$                                                                      $
$                                                                      $
*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*/
#include <bits/stdc++.h>
#define lli                             long long int
#define ull                             unsigned long long int
#define D                               double
#define Input(n)                        for(int i = 0; i < n; i++) cin >> a[i];                          
#define sqr(x)                          ((x)*(x))
#define ff                              first
#define sz                              size()
#define PB                              push_back
#define MP                              make_pair
#define CHR                             getchar()
#define NL                              printf("\n")
#define PI                              2.0*acos(0.0)
#define MEM(a,val)                      memset(a,val,sizeof(a))
#define timesave                        ios_base::sync_with_stdio(0); cin.tie(0)
#define debug                           printf("***** here here here here *****\n");
#define file_input                      freopen("A.in","r",stdin),freopen("A1.out","w",stdout)
using namespace std;

template <typename T> T in(){char ch;T n = 0;bool ng = false;while (1){ch = getchar();if (ch == '-'){ng = true;ch = getchar();break;}if (ch>='0' && ch<='9')     break;}while (1){n = n*10 + (ch - '0');ch = getchar();if (ch<'0' || ch>'9')   break;}return (ng?-n:n);}
template<typename T>inline T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1);  else return SQR(POW(B,P/2));}
template<typename T>inline T Gcd(T a,T b){if(a<0)return Gcd(-a,b);if(b<0)return Gcd(a,-b);return (b==0)?a:Gcd(b,a%b);}
template<typename T>inline T Lcm(T a,T b) {if(a<0)return Lcm(-a,b);if(b<0)return Lcm(a,-b);return a*(b/Gcd(a,b));}


long long Bigmod(long long base, long long power, long long MOD){long long ret=1;while(power){if(power & 1)ret=(ret*base)%MOD;base=(base*base)%MOD;power>>=1;}return ret;}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
long long ModInverse(long long number, long long MOD){return Bigmod(number, MOD-2, MOD);}
bool isConst(char ch){if (isalpha(ch) && !isVowel(ch)) return true; return false;}
int toInt(string s)  { int sm; stringstream ss(s); ss>>sm; return sm; }

const int M = 1e5 + 5;
int a[M], n, cnt;

                        ///*********************** Let`s start ***************************//


int main()
{
	timesave;
	
	string s;
	cin >> s;
	
	cout << "2018";
	for(int i = 4; i < s.size(); i++){
		cout << s[i];
		if(i == s.size()-1) cout << endl;
	}
	
	

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
string YesNo[] = {"No","Yes"};

int main(void)
{
    string S;
    cin >> S;
    sort(S.begin(),S.end());
    cout << YesNo[int(S[0]==S[1] && S[1]!=S[2] && S[2]==S[3])] << endl;

    return 0;
}

Measured memory_bytes: 256
A,B,C,D = map(int, input().split())


if (C > A and C > B) or (A > C and A  >D):
    time =0
else:
    if A < C: # Bの方があとに押した場合
        if B < D:
            time = B-C
        else:
            time = D-C
    else:
        if B<D:
            time = B-A
        else:
            time = D-A
print(time)

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

int main() {
  int N;
  cin >> N;
  vector<int> P(N), Q(N);
  for (int i = 0; i < N; i++) cin >> P.at(i);
  for (int i = 0; i < N; i++) cin >> Q.at(i);

  if (P == Q) return cout << 0 << "\n", 0;
  if (P > Q) swap(P, Q);

  int cnt = 0;
  do cnt++;
  while (next_permutation(P.begin(), P.end()) && P < Q);

  cout << cnt << "\n";
}

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

const int N = 220000;

int a[N];

int main() {
	
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	int n; cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i], a[i] -= i + 1;
	sort(a, a + n);
	long long tot = 0;
	for (int i = 0; i < n; i++) tot += abs(a[i] - a[n / 2]);
	cout << tot << "\n";
	
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
# define ll long long int
#define mm 1000000007
#define pb push_back
									//nestedcode



 int main(){
	ios::sync_with_stdio(false);
  	cin.tie(0); cout.tie(0);
  	ll n,i;
  cin>>n;
  ll a[n+5];
  double ans=0;
  for(i=0;i<n;i++){
  	cin>>a[i];
  	ans+=(1.0/a[i]);
  //	cout<<ans<<endl;
  }
  ans=1/ans;
  cout<<fixed<<setprecision(8)<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int n,m[7],a;

int main(){
	while(cin>>n){
		if(!n)return 0;
		fill(m,m+7,0);
		while(n--){
			cin>>a;
			m[min(a/10,6)]++;
		}
		for(int i=0;i<7;i++)cout<<m[i]<<endl;
	}
}

Measured memory_bytes: 864
n = int(input())
s = list(map(int,input().split()))
cnt = 0
for i in range(1,n-1):
    if s[i] != max(s[i-1],s[i],s[i+1]) and s[i] != min(s[i-1],s[i],s[i+1]):
        cnt += 1
print(cnt)

Measured memory_bytes: 3060
#include<iostream>
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl '\n'
using namespace std;

int main()
{
    fastio;
    long long n,i,j;
    cin>>n;
    long long a[n],dp[n];
    memset(dp,63,sizeof(dp));
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    dp[0]=0;
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<=i+2;j++)
        {
            dp[j]=min(dp[j],dp[i]+abs(a[j]-a[i]));
        }
    }
    cout<<dp[n-1];
    return 0;
}

Measured memory_bytes: 1792
from collections import defaultdict, deque
from bisect import bisect
W, H, M = map(int, input().split())
L = [list(map(int, input().split())) for i in range(M)]

XS = set([0, W])
YS = set([0, H])

for px, py, qx, qy in L:
    XS.add(px); XS.add(qx)
    YS.add(py); YS.add(qy)

X0 = sorted(XS)
Y0 = sorted(YS)

def convert(X0):
    mp = {}
    prv = -1
    cur = 0
    for x in X0:
        mp[x] = cur
        cur += 2
        prv = x
    cur -= 1
    return mp, cur

XM, X = convert(X0)
YM, Y = convert(Y0)

C = [[0]*X for i in range(Y)]
D = [[-1]*X for i in range(Y)]
for i in range(Y):
    C[i][0] = C[i][X-1] = 1
for i in range(X):
    C[0][i] = C[Y-1][i] = 1
for px, py, qx, qy in L:
    if px == qx:
        if not py < qy:
            py, qy = qy, py
        x0 = XM[px]
        y0 = YM[py]; y1 = YM[qy]
        for i in range(y0, y1+1):
            C[i][x0] = 1
    else:
        if not px < qx:
            px, qx = qx, px
        x0 = XM[px]; x1 = XM[qx]
        y0 = YM[py]
        for i in range(x0, x1+1):
            C[y0][i] = 1

dd = ((-1, 0), (0, -1), (1, 0), (0, 1))
que = deque()
cur = 0
for i in range(Y):
    for j in range(X):
        if C[i][j] or D[i][j] != -1:
            continue
        D[i][j] = cur
        que.append((j, i))
        while que:
            x, y = que.popleft()
            for dx, dy in dd:
                nx = x + dx; ny = y + dy
                if C[ny][nx] or D[ny][nx] != -1:
                    continue
                D[ny][nx] = cur
                que.append((nx, ny))
        cur += 1

N = cur
INF = 10**9
G = [[] for i in range(N)]
for i in range(1, Y-1):
    for j in range(1, X-1):
        a = D[i-1][j]; b = D[i+1][j]
        if a != -1 != b != a:
            G[a].append(b)
            G[b].append(a)
        a = D[i][j-1]; b = D[i][j+1]
        if a != -1 != b != a:
            G[a].append(b)
            G[b].append(a)

Q = int(input())
for i in range(Q):
    sx, sy, gx, gy = map(int, input().split())
    x0 = (bisect(X0, sx)-1)*2+1; y0 = (bisect(Y0, sy-1)-1)*2+1
    x1 = (bisect(X0, gx)-1)*2+1; y1 = (bisect(Y0, gy)-1)*2+1
    assert D[y0][x0] != -1 and D[y1][x1] != -1
    s = D[y0][x0]; t = D[y1][x1]
    que = deque([s])
    U = [-1]*N
    U[s] = 0
    while que:
        v = que.popleft()
        d = U[v]
        for w in G[v]:
            if U[w] != -1:
                continue
            U[w] = d+1
            que.append(w)
    print(U[t])



Measured memory_bytes: 7268
import sys,os
from collections import defaultdict, deque
from math import ceil, floor
if sys.version_info[1] >= 5:
    from math import gcd
else:
    from fractions import gcd
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    MOD = 10**9+7

    R = II()
    pi2 = 6.28318530717958623200
    print(R*pi2)

if __name__ == '__main__':
    main()

Measured memory_bytes: 65136
#include<bits/stdc++.h>
#define ll long long int
#define pii pair<int,int>
#define F first
#define S second
using namespace std;
#define mod 1000000007

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    string s,t; cin>>s>>t;
    int ans=1e9;
    for(int i=0;i<s.size();i++){
        int curr=0;
        if(t.size()>s.size()-i)break;
        int k=i;
        for(int j=0;j<t.size();j++){
            if(s[k]!=t[j])curr++;
            k++;
        }
        ans=min(ans,curr);
    }
    cout<< ans <<endl;


}


Measured memory_bytes: 3648
N, A, B = [int(x) for x in input().split()]

ans = 0

for i in range(1, N + 1):
	s = str(i)
	SUM = 0
	for j in range(len(s)):
		SUM += int(s[j])
	if SUM >= A and SUM <= B:
		ans += i

print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
const int N=3e3+5;
typedef long long ll;
ll dp[N][N][2];
int a[N];
void dfs(int,int);
int main(){
    memset(dp,0x3f,sizeof(dp));
    int n;scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",a+i);
    dfs(1,n);
    cout<<dp[1][n][0];
}
void dfs(int l,int r){
    if(dp[l][r][0]!=0x3f3f3f3f3f3f3f3f) return;
    if(l==r){
        dp[l][r][0]=a[l];
        dp[l][r][1]=-a[l];
        return;
    }
    dfs(l+1,r),dfs(l,r-1);
    dp[l][r][0]=max(dp[l+1][r][1]+a[l],dp[l][r-1][1]+a[r]);
    dp[l][r][1]=min(dp[l+1][r][0]-a[l],dp[l][r-1][0]-a[r]);
}


Measured memory_bytes: 141568
import sys
input = sys.stdin.readline

MOD = 10**9 + 7
def main():
    S = input()
    N = len(S)-1

    dp = [0] * 13
    dp[0] = 1

    for i in range(N):
        dppre = dp
        dp = [0] * 13

        if S[i] == '?':
            R = range(10)
        else:
            R = [int(S[i])]
        
        for j in range(13):
            for k in R:
                dp[(j * 10 + k) % 13 ] += dppre[j]
        for j in range(13):
            dp[j] %= MOD

    print(dp[5])
if __name__ == '__main__':
    main()

Measured memory_bytes: 42604
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
char s[100005], f[2][200005], c;
int q, e[2], r, t, g, len;
int main(){
	scanf("%s\n%d", s, &q);
	len = strlen(s);
	rep(i,q){
		scanf("%d", &t);
		if(t == 1) r ^= 1;
		else{
			scanf("%d %c", &g, &c);
			f[r^(g==2)][e[r^(g==2)]++] = c;
		}
	}
	if(r){
		for(int i=e[1]-1; i >= 0; i--) printf("%c", f[1][i]);
		for(int i=len-1; i>=0; i--) printf("%c", s[i]);
		for(int i=0; i<e[0]; i++) printf("%c", f[0][i]);
	}else{
		for(int i=e[0]-1; i >= 0; i--) printf("%c", f[0][i]);
		for(int i=0; i<len; i++) printf("%c", s[i]);
		for(int i=0; i<e[1]; i++) printf("%c", f[1][i]);
	}
	puts("");
}

Measured memory_bytes: 896
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        int n = s.length;
        int rstart = -1;
        int lstart = -1;
        int[] ans = new int[n];
        for (int i = 0; i < n; i++) {
            if(s[i] == 'R'){
                if(rstart < 0){
                    rstart = i;
                    if(0 < lstart){
                        int x = i-lstart;
                        int y = x/2;
                        ans[lstart-1] += y;
                        ans[lstart] += x-y;
                        lstart = -1;
                    }
                }
            }else{
                if(lstart < 0){
                    lstart = i;
                    int x = i - rstart;
                    int y = x/2;
                    ans[i] += y;
                    ans[i-1] += x-y;
                    rstart = -1;
                }
            }
        }
        int x = n-lstart;
        int y = x/2;
        ans[lstart-1] += y;
        ans[lstart] += x-y;
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            sb.append(ans[i] + " ");
        }
        System.out.println(sb.toString());
        sc.close();

    }

}


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

int main(){
  int n; cin>>n;
  int ans=n;
  for(int i=0;i<=n;i++){
    int res=0,t=i;
    while(t!=0){
      res+=t%6;
      t/=6;
    }t=n-i;
    while(t!=0){
      res+=t%9;
      t/=9;
    }ans=min(ans,res);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int N,S,sum,mx,mn;
    while(cin >> N && N>0)
    {
        sum = 0;
        mx = -1;
        mn = 1001; 
        for(int i=0; i<N; ++i)
        {
            cin >> S;
            sum += S;
            mx = max(S,mx);
            mn = min(S,mn);
        }
        cout << (sum - mx - mn) / (N - 2) << endl;
    }
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const ll max_co = 3234600000;
vl ans;
int main(){
    int n,m;
    cin>>n>>m;
    vi a(n);
    rep(i,n){
        cin>>a[i];
    }
    vector<pair<int,int>>me;
    rep(i,m){
        int c,b;
        cin>>b>>c;
        me.push_back({c,b});
    }
    sort(been(me));
    sort(been(a));    
    ll ans =0;
    int j=0;
    for(int i =m-1;me[i].first>a[j];i--){
        int x =j;
        for(int _ =0;j<x+me[i].second&&j<n&&a[j]<me[i].first;j++){
            ans+=me[i].first;
            a[j]=me[i].first;
        }
    }
    rep2(i,j,n){
        ans+=a[i];
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 1784
#include <iostream>
#include<algorithm>
#include<string>
#include<vector>
#include <math.h>
#include <iomanip>

using namespace std;

int main()
{
	string s1,s2,s3;
	cin >> s1 >> s2 >> s3;
	cout << "A" << s2[0] << "C" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;

int main(){
    ll h;
    cin>>h;
    ll ans = 0;
    ll hoge = 1;
    while(h>0){
        ans += hoge;
        hoge = hoge * 2;
        h = h / 2;
    }
    cout<<ans<<endl;
    return 0;
}

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

string s, t;
vector<int> v[30], w[30];
bool f = true;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> s >> t;
	for(int i=0; i<s.size(); ++i)
		v[s[i]-'a'].push_back(i);
	for(int i=0; i<t.size(); ++i)
		w[t[i]-'a'].push_back(i);
	for(int i=0; i<26; ++i)
		for(int j=1; j<v[i].size(); ++j)
			if(t[v[i][0]] != t[v[i][j]])
				f = false;
	for(int i=0; i<26; ++i)
		for(int j=1; j<w[i].size(); ++j)
			if(s[w[i][0]] != s[w[i][j]])
				f = false;
	if(f) cout << "Yes\n";
	else cout << "No\n";
}


Measured memory_bytes: 2824
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> vi;
#define endl '\n'
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define rf(i,a,b) for(int i=a;i>=b;i--) 
#define fast_io ios_base::sync_with_stdio(0);
#define show(x) cout<<x<<endl;
#define pret(x) cout<<x<<endl; return 0;
#define disp(x) cout<<x<<" ";
#define let(x,y) cout<<x<<" "<<y<<endl;
ll MOD=1e9+7;
const int maxn=2e5+5;

int f(){
	int k;
	cin>>k;
	vi visited(k+10,0);
	int curr = (7)%k;
	for (int i = 1; i < 1000010; ++i)
	{
		// show(curr);
		// let(curr, visited[curr]);
		if(visited[curr]) return -1;
		if(curr == 0) return i;
		visited[curr] = 1;
		curr = curr * 10 + 7;
		curr %= k;
	}
}

int32_t main(){
    fast_io;
    int t=1;
    // cin>>t;
    while(t--){
    	show(f());

    	// f();

    	// if(f()){
    	// 	cout<<"Yes"<<endl;
    	// }
    	// else cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 11104
N,M=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(N)]

AB.sort()

rest=M
shop=0
money=0
while True:
    #print(shop,money,rest)
    if AB[shop][1]<rest:
        money+=AB[shop][1]*AB[shop][0]
        rest-=AB[shop][1]
        shop+=1
    else:
        money+=AB[shop][0]*rest
        break

print(money)

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

int main()
{
  string s;
  cin >> s;
  if (s == "ABC"){
    cout << "ARC" << endl;
  }
  else {
    cout << "ABC" << endl;
  }
  return 0;
}


Measured memory_bytes: 3620
#! usr/bin/perl
 
use strict;
use warnings;
 
chomp(my $line = <STDIN>);
my ($K,$S) = split ' ',$line;

my $count = 0;

foreach my $x (0..$K) {
    foreach my $y (0 .. $K) {
            my $z = $S - $x - $y;
            if (0 <= $z && $z <= $K) {$count++;}
    }
} 

print "$count\n"


Measured memory_bytes: 640
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

    int n, k; cin>>n>>k;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin>>a[i];

    if(k == 1){
        cout << 0 << endl;
        return 0;
    }

    vector<ll> sum(n+1, 0);
    for(int i=0; i<n; i++) sum[i+1] = (sum[i] + a[i]) % k;

    map<int, int> cnt;
    cnt[0] = 1;

    ll ans = 0;
    for(int r=1; r<=n; r++){
        int x = (((sum[r] - r) % k) + k) % k;
        ans += cnt[x];
        cnt[x]++;

        // 要素の数が k 以上になった場合、左から消していく
        int l = r - k + 1;
        if(0 <= l){
            int y = (((sum[l] - l) % k) + k) % k;
            cnt[y]--;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 12032
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (a), _end_ = (b); i < _end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define X first
#define Y second
#define mp make_pair
#define eb emplace_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;
typedef long double LD;
typedef pair<int, int> pii;
typedef unsigned long long uLL;

template <typename T> inline void Read(T &x) {
    char c = getchar();
    bool f = false;
    for (x = 0; !isdigit(c); c = getchar()) {
        if (c == '-') {
            f = true;
        }
    }
    for (; isdigit(c); c = getchar()) {
        x = x * 10 + c - '0';
    }
    if (f) {
        x = -x;
    }
}

const int MAX_N = 1100;
const double eps = 1e-8;
const double PI = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;



int n;
double t, a;
double h[1005];

int main() {
#ifdef ANONYM
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif

    cin >> n >> t >> a;
    double mi = INF;
    int ans = -1;
    for(int i=1; i<=n; i++) {
        cin >> h[i];
        h[i] = t - h[i] * 0.006;
        double err = fabs(h[i] - a);
        if(err < mi) mi = err, ans = i;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
P = list(map(int,input().split()))
ans = 0
for i in range(1, n - 1):
    now = P[i]
    tmp = [P[i - 1], P[i], P[i + 1]]
    tmp.sort()
    if now == tmp[1]:
        ans += 1
print(ans)

Measured memory_bytes: 38256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

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

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

int main(){
    int n,x,t;
    cin>>n>>x>>t;
    if(n%x==0){
        cout<<(n/x)*t<<"\n";
    }
    else{
        cout<<(n/x)*t+t<<"\n";
    }
    return 0;
}


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


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    if(fopen(".inp", "r")) freopen(".inp", "r", stdin);
    int n;
    long long d;
    cin >>n >> d;
    d = d*d;
    int cnt=0;
    for(int i=1 ; i<=n ; ++i) {
        long long a, b; cin >> a >> b;
        if(a*a + b*b <= d) ++cnt;
    }
    cout << cnt;


    return 0;
}


Measured memory_bytes: 3660
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ull, ull> UP;
typedef tuple<int, int, int> T;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
ll digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}
ll countpow(ll a, ll b) {
	int ans = 0;
	if (b == 0)return -1;
	while (1) {
		if (a % b == 0) {
			a /= b;
			ans++;
		}
		else break;
	}
	return ans;
}


int main() {
	IOS;
	string s;
	char a[26] = {};
	cin >> s;
	char x = 0;
	REP(i, s.size()) {
		a[s[i] - 'a']++;
	}
	REP(i, 26) {
		if (a[i] == 0) {
			x = 'a' + i;
			break;
		}
	}
	if (x == 0)cout << "None" << endl;
	else cout << x << endl;
}



Measured memory_bytes: 512
S=input()

if S=='SUN':
  print(7)
elif S=='MON':
  print(6)
elif S=='TUE':
  print(5)
elif S=='WED':
  print(4)
elif S=='THU':
  print(3)
elif S=='FRI':
  print(2)
else:
  print(1)




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

using namespace std;

int main()
{
    int N;
    string y;
    float x, Sum = 0;
    cin >> N;

    for (int i = 0; i < N; i++)
    {
        cin >> x >> y;

        if (y == "JPY")
        {
            Sum += x;
        }

        if (y == "BTC")
        {
            Sum += 380000.0 * x;
        }
    }

    cout << Sum;
}

Measured memory_bytes: 256
n,*h=map(int,open(0).read().split())
dp=[0]*n
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
    dp[i]+=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[-1])

Measured memory_bytes: 57872
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <map>
#include <vector>

using namespace std;

void b_81(void) {
	int n;
	cin >> n;

	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			if (i * j == n) {
				cout << "Yes" << endl;
				return;
			}
		}
	}
	cout << "No" << endl;
	return ;
}

int main()
{
    b_81();

    return 0;
}

Measured memory_bytes: 3632
# 176 C
N = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(len(A)-1):
    if A[i] > A[i+1]:
        ans += (A[i] - A[i+1])
        A[i+1] = A[i]
        
print(ans)

Measured memory_bytes: 32180
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << '\n';
typedef int64_t Int;
Int mod = 1e9+7;
Int INF = 1e9+18;

int main() {
    ios::sync_with_stdio(false);
    Int n, k;
    cin >> n >> k;
    vector<Int> a(n);
    vector<Int> b(n + 1, 0);
    vector<Int> c(n + 1, 0);
    Int sum = 0;
    for (Int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] > 0) sum += a[i];
    }
    for (Int i = 0; i < n; i++) b[i + 1] += b[i] + a[i];
    for (Int i = 0; i < n; i++) {
        if (a[i] > 0) c[i + 1] += a[i];
        c[i + 1] += c[i];
    }
    Int res = 0;
    for (Int i = 0; i <= n - k; i++) {
        Int ma = max((Int)0, b[i + k] - b[i]);
        res = max(res, ma + sum - (c[i + k] - c[i]));
    }
    dump(res);
    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int a[34]={0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}; 
int main()
{
	int n;
	cin>>n;
	cout<<a[n]<<endl;
	return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> P1;
typedef pair<P, P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i, x) for (long long i = 0; i < x; i++)
#define repn(i, x) for (long long i = 1; i <= x; i++)
#define SORT(x) sort(x.begin(), x.end())
#define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end())
#define POSL(x, v) (lower_bound(x.begin(), x.end(), v) - x.begin())
#define POSU(x, v) (upper_bound(x.begin(), x.end(), v) - x.begin())
vector<pair<string, P> > vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(long long K, std::vector<long long> A) {
    auto check1 = [&](ll d) {
        bool flg = false;
        ll n = d;
        rep(i, K) {
            if (n >= A[i])
                n -= n % A[i];
            else
                return false;
        }
        if (n >= 2)
            return true;
        else
            return false;
    };

    auto check2 = [&](ll d) {
        bool flg = false;
        ll n = d;
        rep(i, K) {
            if (n >= A[i])
                n -= n % A[i];
            else
                return false;
        }
        if (n >= 3)
            return true;
        else
            return false;
    };

    // 二分探索
    ll left = -1, right = (ll)2e18;
    while (right - left > 1) {
        ll mid = (left + right) >> 1;
        if (check1(mid))
            right = mid;
        else
            left = mid;
    }

    ll n = right;
    rep(i, K) { n -= n % A[i]; }

    if (n != 2) {
        cout << "-1" << endl;
    } else {
        cout << right << " ";

        left = -1, right = (ll)2e18;
        while (right - left > 1) {
            ll mid = (left + right) >> 1;
            if (check2(mid))
                right = mid;
            else
                left = mid;
        }
        cout << left << endl;
    }
}

int main() {
    long long K;
    scanf("%lld", &K);
    std::vector<long long> A(K);
    for (int i = 0; i < K; i++) {
        scanf("%lld", &A[i]);
    }
    solve(K, std::move(A));
    return 0;
}


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

// Debug
#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

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

#define SZ(x) ((int)(x).size())

#define all(x) begin(x),end(x)


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

// std::vector debug
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "[";
    for (auto& e : v) os << e << ", ";
    return os << "]";
}

// std::pair debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    return os << "(" << p.first << " " << p.second << ")";
}

// infty
template<typename T>
T inf() { return numeric_limits<T>::max(); }

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

const ll MOD = 1e9+7;
const ld EPS = 1e-9;


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

    for (;;) {
        int n, a, b, c, x;
        cin >> n >> a >> b >> c >> x;
        if (n == 0) break;
        vi y(n);
        rep (i, n) cin >> y[i];
        int now = 0, ans = -1;

        rep (i, 10001) {
            if (y[now] == x) {
                if (++now == n) {
                    ans = i;
                    break;
                }
            }
            x = (a * x + b) % c;
        }

        cout << ans << endl;
    }

    return 0;
}



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

int main() {
	char S[4];
	string T;
	int a = 0;
	int A = 0;
	int b = 0;
	int B = 0;
	int c = 0;
	int C = 0;
	int q, w, z;
	int n = 0;
	int x = 0;
	int y = 0;
	int ans = 0;
	cin >> n >> a >> x >> y;
	for (int i = 1; i < n+1; i++) {
		if (i > a) {
			ans += y;
		}
		else {
			ans += x;
		}
	}
	
	cout << ans;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = ReadInt();
            var N = ReadInt();
            for (int i = 0; i < N; i++)
            {
                var ab = ReadInts();
                var a = ab[0];
                var b = ab[1];
                var min = Min(a - 1, Min(n - a, Min(b - 1, n - b)));
                WriteLine((min % 3) + 1);
            }
        }
        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}



Measured memory_bytes: 15904
#
n = int(input())
s = []
for _ in range(n):
    #s.append(list(input())) # !!!
    #s.append(sorted(list(input()))) # !!!
    #s.append(sorted(input())) # !!!
    s.append([''.join(sorted(input()))])
    #s += [''.join(sorted(input()))]
    #''.join(sorted((sorted(input()))
s = sorted(s)
#print(s)

a = []
x = 1
for i in range(1,n):
    if s[i] == s[i-1]:
        x += 1
    else:
        a.append(x)
        x = 1
else:
    a.append(x)
#print(a)

y = 0
for j in a:
    y += j*(j-1)/2

print(int(y))


Measured memory_bytes: 20860
#include<cstdio>
#include<algorithm>
using namespace std;
int n, w[101000], G[101000], s, c;
int main(){
    int i, ck;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%d",&w[i]);
    }
    for(i=1;i<n;i++){
        if(w[i]<w[i+1])G[i] = 1;
        if(w[i]>w[i+1])G[i] = 2;
    }
    for(i=1;i<n;i++){
        s|=G[i];
        if(s==3)c++,s=0;
    }
    printf("%d\n",c+1);
}

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

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

Measured memory_bytes: 3588
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split();
        var a = int.Parse(input[0]);
        var b = int.Parse(input[1]);

        var m = Math.Min(a, b);
        for (int i = 0; i < Math.Max(a, b); i++)
        {
            Console.Write(m);
        }
        Console.WriteLine();
    }
}


Measured memory_bytes: 11092
N,M,C=gets.chomp.split.map(&:to_i)
B=gets.chomp.split.map(&:to_i)
ans = 0
N.times do
  a=gets.chomp.split.map(&:to_i)
  t=0
  a.each_with_index do |v,i|
    t += v * B[i]
  end
  ans +=1 if t + C > 0
end
puts ans
     


Measured memory_bytes: 3836
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
int prime(int n)
{
    for(int i=3;i<=n/2+1;i+=2)
        if(n%i==0)
        {
            return 0;
        }
    return 1;
}
int main()
{
    int n;
    cin>>n;
    if(n==2)
    {
        cout<<n;
        return 0;
    }
    if(n%2==0) n++;
    while(prime(n)==0)
    {
        n+=2;
    }
    cout<<n;
}

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

long long int res = 0;

// op: 1->concat 2-> plus
void search(string input, int op, stack<long long int> st)
{
    stack<long long int> stt = st;
    long long int tmp;
    if (input.length() == 1) {
        switch (op) {
            case 1:
                tmp = st.top();
                st.pop();
                st.push(tmp * 10 + (long long int)(input[0] - '0'));
                break;
            case 2:
                st.push((long long int)(input[0] - '0'));
                break;
            default:
                st.push((long long int)(input[0] - '0'));
                break;
        }
        while (!st.empty()) {
            res += st.top();
            st.pop();
        }
    }
    else {
        switch (op) {
            case 1:
                tmp = stt.top();
                stt.pop();
                stt.push(tmp * 10 + (long long int)(input[0] - '0'));
                search(input.substr(1), 1, stt);
                search(input.substr(1), 2, stt);
                break;
            case 2:
                stt.push((long long int)(input[0] - '0'));
                search(input.substr(1), 1, stt);
                search(input.substr(1), 2, stt);
                break;
            default:
                tmp = (long long int)(input[0] - '0');
                stt.push(tmp);
                search(input.substr(1), 1, stt);
                search(input.substr(1), 2, stt);
        }
    }
}

int main(int argc, char const* argv[])
{
    string input;
    cin >> input;
    stack<long long int> st;

    search(input, 0, st);
    
    cout << res << endl;
    return 0;
}


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

typedef long long ll;

int main() {

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    ll a = 0, b = 0;
    char s;

    cin >> a >> s >> b;

    if(s == '+') {
        cout << a + b << endl;
    }
    else {
        cout << a - b << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int D,T,S;
    cin >> D >> T >> S;
    if (T * S >= D) cout << "Yes" << endl;
    else cout << "No" << endl;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

ll h, w;
vll dx = {1, 0, -1, 0};
vll dy = {0, 1, 0, -1};

vvll a(51, vll(51));

bool isin(ll y, ll x){
    return (y >= 0 && y < h && x >= 0 && x < w);
}

ll bfs(ll y, ll x){
    vvll visited(h, vll(w)), d(h, vll(w));
    queue<P> que;
    que.push(P{y, x});
    d[y][x] = 0;
    visited[y][x] = 1;
    while(!que.empty()){
        ll cy = que.front().first, cx = que.front().second;
        que.pop();
        REP(i, 4){
            ll ny = cy + dy[i], nx = cx + dx[i];
            if(!isin(ny, nx) || visited[ny][nx] || a[ny][nx]) continue;
            que.push(P{ny, nx});
            d[ny][nx] = d[cy][cx] + 1;
            visited[ny][nx] = 1;
        }
    }
    if(visited[h - 1][w - 1]) return d[h - 1][w - 1];
    else return -1;
}
int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> h >> w;
    ll black = 0;
    char c;
    REP(i, h){
        REP(j, w){
            cin >> c;
            if(c == '#'){
                a[i][j] = 1;
                black++;
            }
        }
    }
    if(bfs(0, 0) == -1){
        cout << -1 << endl;
        return 0;
    }
    ll res = h * w - black - bfs(0, 0) - 1;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main() {
	int h, n;
	cin >> h >> n;
	int skil[100000];
	for (int i = 0; i < n; i++)
		cin >> skil[i];
	for (int i = 0; i < n; i++)
		h -= skil[i];
	if (h > 0)
		cout << "No";
	else
		cout << "Yes";
}

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

#define int long long
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define vcopy(v1,v2) copy((v1).begin(), (v1).end(), back_inserter((v2)));
#define pb(n) push_back(n);

string s;

main() {
    cin >> s;
    s[5] = ' ';
    s[13] = ' ';
    ct(s)
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void) {
    std::deque<int> deq;
    for (int i=0;i<10001;i++) {
        if (i==0) {
            deq.emplace_back(0);
        } else if (i==1) {
            deq.emplace_back(2);
        } else {
            deq.emplace_back(deq[i-1]+i);
        }
    }
    int n;
    while (cin>>n) {
        cout<<deq[n]<<endl;
    }
}


Measured memory_bytes: 3096