akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
 
int flagCheck(int A[], bool flag[], int N)
{
	int num = 0;
	for(int i=0; i<N; i++){
		if(A[i]<400) flag[0] = true;
		else if (A[i]<800 && A[i]>=400) 
			flag[1] = true;
		else if (A[i]<1200 && A[i]>=800) 
			flag[2] = true;
		else if (A[i]<1600 && A[i]>=1200) 
			flag[3] = true;
		else if (A[i]<2000 && A[i]>=1600) 
			flag[4] = true;
		else if (A[i]<2400 && A[i]>=2000) 
			flag[5] = true;
		else if (A[i]<2800 && A[i]>=2400) 
			flag[6] = true;
		else if (A[i]<3200 && A[i]>=2800) 
			flag[7] = true;
		else num ++;
	}
	return num;
}
 
int main()
{
	int A[100], N, num, min=0, max=0;
	bool flag[8];
	for(int i=0; i<8; i++){
		flag[i] = false;
	}
	scanf("%d", &N);
	for(int i=0; i<N; i++){
		scanf("%d", &A[i]);
	}
	num = flagCheck(A, flag, N);
	for(int i=0; i<8; i++){
		if(flag[i]){
			min ++;
		}
	}
	max = min+num;
	if(min == 0) min = 1;
	printf("%d %d\n", min, max);
	return 0;
}

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

#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define si set<int>
#define mi map<int,int>
#define mll map<long long,long long>
#define qi queue<int>
#define pb push_back
#define mod %
#define pow ^
#define pnode struct node
#define pair_int pair<int,int>
#define pair_ll pair<long,long>
#define pq priority_queue

int dp[100001];

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

   int n,k;
   cin >> n >> k;
   int x;
   vi v;
   for (int i = 0; i < n; ++i)
   {
      cin >> x;
      v.pb(x);
   }
   sort(v.begin(), v.end());
   for (int i = v[0]; i <= k; i++)
   {
      for(int j=0;j<=n-1;j++)
      {
         if(v[j] > i)
            continue;

         if(dp[i-v[j]]==0)
         {
            dp[i]=1;
         }
      }
     
      // cout << dp[i] << "\n";
   }
   if(dp[k]==1)
   {
      cout << "First" << "\n";
   }
   else
   {
      cout << "Second" << "\n";
   }
   return 0;
}


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

typedef pair<int,int> P;

int a[200005];
vector<int>v[200005];

queue<P>q;
bool vis[200005];


int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
    {
        int q,w;
        scanf("%d%d",&q,&w);
        v[q].push_back(w);
        v[w].push_back(q);
    }
    vis[1]=true;
    q.push(P(1,0));
    int ans=0x3f3f3f3f;
    while(!q.empty())
    {
        P pai=q.front();
        q.pop();
        if(pai.second==3)
            break;
        if(pai.first==n)
        {
            ans=pai.second;
            break;
        }
        for(int i=0;i<v[pai.first].size();i++)
            if(vis[v[pai.first][i]]==false)
        {
            vis[v[pai.first][i]]=true;
            q.push(make_pair(v[pai.first][i],pai.second+1));
        }
    }
    if(ans>2)
        puts("IMPOSSIBLE");
    else
        puts("POSSIBLE");
    return 0;
}


Measured memory_bytes: 13040
a,b,c,x,y = map(int, input().split())

base = a * x + b * y

if x < y:
    t = y
else:
    t = x
    
for i in range(t+1):
    money = a * max(0, x - i) + b * max(0, y - i) + 2 * c * i 
    if money < base:
        base = money

print(base)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {

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

    int m; cin >>m;
    vector<int> p(m); vector<int> x(m);
    REP(i,m) cin >> p[i] >> x[i];

    for (int i = 0; i < m; i++) {
        cout << sum - t[p[i]-1] + x[i] << endl;
    }

    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=1e9+7,num,ans;
string s;
ll qpow(ll a,ll b){
	ll res=1;
	while(b){
		if(b&1) res=res*a%mod;
		b/=2;
		a=a*a%mod;
	}
	return res%mod;
}
int main(){
	cin>>s;
	ll n=s.length();
	for(int i=0;i<s.length();i++){
		if(s[i]=='1'){
			ans=(ans%mod+qpow(2,num)%mod*qpow(3,n-i-1)%mod)%mod;
			num++;
		}
	}
	cout<<(ans%mod+qpow(2,num)%mod)%mod<<endl;

}

Measured memory_bytes: 512
// clang-format off
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i,n) for(ll i=n-1; i>=0; --i)
#define rrep1(i,n) for(ll i=n; i>0; --i)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define SORT_DESC(x) sort(all(x), greater<>())
#define pb push_back
#define mp make_pair
#define coutl cout<<fixed<<setprecision(10)
#define ANS(ans) cout<<ans<<endl;
#define INF 1e9;
#define LINF 1e18;
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;}
// clang-format on

void solve(long long N, std::string S) {
  ll ans = 0;
  rep(i, N - 2) {
    if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C')
      ans++;
  }
  ANS(ans);
}

// clang-format off
int main() {
  long long N;
  scanf("%lld",&N);
  std::string S;
  std::cin >> S;
  solve(N, S);
  return 0;
}


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

int n, k;
typedef vector<int> perm;
perm operator + (const perm &a, const perm &b) {
  perm c(n, 0);
  for (int i = 0; i < n; i++) {
    c[i] = b[a[i]];
  }
  return c;
}
perm operator ~ (const perm &a) {
  perm c(n);
  for (int i = 0; i < n; i++) {
    c[a[i]] = i;
  }
  return c;
}

