akhauriyash/Code-Regression huggingface dataset:
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <regex>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;
using VL=vector<ll>;

#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
const long long INF =  999999999;

int ans[200200],N;
int main(){
  cin>>N;
  int s;
  rep(i,N-1){
    cin>>s;
    s--;
    ans[s]++;
  }
  rep(i,N){
    cout<<ans[i]<<endl;
  }
}


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

int main(){
  int x1,x2,x3,x4,x5;
  cin >> x1 >> x2 >> x3 >> x4 >> x5;

  if(x1 == 0){
    cout << 1;
  } else if(x2 == 0){
    cout << 2;
  } else if(x3 == 0){
    cout << 3;
  } else if(x4 == 0){
    cout << 4;
  } else if(x5 == 0){
    cout << 5;
  } else {
    cout << "Error";
  }

  return 0;
}

Measured memory_bytes: 3564
#include <stdio.h>
#include <string.h>

int main(void){
    char str[1000000];

    while(1){
        scanf("%[^\n]%*c", str);
        if(strcmp(str, ".") == 0){
            break;
        }

        int i;
        int check[strlen(str)], k = 0;
        for(i = 0; i < sizeof(check) / sizeof(check[0]); i++){
            check[i] = 0;
        }
        for(i = 0; i < strlen(str); i++){
            if(str[i] == '('){
                check[k] = -1;
                k++;
            }
            else if(str[i] == '['){
                check[k] = 1;
                k++;
            }
            else if(str[i] == ')'){
                if(k == 0 || check[k-1] == 1){
                    printf("no\n");
                    break;
                }
                k--;
                check[k] = 0;
            }
            else if(str[i] == ']'){
                if(k == 0 || check[k-1] == -1){
                    printf("no\n");
                    break;
                }
                k--;
                check[k] = 0;
            }

            if(i == strlen(str) - 1){
                if(k == 0){
                    printf("yes\n");
                }
                else{
                    printf("no\n");
                }
            }
        }
    }

    return 0;
}


Measured memory_bytes: 2048
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>

typedef long long ll;

using namespace std;

