akhauriyash/Code-Regression huggingface dataset:
class Heap:
    def __init__(self, L):
        self.H = len(L)
        self.heap = L
        self.heap.insert(0, 0)

    def parent(self, i):
        return i // 2

    def left(self, i):
        return 2 * i

    def right(self, i):
        return 2 * i + 1

    def maxHeapify(self, i):
        l = self.left(i)
        r = self.right(i)
        if l <= H and self.heap[l] > self.heap[i]:
            largest = l
        else:
            largest = i

        if r <= H and self.heap[r] > self.heap[largest]:
            largest = r

        if largest != i:
            self.heap[i], self.heap[largest] = self.heap[largest], self.heap[i]
            self.maxHeapify(largest)

    def buildMaxHeap(self):
        for i in range(self.H // 2, 0, -1):
            self.maxHeapify(i)


H = int(input())
L = list(map(int, input().split()))
heap = Heap(L)
heap.buildMaxHeap()
heap.heap.pop(0)
print(' ' + ' '.join([str(a) for a in heap.heap]))

Measured memory_bytes: 65628
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]


N = int(input())
min_num = INF
SUM = 0

for i in range(N):
	s = int(input())
	SUM += s
	if s%10 != 0:
		min_num = min(s,min_num)

if SUM%10 != 0:
	print(SUM)
else:
	if min_num == INF:
		print(0)
	else:
		print(SUM-min_num)

Measured memory_bytes: 3824
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

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; }
const long long LINF = 1e18;

int main()
{
  int N, W; cin >> N >> W;
  vector<int> w(N), v(N);

  for (int i = 0; i < N; ++i) {
    cin >> w[i] >> v[i];
  }

  vector<vector<ll>> dp(N+1, vector<ll>(W+1));
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j <= W; ++j) {
      if (j + w[i] <= W) {
        chmax(dp[i+1][j+w[i]], dp[i][j] + v[i]);
      }
      chmax(dp[i+1][j], dp[i][j]);
    }
  }

  cout << dp[N][W] << endl;
}

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

using namespace std;
int a,b,k,ok;
int main()
{
    ios::sync_with_stdio(false);
    cin>>k>>a>>b;
    for(int i=a;i<=b;++i) if(i%k==0) ok=1;
    if(ok==1) cout<<"OK";
    else cout<<"NG";
    return 0;
}


Measured memory_bytes: 3648
#-*-coding:utf-8-*-

def main():
    n, x = map(int, input().split())
    a_list = list(map(int, input().split()))
    a_list_cp = a_list[:]
    ans = 0

    for i in range(1, n):
        temp = a_list[i-1] + a_list[i]
        if temp > x:
            if x - a_list[i-1] >= 0:
                a_list[i] = x - a_list[i-1]
            else:
                a_list[i] = 0
                a_list[i-1] = a_list[i-1] + x - a_list[i-1]
    for a, b in zip(a_list, a_list_cp):
        ans += b - a
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 14060
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;

void main(){
	auto ip1 = readln.chomp;
	auto ip2 = readln.chomp;
	auto ip3 = readln.chomp;
	("" ~ ip1[0] ~ ip2[1] ~ ip3[2]).writeln;
}

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

int main() {
  int H, W; 
  int mass[110][110];
  cin >> H >> W;
  
  int N;
  cin >> N;
  
  int a[10100];
  for (int i = 1; i <= N; i++) {
    cin >> a[i];
  }
  
  
  vector<pair<int, int>> perm(10100);
  int count = 1;
  for (int i = 0 ; i < H; i++) {
    int x;
    pair<int, int> p;
    if (count % 2) {
      for (int j = 0; j < W; j++) {
        p = make_pair(i, j);
        perm[x] = p;
        x++;
      }
    } else {
      for (int j = W-1; j >= 0; j--) {
        p = make_pair(i, j);
        perm[x] = p;
        x++;  
      }
    }
    count++;
  }
  
  int x = 0;
  for (int i = 1; i <= N; i++) {
    int count = 0;
    
    while (count < a[i]) {
      int h = perm[x].first, w = perm[x].second;
      mass[h][w] = i;
      x++;
      count++;
    }
    
  } 
  // 結果の出力
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cout << mass[i][j] << " ";
    }
    cout << endl; 
  }
}

Measured memory_bytes: 3736
#include<iostream>
#include<vector>
#include<map>
#include<cmath>
using namespace std;