int main() {
  scanf("%d%d", &n, &k);
  perm a(n), b(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    --a[i];
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &b[i]);
    --b[i];
  }
  perm p = ~b + a + b + ~a, q(n);
  vector<int> visit(n, 0), d;
  for (int i = 0; i < n; i++) {
    if (!visit[i]) {
      d.clear();
      int j = i;
      do {
        d.push_back(j);
        visit[j] = 1;
        j = p[j];
      } while (j ^ i);
      for (int j = 0; j < (int) d.size(); j++) {
        q[d[j]] = d[(j + (k - 1) / 6) % d.size()];
      }
    }
  }
  a = q + a + ~q;
  b = q + b + ~q;
  for (int t = (k - 1) % 6; t; t--) {
    perm c = ~a + b;
    a = b, b = c;
  }
  for (int i = 0; i < n; i++) {
    printf("%d%c", a[i] + 1, i == n - 1 ? '\n' : ' ');
  }
}


Measured memory_bytes: 3920
#include<iostream>
#include<vector>
#include<algorithm> // sort,reverse,min,lower_bound

using namespace std;
#define df 0
#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
typedef long int li;

li judge(li temp,const vector<li>& f,const vector<li>& a){
  if(df)printf("judge %ld-> ",temp);
  li cnt=0;
  rep(i,f.size()){
    li b=temp/f.at(i);
    if(b<a.at(i)){
      cnt+=a.at(i)-b;
      if(df)printf("+%ld(%d-%d)",a.at(i)-b,a.at(i),b);
    }
  }
  if(df)printf("=%ld\n",cnt);
  return cnt;
}

int main(){
  if(df) printf("*debug mode*\n");
  int n;li k; cin >>n >>k;
  vector<li> a(n),f(n);
  for(li& x: a) cin >>x;
  for(li& x: f) cin >>x;
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  if(df){
    for(li x: a) printf("%ld ",x);
    printf("\n");
  }
  sort(f.begin(),f.end());
  if(df){
    for(li x: f) printf("%ld ",x);
    printf("\n");
  }
  li ok=*(a.begin())*(*(f.rbegin())),ng=-1;
  if(df)printf("max:%ld\n",ok);
  while(ok-ng>1){
    li temp=(ok+ng)/2;
    if(judge(temp,f,a)<=k)
      ok=temp;
    else ng=temp;
  }
  cout << ok;
}

/// confirm df==0 ///


Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  	int N,K;
    cin >> N >> K;
  	int num = 1;

  	for(int i=0;i<N;i++){
     	if(num<K)
        	num *= 2;
      	else
        	num += K;
    }
  cout << num;
}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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; }

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

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

  set<ll> st;
  int N;
  cin >> N;
  ll a;
  rep(i, N){
    cin >> a;
    st.insert(a);
  }  

  if(st.size() == N){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }

  return 0;
}


Measured memory_bytes: 9600
A,B,C,D= map(int,input().split())
import fractions

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)




c_w = B//C

if A%C==0:
    c_w -= A//C - 1
if A%C!=0:
    c_w -= A//C 
d_w = B//D

if A%D==0:
    d_w -= A//D - 1
if A%D!=0:
    d_w -= A//D

E = lcm(C,D)

cd_w = B//E

if A%E==0:
    cd_w -= A//E - 1
if A%D!=0:
    cd_w -= A//E

# print(c_w,d_w,cd_w)
print(B-A+1-c_w-d_w+cd_w)



Measured memory_bytes: 5104
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))
#define Endl endl

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

int ceil_(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); }
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * ceil_(a, b)); }
int bpm(int x, unsigned int y) {
  if (x == 0) return 0;
  if (y == 0) return 1;
  int ans   = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}
template <class T>
void cumulative_sum(T &container) {
  for (int i = 0; i < container.size() - 1; i++) container[i + 1] += container[i];
}

class DTeleporter {
public:
  static void solve(std::istream &cin, std::ostream &cout) {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    int first;
    int now = 1;
    int num;
    vector<int> temp{};
    map<int, int> where{};
    FOR(i, 1, 10000000) {
      temp.emplace_back(now);
      if (where[now]) {
        num   = i - where[now];
        first = where[now] - 1;
        break;
      }
      where[now] = i;
      now        = A[now - 1];
    }
    if (K >= first){
      cout << temp[(K - first) % num + first] << endl;
    }else{
      cout<<temp[K]<<endl;
    }
  }
};


