akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long int
#define FASTIO std::ios::sync_with_stdio(false);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define inf 1e18
#define g(x) cout<<x<<" "<<endl;
#define gg(x,y) cout<<x<<" & "<<y<<" "<<endl
#define jam(t) cout<<"Case #"<<t<<": "
#define ggg(x,y,z) cout<<x<<" & "<<y<<" & "<<z<<" "<<endl
#define all(x) x.begin(),x.end()
#define input_from_file  freopen("input.txt", "r", stdin);
#define mod 1000000007ll
#define sz 400005
#define bitcnt(x) __builtin_popcountll(x)

using namespace std;
vector <ll> ve[sz];
ll a[sz];
void solve(){
  ll n,m;
  cin >> n >> m;
  for(ll i=1;i<=n;i++)
    cin >> a[i];
  for(ll i=1;i<=m;i++){
    ll u,v;
    cin >> u >> v;
    ve[u].pb(v);
    ve[v].pb(u);
  }
  ll ans = 0;
  for(ll i=1;i<=n;i++){
    // if(ve[i].size() == 0){
    //   ans ++;
    //   continue;
    // }
    bool ok = true;
    for(auto it:ve[i]){
      if(a[it] >= a[i])
        ok = false;
    }
    if(ok)
      ans ++;
  }
  g(ans);
}
int main()
{
#ifndef ONLINE_JUDGE
input_from_file
#endif
 
    FASTIO
    cin.tie(NULL);
    fflush(stdout);
    ll t = 1;
  //  cin >> t;
    for(ll tcase = 1;tcase <= t;tcase++){
      solve();
        
    }
return 0;
}

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

int main(){
    
    int n;
    cin >> n;
    set<int> s;
    for(int i=0;i<n;i++){
        int val;cin >> val;
        s.insert(val);
    }
    if(s.size()==n){
        cout << "YES";
    }else{
        cout << "NO";
    }
    
    return 0;
}

Measured memory_bytes: 12932
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#include <iomanip>
//cout << fixed << setprecision(20) << *** << endl;
#define rep(i,N) for(int i=0;i<(int)N;++i)
typedef long long ll;
using namespace std;
//ユークリッド
ll gcd(ll a,ll b){
	ll t;
	if(a<b){
		t=a;
		a=b;
		b=t;
	}
	if(a%b==0)return b;
	return gcd(b,a%b);
}
//階乗
ll Factorial(ll a){
	ll b=1;
	for(ll i=a;i>=1;i--){
		b=b*i;
	}
	return b;
}
//素数判定
bool prime(ll n){
	for(ll i=2;i*i<=n;i++){
		if(n%i==0) return false;
	}
	return true;
}
int main()
{
	ll N,K;
	vector<ll>H,ANS;
	cin>>N>>K;
	rep(i,N){
		ll t;
		cin>>t;
		H.push_back(t);
	}
	sort(H.begin(),H.end());
	for(ll i=0;i<N-K+1;i++){
		ll t;
		t=H[i+K-1]-H[i];
		ANS.push_back(t);
	}
	sort(ANS.begin(),ANS.end());
	cout<<ANS.front()<<endl;
}

Measured memory_bytes: 2548
using System;
using System.Collections.Generic;

namespace atcorder
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            atcorder.Test.Run();
        }
    }



    public class Test
    {
        public static void Run()
        {
            string s = Console.ReadLine();
            string[] ss = s.Split(' ');
            long N = long.Parse(ss[0]);
            long M = long.Parse(ss[1]);
            List<long> l = new List<long>();
            s = Console.ReadLine();
            ss = s.Split(' ');
            for (long i = 0; i < M;i++){
                l.Add(long.Parse(ss[i]));
            }
            l.Sort();
            List<long> sub = new List<long>();
            for (int i = 1; i < M; i++)
            {
                sub.Add(l[i]-l[i-1]);
            }
            sub.Sort();
            for (int i = 0; i < N - 1;i++){
                if (sub.Count == 0) break;
                sub.RemoveAt(sub.Count - 1);
            }
            if (sub.Count == 0) Console.WriteLine("0");
            else{
                long sum = 0;
                foreach (long i in sub) sum += i;
                Console.WriteLine(sum);
            }
        }
    }
}

Measured memory_bytes: 20576
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <stdlib.h>
using namespace std;

int main(){
	int N;
	cin >> N;
	long long ans = 1; //intは20億ぐらいしか計算できない
	for(int i = 1; i <= N; i++){
		ans = ans * i % 1000000007;
	}
	cout << ans <<endl;
	return 0;

}


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

int main(void) {
	int n;
	char in[1024], *ptr;

	scanf("%d ", &n);

	while (n--) {
		fgets(in, 1023, stdin);
		ptr = strstr(in, "Hoshino");
		while (ptr != NULL) {
			ptr[6] = 'a';
			ptr = strstr(ptr, "Hoshino");
		}
		printf("%s", in);
	}
	return 0;
}

Measured memory_bytes: 604
import Data.List

main :: IO ()
main = do
  (n:m:_) <- fmap (map read . words) getLine :: IO [Int]
  xs <- fmap (map read . words) getLine :: IO [Int]
  print $ solve n xs

solve n xs = sum . take (length xs - n) $ sort diffs
  where
    sorted = sort xs
    diffs = zipWith (-) (tail sorted) sorted

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

using namespace std;
typedef pair<int, int> P;

