akhauriyash/Code-Regression huggingface dataset:
//  ROAD TO GREEN
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <queue>
#include <set>
#include <bitset>

#define ll long long
#define uint unsigned int
#define ull unsigned ll
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define speedhack() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


using namespace std;
const ll MAXN = 2e9+2;
const ll SIZE = 1e6+2;
const ll mod = 1e9+7;



int main(){ 
	speedhack()
	int a,b,c;
	cin >> a >> b >> c;
	cout << c-min(a-b,c) << endl;
	return 0;
}


Measured memory_bytes: 256
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
  return int(readline())
s = input()
t = input()
ans = len(t)
for i in range(len(s)-len(t)+1):
    nya = s[i:i+len(t)]
    #print(nya)
    p = 0
    for j in range(len(nya)):
        if t[j] == nya[j]:
            pass
        else:
            p += 1
    ans = min(ans,p)
print(ans)


Measured memory_bytes: 10400
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;

int main() {
  int n;
  cin >> n;
  map<string,int> mp;
  rep(i,n) {
    string s;
    cin >> s;
    mp[s]++;
  }
  int ans = mp.size();
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 19180
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int a,b,c,k;
  cin >> a>> b >> c >> k;
  if(k<=a){
    printf("%d\n",k);
  }
  else if(k<=a+b){
    printf("%d\n",a);
  }
  else if(k<=a+b+c){
    k=k-a-b;
    printf("%d\n",a-k);
  }
  return 0;
}

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

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

	vector<bool> c(8);
	int ansmax = 0;

	for(int i = 0; i < n; i++)
	{
		int k;
		cin >> k;
		if(k < 3200) c[k/400] = true;
		else ansmax++;
	}
	
	int ans = 0, ansmin;
	for(int i = 0; i < 8; i++)
	{
		if(c[i]) ans++;
	}
	ansmin = ans;
	if(ansmin == 0 && ansmax > 0) ansmin  = 1;
	ansmax += ans;

	cout << ansmin << ' ' << ansmax << endl;

	return 0;
}

Measured memory_bytes: 256
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
void main()
{
    auto n = lread();
    auto t = aryread();
    // writeln(t);
    auto m = lread();
    auto px = new long[][](m, 2);
    foreach (i; 0 .. m)
    {

        px[i] = aryread();

    }
    // writeln(px);
    foreach (i; 0 .. m)
    {
        writeln(px[i][1] + (sum(t[0 .. (px[i][0] - 1)])) + (sum(t[px[i][0] .. $])));

    }
}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s, ans = "";
    cin >> s;
    
    ans = s.substr(0, 4) + " " + s.substr(4);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, a, b;
    cin >> n >> a >> b;
    string s;
    cin >> s;
    int kakutei = 0;
    int kaigai = 1;
    rep(i, n) {
        if (s[i] == 'a') {
            if (kakutei < a+b) {
                kakutei++;
                cout << "Yes" << endl;
            } else {
                cout << "No" << endl;
            }
        } else if (s[i] == 'b') {
            if (kakutei < a+b && kaigai <= b) {
                kakutei++;
                kaigai++;
                cout << "Yes" << endl;
            } else {
                cout << "No" << endl;
            }
        } else {
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 848
using System;
class Program
 {
  		
        static void Main(string[] args)
        {/*
    　　int a,b,c;
            a = int.Parse(Console.ReadLine()); //標準入力
            string[] str = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
            b = int.Parse(str[0]);  //数値で受け取りたい場合は変換する
            c = int.Parse(str[1]);
　　　　　　　Console.Write("改行なし a = {0} b = {1} c = {2}", a, b, c)//改行なし出力
            Console.WriteLine("改行あり a = {0} b = {1} c = {2}", a, b, c);//改行付き出力*/
          
        long n,x;
          
          string[] str1 = Console.ReadLine().Split(' ');
          n = long.Parse(str1[0]);
          x = long.Parse(str1[1]);
          
        long[] a = new long[n];
          
          string[] str2 = Console.ReadLine().Split(' ');
          for(long c = 0; c<n; c++) 
          {
          	a[c] = long.Parse(str2[c]);
          }
          
          long time = 0;
          for(long d = 0; d<n-1; d++)
          {
            
          	if(a[d] + a[d+1] > x)
            {
              	time = time + a[d] + a[d+1] - x;
              if(a[d]>=x)
              {
               	a[d+1] = 0;
                a[d] = x;
              }else{
                a[d+1] = x - a[d];
              }
              
            }
            
          }
          
          Console.Write(time);
          
        }
 }

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD
int r;
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    double ans = 0;
    cin>>r;

    ans = 2*r*M_PI;

    cout << std::setprecision(12) << ans << endl;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int sum=0;
  bool aa=false;
  for(int i=0;i<N;i++){
    int a;
    cin >> a;
    if(a==(i+1)){
      if(aa)aa=false;
      else{
        aa=true;
        sum++;
      }
    }
    else if(aa)aa=false;
  }
  cout << sum;
}



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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<bitset<20>> vbi;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

//桁数
ll GetDigit(ll num)
{
  return log10(num) + 1;
}

//約数全列挙
vector<ll> enum_div(ll n)
{
  vector<ll> ret;
  for (ll i = 1; i * i <= n; ++i)
  {
    if (n % i == 0)
    {
      ret.push_back(i);
      if (i * i != n)
      {
        ret.push_back(n / i);
      }
    }
  }
  sort(begin(ret), end(ret));
  return ret;
}

//累乗(xのn乗%mod)
ll modpow(ll x, ll n, ll mod = MAX)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1)
      res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}