signed main() {
  DTeleporter solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


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


using namespace std;

typedef long long ll;



int main() {
    ll n;
    cin >> n;
    vector<ll>arr( n + 1);
    for(ll i = 1; i <= n; i++)cin >> arr[i];
    vector<ll> dp(n + 1);
    dp[2] = abs(arr[1] - arr[2]);
    for(ll i = 3; i <= n; i++){
        dp[i] = min(abs(arr[i] - arr[i - 1]) + dp[i - 1], abs(arr[i] - arr[i - 2]) + dp[i - 2]);
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 4812
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
#include <iostream>
#include <math.h>
using namespace std;
int main ()
{
	int a,b,r=1;
	scanf("%i",&a);
	int i=1,j=2;
	if(a==1)
	{
		printf("1");
		return 0;
	}
	else
	{
		for(i=2;i<=100;i++)
		{
			for(j=1;j<=100;j++)
			{
				if((int)round(pow(j,i))>a)
				{
					if((int)round(pow(j-1,i))>=r)
					{
						r=(int)round(pow(j-1,i));
					}
					break;
				}
				else if((int)round(pow(j,i))==a)
				{
					printf("%i",(int)round(pow(j,i)));
					return 0;
				}
			}
		}
	}
	printf("%i",r);
	return 0;
}


Measured memory_bytes: 256
mod=10**9+7

N=int(input())
A=list(map(int,input().split()))
B=[0]
for x in A:
  B.append(B[-1]+x)

ans=0
for i in range(N):
  s=(B[N]-B[i+1])%mod
  ans+=A[i]*s
  ans%=mod

print(ans)


Measured memory_bytes: 31504
#include <stdio.h>

int main(void)
{
	int N;
	int k;
	int max;
	int n;
	int i;
	
	while (1){
		scanf("%d", &N);
		if (N == 0){
			break;
		}
		
		n = 0;
		max = 0;
		for (i = 0; i < N; i++){
			scanf("%d", &k);
			
			if (k > 0){
				n++;
			}
			if (k > max){
				max = k;
			}
		}
		
		if (N == 1 && max >= 2){
			printf("2\n");
		}
		else if (max <= 1){
			printf("NA\n");
		}
		else {
			printf("%d\n", n + 1);
		}
	}
	
	return (0);
}

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

int main(void)
{
    int count[26] = {};
    char c;
    
    while (cin >> c) {
        if ('a' <= c && c <= 'z')
            ++count[c - 'a'];
        else if ('A' <= c && c <= 'Z')
            ++count[c - 'A'];
    } 
    
    for (int i=0; i<26; ++i)
        cout << char('a'+i) << " : " << count[i] << endl;
        
    return 0;
}


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

#ifdef LOCAL
	#define D(a) cerr << #a << " = " << a << endl
#else
	#define D(a)
	#define cerr false && cerr
#endif
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define dforsn(i,s,n) for(int i=int(n-1);i>=int(s);i--)
#define forsn(i,s,n) for(int i=int(s);i<int(n);i++)
#define dforn(i,n) dforsn(i,0,n)
#define forn(i,n) forsn(i,0,n)
#define all(a) a.begin(),a.end()
#define si(a) int((a).size())
#define pb emplace_back
#define mp make_pair
#define snd second
#define fst first
#define endl '\n'
using pii = pair<int,int>;
using vi = vector<int>;
using ll = long long;

int main() {
	fastio;
	
    int n, m = 0, res = 0; cin >> n;
    forn(i,n){
        int x; cin >> x;
        m = max(m,x);
        if(x >= m) res++;
    }
	cout << res << endl;
	return 0;
}


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

int main(void){
    int a,b,k;
    cin>>k>>a>>b;
    cerr<<(a+(k-a%k))<<endl;
    if(k==1){cout<<"OK"<<endl;}
    else if((a+(k-a%k))<=b)cout<<"OK"<<endl;
    else if(a%k==0||b%k==0)cout<<"OK"<<endl;
    else cout<<"NG"<<endl;
}

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

int read(){
	int x=0; char c; int flag=1;
	for(c=getchar();!isdigit(c);c=getchar()) if(c=='-') flag=-1;
	for(;isdigit(c);c=getchar()) x=((x+(x<<2))<<1)+(c^48);
	return x*flag;
}

const int N=505;
int n;

struct node{
    int id,v;
}a[N];
bool cmp(node a,node b) { return a.v<b.v; }

int f[N*N];
int ps;

int main() {
    n=read();
    for(int i=1;i<=n;i++) a[i].v=read(),a[i].id=i,f[a[i].v]=i;
    
    sort(a+1,a+n+1,cmp);
    
    bool flag=1;
    ps=0;
    for(int i=1;i<=n;i++){
    	for(int j=1;j<=a[i].id-1;j++) 
		{ while(f[ps+1]) ps++; f[ps+1]=a[i].id; }
	    if(ps>=a[i].v) { flag=0; break; }
	}
	if(!flag) { puts("No"); return 0; }
	
	ps=n*n+1;
	for(int i=n;i>=1;i--){
		for(int j=1;j<=n-a[i].id;j++)
		{ while(f[ps-1]) ps--; f[ps-1]=a[i].id; }
	    if(ps<=a[i].v) { flag=0; break; }
	}
	if(!flag) { puts("No"); return 0; }
	
	puts("Yes");
	for(int i=1;i<=n*n;i++) printf("%d ",f[i]);
	return 0;
}


Measured memory_bytes: 2176
#include <algorithm>
#include <cstdio>
#include <climits>
#include <vector>
using namespace std;

int chid(char ch) {int ret = ch; if(ret<=0) ret+=256; return ret;}

int main() {
    while(true) {
        int n; scanf("%d\n", &n);
        if(n==0) break;
        static char transl[256];
        for(int i = 0; i < 256; i++) transl[i] = i;
        for(int i = 0; i < n; i++) {
            char x,y; scanf("%c %c\n", &x, &y);
            transl[chid(x)] = y;
        }
        int m; scanf("%d\n", &m);
        for(int i = 0; i < m; i++) {
            char a; scanf("%c\n", &a);
            printf("%c", transl[chid(a)]);
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 0
#pragma GCC diagnostic ignored "-Wreturn-type"
#include<bits/stdc++.h>
#include<cstdio>
#include<limits>
#define deb(x) cout<<#x<<'='<<(x)<<endl
#define deb2(x,y) cout<<'['<<#x<<'='<<(x)<<','<<#y<<'='<<(y)<<']'<<endl
#define debmap(v) {cout<<#v<<'=';for(auto p:v)cout<<'('<<p.first<<','<<p.second<<") ";cout<<endl;}
#define debarr(a,n) {cout<<#a<<'='; for(int i=0;i<n;i++) cout << a[i] << ' '; cout<<endl;}
#define deb2darr(a,n,m) {cout<<#a<<"=\n";for(int i=0;i<n;i++){for(int j=0;j<m;j++)cout<<a[i][j]<<' ';cout<<endl;}}
#define debvec(v) {cout<<#v<<'=';for(auto itr=v.begin();itr!=v.end();itr++)cout<<*itr<<' ';cout<<endl;}
#define deb2dvec(v) {cout<<#v<<"=\n";for(auto x:v){for(auto y:x)cout<<y<<' ';cout<<endl;}}
#define ll long long
#define int long long
#define INF numeric_limits<int>::max()
#define NINF numeric_limits<int>::min()
using namespace std;

void solve(){
	int n;
	cin>>n;
	if(n%1000==0)
		cout<<0<<endl;
	else
		cout<<1000-(n%1000)<<endl;
}

main(){
	//ios_base::sync_with_stdio(false);
	//cin.tie(NULL);

	int T=1;
	while(T--){
		solve();
	}
}



Measured memory_bytes: 3632
N, K = map(int, input().split())
a = [int(i) for i in input().split()]


cand = []
for i in range(N):
    sum = 0
    for j in range(i, N):
        sum += a[j]
        cand.append(sum)


def countMask(a):
    ret = 0
    for x in cand:
        if (x & a) == a:
            ret += 1
    return ret


ans = 0

for i in range(40, -1, -1):
    if (countMask(ans | (1 << i)) >= K):
        ans |= 1 << i

print(ans)


Measured memory_bytes: 28848
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define INF 0x3f3f3f3f
using namespace std;
int n,m,x,y,dis[100001],ans;
vector<int> v[100001];
int dfs(int x)
{
	if (dis[x]!=-1) return dis[x];
	int ret=0;
	for (int i=0;i<v[x].size();i++) ret=max(ret,dfs(v[x][i])+1);
	return dis[x]=ret;
}
int main()
{
	cin>>n>>m;
	for (int i=0;i<=n;i++) dis[i]=-1;
	for (int i=0;i<m;i++) cin>>x>>y,v[x].pb(y);
	for (int i=1;i<=n;i++) ans=max(ans,dfs(i));
	cout<<ans;
	return 0;
}

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

using namespace std;

int main()
{
	long long count = 0, ans = 0;
	string A;
	cin >> A;

	const int num = 26;
	int chars[num];
	vector<long long> table(A.size());

	for (int i = 0; i < num; i++)
	{
		chars[i] = 0;
	}

	table[0] = 1;
	for (int i = 1; i < A.size(); i++)
	{
		table[i] = table[i - 1] + (i + 1);
	}

	for (int i = 0; i < A.size(); i++)
	{
		chars[A[i] - 'a']++;
	}

	for (int i = 0; i < num; i++)
	{
		if (chars[i] == 0)
			continue;

		count += table[chars[i] - 1];
	}

	for (int i = 1; i < A.size(); i++)
	{
		ans += i;
	}
	ans =  table[A.size() - 1] - count + 1;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 2180
import java.util.*;
public class Main {
	Scanner sc = new Scanner(System.in);
	int a,b,c,d,e,f,k,l,m,n,x,y,z;
	int ans;
	String[] S;

	Main(){
		// 整数の入力
		n = sc.nextInt();

		for(int i=1;i<=n;i++){
			int num=i;
			int j=0;
			while(num>0){
				num/=10;
				j++;
			}
			ans+=j%2==1?1:0;
		}

		// 出力
		System.out.println(ans);
	}

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

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

int main(){
    ll w,h,x,y; cin >> w >> h >> x >> y;
    bool t=0;
    if(w/2==x && (w+1)/2==x && h/2==y && (h+1)/2==y){
        t=1;
    }
    double s=w*h/2;
    if(w%2==1 & h%2==1) s+=0.5;
    cout << s << " " << t << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b; cin >> a >> b;
  int joined;
  if (b < 10) joined = a * 10 + b;
  else if (b < 100) joined = a * 100 + b;
  else joined = a * 1000 + b;
  for (auto i = 1; i <= 1000; i++) {
    if (joined == i * i) {
      puts("Yes");
      return 0;
    }
  }
  puts("No");
}


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

int main()
{
    ll T ;
    cin >> T ;
    vector <double> X ;
    vector <double> Y ;
    for(ll i = 0 ; i < T ; i++)
    {
        double G ;
        cin >> G ;
        X.push_back(G) ;
    }
    for(ll i = 0 ; i < T ; i++)
    {
        double G ;
        cin >> G ;
        Y.push_back(G) ;
    }
    double ans1 = 0.00 , ans2 = 0.00 , ans3 = 0.00 , ans4 = abs(X[0] - Y[0]) ;
    for(ll i = 0 ; i < T ; i++)
    {
        ans1 += abs(X[i] - Y[i]) ;
    }
    for(ll i = 0 ; i < T ; i++)
    {
        ans2 += abs(X[i] - Y[i])*abs(X[i] - Y[i]) ;
    }
    ans2 = sqrt(ans2) ;
    for(ll i = 0 ; i < T ; i++)
    {
        ans3 += abs(X[i] - Y[i])*abs(X[i] - Y[i])*abs(X[i] - Y[i]) ;
    }
    ans3 = cbrt(ans3) ;
    for(ll i = 1 ; i < T ; i++)
    {
        if(abs(X[i] - Y[i]) > ans4) ans4 = abs(X[i] - Y[i]) ;
    }
    printf("%.6lf\n" , ans1) ;
    printf("%.6lf\n" , ans2) ;
    printf("%.6lf\n" , ans3) ;
    printf("%.6lf\n" , ans4) ;
}


Measured memory_bytes: 3428
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_macros)]
#![allow(unused_variables)]
#![allow(unused_imports)]
#![allow(dead_code)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        N: usize,
        xu: [(f64, String); N]
    }
    let mut ret = 0.0_f64;
    for i in 0..N {
        ret += if &*xu[i].1 == "JPY" { xu[i].0 } else { xu[i].0 * 380000.0 };
    }

    println!("{}", ret);
}



Measured memory_bytes: 4352
//AOJ0555

#include <iostream>
#include <string>
using namespace std;

int main(){
  string wont;
  cin>>wont;

  int ring,cnt1=0,cnt2=0;
  cin>>ring;

  string str;

  for(int i=0;i<ring;i++){
    cin>>str;
    str=str+str;
    cnt1=str.find(wont);
    if(cnt1==string::npos){}
    else{
      cnt2++;
    }
  }
cout<<cnt2<<"\n";

 return 0;
}

Measured memory_bytes: 1216
N = int(input())
m = len(str(N))

ans = 0
if m > 1:
    for i in range(0, m - 1, 2):
        ans += 9 * (10 ** i)

if m % 2 == 1:
    ans += N - 10 ** (m - 1) + 1

print(ans)

Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
	float a, b, c, d, e, f;
	float x, y;
	
	while (scanf("%f %f %f %f %f %f", &a, &b, &c, &d, &e, &f) != EOF){
		y = ((c * d) - (a * f)) / ((b * d) - (a * e));
		x = (c - (b * y)) / a;
		printf("%.3f %.3f\n", x, y);
	}
	
	return (0);
}

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

using namespace std;

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Ti = tuple<int, int, int>;
using Tl = tuple<ll, ll, ll>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
#define Get(t, i) get<(i)>((t))
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, f, n) for(int i = (int)(f); i < (int)(n); i++)
#define each(a, b) for(auto& a : b)

const int inf = 1 << 25;
const ll INF = 1LL << 55;

struct edge
{
  int to, weight;
  edge(){}
  edge(int to, int weight):to(to), weight(weight){}
};

using Pi = pair<int, int>;
using Graph = vector< vector<edge> >;
  
Pi dfs(Graph& graph, int cur, int prev)
{
  Pi ret = Pi(0, cur);
  for(edge e : graph[cur]) {
    if(e.to != prev) {
      Pi dist = dfs(graph, e.to, cur);
      dist.first += e.weight;
      ret = max(ret, dist);
    }
  }
  return ret;
}

int diameter(Graph& tree)
{
  Pi p = dfs(tree, 0, -1);
  Pi q = dfs(tree, p.second, -1);
  return q.first;
}


int main()
{
  int n; cin >> n;
  Graph graph(n);
  n--;
  while(n--) {
    int s, t, w;
    cin >> s >> t >> w;
    graph[s].push_back(edge(t, w));
    graph[t].push_back(edge(s, w));
  }
  cout << diameter(graph) << endl;
  return 0;
}

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

string N;

int64_t dp[20][1000][2][2];

int64_t rec(int idx = 0, int pre = 0, bool tight = true, bool gochiusa = false) {
  if (idx == N.size()) {
    return gochiusa;
  }

  int64_t &res = dp[idx][pre][tight][gochiusa];
  if (~res) return res;
  res = 0;

  int x = N[idx] - '0';
  int r = (tight ? x : 9);
  for (int i = 0; i <= r; ++i) {
    int now = 10 * pre + i;
    res += rec(idx + 1, now % 1000, tight && i == r, gochiusa || (i == 3 && pre / 10 == 51));
  }

  return res;
}

int main() {
  memset(dp, -1, sizeof(dp));
  cin >> N;

  cout << rec() << endl;
}



Measured memory_bytes: 3844
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll n, m;
    cin >> n >> m;
    vector<vector<ll>> g(n);
    REP(i, m) {
        ll a, b;
        cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    dump(g);

    bool flag;
    vector<ll> col(n, -1);
    function<void(ll,ll)> dfs = [&](ll v, ll c) {
        col[v] = c;
        for(auto to: g[v]) {
            if(col[to] == c) flag = false;
            if(col[to] == -1) dfs(to, 1-c);
        }
    };
    ll x = 0, y = 0, z = 0;
    REP(i, n) {
        if(g[i].size() == 0) z++;
        else if(col[i] == -1) {
            flag = true;
            dfs(i, 0);
            if(flag) x++;
            else y++;
        }
    }
    dump(x, y, z);
    cout << 2*x*x + 2*x*y + y*y + z*z + 2*z*(n-z) << endl;

    return 0;
}

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

int main(int argc, const char * argv[]) {
    
    int a,b,c;
    cin >> a >> b >> c;
    
    int yaku = 0;
    for(int i=a;i<=b;i++){
        if(c%i==0){
            yaku++;
        }
    }
    
    cout << yaku << endl;
    
    return 0;
}

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

int main(){
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    bool left = true;
    bool right = true;
    bool top = true;
    bool bottom = true;

    if(x - r < 0) left = false;
    if(x + r > w) right = false;
    if(y - r < 0) bottom = false;
    if(y + r > h) top = false;

    cout << ((left && right && bottom && top) ? "Yes" : "No") << endl;
}




Measured memory_bytes: 3092
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		List<Integer> results = new ArrayList<>();

		while (true) {
			String inputs = s.nextLine();
			String[] input = inputs.split(" ");
			int a = Integer.parseInt(input[0]);
			String op = input[1];
			int b = Integer.parseInt(input[2]);
			if(a>=0 && b>=0 && a<=20000 && b<=20000) {
			if (op.equals("?")) {
				break;
			}
			if (op.equals("+")) {
				results.add(a + b);
			} else if (op.equals("-")) {
				results.add(a - b);
			}else if(op.equals("*")) {
				results.add(a * b);
			}else if(op.equals("/")) {
				if(b!=0)results.add(a / b);
			}
		}
		}
		for(int j =0;j<results.size();j++) {
			System.out.println(results.get(j));
		}

	}
}

