akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
#include<vector>//s1.erase(n)=文字列s1の、n文字目以降削除
#include<algorithm>//辞書順=next_permutation
#include<set>
#include<string>//char 小文字のほうが32大きい
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap=数値交換
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define str string
#define please return
#define AC 0
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
#define Pi 3.1415926535897932384626
#define nine 1000000000

using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */


int main(void) {

	char s[4];
	cin >> s;
	rep(i, 3) {
		if (s[i] == '1')cout << 9;
		else cout << 1;
	}
	cout << rt;

	please AC;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N;
	cin >> N;

	int A[200001];
	int mae[200002] = {};
	int ato[200002] = {};
	rep1(i, N) {
		cin >> A[i];
		mae[i] = max(mae[i - 1], A[i]);
	}
	for (int i = N; i >= 1; i--) {
		ato[i] = max(ato[i + 1], A[i]);
	}

	rep1(i, N) {
		co(max(mae[i - 1], ato[i + 1]));
	}

	Would you please return 0;
}

Measured memory_bytes: 3968
from sys import stdin
input = stdin.readline

def solve():
    N = int(input())
    res = []
    while True:
        N -= 1
        N,r = divmod(N,26)
        res.append(chr(ord('a')+r))
        if N == 0:
            break

    print(''.join(reversed(res)))






if __name__ == '__main__':
    solve()


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