void solve()
{
	int Digit[100002];
	for(int i = 0; i < 100002; ++i)
	{
		Digit[i] = 0;
	}
	int N;
	cin >> N;
	vector<P> Person(N);
	for(int i = 0; i < N; ++i)
	{
		cin >> Person[i].first >> Person[i].second;
	}
	for(int i = 0; i < N; ++i)
	{
		for(int j = Person[i].first; j <= Person[i].second; ++j)
		{
			++Digit[j];
		}
	}
	int Max = 0;
	for(int i = 0; i <= N + 1; ++i)
	{
		if(Digit[i] + 1 >= i)
		{
			Max = i - 1;
		}
	}
	cout << Max << endl;
}

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

Measured memory_bytes: 2028
n = int(input())
a = input().split()
b = input().split()

count = 0

for i in range(n+1):
    city = n - i
    if (city != n):
        defeat = min(int(a[city]), int(b[city]))
        count = count + defeat
        a[city] = str(int(a[city]) - defeat)
    if (city != 0):
        defeat = min(int(a[city]), int(b[city-1]))
        count = count + defeat
        b[city-1] = str(int(b[city-1]) - defeat)

print(count)

Measured memory_bytes: 21680
#include<bits/stdc++.h>
using namespace std;
int n;
int main()
{
	cin>>n;
	if(n==0)
	{
		puts("0");
		return 0;
	}
	int z=0;
	string ans="";
	while(n)
	{
		if(n%2)
		{
			ans+='1';
			if(z%2)
				++n;
			else
				--n;
		}
		else
			ans+='0';
		++z;
		n/=2;
	}
	reverse(ans.begin(),ans.end());
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static int stack[] = new int[1000];
	static int counta = 0;

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		String input[] = (scanner.nextLine()).split(" ");

		for (int i = 0; i < input.length; i++) {
			if (input[i].equals("*")) {
				push(pop() * pop());

			} else if (input[i].equals("+")) {
				push(pop() + pop());

			} else if (input[i].equals("-")) {
				push(-pop() + pop());

			} else {
				push(Integer.parseInt(input[i]));

			}
		}
		System.out.println(pop());
	}

	public static int pop() {
		counta--;
		return stack[counta];
	}

	public static void push(int i) {
		stack[counta] = i;
		counta++;
	}
}


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

const int MAXN = 100010;
int head[MAXN], nxt[MAXN << 1], to[MAXN << 1], tot;
void addedge(int b, int e) {
	nxt[++tot] = head[b]; to[head[b] = tot] = e;
	nxt[++tot] = head[e]; to[head[e] = tot] = b;
}
int n;
int dfs(int u, int fa = 0) {
	int pre = 0, hav = 0;
	for (int i = head[u]; i; i = nxt[i]) if (to[i] != fa) {
		int t = dfs(to[i], u);
		hav |= pre & t;
		pre |= t;
	}
	int p = hav ? std::__lg(hav) + 1 : 0;
	p += __builtin_ctz((pre >> p) + 1);
	pre ^= pre & (1 << p) - 1;
	return pre | 1 << p;
}
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n;
	for (int i = 1, t1, t2; i < n; ++i)
		std::cin >> t1 >> t2, addedge(t1, t2);
	std::cout << std::__lg(dfs(1)) << std::endl;
	return 0;
}


Measured memory_bytes: 5632
#include<stdio.h>

int main (){
	int N,i,j,flag;
	scanf("%d",&N);
	flag = 0;
     int p[2][9] = {
	         {1,2,3,4,5,6,7,8,9},
              {1,2,3,4,5,6,7,8,9}
		    };
	for (i=0;i<9;i++){
		for (j=0;j<9;j++){
			if (p[0][i]*p[1][j]==N){
				printf("Yes\n");
			     flag=1;
			     j=9;
			     i=9;
			 }
		}
	}
	if (flag==0){
		printf("No\n");
	}
	return 0;
}


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

long long T[100];

long long LCM(long long a, long long b)
{
	long long aa = a, bb = b;
	/* 自然数 a > b を確認・入替 */
	if (a<b) {
		long long tmp = a;
		a = b;
		b = tmp;
	}

	/* ユークリッドの互除法 */
	long long r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return aa/b*bb;

}

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

	long long lcm = 1;
	for (int i = 0; i < N; ++i) {
		cin >> T[i];
		lcm = LCM(lcm, T[i]);
	}

	cout << lcm << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INFTY (1<<21)

int n,M[MAX][MAX];

void dijkstra(){
  int minv;
  int i,j,u;
  int d[MAX],color[MAX];
  for(i=0;i<n;i++){
    d[i]=INFTY;
    color[i]=WHITE;
  }
  d[0]=0;
  color[0]=GRAY;
  while(1){
    minv=INFTY;
    u=-1;
    for(i=0;i<n;i++){
      if(minv>d[i] && color[i]!=BLACK){
        u=i;
        minv=d[i];
      }
    }
    if(u==-1)break;
    color[u]=BLACK;
    for(j=0;j<n;j++){
      if(color[j]!=BLACK && M[u][j]!=INFTY){
        if(d[j]>d[u]+M[u][j]){
          d[j]=d[u]+M[u][j];
          color[j]=GRAY;
        }
      }
    }
  }
  for(i=0;i<n;i++){
    printf("%d %d\n",i,d[i]==INFTY ? -1:d[i]);
  }
}

int main(){
  int i,j;
  int k,c,u,v;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j]=INFTY;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d %d",&v,&c);
      M[u][v]=c;
    }
  }
  dijkstra();

  return 0;
}


Measured memory_bytes: 2112
#include <iostream>
#include <cmath>
#include <cstdio>
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;