Measured memory_bytes: 26132
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
from itertools import combinations
from collections import Counter

n = int(input())
l = [int(item) for item in input().split()]
unique = list(set(l))
cnt = Counter(l)

ans = 0
for comb in combinations(unique, 3):
    a, b, c = comb
    if a + b > c and b + c > a and a + c > b:
        ans += cnt[a] * cnt[b] * cnt[c]
print(ans)

Measured memory_bytes: 9460
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const int INF = 1e9 + 6;
const int MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<int, int>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()

int H, W;
const int MAX_GRID = 1001;
string a[MAX_GRID];
int dp[MAX_GRID][MAX_GRID];

int solve(int i, int j) {
    if(i >= H || j >= W) return 0;
    if(a[i][j] == '#') return dp[i][j] = 0;
    if(dp[i][j] != -1) return dp[i][j];
    if(i == H - 1 && j == W - 1) return 1;
    return dp[i][j] = (solve(i + 1, j) + solve(i, j + 1))%MOD;
}

int main() {
    cin >> H >> W;
    rep(i, H) cin >> a[i];
    rep(i, H)
        rep(j, W)
            dp[i][j] = -1;
    cout << solve(0, 0) << endl;
}


Measured memory_bytes: 5248
import sys

alpha = 'ABC'
N, A, B, C = map(int, input().split())
S = []
for s in sys.stdin.readlines():
    s = list(s)
    i, j, _ = s
    S.append((alpha.index(i), alpha.index(j)))