int main() {
    int H, W, D;
    cin>>H>>W>>D;
    map<int, pair<int, int> > A;
    int tmp;
    for(int i=0;i<H;++i){
        for(int j=0;j<W;++j){
            cin>>tmp;
            tmp--;
            A[tmp] = make_pair(i, j);
        }
    }
    int sum[D][H*W/D+1];
    for(int i=0;i<D;++i){
        for(int j=0;j<H*W/D+1;++j){
            if(j==0)sum[i][j]=0;
            else{
                if(i+j*D >= H*W) sum[i][j] = 0;
                else sum[i][j] = sum[i][j-1] + abs(A[i+j*D].first - A[i+(j-1)*D].first) + abs(A[i+j*D].second - A[i+(j-1)*D].second);
            }
        }
    }
    /**
    for(int i=0;i<D;++i){
        for(int j=0;j<H*W/D+1;++j){
            cout<<sum[i][j]<<" ";
        }
        cout<<endl;
    }
    cout<<endl;
    **/
    int Q;
    cin>>Q;
    int L, R;
    for(int i=0;i<Q;++i){
        cin>>L>>R;
        L--;
        R--;
        cout<<sum[R%D][R/D] - sum[L%D][L/D]<<endl;
    }
}


Measured memory_bytes: 7040
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647
// MAX O(n) 10^18

int main() {
    int s;
    cin >> s;
    set<int> a;

    int n = s;
    int ans;
    for (int i = 1;; i++) {

        if (a.count(n) == 0) {
             a.insert(n);
        } else {
            ans = i;
            break;
        }

        // making next value
        if(n % 2 == 0) { // even
            n /= 2;
        } else { // odd
            n = 3 * n + 1;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define l first
#define r second
using namespace std;
typedef pair<int, int> ii;

ii p[100005];

int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; ++i) cin >> p[i].l >> p[i].r;
	int l = 0, r = 1e9;
	int x, y;
	for (int i = 0; i < N; ++i) {
		if (p[i].l > l) {
			l = p[i].l;
			x = i;
		}
		if (p[i].r < r) {
			r = p[i].r;
			y = i;
		}
	}

	int ans = 0;
	for (int i = 0; i < N; ++i) {
		ans = max(max(p[i].r - p[i].l + 1, 0), ans);
	}
	ans += max(r - l + 1, 0);
	if (x == y) {		
		cout << ans << '\n';
		return 0;
	}

	vector<ii> c;
	for (int i = 0; i < N; ++i) {
		c.emplace_back(max(p[i].r - l + 1, 0), max(r - p[i].l + 1, 0));
	}
	sort(c.begin(), c.end());
	int s = 1e9;
	for (int i = 0; i < N - 1; ++i) {
		s = min(s, c[i].r);
		ans = max(s + c[i + 1].l, ans);
	}
	cout << ans << '\n';
}

Measured memory_bytes: 2168
N,K=map(int,input().split())
R,S,P=map(int,input().split())
T=input()
A=[]
for i in range(N):
  if T[i]=='r':
    A.append('p')
  elif T[i]=='p':
    A.append('s')
  else:
    A.append('r')
for i in range(K,N):
  if A[i]==A[i-K]:
    A[i]='x'
score=0
for i in A:
  if i=='r':
    score+=R
  elif i=='s':
    score+=S
  elif i=='p':
    score+=P
print(score)

Measured memory_bytes: 4212
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, n) for (int i = 1; i <= (int)(n); i++)
#define fore(i, a) for (auto &i:a)

#define ll long long
#define pll vector<pair<ll, ll>>
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
using namespace std;

const long double PI = acos(-1);

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}

bool isInteger(double x){return floor(x) == x;}

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

    int A,B;cin >> A >> B;

    cout << max(max((A+B),(A-B)),(A*B)) << endl;
}

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

int main() {
    int a;
    cin >> a;
    int ans = a;
    ans+=a*a;
    ans+=a*a*a;
    cout << ans << endl;
    return 0;
}

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

int main() {
	int n, k;
	cin >> n >> k;
	int h[n];
	int ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
		if (k <= h[i]) {
			ans++;
		}
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int aa = sc.nextInt();
		int bb = sc.nextInt();
		
		int tmp;
		int xx;
		
		bb--;
		
		tmp = (int)bb/(aa-1);
		xx = bb%(aa-1);
		
		if (xx == 0){
			System.out.print(tmp);
		}else{
			System.out.print(tmp+1);
		}
	}
}

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

#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,b,e) for(int i = (b); i <= (e); i++)

#define pr(x) do{cerr << (#x) << " = " << (x) << endl;}while(0)
#define pri(x,i) do{cerr << (#x) << "[" << i << "] = " << (x[i]) << endl;}while(0)

namespace std {
	template<class S, class T> pair<S, T> operator + (const pair<S, T> &a, const pair<S, T> &b) {return mp<S, T>(a.first + b.first, a.second + b.second);}
	template<class S, class T> pair<S, T> operator - (const pair<S, T> &a, const pair<S, T> &b) {return mp<S, T>(a.first - b.first, a.second - b.second);}
	template<class S, class T> pair<S, T>& operator += (pair<S, T> &a, const pair<S, T> &other) {return a = a + other;}
	template<class S, class T> pair<S, T>& operator -= (pair<S, T> &a, const pair<S, T> &other) {return a = a - other;}
	template<class S, class T> ostream& operator << (ostream& ost, pair<S, T> p) {ost << "(" << p.first << ", " << p.second << ")";return ost;}
	template<class T> ostream& print_iterable_container(ostream& ost, T& container) {
		for (auto&& iter = begin(container); iter != end(container); ++iter) ost << (iter == begin(container) ? " [ " : ", ") << (*iter);
		return ost << " ]";
	}
#	define APPLY_PRINT_ITERABLE_CONTAINER(container_type)\
	template<class T> ostream& operator << (ostream& ost, container_type<T>& container) {\
		return print_iterable_container(ost, container);\
	}
	APPLY_PRINT_ITERABLE_CONTAINER(vector);
	APPLY_PRINT_ITERABLE_CONTAINER(list);
	APPLY_PRINT_ITERABLE_CONTAINER(deque);
}