int main(){
    ll r;
    cin>>r;
    if(r<1200){
        cout<<"ABC"<<endl;
    }else if(r<2800){
        cout<<"ARC"<<endl;
    }else{
        cout<<"AGC"<<endl;
    }
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include <bits/stdc++.h>

using namespace std;

long long h, ans, i;

int main()
{	
	cin>>h;
	while(h > 0)
	{
		ans += pow(2, i);
		h /= 2;
		i ++;
	}
	cout<<ans;
	return 0;
}

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

#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
 
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}
vector<int>adj[maxn],col(maxn);

void solve(){
        
        int s,w;
        cin >> s >> w;
        if(w >= s)cout << "unsafe";
        else cout << "safe";
    
}

signed main()
{
    showoff;
    int t;
    //cin >> t;
    t = 1;
    while(t--){
        solve();
    }
    
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ... 


Measured memory_bytes: 9440
// AUTHOR : Kishan Srivastav
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define in freopen("input.txt", "r", stdin)
#define out freopen("output.txt", "w", stdout)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main() {
	ios
#ifndef ONLINE_JUDGE
	in;
	out;
#endif
	string s;
	cin>>s;
	int len = s.length();
	int l = 0;
	int r = len-1;
	int count = 0;
	while(l<r){
		if (s[l] != s[r]){
			count++;
		}
		l++;
		r--;
	}
	cout<<count<<endl;
}

Measured memory_bytes: 3620
n,m = tuple(map(int,input().split()))

drinks = []

for i in range(n):
  drinks.append(tuple(map(int,input().split())))
  
drinks = sorted(drinks)

ans = 0
t = 0
for a,b in drinks:
  if t+b<m:
    t+=b
    ans+=a*b
  else:
    ans+=a*(m-t)
    break
print(ans)

Measured memory_bytes: 17772
#include<cstdio>
#include<algorithm>

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

using namespace std;

const double EPS=1e-8;

const int T=86400;

int main(){
	int n;
	for(double L;scanf("%d%lf",&n,&L),n;){
		static int use[T];
		rep(t,T) use[t]=0;
		rep(i,n){
			int a,b,u; scanf("%d%d%d",&a,&b,&u);
			for(int t=a;t<b;t++) use[t]=u;
		}

		double lo=0,hi=1e11;
		rep(_,60){
			double mi=(lo+hi)/2;

			bool ok=true;
			double water=L,w1;
			rep(t,2*T){
				if(t==T) w1=water;
				water=min(water+mi-use[t%T],L);
				if(water<0){ ok=false; break; }
			}
			if(ok && w1<water+EPS) hi=mi; else lo=mi;
		}
		printf("%.9f\n",(lo+hi)/2);
	}

	return 0;
}

Measured memory_bytes: 1416
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

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

    int h, w, d;
    cin >> h >> w >> d;

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            int x = i + j;
            int y = i - j + w + (d - w % d);
            cout << "RYGB"[(x % (d * 2) < d) + (y % (d * 2) < d) * 2];
            //cout << x << ',' << y << ' ';
        }
        cout << '\n';
    }

    return 0;
}

Measured memory_bytes: 512
// ABC001C.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>

using namespace std;




int main()
{
	string str;
	cin>>str;
	int count = 0;
	for(int i = 0; i < 4;i++){
		if(str[i] == '2'){
			count++;
		}
	}
	cout<<count<<endl;
	return 0;
}



Measured memory_bytes: 256
def solve():
  n=int(input())
  a=list(map(int,input().split()))
  s=input()
  base=[]
  for i in range(n-1,-1,-1):
    v=a[i]
    for x in base:
      v=min(v,v^x)
    if v:
      if s[i]=='0':
        base.append(v)
      else:
        return 1
  return 0

t=int(input())
for _ in range(t):
  print(solve())

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

using namespace std;