bool is_leap(int y)
{
	return y % 4 == 0 && y % 100 || y % 400 == 0;
}
int main()
{
	int days[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
	int y[2], m[2], d[2];
	while (scanf("%d %d %d %d %d %d", &y[0], &m[0], &d[0], &y[1], &m[1], &d[1]),
		y[0] >= 0 && m[0] >= 0 && d[0] >= 0 && y[1] >= 0 && m[1] >= 0 && d[1] >= 0)
	{
		int dd[2];
		for (int i = 0; i < 2; ++i)
		{
			dd[i] = d[i];
			for (int j = 0; j < m[i]-1; ++j)
				dd[i] += days[j];
		}
		int ans = dd[1] - dd[0];
		ans += (y[1] - y[0]) * 365;
		for (int i = y[0]; i < y[1]; ++i)
		{
			if (is_leap(i))
				++ans;
		}
		if (is_leap(y[0]) && m[0] > 2)
			--ans;
		if (is_leap(y[1]) && m[1] > 2)
			++ans;

		printf("%d\n", ans);
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  int bunbo = 10000000;
  int digit = 0;
  int tmp = N;
  for (int i = 0; i < 8; ++i){
    digit += tmp / bunbo;
    tmp %= bunbo;
    bunbo /= 10;
    //cout << "digit:" << digit << ", tmp:" << tmp << ", bunbo:" << bunbo <<endl;
  }
  
  // 1 <= Nなので0割の評価はしない
  if (0 == N % digit){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <numeric>
#include <set>
#include <iomanip>
#include <functional>
#define FOR(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
using namespace std;


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

	long long r, D, temp;

	cin >> r >> D >> temp;

	REP(i, 10)
	{
		temp = r * temp - D;
		cout << temp << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;i++)
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vip;

int main(){
    int x,a;cin>>x>>a;
    cout << (x<a?0:10)<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static Scanner sc;
    public static void main(String[] args) throws Exception {
        sc = new Scanner(System.in);
        int n = 1;
        while (sc.hasNext()) {
            int i = sc.nextInt();
            if (i == 0) break;
            
            System.out.println("Case " + n + ": " + i);
            n++;
        }
    }
}

Measured memory_bytes: 42836
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
#include <cmath>
#include <queue>
#include <numeric>


int main()
{
	long long n, m;

	std::map<int, int> mm;

	std::cin >> n;
	for (size_t i = 0; i < n; i++)
	{
		int a;

		std::cin >> a;
		mm[a]++;
	}

	std::cin >> m;

	bool flag = false;
	for (size_t i = 0; i < m; i++)
	{
		int a;

		std::cin >> a;

		if (mm[a] == 0) {
			flag = true;
		}
		else {
			mm[a]--;
		}
	}
	
	if (flag) {
		std::cout << "NO" << std::endl;
	}
	else {
		std::cout << "YES" << std::endl;
	}

	return 0;
}

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


class name
{
    static void Main()
    {

        int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();
        string m=string.Empty ;
        int[] h = new int[10];
        string AC = "AC";
        string WA = "WA";
        string TLE = "TLE";
        string RE = "RE";
        for(int k = 0; k < n[0]; k++)
        {
            m = Console.ReadLine();
            if (m.Equals(AC))
            {
                h[0] += 1;

            }
            else if (m.Equals(WA))
            {

                h[1] += 1;
            }
            else if (m.Equals(TLE))
            {
                h[2] += 1;

            }
            else if(m.Equals(RE)) 
            {
                h[3] += 1;

            }

        }
        Console.WriteLine("AC x " + h[0] + "");
        Console.WriteLine("WA x " + h[1] + "");
        Console.WriteLine("TLE x " + h[2] + "");
        Console.WriteLine("RE x " + h[3] + "");

    }



}


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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template <typename T1, typename T2> 
inline bool chmax(T1 &a, T2 b) {
  return a < b && (a = b, true);
}

template <typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {
  return a > b && (a = b, true);
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  VLL h(n);
  rep(i, n) cin >> h[i];
  VLL dp(n + 10, 1e9);
  dp[0] = 0;
  dp[1] = abs(h[0] - h[1]);
  FOR(i, 2, n) {
    dp[i] =
        min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
  }
  cout << dp[n - 1] << endl;
  return 0;
}


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

using namespace std;
#define int long long
#define MOD 1000000007
#define pb push_back
int query(vector<int>&BIT,int idx)
{
    int ans=0;
    while(idx)
    {
        ans=max(ans,BIT[idx]);
        idx-=(idx&-idx);
    }
    return ans;
}
void update(vector<int>&BIT,int idx, int val)
{
    while(idx<BIT.size())
    {
        BIT[idx]=max(BIT[idx],val);
        idx+=(idx&-idx);
    }
    return ;
}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin>>N;
    vector<int> BIT(N+1,0);
    vector<int> h(N);
    vector<int>A(N);
    for(int i=0;i<N;i++)cin>>h[i];
    for(int i=0;i<N;i++)cin>>A[i];
    
    for(int i=0;i<N;i++)
    {
        int k=query(BIT,h[i]-1);
            update(BIT,h[i],A[i]+k);
        
    }
    cout<<query(BIT,N);
    
    return 0;
}

Measured memory_bytes: 4992
// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//


#define _USE_MATH_DEFINES
#include<math.h>

//#include<cmath>

#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>



//#include "Ants.h"
using namespace std;
typedef long long ll;
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<n;i++)
#define show(s) cout<<s<<endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define LINF (1000000000000000000ll)

//typedef pair < int, int> P;
ll gcd(ll a, ll b) {//最大公約数を求める///最大公倍数a*b/gcd(a,b)
	if (b == 0) return a;
	return gcd(b, a % b);
}

ll lcd(ll a, ll b) {//最小公倍数を求める　b=0のときaを返す
	if (b == 0) return a;
	return (a / gcd(a, b)) * b;
}
vector<int> calc(ll num) {
	int dig;
	vector<int>p;
	while (num) {
		dig = num % 10;
		p.push_back(dig);
		num /= 10;
	}
	return p;
}
int N;
set<int>s;
int main()
{
	cin >> N;
	rep(i, N) {
		int a = 0;
		cin >> a;
		s.insert(a);
	}
	if (N != s.size()) {
		cout << "NO" << endl;
	}
	else cout << "YES" << endl;
	
}

Measured memory_bytes: 9600
#include <stdio.h>
int main(void){
   int a, b, c;
    int tmp;
 
    scanf("%d%d%d", &a, &b, &c);
    if (a > b) tmp = a, a = b, b = tmp;
    if (b > c) {
        tmp = b, b = c, c = tmp;
        if (a > b) tmp = a, a = b, b = tmp;
    }
    printf("%d %d %d\n", a, b, c);
    return 0;
}


Measured memory_bytes: 2060
N = int(input())
h = list(map(int, input().split()))
dp = [10**20 for i in range(N)]
dp[0] = 0

for i in range(N):
    if i+1 < N:
        dp[i+1] = min(dp[i+1], dp[i]+abs(h[i]-h[i+1]))
    if i+2 < N:
        dp[i+2] = min(dp[i+2], dp[i]+abs(h[i]-h[i+2]))

print(dp[-1])

Measured memory_bytes: 13980
n = int(input())
w = []
for i in range(n):
    w.append(input())
if len(set(w)) != n:
    print("No")
else:
    buf = w[0][0]
    for i in w:
        if i[0] != buf:
            print("No")
            exit()
        buf = i[-1]
    print("Yes")

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

int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int count=0;
    for(int a=0;a<n;a++)
    {
    	if(s[a]=='R')
    	count++;
    }
    int W=0;
    for(int a=0;a<count;a++)
    {
    	if(s[a]=='W')
    	W++;
    }
    cout<<W<<"\n";
}

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

int main(){
	cin.sync_with_stdio(0);
	cin.tie(0);
	cin.exceptions(cin.failbit);

	int k;
	cin >> k;
	vi a(k);
	trav(x, a) cin >> x;

	int mn = 1000, mx = 1;
	trav(x, a) mn = min(mn, x);
	trav(x, a) mx = max(mx, x);

	if(mn * 2 < mx){
		cout << -1 << endl;
		return 0;
	}

	int len = 0;
	trav(x, a) len += x;
	vi ans(len, -1);

	vi cnt(k, 0);
	vector<bool> happy(k, true);
	vi prev(k, -1);

	rep(i,0,len){
		mx = 0, mn = 1000;
		trav(x, a) mx = max(mx, x);
		trav(x, a) mn = min(mn, x);
		int imx = 1000;
		rep(d,0,k) if(a[d] == mn) imx = min(imx, prev[d]);
		rep(d,0,k) if(happy[d] && a[d]*2 > mx && !(mx>=2*mn+1 && prev[d] > imx)){
			ans[i] = d;
			break;
		}
		if(ans[i] < 0){
			rep(j,0,i) cout << 1+ans[j] << " ";
			cout << endl;
			trav(x, a) cout << x << " ";
			cout << endl;

			cout << mx << " " << mn << endl;
			cout << a[ans[i]] << endl;
			cout << imx << " " << prev[ans[i]] << endl;
			assert(false);
		}
		prev[ans[i]] = i;
		happy[ans[i]] = false;
		--a[ans[i]];
		++cnt[ans[i]];
		if(i >= k) --cnt[ans[i-k]];
		if(count(all(cnt), 0) == 0){
			rep(d,0,k) happy[d] = true;
		}
	}

	trav(x, ans) cout << x+1 << " ";
	cout << endl;
}


Measured memory_bytes: 3664
"use strict";

const permutateWithRepetitions = (
  permutationOptions,
  permutationLength
) => {
  if (permutationLength === 1) {
    return permutationOptions.map(permutationOption => [permutationOption]);
  }

  const permutations = [];

  const smallerPermutations = permutateWithRepetitions(
    permutationOptions,
    permutationLength - 1
  );

  permutationOptions.forEach((currentOption) => {
    smallerPermutations.forEach((smallerPermutation) => {
      permutations.push([currentOption].concat(smallerPermutation));
    });
  });

  return permutations;
}

const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0]);
    const S = arg[1].split("").map(n=>parseInt(n));

    // 最大で1000通りしかありえないので全探索する
    const digits = [0,1,2,3,4,5,6,7,8,9];
    
    const combos = permutateWithRepetitions(digits, 3);
    
    let cnt = 0;
    
    for(let i=0; i<1000; i++) {
        let digit1 = combos[i][0];
        let digit2 = combos[i][1];
        let digit3 = combos[i][2];
        
        let flag1 = false;
        let flag2 = false;
        let flag3 = false;

        for(let j=0; j<N; j++) {
            if(S[j] === digit1 && flag1 !== true) {
                flag1 = true;
            } else if(S[j] === digit2 && flag1 && flag2 !== true) {
                flag2 = true;
            } else if(S[j] === digit3 && flag1 && flag2) {
                flag3 = true;
            }
        }
        
        
        if(flag1 && flag2 && flag3) {
            cnt++;
        }
    }
    
    console.log(cnt);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

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

