akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CLEAR(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

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

const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };


const int MAX = 1500 * 1000 + 810;
void count(int n, int* c)
{
	int len[2048];
	rep (i, n)
		scanf("%d", len + i);
	fill_n(c, MAX, 0);
	for (int i = 0; i < n; ++i)
	{
		int s = 0;
		for (int j = i; j < n; ++j)
		{
			s += len[j];
			++c[s];
		}
	}
}
int main()
{
	int n, m, t;
	while (scanf("%d%d", &n, &m), n | m)
	{
		static int hor[MAX], ver[MAX];
		count(n, ver);
		count(m, hor);
		int res = 0;
		for (int i = 0; i < MAX; ++i)
			res += ver[i] * hor[i];
		printf("%d\n", res);
	}
}

Measured memory_bytes: 0
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

/**
 *
 * @author baito
 */
public class Main {
    static StringBuilder sb = new StringBuilder();
    /**
     * @param args the command line arguments
     * @throws java.lang.Exception
     */
    public static void main(String[] args) throws Exception {
        // TODO code application logic here
        ContestScanner sc = new ContestScanner();
        int n = sc.nextInt();
        char[] c;
        boolean[] dic = new boolean[244140625];
        for (int i = 0; i < n; i++) {

            c = sc.readLine().toCharArray();
            {
                if (c[0] == 'i') {
                    dic[hash(Arrays.copyOfRange(c, 7, c.length))] = true;
                } else {
                    if(dic[hash(Arrays.copyOfRange(c, 5, c.length))]==true)
                        sb.append("yes\n");
                    else
                        sb.append("no\n");
                }
            }
        }
        System.out.print(sb);
    }

    public static int hash(char[] c) {
        int p;
        int hash = 0;
        for (int i = 0; i < c.length; i++) {
            switch (c[i]) {
                case 'A':
                    p = 1;
                    break;
                case 'C':
                    p = 2;
                    break;
                case 'G':
                    p = 3;
                    break;
                default:
                    p = 4;
                    break;
            }
            hash = hash * 5 + p;

        }
        return hash;
    }

}

//????????????????????????
class ContestScanner {

    private final BufferedReader reader;
    private String[] line;
    private int idx;

    public ContestScanner() throws FileNotFoundException {
        reader = new BufferedReader(new InputStreamReader(System.in));
    }

    public ContestScanner(String filename) throws FileNotFoundException {
        reader = new BufferedReader(new InputStreamReader(new FileInputStream(filename)));
    }
    //???????????? 

    public String readLine() throws Exception {
        return reader.readLine();
    }

    public String nextToken() throws IOException {
        if (line == null || line.length <= idx) {
            line = reader.readLine().trim().split(" ");
            idx = 0;
        }
        return line[idx++];
    }

    public long nextLong() throws IOException, NumberFormatException {
        return Long.parseLong(nextToken());
    }

    public int nextInt() throws NumberFormatException, IOException {
        return (int) nextLong();
    }

    public double nextDouble() throws NumberFormatException, IOException {
        return Double.parseDouble(nextToken());
    }
}

Measured memory_bytes: 314056
#include<iostream>
#include<vector>
using namespace std;
int cnt=1;
void depth(vector< vector<int> > &vv,vector<int> &f,vector<int> &c,int num){
	f[num]=cnt;
	cnt++;
	for(int i=0; i<vv[num].size(); i++){
		if(vv[num][i]!=0 && f[i]==0){
			depth(vv,f,c,i);
		}
	}

		c[num]=cnt;
		cnt++;

}
int main(){
	int n;
	cin>>n;
	vector< vector<int> > v(n,vector<int> (n,0));
	vector<int> ft(n,0);
	vector<int> ct(n,0);
	int u[n];
	for(int i=0; i<n; i++){
		int k;
		cin>>u[i]>>k;
		for(int j=0; j<k; j++){
			int x;
			cin>>x;
			v[i][x-1]=1;
		}
	}
	for(int i=0; i<n; i++){
		if(ft[i]==0){
			depth(v,ft,ct,i);
		}
	}
	for(int i=0; i<n; i++){
		cout<<u[i]<<" "<<ft[i]<<" "<<ct[i]<<endl;
	}
  return 0;
}


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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

typedef pair<ll, ll> P;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main(){
    int n, m, ans = 0;
    cin >> n >> m;
    vector<int> x(m);
    REP(i, m) cin >> x[i];
 
    if(n >= m) {
        cout << "0" << endl;
        return 0;
    }
    
    sort(x.begin(), x.end());

    vector<int> width(m-1);

    REP(i, m-1) {
        width[i] = x[i+1] - x[i];
    }

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

    /* 上のn個は動かない区間 */
    REP(i, m-n) ans += width[i];

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <array>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b; return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b; return true;
    }
    return false;
}
#define pb push_back
#define mp make_pair
#define mt make_tuple