//階乗
ll factorial(ll n)
{
  if (n > 0)
    return n * factorial(n - 1);
  else
    return 1;
}

ll modinv(ll a, ll mod)
{
  ll b = mod, u = 1, v = 0;
  while (b)
  {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= mod;
  if (u < 0)
    u += mod;
  return u;
}

ll gcd(ll a, ll b)
{
  return b ? gcd(b, a % b) : a;
}

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

void Main()
{
  ll n; cin >> n;
  ll sum = 0;
  ll flag = 0;
  for(ll i = 1;i <= n;i++)
  {
    sum += i;
    if(sum >= n)
    {
      flag = i;
      break;
    }
  }
  for(ll i = 1;i <= flag;i++)
  {
    if(i == sum - n) continue;
    cout << i << endl;
  }
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  //cout << setfill('0') << internal << setw(4); 0埋め４桁
  Main();
  return 0;
}


Measured memory_bytes: 256
from itertools import*
from math import*
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = float("inf")
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

N = int(input())
dp=[inf]*110000
dp[0] = 0
for n in range(1,N+1):
    pow6,pow9 = 1,1
    while pow6<=n:
        dp[n] = min(dp[n],dp[n-pow6]+1)
        pow6 *= 6
    while pow9 <= n:
        dp[n] = min(dp[n],dp[n-pow9]+1)
        pow9 *= 9
print(dp[N])

Measured memory_bytes: 4560
def tax(n,r):
    return n*(100+r)//100

while True:
    x,y,s = map(int,input().strip().split(" "))
    if [x,y,s] == [0,0,0]:   #ｘは変更前税率、ｙは変更後税率、ｓは変更前税込み合計
        break
    S = []
    M = 0
    for i in range(1,s//2+1):
        for j in range(1,s-i+1):
            if  tax(i,x) + tax(j,x) == s:
                t = tax(i,y) + tax(j,y)
                if t > M:
                    M = t
    print(M)



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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n; cin>>n;
	vector<int> x(n), y(n);
	for(int i = 0; i < n; i++){
		cin>>x[i]>>y[i];
	}
	ld ans = 0;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			ld dx = x[i] - x[j];
			ld dy = y[i] - y[j];
			ld dist = sqrt(dx*dx + dy*dy);
			ans += dist/n;
		}
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;

int main(void){
  ll n;
  cin >> n;
  
  vector<ll> p(n + 1);
  vector<ll> a(n);
  for (int i = 0; i < n; i++){
    cin >> a[i];
    p[a[i]] = i;
  }

  ll ans = 0;
  set<ll> s;
  set<ll> s2;
  for (int i = 1; i <= n; i++){
    auto r = s.lower_bound(p[i]);
    auto r2 = s2.lower_bound(-p[i]);
    if (r == s.end()){
      if (i == 1){
        ans += i*(n - p[i]) * (p[i] + 1);
      }
      else {
        auto l = prev(r, 1);
        ans += i*(n - p[i]) * (p[i] - *l);
      }
    }
    else {
      auto l = r2;
      if (l == s2.end()){
        ans += i*(*r - p[i]) * (p[i] + 1);
      }
      else {
        ans += i*(*r - p[i]) * (p[i] + *l);
      }
    }

    s.insert(p[i]);
    s2.insert(-p[i]);
  }
  cout << ans << endl;
  

  return 0;
}


Measured memory_bytes: 22144
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
  
int main() {
  ll n;
  cin >> n;
  map<ll,ll> student;
  rep(i,n){
    ll a;
    cin >> a;
    student[a] = i+1;
  }
  rep(i,n){
    cout << student.at(i+1) << " ";
  }
  return 0;
}

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

bool solve(void) {
	long long int i,n,sum=0;
	cin>>n;
	long int a[n+1],b[n];
	for(i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	a[n]=a[0];
	long long int k=n*(n+1)/2;
	
	if(sum%k!=0)return false;
	long long int max=sum/k;
	
	for(i=0;i<n;i++){
		if((max-(a[i+1]-a[i]))%n!=0)return false;
		b[i]=(max-(a[i+1]-a[i]))/n;
		if(b[i]<0||b[i]>max)return false;
	}
	return true;
}

int main(){
	if(solve())cout<<"YES"<<endl;
	else{
		cout<<"NO"<<endl;
	}
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> ii;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, t;
    cin >> n;
    int a[n + 1], b[n];
    for (int ctr1 = 0; ctr1 <= n; ++ctr1)
        cin >> a[ctr1];
    for (int ctr1 = 0; ctr1 < n; ++ctr1)
        cin >> b[ctr1];
    ll rez = 0;
    for (int ctr1 = 0; ctr1 <= n; ++ctr1) {
        if (ctr1 > 0) {
            int cur = min(a[ctr1], b[ctr1 - 1]);
            b[ctr1 - 1] -= cur;
            a[ctr1] -= cur;
            rez += cur;
        }
        if (ctr1 < n) {
            int cur = min(a[ctr1], b[ctr1]);
            b[ctr1] -= cur;
            a[ctr1] -= cur;
            rez += cur;
        }
    }
    cout << rez << "\n";
    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
//#include <unordered_set>
//#include <unordered_map>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <locale>
using namespace std;
#define MS0(I) memset(I, 0, sizeof(I));
#define MS1(I) memset(I, -1, sizeof(I));
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, s, n) for(int i = (s); i < (n); ++i)
#define per1(i, a, b) for(int i = a; i >= b; --i)
#define DRI(A) int A; scanf("%d", &A);
#define DRII(A, B) int A, B; scanf("%d %d", &A, &B);
#define DRIII(A, B, C) int A, B, C; scanf("%d %d %d", &A, &B, &C);
#define SZ(X) ((int)X.size() )
#define MP make_pair 
#define pb push_back
#define F first
#define S second
#define ALL(I) (I).begin(), (I).end()
typedef const void CV;
typedef long long LL;
typedef unsigned long long ULL;
typedef double DB;
typedef long double LDB;
typedef pair<int, int> PII; 
const double eps = 1e-9;
const double PI = acos(-1);
const LL INFF = 1e18;
const int INF = 1e9;
const int mod = 1e9+7;
const int MAX = 1e5+7;
int n, m, s, t;
vector<PII>edge[MAX];
vector<PII>edge2[MAX];
void init(){
	scanf("%d %d %d %d", &n, &m, &s, &t);
	rep1(i, 1, m+1){
		DRII(u, v);
		DRII(v1, v2);
		edge[u].pb(MP(v, v1));
		edge2[u].pb(MP(v, v2));
		edge[v].pb(MP(u, v1));
		edge2[v].pb(MP(u, v2));
	}
}
#define PLI pair<LL, int>
priority_queue<PLI, vector<PLI>, greater<PLI>>pq;
LL in[MAX];
bitset<MAX>ck;
void sol2(){
	rep1(i, 1, n+1) in[i] = INFF;
	in[s] = 0;
	pq.push(MP(0, s));
	while(!pq.empty()){
		while(!pq.empty() && ck[ pq.top().S ]) pq.pop();
		if(pq.empty()) break;
		LL d; int u; tie(d, u) = pq.top(); pq.pop();
		in[u] = d; ck[u] = 1;
		for(auto x : edge[u]){
			if(!ck[x.F] && d + x.S < in[x.F]){
				in[x.F] = x.S + d;
				pq.push(MP(in[x.F], x.F));
			}
		}
	}
}
LL out[MAX];
void sol3(){
	ck.reset();
	rep1(i, 1, n+1) out[i] = INFF;
	out[t] = 0;
	pq.push(MP(0, t));
	while(!pq.empty()){
		while(!pq.empty() && ck[ pq.top().S ]) pq.pop();
		if(pq.empty()) break;
		LL d; int u; tie(d, u) = pq.top(); pq.pop();
		out[u] = d; ck[u] = 1;
		for(auto x : edge2[u]){
			if(!ck[x.F] && d + x.S < out[x.F]){
				out[x.F] = x.S + d;
				pq.push(MP(out[x.F], x.F));
			}
		}
	}
}
LL ans[MAX];
void sol(){
	sol2();
	sol3();
	LL mxn = 0, v = (LL)1e15;
	per1(i, n, 1){
		LL d = v - (in[i] + out[i]);
		mxn = max(mxn, d);
		ans[i-1] = mxn;
	}


	rep(i, n) printf("%lld\n", ans[i]);
}
int main(void){
	init();
	sol();
	return 0;
}


Measured memory_bytes: 16884
from sys import stdin

def count(N, s):
    r = 0
    b = 0
    for i in range(N):
        if s[i] == 'R':
            r = r + 1
        else:
            b = b + 1
    if r > b:
        return 'Yes'
    else:
        return 'No'


if __name__ == '__main__':

    N = int(stdin.readline().rstrip())
    s = stdin.readline().rstrip()

    print(count(N,s))


Measured memory_bytes: 2940
#include <stdio.h>
int main() {
    int H, W, i, k;
    while(1) {
        scanf("%d %d", &H, &W);
        if(H == 0 && W == 0) break;
        for(i = 0; i < H; i++) {
            for(k = 0; k < W; k++) {
                if(i == 0 || i == H - 1 || k == 0 || k == W - 1) {
                    printf("#");
                } else {
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 1796
import java.util.*;
import java.math.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int x = sc.nextInt();

    int[] l = new int[n];
    int[] data = new int[n+1];

    for (int i = 0; i < n; i++) {
      l[i] = sc.nextInt();
    }

    data[0] = 0;

    for (int i = 1; i < n+1; i++) {
      data[i] = data[i-1] + l[i-1];
    }

    int count = 0;

    for (int i = 0; i < n+1; i++) {
      if (data[i] <= x) {
        count++;
      }
    }

    System.out.println(count);

  }

}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> a;
    int temp;
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> temp;
        a.push_back(temp);
    }

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

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

int main(int argc, char const *argv[])
{
    int N, p;
    int i, ans, max;
    ans = 0;
    max = 0;
    cin >> N;
    for (i = 0; i < N; i++)
    {
        cin >> p;
        if (max < p)
        {
            max = p;
        }
        ans += p;
    }
    ans -= (max / 2);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
	int n;
	cin >> n;
	int a[n];
	REP(i,n) cin >> a[i];
	int b[n];
	if(n % 2 == 0){
		for(int i = 0; i < n / 2; i++) b[n / 2 + i] = a[i * 2];
		for(int i = 1; i <= n / 2; i++) b[n / 2 - i] = a[i * 2 - 1];
	}else{
		b[n / 2] = a[0];
		for(int i = 1; i <= n / 2; i++) b[n / 2 + i] = a[i * 2 - 1];
		for(int i = 1; i <= n / 2; i++) b[n / 2 - i] = a[i * 2];
	}
	REP(i,n) cout << b[i] << " ";
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  ll x;
  cin >> x;
  ll a = 100;
  REP(i, 1, 10000000) {
    a = a + a / 100;
    if (x <= a) {
      cout << i << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
inline LL read()
{
    LL x=0,f=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

const int maxn=1e6+7;
int cnt1[maxn],cnt2[maxn];
struct node
{
    int num,id;
    bool operator <(const node &b)const
    {
        return num>b.num;
    }
}a[maxn],b[maxn];

int main()
{
    int n=read();
    for(int i=1;i<maxn;i++){
        a[i].id=i;b[i].id=i;
    }
    int cntx=0,cnty=0;
    for(int i=1;i<=n;i++){
        int x=read();
        if(i&1){
            cntx++;
            a[x].num++;
        }
        else{
            cnty++;
            b[x].num++;
        }
    }
    sort(a+1,a+1+maxn-2);
    sort(b+1,b+1+maxn-2);
    int ans=maxn+7;
    if(a[1].id==b[1].id){
        ans=cntx+cnty-max(a[1].num+b[2].num,a[2].num+b[1].num);
    }
    else{
        ans=cntx+cnty-a[1].num-b[1].num;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;
vector <string> patterns;
using ll = long long;
void create_patterns(int n, string s){
    if(s.size()>n) return ;
    if(s.size()==n) {
        for(int i=0;i<n-1;i++){
            if(s[i]=='1'&&s[i+1] == '1') return ;
            
        }
        if(!binary_search(patterns.begin(), patterns.end(), s))patterns.push_back(s);
    }
    create_patterns(n, s+"0");
    create_patterns(n, s+"1");
    return ;
}
int main(void){
    int h,w,k; cin>>h>>w>>k;
    k--;
    if(w==1) {cout<<1<<endl; return 0;}
    create_patterns(w-1, "");
    vector <vector<int>> itoj(w ,vector <int>(w ));
    for(int i=0;i<patterns.size();i++){
        //cout<<patterns[i]<<endl;
        string s = patterns[i];
        if(s[0]=='0') itoj[0][0]++;
        //if(s[w-1]=='0') itoj[w-1][w-1]++;
        for(int j=1;j<w-1;j++){
            if(s[j-1]=='0'&&s[j]=='0') itoj[j][j]++;
        }
        for(int i=0;i<w-1;i++){
            if(s[i]=='1') {itoj[i][i+1]++; itoj[i+1][i]++;}
        }
    }
    itoj[w-1][w-1] = itoj[0][0];
    for(int i=0;i<w;i++){
        for(int j=0;j<w;j++){
            if(abs(i-j)>1) continue;
            //cout<<i<<"to"<<j<<' '<<itoj[i][j]<<endl;
        }
    }
    vector <vector<ll>> dp(h+5 ,vector <ll>(w));
    dp[0][0]=1;
    for(int i=0;i<h+1;i++){
        for(int j=0;j<w;j++){
            dp[i+1][j]+= dp[i][j]*itoj[j][j];
            if(j+1<w)
            dp[i+1][j+1] += dp[i][j]*itoj[j][j+1];
            if(j-1>=0)
            dp[i+1][j-1] += dp[i][j]*itoj[j][j-1];
            dp[i+1][j]%=1000000007;
            dp[i+1][j+1]%=1000000007;
            dp[i+1][j-1]%=1000000007;
        }
    }
    cout<<dp[h][k]<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()


int main() {
    int n,k;
    cin>>n>>k;
    ll a[n];
    rep(i,n){
        cin>>a[i];
    }
    if(k==1){
        cout<<0<<endl;
        return 0;
    }

    ll ans=1LL<<60;
    for(int bit=0;bit<(1<<n);bit++){
        if(__builtin_popcount(bit)==k-1 && !(bit & 1<<0)){
            ll cur=a[0],tmp=0;
            rep(i,n){
                if(bit & (1<<i)){
                    ll add=max(0LL,cur-a[i]+1);
                    tmp+=add;
                    cur=a[i]+add;
                }
                else cur=max(cur,a[i]);
            }
            //cout<<bit<<" "<<tmp<<endl;
            ans=min(ans,tmp);
        }
    }
 
    cout<<ans<<endl;
}




Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

// fact(n)
int fact(int n){
	if(n == 1)	return 1;
	else return (n * fact(n - 1));
}

// nCr(n,r)
int nCr(int n, int r){
	if(r == 0 || r == n)	return 1;
	else if(r == 1)	return n;
	return (nCr(n - 1, r - 1) + nCr(n - 1, r));
}

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

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

// swap(&a, &b);
void swap(int *a,int *b){
	int tmp;
	tmp = *a;	*a = *b;	*b = tmp;
	return;
}

// qsort(array, size, sizeof(int),comp);
int ASC(const int *a,const int *b){
	return (*a - *b);
}

int DESC(const int *a,const int *b){
	return (*b - *a);
}

// append(array,*size,addNum)
void append(int *array,int *size,int num){
	realloc(array, sizeof(int) * (*size + 1));
	array[(*size)] = num;
	++(*size);
}

// pop(array,*size) & nongetpop(array,*size)
int pop(int *array,int *size){
	int temp = array[(*size - 1)];
	nongetpop(array,&(*size));
	return temp;
}

int nongetpop(int *array,int *size){
	realloc(array,sizeof(int) * (*size - 1));
	--(*size);
}

int main(int argc, char const *argv[])
{	
	int n,s[100];
	int max = 0,min = 0x7F,pat,sum = 0;
	scanf("%d",&n);
	for (int i = 0; i < n; ++i){
		scanf(" %d",&s[i]);
		sum += s[i];
	}
	if(sum % 10 != 0){
		printf("%d\n",sum);
		return 0;
	}
	else{
		qsort(s,n,sizeof(int),ASC);
		for (int i = 0; i < n; ++i)
		{
			if(s[i] % 10 != 0){
				sum -= s[i];
				break;
			}
		}
		sum = (sum % 10 == 0) ? 0 : sum;
		printf("%d\n", sum);
	}
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
#define Tl 7010
int dp[Tl],cop[Tl],n,t,s;
int main(){
  cin>>n>>t>>s;
  lol(i,Tl)dp[i]=0;
  lol(u,n){
    int a,b;cin>>a>>b;
    lol(i,Tl)cop[i]=dp[i];
    for(int i=t;i>=0;i--){
      if(i<s&&s<i+b)cop[s+b]=max(cop[s+b],dp[i]+a);
      else cop[i+b]=max(cop[i+b],dp[i]+a);
    }
    lol(i,Tl)dp[i]=cop[i];
  }
  int ans=0;
  lol(i,t+1)ans=max(ans,dp[i]);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3144
// 2011/07/02 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		double wgt;
		cin >> wgt;
		if(cin.eof())
			break;

		if(wgt<=48.0)
			cout << "light fly" << endl;
		else if(wgt<=51.0)
			cout << "fly" << endl;
		else if(wgt<=54.0)
			cout << "bantam" << endl;
		else if(wgt<=57.0)
			cout << "feather" << endl;
		else if(wgt<=60.0)
			cout << "light" << endl;
		else if(wgt<=64.0)
			cout << "light welter" << endl;
		else if(wgt<=69.0)
			cout << "welter" << endl;
		else if(wgt<=75.0)
			cout << "light middle" << endl;
		else if(wgt<=81.0)
			cout << "middle" << endl;
		else if(wgt<=91.0)
			cout << "light heavy" << endl;
		else
			cout << "heavy" << endl;
	}

	return 0;
}

Measured memory_bytes: 0
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    B = list(map(int, input().split()))

    ans = []
    for _ in range(N):
        j = -1
        for i in range(len(B)):
            if B[i] == i+1:
                j = i
        if j == -1:
            print(-1)
            exit()
        ans.append(j+1)
        B.pop(j)
    for a in ans[::-1]:
        print(a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 64112
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;
int main() {
  string day[7] = { "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" };
  string S;
  cin >> S;
  for (int i = 0; i < 7; i++) {
	  if (day[i] == S) {
		  cout << 7 - i << endl;
		  return 0;
		}
	}
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

vector<vector<ll>> g;
vector<ll> num;
vector<P> constr;
bool ans = true;

void dfs1(ll pos, ll par) {
	REP(i,g[pos].size()) {
		if(g[pos][i] == par) continue;
		dfs1(g[pos][i], pos);
		if(abs(constr[pos].first) < INF && abs(constr[g[pos][i]].first) < INF
		   && abs(constr[pos].first) % 2 != abs(constr[g[pos][i]].first - 1) % 2) {
			// cout << 1 << " " << pos << endl;
			ans = false;
		}
		constr[pos].first = max(constr[pos].first, constr[g[pos][i]].first - 1);
		constr[pos].second = min(constr[pos].second, constr[g[pos][i]].second + 1);
		if(constr[pos].second - constr[pos].first < 0) {
			ans = false;
			// cout << 1 << " " << pos << endl;
		}
	}
	return;
}

void dfs2(ll pos, ll par) {
	if(par != -1) {
		if(abs(constr[pos].first) < INF && abs(constr[par].first) < INF
		   && abs(constr[pos].first) % 2 != abs(constr[par].first - 1) % 2) {
			// cout << 2 << " " << pos << endl;
			ans = false;
		}
		constr[pos].first = max(constr[pos].first, constr[par].first - 1);
		constr[pos].second = min(constr[pos].second, constr[par].second + 1);
	}
	if(constr[pos].second - constr[pos].first < 0) {
		ans = false;
		// cout << 2 << " " << pos << endl;
	}
	REP(i,g[pos].size()) {
		if(g[pos][i] == par) continue;
		dfs2(g[pos][i], pos);
	}
	return;
}

int main() {
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	g.resize(n);
	num.assign(n, -1);
	constr.assign(n, P(-INF, INF));
	REP(i,n-1) {
		ll a, b;
		cin >> a >> b;
		a--;
		b--;
		g[a].pb(b);
		g[b].pb(a);
	}
	ll k;
	cin >> k;
	REP(i,k) {
		ll v, p;
		cin >> v >> p;
		v--;
		num[v] = p;
		constr[v] = P(p, p);
	}
	dfs1(0, -1); dfs2(0, -1);
	if(!ans) cout << "No" <<endl;
	else {
		cout << "Yes" << endl;
		REP(i,n) cout << constr[i].first << endl;
	}
	return 0;
}


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


int main()
{
	int a, b, c;

	std::cin >> a >> b >> c;

	int dist1 = std::abs(a - b);
	int dist2 = std::abs(a - c);

	if (dist1 < dist2) {
		std::cout << "A" << std::endl;
	}
	else {
		std::cout << "B" << std::endl;
	}

	return 0;
}

Measured memory_bytes: 256
N,M,K = map(int,input().split())
*A, = map(int,input().split())
*B, = map(int,input().split())

def binary_search(l,r,func):
    if func(l):return l-1
    if not func(r):return r
    while l+1<r:
        i = (l+r)//2
        if func(i):
            r = i
        else:
            l = i
    return l


A = [0] + A
B = [0] + B
for i in range(1,N+1):
    A[i] += A[i-1]
for i in range(1,M+1):
    B[i] += B[i-1]

def g(i,t):
    return B[i]>t
ans = 0

for i,a in enumerate(A):
    T = K-a
    if T<0 : break
    gt = lambda x:g(x,T)
    tmp = binary_search(0,M,gt)
    ans = max(ans,tmp+i)
print(ans)

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

int main(){
  long long a,v,b,w,t;
  cin >> a >> v >> b >> w >> t;

  long long dis = abs(b - a);
  long long ver = w - v;

  // if(ver == 0) {
  //   if(dis == 0) cout << "YES" << endl;
  //   else cout << "NO" << endl;
  //   return 0;
  // }

  // if(ver < 0 && dis / abs(ver) <= t){
  if(ver < 0 && dis <= t * abs(ver)){
    cout << "YES" << endl;
  }else cout << "NO" << endl;
  
  return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;


const int len = 1000050;

inline int next(int pos){
	return (pos == len - 1) ? 0 : pos + 1;
}


inline int prev(int pos){
	return (pos == 0) ? len - 1: pos - 1;
}

int main(){
//	ios::sync_with_stdio(false);
//	cin.tie(0);
	
	int n;
	cin >> n;
	
	vector<int> li(len);
	int fi =0 ,la = 0;
	
	string op;
	int key;
	for(int i = 0;i < n;i++){
		cin >> op;
		if(op[0] == 'i'){
			cin >> key;
			fi = prev(fi);
			li[fi] = key;
		} else if(op.size() > 6 && op[6] == 'F'){
				while(li[fi] == -1){
					fi = next(fi);
				}
			fi=next(fi);
		} else if(op.size() > 6 && op[6] == 'L'){
			while(li[prev(la)] == -1){
				la = prev(la);
			}
			la=prev(la);
		 } else {
		 	cin >> key;
		 	for(int j = fi;j!=la;j=next(j)){
		 		if(li[j] == key){
		 			li[j] = -1;
		 			break;
		 		}
		 	}
		 }
	}
	
	bool nospace = true;
	for(int i = fi;i!=la;i=next(i)){
		if(li[i] == -1) continue;
		if(nospace){
			cout << li[i];
			nospace = false;
		}else{
			cout << " " << li[i];
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 6728
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1e18;
#define Pint pair<int, int>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rnr(i,a,b) for(int i=int(a);i>=int(b);i--)
#define rep(i,b) rng(i,0,b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    string s, t; cin >> s >> t;
    int ans = INF;
    rep(i, s.size()) {
        int tmp = 0;
        if(i + t.size() > s.size()) break;
        rep(j, t.size()) {
            if(s[i + j] == t[j])
                ++tmp;
        }
        ans = min(int(t.size() - tmp), ans);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k,d,i,j,l,count=0;
	map<int ,int>m;
	cin>>n>>k;
	for(i=1;i<=k;i++)
	{
		cin>>d;
		for(j=1;j<=d;j++)
		{
			cin>>l;
			m[l]=1;
		}
	}
	for(i=1;i<=n;i++)
	{
		if(m[i]==0)count++;
	}
	cout<<count<<endl;
	return 0;
}


Measured memory_bytes: 3640
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A

#B

#C

#D
s = S()
l = len(s)
for i in range(l-1):
    if s[i] == s[i+1]:
        print(i+1,i+2)
        quit()
for i in range(l-2):
    if s[i] == s[i+2]:
        print(i+1,i+3)
        quit()
print(-1,-1)
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 50544
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int D = sc.nextInt();
		int X = sc.nextInt();
		int y = 0;
		for (int i = 0; i < N; i++) {
			int Ai = sc.nextInt();
			for (int j = 0; j < D; j++) {
				int e = j * Ai + 1;
				if (e <= D) {
					y++;
				
				}
			}
		}
		int answer = y + X;
		System.out.println(answer);
		sc.close();
	}
}

Measured memory_bytes: 21844
K, N = map(int, input().split())
A = list(map(int, input().split()))

ans = float('inf')
for i in range(N):
    if i == 0:
        ans = min(ans, A[-1] - A[0])
    else:
        ans = min(ans, (A[-1]-A[i]) + (K-A[-1]) + (A[i-1]))

print(ans)

Measured memory_bytes: 77388
from collections import Counter
n, p = map(int, input().split( ))
s = input()
#n,p = 10000,5
#s = "7"*10000
#p=2,5は例外
#例外でなければ累積和
if p==2:
    ans = 0
    for i in range(n):
        if int(s[i])%2==0:
            ans += i+1
    print(ans)
    exit()
if p==5:
    ans=0###
    for i in range(n):
        if int(s[i])%5==0:
            ans += i+1
    print(ans)
    exit()


accm = [0]
s = s[::-1]
#print(s)
sm = 0
beki_p = 1
for i in range(n):
    sm += int(s[i])*beki_p
    sm %=p
    accm.append(sm)
    beki_p *=10
    beki_p%=p

aC = Counter(accm)
ans = 0
for k in aC:
    ans += aC[k]*(aC[k]-1)//2
print(ans)


Measured memory_bytes: 11956
#include <stdio.h>
#include <math.h>
#include <algorithm>
using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  long long minv = 2e+9;
  long long ans = -2e+9;
  for (int i = 0; i < n; i++) {
    long long v;
    scanf("%lld", &v);
    ans = max(ans, v - minv);
    minv = min(minv, v);
  }
  printf("%lld\n", ans);
}

Measured memory_bytes: 1028
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#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 <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
char c;
int sum;
int main()
{
  bool flag =true;
  sum = 0;
  c ='+';
  while(1){
    if(flag){
      int x;
      cin >>x;
      if(c =='+'){
	sum +=x;
      }else if(c =='-'){
	sum -=x;
      }else if(c =='*'){
	sum *=x;
      }else if(c =='/'){
	sum /=x;
      }
      flag = false;
    }else{
      cin >>c;
      if(c =='=')
	break;
      flag = true;
    }
  }
  cout <<sum<<endl;
  return 0;
}

Measured memory_bytes: 1160
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2019-12-07 22:21:13
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>

using namespace std;

using int64 = long long;
#define debug(_) cerr << #_ << ": " << (_) << '\n'
template<class T> ostream& operator<<(ostream& os, vector<T>& _) { os << '{'; for (T& x : _) { os << x; if (&x != &_.back()) os << ','; } os << '}'; return os; }
template<class T, class U> ostream& operator<<(ostream& os, pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }

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

  int n; cin >> n;
  vector<vector<int>> graph(n);
  vector<int> cnt(n, 0);
  vector<pair<int, int>> in(n);

  for (int i = 0; i < n - 1; ++i) {
    int a, b; cin >> a >> b;
    --a; --b;
    ++cnt[a]; ++cnt[b];
    graph[a].emplace_back(b);
    graph[b].emplace_back(a);
    in[i] = {a, b};
  }
  //cerr << '\n';
  cout << *max_element(cnt.begin(), cnt.end()) << '\n';

  map<pair<int, int>, int> mp;
  vector<int> color(n, -1);
  vector<bool> visited(n, false);

  queue<int> q;
  q.push(0);
  visited[0] = true;

  while (!q.empty()) {
    int cur = q.front(); q.pop();
    int num = 1;
    for (int next : graph[cur]) {
      if (visited[next]) continue;
      if (num == color[cur]) ++num;
      color[next] = num;
      mp[{cur, next}] = mp[{next, cur}] = num;
      ++num;
      visited[next] = true;
      q.push(next);
    }
  }

  for (int i = 0; i < n - 1; ++i) {
    cout << mp[in[i]] << '\n';
  }

  return 0;
}

Measured memory_bytes: 20096
// https://atcoder.jp/contests/abc162/tasks/abc162_f

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")
#define DUMP2DLL(a, n, m) REP(_i, n) REP(_j, m) printf("%lld%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

const int N_MAX = 2*1e5;
const int A_I_MAX = 1e9;
const ll INF = 1e15;

int N;
int A[N_MAX];

ll dp0[4][2];
ll dp1[4][2];

void solve() {
  auto cur = dp0;
  auto nxt = dp1;
  fill(cur[0], cur[4], -INF);
  cur[0+1][0] = 0;
  REP(i, N) {
    // DUMP2DLL(cur, 4, 2);
    nxt[-1+1][0] = -INF;
    nxt[-1+1][1] = cur[0+1][0] + A[i];
    nxt[0+1][0] = max(cur[-1+1][0], cur[-1+1][1]);
    nxt[0+1][1] = cur[1+1][0] + A[i];
    nxt[1+1][0] = max(cur[0+1][0], cur[0+1][1]);
    nxt[1+1][1] = cur[2+1][0] + A[i];
    nxt[2+1][0] = max(cur[1+1][0], cur[1+1][1]);
    nxt[2+1][1] = -INF;
    swap(cur, nxt);
  }
  // DUMP2DLL(cur, 4, 2);
  ll ans = max(cur[N % 2 + 1][0], cur[N % 2 + 1][1]);
  printf("%lld\n", ans);
}

void input() {
  scanf("%d", &N);
  REP(i, N) scanf("%d", A + i);
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 4652
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}
void judgement(int a){
  if(a){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  if(a){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

int main(){
  ll i,j,N,H,W,ans;
  cin>>N;
  H=N/100;
  W=N%100;
  cout<<(H*5>=W)<<endl;
  return 0;
}

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

using namespace std;

int main()
{
    string s, t;
    cin >> s >> t;
    string p="";
    int sum = 0;
    int result = 0;
    for (int i=0; i < s.size() - t.size() + 1; i++) {
        sum = 0;
        string temp = s.substr(i, t.size());
        for (int j = 0; j < t.size(); j++) {
            string a = {temp[j]};
            string b = {t[j]};
            if (a == b) {
                sum++;
                // cout << sum << endl;
            }
        }
        if (result < sum) {
            result = sum;
        }
    }
    
    cout << t.size() - result << endl;
}

Measured memory_bytes: 3560
#include <stdio.h>

int main(){
    int N;
    int A[1000000];
    int Sub[1000000] = {};
    
    scanf("%d", &N);

    for(int i = 1; i <= N; i++){
        scanf("%d", &A[i]);
        Sub[A[i]]++;
    }
    for(int j = 1; j <= N; j++){
        printf("%d\n", Sub[j]);
    }
    }

Measured memory_bytes: 6380
import sys
import copy


def solve():
    n = 10**6
    INF = 10**3
    dp = [INF] * (n + 1)
    dp[0] = 0
    dp_odd = copy.deepcopy(dp)

    for i in range(n):
        for x in arr:
            if i + x > n:
                break
            if dp[i + x] > dp[i] + 1:
                dp[i + x] = dp[i] + 1
            if x % 2:
                if dp_odd[i + x] > dp_odd[i] + 1:
                    dp_odd[i + x] = dp_odd[i] + 1

    return dp, dp_odd


arr = [1]

for i in range(1, 180):
    arr.append(arr[-1] * (i + 3) // i)

a, b = solve()


while True:
    n = int(input())
    if n == 0:
        sys.exit()
    print(a[n], b[n])


Measured memory_bytes: 22044
#include<bits/stdc++.h>//万能头文件
using namespace std;
string s;
int judge=0;
int main()
{
    cin>>s;
    if(s[0]==s[s.size()-1])//满足条件1
        judge++;
    if(s.size()%2==1)//满足条件2
        judge++;
    if(judge==1)//满足一个是First
        cout<<"First"<<endl;
    else
        cout<<"Second"<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
#include <tuple>
#include <bitset>
#include <ciso646>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;

inline bool cheak(ll x, ll y, ll xMax, ll yMax){ return x >= 0 && y >= 0 && xMax > x && yMax > y; }
inline ll toInt(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<class T> inline T sqr(T x) { return x*x; }

#define For(i,a,b)	for(ll (i) = (a);i < (b);(i)++)
#define rep(i,n)	For(i,0,n)
#define rFor(i,a,b)	for(ll (i) = (a-1);i >= (b);(i)--)
#define rrep(i,n)	rFor(i,n,0)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define sz(a)		(sizeof(a))

const ll dx[8] = { 1, 0, -1, 0, 1, 1, -1, -1 }, dy[8] = { 0, -1, 0, 1, -1, 1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = 1e9 + 9;

vector<pair<int, string>> vs[1001];
void dfs(int m,int c){
	rep(i, vs[m].size()){
		rep(j, c)cout << ".";
		cout << vs[m][i].second << endl;
		dfs(vs[m][i].first,c+1);
	}
}

int main(){
	int n;
	cin >> n;
	For(i,1, n+1){
		int t;
		string s;
		cin >> t >> s;
		vs[t].push_back(make_pair(i, s));
	}
	dfs(0,0);
	return 0;
}

Measured memory_bytes: 1452