num = [A, B, C]


ope = []
for idx, (i, j) in enumerate(S):
    for k in range(3):
        if k not in (i, j):
            break

    if num[i] == 0 and num[j] == 0:
        ans = 'No'
        break
    
    if num[i] == 1 and num[j] == 1 and num[k] == 0 and idx < N - 1:
        if i in S[idx + 1]:
            plus, minus = i, j
        else:
            plus, minus = j, i
    else:
        if num[i] < num[j]:
            plus, minus = i, j
        else:
            plus, minus = j, i
    
    num[plus] += 1
    num[minus] -= 1
    ope.append(alpha[plus])
    # print(idx, num)

else:
    ans = 'Yes'

print(ans)
if ans == 'Yes':
    print(*ope, sep='\n')


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

int main() {
	string S, T;
	cin >> S >> T;

	for (int i = 0; i < S.length(); i++) {
		if (S[i] != T[i]) {
			cout << "No" << endl;
			return 0;
		}
	}
	if (S.length() + 1 != T.length()) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 3576
#!/usr/bin/env python3
#ABC104 B

alpha = "BDEFGHIJKLMNOPQRSTUVWXYZ"
s = list(input())
if s[0] != 'A':
    print('WA')
    quit()
if s[2:-1].count('C')!= 1:
    print('WA')
    quit()
for i in range(len(s)):
    if s[i] in alpha:
        print('WA')
        quit()
    elif s[i] == 'A':
        if i != 0:
            print('WA')
            quit()
    elif s[i] == 'C':
        if 0 <= i < 2 or i == len(s)-1:
            print('WA')
            quit()
print('AC')


Measured memory_bytes: 39664
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B: Contiguous Repainting
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;
const int INF = 1 << 30;
typedef long long ll;
const ll LINF = 1LL << 60;

/* typedef */

typedef vector<int> vi;
typedef queue<int> qi;
typedef pair<int,int> pii;

/* global variables */

int as[MAX_N];
ll sums[MAX_N + 1], psums[MAX_N + 1];

/* subroutines */

/* main */

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

  sums[0] = psums[0] = 0;
  for (int i = 0; i < n; i++) {
    cin >> as[i];
    sums[i + 1] = sums[i] + as[i];
    psums[i + 1] = psums[i] + (as[i] > 0 ? as[i] : 0);
  }

  ll maxsum = -INF;
  for (int i0 = 0, i1 = k; i1 <= n; i0++, i1++) {
    ll sum0 = psums[n] - (psums[i1] - psums[i0]);
    ll sum1 = sum0 + sums[i1] - sums[i0];
    ll sum = max(sum0, sum1);
    if (maxsum < sum) maxsum = sum;
  }

  printf("%lld\n", maxsum);
  return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
 
const int DIM = 5e2 + 5;
 
int dp[DIM][11];
 
int main( void ) {
    ios::sync_with_stdio( false );
    cin.tie(); cout.tie();
    
    int n;
    cin >> n;
    
    for( int i = 1; i <= 9; i ++ )
        dp[0][i] = numeric_limits<int> :: min() / 3;
    
    for( int i = 1; i <= n; i ++ ) {
        int x;
        cin >> x;
        
        for( int j = 0; j <= 9; j ++ )
            dp[i][j] = max( dp[i - 1][j], dp[i - 1][(j - x % 10 + 10) % 10] + x );
    }
    
    cout << max( *max_element( dp[n] + 1, dp[n] + 10 ), 0 );
    
    return 0;
}

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

using namespace std;

char h[200005];
int  v[30], g[30];

int main()
{
    char s[200005], t[200005];
    cin>>s>>t;
    for(int i=0; i<strlen(s); i++){
        if(h[s[i]]==0)
            h[s[i]]=t[i];
        else{
            if(h[s[i]]!=t[i]){
                cout<<"No";
                return 0;
            }
        }
    }
    for(int i=0; i<strlen(s); i++){
        v[s[i]-'a']++;
        g[t[i]-'a']++;
    }
    sort(v, v+30);
    sort(g, g+30);
    for(int i=0; i<30; i++){
        if(v[i]!=g[i]){
            cout<<"No";
            return 0;
        }
    }

    cout<<"Yes";

    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void){
  int a, b, i;
  scanf("%d%d", &a, &b);
  int dif = b - a;
  int ha = 1;
  for(i = 2; i < dif; i++){
    ha += i;
  }
  printf("%d\n", ha - a);
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x -> left != NIL){
    x = x -> left;
  }
  return x;
}

