akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#include <bits/stdc++.h>
//~ #include <atcoder/all>
using namespace std;
using ll = long long;
//~ using P = pair<int, int>;

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
//~ int A = (1<<2) | (1<<3) | (1<<5) | (1<<7);
//~ for (int bit=A; ; bit=(bit-1)&A){
//~ if (!bit) break;
//~ }
int next_combination(int sub)
{
    int x = sub & -sub, y = sub + x;
    return (((sub & ~y) / x) >> 1) | y;
}
//~ int n=5;
//~ int k=3; // nCkの組み合わせ、ただしk=0には対応してない
//~ int bit=(1<<k)-1; // 1000 -> 0111
//~ for(; bit < (1<<n); bit=nex_combination(bit){
//~ }
bool isPrime(int a)
{
    if (a == 2)
        return true;
    if (a <= 1 || a % 2 == 0)
        return false;

    for (int i = 3; i * i <= a; i += 2)
    {
        if (a % i == 0)
            return false;
    }
    return true;
}
//~ vector<int> a = {1, 14, 32, 51, 51, 51, 243, 419, 750, 910};
vector<int> a;
// index が条件を満たすかどうか
bool isOK(int index, int key)
{
    if (a[index] >= key)
        return true;
    else
        return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key)
{
    int ng = -1;            //「index = 0」が条件を満たすこともあるので、初期値は -1
    int ok = (int)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1)
    {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key))
            ok = mid;
        else
            ng = mid;
    }
    return ok;
}

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

//~ int v[100100];
//~ int INF = 1 << 30;
//~ vector<vector<int>> dp(310, vector<int>(310));
//~ ll dp[110][100100];
//~ vector<int> dp(100100, 0));

//~ int seen[110];
//~ int ans[110][2];
//~ ll MOD = 1e9 + 7;

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

    int ans = (N * 100 + 108 - 1) * 100 / 10800;

    if ((ans*108/100) == N)
    {
        cout << ans << endl;
    }
    else
    {
        cout << ":(" << endl;
    }

    return 0;
}


Measured memory_bytes: 3636
n=int(input(""))
lisl=input("").split(" ")
l=[]
for i in lisl:
    l+=[int(i)]
l.sort()
t=0
for i in range(2,n):
    for ii in range(1,i):
        for iii in range(ii):
            if(l[i]<l[ii]+l[iii] and l[i]!=l[ii] and l[ii]!=l[iii]):
                t+=1
print(t)
    