template<class T> inline bool CHMAX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool CHMIN(T &l,const T &r){return l>r?l=r,1:0;}

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vpii = vector<pii>;
using vpll = vector<pll>;

using ld = long double;

template<class T> using VV = vector<vector<T> >;
template<class T> using maxPQ = priority_queue<T>;
template<class T> using minPQ = priority_queue<T, vector<T>, greater<T> >;
template<class T, class U> using uomap = unordered_map<T, U>;
template<class T> using uoset = unordered_set<T>;

const ll INF = 1001001001;
const ll INFll = (ll)INF * INF;
const ll MOD = 1000000007;
const ll MOD_FFT = 998244353;
const ld EPS = 1e-15;

//function<void(int,int)> tensi_no_3p=[&](int v,int d){
//};

int main() {
	ios_base::sync_with_stdio(false);
	int N; cin >> N;
	vi A(N), B(N);
	ll suma = 0, sumb = 0;
	rep(i, N) cin >> A[i], suma += A[i];
	rep(i, N) cin >> B[i], sumb += B[i];
	if (suma < sumb) {
		cout << -1 << endl;
		return 0;
	}

	ll sumdiff = suma - sumb;
	int ans = 0;
	vi D;
	rep(i, N) if (A[i] >= B[i]) D.pb(A[i] - B[i]);
	sort(begin(D), end(D));
	rep(i, D.size()) {
		if (D[i] <= sumdiff) {
			sumdiff -= D[i];
			ans++;
		}
		else {
			break;
		}
	}
	cout << N - ans << endl;
	return 0;
}


Measured memory_bytes: 1660
import collections
N,K,Q=map(int,input().split())
P=[K]*N
M=[Q]*N
A=[int(input()) for _ in range(Q)]
for a in A:
  M[a-1]-=1
C=[p-m for (p,m) in zip(P,M)]
for c in C:
  if c>0:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 15556
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n;
    cin>>n;
    vector<int> s;
    int first=INT_MIN,sec=INT_MIN;  
    for(int i=0;i<n;i++)
    {  
         int x;
         cin>>x;
         s.push_back(x);
         if(first<x)
         {
           first=x;
         }
      	else if(sec<x)
      	{
         sec=x;
      	}
    }
    
 
     for(int i=0;i<n;i++)
     {
       if(s[i]!=first)
       {
          cout<<first<<endl;
        }
       else
       {
          cout<<sec<<endl;
       }
     }
	return 0;
}

Measured memory_bytes: 2548
N = int(input())

def standard_string(N, st):
    if len(st) == N:
        print(st)
    elif st == "":
        standard_string(N, "a")
    else:
        for i in range(97, ord(max(st))+ 2):
            st += chr(i)
            standard_string(N, st)
            st = st[:-1]
standard_string(N, "")

Measured memory_bytes: 4404
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 0x3F3F3F3F;
const int maxn = 2e6 + 555;
const int MOD = 1e9 + 7;
int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(10);
    cout << fixed;
    int n, m;
    cin >> n >> m;
    static ll inv[maxn + 555], invp[maxn + 555], p[maxn + 555];
    inv[1] = 1;
    for (int i = 2; i <= maxn; i++)
        inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;
    p[0] = 1;
    for (int i = 1; i <= maxn; i++)
        p[i] = p[i - 1] * i % MOD;
    invp[0] = 1;
    for (int i = 1; i <= maxn; i++)
        invp[i] = invp[i - 1] * inv[i] % MOD;
    auto C = [&](int a, int b) -> ll {
        if (a < b)
            return 0;
        else
            return p[a] * invp[b] % MOD * invp[a - b] % MOD;
    };
    ll all = C(m, n) * p[n] % MOD;
    all = all * all % MOD;
    ll jb = 0;
    for (int i = 1; i <= n; i++) {
        ll single = C(m - i, n - i) * p[n - i] % MOD;
        single = single * single % MOD;
        ll res = C(n, i) * C(m, i) % MOD * p[i] % MOD * single % MOD;
        if (i & 1) {
            jb += res;
            jb %= MOD;
        } else {
            jb -= res;
            jb %= MOD;
        }
    }
    all -= jb;
    all %= MOD;
    all += MOD;
    all %= MOD;
    cout << all << endl;
    return 0;
}

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