int main(void)
{
    cin.sync_with_stdio(false);
    int H, W, K;
    cin >> H >> W >> K;
    vector<vector<int>> cells(H, vector<int>(W));
    REP(h, H) {
        REP(w, W) {
            char ch; cin >> ch;
            cells[h][w] = ch - '0';
        }
    }

    ll ans = 1e9;
    vector<int> idxes(H);
    REP(i, (1 << (H - 1))) {

        int now = 0;
        idxes[0] = now;
        REP(j, H - 1) {
            if (i & (1 << j)) {
                ++now;
            }
            idxes[j+1] = now;
        }

        ll local_ans = now;

        // for(auto idx: idxes) cout <<idx << " ";
        // cout << endl;

        vector<int> counter(now + 1);
        REP(w, W) {

            vector<int> counter2(now + 1);
            REP(h, H) {
                int idx = idxes[h];
                counter2[idx] += (cells[h][w] == 1);
            }

            // この列だけでだめなら、ぜったいだめ
            bool ok = true;
            for(auto c: counter2) {
                if (c > K) {
                    ok = false; break;
                }
            }
            if (!ok) {
                local_ans = 1e9;
                break;
            }
            
            // たしてみる
            ok = true;
            REP(j, now + 1) {
                counter[j] += counter2[j];
                if (counter[j] > K) {
                    ok = false; break;
                }
            }
            if (!ok) {
                ++local_ans;
                counter = counter2;
            }
        }
        chmin(ans, local_ans);
    }
    cout << ans << endl;

    return 0;
}


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

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

    ll sum = 0;
    for (int i = 1; i <= n; i++)
    {
        if(i%3==0)
            continue;
        if(i%5==0)
            continue;
        sum += i;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3636
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
//max_element


int N;
int W[101];


signed main()
{
	cin >> N;
	REP(i, N)
	{
		cin >> W[i];
	}

	int mi = INT_MAX;
	for (int t = 0; t <= 100; t++)
	{
		int sum1 = 0;
		int sum2 = 0;
		for (int i = 0; i < N; i++)
		{
			if (i <= t)
			{
				sum1 += W[i];
			}
			else
			{
				sum2 += W[i];
			}
		}
		int m = abs(sum1 - sum2);
		mi = min(mi, m);
	}

	cout << mi << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll n; cin >> n;
    map<ll, ll> cnt;
    rep(i, n){
        ll a; cin >> a;
        cnt[a]++;
        if(a-1 >= 0) cnt[a-1]++;
        if(a+1 < 100000 ) cnt[a+1]++;
    }
    vector<pair<ll, ll>> cntr;
    for(auto p: cnt) cntr.push_back(make_pair(p.second, p.first));
    sort(all(cntr));
    cout << cntr[cntr.size()-1].first << endl;
}

Measured memory_bytes: 8436
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
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 qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}



signed main(){
  int m;
  cin >> m;
  cout << 24+(24-m) fin;
  return 0;
}



struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;



Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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


const ll INF=1e9+7;

vector<ll> used,p,c;
vector<vector<ll>> loop;
ll cnt=0;
void dfs(ll v){
    if(used[v]){
        return;
    }
    used[v]=1;
    loop[cnt].push_back(v);
    dfs(p[v]);
}