Node treeSearch(Node u, int k){
  if(u == NIL || k == u -> key){
    return u;
  }
  if(k < u -> key){
    return treeSearch(u -> left,k);
  }
    else return treeSearch(u -> right,k);
}

Node treeSuccessor(Node x){
  Node y;
  if(x -> right != NIL){
    return treeMinimum(x -> right);
  }
    y = x -> parent;
    while(y != NIL && x == y -> right){
      x = y;
      y = y -> parent;
    }
    return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(x != NIL){
    y = x;
    if(z -> key < x -> key){
      x = x -> left;
    }
    else x = x -> right;
  }
  z -> parent = y;
  if(y == NIL){
    root = z;
  }
  else if(z -> key < y -> key){
    y -> left =z;
  }
  else y -> right = z;
}

void inorder(Node u){
  if(u -> left != NIL){
    inorder(u -> left);
  }
  printf(" %d",u -> key);

  if(u -> right != NIL){
    inorder(u -> right);
  }
}

void preorder(Node u){
  printf(" %d",u ->key);

  if(u -> left != NIL){
    preorder(u -> left);
  }
  if(u -> right != NIL){
    preorder(u -> right);
  }
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

Measured memory_bytes: 11000
#include <iostream>
using namespace std;
typedef long long lli;
typedef unsigned int usi;
const lli A = 1 << 16;
lli n,x,y,z;
lli dp[41][A];
usi taboo = 0;
bool bl[41][A];
lli solve(lli a,usi b){
    if(bl[a][b]) return dp[a][b];
    bl[a][b] = true;
    if(a == n) return dp[a][b] = 1;
    usi t = b;
    t <<= 1;t++;
    for(lli i = 0;i < 10;i++,t <<= 1){
        if((t & taboo) == taboo) continue;
        dp[a][b] += solve(a+1,t%A);
        dp[a][b] %= 1000000007;
    }
    return dp[a][b];

}
lli lli_pow(lli a,lli n,lli mod = 1000000007){
	lli ret = 1;
	for(;n!=0;n=n>>1){
		if(n&1) ret = (ret * a) % mod;
		a = (a * a) % mod;
	}
	return ret;
}
int main(int argc, char const *argv[]) {
    cin >> n >> x >> y >> z;
    taboo <<= 1;taboo++;for(lli i = 1;i < x;i++) taboo <<= 1;
    taboo <<= 1;taboo++;for(lli i = 1;i < y;i++) taboo <<= 1;
    taboo <<= 1;taboo++;for(lli i = 1;i < z;i++) taboo <<= 1;
    cout << (lli_pow(10,n) - solve(0,0) + 1000000007) % 1000000007 << endl;
    return 0;
}


Measured memory_bytes: 23680
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<string> vs;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 2e9+7;

int main() {
    int a, b;
    cin >> a >> b;
    cout << a * b - a - b + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
 
using namespace std;

typedef long long ll;

const int MOD = 998244353; 
const int MAXN = 1e6 + 239;

int add(int a, int b) {
    ll res = (ll)a + b;
    return res % MOD;
}

int sub(int a, int b) {
    ll res = (ll)a - b;
    return (res % MOD + MOD) % MOD;
}


int mul(int a, int b) {
    ll res = (ll)a * b;
    return res % MOD;
}

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1) {
            res = mul(res, a);
        }
        a = mul(a, a);
        b >>= 1;
    }
    return res;
}