int main() {
  string s;
  cin >> s;
  int price=700;
  rep(i,3){
    if(s[i]=='o'){
      price += 100;
    }
  }
  cout << price << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    static int S;
    static int m;
    static int h;
    static int s;

    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      S = sc.nextInt();    
      h = S / 3600;
      m = S % 3600 / 60;
      s = S % 3600 % 60;
      System.out.println(h + ":" + m + ":" + s);
    }
}


Measured memory_bytes: 26328
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t n;
  cin>>n;
  int64_t m=n/2;
  int64_t f=0;
  while(m>0){
    f+=m/5;
    m/=5;
  }
  cout<<(n%2==0?f:0)<<endl;
}

Measured memory_bytes: 256
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))

a = int(input())
b = int(input())

if (a == 1 and b == 2):
    print(3)
elif(a == 1 and b == 3):
    print(2)
elif (a == 2 and b == 1):
    print(3)
elif (a == 2 and b == 3):
    print(1)
elif (a == 3 and b == 1):
    print(2)
elif (a == 3 and b == 2):
    print(1)


Measured memory_bytes: 9020
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

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

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  ll n,a,b; cin >> n >> a >> b;
  vl num(3);
  
  rep(i,n){
    ll x; cin >> x;
    if(x <= a) num[0]++;
    else if(b+1 <= x) num[2]++;
    else num[1]++;
  }
  
  cout << min({num[0],num[1],num[2]}) << endl;
  
  
}

Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include<vector>
#include<math.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
struct pnt{
  double x,y;
  bool operator>(const pnt &key)const{
      if(this->x==key.x)return this->y>key.y;
      return this->x>key.x;
  }
  pnt operator+(pnt key){
      pnt res;res.x=x+key.x,res.y=y+key.y;
      return res;
  } 
  pnt operator-(pnt key){
      pnt res;res.x=x-key.x,res.y=y-key.y;
      return res;
  }  
  pnt operator*(double key){
      pnt res;res.x=x*key,res.y=y*key;
      return res;
  }
  pnt operator/(double key){
      pnt res;res.x=x/key,res.y=y/key;
      return res;
  }
  double abs(){
      return sqrt(x*x+y*y);
  }
};
double dot(pnt a,pnt b){
    return a.x*b.x+a.y*b.y;
}
double dis(pnt a,pnt b){
    return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
pnt shaei(pnt a,pnt b,pnt c){
    pnt base=b-a;
    return a+base*dot(c-a,base)/base.abs()/base.abs();
}
pair<pnt,pnt> koten(pnt a,pnt b,pnt c,double r){
    pnt sha=shaei(a,b,c);
    double di=dis(c,sha);
    double len=sqrt(r*r-di*di);
    pnt e=(a-b)/dis(a,b);
    return make_pair(sha+e*len,sha+e*len*-1);
}
void inn(pnt & a){
    cin>>a.x>>a.y;
}
int main(){
    pnt cir;double rad;
    inn(cir); cin>>rad;
    ll q;cin>>q;
    while(q--){
	pnt a,b;inn(a);inn(b);
	pair<pnt,pnt> res=koten(a,b,cir,rad);
	if(res.first>res.second)swap(res.first,res.second);
	cout<<fixed<<setprecision(9)<<res.first.x<<" ";
	cout<<fixed<<setprecision(9)<<res.first.y<<" ";
	cout<<fixed<<setprecision(9)<<res.second.x<<" ";
	cout<<fixed<<setprecision(9)<<res.second.y<<endl;
    }
    return 0;
}



Measured memory_bytes: 3268
#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Bytes, Chars, Isize1, Usize1},
};

fn main() {
    input! {
        k:usize
    }
    let mut buf = 7_usize % k;
    for i in 0..99999999 {
        if buf % k == 0 {
            println!("{}", i + 1);
            return;
        }
        buf *= 10;
        buf += 7;
        buf %= k;
    }
    println!("-1");
}

Measured memory_bytes: 2108
#include <iostream>
#include <string>
#include <deque>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	string s;
	cin>>s;
	deque<char> q;
	for (auto &c : s) {
		q.push_back(c);
	}
	int t;
	cin>>t;
	bool f = true;
	for (int i = 0; i < t; i++) {
		int T;
		cin>>T;
		if (T == 1) {
			f = !f;
		} else {
			int F;
			char C;
			cin>>F>>C;
			if ((f && F == 1) || (!f && F == 2)) {
				q.push_front(C);
			} else {
				q.push_back(C);
			}
		}
	}
	if (f) cout<<string(q.begin(), q.end())<<endl;
	else cout<<string(q.rbegin(), q.rend())<<endl;
	return 0;
}

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

int64_t fact(int64_t n){
  int64_t s = 1;
  for (int i = 1; i < n+1; i++){
    s = (s * i) % 1000000007;
  }
  return s;
}

