akhauriyash/Code-Regression huggingface dataset:
h,w=gets.split.map &:to_i
s=[*$<]
dx=[0,1,0,-1,1,1,-1,-1]
dy=[1,0,-1,0,1,-1,1,-1]
h.times{|i|
	w.times{|j|
		if s[i][j]=='#' then
			print'#'
		else
			print (0..7).count{|r|
				x=i+dx[r]
				y=j+dy[r]
				x>=0&&y>=0&&x<h&&y<w&&s[x][y]=='#'}
		end
	}
	puts''
}

Measured memory_bytes: 1788
#include <stdio.h>
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= 9; i++) {
		if (n <= i + i * 10 + i * 100) {
			printf("%d\n", i + i * 10 + i * 100);
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
from collections import Counter

N,K,Q=map(int,input().split(" "))
s=[]
s=Counter(s)
for _ in range(Q):
    i=int(input())
    s[i]+=1
for i in range(1,N+1):
    if s[i]>=(Q-K+1):
        print("Yes")
    else:
        print("No")



Measured memory_bytes: 9440
//include,using,define等
#pragma region header
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>

// ===============================================================
//using系
#pragma region header
using namespace std;
using ll = long long;
using lint = long long;
using vl = vector<long long>;
using vvl = vector<vector<long long>>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;
using ui = unsigned int;
using qul = queue<ll>;
using pql = priority_queue<ll>;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
#pragma endregion
// ========================================================================
//define
#pragma region header
//#define int long long
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i <= n; i++)
#define INF (ll)10000000000000000
#define mod (ll)1000000007
#define P pair<lint,lint>
template <class T>
bool chmax(T & a, const T & b) {
	if (a < b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}
template <class T>
bool chmin(T& a, const T& b) {
	if (a > b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main(void) {
	int n, p; cin >> n >> p;
	bool h = false;
	for (int i = 0; i < n; i++) {
		int s; cin >> s;
		if (s % 2 == 1)
			h = true;
	}
	if (h) printf("%lld\n", (lint)pow(2, n - 1));
	else {
		if (p == 1) printf("%d\n", 0);
		else printf("%lld\n", (lint)pow(2, n));
	}


    return 0;
}

Measured memory_bytes: 4152
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <cstdio>
#include <cstdlib>

using namespace std;

int n,a,r[100001];

int main(int argc,char** argv) {
	cin >> n;
	for(int i = 0;i < n;i++) {
		cin >> a;
		r[a]++;
		r[a-1]++;
		r[a+1]++;
	}
	int res = 0;
	for(int i = 0;i <= 100000;i++) {
		res = max(res,r[i]);
	}
	cout << res;
}


Measured memory_bytes: 640
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
from re import split
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce
from copy import deepcopy
import re

sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


x, y, a, b, c = LI()
P = LI()
Q = LI()
R = LI()
L = []
for p in P:
    L += [(p, 0)]

for q in Q:
    L += [(q, 1)]

for r in R:
    L += [(r, 2)]

L.sort(reverse=True)
ret = 0
z = 0
for l, i in L:
    if i == 0 and x:
        x -= 1
        ret += l
    elif i == 1 and y:
        y -= 1
        ret += l
    elif i == 2:
        z += 1
        ret += l
    if x + y == z:
        break


print(ret)




Measured memory_bytes: 79364
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

#define rep(i, n) for(int i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()

int dx[] = { 1, -1, 0, 0 };
int dy[] = { 0, 0, 1, -1 };

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

int gcd(int a, int b) {
  if (a < b) { swap(a, b); }
  if (b == 0) { return a; }
  return gcd(b, a % b);
}

bool prime(int n) {
  for (int i = 2; i <= sqrt(n); ++i) {
    if (n % i == 0) { return false; }
  }
  return n != 1;
}

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

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  int N, A, B, C, D;
  cin >> N >> A >> B >> C >> D;
  --A; --B; --C; --D;
  string S;
  cin >> S;

  // Check reachability of sunuke.
  for (int i = A; i < C; ++i) {
    if (S[i] == '#' && S[i+1] == '#') {
      cout << "No" << endl;
      return 0;
    }
  }
  // Check reachability of hunuke.
  for (int i = B; i < D; ++i) {
    if (S[i] == '#' && S[i+1] == '#') {
      cout << "No" << endl;
      return 0;
    }
  }

  // Now, sunuke and hunke can reach the goal if they are alone.
  if (D > C) {
    cout << "Yes" << endl;
    return 0;
  }

  // Here, sunuke must overtake hunuke.
  bool ans = false;
  for (int i = B; i <= D; ++i) {
    if (S[i-1] == '.' && S[i] == '.' && S[i+1] == '.') {
      ans = true;
      break;
    }
  }

  if (ans) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 640
from typing import Dict


def main():
    n: int = int(input())
    d: Dict[str, bool] = {}

    for _ in range(n):
        command = input().split()
        if command[0] == "insert":
            d[f"{command[1]}"] = True
        else:
            if command[1] in d:
                print("yes")
            else:
                print("no")


if __name__ == "__main__":
    main()



Measured memory_bytes: 34644
#include<stdio.h>
#define N 25

typedef struct{
  int parent;
  int left;
  int right;
}node;

int preorder(int);
int inorder(int);
int postorder(int);

node T[N];

int main(){
  int n, i, j;
  int id, left, right;

  scanf("%d\n",&n);
  for(i = 0 ; i < n ; i++){
    T[i].parent = -1;
    T[i].left = -1;
    T[i].right = -1;
  }

  for(i = 0 ; i < n ; i++){
    scanf("%d%d%d", &id, &left, &right);
    T[id].left = left;
    T[left].parent = id;
    T[id].right = right;
    T[right].parent = id;
  }

  printf("Preorder\n");
  for(i = 0 ; i < n ; i++){
    if(T[i].parent == -1){
      preorder(i);
    }
  }
  printf("\n");

  printf("Inorder\n");
  for(i = 0 ; i < n ; i++){
    if(T[i].parent == -1){
      inorder(i);
    }
  }
  printf("\n");

  printf("Postorder\n");
  for(i = 0 ; i < n ; i++){
    if(T[i].parent == -1){
      postorder(i);
    }
  }
  printf("\n");
    
  return 0;
}

int preorder(int u)
{
  if(u == -1){
     return;
  }
  printf(" %d", u);
  
  preorder(T[u].left);
  preorder(T[u].right);
}

int inorder(int u)
{
  if(u == -1){
    return;
  }
  inorder(T[u].left);
  printf(" %d", u);
  inorder(T[u].right);
}

int postorder(int u)
{
  if(u == -1){
    return;
  }
  postorder(T[u].left);
  postorder(T[u].right);
  printf(" %d", u);
}

Measured memory_bytes: 616
from collections import Counter
import heapq

n = int(input())
ss = []
for _ in range(n):
    ss.append(input().rstrip())
ctr = Counter(ss)
heap = [(-v, k) for k, v in ctr.items()]
heapq.heapify(heap)
maxv = heap[0][0]
while heap:
    c = heapq.heappop(heap)
    if c[0] != maxv:
        break
    print(c[1])


Measured memory_bytes: 45492
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>
using namespace std;

int main()
{
    bool hundred[10];
    bool ten[10][10];
    bool one[10][10][10];
    for(int i=0;i<10;i++){
        hundred[i]=false;
        for(int j=0;j<10;j++){
            ten[i][j]=false;
            for(int k=0;k<10;k++){
                one[i][j][k]=false;
            }
        }
    }
    int num;
    cin >> num;
    char str;
    int current;
    for(int i=0;i<num;i++){
        cin >> str;
        current = (int)str-48;
        for(int j=0;j<10;j++){
            if(hundred[j]){
                for(int k=0;k<10;k++){
                    if(ten[j][k]){
                        one[j][k][current]=true;
                    }else if(k==current){
                        ten[j][k]=true;
                    }
                }
            }else if(j==current){
                hundred[j]=true;
            }
        }
    }
    int ans = 0;
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            for(int k=0;k<10;k++){
                if(one[i][j][k]){
                    ans ++;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
  int64_t N, t, a, x = 1, y = 1;
  cin >> N;
  for (int i = 0; i < N; i++)
  {
    cin >> t >> a;
    int64_t x_t = (x % t == 0) ? x / t : x / t + 1;
    int64_t y_a = (y % a == 0) ? y / a : y / a + 1;
    x = t * max(x_t, y_a);
    y = a * max(x_t, y_a);
  }
  cout << x + y << endl;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


enum L = 2001;

void main() {
    int M, D;
    scan(M, D);

    int ans;

    foreach (m ; 1 .. M + 1) {
        foreach (d ; 1 .. D + 1) {
            auto d1 = d % 10;
            auto d10 = d / 10;
            if (d1 <= 1 || d10 <= 1) {
                continue;
            }
            if (d1 * d10 == m) ans++;
        }
    }

    writeln(ans);
}

















void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


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

#define int long long
#define counter(m)     for(int i=0;i<m;i++)
#define gcd            __gcd
#define endl           "\n"
#define pb             emplace_back
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define deci(x, y)      fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(NULL)
#define PI             3.141592653589793238
using namespace std;

int power(int x, int y, int p) {
    int res = 1;
    x = x % p;
    while (y > 0) {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
int modi(int a, int m) {
    return power(a, m - 2, m);
}

class dsu {
public:
    vector<int> parent;
    vector<int> size;

    void init(int a) {
        parent.resize(a);
        size.resize(a);
        for (int i = 0; i < a; i++) {
            parent[i] = i;
            size[i] = 1;
        }
    }

    int par(int i) {
        if (i == parent[i])
            return i;
        return parent[i] = par(parent[i]);
    }

    void unite(int a, int b) {
        a = par(a);
        b = par(b);
        if (a != b) {
            parent[a] = b;
            size[b] += size[a];
            size[a] = 0;
        }
    }
};
int32_t main() {
    nitin;
    dsu g;
    int n,m;
    cin>>n>>m;
    g.init(n);
    for(int i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        --a;
        --b;
        g.unite(a,b);
    }
    int ans=-1;
    for(auto c:g.size)
        ans=max(ans,c);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 6364
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define LINF2 10000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;

ll d[305][305];
ll dd[305][305];

int main(int argc, char* argv[])
{
    int n,m,L;
    scanf("%d%d%d", &n, &m, &L);

    int i,j;
    for(i=0; i<n; i++) {
        for(j=0; j<n; j++) {
            if(i!=j) d[i][j]=LINF2;
        }
    }

    for(i=0; i<m; i++) {
        int a,b,c;
        scanf("%d%d%d", &a, &b, &c);  a--; b--;
        d[a][b]=c;
        d[b][a]=c;
    }

    {
        //ワーシャルフロイド
        for(int k = 0; k < n; ++k)
            for(int i = 0; i < n; ++i)
                for(int j = 0; j < n; ++j) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    }

    for(i=0; i<n; i++) {
        for(j=0; j<n; j++) {
            if(i==j) {
                dd[i][j]=0;
            }
            else if(d[i][j]<=L) {
                dd[i][j]=1;
            }
            else {
                dd[i][j]=LINF2;
            }
        }
    }

    {
        //ワーシャルフロイド
        for(int k = 0; k < n; ++k)
            for(int i = 0; i < n; ++i)
                for(int j = 0; j < n; ++j) dd[i][j] = min(dd[i][j], dd[i][k] + dd[k][j]);
    }

    int Q;
    scanf("%d", &Q);
    for(i=0; i<Q; i++) {
        int s,t;
        scanf("%d%d", &s, &t); s--; t--;

        if(dd[s][t]==LINF2) {
            printf("-1\n");
        }
        else {
            printf("%lld\n", dd[s][t]-1);
        }
    }

    return 0;
}



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

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

  bool state = false;
  if(N%10 == 7) state = true;
  if((N%100)/10 == 7) state = true;
  if(N/100 == 7) state = true;

  if(state){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3636
n,k = map(int,input().split())
S = input()+'K'
S_c = []
cnt = 0
for i in range(n):
  if S[i+1]==S[i]:
    cnt += 1
  else:
    cnt += 1
    S_c.append(cnt)
    cnt = 0
    

if 2*k+1 <= len(S_c):
  ans = sum(S_c[:2*k+1])-1

  for i in range(2*k+1,len(S_c)):
    ans += S_c[i]-1
  print(ans)
else:
  print(sum(S_c)-1)
    




Measured memory_bytes: 4724
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;


Int s, t, p, q, m, y;

int main(){
    cin >> s >> t >> p >> q >> m >> y;
    cout << (t ^ s ^ y) << endl;
    return 0;
}



Measured memory_bytes: 3116
# https://atcoder.jp/contests/abc152/tasks/abc152_b

read row ; row=($row) ; a=$((row[0])) ; b=$((row[1]))
ans=""
if [ $a -lt $b ] ; then
  # aをb回繰り返す
  for ((i = 0; i < b; i++)) ; do
    ans="${ans}$a"
  done
else
  # bをa回繰り返す
  for ((i = 0; i < a; i++)) ; do
    ans="${ans}$b"
  done
fi
echo $ans


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

using namespace std;

int main()
{
    int n , m ,C1=0 ,C2=0 , I;
    cin>>n>>m;
    vector<int> a[n+1];
    int vis[ n+1 ]={0};
    for(int i=1; i<=m ;i++)
    {
        string x;
        cin>>I>>x;
        if( x =="AC" ){
            a[ I ].push_back(1);
            vis[I]=1;}
        else
            a[ I ].push_back(0);
    }
    int v[ n+1 ]={0};
    for( int i=1;i<=n ;i++ )
    {
        for(int j=0 ; j<a[i].size() ; j++ )
        {
            if( a[i][j]==1 && v[i]==0 )
            {
                C1++;
                v[i]=1;
                break;
            }
            else if( a[i][j]==0 && v[ i ]==0 && vis[i]==1 )
                C2++;

        }
    }
    cout<<C1<<" "<<C2<<endl;
    return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
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; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

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

    ll N;
    cin >> N;
    vector<ll> a(N), b(N);
    REP(i, N) cin >> a[i];
    REP(i, N) cin >> b[i];

    ll res = 0;
    REP(t, 30){
    	ll D = (1<<t);
    	vector<ll> c, d;
    	REP(i, N) c.push_back(a[i]%(D*2));
    	REP(i, N) d.push_back(b[i]%(D*2));
    	sort(c.begin(), c.end());
    	sort(d.begin(), d.end());

    	ll kosu = 0;
    	REP(i, N){
    		kosu += lower_bound(d.begin(), d.end(), 2*D-c[i]) - lower_bound(d.begin(), d.end(), D-c[i]);
    		kosu += lower_bound(d.begin(), d.end(), 4*D-c[i]) - lower_bound(d.begin(), d.end(), 3*D-c[i]);
    	}
    	if(kosu%2) res += D;
    }
    cout << res << endl;
    return 0;
}

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

int main()
{
  int N;
  cin >> N;
  // string w;
  map<string,int> mp;
  rep(i,N) {
    string w;
    cin >> w;
    sort(w.begin(),w.end());
    mp[w]++;
  }
  ll ans=0;
  for(auto& p : mp){
    int count = p.second;
    ans +=(ll) count * (count-1) / 2;
 // ans +=(ll) (count * (count-1))/2;  //WAになる
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 11136
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

const int MAX_M = 100000000;

char find_replace(vector<pair<char,char> > &table, const char &c)
{
  vector<pair<char,char> >::iterator fit;
  int n = table.size();

  int l=0, r=n;
  while (r-l>=1)
  {
    int i = (l+r)/2;
    char k = table[i].first;
    if (k == c)
    {
      return table[i].second;
    }
    else if (k < c) l = i+1;
    else r = i;
  }
  return ' ';
}

int main()
{
  int n, m;
  char b, a, c;


  while (cin >> n)
  {
    if (n==0) return 0;

    vector<pair<char,char> > table;
    string str;

    for (int i=0; i<n; i++)
    {
      cin >> b >> a;
      table.push_back(make_pair(b, a));
    }
    cin >> m;
    for (int i=0; i<m; i++)
    {
      cin >> c;
      str.push_back(c);
    }

    sort(table.begin(), table.end());
    for (int i=0; i<str.length(); i++)
    {
      c = find_replace(table, str[i]);
      if (c != ' ')
      {
        str[i] = c;
      }
    }
    cout << str << endl;
  }
}

Measured memory_bytes: 1328
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

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

    int H, W, N;
    read(H, W, N);

    i64 ans = LINF;
    reps(i, 0, H) {
        reps(j, 0, W) {
            if (i*W + j*H - i*j >= N) {
                chmin(ans, i + j);
            }
        }
    }

    print(ans);

    return 0;
}


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

typedef unsigned long long int ulint;
typedef long long int lint;

ulint prime = 1000000000 + 7;

int main(){
  ulint N;
  cin >> N;

  vector<ulint> A;
  
  for (int i = 0; i < N; ++i) {
    ulint a = 0;
    cin >> a;
    A.push_back(a);
  }

  ulint val = 0;
  for (int i = 0; i < 62; ++i) {
    // i := i-th bit.

    ulint ones = 0;
    
    for (int j = 0; j < N; ++j) {
      if ((A[j] >> i) & (ulint) 1) {
	++ones;
      }
    }
    
    ulint added_val = (ulint) ones * ((ulint) (N - ones) * ((((ulint) 1) << i) % prime) % prime) % prime;
    
    // cout << "i = " << i << ": #1="
    // 	 << ones << endl;
    // cout << "added " << added_val << endl;
    
    val += added_val;
    val %= prime;
  }
  cout << val << endl;
}


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

int main(){
    ll mod = 1e9 + 7;
    int N;  cin >> N;
    string S;  cin >> S;
    if(S[0] == 'W' || S[2*N-1] == 'W'){
        cout << 0 << endl;
        return 0;
    }

    vector<int> s(2*N, 0);
    for(int i=1; i<2*N; i++){
        if(S[i] == S[i-1]) s[i] = 1 - s[i-1];
        if(S[i] != S[i-1]) s[i] = s[i-1];
    }
    if(s[2*N-1] == 0){
        cout << 0 << endl;
        return 0;
    }

    vector<int> cntL(2*N), cntR(2*N);
    for(int i=0; i<2*N; i++){
        if(i > 0){
            cntL[i] += cntL[i-1];
            cntR[i] += cntR[i-1];
        }
        if(s[i] == 0){
            cntL[i]++;
        }else{
            cntR[i]++;
        }
    }
    if(cntL[2*N-1] != cntR[2*N-1]){
        cout << 0 << endl;
        return 0;
    }

    ll ans = 1;
    for(int i=0; i<2*N; i++){
        if(s[i] == 1){
            ans = (ans * (cntL[i] - (cntR[i] - 1)))%mod;
        }
    }
    for(int i=1; i<=N; i++){
        ans = (ans * i)%mod;
    }
    cout << ans << endl;
}


Measured memory_bytes: 2948
#include <stdio.h>
#include <algorithm>
int n, a, b;
int x[200000];
int y[200000];
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", x + i);
		y[i] = x[i];
	}
	std::sort(x, x + n);
	a = x[n / 2 - 1];
	b = x[n / 2];
	for (int i = 0; i < n; i++) {
		if (y[i] <= a)printf("%d\n", b);
		else printf("%d\n", a);
	}
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define pb push_back
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define mem(a,k) memset(a,k,sizeof(a))
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

#define Pr(f,...) //fprintf(stderr,f,##__VA_ARGS__),fflush(stderr)

typedef long long ll;

template<typename T>
void read(T &x){
	x=0; 
	char c;
	for(c=getchar();!isdigit(c);c=getchar()); 
	for(;isdigit(c);c=getchar())x=x*10+c-'0'; 
}

int n,x,v[(int)5e6],a[(int)5e6];
int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
	/*
	freopen("dat.in","r",stdin);
	freopen("my.out","w",stdout);
	*/
#endif
	cin>>n>>x;
	if(x==1||x==n*2-1){
		puts("No"); 
		return 0; 
	}
	v[x-1]=v[x]=v[x+1]=1;
	a[n-1]=x-1,a[n]=x,a[n+1]=x+1; 
	for(int i=1,p=1;i<=n+n-1;++i)if(!a[i]){
		for(;v[p];++p); a[i]=p++; 
	}
	puts("Yes"); 
	rep(i,1,n+n-1)printf("%d\n",a[i]); 
	return 0;
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pop pop_back
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int n){
	par= vector<int>(n, -1);
  }
  int find(int x){
    if(par[x]<0)
      return x;
    else
      return par[x]=find(par[x]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
/*struct aa{
	vector<int> gt;
  aa(int n){
	gt= vector<int>(n, 1);
  }
	void c(V<int> d,int b){
	if(d[b]==0){
		gt[d[b]-1]++;
		gt[gt.sz-1]++;
	}
	else{
		gt[d[b]-1]++;
		c(d,d[d[b]]-1);
	}
}
void cok(int a){
	cout<<gt[a-1]<<endl;
	fo(i,a-1)
	cout<<gt[i]<<endl;
}
};
*/
signed main(){
  string s;
  cin>>s;
  string a="abc";
  Sort(s);
  if(s==a)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <cstdio>

const int MOD=1000000007;

int sr;
int sum(int a, int b){
	sr=a+b;
	if(sr>=MOD)	sr-=MOD;
	return sr;
}

int mul(int a, int b){
	return (int)((1LL*a*b)%(long long)(MOD));
}

int N, M;

int Tr1_[3][3]={{2, 1, 1}, {2, 1, 2}, {1, 0, 1}};
int Tr2_[3][3]={{1, 1, 1}, {0, 1, 2}, {0, 0, 1}};

struct Mat{
	int x[3][3];
} Zero, One, Tr1, Tr2, Ans;

Mat operator * (const Mat &A, const Mat &B){
	Mat ret=Zero;
	for(int i=0;i<3;++i)
		for(int j=0;j<3;++j)
			for(int k=0;k<3;++k)
				ret.x[i][k]=sum(ret.x[i][k], mul(A.x[i][j], B.x[j][k]));
	return ret;
}

Mat operator ^ (const Mat &A, int k){
	Mat ret=One, t=A;
	while(k){
		if(k&1)	ret=ret*t;
		t=t*t;
		k>>=1;
	}
	return ret;
}

int main(){
	
	for(int i=0;i<3;++i){
		One.x[i][i]=1;
		for(int j=0;j<3;++j){
			Tr1.x[i][j]=Tr1_[i][j];
			Tr2.x[i][j]=Tr2_[i][j];
		}
	}
	
	scanf("%d%d", &N, &M);
	Ans=One;
	int p=0;
	for(int i=1, a;i<=M;++i){
		scanf("%d", &a);
		Ans=Ans*(Tr1^(a-p-1));
		Ans=Ans*Tr2;
		p=a;
	}
	Ans=Ans*(Tr1^(N-p));
	printf("%d\n", Ans.x[0][2]);
	
	return 0;
}

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

namespace Tasks
{
    public class B
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var N = Scanner.Scan<int>();
            var answer = new int[4];
            for (var i = 0; i < N; i++)
            {
                var S = Scanner.Scan<string>();
                switch (S)
                {
                    case "AC": answer[0]++; break;
                    case "WA": answer[1]++; break;
                    case "TLE": answer[2]++; break;
                    case "RE": answer[3]++; break;
                    default: break;
                }
            }
            Console.WriteLine($"AC x {answer[0]}");
            Console.WriteLine($"WA x {answer[1]}");
            Console.WriteLine($"TLE x {answer[2]}");
            Console.WriteLine($"RE x {answer[3]}");
        }

        public static class Scanner
        {
            private static Queue<string> queue = new Queue<string>();
            public static T Next<T>()
            {
                if (!queue.Any()) foreach (var item in Console.ReadLine().Trim().Split(" ")) queue.Enqueue(item);
                return (T)Convert.ChangeType(queue.Dequeue(), typeof(T));
            }
            public static T Scan<T>() => Next<T>();
            public static (T1, T2) Scan<T1, T2>() => (Next<T1>(), Next<T2>());
            public static (T1, T2, T3) Scan<T1, T2, T3>() => (Next<T1>(), Next<T2>(), Next<T3>());
            public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>());
            public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>(), Next<T5>());
            public static IEnumerable<T> ScanEnumerable<T>() => Console.ReadLine().Trim().Split(" ").Select(x => (T)Convert.ChangeType(x, typeof(T)));
        }
    }
}


Measured memory_bytes: 38508
#include "bits/stdc++.h"
using namespace std;

int main() {
    int A, B, C, X;
    cin >> A >> B >> C >> X;

    int res = 0;
    for (int a = 0; a <= A; a++) {
        for (int b = 0; b <= B; b++) {
            for (int c = 0; c <= C; c++) {
                if (X == 500 * a + 100 * b + 50 * c) {
                    res++;
                }
            }
        }
    }

    cout << res << endl;
}

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

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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<long long> A(N);
  rep(i,N) cin >> A[i];
  map<long long,int> mp;
  long long sum = 0, cnt = 0;
  mp[0] = 1;
  rep(i,N) {
    cnt += mp[sum+A[i]];
    sum += A[i];
    ++mp[sum];
  }
  cout << cnt << endl;
  return 0;
}


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

int main()
{
   int n;
   cin>>n;
   if(n%2==0)printf("0.5000000000\n");
   else
   {
       double x=n,res;
       n=n/2+1;
       x=(double)n/x;

       printf("%0.8f\n",x);


   }

    return 0;

}


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

int     main() {
        int N;
        cin >>N;
        vector<vector<int>> A(N+1, vector<int> (N, 0));
        vector<vector<bool>> C(N+1, vector<bool> (N+1, false));
        vector<int> Next(0);
        for (int i=1; i<=N; i++) {
                cin >>A.at(i).at(1);
                C.at(i).at(A.at(i).at(1))=true;
                Next.push_back(i);
                for (int j=2; j<N; j++)
                        cin >>A.at(i).at(j);
        }
        vector<int> I(N+1, 1);
        int S=0;
        int AN=N;
        vector<vector<int>> Games(0);
        while (true) {
                if (!Games.empty())
                        Games.clear();
                sort(Next.begin(), Next.end());
                Next.erase(unique(Next.begin(), Next.end()), Next.end());
                int SS=Next.size();
                for (int ii=0; ii<SS; ii++) {
                        int i=Next.at(ii);
                        if (I.at(i)<N)
                                Next.push_back(A.at(i).at(I.at(i)));
                }
                sort(Next.begin(), Next.end());
                Next.erase(unique(Next.begin(), Next.end()), Next.end());
                for (int ii=0; ii<Next.size(); ii++) {
                        int i=Next.at(ii);
                        if (I.at(i)<N) {
                                int A2=A.at(i).at(I.at(i));
                                if (C.at(i).at(A2) && C.at(A2).at(i)) {
                                        Games.push_back({i, A2});
                                }
                        }
                }
                if (Games.empty()) {
                        cout <<-1 <<endl;
                        return 0;
                }
                Next.clear();
                for (int i=0; i<Games.size(); i++) {
                        int A1=Games.at(i).at(0);
                        I.at(A1)++;
                        if (I.at(A1)<N) {
                                int A2=A.at(A1).at(I.at(A1));
                                C.at(A1).at(A2)=true;
                                Next.push_back(A2);
                        } else
                                AN--;
                }
                S++;
                if (0==AN)
                        break;
        }
        cout <<S <<endl;
        return 0;
};

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

int main() {
    uint64_t A;
    string B;
    cin >> A >> B;


    uint64_t Bx100 = 0;
    for (uint64_t i = 0; i < B.size(); i++) {
        if (i == 1) {
            continue;
        }
        Bx100 *= 10;
        Bx100 += B[i] - '0';
    }
    A *= Bx100;

    cout << A / 100 << endl;
}

Measured memory_bytes: 3596
#include "bits/stdc++.h"
using namespace std;

#define ul unsigned long int
#define ull unsigned long long
#define li long long int


int main()
{
  ul a,b,c;
  cin>>a>>b>>c;
  ul ans[3];

  if (a>b) {
    if (b>c) {
      ans[0]=c;
      ans[1]=b;
      ans[2]=a;
    } else {
      if (a>c) {
        ans[0] = b;
        ans[1] = c;
        ans[2] = a;
      } else {
        ans[0] = b;
        ans[1] = a;
        ans[2] = c;
      }
    }
  } else {
    if (b<c) {
      ans[0] = a;
      ans[1] = b;
      ans[2] = c;
    } else {
      if (a>c) {
        ans[0] = c;
        ans[1] = a;
        ans[2] = b;
      } else {
        ans[0] = a;
        ans[1] = c;
        ans[2] = b;
      }
    }
  }

  cout << ans[0] << " " << ans[1] << " " << ans[2]<<endl;

      return 0;
}



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

using namespace std;

int N;

bool ask1(int it){
    cout<<"? ";
    for(int i = 1; i <= N; i++)
        cout<<it + i - 1<<" ";
    cout<<endl;
    string str;
    cin>>str;
    if(str == "Red") return 1;
    else return 0 ;
}


bool ask2(int it,int pos){
    cout<<"? "<<pos<<" ";
    for(int i = 1; i <= it - 1; i++)
        cout<<i<<" ";
    for(int i = it + N + 1; i <= 2 * N; i++)
        cout<<i<<" ";
    cout<<endl;
    string str;
    cin>>str;
    if(str == "Red") return 1;
    else return 0 ;
}

bool ask3(int it,int pos){
    cout<<"? "<<pos<<" ";
    for(int i = it + 1; i <= it + N -1; i++)
        cout<<i<<" ";
    cout<<endl;
    string str;
    cin>>str;
    if(str == "Red") return 1;
    else return 0 ;
}

int main()
{
    cin>>N;
    int left = 1;
    int right = N + 1;
    int val = ask1(1);
    int it;
    while(left <= right){
        int mid = (left + right) / 2;
        if(val == ask1(mid)){
            it = mid;
            left = mid + 1;
        }
        else right = mid - 1;
    }

    char sol[2*N];
    if(!val){
        sol[it] = 'B';
        sol[it + N] = 'R';
    }
    else {
        sol[it] = 'R';
        sol[it + N] = 'B';
    }

    for(int i = it + 1; i <= it + N - 1; i++){
        //cout<<2<<" ";
        if(!ask2(it,i))
            sol[i] = 'B';
        else sol[i] = 'R';
    }

    for(int i = 1; i <= it - 1; i++){
        //cout<<3<<" ";
        if(!ask3(it,i))
            sol[i] = 'B';
        else sol[i] = 'R';
    }

    for(int i = it + N + 1; i <= 2 * N; i++){
        //cout<<3<<" ";
        if(!ask3(it,i))
            sol[i] = 'B';
        else sol[i] = 'R';
    }

    cout<<"! ";
    for(int i = 1; i <= 2 * N; i++)
        cout<<sol[i];
    return 0;
}


Measured memory_bytes: 724
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct UnionFind{
  Int n;
  vector<Int> r,p;
  UnionFind(){}
  UnionFind(Int sz):n(sz),r(sz,1),p(sz,0){iota(p.begin(),p.end(),0);}
  Int find(Int x){
    return (x==p[x]?x:p[x]=find(p[x]));
  }
  bool same(Int x,Int y){
    return find(x)==find(y);
  }
  void unite(Int x,Int y){
    x=find(x);y=find(y);
    if(x==y) return;
    if(r[x]<r[y]) swap(x,y);
    r[x]+=r[y];
    p[y]=x;
  }
  Int size(Int x){
    return r[find(x)];
  }
};

//INSERT ABOVE HERE
signed main(){
  Int w,h;
  cin>>w>>h;

  vector<string> st(h);
  for(Int i=0;i<h;i++) cin>>st[i];

  auto idx=[&](Int y,Int x){return y*w+x;};  
  UnionFind uf(h*w);
  
  auto in=[&](Int y,Int x){return 0<=y&&y<h&&0<=x&&x<w;};
  Int dy[]={0,0,1,-1};
  Int dx[]={1,-1,0,0};

  auto check=
    [&](Int y,Int x)->void{
      if(!in(y,x)||st[y][x]=='#') return;
      for(Int k=0;k<4;k++){
        Int ny=y+dy[k],nx=x+dx[k];
        if(in(ny,nx)&&st[ny][nx]!='#')
          uf.unite(idx(y,x),idx(ny,nx));        
      }
    };

  for(Int i=0;i<h;i++)
    for(Int j=0;j<w;j++)
      check(i,j);
  
  Int ty=0,tx=0;
  for(Int i=0;i<h;i++)
    for(Int j=0;j<w;j++)
      if(st[i][j]=='t')
        ty=i,tx=j;  
  
  if(uf.same(idx(0,0),idx(ty,tx))){
    cout<<0<<endl;
    return 0;
  }

  Int n;
  cin>>n;
  
  Int x,y,cnt=0;
  while(cin>>x>>y){
    cnt++;
    if(st[y][x]!='#') continue;
    st[y][x]='.';
    check(y,x);
    if(uf.same(idx(0,0),idx(ty,tx))){
      cout<<cnt<<endl;
      return 0;
    }
  }
 
  cout<<-1<<endl;
  return 0;
}



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

using namespace std;

void FAST_IO() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

#define REP(_i, _a) for(int _i = 0; _i < (int)_a; ++_i)
#define FOR(_i, _a, _b) for(int _i = (int)_a; _i <= (int)_b; ++_i)
#define FORD(_i, _a, _b) for(int _i = (int)_a; _i >= (int)_b; --_i)
#define RESET(_a, _value) fill_n(_a,sizeof(_a)/sizeof(_a[0]),_v)
#define ALL(_a) _a.begin(), _a.end()
#define SIZE(_a) _a.size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define newline '\n';

// DEBUG UTIL
#define DEBUG(args...) { cerr << "> "; \
						 string _s = #args; \
						 replace(_s.begin(), _s.end(), ',', ' '); \
						 stringstream _ss(_s); istream_iterator<string> _it(_ss); \
						 err(_it, args); }

void err(istream_iterator<string> it) { cerr << endl; }
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << ": " << a << " ";
	err(++it, args...);
}

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

string format(const string& s, ...) {
    va_list args;
    va_start (args, s);
    size_t len = vsnprintf(NULL, 0, s.c_str(), args);
    va_end (args);
    std::vector<char> vec(len + 1);
    va_start (args, s);
    vsnprintf(&vec[0], len + 1, s.c_str(), args);
    va_end (args);
    return &vec[0];
}

const double PI = acos(-1.0);
const int MOD = 1e9 + 7;
const int INF = 2e9;

int n;
vi arr;
ll tot = 0LL;

void read() {
	cin >> n;
	arr.resize(n);
	REP(i, n) {
		cin >> arr[i];
		tot += arr[i] - 1;
	}
	cout << tot << endl;
}

void solve() {
	
}

int main() {
	FAST_IO();

	int TC = 1;
	// cin >> TC;
	FOR(tc, 1, TC) {
		read();
		solve();
	}

	return 0;
}


Measured memory_bytes: 256
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

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

int main(){
	int h, w;
	scanf("%d %d", &h, &w);
	char s[w+1];
	for(int i=0; i<h; i++){
		scanf("%s", s);
		printf("%s\n%s\n", s, s);
	}
	return 0;
}



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

int main(){
  int n;
  string s;

  cin >> n;

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

  int cnt =0;

  for(int i=0; i<=n-3; ++i){
    if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C'){
      cnt++;
    }
  }

  cout << cnt;

}



Measured memory_bytes: 256
#include "iostream"
#include "cmath"
using namespace std;
int main()
{
	int a, b, ans;
	cin >> a >> b;
	if (a >= 13)
	{
		ans = b;
	}
	else if(a>=6)
	{
		ans = b / 2;
	}
	else
	{
		ans = 0;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int factorial(int n) {
    int f = 1;
    REP(i, 1, n + 1)
    f *= i;
    return f;
}

class Factorial {
    public:
    Factorial(int n) {
        fac = new ll[n + 1];
        fac[0] = 0; fac[1] = 1;
        REP(i, 2, n + 1) {
            fac[i] = fac[i - 1] * i % MOD;
        }
    }

    ll factorial(int n) {
        return fac[n];
    }

    private:
    ll *fac;
};


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

    int count[N] = {};
    REP(i, 0, N) {
        int a; cin >> a;
        count[a]++;
    }

    int diff[N] = {};
    REP(i, 0, N) diff[abs((N - i - 1) - i)]++;

    Factorial f(N);
    ll ans = 1;
    REP(i, 0, N) {
        if (count[i] != diff[i]) {
            cout << 0 << endl;
            return 0;
        }
        if (count[i] == 0) continue;
        ans = ans * f.factorial(count[i]) % MOD;
    }

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

Measured memory_bytes: 1792
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    string s; cin >> s;
    s += "X";

    int cons = 0, ans = 0;
    for(int i=0; i<(int)s.size(); i++) {
        if(s[i] == 'R') cons++;
        else {
            chmax(ans, cons);
            cons = 0;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main () {
  int x, y, z;
  while(true) {
    cin >> x >> y;
    if (x == 0 && y == 0) {
      break;
    } else {
      if (x > y) {
        z = x;
        x = y;
        y = z;
      }
      cout << x << " " << y << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3120