int dvv(int a, int b) {
    return mul(a, binpow(b, MOD - 2));
}

int cnt[MAXN];
int ml[MAXN];
int sn[MAXN];

int pr[MAXN];
int meb[MAXN];

vector<int> divs[MAXN];

void init() {
    for (int i = 1; i < MAXN; i++) {
        divs[i].push_back(i);
        for (int j = 2 * i; j < MAXN; j += i) {
            divs[j].push_back(i);
        }
    }
    fill(ml, ml + MAXN, 0);
    fill(cnt, cnt + MAXN, 0);
    fill(pr, pr + MAXN, 1);
    meb[1] = 1;
    for (int i = 1; i < MAXN; i++) {
        for (int j = 2 * i; j < MAXN; j += i) {
            meb[j] -= meb[i];
        }
    }
}

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

    init();
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        for (auto t : divs[x]) {
            ml[t] = add(ml[t], mul(sn[t], x));
            sn[t] = add(sn[t], x);
        }
    }
    for (int i = 1; i < MAXN; i++) {
        for (int j = i; j < MAXN; j += i) {
            int t = j / i;
            if (meb[t] == 1) {
                cnt[i] = add(cnt[i], ml[j]);
            } else if (meb[t] == -1) {
                cnt[i] = sub(cnt[i], ml[j]);
            }
        }
    }
    int res = 0;
    for (int i = 1; i < MAXN; i++) {
        res = add(res, dvv(cnt[i], i));
    }
    cout << res << endl;
}  

Measured memory_bytes: 134400
#include <stdio.h>
#define N 100000

int A[N];
int partition(int,int);
int main(){
    int p,i,n;
    scanf("%d",&n);
    for(i = 0;i < n; i++){
        scanf("%d",&A[i]);
    }
    p = partition(0,n-1);
    for(i = 0; i < n ;i++){
        if(i==p){
            printf("[");
        }
    printf("%d",A[i]);

    if(i==p){
            printf("]");
        }
    if(i!=n-1){
			printf(" ");
		}
    }
        printf("\n");

        return 0;
}


int partition(int p,int r){
    int x,i,j,temp1=0,temp2=0;
    x = A[r];
    i = p-1;
    for(j = p;j <= r-1;j++){
        if(A[j] <= x){
            i = i + 1;
            temp1 = A[i];
            A[i] = A[j];
            A[j] = temp1;
        }
    }
     
       temp2 = A[i+1];
            A[i+1] = A[r];
            A[r] = temp2;
    
   return i+1;
}