int main(){
  int64_t N, M, S;
  cin >> N >> M;
  
  if (abs(N - M) == 0){
    cout << fact(N) * fact(M) * 2 % 1000000007 << endl;
  }
  else if (abs(N - M) == 1){
    cout << fact(N) * fact(M) % 1000000007 << endl;
  }
  else{
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
//abc104_a.cpp
//Wed Aug 22 21:39:52 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	if (r<1200){
		cout << "ABC" << endl;
	}else if (r<2800){
		cout << "ARC" << endl;
	}else {
		cout << "AGC" << endl;
	}
}

Measured memory_bytes: 256
import sys
import math
import itertools
from heapq import heapify, heappop, heappush
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect, bisect_left, bisect_right
from collections import defaultdict, deque


# d = defaultdict(lambda: 0)
# setrecursionlimit(10**7)
# inf = float("inf")


##### stdin ####
def LM(t, r): return list(map(t, r))
def R(): return stdin.readline()
def RS(): return R().split()
def I(): return int(R())
def F(): return float(R())
def LI(): return LM(int,RS())
def LF(): return LM(float,RS())
def ONE_SL(): return list(input())
def ONE_IL(): return LM(int, ONE_SL())
def ALL_IL(): return LM(int,stdin)

##### tools #####
def ap(f): return f.append
def pll(li): print('\n'.join(LM(str,li)))
def pljoin(li, s): print(s.join(li))


##### Library ####


##### main #####
def main():
    N = I()
    mid_N = math.ceil(N / 2) 

    ans = float('inf')
    for a in range(1,mid_N+1):
        b = N-a

        sum_digit_a = sum(map(int,list(str(a))))
        sum_digit_b = sum(map(int,list(str(b))))

        tmp = sum_digit_a + sum_digit_b
        ans = min(ans, tmp)

    print(ans)

   
if __name__ == '__main__':
    main()



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

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

if len(set(A)) != 1:
    cost = 2**20
    for i in range(-100, 101):
        tc = 0
        for a in A:
            tc += (a-i)**2
        if cost > tc:
            cost = tc
else:
    cost = 0

print(cost)

Measured memory_bytes: 9044
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
void Main(){
    int n;
    cin >> n;
    vector<ll> a(100010,0);
    For(i,0,n){
        int t;
        cin>>t;
        a[t]++;
    }
    map<ll,ll> mp;
    For(i,0,100010){
        if(a[i]>0){
            mp[i]=a[i];
        }
    }
    for(auto p:mp){
        ans += p.first * p.second;
    }    
    int q;
    cin >> q;
    For(_,0,q){
        int b,c;
        cin >> b >> c;
        ans += (c-b)*mp[b];
        mp[c]+=mp[b];
        mp[b]=0;
        cout<<ans<<endl;
    }
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 9956
import java.io.IOException;
import java.util.Scanner;

public class Main {
    static class Solution {
        public void find(int perimeter, int[] arr) {

            arr[arr.length-1] = perimeter;

            int res = Integer.MAX_VALUE;
            int antiClock = (arr[0] + perimeter)%perimeter;

            res = Math.min(res, perimeter-(perimeter - arr[arr.length-2])- antiClock);
            res = Math.min(res, perimeter - (arr[1]-arr[0]));

            for(int i=1; i<arr.length-1; i++) {
                res = Math.min(res, perimeter - (arr[i+1]-arr[i])); //clock
                res = Math.min(res, perimeter - (arr[i]-arr[i-1])); //anti
            }
            System.out.println(res);

        }

    }

    public static void main(String[] args) throws IOException {
        Solution sol = new Solution();
        Scanner sc = new Scanner(System.in);
        int perimeter = sc.nextInt();
        int n = sc.nextInt();
        int[] arr = new int[n+1];
        for(int i=0; i<n; i++) {
            arr[i] = sc.nextInt();
        }
        sol.find(perimeter, arr);
    }
}


Measured memory_bytes: 76544
#include <iostream>
#include <math.h>
using ll = long long;
using namespace std;

int main(){
    ll n, m=0, ans;

    cin >> n;

    for(ll i = sqrt(n); i>0; i--){
        if(n%i==0){
            m = i;
            break;
        }
    }

    ans = (m-1) + (n/m-1);
    cout << ans << endl;

    return 0;
}

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

using namespace std;

int main () {

    string str;
    int result;
    cin >> str;

    if (str[0] == 'R') {
        result = 1;
    } else {
        result = 0;
    }

    if (str[1] == 'R') {
        if (str[2] == 'R') {
            result += 2;
        } else {
            result += 1;
        }
    }

    if (result == 0 && str[2] == 'R') {
        result = 1;
    }
    
    cout << result << endl;

    return 0;
}


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



Measured memory_bytes: 2056
local t
do
  local _accum_0 = { }
  local _len_0 = 1
  local _list_0 = {
    "dream",
    "dreamer",
    "erase",
    "eraser"
  }
  for _index_0 = 1, #_list_0 do
    local e = _list_0[_index_0]
    _accum_0[_len_0] = e:reverse()
    _len_0 = _len_0 + 1
  end
  t = _accum_0
end
local s = io.read("*l"):reverse()
local c = 1
local l = s:len()
while c <= l do
  local k = nil
  for _index_0 = 1, #t do
    local e = t[_index_0]
    if s:sub(c, c + e:len() - 1) == e then
      k = e
      break
    end
  end
  if k == nil then
    print("NO")
    return 
  end
  c = c + k:len()
end
return print("YES")


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF INT_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N;
  cin>>N;
  vector<int>B(N-1);
  for(int i=0;i<N-1;i++)cin>>B[i];
  vector<int>A(N,INF);
  for(int i=0;i<N-1;i++){
    A[i]=min(A[i],B[i]);
    A[i+1]=min(A[i+1],B[i]);
  }
  int ans=0;
  for(auto it:A)ans+=it;
  cout<<ans<<endl;
  return 0;
}


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