using namespace std;

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

  int n;
  cin >> n;
  int as[n];
  REP(i, n) {
    cin >> as[i];
  }

  int xs[] = {0, 0, 0};
  REP(i, n) {
    int a = as[i];
    if (a % 4 == 0) {
      ++xs[2];
    } else if (a % 2 == 0) {
      ++xs[1];
    } else {
      ++xs[0];
    }
  }

  int d = xs[0] - xs[2];
  bool ans = d <= 0 || (d == 1 && xs[1] == 0);
  cout << (ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 640
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
//* vamsicool007    You are never wrong to do the right thing    vamsicool007 *
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
#include<bits/stdc++.h>
using namespace std;
#define flash ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define endl "\n"
#define int long long
typedef long long ll;
typedef long double ld;
const int mod = 1000000007;
const int N=200005;
vector<int>vis(N);
vector<vector<int>>adj(N);
void dfs(int v){vis[v]=1;for(auto i:adj[v]){if(!vis[i]){dfs(i);}}return;}
bool isPrime(ll n){if(n<2)return false;for(ll i=2;i*i<=n;++i){if(n%i==0){return false;}}return true;}
ll factorial(ll n){return (n==1 || n==0) ? 1:n*factorial(n-1);}
ll power(ll x,ll y){ll res=1;x=x;while(y>0){if(y&1)res=(res*x)%mod;y=y>>1;x=(x*x)%mod;}return res%mod;}
ll gcd(ll a,ll b){if (a==0)return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return (a/gcd(a,b)*b);}
ll max(ll a,ll b){ll ans=a>b?a:b;return ans;}
ll min(ll a,ll b){ll ans=a<b?a:b;return ans;}
int root(int a[],int i){while(a[i]!=i){a[i]=a[a[i]];i=a[i];}return i;}
void unionn(int a[],int i,int j){int root_i=root(a,i);int root_j=root(a,j);a[root_i]=root_j;return;}
// void fun()
// {
//     #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
//     #endif
// }

int f1(int n)
{
    n--;
    n=(n*(n+1))/2;
    return n;
}
signed main()
{
    flash;
    //fun();
    int tt=1;
    //cin>>tt;
    while(tt--)
    {
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        while(a>0 && c>0)
        {
            a=a-d;
            c=c-b;
        }
        if(c<=0)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 9452
sub parin {
	$s = @_[0];
	return $s eq reverse($s)
}

use integer;
$s = <>;
chop($s);
$n = length($s);
print parin($s) && parin(substr($s, 0, ($n-1)/2)) && parin(substr($s, ($n+1)/2)) ? Yes : No

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


int main(){
  ll n;
  cin >> n;
  vector<ll> a(n);
  ll ans=1000;
  for(int i=0;i<n;++i) cin >> a[i];

  for(int i=0;i<n-1;++i){
    ll s=0;
    if(a[i]<a[i+1]) s=ans/a[i];
    ans+=(a[i+1]-a[i])*s;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3628
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

N,K,C = LI()
S = str(input())

L = []
R = []

for i in range(N):
    if S[i] == 'o':
        if len(L) == 0:
            L.append(i)
        else:
            if L[-1]+C+1 <= i:
                L.append(i)
    if len(L) == K:
        break

for i in range(N)[::-1]:
    if S[i] == 'o':
        if len(R) == 0:
            R.append(i)
        else:
            if R[-1]-C-1 >= i:
                R.append(i)
    if len(R) == K:
        break

R = list(reversed(R))

for i in range(len(L)):
    if L[i] == R[i]:
        print(L[i]+1)

Measured memory_bytes: 56700
import itertools

s = list(input())
t = list(input())
# ss = list(itertools.permutations(s)).sort()
# tt = list(itertools.permutations(t)).sort()
s.sort()
t.sort()
ti = t[::-1]
ss = ''.join(s)
tt = ''.join(ti)
tmp = []
tmp.append(ss)
tmp.append(tt)
tmp.sort()
if tmp[0] == ss and ss != tt:
    print('Yes')
else:
    print('No')


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<pair<int, int>> task(N);
    rep(i, N) {
        int A, B; cin >> A >> B;
        task[i] = make_pair(B, A);
    }
    sort(all(task));
    int time = 0;
    bool flg = true;
    rep(i, N) {
        time += task[i].second;
        if (time > task[i].first) flg = false;
    }
    cout << (flg ? "Yes" : "No") << endl;
    return 0;
}

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

int main(){
	string a,b;
	int i=0,j=0,an,bn,count=0;
	cin >> a;
	cin >> b;
	a += a;
	an = a.size();
	bn = b.size();
	
	if(a.find(b)!=std::string::npos){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	
	return 0;
}
	

Measured memory_bytes: 3216
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		
		List<int[]> lists = new ArrayList<>();
		for(int i = 0; i < M; i++) {
			int k = sc.nextInt();
			int[] list = new int[k];
			for(int j = 0; j < k; j++) {
				list[j] = sc.nextInt();
			}
			lists.add(list);
		}
		
		int[] p = new int[M];
		
		for(int i = 0; i < M; i++) {
			p[i] = sc.nextInt();
		}
		
		int sum = 0;
		
		for(int i = 0; i < (1 << N); i++) {
			boolean flag = true;
			for(int j = 0; j < M; j++) {
				int on = 0;
				for(int k : lists.get(j)) {
					if((1 & (i >> (k - 1)))==1) {
						on++;
					}
				}
				if(on % 2 != p[j]) {
					flag = false;
					break;
				}
			}
			if(flag) {
				sum++;
			}
		}	
		System.out.println(sum);	
	}
}


Measured memory_bytes: 25044
//Never stop chasing!-MdSourav.
#include <bits/stdc++.h>

#define yes            cout<<"YES"<<endl
#define no             cout<<"NO"<<endl
#define sz(x)          x.size()
#define ll                    long long int
#define ls             long int
#define start          ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test           int t;cin>>t;while(t--)
#define f(i, a, n)     for(int i=a; i<n;i++)
#define gcd(a,b)       __gcd(a,b)
#define lcd(a,b)       (a*b)/gcd(a,b)
#define pb             push_back
#define mp(x,y)        make_pair(x,y)
#define rsrt(v)        sort(v.begin(),v.end(),greater<int>())
#define srt(v)         sort(v.begin(),v.end())
#define basrt(a,n)     sort(a,a+n,greater<int>())
#define asrt(a,n)      sort(a,a+n)
#define fact(n)        ll x=1;for(ll i=1;i<=n;i++){x=(x*i);}
#define F              first
#define S              second
#define deb(x)         cout << #x << ": " << x << endl;
#define enter(v,n)     for(ll i=0;i<n;i++){ll x;cin>>x;v.pb(x);}
#define INF 	       1000000007
#define unique(v)      v.erase(unique(v.begin(),v.end()),v.end())
using namespace std;

double pi=3.14159265358979323846;
typedef vector<ll> vll ;
typedef vector<int> vii ;

template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v)
{
    os << '{';
    for (const auto &x : v) os << " " << x;
        return os << '}';
}

void solve()
{

	int x,n;
	cin>>x>>n;
	if(n==0)
	{
		cout << x;
		return;
	}
	vii v,vv;
	enter(v,n);
	srt(v);
	int j=0;
	for(int i=0;i<=101;i++)
	{
		if(v[j]==i)
		{
			j++;
		}
		else
		{
			vv.pb(i);
		}
	}
	//for(int i=0;i<vv.size();i++)
	//{
		//cout << vv[i] << " ";
	//}
	//cout << endl;
	int ans1=1000;
	int ans=0;
	for(int i=0;i<vv.size();i++)
	{
		int c=abs(vv[i]-x);
		//deb(c);
		if(c<ans1)
		{
			ans1=c ;
			ans=vv[i];
		}
	}
	cout << ans << endl;






}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
    ll test_case=1;
    //cin>>test_case;
    while(test_case--)
	{
		solve();
	}

	return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};


int main()
{
  int h, w; cin >> h >> w;
  vector<string> a(h);
  rep(i, h) cin >> a[i];

  set<int> cut_h, cut_w;

  rep(i, h) {
    bool ok = true;
    rep(j, w) if(a[i][j] == '#') ok = false;
    if(ok) cut_h.insert(i);
  }
  rep(j, w) {
    bool ok = true;
    rep(i, h) if(a[i][j] == '#') ok = false;
    if(ok) cut_w.insert(j);
  }

  rep(i, h) {
    if(cut_h.find(i) != cut_h.end()) continue;
    rep(j, w) {
      if(cut_w.find(j) != cut_w.end()) continue;
      cout << a[i][j];
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
from fractions import gcd
def lcm(a, b):
    return a * b // gcd(a, b)

n = int(input())
a = list(map(int,input().split()))
mod = 10 ** 9 + 7

LCM = 1
a_mod = 0
for i in range(n):
    LCM = lcm(LCM, a[i])
    a_mod = (a_mod + pow(a[i], mod - 2, mod)) % mod

LCM = LCM % mod
ans = LCM * a_mod
print(ans % mod)

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

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

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

int main(void){
    int N,K; cin >> N >> K;
    cout << (N%K ? 1 : 0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

#define MOD 1000000007

using lli = long long int;
using ulli = unsigned long long int;

#ifndef EVEL

#define dbug(X) std::cout << #X << ":" <<X<<" " ;
#define dbugf(s) std::cout << s;
#define dbugln std::cout<<"\n";

#else

#define dbug(X) {X=X;}
#define dbugf(f) {f=f;}
#define dbugln {}

#endif

string s[3];
char ans[4];

int main(){
  for(auto& in: s){
    cin >> in;
  }
  //cout << (int)'b' << " " <<  (int)'B' << endl;
  for(int l = 0; l < 3; l++){
    ans[l] = s[l][0];
    if(ans[l] >= 97){
      ans[l] -= 32;
    }
  }
  ans[3] = '\0';
  cout << ans;

}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	long long int a;
	int suu[11];
	int i,j;
	int n;
	
	while(scanf("%lld",&a)!=EOF){
		for(i=0;i<10;i++){
			suu[i]=a%10;
			a=a/10;
		}
		n=9;
		for(i=0;i<9;i++){
			for(j=0;j<n;j++){
				suu[j]=(suu[j]+suu[j+1])%10;
			}
	/*		for(j=0;j<n;j++){
				printf("%d ",suu[j]);
			}
			printf("\n");
			n--;*/
		}
		printf("%d\n",suu[0]);
	}
	return 0;
}

Measured memory_bytes: 1028
while True:
    a,op,b = input().split()
    a = int(a)
    b = int(b)
    
    if op == '?':
        break
    elif op == '+':
        print(a+b)
    elif op == '-':
        print(a-b)
    elif op == '*':
        print(a*b)
    elif op == '/':
        print(a//b)


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

using namespace std;
using lint = long long;

char changeAlpha(char A, char B)
{
    char s = 'a';
    for(int i = 0; i < 26; i++){
        if(s != A && s != B){
            return s;
        }
        s += 1;
    }
}
int main(void)
{
    /*
    string S;
    lint K;
    cin >> S;
    cin >> K;

    if(S.size() == 1){
        cout << K / 2 << endl;
        return 0;
    }
    
    S += S[0];
    //cout << S << endl;
    lint cnt = 0;
    lint flag = 0;
    for(int i = 1; i < S.size()-1; i++){
        
        if(S[i-1] == S[i]){
            S[i] = changeAlpha(S[i-1], S[i+1]);
            cnt++;
        }
        else if(i == S.size()-2 && S[i+1] == S[i]){
            S[i] = changeAlpha(S[i-1], S[i+1]);
            cnt++;
            flag = 1;
        }
    }

    cout << cnt * K - flag << endl;
    return 0;
    */
   string S;
   lint K;
   cin >> S >> K;
   lint cnt = 0;
   
   char s0 = S[0];
   lint c = 0;
   for(int i = 0; i < S.size(); i++){
       c += s0 - S[i];
   }
   if(c == 0){
       cout << S.size() * K / 2 << endl;
       return 0;
   }
   if(S.size() == 1){
       cout << K / 2 << endl;
       return 0;
   }
   if(K == 1){
       S = S + S[0];
       for(int i = 1; i < S.size()-1; i++){
           if(S[i-1] == S[i]){
               S[i] = changeAlpha(S[i-1], S[i+1]);
               cnt++;
           }
       }

       cout << cnt << endl;
       return 0;
   }
   

   string S1 = S + S[0];
   for(int i = 1; i < S1.size()-1; i++){
       if(S1[i] == S1[i-1]){
           S1[i] = changeAlpha(S1[i-1], S1[i+1]);
           cnt++;
       }
   }

   //cout << cnt << endl;

   lint cnt2 = 0;
   string S2 = S1[S1.size()-2] + S + S[0];
   //cout << S2 << endl;
   for(int i = 1; i < S2.size()-1; i++){
       //cout << S2[i] << endl;
       if(S2[i] == S2[i-1]){
           S2[i] = changeAlpha(S2[i-1], S2[i+1]);
           cnt2++;
       }
   }
   //cout << cnt2 << endl;
   cout << cnt + cnt2 * (K-1)<< endl;
   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10
#define MOD 100000

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int dp[2][2][128][128];
int H, W;

int dfs(int f, int d, int h, int w){
  if(h==H-1&&W-1==w) return 1;
  if(h==H||W==w) return 0;
  int &res = dp[f][d][h][w];
  if(res >= 0) return res;
  res = 0;
  if(f){
    if(d) res = (res + dfs(0, d, h, w+1))%MOD;
    else  res = (res + dfs(0, d, h+1, w))%MOD;
  }else{
    res = (res + dfs(d?0:1, 1, h, w+1))%MOD;
    res = (res + dfs(d?1:0, 0, h+1, w))%MOD;
  }
  return res;
}

int main(){
  while(scanf("%d%d", &H, &W)&& (H || W)){
    int res = 0;
    memset(dp, -1, sizeof(dp));
    res += dfs(0, 0, 1, 0);
    memset(dp, -1, sizeof(dp));
    res += dfs(0, 1, 0, 1);
    printf("%d\n", res%MOD);
  }
  return 0;
}

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

using namespace std;

const int N = 1e5 + 7;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector <int> a(n), b(n);
    vector <int> p;
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
        p.push_back(a[i] + b[i]);
    }
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        ans -= b[i];
    }
    sort(p.begin(), p.end());
    reverse(p.begin(), p.end());
    for (int i = 0; i < n; i++) {
        if (i % 2 == 0) {
            ans += p[i];
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define ull unsigned long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define pi acosl(-1)
#define sqr(x) ((x)*(x))
#define mod (1000*1000*1000+7)
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
template <typename T>
string NumberToString(T pNumber)
{
     ostringstream oOStrStream;
     oOStrStream << pNumber;
     return oOStrStream.str();
}
ll StringToNumber(string s)
{
    stringstream geek(s);
    ll x=0;
    geek>>x;
    return x;
}
ll modPow(ll x,ll n,ll m)
{
    if(n==0)
    return 1%m;
    ull u = modPow(x,n/2,m);
    u=u*u%m;
    if(n%2==1)
    u=u*x%m;
    return u;
}
ll gcd(ll a,ll b)
{
    if(b==0)
    return a;
    return gcd(b,a%b);
}
vl primes;
void seiveForm(ll n)
{
    ll i,j;
    vector<bool> isPrime(n+1,true);
    isPrime[0]=false;
    isPrime[1]=false;
    f(i,2,n+1)
    {
        if(isPrime[i]==true)
            for(j=i*i;j<=n+1;j+=i)
                isPrime[j]=false;
    }
    rep(i,n+1)
    {
        if(isPrime[i]==true)
            primes.pb(i);
    }
}
bool isPerfectSquare(ll num)
{
    double n = sqrt(num);
    return n==(ll)n?true:false;
}
ll countSetbits(ll num)
{
    ull temp=0;
    while(num){
        num=num&(num-1);
        temp++;
    }
    return temp;
}
bool isPowerOfTwo(ll n)
{
   if(n==0)
   return false;
   return (ceil(log2(n)) == floor(log2(n)));
}
ll power(ll x, ll y)
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = res*x;
        y = y>>1;
        x = x*x;
    }
    return res;
}
ll divisors(ll n)
{
    seiveForm(n);
    ll result = 1,i;
    rep(i,sz(primes))
    {
        ll p = primes[i];
        ll exp = 0;
        while(p<=n)
        {
            exp+=(n/p);
            p*=primes[i];
        }
        result*=(exp+1);
        result%=mod;
    }
    return result;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,i,j,k,x=0,ans=0;
    cin>>n;
    cout<<divisors(n)<<endl;
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }


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

    vector<int> a(4);
    rep(i,4) cin>>a[i];
    sort(ALL(a));
    if(a[0]==1 and a[1]==4 and a[2]==7 and a[3]==9) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
	char s[10];
	scanf("%s",s);
	int count=0;
	if(strcmp(s,"RRR")==0) printf("3\n");
	else if(strcmp(s,"SSS")==0) printf("0\n");
	else if(strcmp(s,"RRS")==0 || strcmp(s,"SRR")==0) printf("2\n");
	else printf("1\n");
	
	
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<"\n"
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define mp make_pair
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using vc = vector<char>;
using vvc = vector<vc>;
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; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll h,w;
  cin>>h>>w;
  vstr s(h);
  rep(i,h) cin>>s[i];
  ll cu=0;
  vvll t(h,vll(w,-1));
  rep(i,h)rep(j,w){
    if(t[i][j]!=-1) continue;
    t[i][j]=cu;
    queue<pll> que;
    que.pu(pll(i,j));
    while(sz(que)){
      pll now=que.front();
      que.pop();
      rep(u,4){
        ll nx=now.F+dx[u];
        ll ny=now.S+dy[u];
        if(nx>=0&&ny>=0&&nx<h&&ny<w&&t[nx][ny]==-1&&s[nx][ny]!=s[now.F][now.S]){
          t[nx][ny]=cu;
          que.pu(pll(nx,ny));
        }
      }
    }
    cu++;
  }
  ll ans=0;
  vll a(cu),b(cu);
  rep(i,h)rep(j,w){
    if(s[i][j]=='.'){
      a[t[i][j]]++;
    }
    else{
      b[t[i][j]]++;
    }
  }
  rep(i,cu){
    ans+=a[i]*b[i];
  }
  COUT(ans);
}


Measured memory_bytes: 6616
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	static int top = 0;

	public static void main(String[] args) throws Exception {
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		String[] array = r.readLine().split(" ");
		int[] stack = new int[array.length];


		for(int i = 0; i < array.length; i++){
			String temps = array[i];
			int x,y = 0;
			switch(temps){
				case "+":
					x = pop(stack);
					y = pop(stack);
					push(stack,y + x);
					break;
				case "-":
					x = pop(stack);
					y = pop(stack);
					push(stack,y - x);
					break;
				case "*":
					x = pop(stack);
					y = pop(stack);
					push(stack,y * x);
					break;
				default:
					push(stack,Integer.parseInt(temps));
					break;
			}
		}
		System.out.println(stack[top]);
	}

	public static void push(int[] stack,int num){
		top++;
		stack[top] = num;
	}

	public static int pop(int[] stack){
		return stack[top--];
	}


}

Measured memory_bytes: 24408
N=int(input())
T=list(map(int,input().split()))
A=list(map(int,input().split()))
mod=10**9+7

#0:高さ確定 1:高さそれ以下
for i in range(0,N):
    if i==0:
        T[i]=(T[i],0)
    else:
        h,query=T[i-1]
        if h==T[i]:
            T[i]=(T[i],1)
        else:
            T[i]=(T[i],0)

for i in range(0,N):
    if i==0:
        A[-i-1]=(A[-i-1],0)
    else:
        h,query=A[-i]
        if h==A[-i-1]:
            A[-i-1]=(A[-i-1],1)
        else:
            A[-i-1]=(A[-i-1],0)

ans=1
for i in range(0,N):
    h1,q1=T[i]
    h2,q2=A[i]
    if q1==0:
        if q2==0:
            if h1!=h2:
                ans=0
        else:
            if h1>h2:
                ans=0
    else:
        if q2==0:
            if h2>h1:
                ans=0
        else:
            ans=(ans*min(h1,h2))%mod

print(ans)


Measured memory_bytes: 90596
n = int(input())
h = list(map(int, input().split()))

import numpy as np

d = [0] * n

d[1] = np.abs(h[1] - h[0])

for i in range(n-2):
    d[i+2] = min(d[i]+np.abs(h[i+2]-h[i]), d[i+1]+np.abs(h[i+2]-h[i+1]))

print(d[n-1])

Measured memory_bytes: 20676
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define MOD 1000000007
#define INF 1 << 30

using namespace std;
typedef long long ll;

int main(void) {
	int num, i, p;
	ll len, ans = 0, ansb = 0;
	cin >> num >> len;
	vector<ll> x(num, 0), v(num, 0), a(num, 0), g(num, 0), b(num);
	for (i = 0; i < num; i++)
		scanf("%lld%lld", &x[i], &v[i]);
	a[0] = v[0];
	for (i = 1; i < num; i++)
		a[i] = a[i - 1] + v[i];
	for (i = 0; i < num; i++)
		a[i] -= x[i];
	for (p = -1, i = 0; i < num; i++) {
		g[i] = p;
		if (ans < a[i]) {
			ans = a[i];
			p = i;
		}
	}
	b[num - 1] = v[num - 1];
	for (i = num - 2; i >= 0; i--)
		b[i] = b[i + 1] + v[i];
	for (i = 0; i < num; i++)
		b[i] -= len - x[i];
	for (i = 0; i < num; i++) {
		if (g[i] < 0)
			ans = max(ans, b[i]);
		else
			ans = max(ans, b[i] + a[g[i]] - len + x[i]);
	}
	for (p = -1, i = num - 1; i >= 0; i--) {
		g[i] = p;
		if (ansb < b[i]) {
			ansb = b[i];
			p = i;
		}
	}
	ans = max(ans, ansb);
	for (i = 0; i < num; i++) {
		if (g[i] < 0)
			ans = max(ans, a[i]);
		else
			ans = max(ans, b[g[i]] + a[i] - x[i]);
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 4224
// AGC001_A
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <tuple>  // std::tuple std::get
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define REPN(i, n) for (ll i=1; i <= n; i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0LL)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
#define zero_pad(num) setfill('0') << std::right << setw(num)
#define space_pad(num) setfill(' ') << std::right << setw(num)

typedef long long ll;

const ll MOD7 = 1000000007;  // 1 000 000 007
const ll MOD9 = 1000000009;  // 1 000 000 009

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

    // input
    ll N;
    cin >> N;
    vector<ll> vec(2*N);
    REP(i, 2*N) cin >> vec[i];
    
    // calculation
    sort(vec.begin(), vec.end());
    ll res = 0;
    REP(i, N) {
        res += min(vec[2*i], vec[2*i+1]);
    }
    
    cout << res << "\n";
    
    return 0;
}


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

using namespace std;

int calc(string s, string x){
  stack<char> st;
  
  for(int i=0;i<(int)s.size();i++){
    if(s[i] == '[') continue;

    if('a' <= s[i] && s[i] <= 'd'){
      st.push(x[s[i]-'a'] - '0');
    }else if (s[i] != ']') {
      st.push(s[i]);
    }else{      
      char a = st.top(); st.pop();
      char b = st.top(); st.pop();
      char c = st.top(); st.pop();
        
      if(c == '+') st.push(a | b);
      if(c == '*') st.push(a & b);
      if(c == '^') st.push(a ^ b);
    }
  }

  return st.top();  
}

bool solve(){
  string s; string p;

  cin >> s >> p;

  if(s == ".") return false;
  
  int hash = calc(s, p);

  int ans = 0;
  
  for(int i=0;i<=9999;i++){
    char c[5];
    sprintf(c, "%04d", i);
    string t = c;

    ans += hash == calc(s, t);
  }

  cout << hash << " " << ans << endl;

  return true;
}

int main(){
  while(solve());


}




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

#define ll long long

using namespace std;

const int N = (int)3e3 + 7;
const ll inf = (ll)1e18 + 7;

ll dp[2][N][N];
ll a[N];
int n;

ll calc(int tp, int l, int r) {
	if (l > r) return 0;
	ll &res = dp[tp][l][r];
	if (res != -1) return res;
	res = 0;
	if (tp == 0) {
		res = -inf;
		res = max(res, calc(tp ^ 1, l + 1, r) + a[l]);
		res = max(res, calc(tp ^ 1, l, r - 1) + a[r]);
	} else {
		res = inf;
		res = min(res, calc(tp ^ 1, l + 1, r) - a[l]);
		res = min(res, calc(tp ^ 1, l ,r - 1) - a[r]);
	}
	return res;
}

main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%lld", &a[i]);
	}
	for (int len = 1; len <= n; len++) {
		for (int r = len; r <= n; r++) {
			int l = r - len + 1;
			for (int tp = 0; tp <= 1; tp++) {
				ll &res = dp[tp][l][r];
				if (tp == 0) {
					res = -inf;
					res = max(res, dp[tp ^ 1][l + 1][r] + a[l]);
					res = max(res, dp[tp ^ 1][l][r - 1] + a[r]);
				} else {
					res = inf;
					res = min(res, dp[tp ^ 1][l + 1][r] - a[l]);
					res = min(res, dp[tp ^ 1][l][r - 1] - a[r]);
				}
			}
		}
	}
	cout << dp[0][1][n];
}


Measured memory_bytes: 141568
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
	int x,y,s;
	char com;
	int a[10][10];
	for(int i=0;i<100;i++) a[i/10][i%10] = 0;
	while(cin >> x >> com >> y >> com >> s){
		a[x][y]++;
		if(x>0) a[x-1][y]++;
		if(x<9) a[x+1][y]++;
		if(y>0) a[x][y-1]++;
		if(y<9) a[x][y+1]++;
		if(s>1){
			if(x>0 and y>0) a[x-1][y-1]++;
			if(x>0 and y<9) a[x-1][y+1]++;
			if(x<9 and y>0) a[x+1][y-1]++;
			if(x<9 and y<9) a[x+1][y+1]++;
		}
		if(s==3){
			if(x>1) a[x-2][y]++;
			if(x<8) a[x+2][y]++;
			if(y>1) a[x][y-2]++;
			if(y<8) a[x][y+2]++;
		}
	}
	int c = 0;
	int b = 0;
	for(int i=0;i<100;i++){
		int t = a[i/10][i%10];
		if(t==0) c++;
		if(b<t) b = t;
	}
	cout << c << endl;
	cout << b << endl;
}

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

#define ll long long
#define ii pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pi 3.141592653
#define oo 1000000007
#define loo 10000000000000007

#define prime 1000000007

#define W(x) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << "\n";
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    double a, b, x; cin >> a >> b >> x;
    double aux = x/(a*a);
    if(x>=a*a*b/2){
        double c = 2.0*(b - aux);
        double d = 180/pi*atan(a/c);
        cout << setprecision(9) << 90.0-d << "\n";
    }else{
        double c = 2.0*(aux*a/b);
        double d = 180/pi*atan(c/b);
        cout << setprecision(9) << 90.0-d << "\n";
    }

    return 0;
}

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

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

using namespace std;

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

int main() {
  ll n, a, b, c, d, e;
  cin >> n >> a >> b >> c >> d >> e;
  vector<ll> x(6, 0);
  // 一番遅い人の移動時刻を考える
  ll rateDeterminingStepValue = min({a, b, c, d, e});
  ll result = ceil((double) n / rateDeterminingStepValue) + 4;
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256