Measured memory_bytes: 2120
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define sort_1(v) sort(v.begin(),v.end())
#define sort_2(v) sort(v.begin(),v.end(),greater<ll>())
#define reverse(v) reverse(v.begin(),v.end())
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
    int n,W;
    cin >> n >> W;
    int weight[n];
    int value[n];
    rep(i,0,n) cin >> value[i] >> weight[i];

    int dp[101][10001];

    rep(i,0,n+1){
        rep(j,0,W+1){
            dp[i][j] = 0;
        }
    }

    rep(i,1,n+1){
        rep(w,0,W+1){
            if(w >= weight[i-1]){
                dp[i][w] = max({dp[i-1][w], dp[i-1][w - weight[i-1]] + value[i-1], dp[i][w-weight[i-1]] + value[i-1]});
            }else{
                dp[i][w] = dp[i-1][w];
            }
        }
    }

    cout << dp[n][W] << endl;
    return 0;
}


Measured memory_bytes: 7024
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef vector<ll> vi;
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
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; }

int main(){
  ll n;
  cin >> n;
  if(n==2){
    ll a, b;
    cin >> a >> b;
    print(a + b);
  }
  else{
    print("Hello World");
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<iostream>
#include<sstream>
#include<fstream>
#include<list>
#include<deque>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cmath>
#include<ctime>
#include<iomanip>
using namespace std;
/*freopen{"input.txt","r",stdin};
freopen{"output.txt","w",stdout};*/
#define mp make_pair
#define pb push_back
const int INF=1000*1000*1000;
const int maxn=2e5; 
typedef long long ll;
typedef long double ld;
typedef pair<int,int>PII;
//priority_queue <int,vector<int>,greater<int> > q1;  //从小到大 
//priority_queue <int,vector<int>,less<int> >q2;  //从大到小 

//set multiset vector queue priority_queue map multimap pair string structure 

//枚举 思维 贪心 搜索 模拟 预处理 二分 排序 
map<ll,ll>m;
int main(){
	//ios_base::sync_with_stdio(0);
    //cin.tie(0);
    //cout.tie(0);
	int n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		ll x;
		cin>>x;
		m[x]++;
	}
	vector<pair<ll,ll>>v;
	for(auto g:m){
		v.pb(mp(g.second,g.first));
	}
	sort(v.begin(),v.end());
	if(v.size()<=k){
		cout<<0;
		return 0;
	}
	ll sum=0;
	for(int i=0;i<v.size()-k;i++){
		sum+=v[i].first;
	}
	cout<<sum;
	
	
	
	
	return 0;
}



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

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

  set<int> st;
  rep(i,n) {
    int a; cin >> a;
    st.insert(a);
  }
  cout << (int)st.size() << '\n';
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for ((i)=1;(i)<=(n);(i)++)
using namespace std;
long long n,m,i,j,a[400005],s[400005],ans=0x3f3f3f3f3f3f3f3fll;
int main()
{
	cin>>n>>m;
	rep(i,n){
		cin>>a[i];
	}
	reverse(a+1,a+n+1);
	rep(i,n+n){
		s[i]=s[i-1]+a[i];
	}
	rep(i,n){
		long long tmp=n*m+i*m;
		for(j=1;i*(j-1)+1<=n;j++){
			if((ans-tmp)/(s[i*j]-s[i*(j-1)])<(j==1?5:j*2+1)){
				tmp=ans;break;
			}
			tmp+=(j==1?5:j*2+1)*(s[i*j]-s[i*(j-1)]);
		}
		ans=min(ans,tmp); 
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6400
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace C_sharp_canp
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] In = Console.ReadLine().Split(' ');
            decimal a = decimal.Parse(In[0]);
            decimal b = decimal.Parse(In[1]);
            Console.WriteLine(Decimal.Floor(a * b));
            Console.Read();
        }
    }
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#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);

int main(){
	int n,m;
	cin >> n >> m;
	vector<vector<ll>> x(n,vector<ll>(3));
	rep(i,n) cin >> x[i][0] >> x[i][1] >> x[i][2];
	ll ans = -INF;
	for(int i = 0; i < (1<<3); i++){
		vector<ll> sum(n);
		for(int j = 0; j < n; j++){
			for(int k = 0; k < 3; k++){
				if(i&(1<<k)) sum[j] += x[j][k];
				else sum[j] -= x[j][k];
			}
		}

		sort(all(sum),greater<ll>());
		ll tmp = 0;
		for(int i = 0; i < m; i++){
			tmp += sum[i];
		}
		ans = max(ans,tmp);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <limits.h>

int arr[100000][3];

int main()
{
	int n;
	int a, b, c;
	std::cin >> n;
	for (int i = 0; i < n; i++)
	{
		std::cin >> a;
		std::cin >> b;
		std::cin >> c;
		arr[i][0] = a;
		arr[i][1] = b;
		arr[i][2] = c;
	}
	for (int i = n-1; 0 <= i; i--)
	{
		for (int j = 0; j < 3; j++)
		{
			int max = INT_MIN;
			for (int k = 0; k < 3; k++)
			{
				if (k!=j) {
					if (arr[i+1][k]>max) {
						max = arr[i + 1][k];
					}
				}
			}
			arr[i][j] += max;
		}
	}
	int max = INT_MIN;
	for (int i = 0; i < 3; i++)
	{
		if (arr[0][i]>max) {
			max = arr[0][i];
		}
	}
	std::cout << max << std::endl;
}

Measured memory_bytes: 1408
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define endl '\n'
int mod=1e9+7;

signed main(){
  int n;
  string a,b,c;
  cin>>n>>a>>b>>c;
  int ans=0;
  for(int i=0;i<n;i++){
    if(a[i]==b[i]&&b[i]==c[i]){

    }else if(a[i]==b[i]||b[i]==c[i]||c[i]==a[i]){
      ans++;
    }else ans+=2;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256