#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define MAX(x, y) ((x) > (y) ? (x) : (y))
#define ABS(x, y) ((x) > (y) ? ((x) - (y)) : ((y) - (x)))

#define DIVUP(x, y) (((x) + ((y) - 1)) / (y))
#define DIVOFF(x, y) (((x) + ((y) / 2)) / (y))
#define REMAINDER(x, y) ((x) % (y))

int main() {
  int A, B, C; scanf("%d%d%d", &A, &B, &C);
  printf("%d\n", B > C ? C * 2 + B - C : B * 2 + MIN(A + 1, C - B));
  return 0;
}


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

public class Hello
{
    private const int MOD_N = 1000000000 + 7;

    public static void Main()
    {
        var list = Console.ReadLine().Split(' ');
        var n = int.Parse(list[0]);
        var k = int.Parse(list[1]);

        Console.WriteLine(k == 1 ? 0 : n - k);
    }

    private static int Comb(int m, int n)
    {
        var t = m - n;
        if (n > t)
            n = t;

        long numerator = 1;
        for (int i = 0; i < n; ++i)
        {
            numerator *= m - i;
            numerator %= MOD_N;
        }
        long denominator = 1;
        for (; n != 0; --n)
        {
            denominator *= n;
            denominator %= MOD_N;
        }

        var inv_denominator = ModInv((int)denominator, MOD_N);
        var ret = (int)(numerator * inv_denominator % MOD_N);

        return ret >= 0 ? ret : ret + MOD_N;
    }

    private static int ModInv(int a, int m)
    {
        int b = m, x = 1, y = 0;
        while (b != 0)
        {
            var t = a / b;
            a -= t * b;
            Swap(ref a, ref b);
            x -= t * y;
            Swap(ref x, ref y);
        }
        x %= m;
        return x >= 0 ? x : x + m;
    }