#define rep(i, x)   for (__typeof(x) i = 0; i < x; i++)
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define repi(i, x)  for (__typeof(x) i = x-1; i >= 0; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    vi;
typedef vector<ii>     vii;
typedef vector<iii>    viii;
typedef vector<vector<int> > vvi;
typedef pair<ll, ll>   pairl;
typedef vector<ll>     vl;
typedef vector<ll>     vll;
typedef vector<vector<ll> > vvl;
const   int            infi = numeric_limits<int>::max();
const   ll             infl = numeric_limits<ll>::max();
const   double         eps = 0;
const   int            ms  = 0;

const ll MOD = 1000000007;

int main()
{
    ios::sync_with_stdio(false);//endl->"\n"
    cin.tie(0);
    int N;
    cin >> N;
    vl C(N);
    vl L(2*100000+1, -1);
    vl p(N, 1);
    rep(i, N)cin >> C[i];   
    ll ans = 1;

    L[C[0]] = 0;    
    for(int i = 1 ; i < N; i++){
        //debug(i)
        int c = C[i];
        int l = L[c];

        if(L[c] != -1 && L[c] != i-1){
            p[i] = p[l];
            p[i] = (p[i]+p[i-1])%MOD;
        }
        else{
            p[i] = p[i-1];
        }
        L[c] = i;
        //p[i] = p[L[c]] + p[i-1];
        //debug(ans)
    }
    cout << p[N-1] << endl;
    return 0;
}

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

#ifdef _DEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x)
#endif

using namespace std;

int main() {
    int H, N;
    cin >> H >> N;
    vector<int> as, bs;
    for (int i = 0; i < N; ++i) {
        int a, b;
        cin >> a >> b;
        as.push_back(a);
        bs.push_back(b);
    }

    vector<vector<int64_t>> dp(N, vector<int64_t>(H + 1, 0));
    for (int h = 0; h <= H; ++h) {
        int64_t k = (h + as[0] - 1) / as[0];
        dp[0][h] = bs[0] * k;
    }
    for (int i = 1; i < N; ++i) {
        for (int h = 0; h <= H; ++h) {
            dp[i][h] = bs[i] * ((h + as[i] - 1) / as[i]);
            if (h - as[i] >= 0) {
                dp[i][h] = min(dp[i][h], bs[i] + dp[i][h - as[i]]);
            }
            dp[i][h] = min(dp[i][h], dp[i - 1][h]);
        }
    }
    // for (int i = 0; i < N; ++i) {
    //     for (int h = 0; h <= H; ++h) {
    //         cout << dp[i][h] << " ";
    //     }
    //     cout << endl;
    // }
    cout << dp[N - 1][H] << endl;
}

Measured memory_bytes: 78464
n = int(raw_input())
a = map(int, raw_input().split(" "))

min = 1000000
max = -1000000
sum = 0
for x in a:
  if x < min:
    min = x
  if x > max:
    max = x
  sum += x

print "%d %d %d" % (min, max, sum)

Measured memory_bytes: 4980
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
using namespace std;

#define fi first
#define se second
typedef long long LL;
typedef long double LD;

LL X;

int main(){
    cin >> X;

    LL N=1;
    while (N*(N+1)/2<X) N++;

    cout << N << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iomanip>
#include<iostream>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<vector>
#include<bitset>
#include<cmath>
#define FOR(i,a,b) for(int i=(a); i<int(b); ++i)
#define RFOR(i,a,b) for(int i=(b)-1; i>=int(a); --i)
#define rep(i,n) FOR(i,0,n)
#define rep1(i,n) FOR(i,1,int(n)+1)
#define rrep(i, n) RFOR(i, 0, n)
#define rrep1(i, n) RFOR(i, 1, int(n) + 1)
#define all(c) begin(c), end(c)
#define al(d) d.begin(),d.end()
template <typename T>
using vec = std::vector<T>;
using vi = vec<int>;
using vvi = vec<vi>;
using pii = std::pair<int, int>;
using ll = long long;
using ld = long double;
using namespace std;
const int MOD = 1000000007;

template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
template <class T>
vector<T> getv(int n){
	vector<T> vec;
	rep(i,n){
		T input;
		cin >> input;
		vec.emplace_back(input);
	}
	return vec;
}

using AdjList = vector<vector<int>>;
using Weight = int;
using Flow = int;
struct Edge {
	int src, dst;
	Weight weight;
	Flow cap;
	Edge() : src(0), dst(0), weight(0) {}
	Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;
void add_edge(Graph &g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); }
// Recieve edge(=(int,int)) as an adj list.
AdjList getadj(int N, int M){
	// Initialize all lists of the graph as a empty vector.
	vector<int> init;
	vector<vector<int>> graph(N,init);
	rep(i,M){
		int a, b;
		cin >> a >> b;
		graph[a-1].emplace_back(b-1);
		graph[b-1].emplace_back(a-1);
	}
// rep(i,N)
// 	putv(graph[i]);
	return graph;
}

ll Manhattan_dist(ll x1, ll y1, ll x2, ll y2){
	return abs(x1-x2) + abs(y1-y2);
}
void out(bool ans){
	if(ans == true) cout << "yes" << endl;
	else cout << "no" << endl;
}
void Out(bool ans){
	if(ans == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}
void OUT(bool ans){
	if(ans == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}
ll gcd(const ll a, const ll b){
	return (b==0) ? a : gcd(b,a%b);
}
// $\min\{s\in\mathbb{N}:p^s|n\}$
ll hmt_p_divide_n(ll p, ll n){
	ll s = 0;
	while(n%p == 0){
		n /= p;
		s++;
	}
	return s;
}

int main(){
	int N;
	cin >> N;
	vi a = getv<int>(N);
	ll sum = 0;
	for(auto x:a) sum+=x-1;
	cout << sum << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define speed_up ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define ara(A,N) sort(A,A+N)
#define rev(A,N) sort(A,A+N,greater<long long>())
using namespace std;
ll mul_value(long long tp, long long ti)
{
    ll c, ans;
    if(tp<ti) return 0;
    else if(tp%ti == 0)
    {
        ans = tp/ti;
        return ans;
    }
    else
    {
        ans = tp/ti + 1;
        return ans;
    }
}
int main()
{
    speed_up;
    ll n, sum, tp = 0, ap = 0, ti, ai, a, b;
    cin>>n;
    while(n--)
    {
        cin>>ti>>ai;
        if(ti>tp && ai>ap)
        {
            tp = ti;
            ap = ai;
        }
        else
        {
            a = mul_value(tp, ti);
            b = mul_value(ap, ai);
            a = max(a, b);
            tp = ti * a;
            ap = ai * a;
        }
    }

    sum = tp + ap;
    cout<<sum<<endl;

return 0;
}



Measured memory_bytes: 3616
//{{{
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> ls(n); cin >> ls;
    sort(ls.begin(), ls.end());
    cout << (accumulate(ls.begin(), ls.end(), 0ll) - ls.back() > ls.back() ? "Yes" : "No") << '\n';
}


Measured memory_bytes: 256
#![allow(unused_imports, unused_variables, dead_code)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

trait InputValue {
    fn parse(s: &str) -> Self;
}

fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

fn main() {
    let (n, t): (usize, i64) = read();
    let time: Vec<i64> = readnc();
    let mut sum = 0;
    let mut till = 0;
    for i in 0..n {
        let tt = time[i] + t;
        sum += min(tt - till, t);
        till = tt;
    }
    println!("{}", sum);
}

Measured memory_bytes: 8444
#include<iostream>
#include<vector>
#include<string>

using namespace std;


int main(){
  string s;
  vector<string> idata;
  while(!cin.eof()){
    getline(cin, s);
    idata.push_back(s);
  }

  int data[26] = {0};

  int subscript = 0;
  for(vector<string>::size_type k = 0; k < idata.size(); k++){
    for(string::size_type i = 0; i < idata[k].length(); i++){
      subscript = idata[k][i];
      if(subscript >= 97 && subscript <= 122){
        data[subscript-97] += 1;
      }
      else if(subscript >= 65 && subscript <= 90){
        data[subscript-65] += 1;
      }
    }
  }
  char c;
  for(int i = 0; i < 26; i++){
    c = 97+i;
    cout << c << " : " << data[i] << endl;
  }
  
  return 0;
}



Measured memory_bytes: 3140
#include <bits/stdc++.h>
#define rep(i,a,b) for(register int i=(a);i<(b);i++)
#define per(i,a,b) for(register int i=(b);i>=(a);i--)
#define For(i,a,b) for(register int i=(a);i<=(b);i++)
#define Forenska(it,c) for(register __typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
using namespace std;
typedef long long LL;
typedef pair<int,int> Pair;
typedef vector<int> vec;
const long double PI=3.14159265358979323846264338327950288;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
int main()
{
	int n,m;
	cin>>n>>m;
	vector <int> f;
	For(i,1,sqrt(m))
	{
		if(m%i==0)f.pb(i),f.pb(m/i);
	}
	sort(all(f));
	int ans=1;
/*	rep(i,2,m)
	{
		if(m/i<n)break;
		if(m%i==0)
		{
		//	cout<<i<<endl;
		//	return 0;
			ans=max(ans,i);
		}
	}*/
	rep(i,0,f.size())
	{
		if(m/f[i]<n)break;
		ans=max(ans,f[i]);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

namespace B_ABC152
{
    class MainClass
    {

        static int[] s;

        public static void Main(string[] args)
        {
            s = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            int a = Min(s[0],s[1]);
            int b = Max(s[0],s[1]);
            for(int i = 0;i < b;i++){
                Write(a);
            }
            WriteLine();
        }
    }
}


Measured memory_bytes: 13268
#include<iostream>
#include<iomanip>
#include<cmath>

using namespace std;
using ll=long long;

int main(){
  std::cin.tie(nullptr);                  // 標準入出力高速化
  std::ios_base::sync_with_stdio(false);  // SとS++の入出力出力を非同期
  double h,a;
  cin>>h>>a;
  cout<<ceil(h/a)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios_base::sync_with_stdio(false);
      std::cin.tie(NULL);
      string first,second;
      std::cin >>first>>second;
      int count=0;
      for(int i=0;i<first.length();i++){
          if(first[i] != second[i])
             count++;
           }
std::cout << count << '\n';
return 0;
}


Measured memory_bytes: 3836
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=(0);i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
 
template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int N=100005;
struct node{
	int a,b,id;
	bool operator < (node &o){ return a-b<o.a-o.b; }
}x[N];
int cur[N],pa[N],n,m,u,v;
ll f[N],s[N]; vi e[N];

int getpa(int x){
	return pa[x]==x?x:pa[x]=getpa(pa[x]);
}

int main(){
	read(n),read(m);
	rep(i,1,n){
		read(x[i].a),read(x[i].b);
		x[i].id=i,x[i].a=max(x[i].a,x[i].b);
	}
	sort(x+1,x+n+1);
	rep(i,1,n)cur[x[i].id]=i;
	rep(i,1,m){
		read(u),read(v);
		e[cur[u]].pb(cur[v]);
		e[cur[v]].pb(cur[u]);
	}
	rep(i,1,n){
		pa[i]=i,f[i]=x[i].a,s[i]=x[i].b;
	}
	rep(u,1,n){
		ll mn=max(x[u].a,x[u].b),S=0;
		for(auto v:e[u])
			if(v<u&&getpa(u)!=getpa(v)){
				mn=min(mn,max((ll)x[u].a,x[u].b+f[getpa(v)])-s[getpa(v)]);
				S+=s[getpa(v)];
				pa[getpa(v)]=getpa(u);
			}
		s[getpa(u)]=S+x[u].b;
		f[getpa(u)]=S+mn;
	}
	cout<<f[getpa(1)]<<endl;
	return 0;
}

Measured memory_bytes: 9468
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
const int mod=1e9+7;
                     // I'm in Love with Experience.
void solve()
{
    ll N;cin>>N;
    ll a,b;
    ll c=0;
    bool f=false;
    while(N--)
    {
        cin>>a>>b;
        if(a!=b)c=0;
        else c++;
        
        if(c==3)f=true;
        
    }
    f ? cout<< "Yes" : cout<< "No";
}
int main(void)
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);solve();exit(0);
}/*Solved By:- Ritik Agarwal*/

Measured memory_bytes: 3632
n, k = map(int, input().split())

ans = 0
if k == 0:
    print(n * n)
    exit()

for i in range(k + 1, n + 1):
    # 周期i
    # 0 1 2 3 ... i - 1, 0,
    # 1周期にi - kこk以上

    # 1始まりなのがめんどい
    # 最初1周期だけさせる
    m = n
    m -= i - 1
    ans += i - k

    full = m // i * (i - k)
    amari = m % i  # 周期の途中でnを超える
    ans += full + max(0, amari - k)
print(ans)


Measured memory_bytes: 9156
#include<bits/stdc++.h>
using namespace std;
const int mxn = 1e5 + 5;
vector< pair< int , int > > adj[mxn] ;
vector< int > tps;

int n , m , d, l , r;

bool vis[mxn];
int dis[mxn];
void dfs(int u)
{
	vis[u] = true;
	for(int i = 0; i < adj[u].size(); i++)
	{
		int v = adj[u][i].first;
		if(vis[v]!= true)
		{
			dfs(v);
		}
	}
	tps.push_back(u);
}

int main()
{
	cin>>n;
	cin>>m;
	for(int i = 0; i < m; i++)
	{
		cin>>l>>r>>d;
		adj[l].push_back(make_pair(r , d));
	}
	memset(vis , false ,sizeof vis);
	for(int i = 1; i <= n; i++)
	{
		if(!vis[i])
		dfs(i);
	}
	reverse(tps.begin() , tps.end());
	memset(dis , -1 ,sizeof dis);
	bool flag = true;
	for(int i = 0; i < tps.size(); i++)
	{
		int u = tps[i];
		if(dis[u]==-1)
		{
			dis[u] = 0;
		}
		for(int j = 0; j < adj[u].size(); j++)
		{
			int v = adj[u][j].first;
			int d = adj[u][j].second;
			if(dis[v]==-1)
			{
				dis[v] = dis[u] + d;
			}
			else
			{
				if(dis[v]!=dis[u]+d)
				{
					flag = false;
					break;
				}
				
			}
		}
		if(!flag)
		break;
	}
	if(flag)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
	return 0;
}


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

int main(void) {
   long N;
   cin>>N;
   long Nsq = long(sqrt(N));
   // cout<<Nsq<<endl;

   long min_step = N+5;
   for (int i = 1; i<=Nsq;i++) {
      if (N%i ==0) {
         min_step = min(min_step,N/i+i);
         // cout<<min_step<<endl;
      }
   }
   cout<<min_step-2<<endl;
   return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<algorithm>

#define ll long long
#define sz 10005

using namespace std;

int main()
{
    ll a,b,arr[sz];

    scanf("%lld %lld",&a,&b);

    for(ll i=0;i<a;i++)
    {
        scanf("%lld",&arr[i]);
    }

    sort(arr, arr+a, greater<ll>());

    ll sum=0;

    for(ll i=0;i<b;i++)
    {
        sum+=arr[i];
    }

    printf("%lld\n",sum);

    return (0);
}


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

int main(){
  int n,m,x,y,a,b,c;
  scanf("%d%d",&n,&m);
  
  scanf("%d",&x);
  vector<int> e(n+1);
  for(int i=1;i<m;i++){
    scanf("%d",&y);
    if(x<y)e[x]++, e[y]--;
    else e[x]--, e[y]++;
    x = y;
  }

  ll ans = 0, num = 0;
  for(int i=1;i<n;i++){
    scanf("%d%d%d",&a,&b,&c);
    num += e[i];
    ans += min(num*a, num*b+c);
  }
  printf("%lld\n",ans);
}

Measured memory_bytes: 1532
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<pii, int> ppiii;

vector<int> edges[100005];

int dfs(int curr, int par=-1) {
  int ans = 0;
  int sz = 0;
  for(int out: edges[curr]) {
    if(out == par) continue;
    ans ^= dfs(out, curr)+1;
  }
  return ans;
}

void solve() {
  int n;
  cin >> n;
  for(int i = 1; i < n; i++) {
    int a, b;
    cin >> a >> b;
    edges[a].push_back(b);
    edges[b].push_back(a);
  }
  int ret = dfs(1);
  if(ret != 0) cout << "Alice\n";
  else cout << "Bob\n";
}

void casesolve() {
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  // casesolve();
}


Measured memory_bytes: 10368
#include <iostream>
using namespace std;
int main(){
	int a,b,c,d,count=0;
	cin>>a>>b>>c>>d;
	int i,j,k;
	for(i=0; i<=a; i++){
		for(j=0; j<=b; j++){
			for(k=0; k<=c; k++){
				if(500*i+100*j+50*k==d) count++;
			}
		}
	}
	cout<<count;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
#include<stack>
#include<fstream>
#include<stdlib.h>
#include<set>
#include<climits>
#include<cmath>  
#include<memory.h> 
#include<sstream>
#include<time.h>
#include<iomanip>
using namespace std;
const unsigned long long BIGEST=1000000000000000000+1000000000000000000;
const long long BIGER=1000000000000000000;
const int BIG=1000000000;
const long long MOD=1004535809;
const long long LMOD=154590409516822759;
//const long long LMOD=1000000007;
#define Fi first
#define Se second
#define P2 pair
#define Pii pair<int,int>
#define Pll pair<long long,long long>
#define Cb make_pair
#define ll long long
#define Ull unsigned long long
#define Sf scanf
#define Pf printf
#define Pb push_back
#define Psh push
#define Stc stack
#define Vct vector
#define Ret return
#define Re0 return 0
#define Sz size
#define Is insert
#define Que queue
#define Emp empty
#define Fro front
#define Rv reverse
#define Er erase
#define Bg begin
#define Srt sort
#define Pq priority_queue
#define Ins insert
#define Ite iterator
#define Cou count
#define Cot continue
#define Beg begin
int main()
{
	int n;
	cin>>n;
	string a;string b;
	cin>>a>>b;
	for(int i=0;i<n;i++)
	{
		cout<<a[i]<<b[i];
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int a = 0, b = 0, c = 0, d = 0, A = 0, B = 0, C = 0, D = 0;
	double tmp, tmp2;
	while (cin >> tmp >> tmp2)
	{	
		if (tmp >= 1.1)
			a++;
		else if (0.6 <= tmp)
			b++;
		else if (0.2 <= tmp)
			c++;
		else
			d++;

		if (tmp2 >= 1.1)
			A++;
		else if (0.6 <= tmp2)
			B++;
		else if (0.2 <= tmp2)
			C++;
		else
			D++;
	}
	cout << a << " " << A << endl << b << " " << B << endl << c << " " << C << endl << d << " " << D << endl;
}

Measured memory_bytes: 1228
#include<bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
const ll mod = 1000000007;
// const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"
#define TO_STRING(VariableName) # VariableName

bool solve(){
	int x,y;cin>>y>>x;
	if((x-2*y)%2!=0){
		cout<<"No"<<endl;
	}
	else if((x-2*y)/2<0){
		cout<<"No"<<endl;
	}else if((x-2*y)/2>y){
		cout<<"No"<<endl;
	}else cout<<"Yes"<<endl;
	
  	return false;
}

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout<<fixed<<setprecision(15);
  solve();
}


Measured memory_bytes: 3648
// Starting with the name of Allah

#include <bits/stdc++.h>
#define ll long long
#define nl endl
#define Nayon ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define gcd(a,b)         __gcd(a,b)
#define lcm(a,b)         (a/gcd(a,b))*b


using namespace std;




int main()
{
	Nayon;
	ll i,j,k,n,cnt=0;
	cin>>n;
	ll a[n+1];
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	for(i=0;i<n;i++){
		for(j=i+1;j<n;j++){
			for(k=j+1;k<n;k++){
				if(a[i]==a[j] || a[i]==a[k] || a[j]==a[k]){
					continue;
				}
				else{
					if(a[i]+a[j]>a[k]){
						cnt++;
					}
				}
			}
		}
	}
	cout<<cnt<<nl;
}


Measured memory_bytes: 3548
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
//#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define SZ(X) ((int64_t)((X).size()))
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define intmax (std::numeric_limits<int64_t>::max() / 4)
#define doublemax (std::numeric_limits<double>::max() / 4)
using namespace std;
//typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);



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

	int N;
	cin >> N;
	string s;
	cin >> s;

	rep(c1, 2)rep(c2, 2) {
		string ans;
		ans.push_back(c1 ? 'S' : 'W');
		ans.push_back(c2 ? 'S' : 'W');
		for (int i = 1; i < N; i++) {
			//ans[i-1]とans[i]は決まっている。
			//s[i]をもとにans[i+1]を決める。
			if (ans[i] == 'S') {
				if (s[i] == 'o') {
					ans.push_back(ans[i - 1]);
				}
				else {
					ans.push_back(ans[i - 1] == 'S' ? 'W' : 'S');
				}
			}
			else {
				if (s[i] == 'o') {
					ans.push_back(ans[i - 1] == 'S' ? 'W' : 'S');
				}
				else {
					ans.push_back(ans[i - 1]);
				}
			}
		}
		if (ans[N] != ans[0])continue;
		if (ans[0] == 'S') {
			if (s[0] == 'o') {
				if (ans[N - 1] != ans[1])continue;
			}
			else {
				if (ans[N - 1] == ans[1])continue;
			}
		}
		else {
			if (s[0] == 'o') {
				if (ans[N - 1] == ans[1])continue;
			}
			else {
				if (ans[N - 1] != ans[1])continue;
			}
		}

		rep(i, N)cout << ans[i];
		cout << endl;
		return 0;
	}

	cout << -1 << endl;

	return 0;
}



Measured memory_bytes: 748
#include<bits/stdc++.h>
using namespace std;
int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin>>t;
  map<string,int> mapp;
  while(t--)
  {
    string s;
    cin>>s;
    mapp[s]++;
  }
  int ans = 0;
  for(auto i : mapp)
  {
    ans++;
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 19240
#include <bits/stdc++.h>
#define sanyes ios_base::sync_with_stdio(0), cout.tie(0); cin.tie(0);
#define llong long long
#define pb push_back
#define bpc __builtin_popcount

const llong mxn = 1e5 + 7;
const llong mod = 998244353;
const llong inf = 1e18 + 9;

using namespace std;

llong n, k, dp[101][mxn], w[mxn], v[mxn], mx = -inf;

int main (){
    cin >> n >> k;
    for (int i = 1; i <= n; i ++){
        cin >> w[i] >> v[i];
    }for (int i = 1; i <= n; i ++){
        for (int j = 1; j <= k; j ++){
            if(j >= w[i]){
                dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);
            }else{
                dp[i][j] = dp[i - 1][j];
            }
        }
    }cout << dp[n][k];
    return 0;
}

Measured memory_bytes: 78720
import java.util.Scanner;

public class Main {
	 
	    public static void main(String[] args){
	        Scanner scan = new Scanner(System.in);
	        int i = 1;
	        while (true){   
	            int a = scan.nextInt();
	            if(a == 0){
	                break;
	            }else{
	                System.out.println("Case"+" "+i+":"+" "+a);
	                i= i + 1;
	            }
	        }
	   }
	}

Measured memory_bytes: 33024
from heapq import heapify, heappop, heappush
N, M, K = map(int, input().split())
A, B, C = map(int, input().split())
T = int(input())
S = [int(input())-1 for i in range(M)]

def f(rt, rn):
    return min(rt // A, rn-1)

ans = 0
que = []
for i in range(M-1):
    s0 = S[i]; s1 = S[i+1]
    if B*s0 <= T:
        rt = T - B*s0; rn = s1-s0
        k = f(rt, rn)
        ans += k+1

        rt -= (k+1)*C; rn -= k+1
        k0 = f(rt, rn)

        if k0 >= 0:
            que.append((-k0, rt, rn))
if B*S[-1] <= T:
    ans += 1
heapify(que)

for i in range(K-M):
    if not que:
        break
    k, rt, rn = heappop(que); k = -k
    rt -= (k+1)*C; rn -= k+1
    ans += k+1

    k0 = f(rt, rn)
    if k0 >= 0:
        heappush(que, (-k0, rt, rn))
print(ans-1)



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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a;
    cin >> a ;
    cout << a * a << endl;
    return 0;
}

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

namespace ConsoleApplication58
{
    class Program
    {
        static void Main()
        {
            int[] s = new int[100];
            while (true)
            {
                string a = Console.ReadLine();
                if (a == "0,0") break;
                s[int.Parse(a.Split(',')[0]) - 1] += int.Parse(a.Split(',')[1]);
            }
            while (true)
            {
                string b = Console.ReadLine();
                if (b == null) break;
                int c = s[int.Parse(b) - 1];
                int[] t=new int[100];
                for(int u = 0; u < 100; u++)
                {
                    t[u] = s[u];
                }
                Array.Sort(t);
                Array.Reverse(t);
                int r = t[0], l = 1, x=0;
                for(x = 0; x < t.Length; x++)
                {
                    if (t[x] != r) { r = t[x];l++; }
                    if (t[x] == c) { Console.WriteLine(l); break; }
                }
            }
        }
    }
}

Measured memory_bytes: 9204
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

class Program{
  public static void Main(){

    var input = Console.ReadLine().Split();
    int x = int.Parse(input[0]);
    int a = int.Parse(input[1]);
    int b = int.Parse(input[2]);
    
    string ans;
    if(a >= b) ans = "delicious";
    else if(a + x >= b) ans = "safe";
    else ans = "dangerous";
    
    Console.WriteLine(ans);

  }
}

Measured memory_bytes: 11092
import itertools

def main():
    n,m=map(int,input().split())
    k = []
    for _ in range(m):
        k.append(list(map(int, input().split())))
    p = list(map(int, input().split()))
    count = 0
    for s in itertools.product([0,1], repeat=n):
        for i,kk in enumerate(k):
            if not is_on(s, kk[1:], p[i]):
                break
        else:
            #print(s)
            count += 1
    print(count)

def is_on(s, cond, p):
    count = 0
    for c in cond:
        count += s[c-1]
    return count % 2 == p
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
using P = pair<int,int>;
using ll = long long;
static const int INF = 1000000000;
static const ll MOD = 1000000007;

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

int main(){
	string a, b;
	cin >> a >> b;
	a += b;
	int v = 0;
	for(int i = 0; i < a.size(); ++i){
		v += a[i] - '0';
		v *= 10;
	}
    v /= 10;
	for(int i = 0; i < 500; ++i){
		if(i * i == v){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}



Measured memory_bytes: 256
import java.util.*;
 
public class Main{
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    String[] S = sc.nextLine().split(" ");
    int N = Integer.parseInt(S[0]);
    int D = Integer.parseInt(S[1]);
    int[][] num = new int[N][D];
    for(int i = 0; i < N; i++){
      String[] T = sc.nextLine().split(" ");
      for(int j = 0; j < D; j++){
        num[i][j] = Integer.parseInt(T[j]);
      }
    }
    
    int count = 0;
    for(int i = 0; i < N; i++){
      for(int j = i; j < N; j++){
        if(i != j){
          int b = 0;
          for(int k = 0; k < D; k++){
            b += (num[i][k] - num[j][k])*(num[i][k] - num[j][k]);
          }
          int a = (int)Math.sqrt(b);
          if((a*a) == b){
            count++;
          }
        }
      }
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 21716
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <iostream>

#define INF 2000000000
#define MOD
using namespace std;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("inout.txt", "w", stdout);
    string s;
    cin >> s;
    for (int i = 0; i < 26; i++) {
        char c = 'a' + i;
        int prev = -1;
        for (int j = 0; j < s.length(); j++) {
            if (s[j] == c) {
                if (prev != -1) {
                    if (j - prev <= 2) {
                        cout << prev + 1 << " " << j + 1 << endl;
                        return 0;
                    } else {
                        prev = j;
                    }
                } else {
                    prev = j;
                }
            }
        }
    }
    cout << "-1 -1" << endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <set>
#include <vector>
#include <algorithm>
#include <bitset>
#define ll long long
using namespace std;


int main(){
 string s;cin>>s;
 if(s[0] != 'A') {
     cout<<"WA"<<endl;
     return 0;
 }

 bool Cflag = false;
 bool sizeFlag = true;

 set <char> a;
 for(char i='a';i<='z';i++) a.insert(i);


 for(int i=1;i<s.size();i++){
     if(Cflag == true and s[i]=='C') {
         cout<<"WA"<<endl;
         return 0;
     }
     if(s[i] == 'C' and i != s.size()-1 and i>=2) {Cflag = true ;continue;}
     if(a.find(s[i]) != a.end())  continue;
     sizeFlag = false;
 }

 if(sizeFlag == true and Cflag== true) cout<<"AC"<<endl;
 else cout<<"WA"<<endl;

    return 0;
}

 


Measured memory_bytes: 256
w, h, n = map(int, input().split())
li = list()
for _ in range(n):
    li.append(list(map(int, input().split())))

l = 0
r = w
d = 0
u = h

for x in li:
    if(x[-1] == 1):
        l = max(l, x[0])
    elif (x[-1] == 2):
        r = min(r, x[0])
    elif (x[-1] == 3):
        d = max(d, x[1])
    else:
        u = min(u, x[1])

print(max(0, (r - l)) * max(0, (u - d)))


Measured memory_bytes: 3064