Measured memory_bytes: 9108
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<vector>
#include<map>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
int main() {
  int n,k,h,ans=0;
  cin >> n >> k;
  for(int i=0; i<n; i++) {
    cin >> h;
    if(h>=k) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())

for i in range(1, n + 1):
  x = i
  if x % 3 == 0:
    print(' {}'.format(i), end = '')
  else:
    while x > 0 :
      if x % 10 == 3:
        print(' {}'.format(i), end = '')
        break
      x //= 10
print()
  


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

/*
    辺が存在しない場合、dist[i][j] = INF、ただしdist[i][i] = 0 とする
    頂点数 V のとき : 
    vector<vector<int>> dist(V, vector<int>(V, INF));
    for(int i = 0; i < V; i++){
        dist[i][i] = 0;
    }
*/
template <typename T>
void WarshallFloyd(vector<vector<T>> & dist, int k){
    int V = dist.size();
    //for(int k = 0; k < V; k++){
        for(int i = 0; i < V; i++){
            for(int j = 0; j < V; j++){
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    //}
    // dist[i][i] < 0 が存在 <-> 負の閉路が存在
}

signed main(){
    int n;
    cin >> n;
    ll a[n][n];
    vector<pair<ll, P>> vec;
    REP(i,n){
        REP(j,n){
            cin >> a[i][j];
            if(j > i) vec.emplace_back(pair<ll, P>(a[i][j], P(i, j)));
        }
    }
    sort(ALL(vec));
    vector<vector<ll>> dist(n, vector<ll>(n, LINF));
    REP(i,n){
        dist[i][i] = 0;
    }
    ll ans = 0;
    REP(i,vec.size()){
        if(vec[i].first < dist[vec[i].second.first][vec[i].second.second]){
            dist[vec[i].second.first][vec[i].second.second] = vec[i].first;
            dist[vec[i].second.second][vec[i].second.first] = vec[i].first;
            ans += vec[i].first;
            WarshallFloyd<ll>(dist, vec[i].second.first);
            WarshallFloyd<ll>(dist, vec[i].second.second);
        }else if(vec[i].first > dist[vec[i].second.first][vec[i].second.second]){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;
const int INF = pow(2, 30) - 1;

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

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

    ll A,B;
    string S;
    cin >> A>>B;

    bool flag = true;

    REPS(i,10000){
        double A_d = (double)i * 0.08;
        double B_d = (double)i * 0.1;

        ll A_l = (ll)A_d;
        ll B_l = (ll)B_d;
        if(A_l==A&&B_l==B&&A<=100&&B<=100&&1<=A&&1<=B){
            cout << i << endl;
            flag = false;
            break;
        }
    }
    if(flag){
        cout << -1 << endl;
    }
}


Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main(){
    int H,W;
    while(1){
        cin >> H >> W;
        if(H==0 && W==0)break;
        for(int i=0;i<H;i++){
            for(int j=0;j<W-1;j++){
                cout << "#";
            }cout <<"#" << endl;
        }cout << endl;
    }return 0;
}


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

int k;
vector<int> ax, ay;

void sol(vector<int> x, vector<int> y){
  if(ax.size()==8) return;
  
  if(x.size()==8){
    for(int i=0;i<8;i++){
      //cout<< x[i] << " " << y[i] <<endl;
      ax.push_back(x[i]);
      ay.push_back(y[i]);
    }
    //cout<< endl;
    return;
  }
    
  int flag=1, cle;
  for(int i=0;i<8;i++){
    for(int j=0;j<8;j++){
      cle=1;
      for(int k=0;k<x.size();k++){
        if(x[k]==i || y[k]==j || x[k]-i==y[k]-j || i+j==x[k]+y[k]){
          cle=0;
        }else{
          //cout<< i << " " << j << " " << x[k] << " " << y[k] <<endl;
        }
      }
      if(cle){
        x.push_back(i);
        y.push_back(j);
        sol(x, y);
    	x.pop_back();
    	y.pop_back();
      }
    }
  }
}

int main(){
  
  int r, c;
  vector<int> x, y;
  vector< vector<char> > v;
  cin >> k;
  
  for(int i=0;i<k;i++){
    cin>> r >> c;
    x.push_back(r);
    y.push_back(c);
  }
  
  sol(x, y);
  
  v.resize(8);
  for(int i=0;i<8;i++) v[i].resize(8, '.');
  for(int i=0;i<8;i++) v[ax[i]][ay[i]]='Q';
  
  for(int i=0;i<8;i++){
    for(int j=0;j<8;j++){
      cout<< v[i][j];
    }
    cout<< endl;
  }
  
  return 0;
}


Measured memory_bytes: 3176
n,m=map(int, input().split())
h=list(map(int, input().split()))
d={}
for i in range(1,n+1):
    d[i]=[]
for z in range(m):
    a,b=map(int, input().split())
    d[a].append(b)
    d[b].append(a)
ans=0
for i in range(1,n+1):
    val=0
    for j in d[i]:
        if h[j-1]>=h[i-1]:
            val=1
            break
    if val==0:
        ans=ans+1
print(ans)

Measured memory_bytes: 37928
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

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



Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        char[] c = str.toCharArray();
        System.out.print("2018/");
        for (int i = 5; i < c.length; i++) {
            System.out.print(c[i]);
        }
        System.out.println();
    }
}


Measured memory_bytes: 21844
import heapq
w,h = map(int,input().split())
l = []
for i in range(w):
    p0 = int(input())
    l.append([-1*p0,0])
for i in range(h):
    q0 = int(input())
    l.append([-1*q0,1])
heapq.heapify(l)
wide = 0
high = 0
ans = 0
for i in range(w+h):
    a,b = heapq.heappop(l)
    if b == 0:
        ans += -1*a*(high+1)
        wide += 1
    else:
        ans += -1*a*(wide+1)
        high += 1
print(ans)

Measured memory_bytes: 29956
from collections import Counter

N = int(input())
numbers = [int(x) for x in input().split()]

cumulatives = [0] * (N + 1)
for i in range(N):
  cumulatives[i + 1] = cumulatives[i] + numbers[i]
  
counter = Counter(cumulatives)

def nC2(n):
  return  n * (n - 1) // 2

print(sum(
  nC2(v)
  for v in counter.values()
  if v > 1
))

Measured memory_bytes: 112976
N,M = map(int,input().split(" "))
students = [tuple(map(int,input().split(" "))) for _ in range(N)]
checkpoints = [tuple(map(int,input().split(" "))) for _ in range(M)]
Ans = [(0,4*(10**8))]*N

# print(students)
# print(checkpoints)

i = 0
for n in students:
    j=0
    for m in checkpoints:
        j+=1
        dist = abs(n[0]-m[0])+abs(n[1]-m[1])
        if dist<Ans[i][1]:
            Ans[i] = (j,dist)
    i+=1
    
# print(Ans)

for ans in Ans:
    print(ans[0])

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

void solve(long long a)
{
    cout << a + a * a + a * a * a << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long a;
    scanf("%lld", &a);
    solve(a);
    return 0;
}


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

int main()
{
    int K;
    std::cin >> K;
    std::vector<long long> A(K);
    for(int i=0; i<K; i++) scanf(" %lld", &A[i]);

    if(A[K-1] != 2){printf("-1\n"); return 0;}

    long long lb = 2, ub = 2;
    for(int i=K-1; i>=1; i--){
        lb = (lb % A[i-1] == 0) ? lb : (lb / A[i-1] + 1) * A[i-1];
        ub = ((ub+A[i]-1) / A[i-1]) * A[i-1];
        // printf("lb, ub = %lld %lld\n", lb, ub);
        if(lb > ub){printf("-1\n"); return 0;}
    }
    printf("%lld %lld\n", lb, ub+A[0]-1);
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cmath>
#include <algorithm>
#include <iterator>
#define r(i, n) for (int i = 0; i < n; i++)
#define R(i, c, n) for (int i = c; i < n; i++)
#define DEBUG(x) cerr << #x << ": " << x << endl;
#define DUMP(a)            \
  REP(d, a.size())         \
  {                        \
    cout << a[d];          \
    if (d != a.size() - 1) \
      cout << " ";         \
    else                   \
      cout << endl;        \
  }
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) \
  sort(ALL(v));   \
  v.erase(unique(ALL(v)), v.end());
#define pb push_back
using namespace std;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

  int a[5];
  int k;
  r(i,5) cin >> a[i];
  cin >> k;

  r(i,5){
    r(j,4){
      if (abs(a[i]-a[j])>k){
        cout << ":(" << endl;
        return 0;
      }
    }
  }
  cout << "Yay!" << endl;

  return 0;
}

Measured memory_bytes: 256
"""
N = int(input())
A, B = map(int,input().split())
A = list(map(int,input().split())) ## 横一列
A = [int(input()) for _ in range(N)] ## 縦一列
lst = [list(map(int,input().split())) for i in range(M)] ## 二次元
"""

S = input()

for i in range(len(S)):
  if i % 2 == 0:
    if S[i] not in ['R', 'U', 'D']: 
      ans = 'No'
      break
  else:
    if S[i] not in ['L', 'U', 'D']: 
      ans = 'No'
      break
else:
  ans = 'Yes'
  
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>
using namespace std;
using ll=long long;
using R=double;


int main(){
	int N;
	cin >> N;
	ll A[N], B[N];
	for(int i = 0; i < N; i++){
		cin >> A[i] >> B[i];
	}

	ll count = 0;
	for(int i = N-1; i >= 0; i--){
		if((A[i]+count)%B[i]==0){
			continue;
		}else{
			count += B[i]-((A[i]+count)%B[i]);
		}
	}

	cout << count << endl;
	return 0;

}


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

int main(){
  int x0,y0,x1,y1;
  x0=0;
  y0=0;
  int N;
  int x,y,a;
  int S;
  cin >> x1 >> y1 >> N;
  for (int i=0; i<N; i++){
    cin >> x>>y>>a;
    switch (a){
      case 1:
        if(x>x0) x0=x;
        break;
      case 2:
        if(x<x1) x1=x;
        break;
      case 3:
        if(y>y0) y0=y;
        break;
      case 4:
        if(y<y1) y1=y;
        
        break;
    }
  }
  S=(x1-x0)*(y1-y0);
  if((x1-x0)<=0 || (y1-y0)<=0){
    cout << 0<< endl;
  }else{
    cout << S<<endl;
  }
}
       
      

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

int N, T, A;
vector<int> edges[100000];

int dist[100000];
void dfs1(int i, int p){
    for(int j : edges[i]) if(j != p){
        dist[j] = dist[i] + 1;
        dfs1(j, i);
    }
}

int ans;
void dfs2(int i, int p, int d){
    if(d >= dist[i]) return;
    ans = max(ans, dist[i]-1);
    for(int j : edges[i]) if(j != p) dfs2(j, i, d+1);
}

int main(){
    cin >> N >> T >> A;
    T--; A--;
    for(int i=0; i<N-1; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    dfs1(A, -1);
    dfs2(T, -1, 0);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9984
#include <iostream>
#include <vector>
using namespace std;
long long const mod = 1000000007;
long long mod_fact(int x){
    static vector<long long> fact = {1, 1};
    if(x < 0)return 0; //
    if(x < fact.size())return fact[x];
    for(int i = fact.size(); i <= x; i++){
        fact.push_back((fact[i-1] * i) % mod);
    }
    return fact[x];
}

long long mod_pow(long long a, long long b){
    long long res = 1;
    a %= mod;
    while(b > 0){
        if(b%2 == 1) res = (res * a) % mod;
        a = (a * a) % mod;
        b /= 2;
    }
    return res;
}

long long mod_inv(long long a){
    return mod_pow(a, mod-2);
}

long long mod_comb(int a, int b){
    if(b < 0 || a < b)return 0;
    if(b > a/2)return mod_comb(a, a-b);
    return (((mod_fact(a) * mod_inv(mod_fact(a-b))) % mod) * mod_inv(mod_fact(b))) % mod;
}

int main(void){
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    long long ans = 0;
    int y = h-a;
    int x = b+1;
    for(; y >= 1 && x <= w;){
        ans += mod_comb(x+y-2, x-1) * mod_comb(h+w-x-y, w-x) % mod;
        ans %= mod;
        //cout << y << " " << x << " " << ans << endl;
        y--;
        x++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 2420
import math

def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

N = 200000   # N is max number
prime = [True]*(N+1)
prime[0] = False
prime[1] = False

R = int(math.sqrt(N))

for i in range(2, R+1):
    if prime[i]:
        cnt = 2
        while i * cnt <= N:
            prime[i * cnt] = False
            cnt += 1

X = int(input())
while True:
    if prime[X]:
        break
    else:
        X += 1
print(X)



Measured memory_bytes: 4596
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    FastScanner sc;
    PrintWriter p;

    void solve() {
        double D = sc.nextDouble();
        double T = sc.nextDouble();
        double S = sc.nextDouble();

        if(D / S <= T)
            p.println("Yes");
        else
            p.println("No");
    }

    void run() {
        try {
            sc = new FastScanner(new File("DontBeLate.in"));
            p = new PrintWriter(new File("DontBeLate.out"));

            solve();

            p.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }

    void runIO() {

        sc = new FastScanner(System.in);
        p = new PrintWriter(System.out);

        solve();

        p.close();
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(File f) {
            try {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner(InputStream f) {
            br = new BufferedReader(new InputStreamReader(f));
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return null;
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

        boolean hasMoreTokens() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return false;
                st = new StringTokenizer(s);
            }
            return true;
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] nextIntArray(int N) {
            int[] A = new int[N];
            for (int i = 0; i < N; i++) {
                A[i] = sc.nextInt();
            }
            return A;
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        long[] nextLongArray(int N) {
            long[] A = new long[N];
            for (int i = 0; i < N; i++) {
                A[i] = sc.nextLong();
            }
            return A;
        }

        BigInteger nextBigInteger() {
            return new BigInteger(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        double[] nextDoubleArray(int N) {
            double[] A = new double[N];
            for (int i = 0; i < N; i++) {
                A[i] = sc.nextDouble();
            }
            return A;
        }

    }

    public static void main(String[] args) {
        new Main().runIO();
    }
}




Measured memory_bytes: 33044
#include <cmath>
#include <cstring>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector> 
#include <algorithm>
#define ll long long
using namespace std;

ll a, b, x;
ll ans;

int main()
{
	ios::sync_with_stdio(false);
	cin >> a >> b >> x;
	ans = b / x - a / x + !(a % x);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
s = input()[::-1]
ans = 'YES'
while s:
    if s[:5] == 'maerd' or s[0:5] == 'esare':
        s = s[5:]
    elif s[:6] == 'resare':
        s = s[6:]
    elif s[:7] == 'remaerd':
        s = s[7:]
    else:
        ans = 'NO'
        break
print(ans)

Measured memory_bytes: 3316
n = int(input())
s = list(input())
n_r_b = s.count('#')
n_r_w = s.count('.')
n_l_b = 0
n_l_w = 0
ans = n
for i in range(n):
    ans = min(ans,n_l_b+n_r_w)
    if s[i] == '.':
        n_l_w += 1
        n_r_w -= 1
    else:
        n_l_b += 1
        n_r_b -= 1
ans = min(ans,n_l_b+n_r_w)
print(ans)

Measured memory_bytes: 4840
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
using namespace std;
const int MAXN = 3005;
const int INF = (LL)1e9 + 5;
const LL MOD = 998244353;

int N;
double dp[MAXN];

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> N;
	dp[0] = 1.0;
	for (int i = 1; i <= N; i++) {
		double p;
		cin >> p;
		for (int j = i; j >= 0; j--) {
			dp[j] = j == 0 ? dp[j] * (1 - p) : dp[j] * (1 - p) + dp[j - 1] * p;
		}
	}
	
	cout << fixed << setprecision(20) << accumulate(dp + N / 2 + 1, dp + N + 1, 0.0) << "\n";
}


Measured memory_bytes: 384
N, M = map(int, input().split())
A = set([int(input()) for _ in range(M)])
dp = [0]*(N+1)
dp[0] = 1
for i in range(1,N+1):
    if i in A:
        dp[i] = 0
    else:
        dp[i] = (dp[i-1] + dp[i-2]) % (10**9+7)
print(dp[N])

Measured memory_bytes: 13216
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools

class cin():
    def int():
        return int(sys.stdin.readline().rstrip())
    def string():
        return sys.stdin.readline().rstrip()
    def mapInt():
        return [int(x) for x in cin.string().split()]
    def stringList(n):
        return [input() for i in range(n)]

class Util():
    def round_up(a,b):
        return -(-a // b)
    def toUpperMultiple(a,x):
        return Util.round_up(a,x) * x
    def toLowerMultiple(a,x):
        return (a // x) * x

N = cin.int()
A = cin.mapInt()

ans = 0
for x in A:
    ans += format(x,"b")[::-1].find("1")
print(ans)


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

int main() {
    int n, k; cin >> n >> k;
    vector<int> p(n);
    for(auto& x : p) cin >> x;

    vector<int> dp(n);
    for(int i = 1; i < n; ++i) {
        if(p[i - 1] < p[i]) {
            dp[i] = dp[i - 1] + 1;
        }
    }

    set<int> s;
    int ans = 0, sorted = 0;
    if(dp[k - 1] == k - 1) {
        sorted = 1;
    } else {
        ans = 1;
    }
    for(int i = 0; i < k; ++i) {
        s.insert(p[i]);
    }
    for(int i = k; i < n; ++i) {
        bool add = *s.begin() != p[i - k];
        s.insert(p[i]);
        s.erase(p[i - k]);
        add |= *prev(s.end()) != p[i];
        if(add) {
            if(dp[i] >= k - 1) {
                sorted = 1;
            } else {
                ans += 1;
            }
        }
    }
    ans += sorted;

    cout << ans << endl;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int R, G, B, N; cin >> R >> G >> B >> N;
  lint res = 0;
  for (int r = 0; R * r <= N; ++r) {
    for (int g = 0; R * r + G * g <= N; ++g) {
      res += (N - R * r - G * g) % B == 0;
    }
  }
  cout << res << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define frep(i, m, n) for(int i = m;i < n;i++)
#define frepr(i, m, n) for(int i = m;i >= n;i--)
#define vsort(v) sort(v.begin(),v.end())
#define ll long long
#define inf 999999999
typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<string> vst;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
typedef pair<int,P> PP;
typedef pair<ll,LP> LPP;


int main(){
    ll n,m;
    while(cin >> n >> m && n!=0){
        vector<LP> dp(n);
        rep(i,n) cin >> dp[i].second >> dp[i].first;
        sort(dp.begin(),dp.end(),greater<LP>());
        ll ans=0;
        rep(i,n){
            if(dp[i].second<=m){
                m-=dp[i].second;
            }
            else{
                ans+=dp[i].first*(dp[i].second-m);
                m=0;
            }
        }
        // rep(i,dp.size()){
        //     // cout << dp[i].first << "," << dp[i].second << endl;
        //     ans+=dp[i].first*dp[i].second;
        // }
        cout << ans << endl;
    }

    return 0;
}


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

#define gcd(a,b)		__gcd(a,b)
#define lcm(a,b)		(a*b)/gcd(a,b)
#define ff              first
#define ss              second
#define int             long long
#define pb              emplace_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             INT_MAX
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(x)			x.begin(),x.end()
#define digits(x)		floor(log10(x))+1
#define FIO				ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

class dsu {
private:
	int *id;
	int* sz;

	int root(int i) {
		while (i != id[i]) {
			id[i] = id[id[i]];
			i = id[i];
		}
		return i;
	}
public:
	int n;
	dsu(int v) {
		n = v;
		id = new int[n];
		sz = new int[n];

		for (int i = 0; i < n; i++) {
			id[i] = i;
			sz[i] = 0;
		}
	}

	bool find(int p , int q) {
		return root(p) == root(q);
	}

	void join(int p , int q) {
		int i = root(p);
		int j = root(q);
		if (i == j) {
			return;
		}
		if (sz[i] < sz[j]) {
			id[i] = j ;
			sz[j] += sz[i];
		}
		else {
			id[j] = i;
			sz[i] += sz[j];
		}
	}
};

int nCr(int n , int r ) {
	int p = 1, k = 1;

	if (n - r < r ) {
		r = n - r;
	}
	if (r != 0) {
		while (r != 0) {
			p *= n ;
			k *= r ;
			int m = __gcd(p, k);
			p /= m;
			k /= m;
			n--;
			r--;
		}
	}
	else {
		p = 1;
	}
	return p ;
}

int modPower(int x, int y , int p) {
	//Used to calculate (x^y)%p
	int res = 1;
	if (y == 0) {
		return 1;
	}

	x = x % p;
	if (x == 0) {
		return 0  ;
	}

	while (y > 0) {
		if (y & 1) {
			res = (res * x) % p;
		}

		y >>= 1;
		x = (x * x) % p;
	}
	return res ;

}


int32_t main() {
	FIO;


	int a, b;
	cin >> a >> b;

	int d = abs(b - a);
	if (d & 1) {
		cout << "IMPOSSIBLE";
	}
	else {
		int k = min(a, b);
		k += (d / 2);
		cout << k;
	}



	return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll n,i,j;
	cin>>n;
	ll a[n];
	ll max=0;
	vector<ll> count;
	ll c=0;
	for(i=0;i<n;i++){
	    cin>>a[i];
	    if(i>0){
	        if(a[i]<=a[i-1]){
	            c++;
	        }
	        else{
	            count.push_back(c);
	            c=0;
	        }
	    }
	}
	count.push_back(c);
	for(i=0;i<count.size();i++){
	    if(count[i]>max){
	        max=count[i];
	    }
	}
	
	
	cout<<max;
	return 0;
}


Measured memory_bytes: 1912
import sys
N = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(1000):
    for i in range(len(A)):
        if A[i]%2 == 1:
            print(ans)
            sys.exit()
        A[i] = A[i]/2
    ans += 1

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

int main(){
    int n, p, k;
    string s;
    cin >> n;
    vector<tuple<string, int, int>> e;
    rep(i, n){
        cin >> s >> p;
        p = -1 * p;
        k = i + 1;
        e.push_back(tie(s, p, k));
    }
    sort(e.begin(), e.end());
    for(auto ei: e){
        cout << get<2>(ei) << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<typename T> using Graph = vector<vector<T>>;

#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (__typeof(a.begin()) x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define endl '\n'

int N;
int s[105];
int dp[10005];

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

  cin >> N;
  rep(i, N) cin >> s[i];

  rep(i, N) {
      for (int j = 10000; j >= 0; j--){
          if (dp[j] > 0) dp[j + s[i]] = 1;
      }
      dp[s[i]] = 1;
  }

  int ans = 0;
  rep(i, 10005) if (dp[i] && i%10 != 0) ans = i;

  cout << ans << endl;

  return 0;
}


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

using namespace std;
map < pair < int , int > , int > mp;

int main()
{
    int n;   cin >> n;
    int Ans = 0;
    for(int i = 1;i<=n;i++){
        vector < int > v;
        int x = i;
        while(x)   v.push_back(x % 10) , x/=10;
        Ans+=mp[{v[v.size() - 1] , v[0]}] * 2;
        if(v[0] == v[v.size() - 1])  Ans++;
        mp[{v[0] , v[v.size() - 1]}]++;
    }
    cout << Ans;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>



int main(void){
	
	int *num,t=0,a[4];
	a[0] = 0, a[1] = 1;
	int ans;
	num = new int[1000];

	do{
		std::cin >> num[t];
		t++;
	} while (num[t - 1] != 0);

	t = 0;
	while (num[t] != 0){
		a[0] = 0; a[1] = 0, a[2] = 1;
		for (int i = 0; i < num[t]; i++){
			a[3] = a[2] + a[1]+a[0];
			a[0] = a[1];
			a[1] = a[2];
			a[2] = a[3];
		}
		std::cout << (int)a[3]/365/10+1<<std::endl;
		t++;
	}


	return 0;
}

Measured memory_bytes: 1188
#include <iostream>

using namespace std;

int main()
{
	int N;
	cin >> N;
	int *arr = new int[N];
	for(int i = 0; i < N; i++)
		cin >> arr[i];
	int j = 0, i, operation = 0;
	bool found_even ;
	for(int i = 0; i < N; i++)
	{
		while(arr[i] % 2 == 0)
		{
			arr[i] = arr[i] / 2;
			operation++;
		}
		//cout << "i: " << i << "operation: " << operation << endl;
	}
	cout << operation << endl;
	delete []arr;
	return 0;
}

Measured memory_bytes: 256
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
from collections import deque
inf = 10**18
mod = 10**9+7

n = int(input())
a = list(map(int, input().split()))
a.sort()
minnum = a[0]
maxnum = a[-1]
zind = bisect.bisect_left(a, 0)
ans = []
ansnum = maxnum
if zind == n:
    zind-=1
for i in range(1,zind):
    tmp = a[i]
    ans.append([maxnum, tmp])
    ansnum-=tmp
    maxnum-=tmp
ansnum -= minnum
if zind == 0:
    zind+=1
for i in range(zind, n-1):
    tmp = a[i]
    ans.append([minnum, tmp])
    ansnum+=tmp
    minnum-=tmp
ans.append([maxnum, minnum])
print(ansnum)
for p in ans:
    print(*p, sep = ' ')

Measured memory_bytes: 68956
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
 public static void main(String[] args) {
	final Map<Character, Integer> map = new HashMap<Character, Integer>();
	map.put(Character.valueOf('I'), Integer.valueOf(1));
	map.put(Character.valueOf('V'), Integer.valueOf(5));
	map.put(Character.valueOf('X'), Integer.valueOf(10));
	map.put(Character.valueOf('L'), Integer.valueOf(50));
	map.put(Character.valueOf('C'), Integer.valueOf(100));
	map.put(Character.valueOf('D'), Integer.valueOf(500));
	map.put(Character.valueOf('M'), Integer.valueOf(1000));
	Scanner in = new Scanner(System.in);
	while (in.hasNext()) {
	 char[] q = in.next().toCharArray();
	 int val = 0;
	 int pre = 0;
	 for (int i = q.length - 1; i >= 0; i--) {
		int cVal = map.get(q[i]).intValue();
		if (cVal >= pre) {
		 val += cVal;
		} else {
		 val -= cVal;
		}
		pre = cVal;
	 }
	 System.out.println(val);
	}
 }
}

Measured memory_bytes: 12000
use proconio::input;

const alpha: [char; 26] = [
    'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
    't', 'u', 'v', 'w', 'x', 'y', 'z',
];

const Alpha: [char; 26] = [
    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
    'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
];

fn main() {
    input!(n: usize);
    input!(a: [usize; n]);
    let sum = a.iter().fold(0, |acc, &e| acc ^ e);
    let mut ans = vec![];
    for i in 0..n {
        ans.push(sum ^ a[i]);
    }
    for i in 0..n {
        print!("{} ", ans[i]);
    }
}

Measured memory_bytes: 7876
#include<bits/stdc++.h>
#define N 100005
using namespace std;
struct edge{
	int f,t;
	edge(int f1,int t1){
		if(f1>t1) swap(f1,t1);
		f=f1;t=t1;
	}
	bool operator <(const edge &b)const{
		if(f!=b.f) return f<b.f;
		return t<b.t;
	}
};
int bcj[N];
int ff(int x) {return bcj[x]==x? x:bcj[x]=ff(bcj[x]);}
void connect(int fr,int to){
	if(ff(fr)==ff(to)) return ;
	bcj[ff(fr)]=ff(to);
}
vector<int> g1[N],g2[N];
queue<edge> q;
set<edge> st,st2;

int n;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) bcj[i]=i;
	for(int i=1,f,t;i<n;i++){
		scanf("%d%d",&f,&t);
		st.insert(edge(f,t));
		g1[f].push_back(t),g1[t].push_back(f);
	}
	int cnt=0;
	for(int i=1,f,t;i<n;i++){
		scanf("%d%d",&f,&t);
		edge e(f,t);
		if(st.find(e)!=st.end()) q.push(e);
		else g2[f].push_back(t),g2[t].push_back(f),st2.insert(e);
	}
	while(!q.empty()){
		edge e=q.front();q.pop();
		if(ff(e.f)==ff(e.t)) continue;
		cnt++;
		int f=ff(e.f),t=ff(e.t);
		if(g1[f].size()>g1[t].size()) swap(f,t);
		connect(f,t);
		for(int i=0;i<g1[f].size();i++){
			if(ff(g1[f][i])!=t){
				edge e(ff(g1[f][i]),t);
				if(st2.find(e)!=st2.end()) q.push(e);
				else g1[t].push_back(ff(g1[f][i])),st.insert(e);
			}
		}
		g1[f].clear();
		
		for(int i=0;i<g2[f].size();i++){
			if(ff(g2[f][i])!=t){
				edge e(ff(g2[f][i]),t);
				if(st.find(e)!=st.end()) q.push(e);
				else st2.insert(e),g2[t].push_back(ff(g2[f][i]));
			}
		}
		g2[f].clear();
	}
	
	if(cnt==n-1) puts("YES");
	else puts("NO");
	return 0;
}

Measured memory_bytes: 26240
#include<bits/stdc++.h>
using namespace std;
int main(){
    char s[52][52];
    int h,w;
    cin>>h>>w;
    for(int i=0;i<=51;i++){
        for(int j=0;j<=51;j++)s[i][j]='.';
    }
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cin>>s[i][j];
        }
    }
    bool ans=true;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            bool flag=false;
            if(s[i][j]=='#'){
                if(s[i-1][j]=='#')flag=true;
                if(s[i+1][j]=='#')flag=true;
                if(s[i][j-1]=='#')flag=true;
                if(s[i][j+1]=='#')flag=true;
                if(!flag)ans=false;
            }
        }
    }
    if(ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
def bubble_sort(ls):
    flag=True
    i=0
    ch=0
    while flag:
        flag = False
        for j in reversed(range(i+1,len(ls))):
            if ls[j] < ls[j-1]:
                ls[j],ls[j-1] = ls[j-1],ls[j]
                flag = True
                ch += 1
        i += 1
    return ch

if __name__ == "__main__":
    ls=[]
    n=int(input())
    ls = list(map(int,input().split()))
    ch=bubble_sort(ls)
    for i in range(len(ls)):
        if i == len(ls)-1:
            print(ls[i])
        else:
            print(ls[i],end=" ")
    print(ch)


Measured memory_bytes: 5612
#include <cmath>
#include <iostream>
#include <string>

#define FOR(i,a,b) for(i=a;i<b;++i) 

using namespace std;

int main() {
	string S, T;
	cin >> S >> T;
	int i;
	FOR(i, 0, S.size()) {
		S = S[S.size() - 1] + S;
		S.pop_back();
		if (S == T) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
package main

import (
	"io"
	"os"

	"fmt"
)

func Solve(in io.Reader, out io.Writer) {
	var a, b, c, d int
	fmt.Fscan(in, &a, &b, &c, &d)

	if abs(a-c) <= d {
		fmt.Fprintln(out, "Yes")
		return
	}

	if abs(a-b) <= d && abs(b-c) <= d {
		fmt.Fprintln(out, "Yes")
		return
	}

	fmt.Fprintln(out, "No")
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func main() {
	Solve(os.Stdin, os.Stdout)
}


Measured memory_bytes: 512
import sys
input = sys.stdin.readline

N, Ma, Mb = map(int, input().split())
MAX = 400
INF = float('inf')
dp = [[INF] * (MAX+1) for _ in range(MAX+1)]
dp[0][0] = 0
for _ in range(N):
    a, b, c = map(int, input().split())
    for i in range(a, MAX+1)[::-1]:
        for j in range(b, MAX+1)[::-1]:
            dp[i][j] = min(dp[i][j], dp[i-a][j-b] + c)
ans = INF
x = 1
while Ma*x <= MAX and Mb*x <= MAX:
    ans = min(ans, dp[Ma*x][Mb*x])
    x += 1
print(ans if ans < INF else -1)

Measured memory_bytes: 57436
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int N = sc.nextInt();
        String S = sc.next();
        int count = 0;

        for(int i=0; i<N; i++){
            if(i+2 == N){
                break;
            }
            if(S.charAt(i)=='A'){
                if(S.charAt(i+1)=='B'){
                    if(S.charAt(i+2)=='C'){
                        count++;
                    }
                    else{
                        continue;
                    }
                }
                else{
                    continue;
                }
            }else{
                continue;
            }
        }
        // 出力
        System.out.println(count);
    }
}

Measured memory_bytes: 23252
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <numeric>
#include <string>
#include <functional>

using namespace std;
long long MOD=1000000007;

int main(void){
    string L;
    cin>>L;
    long long dp1[100001];
    long long dp2[100001];
    dp1[0]=0;
    dp2[0]=1;
    
    for(int i=0;i<L.length();i++){
        if(L[i]=='1'){
            dp1[i+1]=(3*dp1[i]+dp2[i])%MOD;
            dp2[i+1]=(2*dp2[i])%MOD;
        }else{
            dp1[i+1]=(3*dp1[i])%MOD;
            dp2[i+1]=dp2[i];
        }
    }
    long long ans=(dp1[L.length()]+dp2[L.length()])%MOD;
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 2048
X = gets.to_i
arr = Array.new

ans = 1
b = 2
p = 2
while b <= Math.sqrt(X)
  n = b**p
  if n <= X
    ans = [ans, n].max
    p += 1
  else
    b += 1
    while arr.include?(b)
      b += 1
    end
    p = 2
  end
end

puts ans


Measured memory_bytes: 1788
n = int(input())
a = [list(map(int, input().split())) for _ in range(2)]
res = 0
a1 = 0
a2 = sum(a[1])
for i in range(n):
    a1 += a[0][i]
    res = max(a1 + a2, res)
    a2 -= a[1][i]
print(res)

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */



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

	LL N; cin>>N;
	VL a(N);
	FOR(i, 0, N) {
		cin >> a[i];
	}
	
	
	LL ans = accumulate(ALL(a),0)-N;
	cout<<ans<<endl;

	return 0;
}


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
	string s;cin >> s;
	for(int i = s.length()-1; i >= 0; i--){
		cout << s[i];
	}
	cout << endl;

	return 0;
}



Measured memory_bytes: 2996
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<iomanip>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define erep(i, n) for (int i = 0; i <= (int)(n); i++)

int main() {
    string s; cin >> s;
    sort(s.begin(), s.end());
    cout << (s[0] == s[1] && s[1] != s[2] && s[2] == s[3] ? "Yes" : "No") << endl;
}


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

int main() {
	int N;
	cin >> N;
	vector<int> v(N);
	for (int i = 0; i < N; i++) {
		cin >> v[i];
	}
	sort(v.begin(), v.end());
	long long int count = 0;
	for (int i = 0; i < N; i++) {
		for (int j = i+1; j < N; j++) {
			for (int k = j+1; k < N; k++) {
				if (v[i] < v[j]+v[k] && v[j] < v[i]+v[k] && v[k] < v[i]+v[j]) {
					count++;
				} else {
					break;
				}
			}
		}
	}
	cout << count << endl;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
//const ll INF = 1e18;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

class UnionFind{
private:
	vector<int> par; //�e
	vector<int> sizes; //�f�[�^�̐�

public:
	UnionFind(int n){ 
		par = vector<int>(n);
		sizes = vector<int>(n);
		for(int i = 0; i < n; i++){
			par[i] = i;
			sizes[i] = 1;
		}
	}
	//�؂̍������߂�
	int find(int x){
		if(par[x] == x) return x;
		else return par[x] = find(par[x]);
	}
	//x��y�̑�����W���𕹍�
	void unite(int x,int y){
		x = find(x); //x,y�͊e�f�[�^�̍��m�[�h�𓾂�
		y = find(y);
		if(x == y) return;
		//if (sizes[x] < sizes[y]) swap(x,y);
		par[y] = x; //x��y�̐e�ƂȂ�悤�ɘA������
		sizes[x] += sizes[y];
	}
	//x��y�������W���ɑ����邩�ۂ�
	bool same(int x, int y){
		return find(x) == find(y);
	}
	//x��������W���̃f�[�^��
	int size(int x){
		return sizes[find(x)];
	}
};

int main()
{
	int n,m;
	cin >> n >> m;
	vi a(m),b(m);
	rep(i,m){
		cin >> a[i] >> b[i];
		a[i]--,b[i]--;
	}
	UnionFind uni(n);
	vector<ll> ans(m);
	ans[m-1] = (ll)n*(n-1)/2;
	for(int i = m-1; i >= 1; i--){
		ans[i-1] = ans[i];
		if(!uni.same(a[i],b[i])){
			ans[i-1] -= (ll)uni.size(a[i])*uni.size(b[i]);
			uni.unite(a[i],b[i]);
		}
	}
	rep(i,m) cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 3712
/*
读题不规范，爆零两行泪。
数据不清空，爆零两行泪。
多测不读完，爆零两行泪。
边界不特判，爆零两行泪。
贪心不证明，爆零两行泪。
D P 顺序错，爆零两行泪。
大小少等号，爆零两行泪。
变量不统一，爆零两行泪。
越界不判断，爆零两行泪。
调试不注释，爆零两行泪。
溢出不 l l，爆零两行泪。
*/
#include<bits/stdc++.h>
using namespace std;
int n,m;
int main(){
	cin>>n>>m;
	if(n&1)
		for(int i=1;i<=m;i++)cout<<i<<" "<<n-i+1<<"\n";
	else{
		for(int i=1;i<=n/4&&m;i++,m--)cout<<i<<" "<<n/4*2-i+1<<"\n";
		for(int i=n/4*2+1;m;i++,m--)cout<<i<<" "<<n/4*2+1+n-1-i<<"\n";
	}	
	return 0;
}

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

int main()
{
	int n;
	cin >> n;
	vector<int> v(n);
	int mEven[100010] = {};
	int mOdd[100010] = {};
	for (int i = 0; i < n; i++)
	{
		cin >> v[i];
		if (i % 2 == 0) mEven[v[i]]++;
		else mOdd[v[i]]++;
	}

	int EvenMax = 0;
	int EvenMaxInd;
	int OddMax = 0;
	int OddMaxInd;
	for (int i = 0; i < 100000; i++)
	{
		if (EvenMax<mEven[i])
		{
			EvenMax = mEven[i];
			EvenMaxInd = i;
		}
		if (OddMax < mOdd[i])
		{
			OddMax = mOdd[i];
			OddMaxInd = i;
		}
	}
	int ans = n - EvenMax - OddMax;

	if (EvenMaxInd==OddMaxInd)
	{ 
		mEven[EvenMaxInd] = 0;
		mOdd[OddMaxInd] = 0;
		int EvenMax2 = 0;
		int EvenMaxInd2;
		int OddMax2 = 0;
		int OddMaxInd2;
		for (int i = 0; i < 100000; i++)
		{
			if (EvenMax2 < mEven[i])
			{
				EvenMax2 = mEven[i];
				EvenMaxInd2 = i;
			}
			if (OddMax2 < mOdd[i])
			{
				OddMax2 = mOdd[i];
				OddMaxInd2 = i;
			}
		}
		ans = min(n - EvenMax2 - OddMax, n - EvenMax - OddMax2);
	}

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

Measured memory_bytes: 1408
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n,m = iim()
jud = [False for i in range(n)]
pen = [0 for i in range(n)]

for j in range(m):
    p,s = ism()
    p = int(p) - 1
    if jud[p] == False:
        if s == 'AC':
            jud[p] = True
        elif s == 'WA':
            pen[p] += 1

ans = jud.count(True)
cpn = 0
for k in range(n):
    if jud[k] == True:
        cpn += pen[k]

print(ans,cpn)

Measured memory_bytes: 4784
import sys
sys.setrecursionlimit(2*10**5)


N, M = map(int, input().split())
X, Y, Z = (
    zip(*(map(int, input().split()) for _ in range(M))) if M else
    ((), ())
)

G = [set() for _ in range(N + 1)]
for x, y in zip(X, Y):
    G[x].add(y)
    G[y].add(x)


dp = [-1 for _ in range(N + 1)]


def f(i, k):
    for t in G[i]:
        if dp[t] == -1:
            dp[t] = k
            f(t, k)


L = 0
for i in range(1, N + 1):
    if dp[i] == -1:
        L += 1
        f(i, L)
ans = L
print(ans)


Measured memory_bytes: 135616
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+5;


int main()
{
	ll a1,b1,c1,a0,b0,c0;
	int n;
	cin>>n;
	cin>>a0>>b0>>c0;
	
	if(n==1) 
	{
		cout<<max(a0,max(b0,c0));
		return 0;
	}
	
	n--;
	while(n--)
	{
		
		cin>>a1>>b1>>c1;
		a1=a1+max(b0,c0);
		b1=b1+max(a0,c0);
		c1=c1+max(a0,b0);
		a0=a1;
		b0=b1;
		c0=c1;
	}
	
	cout<<max(a0,max(b0,c0));
	
	return 0;
 } 

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // dequef
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define all(a) (a).begin(), (a).end()
#define mod 1000000007
using ll = long long;
using namespace std;
int gcd(int a, int b){
  if(a % b == 0) return b;
  return gcd(b, a % b);
}
int main(){
  int n;
  cin >> n;
  vi a(n);
  rep(i, n) cin >> a[i];
  set<int> check;
  bool ok = true;
  rep(i, n){
    int num = a[i];
    int b = ceil(sqrt(a[i]));
    for(int j = 2; j < b; j++){
      if(num % j == 0){
        num /= j;
        if(check.count(j)) ok = false;
        check.insert(j);
      }
      while(num % j == 0) num /= j;
    }
    if(num != 1){
      if(check.count(num)) ok = false;
      check.insert(num);
    }
    if(!ok) break;
  }
  if(ok){
    cout << "pairwise coprime" << endl;
    return 0;
  }
  int g = a[0];
  for(int i = 1; i < n; i++) g = gcd(g, a[i]);
  if(g == 1) cout << "setwise coprime" << endl;
  else cout << "not coprime" << endl;
}

Measured memory_bytes: 7392