    private static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define rev(v) reverse(v.begin(), v.end())
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
#define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin());
#define dab(v) for(auto i:v)cout<<i<<' '; cout << endl;
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
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; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

ll beki(int a, int n){
    if(n == 0) return 1;
    ll ans = beki(a, n / 2);
    ans = ans * ans;
    if(n % 2 == 1) ans = ans * a;
    return ans;
}

string S,T,U;
int a,b,c;
vl A,B;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);
    
    int d; cin>>a>>b>>c>>d;
    while(true){
        c -= b;
        if(c <= 0) {
            cout << "Yes" << endl;
            return 0;
        }
        a -= d;
        if(a<=0) {
            cout << "No" << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll n,a[100100],dp[100100],k;
ll rec(ll i)
{
    if(i<0)
        return 1e9;
    if(i==0)
        return 0;
    if(dp[i]!=-1)
        return dp[i];
    ll mini=1e9;
    for(ll j=1 ; j<=k ; j++)
        mini=min(mini,rec(i-j)+abs(a[i-j]-a[i]));
    return dp[i]=mini;
}
int main()
{
    cin>>n>>k;
    for(ll i= 0 ; i<n ; i++)
        cin>>a[i];
    memset(dp,-1,sizeof dp);
    cout<<rec(n-1)<<endl;
    return 0;
}


Measured memory_bytes: 6528
#include <cstdio>
#define N 105

int n, k;
int a[N];

int main() {
    scanf("%d%d", &n, &k);
    for (int i = 1, x; i <= k; ++i) {
        scanf("%d", &x);
        for (int j = 1, t; j <= x; ++j) {
            scanf("%d", &t);
            a[t] = 1;
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; ++i) ans += a[i];
    printf("%d\n", n - ans);
    return 0;
}


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

int main() {
	string s;
	while(cin >> s, s != "0") {
		int a, b;
		a = b = 0;
		for(int i = 1; i < s.size(); i++) {
			if(s[i] == 'A')
				a++;
			else
				b++;
		}
		if(a > b)
			a++;
		else
			b++;
		cout << a << " " << b << endl;
	}
}

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

int main() {
    long long a, b, c;
    cin >> a >> b >> c;
    if (c - a - b < 0) {
        cout << "No" << endl;
    } else {
        if (4 * a * b < (c - a - b) * (c - a - b)) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <bitset>
#include <cmath>
#include <map>
#include <algorithm>
#include <queue>
#include <chrono>
#include <array>
#include <random>
#include <fstream>
#include <list>
typedef int long long ll;
using namespace std;
int a[100000];
int main(){

    int n;cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    map<int,int> mp;
    for(int i=0;i<n;i++){
        mp[a[i]]++;
        
    }
    int ans=0;
    for(auto p:mp){
        int x=p.first;
        int n=p.second;
        if(n<x){
            ans+=n;
        }else{
            ans+=n-x;
        }
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
const ll MOD = 1000000007;

int main() {
	int L, R, d, c = 0;
	cin >> L >> R >> d;
	for (int i = L;i <= R;i++) {
		if (i % d == 0)c++;
	}
	cout << c << endl;
}

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

typedef long long ll;
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)


int main()
{
    optimize();

    int n;
    cin>> n;

    int c[n], v[n], r=0;

    for(int i=0; i<n; i++)
        cin>> c[i];


     for(int i=0; i<n; i++)
    {
        cin>> v[i];
        if(c[i]> v[i])
            r+=(c[i]- v[i]);

    }

    cout<< r;
    nl;

    return 0;
}



Measured memory_bytes: 3588
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
inline bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
inline bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

void Pr(bool f){
  cout << (f ? "Yes" : "No") << endl;
  exit(0);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll a, b, c;
  cin >> a >> b >> c;
  Pr((a == b || b == c || c == a) && !(a == b && b == c));
}


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

using namespace std;
using namespace atcoder;

using ll = long long;

int main() {
    int n, m;

    cin >> n >> m;
    vector<ll> a(n), b(m);

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

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

    vector<ll> ans = convolution(a, b);

    for (auto x : ans) {
        cout << x << " ";
    }
    cout << endl;

    return 0;
}

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

typedef int64_t Int;
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << endl; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

int main() {
    string s;
    cin >> s;
    string t[4] = {"dream", "dreamer", "erase", "eraser"};
    bool update = true;
    while (update and not s.empty()) {
        update = false;
        for (Int i = 0; i < (Int)4; i++) {
            if (s.size() < t[i].size()) continue;
            if (s.substr(s.size() - t[i].size(), t[i].size()) == t[i]) {
                update = true;
                for (Int j = 0; j < (Int)t[i].size(); j++) {
                    s.pop_back();
                }
                break;
            }
        }
    }
    print(s.empty() ? "YES" : "NO");
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define endl '\n'
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define FASTIO ios::sync_with_stdio(0); cin.tie(0);
#define REP(i,a,b) for(int i=a;i<b;i++)
const int inf=2e9;
#define maxx 200005
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

int main(){
    FASTIO;
    int n,x,t,a;
    cin>>n>>x>>t;
    a=ceil((double)n/x);
    cout<<a*t<<endl;
    return 0;
}


Measured memory_bytes: 3576
#include<stdio.h>
int main(void)
{
  int a=0;
  int i=0;
  int j=0;
  int v[1000]={};
  int sum=0;
  int ave[20]={};
  int k=0;
  int max=0,min=1000;
  int l=0;

  while(1)
  {
    scanf("%d", &a);

    if(a==0) break;

    for(;i<a;i++)
      {
        scanf("%d", &v[i]);
        if(max<v[i])
          max=v[i];
        if(min>v[i])
          min=v[i];
      }

    for(l=0;l<i;l++)
      sum+=v[l];

    sum=sum-max-min;

    ave[j]=sum/(a-2);

    j++;
    sum=max=i=0;
    min=1000;

  }

  for(;k<j;k++)
    printf("%d\n", ave[k]);

  return 0;
}

Measured memory_bytes: 604
n, q = map(int, input().split())
s = input()
a = [0] * n
t = 0
for i in range(1, n):
    if s[i-1] == "A" and s[i] == "C":
        t += 1
    a[i] += t
for i in range(q):
    l, r = map(int, input().split())
    print(a[r-1] - a[l-1])


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

int main(int argc, char const *argv[])
{
	int n; cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];

	int target = 1;
	rep(i, n) {
		if (a[i] == target) {
			target++;
		}
	}
	if (target == 1) {
		cout << -1 << endl;
	} else {
		cout << n - target + 1 << endl;
	}
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstring>
#include <algorithm>
#include <map>
#include <cmath>
#include <string>
#include <iterator>
#include <vector>
 
using namespace std;

typedef long long ll;
typedef long double ld;
#define L(ID) ((ID*2)+1)
#define R(ID) ((ID*2)+2)
#define M(L,R) ((L+R)/2)
#define forr(start,end) for(int i = start; i < end; i++)
#define gap ' '
 
const int MAXN = 1e6 + 5;
int n = 0, m = 0;
int a[MAXN];
int b[MAXN];


int largest(int a, int b){
	return (a<b)?b:a;
}


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






    return 0;
} 

Measured memory_bytes: 888
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
int main(){
	int a[100],n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		}
	for(int i=n-1;i>0;i--){
		cout<<a[i]<<" ";
		}
	cout<<a[0]<<endl;
	return 0;
}

Measured memory_bytes: 1160
N = int(input())
H = list(map(int, input().split()))
flag = False
for i in reversed(range(N)):
    if flag:
        H[i] = H[i] - 1
        flag = False
    if i > 0: 
        if H[i] < H[i - 1]:
            if H[i -1] - 1 > H[i]:
                print('No')
                exit(0)
            else:
                flag = True
print('Yes')

Measured memory_bytes: 14396
using System;

public class Program {

        public static void Main(string[] args) {

            var sArray = Console.ReadLine().Split(' ');

            var a = int.Parse(sArray[0]);
            var b = int.Parse(sArray[1]);
            var c = int.Parse(sArray[2]);
            var d = int.Parse(sArray[3]);

            if(a * b > c * d || a * b == c * d) {

                Console.WriteLine(a * b);

            } else if(a * b < c * d) {

                Console.WriteLine(c * d);

            }

        }

    }

Measured memory_bytes: 13140
/* AOJ 0073
 *
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0073
 *
 */

#include <stdio.h>

#include <math.h>


double heron(double a, double b, double c){
    double s;
    s = (a + b + c)/2;
    return sqrt(s*(s-a)*(s-b)*(s-c));
}


int main(){
    int x;
    int h;
    double d;
    double S;

    while(scanf("%d", &x)==1){
        scanf("%d", &h);
        if(x==0 && h == 0)
            break;
        d = sqrt(x*x/2.0 + h*h);
        S = x*x + 4 * heron(d, d, x);
        printf("%f\n", S);
    }


    return 0;
}

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

int getnum() {
    char C; int s = 0, t = 1;
    while (!isdigit(C = getchar())) if(C=='-') t=-1;
    do {s = s * 10 + C - '0'; } while( isdigit(C = getchar()));
    return s * t;
}   

int main() {
  int N = getnum();
  int K = getnum();
  vector<int> A(200000, 0);
  int maxint = 0, minint = 2000000;
  for (int i = 0; i < N; i++) {
    int a = getnum();
    A[a]++;
    maxint = max(maxint, a);
    minint = min(minint, a);
  }
  if (maxint-minint+1<= K) printf("%d\n", 0);
  else {
    sort(A.begin()+minint, A.begin()+maxint+1);
    int cnt = 0;
    while(maxint-minint+1>K) {
    cnt += A[minint];
    minint++;
    }
    printf("%d\n", cnt);
  }
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <iterator>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) container.begin(), container.end()
#define RALL(container) container.rbegin(), container.rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

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; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int n;

string req;
vector<string> props;
main(){
	char c;
	cin >> c >> req;
	REP(i, req.size()) if(req[i] == '.') req[i] = ' ';
	stringstream ss;
	ss << req;
	while(ss >> req){
		props.push_back(req);
	}
	
	cin.ignore();
	int level = 0;
	int depth = 0;
	vi sp(1);
	while(getline(cin, req)){
		int p = 0;
		string prop;
		for(;req[p] == ' ';p++);
		while(sp.back() > p) sp.pop_back();
		if(sp.back() < p) sp.push_back(p);
		if(level > sp.size()-1) break;
		if(level < sp.size()-1) continue;
		while(req[p] != ':') prop.push_back(req[p++	]);
		if(props[level] == prop){
			level ++;
		}else continue;
		if(level == props.size()){
			if(p+1 == req.size()){
				puts("object");
			}else{
				cout << "string \"" << req.substr(p+2) << "\"" << endl;
			}
			return 0;
		}
	}
	puts("no such property");
	return 0;
}

Measured memory_bytes: 1324
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdlib>
#include <string>
#include <cstdio>
#include <algorithm>
#include <math.h>

using namespace std;


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

    char ABCD[5];
    cin >> ABCD;
    int A = ABCD[0] - '0';
    int B = ABCD[1] - '0';
    int C = ABCD[2] - '0';
    int D = ABCD[3] - '0';
    char op1, op2, op3;

    for (int i = 0; i < 2; i++) {
	for (int j = 0; j < 2; j++) {
	    for (int k = 0; k < 2; k++) {
		int tmp = 0;
		if (i == 0) {
		    tmp = (A + B);
		}
		else {
		    tmp = (A - B);
		}
		if (j == 0) {
		    tmp = (tmp + C);
		}
		else {
		    tmp = (tmp - C);
		}
		if (k == 0) {
		    tmp = (tmp + D);
		}
		else {
		    tmp = (tmp - D);
		}

		if (tmp == 7) {
		    if (i == 0) {
			op1 = '+';
		    }
		    else {
			op1 = '-';
		    }
		    if (j == 0) {
			op2 = '+';
		    }
		    else {
			op2 = '-';
		    }
		    if (k == 0) {
			op3 = '+';
		    }
		    else {
			op3 = '-';
		    }
		}

	    }
	}
    }
   
    printf("%d%c%d%c%d%c%d=%d\n", A, op1, B, op2, C, op3, D, 7);

}



Measured memory_bytes: 256