int main() {
  ll N;
  vector<char> a(26);
  vector<char> result;
  
  cin >> N;
  rep(i, 26)
  {
    a[i] = i + 'a';
  }
  
  while(N > 0)
  {
    result.push_back(a.at((N - 1) % 26));
    N = (N - 1) / 26;
  }

  for(int i = result.size() - 1; i >= 0; i--)
  {
    cout << result.at(i);
  }
}

Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
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(a > b){ a = b; return 1; } return 0; }
typedef long long ll;
const ll MOD=1e+9+7;
struct mint{
  ll x;
  mint(ll x=0):x(x%MOD){}
  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*(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()
{
  ll n,k;cin >> n >> k;
  mint res;
  n++;
  for(ll i = k; i <= n; ++i) {
    ll tmp = n*(n-1)/2 - (n-i)*(n-i-1)/2 - i*(i-1)/2 + (ll)1;
    res += (mint)tmp;
  }
  cout << res.x << "\n";
  return 0;
}


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

using vi = vector<int>;
using vvi = vector<vi>;
using State = tuple<double, int, int, int>;

int n;
double R, theta;

vector<vector<double>> dist, angle;
vector<vvi> min_dist;

const double pi = acos(-1);

int main(void){
    cin >> n;
    cin >> R >> theta;
    theta *= pi / 180.0;

    vector<int> x(n), y(n);
    rep(i, n) cin >> x[i] >> y[i];

    dist = angle = vector<vector<double>>(n, vector<double>(n));
    rep(i, n){
        rep(j, n){
            if(i == j) continue;

            int dx = x[j] - x[i], dy = y[j] - y[i];
            dist[i][j]  = sqrt(pow(dx, 2) + pow(dy, 2));
            angle[i][j] = atan2(dy, dx);
        }
    }

    vector<vvi> edge(n + 1, vvi(n + 1));
    rep(i, n){
        rep(j, n){
            if(i == j) continue;
            rep(k, n){
                if(j == k) continue;

                double dtheta = angle[j][k] - angle[i][j];
                while(dtheta < 0)      dtheta += 2 * pi;
                while(dtheta >= pi) dtheta -= 2 * pi;

                if(fabs(dtheta) <= theta){
                    edge[i][j].push_back(k);
                }
            }
        }
    }
    range(i, 1, n) edge[n][0].push_back(i);

    priority_queue<State, vector<State>, greater<State>> q;
    q.push(State(0.0, n, 0, 0));

    const int inf = R + 1234;
    min_dist = vector<vvi>(n + 1, vvi(n + 1, vi(10001, inf)));

    int res = 0;
    while(q.size()){
        double d;
        int prev, v, num;
        tie(d, prev, v, num) = q.top();
        q.pop();

        if(d > R or min_dist[prev][v][num] != inf) continue;
        min_dist[prev][v][num] = d;
        res = max(res, num);

        for(auto & nv : edge[prev][v]){
            if(min_dist[v][nv][num + 1] != inf) continue;
            q.push(State(d + dist[v][nv], v, nv, num + 1));
        }
    }

    cout << res << endl;

	return 0;
}

Measured memory_bytes: 22204
import java.io.PrintWriter

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

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val s = nextInt()
    fun f(n: Int) = if (n % 2 == 0) n / 2 else 3 * n + 1
    val H = ArrayList<Int>()
    var a = s
    H.add(a)
    (2..10000000).forEach { m ->
        a = f(a)
        if (H.contains(a)) {
            println(m)
            return
        }
        H.add(a)
    }
}

Measured memory_bytes: 34760
s = input()
t = input()

maxS = 0
if len(s) != len(t):
    for i in range(len(s) - len(t)):
        simC = 0
        subS = s[i:i + len(t)]
        for ind,j in enumerate(subS):
            if t[ind] == j:
                simC += 1
        if simC>maxS:
            maxS = simC
    print(len(t) - maxS)
else:
    cou = 0
    for i in range(len(s)):
        if s[i] == t[i]:
            cou += 1
    print(len(s) - cou)

Measured memory_bytes: 9144
/*  ex7_1
    takafumi_ueki*/
#include <stdio.h>
#include <math.h>
//頂点を表す構造体
typedef struct{
    int x_elem;
    int y_elem;
}point;

int main(void){
    int x1,y1,x2,y2,x3,y3,x4,y4;
    //値を受け取る
    scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
    point point1={x1,y1},point2={x2,y2},point3,point4;
    /*  90度回転させた点（x3,y3）（x4,y4）はx1,x2,y1,y2を用いて
        x3 = x2 + y1 -y2
        y3 = x2 + y2 -x1
        x4 = x1 + y1 -y2
        y4 = x2 + y1 -y1 で表される。 */
    point3.x_elem = point2.x_elem + point1.y_elem - point2.y_elem;
    point3.y_elem = point2.x_elem + point2.y_elem - point1.x_elem;
    point4.x_elem = point1.x_elem + point1.y_elem - point2.y_elem;
    point4.y_elem = point1.y_elem + point2.x_elem - point1.x_elem;
    //結果を出力する
    printf("%d %d %d %d\n",point3.x_elem,point3.y_elem,point4.x_elem,point4.y_elem);
    return 0;
}

Measured memory_bytes: 1688
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	var (
		x, ans float64
		u      string
	)
	for i := 0; i < n; i++ {
		fmt.Scan(&x, &u)
		if u == "JPY" {
			ans += x
		} else {
			ans += 380000 * x
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<stdio.h>

int main(void)
{
    int x,y,z;
    int tmp;

    scanf("%d %d %d",&x,&y,&z);
    // printf("%d %d %d",x,y,z);

    tmp=x;
    x=y;
    y=tmp;

    tmp=x;
    x=z;
    z=tmp;

    printf("%d %d %d\n",x,y,z);

    return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  auto judge = [](string s) -> bool {
    int n = s.size();
    rep(i, n / 2) {
      if (s[i] != s[n - i - 1]) return false;
    }
    return true;
  };
  string s;
  cin >> s;
  int n = s.size();
  int c = n / 2;
  if (judge(s) && judge(s.substr(0, c)) && judge(s.substr(c + 1))) {
    yes();
  } else {
    no();
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
using namespace std;

int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	char a,b;
	cin>>a>>b;
	if(a==b)cout<<"H"<<endl;
	else cout<<"D"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
using namespace std;
#define INT_MAX 2147483647
#define INT_MIN (-2147483647 - 1)
#define INF (int)1e8
#define _INF (int)-1e8
#define INFLL (long long)1e14
#define _INFLL (long long)-1e14
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<ll, int> P;


int main(){
	int n;
	cin >> n;
	map<int, int> mp;
	Loop(i, n) {
		int a; cin >> a;
		mp[a] ++;
	}
	if (mp.size() % 2 == 1) cout << mp.size() << endl;
	else cout << mp.size() - 1 << endl;
	return 0;
}


Measured memory_bytes: 4864
def main():
    R, G, B, N = map(int, input().split())

    ans = 0
    for i in range(N+1):
        for j in range(N+1):
            tmp = N - i * R - j * G
            if tmp % B == 0 and tmp >= 0:
                ans += 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 40684
def enque(x):
  global tail
  global n
  global queue_list
  queue_list[tail]=x
  if tail==n:
    tail=0
  else:
    tail+=1

def deque():
  global head
  global n
  global queue_list
  _=queue_list[head]
  if head==n:
    head=0
  else:
    head+=1
  return _

n,q=map(int,input().split())
queue_list=[['',0] for i in range(n+1)]
sum_time=0
head=0
tail=n
for i in range(n):
  queue_list[i][0],_time=input().split()
  queue_list[i][1]=int(_time)
while head!=tail:
  _deque=deque()
  if _deque[1]-q >0:
    sum_time+=q
    _deque[1]-=q
    enque(_deque)
  else:
    sum_time+=_deque[1]
    print(_deque[0],sum_time)



Measured memory_bytes: 13016
def exam_and_wizard(a: list, b: list) -> int:
    if sum(a) < sum(b):
        return -1

    count = 0
    minus = 0
    usable = []
    for _a, _b in zip(a, b):
        if _a < _b:
            minus += _a - _b
            count += 1
        elif _a > _b:
            usable.append(_a - _b)
    
    usable = sorted(usable)
    while minus < 0:
        p = usable.pop()
        minus += p
        count += 1

    
    return count


if __name__ == "__main__":
    # ignore N
    _ = input()
    a = [int(s) for s in input().split()]
    b = [int(s) for s in input().split()]

    ans = exam_and_wizard(a, b)
    print(ans)


Measured memory_bytes: 18356
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 0
constexpr int kMod = 1000000007;
typedef long long LL;

struct Cond {
  int k;
  std::vector<int> s;
  int p;
};

int main() {
  int N, M; std::cin >> N >> M;
  std::vector<Cond> cs;

  for (int m = 0; m < M; ++m) {
    Cond c; std::cin >> c.k;
    for (int i = 0; i < c.k; ++i) {
      int v; std::cin >> v;
      c.s.push_back(v);
    }
    cs.push_back(c);
  }
  for (int m = 0; m < M; ++m) {
    std::cin >> cs[m].p;
  }

  int cnt = 0;
  for (int i = 0; i < pow(2, N); ++i) {
#if DEBUG
    std::cout << "---------- i = " << i << std::endl;
#endif
    std::string p;
    bool success = true;
    int b = pow(2, N-1);
    while (b>0) {
      if (i&b) p += '1';
      else     p += '0';
      b >>= 1;
    }

    for (auto c : cs) {
#if DEBUG
      std::cout << "p = " << c.p << std::endl;
#endif
      int on_cnt = 0;
#if DEBUG
      for (int v : c.s) std::cout << v << " ";
      std::cout << std::endl << "->" ;
#endif
      for (int v : c.s) {
#if DEBUG
        std::cout << p[v-1] << " ";
#endif
        if (p[v-1] == '1') ++on_cnt;
      }
#if DEBUG
      std::cout << "on_cnt = " << on_cnt % 2<< std::endl;
#endif
      if (on_cnt%2 != c.p) {
        success = false;
        break;
      }
    }

    if (success) ++cnt;
  }

#if DEBUG
  std::cout << "Result:";
#endif
  std::cout << cnt << std::endl;
}


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

template <class T, T Op(T, T), T E()> struct SegmentTree {
  const int n;
  vector<T> t;
  SegmentTree(int _n) : n(_n), t(2 * n, E()) {}
  T& operator[](int i) { return t[n + i]; }
  void build() { for (int i = n; i-- > 1; ) t[i] = Op(t[2 * i], t[2 * i + 1]); }
  T fold(int l, int r) const {
    T a = E(), b = E();
    for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
      if (l & 1) a = Op(a, t[l++]);
      if (r & 1) b = Op(t[--r], b);
    }
    return Op(a, b);
  }
  void set(int i, T a) {
    t[i += n] = a;
    while (i >>= 1) t[i] = Op(t[2 * i], t[2 * i + 1]);
  }
};
double mul(double a, double b) { return a * b; }
double one() { return 1; }

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  SegmentTree<double, mul, one> st(n);
  vector<int> t(n);
  for (int i = 0; i < n; ++i) {
    int p;
    cin >> t[i] >> p;
    st[i] = (1 - 0.1 * p);
  }
  st.build();
  int q;
  cin >> q;
  while (q--) {
    int l, r;
    cin >> l >> r;
    l = lower_bound(begin(t), end(t), l) - begin(t);
    r = lower_bound(begin(t), end(t), r) - begin(t);
    double res = 1e9 * st.fold(l, r);
    cout << fixed << setprecision(15) << res << '\n';
  }
}



Measured memory_bytes: 5016
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <numeric>
#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);

	int N, M;
	long long sum = 0;
	vector<pair<int, int>> drink;
	cin >> N >> M;

	REP(i, N) {
		int A, B;
		cin >> A >> B;
		drink.push_back(make_pair(A, B));
	}

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

	REP(i, N) {
		REP(j, drink[i].second) {
			if (M == 0) break;
			sum = sum + drink[i].first;
			--M;

		}
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 1400
n = input()
n1 = 0
n2 = 0

for i in range(len(n)):
    n1 += int(n[i])
    n2 += int(n[i]) * 10 ** (len(n) - i - 1)

if n2 % n1:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 2940
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var (
		a, b int
		s    string
	)
	fmt.Scan(&a, &b, &s)
	for i, v := range s {
		if i == a {
			if string(v) == "-" {
				continue
			} else {
				fmt.Println("No")
				return
			}
		}
		_, err := strconv.Atoi(string(v))
		if err != nil {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 512
#include <iostream>
#include <queue>
#include <utility>

using namespace std;

int main(){
    int N, A, B,max = 0;
    long int t = 0;
    cin >> N;
    priority_queue<pair<int, int>> q;
    for (int i = 0; i < N;i++){
        cin >> A >> B;
        if(B > max)
            max = B;
        t += A;
        q.push(make_pair(B, A));
    }
    if(t > max){
        cout << "No" << endl;
        return 0;
    }
    while(!q.empty()){
        int b = q.top().first;
        int a = q.top().second;
        q.pop();
        if(max < a){
            cout << "No" << endl;
            return 0;
        }
        if(max > b)
            max = b;
        max = max - a;
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 2420
#include <stdio.h>
#include <string.h>
 
int main(void){

  char A[200];
  int h,i,j,m,n;
  char t;
 
  scanf("%s",A);
  n=strlen(A);
  while (A[0]!='-'){
    scanf("%d",&m);
    for (i=0;i<m;i++){
      scanf("%d",&h);
      while(h-->0){
        t=A[0];
        for (j=1;j<n;j++){
          A[j-1]=A[j];
        }
        A[n-1]=t;
      }
    }
 
    for (i=0;i<n;i++)
      printf("%c",A[i]);
    printf("\n");
    scanf("%s",A);
    n=strlen(A);
  }
 
  return 0;
}


Measured memory_bytes: 2112
// g++ -std=c++14

//Difficulty according to solve count during contest:
//A B C D H F E I G K L M N P S O Q R J U Z Y X T V W

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

#define int long long
const int mod = 1e9 + 7;


string k;
int d;
int n;
vector<vector<vector<int> > > dp;

int func(int pos, int rem, int check){
  if(pos == n and rem == 0)
    return 1;
  else if(pos == n)
    return 0;
  if(dp[pos][rem][check] != -1)
    return dp[pos][rem][check];
  dp[pos][rem][check] = 0;
  int maxDigit = 0;
  if(check == 0)
    maxDigit = k[pos] - '0';
  else
    maxDigit = 9;
  for(int i = 0; i <= maxDigit; i++){
    int newCheck = check;
    if(check == 0 and i < maxDigit)
      newCheck = 1;
    dp[pos][rem][check] += func(pos + 1, (rem + i) % d, newCheck);
    dp[pos][rem][check] %= mod;
  }
  return dp[pos][rem][check];
}


int32_t main(){
  cin >> k;
  cin >> d;
  n = (int)k.size();
  dp.resize(n, vector<vector<int> > (d, vector<int>(2, -1)));
  int ans = func(0, 0, 0);
  cout << (ans - 1 + mod) % mod << endl;
}


Measured memory_bytes: 59400
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
int main() {
	string a, b, c;
	cin >> a >> b >> c;
	if (a[a.length() - 1] == b[0] && b[b.length() - 1] == c[0])
		cout << "YES" << "\n";
	else
		cout << "NO" << "\n";
}

Measured memory_bytes: 3588
import java.io.*;
import java.util.Scanner;

public class Main{
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);
        
        double x = scan.nextDouble();
        double y = scan.nextDouble();
        double xx = scan.nextDouble();
        double yy = scan.nextDouble();
        int qer = scan.nextInt();
                    
        double xxx = 0;
        double yyy = 0;
        xxx = xx - x;
        yyy = yy - y;
        
        double xp[] = new double[qer];
        double yp[] = new double[qer];
        double ansx[] = new double[qer];
        double ansy[] = new double[qer];
        for(int i = 0; i < qer; i++){
            xp[i] = scan.nextDouble();
            yp[i] = scan.nextDouble();
            double xxxx = x - xp[i];
            double yyyy = y - yp[i];
            ansx[i] = x - xxx * (xxxx * xxx + yyyy * yyy) / (xxx * xxx + yyy * yyy);
            ansy[i] = y - yyy * (xxxx * xxx + yyyy * yyy) / (xxx * xxx + yyy * yyy);
            ansx[i] = 2 * ansx[i] - xp[i];
            ansy[i] = 2 * ansy[i] - yp[i];
            System.out.println(ansx[i] + " " + ansy[i]);
        }

    }

}

Measured memory_bytes: 41992
#include <stdio.h>
#define N_MAX 20

int main(void){
    // Your code here!
    int p[N_MAX];
    int n;
    
    scanf("%d", &n);
    for(int i = 0; i < n; i ++){
        scanf("%d", p+i);
    }
    
    int num = 0;
    for(int i = 1; i < n-1; i ++){
        int p1 = p[i-1];
        int p2 = p[i];
        int p3 = p[i+1];
        num += (p1 < p2 && p2 < p3) || (p3 < p2 && p2 < p1);
    }
    printf("%d", num);
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<functional>
using namespace std;
#define INF 1e15
#define MOD 1000000007
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
typedef long long ll;
#define END system("PAUSE");return 0
int n;
signed main() {
	cin >> n;
	if (n == 1)puts("Hello World");
	else {
		int a, b;
		cin >> a >> b;
		cout << a + b << endl;
	}
	END;
}


Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,x,y) for(int i=x;i<(y);++i)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
/* start */

const int mod = 998244353;

int dp[3030][3030];

signed main(){
   IOS;
   int n, s; cin >> n  >> s;
   vector<int> a(n+1);
   rep(i,0,n) cin >> a[i+1];
   dp[0][0] = 1;
   for(int i = 1;i<=n;i++){
      for(int j = 0;j<3030;j++){
         if(j - a[i] >= 0 and i > 0){
            dp[i][j] = (dp[i-1][j]*2 + dp[i-1][j-a[i]])%mod;
         }
         else dp[i][j] = (dp[i-1][j]*2)%mod;
      }
   }
   cout << dp[n][s] << '\n';
}

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



int fun(string s, string t){
    int res=  0;
    for(int i = 0;i<s.size();i++){
        if(s[i]!=t[i]){
            res++;
        }
    }

    return res;
}



int main(){
        
        ios_base::sync_with_stdio(false); 
        cin.tie(NULL);    
        string s,t;
        cin>>s;
        cin>>t;
        
        int res = INT_MAX;
        for(int i = 0;i<s.size()-t.size()+1;i++){
            res = min(res , fun(s.substr(i,t.size()),t));
        }
    cout<<res<<endl;
   return 0;

}

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

using namespace std;

using ll = long long;
const int INF = 1001001001;
const ll LLINF = 1001001001001001001;
const int MOD = 1000000007;

typedef struct tagNode_t {
  // このノードから伸びるエッジ情報
  vector<pair<int ,ll>> edges; // 各エッジの接続先のノード番号とコスト

  //ベルマンフォード法のためのデータ
  ll cost; // このノードへの現時点で判明している最小コスト
  int from; // どこから来たのか
} Node_t;

int main()
{
  int n, m;
  cin >> n >> m;
  vector<Node_t> g(n+1);

  // src dst edge cost の順で入力がある
  rep (i, m) {
    int src, dst;
    ll cost;
    cin >> src >> dst >> cost;
    g[src].edges.push_back(make_pair(dst, -cost));
  }

  rep (j, n+1) {
    g[j].cost = LLINF;
    g[j].from = INF;
  }

  // 1番からスタートする
  // 初期化
  g[1].cost = 0;
  g[1].from = 0;

  // ベルマンフォード法
  // 
  // n-1回目でcostが更新された場合、それは負の閉路が有ることを意味している
  //
  // 辺の情報をすべて見ることを１ループとすると、
  // １ループするたびに最低でも１つの頂点についての最短距離は求まるので、
  // 頂点の数をVとするとV−1回のループでグラフ全体の最短距離を求めることができます
  //（V−1になる理由は始点はループする前に0と決定しているため。)
  // そのため、V回目のループで頂点の更新があった場合は
  // そのグラフに負の閉路があることになります。

  vector<bool> hu(n+1, false); // 負の閉路を管理する配列

  rep (i, n) {
    for (int j = 1; j <= n; j++) {
      // costが更新できるかを全ての隣接しているedgeについて調べる
      for (auto e : g[j].edges) {
        int eTo = e.first;
        ll eCost = e.second;
        if (g[eTo].cost > eCost + g[j].cost) {
          // n-1回目のループでの更新があった場合、負の閉路がある
          if (i == n-1) {
            hu[j] = true;
          }
          g[eTo].cost = eCost + g[j].cost;
          g[eTo].from = j;
        }
      }
    }
  }

  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (hu[j]) {
        for (auto e : g[j].edges) {
          int eTo = e.first;
          hu[eTo] = true;
        }
      }
    }
  }

  if (hu[n]) {
    cout << "inf" << endl;
    return 0;
  }
  cout << -g[n].cost << endl;
}


Measured memory_bytes: 3716
#include<iostream>
#include<string>
#include<utility>
#include<vector>
using namespace std;
typedef pair<char, int> P;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int N = S.length();
    vector<P> rest;
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        if (S[i] != 'x') rest.push_back(P(S[i], i));
        else cnt++;
    }
    int M = rest.size();
    for (int i = 0; i < M / 2; i++) {
        if (rest[i].first != rest[M - i - 1].first) {
            cout << -1 << endl;
            return 0;
        }
    }
    int ans = 0;
    for (int i = 0; i < (M + 1) / 2; i++) {
        if (i == 0) {
            int d1 = rest[i].second;
            int d2 = N - 1 - rest[M - i - 1].second;
            ans += abs(d1 - d2);
        }
        else {
            int d1 = rest[i].second - rest[i - 1].second - 1;
            int d2 = rest[M - i].second - rest[M - i - 1].second - 1;
            ans += abs(d1 - d2);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1480
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double pi = acos(-1);
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}

	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) {
	for (auto &e : t) fill_v(e, v);
}

//↑template↑



int a, b, k[105], now, ans;
int main() {
	cin >> a >> b;
	for (int i = 0; i < a; ++i) {
		cin >> k[i];
		if (now <= b) { ++ans; }
		now += k[i];
	}
    if (now <= b) { ++ans; }
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int a,b,c,i;
    while(scanf("%d %d",&a,&b) != EOF){
        c=a+b;
        if(0<=c&&c<10){
            printf("1\n");
        }else if(10<=c&&c<100){
            printf("2\n");

        }else if(100<=c&&c<1000){
            printf("3\n");

        }else if(1000<=c&&c<10000){
            printf("4\n");

        }else if(10000<=c&&c<100000){
            printf("5\n");

        }else if(100000<=c&&c<1000000){
            printf("6\n");

        }else if(1000000<=c&&c<10000000){
            printf("7\n");

        }
    }

return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
const double eps=1e-9;
typedef vector<int> vi;
typedef long long ll;
int n;
ll h[105];
int main(void)
{
    while(cin >> n && n) {
        for (int i = 0; i <= n; i++) {
            cin >> h[i];
        }
        ll ans;
        for (int i = 0; i <= n; i++) {
            //とりあえず,h[i]だけ無しとして考えて、等差数列になるか見てみよう。
            ll now = -1;
            ll next = -1;
            ll dif = -1;
            ll pre,nxt;//h[i]を飛ばす関係で,単純にh[j]-h[j-1]にできないので苦し紛れ。
            bool clear = true;
            for (int j = 0; j <= n; j++) {
                if (i == j) continue;
                nxt=h[j];
                if (now == -1) {
                    now = h[j];
                    pre=h[j];
                    continue;
                }
                if (now!=-1 && next == -1) {
                    next = h[j];
                    dif = next - now;
                    pre=h[j];
                    continue;
                }
                if (nxt - pre != dif) {
                    clear = false;
                    break;
                }
                pre=h[j];
            }
            if (clear) ans = h[i];
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3092
N, M = [int(_) for _ in input().split()]
AS = []
for _ in range(M):
    a, _ = [int(_) for _ in input().split()]
    s = sum(1 << (c - 1) for c in [int(_) for _ in input().split()])
    AS += [(a, s)]
dp = [10**10] * (1 << N)
dp[0] = 0
for S in range(1 << N):
    for a, s in AS:
        dp[S | s] = min(dp[S | s], dp[S] + a)
if dp[-1] == 10**10:
    print(-1)
else:
    print(dp[-1])


Measured memory_bytes: 45288
while True:
    i = list(map(int, input().split()))
    if i[0] == 0 and i[1] == 0:
        break
    else:
        for j in range(i[0]):
            for k in range(i[1]):
                if j % 2 == 0 and k % 2 == 0:
                    print("#", end='')
                elif j % 2 == 1 and k % 2 == 1:
                    print("#", end='')
                else:
                    print(".", end='')
            print("\n", end='')
        print("\n", end='')


Measured memory_bytes: 7012
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
typedef pair <int,int> P;
typedef long long ll;
int main(){
 
  int d,n,m;
  while(cin>>d,d){
    cin>>n>>m;
  int D[100001],M[100001];;
  D[0]=0,D[n]=d;
  for(int i=1;i<n;i++) cin>>D[i];
  for(int i=0;i<m;i++) cin>>M[i];
  sort(M,M+m);
  sort(D,D+n+1);
 
  ll ans=0;
  int pos=1;
  for(int i=0;i<m;i++){
    while(D[pos]<=M[i])pos++;
    ans+=min(abs(D[pos]-M[i]),abs(D[pos-1]-M[i]));
  }
  cout <<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1612
#include <iostream>
#include <cstdlib>
#include <algorithm>

int main()
{
	std::ios_base::sync_with_stdio(0);
	std::cin.tie(0);
	
	long long n, k; std::cin >> n >> k;
	// if (k == 1)
		// std::cout << 0;
	// else
		// std::cout << std::abs(n - (n + 1) / k * k);
	
	n = n % k;
	std::cout << std::min(n, std::abs(n - k));
}

Measured memory_bytes: 256
#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 FOR(i,k,n) for(int i=(k);i<(n);++i)
typedef long long ll;
const ll INF = 1LL<<60;
const ll MOD = 1000000007;

inline ll add(ll x, ll y) {return (x+y)%MOD;}
inline ll mul(ll x, ll y) {return (x*y)%MOD;}
inline ll sub(ll x, ll y) {
    ll res = x - y;
    if(res < 0) res += MOD;
    return res;
}

int main(){
    int N; cin >> N;
    vector<ll> A(N);
    REP(i,N) cin >> A[i];
    bool flag = true;
    if(A[0]) flag = false;
    REP(i,N-1) {
        if(A[i+1]>A[i]+1) {
            flag = false;
            break;
        }
    }
    if(!flag) cout << -1 << endl;
    else {
        A.push_back(0);
        ll ans = 0;
        REP(i,N) {
            if(A[i]>=A[i+1]) ans += A[i];
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 4864
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
int t[110000];
long long dp[110000];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<b;i++){
		int p;scanf("%d",&p);
		t[p]=1;
	}
	dp[0]=1;
	for(int i=1;i<=a;i++){
		if(i>1&&t[i-2]==0)dp[i]+=dp[i-2];
		if(t[i-1]==0)dp[i]+=dp[i-1];
		dp[i]%=mod;
	}
	printf("%lld\n",dp[a]);
}


Measured memory_bytes: 1280
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define break break
#define continue continue
#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define LLPair pair<ll, ll>
#define vint vector<int>
#define vll vector<ll>
typedef long long ll;

using namespace std;


int main(void){
	ll a, b, k; cin >> a >> b >> k;
	ll tmp = k-a;
	a = max(0LL, a-k);
	k = tmp;
	if(k > 0) b = max(0LL, b-k);
	cout << a << " " << b;
	return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<ll,ll>;
inline ll ri() {
	ll r; cin >> r; return r;
}


int main()
{
	ll n, k;
	cin >> n >> k;
	priority_queue<P, vector<P>, greater<P>> que;
	priority_queue<P> unused;
	vector<vector<ll>> a(n);
	vector<ll> cntj(n);
	ll numof = 0, sum = 0;

	for(ll i = 0; i < n; i++) {
		ll t, d; cin >> t >> d; t--;
		a[t].push_back(d);
	}
	for(ll i = 0; i < n; i++) {
		sort(a[i].begin(), a[i].end(), greater<ll>());	
		if(a[i].empty())continue;
		que.push({a[i].front(), i});
		cntj[i]++;
		numof++;
		sum += a[i].front();
		for(ll j = 1; j < (ll)a[i].size(); j++)unused.emplace(a[i][j], i);
	}


	while((ll)que.size() > k) {
		cntj[que.top().second]--;
		sum -= que.top().first;
		que.pop();
		numof--;
	}
	while((ll)que.size() < k) {
		que.push(unused.top());
		cntj[unused.top().second]++;
		sum += unused.top().first;
      	unused.pop();
	}

	ll ans = sum + numof * numof;
	while(unused.size()) {
		if(--cntj[que.top().second] == 0)numof--;
		sum -= que.top().first;
		que.pop();
		if(cntj[unused.top().second]++ == 0)numof++;
		sum += unused.top().first;
		que.push(unused.top());
		unused.pop();
		ans = max(sum + numof * numof, ans);
	}
	cout << ans << endl;

}


Measured memory_bytes: 8692
open Printf
open Scanf

let id x = x

let rec seq s t f =
  if s > t then []
  else
    let x = f s in
    x :: seq (s + 1) t f

let solve a b =
  let f x = x * 8 / 100 = a && x / 10 = b in
  try
    List.find f @@ seq 1 1009 id
  with
    Not_found -> -1

let () =
  scanf "%d %d " solve |> printf "%d\n"


Measured memory_bytes: 512
class Candy(object):
    def __init__(self, num, p, q, r):
        self.num = num
        self.p = p
        self.q = q
        self.r = r
    def can_eat(self, P, Q, R, C):
        if self.p > P or self.q > Q or self.r > R:
            return False
        elif 4*self.p + 9*self.q + 4*self.r > C:
            return False
        else:
            return True

while True:
    n = input()
    if n == 0:
        break
    Candylist = []
    for i in range(n):
        data = raw_input().split(" ")
        c = Candy(data[0], int(data[1]), int(data[2]), int(data[3]))
        Candylist.append(c)
    lim = raw_input().split(" ")
    eat_num = []
    for i in range(n):
        if Candylist[i].can_eat(int(lim[0]), int(lim[1]), int(lim[2]), int(lim[3])):
            eat_num.append(Candylist[i].num)
    if len(eat_num) == 0:
        print "NA"
    else:
        for i in eat_num:
            print i

Measured memory_bytes: 6936
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define sz size
#define se second
#define fe first
#define mper make_pair
#define all(x) x.begin(), x.end()
#define mal ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
#define saken string
#define erba continue
using namespace std;

ll a, b, c, d;
ll L;

int main(){

mal

cin >> a >> b >> c >> d;

cin >> L;

ll ans = 0;

while(L >= 2) {


    ans += min(min((8 * a), (4 * b)), min((2 * c), d));

    L -= 2;

}

while(L >= 1) {

    ans += min(min((4 * a), (2 * b)), c);
    L--;
}

cout << ans;

return 0;
}



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

int op_priority(char a) {
	if(a == '+' || a == '-')
		return 0;
	if(a == '*' || a == '/')
		return 1;
	return -1;
}

void clac_once(stack<long long> & num_stack, stack<char> & op_stack) {
	long long a, b;
	long long c;
	char op;

	b = num_stack.top();
	num_stack.pop();
	a = num_stack.top();
	num_stack.pop();
	op = op_stack.top();
	op_stack.pop();

	switch(op) {
		case '+' :
			c = a + b;
			break;
		case '-':
			c = a - b;
			break;
		case '*':
			c = a * b;
			break;
		case '/':
			c = a / b;
	}

	num_stack.push(c);
}

long long clac(string str) {
	stack<long long> num_stack;
	stack<char> op_stack;

	for(int i = 0; i < str.size();) {
		if(str[i] == '(') {
			int start = ++i;
			int count = 1;

			while(count) {
				if(str[i] == ')')
					count--;
				else if(str[i] == '(')
					count++;
				i++;
			}

			num_stack.push(clac(string(str.begin() + start, str.begin() + i)));
		}
		else if(str[i] == '+' || str[i] == '-' || str[i] == '*' || str[i] == '/' || str[i] == '=' || str[i] == ')') {
			while(!op_stack.empty() && op_priority(op_stack.top()) >= op_priority(str[i])) {
				clac_once(num_stack, op_stack);
			}
			op_stack.push(str[i]);
			i++;
		}
		else if('0' <= str[i] && str[i] <= '9') {
			long long tmp = 0;
			while('0' <= str[i] && str[i] <= '9') {
				tmp *= 10;
				tmp += str[i] - '0';
				i++;
			}
			num_stack.push(tmp);
		}
	}

	if(op_stack.size() != 1)
		exit(1);

	return num_stack.top();
}

int main() {
	int n;

	cin >> n;
	for(int i = 0; i < n; i++) {
		string str;

		cin >> str;
		cout << clac(str) << endl;
	}

	return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
typedef long long ll;
#define  rep(i,a,b)for(long long i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
const ll INF=1000000000000LL;
const ll r197=1000000007;
typedef pair<ll,ll>P;
typedef pair<P,P>Pa;
bool Inframe(int a,int b,int c,int d,int h,int w){
	if(a+b>=0&&a+b<h&&c+d>=0&&c+d<w)return true;
	return false;
}
ll C[100005]={};

vector<int> v[100005];

bool ca[1004],cb[1005];
bool a[1000005]={};
int n;
int main() {
	cin>>n;
	int ans=1;
	while(1){
		if(a[n])break;
		a[n]=true;
		ans++;
		if(n%2==0)n/=2;
		else n=3*n+1;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3328
n=int(input())
#n,k=map(int,input().split())
al=[]
bl=[]
ans=0
for i in range(n):
    a,b = [int(i) for i in input().split()]
    al.append(a)
    bl.append(b)
for i in range(n):
    a=al.pop()
    b=bl.pop()
    ans+=(b-(a+ans)%b)%b
print(ans)

Measured memory_bytes: 60760
#include <iostream>
#include <algorithm>
#include <set>

using namespace std;

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

	set<int> colors;
	int n_change = 0;
	for (int i = 0; i < n; i++) {
		cin >> a;

		if (a >= 3200) {
			n_change++;
		} else {
			colors.insert(a / 400);
		}

	}


	int mini = colors.size();
	if (mini == 0) {
		mini += min(1, n_change);
	}
	int maxi = colors.size() + n_change;

	cout << mini << endl;
	cout << maxi << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>

using ldouble = long double;

struct Plant {
    ldouble vw, pf, vf, th;
};

bool solve() {
    int n;
    std::cin >> n;
    if (n == 0) return false;

    ldouble pw;
    std::cin >> pw;
    std::vector<Plant> ps(n);
    for (auto& p : ps) std::cin >> p.vw >> p.pf >> p.vf >> p.th;

    auto calc = [&](ldouble w) {
        ldouble ret = w * pw;
        for (auto p : ps) {
            ldouble need = p.th - p.vw * w;
            if (need > 0) ret += p.pf * need / p.vf;
        }
        return ret;
    };

    ldouble lw = 0, rw = 10000;

    for (int q = 0; q < 100; ++q) {
        ldouble llw = (lw * 2 + rw) / 3,
                rrw = (lw + rw * 2) / 3;

        if (calc(llw) < calc(rrw)) {
            rw = rrw;
        } else {
            lw = llw;
        }
    }

    std::cout << calc(lw) << "\n";
    return true;
}

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

    while (solve()) {};

    return 0;
}



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

int main(){
    int N;
    cin >>N;
    vector<int> vec(N);
    for (int i = 0; i < N; i++) {
        cin >> vec[i];
    }
    
    long long sum = 0;
    for(int i =1;i<N;i++){
        if(vec[i-1]>vec[i]){
            sum+=vec[i-1]-vec[i];
            vec[i] = vec [i-1];
        }
    }
    cout << sum <<endl;
}

Measured memory_bytes: 4028
n = int(input())
alis = list(map(int, input().split()))
blis = list(map(int, input().split()))

s = 0
num = 0
for i in range(n):
    if blis[i] - alis[i] > 0:
        s += blis[i] - alis[i]
        num += 1

if num == 0:
    print(0)
    exit()

nlis = []
for i in range(n):
    if alis[i]-blis[i] >= 0:
        nlis.append(alis[i]-blis[i])

nlis.sort(reverse=True)
tmp = 0
cnt = 0
for i in nlis:
    if tmp >= s:
        break
    tmp += i
    cnt += 1

if tmp < s:
    print(-1)
else:
    print(cnt+num)


Measured memory_bytes: 24396
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
#include<queue>
#include<map>
#include<cmath>
#include<set>
#include<stack>
#define ll long long
#define pb push_back
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)>(y)?(y):(x))
#define cls(name,x) memset(name,x,sizeof(name))//0或-1
#define fs first
#define sc second
#define mp make_pair
#define L(x) (1<<x)
#define next Next
using namespace std;
const int inf=1e9+10;
const ll llinf=1e16+10;
const int maxn=1e5+10;
const int maxm=1e3+10;
const int mod=1e9+7;
int n;
int main()
{
    //freopen("in.txt","r",stdin);
    while(~scanf("%d",&n))
    {
        int c4=0,c2=0,c1=0;
        for(int i=0;i<n;i++)
        {
            int t;
            scanf("%d",&t);
            if(t%4==0) c4++;
            else if(t%2==0) c2++;
            else c1++;
        }
        if(c4<c1-1)
        {
            printf("No\n");
            continue;
        }
        if(c2>=1 && c4==c1-1)
        {
            printf("No\n");
            continue;
        }
        printf("Yes\n");
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp> // Common file
    #include <ext/pb_ds/tree_policy.hpp>
    #include <functional> // for less

    using namespace std;
    #define md 1000000007
    #define itn int
    #define pb push_back
    #define mp make_pair
    // #define ull unsigned long long int
    #define ll long long 
    // #define int ll
    #define ppi pair<int, int>
    #define ppl pair<ll, ll>
    #define vi vector<int>
    #define all(x) x.begin(), x.end()
    #define ff first
    #define lb lower_bound
    #define ub upper_bound
    #define ss second
    #define inf 1e9
    #define enld '\n'
    #define cuot cout
    #define trace1(x) cerr << #x << ": " << x << endl
    #define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
    #define trace3(x, y, z)                                                        \
      cerr << #x << ":" << x << " | " << #y << ": " << y << " | " << #z << ": "    \
           << z << endl
    #define trace4(a, b, c, d)                                                     \
      cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": "   \
           << c << " | " << #d << ": " << d << endl
    #define trace5(a, b, c, d, e)                                                  \
      cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": "   \
           << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl
    #define trace6(a, b, c, d, e, f)                                               \
      cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": "   \
           << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | "   \
           << #f << ": " << f << endl
    #define trace(v)                                                               \
      for (auto it = v.begin(); it != v.end(); it++)                               \
        cerr << *it << " ";                                                        \
      cerr << endl;
    #define linf 1e18
    #define reset(x) memset(x, 0, sizeof(x))
    #define rep(i, a, b) for (int i = a; i < b; i++)

    using namespace __gnu_pbds;

    typedef tree<int, null_type, less<int>, rb_tree_tag,
                 tree_order_statistics_node_update>
        oset;

    void fastio() {
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
    }
    
   
    void solve()
    {  
        int a,b;cin>>a>>b;
        if(a<b)swap(a,b);
        if(a==b)
        {
            cout<<(a+a)<<endl;return;
        }
        cout<<(a+a-1)<<endl;
    }


    signed main() {
      fastio();
      int t;
      t = 1;
      // cin >> t;
      for (int i = 1; i <= t; i++) {
        // cout << "Case #" << i << ": ";
        solve();
      }
      return 0;
    }


Measured memory_bytes: 256