int main(){
    ios;
    ll n,k;
    cin >> n >> k;
    used.resize(n);
    p.resize(n);
    c.resize(n);
    rep(i,n){
        cin >> p[i];
        p[i]--;
    }
    rep(i,n){
        cin >> c[i];
    }
    
    loop.resize(n);
    rep(i,n){
        if(used[i]==0){
            dfs(i);
            cnt++;
        }
    }
    ll ans=-INF;
    
    rep(i,cnt){
        ll m=loop[i].size();
        ll tot=0;
        ll r=(k-1)/m;
        ll t=k-r*m;
        ll sum=0;
        
        vector<ll> s(2*m+1);
        rep(j,m){
            sum+=c[loop[i][j]];
            //s[j+1]=s[j]+c[loop[i][j]];
        }
        /*rep(j,m){
            s[m+j+1]=s[m+j]+c[loop[i][j]];
        }*/
        if(sum>0){
            tot+=r*sum;
            ans=max(ans,tot);
        }
        vector<ll> q(2*m);
        rep(j,m){
            tot+=c[loop[i][j]];
            q[j]=tot;
        }
        if(sum<=0 && r>=1) t=m;
        rep(j,t){
            rep(k,m){
                ans=max(ans,q[j]);
                q[j]-=c[loop[i][(0+k)%m]];
                q[j]+=c[loop[i][(j+1+k)%m]];
                ans=max(ans,q[j]);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4152
import java.util.Scanner;

import javax.script.ScriptException;

public class Main {

	/** 7 */
	private static final int SEVEN = 7;

	public static void main(String[] args) throws ScriptException {
		try (Scanner scanner = new Scanner(System.in)) {
			char[] abcd = scanner.next().toCharArray();
			for (int i = 0; i < (1 << abcd.length); i++) {
				if (ok(abcd, i)) {
					System.out.println(toFormula(abcd, i) + "=" + SEVEN);
					return;
				}
			}
		}
	}

	/**
	 * abcdと'+'か'-'を表す二進数で数式を組み立てて、結果が7かどうかを判定
	 * 
	 * @param abcd
	 * @param n    '+'か'-'を表す二進数
	 * @return 結果が7かどうか
	 */
	private static boolean ok(char[] abcd, int n) throws ScriptException {
		int result = abcd[0] - '0';
		for (int i = 1; i < abcd.length; i++) {
			if (1 == (n & 1)) {
				result += abcd[i] - '0';
			} else {
				result -= abcd[i] - '0';
			}
			n >>= 1;
		}
		return SEVEN == result;
	}

	/**
	 * abcdと'+'か'-'を表す二進数で数式を組み立てる
	 * 
	 * @param abcd
	 * @param n    '+'か'-'を表す二進数
	 * @return a?b?c?d の数式
	 */
	private static String toFormula(char[] abcd, int n) {
		StringBuilder result = new StringBuilder();
		for (char c : abcd) {
			result.append(c);
			result.append((1 == (n & 1)) ? '+' : '-');
			n >>= 1;
		}
		// 最後の文字を削除
		result.deleteCharAt(result.length() - 1);
		return result.toString();
	}
}


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

int main() {
  int a, b;
  cin >> a >> b;
  cout << a/b << " ";
  cout << a%b << " ";
  
  double da = (double)a;
  double db = (double)b;
  cout << fixed << setprecision(5) << da/db << endl;
  
  return 0;
}


Measured memory_bytes: 3292
typedef long long LL;LL a,b,c,d;
LL g(LL x,LL y){if(!y)return x;return g(y,x%y);}
main(){
  scanf("%ld%ld%ld%ld",&a,&b,&c,&d);a--;
  printf("%ld",b-a+a/c-b/c+a/d-b/d+b/c*g(c,d)/d-a/c*g(c,d)/d);
}

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

using vi = vector<int>;
#include <boost/range/irange.hpp>
using boost::irange;

template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
}

int main() {
  int n;
  cin >> n;
  vi arr(n);
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
  }
  vi ans;
  for (int i: irange(n, 0, -2)) {
    ans.push_back(arr[i - 1]);
  }
  for (int i: irange(n % 2, n, 2)) {
    ans.push_back(arr[i]);
  }
  print(ans);
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	int N;
	cin>>N;
	cout<<"Christmas";
	while(N<25) N++, cout<<" Eve";
	cout<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmax(v) v.rbegin()->first
#define mapmin(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const int mod=1000000007;
const int mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

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

void YES(bool b) {cout << (b?"YES\n":"NO\n");}
void Yes(bool b) {cout << (b?"Yes\n":"No\n");}
void yes(bool b) {cout << (b?"yes\n":"no\n");}
void Yay(bool b) {cout << (b?"Yay!\n":":(\n");}

long long powmod(long long a,long long b){
    long long c=1;
    while(b>0){
        if(b&1) c=a*c%mod;
        a=a*a%mod;
        b>>=1;
    }
    return c;
}

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	string s;
	cin >> s;
	ll n=SIZE(s);
	vll a(n+1);
	rep(i,n){
		if(s[i]=='<') chmax(a[i+1],a[i]+1);
	}
	for(ll i=n-1;i>=0;i--){
		if(s[i]=='>') chmax(a[i],a[i+1]+1);
	}
    cerr<<a<<endl;
	cout << sumvec(a) << endl;
	return 0;
}

Measured memory_bytes: 4740
#include <iostream>
#include <algorithm>

using namespace std;

typedef unsigned long long ll;

int N;

ll gcd(ll a, ll b) {
	if (a == 0 || b == 0)
		return a + b;
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a/gcd(a, b)*b;
}

int main() {
	cin >> N;
	ll min = 1;
	for (int i = 0; i < N; ++i) {
		ll tmp;
		cin >> tmp;
		min = lcm(min, tmp);
	}
	cout << min << endl;
}

Measured memory_bytes: 256
//#define LOCAL

#include <fstream>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <climits>

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

#define int long long

using namespace std;

int N, A, B;
int X[100010];

signed main()
{
#ifdef LOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif

    cin >> N >> A >> B;
    rep(i,N) cin >> X[i];

    int ans = 0;
    for (int i=1; i<N; i++) {
        if ((X[i] - X[i-1]) * A > B) {
            ans += B;
        } else {
            ans += (X[i] - X[i-1]) * A;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
int main() {
    string s;
    cin >> s;
    int n = s.size();
    int x, y;
    cin >> x >> y;
    vector<int> ord(1, 0);
    char now = s[0];
    for(int i = 0; i < s.size(); i++) {
        if(now == 'F' && s[i] == 'F') {
            ord.back()++;
        }
        if(now == 'F' && s[i] == 'T') {
            ord.push_back(0);
            now = 'T';
        }
        if(now == 'T' && s[i] == 'F') {
            ord.push_back(1);
            now = 'F';
        }
        if(now == 'T' && s[i] == 'T') {
            ord.push_back(0);
            now = 'F';
        }
    }
    int m = ord.size();
    /*
    for(auto e : ord) {
        cout << e << " ";
    }
    cout << endl;
    */
    vector<int> ox, oy;
    if(ord[0] == 0) {
        for(int i = 0; i < m; i++) {
            if(i % 4 == 1) {
                oy.push_back(ord[i]);
            }
            if(i % 4 == 3) {
                ox.push_back(ord[i]);
            }
        }
    }
    if(ord[0] != 0) {
        for(int i = 0; i < m; i++) {
            if(i % 4 == 0) {
                ox.push_back(ord[i]);
            }
            if(i % 4 == 2) {
                oy.push_back(ord[i]);
            }
        }
    }
    int p = ox.size(), q = oy.size();
    vector<vector<bool>> dpx(2 * n + 10, vector<bool>(p + 1, 0));
    vector<vector<bool>> dpy(2 * n + 10, vector<bool>(q + 1, 0));
    dpx[n + 5][0] = true;
    for(int j = 1; j <= p; j++) {
        for(int i = 0; i < 2 * n + 10; i++) {
            if(i - ox[j - 1] >= 0 && dpx[i - ox[j - 1]][j - 1]) {
                dpx[i][j] = true;
            }
            if(ord[0] != 0 && j == 1) {
                continue;
            }
            if(i + ox[j - 1] < 2 * n + 10 && dpx[i + ox[j - 1]][j - 1]) {
                dpx[i][j] = true;
            }
        }
    }
    dpy[n + 5][0] = true;
    for(int j = 1; j <= q; j++) {
        for(int i = 0; i < 2 * n + 10; i++) {
            if(i - oy[j - 1] >= 0 && dpy[i - oy[j - 1]][j - 1]) {
                dpy[i][j] = true;
            }
            if(i + oy[j - 1] < 2 * n + 10 && dpy[i + oy[j - 1]][j - 1]) {
                dpy[i][j] = true;
            }
        }
    }
    if(dpx[x + n + 5][p] && dpy[y + n + 5][q]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 17536
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int len=s.size();
	int flag=1;
	for(int i=0;i<len;i++)
	{
		for(int j=i+1;j<len;j++)
		{
			if(s[i]==s[j])
			{
				flag=0;
				break;
			}
		}
		if(flag==0)
		{
			cout<<"no"<<endl;
			break;
		}
	}
	if(flag==1)
	{
		cout<<"yes"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
while True:
    h, w = map(int, input().split())
    if h == 0 and w == 0:
        exit()
    else:
        print('#' * w)
        for _ in range(h - 2):
            print('#' + '.' * (w - 2) + '#')
        print('#' * w)
        print()


Measured memory_bytes: 5616
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

struct Node{
	int key;
	struct Node *r,*l,*p;
}Node;

struct Node *root , *NIL;

void insert( int k ){
	struct Node *y = NIL;
	struct Node *x = root;
	struct Node *z;
	
	z = ( struct Node *)malloc( sizeof(struct Node) );
	z->key = k;
	z->l = NIL;
	z->r = NIL;
	
	while( x != NIL ){
		y = x;
		if( z->key < x->key ){
			x = x->l;
		}else{
			x = x->r;
		}
	}
	z->p = y;
	
	if( y == NIL ){
		root = z;
	}else{
		if( z->key < y->key ){
			y->l = z;
		}else{
			y->r = z;
		}
	}
}

void preorder( struct Node *u ){
	
	if( u == NIL ){
		return;
	}
	printf( " %d" , u->key );
	preorder( u->l );
	preorder( u->r );
}

void inorder( struct Node *u ){
	
	if( u == NIL ){
		return;
	}
	inorder( u->l );
	printf( " %d" , u->key );
	inorder( u->r );
}

struct Node * find( struct Node *u , int k ){
	while( u != NIL && k != u->key ){
		if( k < u->key ){
			u = u->l;
		}else{
			u = u->r;
		}
	}
	return u;
}

struct Node * treeMinimum( struct Node *x ){
	while( x->l != NIL ){
		x = x-> l;
	}
	return x;
}

struct Node * treeSuccessor( struct Node *x ){
	if( x->r != NIL ){
		return treeMinimum( x-> r );
	}
	struct Node *y = x->p;
	
	while( y != NIL && x == y->r ){
		x = y;
		y = y->p;
	}
	return y;
}

void treeDelete(struct Node *z ){
	struct Node *y;
	struct Node *x;
	
	if( z->l == NIL || z->r == NIL ){
		y = z;
	}else{
		y = treeSuccessor(z);
	}
	
	if( y->l != NIL ){
		x = y->l;
	}else{
		x = y->r;
	}
	
	if( x != NIL ){
		x->p = y->p;
	}
	
	if( y->p == NIL ){
		root = x;
	}else{
		if( y == y->p->l ){
			y->p->l = x;
		}else{
			y->p->r = x;
		}
	}
	
	if( y != z ){
		z->key = y->key;
	}
	
	free(y);
}

int main( void ){
	
	int n , i , x;
	char com[10];
	
	scanf( "%d" , &n );
	
	for( i = 0; i < n; i++ ){
		
		scanf( "%s" , com );
		if( strcmp(com , "find") == 0 ) {
			scanf( "%d" , &x );
			struct Node *t = find(root,x);
			if( t!= NIL ){
				printf( "yes\n" );
			}else{
				printf( "no\n" );
			}
		}else if( strcmp(com ,"insert") == 0 ){
			scanf( "%d" , &x );
			insert(x);
		}else if( strcmp(com ,"print") == 0 ){
			inorder(root);
			printf( "\n" );
			preorder(root);
			printf( "\n" );
		}else if( strcmp(com ,"delete") == 0 ){
			scanf( "%d" , &x );
			treeDelete( find(root , x ));
		}
	}
	
	return 0;
}
		
		


Measured memory_bytes: 20472
import java.util.Scanner;

class Dice {

	// ?????¨??¶?????? ???(u),S,E,W,N,???(d) ?????¢?????°??????????????????
	int u;
	int s;
	int e;
	int w;
	int n;
	int d;
	int top;

	public Dice(int[] nums) {
		this.u = nums[0];
		this.s = nums[1];
		this.e = nums[2];
		this.w = nums[3];
		this.n = nums[4];
		this.d = nums[5];
		this.top = this.u;
	}

	public void roll(char dist) {

		int tmp;

		switch (dist) {
		case 'N':
			tmp = u;
			u = s;
			s = d;
			d = n;
			n = tmp;
			break;

		case 'E':
			tmp = u;
			u = w;
			w = d;
			d = e;
			e = tmp;
			break;

		case 'W':
			tmp = u;
			u = e;
			e = d;
			d = w;
			w = tmp;
			break;

		case 'S':
			tmp = u;
			u = n;
			n = d;
			d = s;
			s = tmp;
			break;
		default:
			break;
		}

		this.top = u;
	}
}

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int[] nums = new int[6];
		for (int i = 0; i < 6; i++) {
			nums[i] = sc.nextInt();
		}
		sc.nextLine();

		String orders = sc.nextLine();
		sc.close();

		Dice dice = new Dice(nums);

		for(char order : orders.toCharArray()) dice.roll(order);

		System.out.println(dice.top);

	}
}

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

using namespace std;

#define loop(i, n) for(int i = 0;i < int(n);i++)
#define rloop(i, n) for(int i = int(n);i >= 0;i--)
#define range(i, a, b) for(int i = int(a);i <= int(b);i++)
#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1, v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1, v2, v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1, v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1, v2, v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'

typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
typedef long long ll;
typedef pair<int, int> pii;


const int N = 2e5 + 5;
int person[N], dish[N];
int n;
ll k;

bool valid(ll X) {
    ll need = 0;
    for (int i = 0; i < n; i++) {
        ll mx = X / dish[i];
        if (person[i] > mx)need += person[i] - mx;
    }
    return need <= k;
}


int main() {
#ifndef ONLINE_JUDGE
//    freopen("in.in", "r", stdin);
    //freopen("out.in", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> person[i];
    }

    for (int i = 0; i < n; i++) {
        cin >> dish[i];
    }

    sort(person, person + n);
    sort(dish, dish + n);
    reverse(dish, dish + n);

    ll st = 0, ed = 1e12 + 5;
    //FFFFFTTTTT
    while (st < ed) {
        ll mid = st + (ed - st) / 2;
        if (valid(mid))
            ed = mid;
        else
            st = mid + 1;
    }

    cout << st << endl;

    return 0;
}


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

int main(){
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll x;
    cin >> x;
    
    ll ans = 0;
    ans += (x / 11) * 2;
    if(x % 11 > 6) ans += 2;
    else if(x % 11 > 0) ans += 1;
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int a,b ;
char op ;

int main(void){
    
    scanf ("%d%s%d",&a,&op,&b) ;
    
    if ( op=='+' ){
        printf ("%d\n",a+b) ;
        
    } else {
        printf ("%d\n",a-b) ;
        
    }
    
    return 0 ;
}

Measured memory_bytes: 128
import sys
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math

# MOD = 10 ** 9 + 7
MOD = 998244353
# sys.setrecursionlimit(10**8)

N, M, S = map(int, input().split())
MAX_COST = 2500
S = min(S, MAX_COST)

G = [[] for _ in range(N)]
for i in range(M):
    u, v, s, t = map(int, input().split())
    G[u-1].append([v-1, s, t])
    G[v-1].append([u-1, s, t])

change_rate, change_cost = [], []
for i in range(N):
    rate, cost = map(int, input().split())
    change_rate.append(rate)
    change_cost.append(cost)

# dp[i][silver] = 頂点iにいて、銀貨をsilver枚持つときの最小時間
dp = [[float('inf')] * (MAX_COST + 1) for _ in range(N)]
dp[0][S] = 0

# time,node,silver
pq = [(0, 0, S)]
while pq:
    time, node, silver = heapq.heappop(pq)

    # going through exchange station
    next_silver = min(silver + change_rate[node], MAX_COST)
    next_time = time + change_cost[node]
    if next_time < dp[node][next_silver]:
        dp[node][next_silver] = next_time
        heapq.heappush(pq, (next_time, node, next_silver))

    for nei, ns, nt in G[node]:
        remain_silver = min(silver - ns, MAX_COST)
        next_time = time + nt
        if remain_silver >= 0 and next_time < dp[nei][remain_silver]:
            dp[nei][remain_silver] = next_time
            heapq.heappush(pq, (next_time, nei, remain_silver))

for d in dp[1:]:
    print(min(d))


Measured memory_bytes: 100272
def leap_year?(y)
  (y % 4 == 0 && y % 100 != 0) || (y % 400 == 0)
end

def solve(a, b)
  ans = []
  a.upto(b) do |y|
    ans.push(y) if leap_year?(y)
  end

  if ans.empty?
    puts 'NA'
  else
    ans.each {|y| puts y}
  end
end

first_answer = true

while true
  a, b = gets.split.map(&:to_i)
  break if a == 0 and b == 0

  puts unless first_answer
  solve(a, b)
  first_answer = false
end

Measured memory_bytes: 6108
#include<stdio.h>

int main(void){
    while(1){
        int n,k,i,abc=0,box=0,sum=0,r[100000]={0};
        scanf("%d %d",&n,&k);
        if(n==0&&k==0)break;
        for(i=0;i<n;i++){
            scanf("%d",&r[i]);
        }
        for(i=0;i<k;i++){
            sum=r[i]+sum;
        }
        box=sum+0;
        for(i=0;i<n-k;i++){
            abc=sum-r[i]+r[i+k];
            if(box<abc){
                box=abc+0;
            }
            sum=abc;
        }
        printf("%d\n",box);
        sum=0;
        r[100000]='0';
    }
return 0;
}

Measured memory_bytes: 996
a, b, c, d = map(int, list(input()))
op = ['+', '-']
for op1 in op:
    for op2 in op:
        for op3 in op:
            f = '{}{}{}{}{}{}{}'.format(a, op1, b, op2, c, op3, d)
            if eval(f) == 7:
                print('{}=7'.format(f))
                exit()

Measured memory_bytes: 3060
#include <stdio.h>

int main()
{
  int a,b;
  scanf("%d %d", &a, &b);

  int deff = b - a;
  int sum = 0;
  for(int i=1; i<deff; i++)
    sum += i;

  int snow = sum - a;
  printf("%d\n", snow);

  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long int

#define MOD 1000000007

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

    ll N; cin>>N;
    ll sum1=0, sum2=0;
    for(ll i=0 ; i<N ; i++){
        ll t; cin>>t;
        sum1 = (sum1+t)%MOD;
        sum2 = (sum2 + (t*t)%MOD)%MOD;
    }
    sum1 = (sum1*sum1)%MOD;
    ll ans = ((((sum1 - sum2)%MOD + MOD)%MOD)*500000004)%MOD;
    // cout<<sum1<<" "<<sum2<<endl;
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 3632
n, m = [int(i) for i in input().split()]
ns = [input() for i in range(n)]
ms = [input() for i in range(m)]
for i in range(n):
  a = 0
  b = 0
  for j in ns[i].split():
    b += int(j) * int(ms[a])
    a += 1
  print(b)



Measured memory_bytes: 5636
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int a,b,c;
    char d,e;
  	string s;
  	cin>>a>>b>>c;
  if(a<=b&&a<=c)
    cout<<10*max({b,c})+min({b,c})+a<<endl;
  else if(b<=c&&b<=a) 
    cout<<10*max({a,c})+min({a,c})+b<<endl;
  else if(c<=a&&c<=b) 
    cout<<10*max({a,b})+min({a,b})+c<<endl;
 /* else if(a==23)
    cout<<"Christmas Eve Eve"<<endl;
  else
    cout<<"Christmas Eve Eve Eve"<<endl;
  */
  cout<<s<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Rint register int
using namespace std;
typedef long long LL;
const int N = 20;
int n;
LL a[N];
template<typename T>
inline void chkmin(T &a, const T &b){if(a > b) a = b;}
template<typename T>
inline void read(T &x){
	int ch = getchar(); x = 0;
	while(ch < '0' || ch > '9') ch = getchar();
	while(ch >= '0' && ch <= '9'){x = x * 10 + ch - '0'; ch = getchar();}
}
inline LL dfs(int l, int r, int cl, int cr){
    if(l > r) return 0;
    LL ans = 1e18;
    for(Rint i = l;i <= r;++ i)
        chkmin(ans, dfs(l, i - 1, cl, cl + cr) + dfs(i + 1, r, cl + cr, cr) + (cl + cr) * a[i]);
    return ans;
}
int main(){
    read(n);
    for(Rint i = 1;i <= n;++ i) read(a[i]);
    printf("%lld\n", a[1] + a[n] + dfs(2, n - 1, 1, 1));
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define eb emplace_back
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 233;
int main()
{
	ll n,a,b;cin>>n>>a>>b;
	if(a%2==b%2){
		cout << abs(a-b)/2 << endl;
	}
	else{
		if(a>b)swap(a,b);
		ll ans = a+((b-a)-1)/2;
		a = n-a+1;
		b = n-b+1;
		swap(a,b);
		ans = min(ans,a+((b-a)-1)/2);
		cout << ans << endl;
	}
	return 0;
}


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

const int INF = 1e9 + 5;
int main() {
	int n; cin >> n;
	vi h(n);
	for (int i = 0; i < n; i++){
		cin >> h[i];
	}
	vi dp(n, INF);
	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 - 1] - h[i]), dp[i - 2] + abs(h[i - 2] - h[i]));
	}
	cout << dp[n - 1] << endl;
}





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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const long long MOD = 998244353;

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

    ll n;
    cin >> n;
    ll a, b;
    cin >> a >> b;
    if ((b - a) % 2 == 0)
        cout << (b - a) / 2;
    else
        cout << min(a - 1, n - b) + 1 + (b - a - 1) / 2;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(void)
{
	double n;
	int dn;
	int b;
	vector<int> h(8);
	while(1){
		cin >> n;
		if(n==-1.0) break;
		if(256.0<=n||(n/0.0625-(int)(n/0.0625)!=0.0)){
			cout << "NA" << endl;
			continue;
		}
		dn=(int)n;
		for(int i=7;0<=i;i--){
			if(2^i<dn){
				h[i]=dn%2;
				dn/=2;
			}
		}
		for(int i=0;i<8;i++) cout << h[i];
		cout << '.';
		dn=(int)((n-(int)n)*10000);
		b=5000;
		for(int i=0;i<4;i++){
			if(dn>=b){
				cout << "1";
				dn-=b;
			}
			else cout << "0";
			b/=2;
		}
		cout << endl;
		h.clear();
	}
	return 0;
}

Measured memory_bytes: 1220
#include <stdio.h>
int gcd(int a, int b){
    while(1){
        if(a>b)a%=b;
        else b%=a;
        if(a==0)return b;
        if(b==0)return a;
    }
}
int main(void){
    int n,i,e=0,o=0,r,g=0;
    scanf("%d",&n);
    int a;
    for(i=0;i<n;i++){
        scanf("%d",&a);
        if(a==1){
            printf("1");
            return 0;
        }
        else{
            if(g)g=gcd(a,g);else g=a;
            if(a%2){
            if(a!=o&&o){o=-1;}
            else o=a;
            }
            else if(a!=e&&e){e=-1;}
            else e=a;
        }
    }
    if(g>1) r=g;
    else if(o&&e)r=1;
    else if(o==-1)r=1;
    else if(e==-1)r=2;
    else r=(e>o)?e:o;
    printf("%d",r);
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int value[100];
int sp = 0;

void push(const int val)
{
    value[sp++] = val;
}

int pop()
{
    return value[--sp];
}

void operand(const char operand[])
{
    push(atoi(operand));
}

void operator(const char operator)
{
    int tmp1 = pop(), tmp2 = pop();

    switch( operator ){
    case '+': push(tmp2 + tmp1); break;
    case '-': push(tmp2 - tmp1); break;
    case '*': push(tmp2 * tmp1); break;
    default : break;
    }
}

int main()
{
    while( 1 ){
        char ch[256];
        if( scanf("%s", ch) == EOF ) break;
        if( strcmp(ch, "\n") == 0 ) continue;
        
        switch( ch[0] ){
        case '+': case '-': case '*': operator(ch[0]); break;
        default : operand(ch); break;
        }
    }

    printf("%d\n", pop());

    return 0;
}

Measured memory_bytes: 548
import kotlin.math.log10

fun main() {
    val n = nextInt()
    val values = nextLongList().sorted()
    var res = values[0]
    var logRes = log10(res.toDouble())
    (1 until n).forEach {
        logRes += log10(values[it].toDouble())
        res *= values[it]
    }
    when {
        logRes >= 19 || res > 1_000_000_000_000_000_000L -> println(-1)
        else -> println(res)
    }
}

// # Utils
// ## Input
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = next().split(" ").map(String::toInt)
fun nextLongList() = next().split(" ").map(String::toLong)
fun nextDoubleList() = next().split(" ").map(String::toDouble)

// ## Array
inline fun <reified T> sizedArray(size: Int, default: T) = Array(size) { default }

// ## mod^-1
//    [NOTE] CANNOT use this for 0, mod, 2mod, 3mod ...(return wrong value)
fun modinv(num: Long, mod: Long): Long {
    var a = num
    var b = mod
    var u = 1L
    var v = 0L
    while (b > 0) {
        val t = a.div(b)
        a -= t * b
        a = b.also { b = a } // swap a and b
        u -= t * v
        u = v.also { v = u } // swap u and v
    }
    u %= mod
    if (u < 0) u += mod
    return u
}

Measured memory_bytes: 63320
# coding: utf-8
import re
import math
#import numpy as np


#main
n,m=map(int,input().split())
MAP={}
PS=[]
for a in range(m):
    s,t=input().split()
    if(not s in MAP):MAP[s]=[]
    MAP[s].append(t)
ac=0
wa=0
for a,b in MAP.items():
    if(not "AC" in MAP[a]):continue
    for c in b:
        if(c=="WA"):
            wa+=1
        else:
            ac+=1
            break
print(ac,wa)

Measured memory_bytes: 71256
#include <iostream>
#include <math.h>
//#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>


using namespace std;
#define INF 100100100100

#define rep(i,n) for(int i = 0; i < n; i++)
#define rep2(i,a,n) for(int i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl
typedef long long ll;
typedef pair<ll, ll> PI;

int main() 
{
    int n; cin >> n;

    rep(i,9) {
        int q = n / (i+1);
        int m = n % (i+1);
        if((1 <= q) && (q <= 9) && (m == 0)) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}



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

ll dp[3010][3010];
ll MOD = 998244353;

int main() {
  int N, S;
  cin >> N >> S;
  dp[0][0] = 1;
  for (int i = 1; i <= N; i++) {
    int A;
    cin >> A;
    for (int j = 0; j <= 3000; j++) {
      dp[i][j] = 2 * dp[i - 1][j];
      if (j - A >= 0) dp[i][j] += dp[i - 1][j - A];
      dp[i][j] %= MOD;
    }
  }
  cout << dp[N][S] << endl;
}

Measured memory_bytes: 74160
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int num1 = scanner.nextInt();
        int num2 = num1/3600;
        int num3 = num1%3600/60;
        int num4 = num1%60;
        System.out.println(String.format("%s:%s:%s", num2,num3,num4));
    }
}





Measured memory_bytes: 26360
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
#include <cstring>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    ll X, K, D;
    cin >> X >> K >> D;
    if(X == 0){
        if(K & 1)   cout << D << endl;
        else    cout << 0 << endl;
        return 0;
    }
    if(abs(X) % D == 0){
        if(X == 0){
            if(K & 1)   cout << D << endl;
            else    cout << 0 << endl;
        }
        else{
            ll c = abs(X) / D;
            if(K >= c){
                if((K - c) & 1) cout << D << endl;
                else    cout << 0 << endl;
            }
            else{
                cout << abs(X) - D * K << endl;
            }
        }
        return 0;
    }
    ll c = abs(X) / D;
    if(K >= c){
        X = abs(X);
        X -= D * c;
        K -= c;
        if(K & 1)   cout << D - X << endl;
        else    cout << X << endl;
    }
    else{
        cout << abs(X) - D * K << endl;
    }
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 50
#define INF 1<<30
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S;
ll ans = 0;
struct UnionFind {
	vector<int> rank, parent, num;
	UnionFind() {};
	UnionFind(int size) :rank(size, 0), parent(size, 0), num(size, 0) {
		for (int i = 0; i < size; i++)makeset(i);
	}

	void makeset(int x) {
		parent[x] = x;
		rank[x] = x;
		num[x] = 1;
	}

	int size(int x) {
		return num[findset(x)];
	}

	bool same(int x, int y) {
		return findset(x) == findset(y);
	}

	int findset(int x) {
		if (x != parent[x]) {
			parent[x] = findset(parent[x]);
		}
		return parent[x];
	}

	void unite(int x, int y) {
		link(findset(x), findset(y));
	}

	void link(int x, int y) {
		if (rank[x] > rank[y]) {
			parent[y] = x;
			num[x] += num[y];
		}
		else {
			parent[x] = y;
			num[y] += num[x];
			if (rank[x] == rank[y])rank[y]++;
		}
	}
};
int main() {
	cin >> N >> M;
	vector<int>A(M), B(M);
	for (int i = 0; i < M; i++) {
		cin >> A[i] >> B[i];
	}
	UnionFind uf(N + 1);
	vector<ll>res(M + 1, 0);
	for (int i = M - 1; i >= 0; i--) {
		if (uf.same(A[i], B[i])) {
			res[i] = ans;
			continue;
		}
		ans += uf.size(A[i]) * uf.size(B[i]);
		uf.unite(A[i], B[i]);
		res[i] = ans;
	}
	ll tmp = N * (N - 1) / 2;
	for (int i = 1; i <= M; i++)cout << tmp - res[i] << endl;
}

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

using namespace std;

typedef pair<int, int> II;
typedef pair<long long, int> LLI;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<II> VII;

#define For(i,a,b) for(int i = a;i <= b; i++)
#define Rep(i,a,b) for(int i = a;i >= b; i--)
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, f) for(auto i : f)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define BUG(x) (cerr << #x << " = " << x << "\n")
#define ARRAY(f) {cerr << #f << " = "; FOR(i, f) cout << i << ' '; cout << "\n";}
#define sz(s) int(s.size())
#define reset(f, x) memset(f, x, sizeof(f))
#define all(x) x.begin(), x.end()
#define two(x) (1LL << x)
#define bit(x, i) ((x >> (i)) & 1LL)
#define onbit(x, i) (x | (1LL << (i)))
#define offbit(x, i) (x & ~(1 << (i)))

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    srand(time(NULL));
    #ifndef ONLINE_JUDGE
        //freopen("in.txt","r",stdin);
        //freopen("","w",stdout);
    #endif
    int n, m;
    string s, t;
    cin >> n >> m;
    cin >> s >> t;
    LL l = LL(n)*m / __gcd(n, m);
    //cerr << l << "\n";
    for (int i = 0; i < n; i++)
    if ((i*(l/n) % (l/m) == 0))
    {
        int j = (i*(l/n)) / (l/m);
        //cerr << i << ' ' << j << "\n";
        if (j >= m) break;
        if (s[i] != t[j])
        {
            cout << -1 << "\n";
            return 0;
        }
    }
    cout << l << "\n";
}


Measured memory_bytes: 640