akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;


void solve() {
    int N; cin >> N;
    set<int> st;

    for (int i = 0; i < N; i++) {
        int a; cin >> a;
        st.insert(a);
    }

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


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

Measured memory_bytes: 9600
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)

int N,M;
int L[100010],R[100010];
int num[100010];

signed main(){
	cin>>N>>M;
	REP(i,M){
		cin>>L[i]>>R[i];
	}
	REP(i,M){
		num[L[i]-1]++,num[R[i]]--;
	}
	REP(i,100000){
		num[i+1]=num[i]+num[i+1];
	}
	int ans=0;
	REP(i,100000){
		if(num[i]==M){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>

int main(void)
{
	char a, r;
	scanf("%c", &a);

	if (65 <= a && a <= 90)
	{
		printf("A\n");
	}

	if (97 <= a && a <= 122)
	{
		printf("a\n");
	}


	return 0;
}

Measured memory_bytes: 2024
//https://www.codechef.com/problems/CD1IT4

#include<bits/stdc++.h>
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define w(x)            int x; cin>>x; while(x--)
#define fr(i,a,b)       for(int i = a; i < b; i++)

void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}


int mod = 1000000007;
int dp[1000][1000];
int m , n, p;

int solve_grid()
{
	//base case
	if (dp[0][0] == -1)
		return 0;

	//for first row
	fr(j, 0, n)
	{
		if (dp[0][j] == -1)
			break;
		dp[0][j] = 1;
	}

	//for first col
	fr(j, 0, m)
	{
		if (dp[j][0] == -1)
			break;
		dp[j][0] = 1;
	}

	//rest of grid
	fr(i, 1, m)
	{
		fr(j, 1, n)
		{
			//blocked cell
			if (dp[i][j] == -1)
				continue;

			dp[i][j] = 0;
			if (dp[i][j - 1] != -1)
				dp[i][j] = dp[i][j - 1];

			if (dp[i - 1][j] != -1)
				dp[i][j] = (dp[i - 1][j] + dp[i][j]) % mod;
		}
	}

	if (dp[m - 1][n - 1] == -1)
		return 0;

	return dp[m - 1][n - 1];
}

void solve()
{
	memset(dp, 0, sizeof(dp));
	cin >> m >> n;
	string s;
	fr(i, 0, m)
	{
		cin >> s;
		fr(j, 0, n)
		if (s[j] == '#')
			dp[i][j] = -1;
	}
	cout << solve_grid() << endl;
	return;
}

int32_t main()
{
	c_p_c();
	solve();
	return 0;
}

Measured memory_bytes: 11464
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;
 
void solve(){
  int n,d; cin >>n >>d;
  int x[n][d],cnt=0;
  for(int i=0; i<n; i++) for(int j=0; j<d; j++) cin >>x[i][j];
  for(int i=0; i<n-1; i++) for(int j=i+1; j<n; j++){
    int dis=0;
    for(int k=0; k<d; k++) dis+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
    for(int k=1; k<127; k++) if(k*k==dis){cnt++; break;}
  }
  cout <<cnt;
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);
  solve();
return 0;}

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

int main() {
  char a,b;cin>>a>>b;
  if(a == b) cout << 'H' << endl;
  else cout << 'D' << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
void solve()
{
    int n;
  cin>>n;
  if(n>=30)
    cout<<"Yes";
  else
    cout<<"No";
 

  }
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(NULL);
   #ifdef Pranab
   freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
   #endif  
 
   int t=1; 
   //cin>>t;
 
   while(t--)
   {solve();cout<<"\n";}

   cerr<<"\n"<<(float)clock()/CLOCKS_PER_SEC*1000<<" ms"<<endl;

   return 0;
}

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

#define fi first
#define se second
#define eb emplace_back
#define FOR(i, a, b) for(int i = a; i < (int) b; i++)
#define FORD(i, a, b) for(int i = a; i >= (int) b; i--)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vpii> vvpii;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef vector<pi64> vpi64;

const int N = 305;
i64 dp[N][N];

int main () {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int v, e, cap;
  cin >> v >> e >> cap;
  FOR (i, 0, N) {
    FOR (j, 0, N) {
      dp[i][j] = (i == j ? 0 : 1e18);
    }
  }
  FOR (i, 0, e) {
    int st, et;
    i64 w;
    cin >> st >> et >> w;
    --st; --et;
    dp[st][et] = min (dp[st][et], w);
    dp[et][st] = min (dp[et][st], w);
  }
  FOR (k, 0, v) {
    FOR (i, 0, v) {
      FOR (j, 0, v) {
        dp[i][j] = min (dp[i][j], dp[i][k] + dp[k][j]);
      }
    }
  }
  FOR (i, 0, v) {
    FOR (j, 0, v) {
      dp[i][j] = (dp[i][j] <= cap ? 1 : 1e18);
    }
  }
  FOR (k, 0, v) {
    FOR (i, 0, v) {
      FOR (j, 0, v) {
        dp[i][j] = min (dp[i][j], dp[i][k] + dp[k][j]);
      }
    }
  }
  int q;
  cin >> q;
  while (q--) {
    int st, et;
    cin >> st >> et;
    --st; --et;
    cout << (dp[st][et] < (i64) 1e16 ? dp[st][et] - 1 : -1) << '\n';
  }
  return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define PB push_back
#define LL long long
const int mod = 1000 * 1000 * 1000 + 7;
using namespace std;

int fact[200005];
int inv[200005];
int pow3[200005];
int mult(int a , int b)
{
	return (a * (LL)b) % mod;
}
int add(int a , int b)
{
	return a + b >= mod ? a + b - mod : a + b;
}
int modPow(int a , int step)
{
	int ans = 1;
	while(step)
	{
		if(step & 1)
		{
			ans = mult(ans , a);
		}
		step >>= 1;
		a = mult(a , a);
	}
	return ans;
}
int c(int n , int k)
{
	return mult(fact[n] , mult(inv[k] , inv[n - k]));
}
int ways(int x , int y , int z)
{
	return mult(c(x + y + z , z) , c(x + y , y));
}
int main()
{
	int a , b , c;
	cin >> a >> b >> c;
	int ans = min(b , c);
	b -= ans;
	c -= ans;
	ans *= 2;
	if(c == 0)
	{
		ans += b;
		cout << ans;
		return 0;
	}
	else
	{
		ans += min(c , a + 1);
		cout << ans;

	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;
char n[1000001];
int a,b;
long long ans=0;
int main()
{
    scanf("%d%d",&a,&b);
    for(int i=1;i<=a;i++)
    {
        for(int j=1;j<=b;j++)
        {
            scanf("%s",n);
            if(n[0]=='s'&&n[1]=='n'&&n[2]=='u'&&n[3]=='k'&&n[4]=='e')
            {
                printf("%c%d\n",'A'+j-1,i);
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <cctype>
#include <algorithm>
#include <vector>
#include <utility>
#include <string>

int main() {
  size_t N, K;
  scanf("%zu %zu", &N, &K);

  char buf[1024];
  scanf("%s", buf);
  std::string s = buf;

  --K;
  s[K] = tolower(s[K]);
  printf("%s\n", s.c_str());
}


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

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif

const int INF=1e9;
const ll INFF=1e17;
const double EPS=1e-9;
const ll MOD=1e9+7;
const int MAXN=2e5+10;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,a[MAXN];
	cin >> n;
	REP(i,n)cin >> a[i];
	for(int i=n-1;i>=0;i-=2)cout << a[i] << " ";
	if(!(n%2))for(int i=0;i<=n-2;i+=2)cout << a[i] << " ";
	else for(int i=1;i<=n-2;i+=2)cout << a[i] << " ";
	cout << '\n';
	return 0;
}


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

  int main(){
    int a, b;
    cin >> a >> b;
    int c = abs(a - b);
    int tmp = 0;
    for (int i = 1; i < c; i++) {
      tmp += i;
    }
    cout << tmp - a << endl;
  }


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

using namespace std;

typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair

const int N = 2e5 + 10;
const int mod = 1e9 + 7;

int n, k, cnt[2];
pii a[N];

int main() {
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> a[i].fi;
        if (a[i].fi < 0) {
            a[i].se = 0;
            a[i].fi *= -1;
        } else {
            a[i].se = 1;
        }
    }
    sort(a + 1, a + 1 + n, greater<pii>());
    int t[2] = {0, 0}, idl[2] = {0, 0}, idr[2] = {0, 0};
    for (int i = 1; i <= k; i++) {
        if (a[i].se) t[1] ^= 1, idl[1] = i;
        else t[0] ^= 1, idl[0] = i;
    }
    for (int i = k + 1; i <= n; i++) {
        if (a[i].se) {
            if (!idr[1]) idr[1] = i;
        } else {
            if (!idr[0]) idr[0] = i;
        }
    }
    if (!t[0]) {
        long long res = 1;
        for (int i = 1; i <= k; i++) {
            res = 1ll * res * a[i].fi % mod;
        }
        cout << res;
    } else {
        if (!idr[1] && (!idl[1] || !idr[0])) {
            reverse(a + 1, a + 1 + n);
            long long res = 1;
            for (int i = 1; i <= k; i++) {
                res = 1ll * res * (a[i].se ? 1 : -1) * a[i].fi % mod;
            }
            if (res < 0) res += mod;
            cout << res;
        } else {
            if (!idr[1]) {
                long long res = a[idr[0]].fi;
                for (int i = 1; i <= k; i++) {
                    if (i == idl[1]) continue;
                    res = 1ll * res * a[i].fi % mod;
                }
                cout << res;
            } else if (!idl[1] || !idr[0]) {
                long long res = a[idr[1]].fi;
                for (int i = 1; i <= k; i++) {
                    if (i == idl[0]) continue;
                    res = 1ll * res * a[i].fi % mod;
                }
                cout << res;
            } else {
                if (1ll * a[idl[0]].fi * a[idr[0]].fi > 1ll * a[idl[1]].fi * a[idr[1]].fi) {
                    long long res = 1ll * a[idl[0]].fi * a[idr[0]].fi % mod;
                    for (int i = 1; i <= k; i++) {
                        if (i == idl[0] || i == idl[1]) continue;
                        res = 1ll * res * a[i].fi % mod;
                    }
                    cout << res;
                } else {
                    long long res = 1ll * a[idl[1]].fi * a[idr[1]].fi % mod;
                    for (int i = 1; i <= k; i++) {
                        if (i == idl[0] || i == idl[1]) continue;
                        res = 1ll * res * a[i].fi % mod;
                    }
                    cout << res;
                }
            }
        }
    }
}


Measured memory_bytes: 5128
n,m=map(int,input().split())
a=[]
ans=0
for _ in range(m):
  t=list(map(int,input().split()))
  t.pop(0)
  a.append(t)
b=list(map(int,input().split()))
for i in range(2**n):
  c=[0]*m
  for j in range(n):
     if ((i>>j) & 1):
        for k in range(len(a)):
          if (j+1) in a[k]:
            c[k]+=1
  flg=0
  for j in range(m):
    if c[j]%2!=b[j]:
      flg=1
  if flg==0:
    ans+=1
print(ans)

Measured memory_bytes: 9192
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
const int MOD = 1e9+7;
using ll = long long;
using vi = vector<int>;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(x) x.begin(), x.end();
int main() {
  int a,b,sum=0,MAX=0;
  cin >> a;
  rep(i,a){
    cin >> b;
    MAX = max(MAX,b);
    sum += b;
  }
  cout << sum - MAX/2;
}

Measured memory_bytes: 3616
x,k,d=map(int,input().split())
x=abs(x)

if x-k*d>=0:
    print(x-k*d)
else:
    n=x//d
    k-=n
    a=x-n*d
    if k%2==0:
        print(min(a,2*d-a))
    else:
        print(min(d-a,a+d))

Measured memory_bytes: 9176
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF=1000000000000000000;
int N,M;
vector<pair<int,int>> A[110];
int B[110];
signed main(){
  cin>>N>>M;
  set<pair<int,int>> S;
  for(int i=0;i<M;i++){
    int a,b,c;
    cin>>a>>b>>c;
    A[a-1].push_back({b-1,c});
    A[b-1].push_back({a-1,c});
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++)B[j]=INF;
    B[i]=0;
    priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> Q;
    Q.push({0,i});
    while(!Q.empty()){
      pair<int,int> P=Q.top();
      Q.pop();
      if(B[P.second]<P.first)continue;
      for(pair<int,int> p:A[P.second])
        if(P.first+p.second<B[p.first]){
          B[p.first]=P.first+p.second;
          Q.push({P.first+p.second,p.first});
        }
    }
    queue<int> q;
    q.push(i);
    while(!q.empty()){
      int I=q.front();
      q.pop();
      for(pair<int,int> p:A[I])
        if(B[I]+p.second==B[p.first]){
          S.insert({min(p.first,I),max(p.first,I)});
          q.push(p.first);
        }
    }
  }
  cout<<M-S.size()<<endl;
}

Measured memory_bytes: 3656
#include <stdio.h>

int main(int argc, char **argv)
{
    char s1[8], s2[8], s3[8];
    scanf("%[^,],%[^,],%[^,]", s1, s2, s3);
    printf("%s %s %s\n", s1, s2, s3);
    return 0;
}

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

using namespace std;

int main(){
    char n[4];
    cin >> n;
    int period[4] = {n[0] - '0', n[1] - '0', n[2] - '0', n[3] - '0'};
    int front = (10 * period[0]) + period[1];
    int back = (10 * period[2]) + period[3];

    if(front > 12){
        if(back >12){
            cout << "NA";
        }else if(back == 0){
            cout << "NA";
        }else{
            cout << "YYMM";
        }
    }else if(front==0){
        if(back==0){
            cout << "NA";
        }else if(back>12){
                cout << "NA";
        }else{
            cout << "YYMM";
        }
    }else{
        if(back ==0){
            cout << "MMYY";
        }else if(back>12){
            cout << "MMYY";
        }else{
            cout << "AMBIGUOUS";
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#define llint long long
#define mod 1000000007

using namespace std;

llint h, w;
char c[2005][2005];
llint a[2005][2005];

int main(void)
{	
	cin >> h >> w;
	for(int y = 1; y <= h; y++){
		for(int x = 1; x <= w; x++){
			cin >> c[x][y];
		}
	}
	
	for(int y = 1; y <= h; y++){
		llint cnt = 0;
		for(int x = 1; x <= w; x++){
			if(c[x][y] == '.') cnt++;
			else cnt = 0;
			a[x][y] += cnt;
		}
		cnt = 0;
		for(int x = w; x >= 1; x--){
			if(c[x][y] == '.') cnt++;
			else cnt = 0;
			a[x][y] += cnt;
		}
	}
	
	for(int x = 1; x <= w; x++){
		llint cnt = 0;
		for(int y = 1; y <= h; y++){
			if(c[x][y] == '.') cnt++;
			else cnt = 0;
			a[x][y] += cnt;
		}
		cnt = 0;
		for(int y = h; y >= 1; y--){
			if(c[x][y] == '.') cnt++;
			else cnt = 0;
			a[x][y] += cnt;
		}
	}
	
	llint ans = 0;
	for(int y = 1; y <= h; y++){
		for(int x = 1; x <= w; x++){
			if(c[x][y] == '.') ans = max(ans, a[x][y]-3);
		}
	}
	cout << ans << endl;
	
	return 0;
}

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

int main()
{
	//ofstream fcout;
	//fcout.open("output.txt");
	
    ifstream fcin;
    fcin.open("input.txt"); 

    	int x;
    	cin>>x;
    	cout<<x*x<<endl;

    fcin.close();
	//fcout.close();

	return 0;

}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)
var input = make([]int64, 0)

var A, B, K int64

func main() {
	for sc.Scan() {
		in := sc.Text()
		ins := strings.Split(in, " ")
		for i := range ins {
			inInt, _ := strconv.ParseInt(ins[i], 10, 64)
			input = append(input, inInt)
		}

		// first
		A = input[0]
		B = input[1]
		K = input[2]
		eat()
		fmt.Println(A, B)
		input = make([]int64, 0)
	}
}

func eat() {

	for i := int64(1); i <= K; i++ {
		switch i % 2 {
		// 青木
		case 0:
			if B%2 == 0 {
				// nop
			} else {
				B = B - 1
			}
			pass := B / 2
			B = B / 2
			A = A + pass
		// 高橋
		case 1:
			if A%2 == 0 {
				// nop
			} else {
				A = A - 1
			}
			pass := A / 2
			A = A / 2
			B = B + pass
		}
	}
}

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

#define FOR(i,a,b)  for(ll (i)=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll (i)=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      (v).begin(),(v).end()
#define BIT(n)      (1LL<<(n))
#define IN(x,l,r)   ((l)<=(x)&&(x)<=(r))
#define LEN(s)      (string(s)).length()
#define NPOS        string::npos
#define SHOW(x)     cout<<#x<<" = "<<x<<endl
#define SORT(v)     sort(ALL(v))
#define SZ(v)       (ll)(v).size()
#define UNIQ(v)     SORT(v);(v).erase(unique(ALL(v)),(v).end())
#define PERM(v)     for(bool p=1;p;p=next_permutation(ALL(v)))
#define PQ(T)       priority_queue<T,vector<T>,greater<T>>

template<class T>string join(const vector<T>& v,string d=" ")
{stringstream s;REP(i,SZ(v))s<<d<<v[i];return s.str().substr(LEN(d));}

template<class T>ostream& operator<<(ostream& s,const vector<T>& v)
{s<<"{";if(SZ(v))s<<join(v,", ");s<<"}";return s;}

template<class T>bool contain(const string& s,const T& v)
{return s.find(v)!=NPOS;}

template<class T,class U>string& replace(string& s,const T& f,const U& t)
{for(auto p=s.find(f);p!=NPOS;p=s.find(f,p+LEN(t)))s.replace(p,LEN(f),t);}

const ll INF = 1e15;
const ll MOD = 1e9+7;
const double EPS = 1e-10;

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

ll D[32][32];
ll c[502][502];

int main() {
    ll N; cin >> N;
    
    vector<ll> p(N), q(N);
    REP(i, N) {
        cin >> p[i];
        q[p[i] - 1] = i;
    }
    
    {
        vector<ll> a(N);
        ll x = 0;
        REP(i, N) {
            x += q[i] + 1;
            a[i] = x;
        }
        cout << join(a) << endl;
    }
    
    {
        vector<ll> b(N);
        ll x = 0;
        REP(i, N) {
            x += q[N-i-1] + 1;
            b[i] = x;
        }
        reverse(ALL(b));
        cout << join(b) << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1728
// glory be to the sky
#include<cstdio>
#include<bits/stdc++.h> 
#define pb push_back
using namespace std;
	
typedef long long ll; 


int main(){

	ios::sync_with_stdio(false);
	cin.tie(0);
	int N;
	cin >> N;
	int X = N * 800;
	int Y = N / 15 * 200;
	cout << X - Y;
	return 0;	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
int main(){
  int n,q;cin>>n>>q;
  vector<PP> p(n);
  rep(i,n){
    int s,t,x;scanf("%d %d %d",&s,&t,&x);
    get<2>(p[i])=x-t+1;
    get<1>(p[i])=x-s;
    get<0>(p[i])=x;
  }
  sort(p.begin(),p.end());
  set<P> s;
  vi ans(q,-1);
  rep(i,q){
    int a;scanf("%d",&a);
    s.insert(P(-a,i));
  }
  rep(i,n){
    if(s.size()==0)break;
    int a=get<2>(p[i]),b=get<1>(p[i]);
    auto from=s.lower_bound(P(a,-1));
    while(from!=s.end()){
      if((from->first)>get<1>(p[i]))break;
      ans[from->second]=get<0>(p[i]);
      s.erase(from++);
    }
  }
  rep(i,q)printf("%d\n",ans[i]);
}


Measured memory_bytes: 20608
#include <iostream>
#include <algorithm>
using namespace std;
 
int main(){
    int A, B, C;
    cin >> A >> B >> C;
    if(A == B && B == C && A % 2 == 0){
        cout << -1 << endl;
        return 0;
    }
    int ans = 0;
    while(A % 2 == 0 && B % 2 == 0 && C % 2 == 0){
        int tmpA = A, tmpB = B;
        A = (B + C) / 2;
        B = (C + tmpA) / 2;
        C = (tmpA + tmpB) / 2;
        ans++;
    }
    cout << ans << endl;
}

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

int main() {
  string s;
  cin >> s;
  
  int n = -1;
  for(int i = 0;i < s.size();i++){
    if(s.at(i)=='C'){
      n = i;
      break;
    }
  }
  
  int m = -1;
   for(int j = 0;j < s.size();j++){
    if(s.at(j)=='F'){
      m = j;
    }
  }
  
  if(n >= 0 && m >= 0 && n<m){
    cout << "Yes" << endl;
  }
  
  else{
    cout << "No" << endl;
  }
}

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

#define ll long long
#define lli long long int
#define vec vector
#define que queue
#define st stack
#define str string
#define p_q priority_queue
#define d_q dequeue

#define Pi acos(-1)
//const int primes[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
#define modulo 123456789

#define mod(x) (x % modulo)
#define bool_tog(bool_x) bool_x = !bool_x
#define up_c(c) c -= ((c >= 'a' && c <= 'z') ? 32 : 0)
#define low_c(c) c += ((c >= 'A' && c <= 'Z') ? 32 : 0)

#define fi first
#define se second


int i,j,k,n,m,t,cnt;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    cin >> k;
    str s;
    cin >> s;
    if(s.size() <= k) {cout << s << endl;}   
    else{ for(int i = 0; i < k; i++) { cout << s[i]; } cout << "..." << endl; }
    
    return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<string>
using namespace std;
int main()
{
  string s,a;
  cin>>s;
  if(s=="Sunny")a="Cloudy";
  if(s=="Cloudy")a="Rainy";
  if(s=="Rainy")a="Sunny";
  cout<<a<<endl;
  return 0;
}

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

int main(){

    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            int cal = i * j;
            cout << i << "x" << j << "=" << cal << endl;
        }
    }

    return 0;
}

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

#define _BIGNUM_ 100000000

using namespace std;
typedef long long ll;

const ll mod = 1e9+7;

int main() {
  vector<int> N(4);
  cin >> N[0] >> N[1] >> N[2] >> N[3];
  cout <<
    (find(N.begin(), N.end(), 1) != N.end() &&
    find(N.begin(), N.end(), 9) != N.end() &&
    find(N.begin(), N.end(), 7) != N.end() &&
    find(N.begin(), N.end(), 4) != N.end() ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
n = int(input())
s = input()
l = 0
r = s[1:].count('E')
result = l + r
for i in range(1,n-1):
    l += s[i-1].count('W')
    r -= s[i].count('E')
    result = min(result,l+r)
    if result == 0:
        print(0)
        exit()
l += s[n-1].count('W')
r = 0
result = min(result,l+r)
print(result)

Measured memory_bytes: 42352
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<string.h>
#include<list>
#include<limits>
#include<bitset>
#include<ctype.h>
#include<set>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1000000007LL;
const ll INF=1000000000;
const int MAX=100001;
struct edge{int to,cost;};
typedef pair<int,int> P;
int d[51];
int n;
int main(){
    cin>>n;
    int ans=0;
    for(int i=0;i<n;i++){
        cin>>d[i];
    }
    sort(d,d+n);
    int a[51]={};
    int b[51];
    bool f=true;
    for(int i=0;i<n;i++){
        if(f){
            a[i]=d[i];
            f=false;
        }else{
            a[i]=24-d[i];
            f=true;
        }
        b[i]=a[i];
    }
    a[n]=0;
    int s=INF;
    sort(a,a+n+1);
    for(int j=1;j<=n;j++){
        s=min(s,min(abs(a[j]-a[j-1]),24-abs(a[j]-a[j-1])));
    }
    s=min(s,min(abs(a[n]-a[0]),24-abs(a[n]-a[0])));
    for(int j=0;j<n;j++){
        a[j]=b[j];
    }
    ans=s;
    cout<<ans<<endl;
    getchar();
    getchar();
}

                           


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			System.out.println(IntStream.range(0, n).map(i -> scanner.nextInt()).distinct().count());
		}
	}
}


Measured memory_bytes: 26964
# -*- coding: utf-8 -*-
# 標準入力を取得
N = int(input())

# 求解処理
s = str(N)
l = list(map(int, s))
ans = str()
if sum(l) % 9 == 0:
    ans = "Yes"
else:
    ans = "No"

# 結果出力
print(ans)


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

class SegmentTree():
    def __init__(self, S, n):
        self.size = n
        self.array = [set()] * (2**(self.size + 1) - 1)
        for i, c in enumerate(S):
            self.array[i + 2**self.size - 1] = {c}
        for i in range(2**self.size - 1)[::-1]:
            self.array[i] = self.array[2 * i + 1] | self.array[2 * i + 2]

    def subquery(self, l, r, k, i, j):
        if j <= l or r <= i:
            return set()
        elif l <= i and j <= r:
            return self.array[k]
        else:
            l_set = self.subquery(l, r, 2 * k + 1, i, (i + j) // 2)
            r_set = self.subquery(l, r, 2 * k + 2, (i + j) // 2, j)
            return l_set | r_set

    def query(self, l, r):
        return len(self.subquery(l, r, 0, 0, 2**self.size))

    def update(self, i, c):
        tmp = i + 2**self.size - 1
        self.array[tmp] = {c}
        while tmp > 0:
            tmp = (tmp - 1) // 2
            self.array[tmp] = self.array[2 * tmp + 1] | self.array[2 * tmp + 2]

n = int(input())
S = [ord(c) for c in list(input())]
segtree = SegmentTree(S, 19)
for _ in range(int(input())):
    t, i, c = input().split()
    if t == '1':
        segtree.update(int(i)-1, ord(c))
    if t == '2':
        print(segtree.query(int(i)-1, int(c)))


Measured memory_bytes: 471624
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define f first
#define s second
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)
#define loop(i, a, b) for(int i=a; i<b; i++)
#define loopb(i, a, b) for(int i=a; i>=b; i--)
#define pb push_back
typedef long long int lli;
typedef pair<lli, lli> pii;
typedef vector<lli> vll;
// use to avoid collision
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// for pair in unordered_map
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
lli power(lli x, lli y, lli p){
    lli res = 1;
    x = x % p;
    while (y > 0) {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
lli calc(vector<lli>& S, lli lo, lli hi){
	lli ans = 0;
	lli index1 = upper_bound(S.begin()+hi, S.end(), S[lo]+S[hi]-1) - S.begin();
	lli index2 = lower_bound(S.begin()+hi, S.end(), S[lo]+S[hi]-1) - S.begin();
	if(index1 == S.size())
		index1--;
	if(index2 == S.size())
		index2--;
	if( S[index2] > S[lo] + S[hi] - 1){
		index1--;
		index2--;
	}
	if(S[index1] > S[lo] + S[hi] - 1)
		index1--;
//	cout<<lo<<" "<<hi<<" "<<index2<<" "<<index1<<"\n";
	if(index1 > hi)
		ans += index1-hi;
	return ans;
}
int main(){
	fastio;
	lli n;
	cin>>n;
	vll S(n);
	loop(i, 0, n)	cin>>S[i];
	sort(S.begin(), S.end());
	lli count = 0;
	loop(i, 0, n-1){
		loop(j, i+1, n){
			count += calc(S, i, j);
		}
	}
	cout<<count<<"\n";
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"io"
	"os"
	"sort"

)

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

type inInfo struct {
	in    int
	after int
}

type inInfoSorter []*inInfo

func (a inInfoSorter) Len() int      { return len(a) }
func (a inInfoSorter) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a inInfoSorter) Less(i, j int) bool {
	switch {
	case a[i].in > a[j].in:
		return true
	case a[i].in < a[j].in:
		return false
	case a[i].after > a[j].after:
		return true
	default:
		return false
	}
}

func sum(w []int) int {
	s := 0
	for _, v := range w {
		s += v
	}
	return s
}

type ptr []int

func (x ptr) top(i int) int {
	ptrs := []int(x)
	var his []int
	cur := i
	for ; cur >= 0 && ptrs[cur] != cur; cur = ptrs[cur] {
		his = append(his, cur)
	}
	for _, v := range his {
		ptrs[v] = cur - 1
	}
	if cur >= 0 {
		ptrs[cur] = cur - 1
	}
	return cur
}

func solve(stdin io.Reader, stdout io.Writer) {
	var n, m int
	var infos []*inInfo

	fmt.Fscanln(stdin, &n, &m)

	for i := 0; i < n; i++ {
		var info inInfo
		fmt.Fscanln(stdin, &info.after, &info.in)
		infos = append(infos, &info)
	}

	sort.Sort(inInfoSorter(infos))

	var ans = make([]int, m)
	var p = make([]int, m)
	for i := range p {
		p[i] = i
	}
	ptrs := ptr(p)

	for _, w := range infos {
		i := ptrs.top(m - w.after)
		if i >= 0 {
			ans[i] = w.in
		}
	}

	fmt.Fprintln(stdout, sum(ans))

}



Measured memory_bytes: 8704
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);

        int[] p = IntStream.range(0, sc.nextInt()).map(e -> sc.nextInt()).toArray();
        int temp = p[0];
        int ans = 0;
        for (int i = 0; i < p.length; i++) {
            if (p[i] <= temp) {
                ans++;
                temp = p[i];
            }
        }
        System.out.println(ans);
        sc.close();
    }
}

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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define foe(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); it++)
#define long long long 
#define db double 
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

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

const int N = 21;
char s[N][N];
int res = 0, n, m;

void bfs(int i, int j){
  vector <vector <int>> dis(n + 1, vector <int> (m + 1, -1));
  dis[i][j] = 0; queue <pii> Q;
  Q.push(pii(i, j));
  while (Q.size()){
    int u = Q.front().first;
    int v = Q.front().second;
    Q.pop();
    for (int k = 0; k < 4; k++){
      int x = u + dx[k];
      int y = v + dy[k];
      if (x < 1 || x > n || y < 1 || y > m) continue;
      if (s[x][y] == '#' || dis[x][y] != -1) continue;
      dis[x][y] = dis[u][v] + 1;
      res = max(res, dis[x][y]);
      Q.push(pii(x, y));
    }
  }
}

int main()
{
  fastio;
  cin >> n >> m;
  for (int i = 1; i <= n; i++){
    for (int j = 1; j <= m; j++){
      cin >> s[i][j];
    }
  }
  for (int i = 1; i <= n; i++){
    for (int j = 1; j <= m; j++){
      if (s[i][j] == '.') bfs(i, j); 
    }
  }
  cout << res;
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,l;
	cin>>n>>l;
	int d=0,c=1;
	for(int i=0;i<n;i++){
		int x;cin>>x;
		d=d+x;
		if(d<=l) c++;
	}
	cout<<c;
}


Measured memory_bytes: 256
A, B = map(int, input().split())

import math

a = math.floor(math.sqrt(A))
b = math.floor(math.sqrt(B))

A_ = [1]
i = 2
while i <= a:
    if A % i == 0:
        A //= i
        A_.append(i)
    else:
        i += 1
A_.append(A)
        
B_ = [1]
i = 2
while i <= b:
    if B % i == 0:
        B //= i
        B_.append(i)
    else:
        i += 1
B_.append(B)

#print(A_)
#print(B_)
#print(set(A_))
#print(set(B_))

count = 0
for i in set(A_):
    if i in set(B_):
        count += 1

print(count)

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


int main(){
    string s;
    cin >> s;
    if ( s[0] == s[1] && s[0] == s[2] && s [2] == s [3])
        cout << "No" << endl;
    else if ( s[0] == s[1] && s [2] == s [3])
        cout << "Yes" << endl;
    else if ( s[0] == s[2] && s [1] == s [3])
        cout << "Yes" << endl;
    else if ( s[0] == s[3] && s [1] == s [2])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int T;
    scanf("%d",&T);
    int n = 0,m = 0;
    for(int i = 1;i <= T;i++)
    {
        if(i%2 == 0) n++;
        else m++;
    }
    printf("%d\n",m*n);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll     = long long;
using prefix = __attribute__((constructor))void;
const ll MOD = 1000000007;
const ll INF = 9223372036854775807LL;

#define elif           else if
#define def            inline auto
#define func           inline constexpr ll
#define up(i,a,n)      for(ll i=(a),i##_1=(n);i<i##_1;++i)
#define down(i,a,n)    for(ll i=(a),i##_1=(n);i>=i##_1;--i)
#define rep(i,n)       up(i,0,n)

func    gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
func    lcm(ll a,ll b) {return a*b/gcd(a,b);}
def     dig(ll a)      {return to_string(a).length();}
prefix  init()         {cin.tie(0),ios::sync_with_stdio(0);}

func fact(ll a){return a?fact(a-1)*a:1;}

signed main(){
    ll A,B,C,D;
    cin>>A>>B>>C>>D;
    ll X=C-A,Y=D-B,XX=C-Y,YY=D+X,XXX=XX-X,YYY=YY-Y;
    cout<<XX<<" "<<YY<<" "<<XXX<<" "<<YYY;

}
//for compilation: g++ -o _ _.cpp -std=c++14 (or 17)
//
//for fastening: g++ -O2 -o _ _.cpp -std=c++14 (or 17)
//for fastening: g++ -O3 -mtune=native -march=native -o _ _.cpp -std=c++14 (or 17)


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
#define tget(a,b) get<a>(b)
using namespace std;
typedef long long ll;
const ll INF = 1e17;
const int MOD = 1e9 + 7;

string A;
ll N=0, K,ans;


int main(void) {
	cin >> A;
	if (A[5] == '1')N = 1;
	if (A[6] >= '5')N = 1;
	if (N == 0)ct("Heisei");
	else ct("TBD");



	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
*/
using namespace std;
/////////////////// TYPES & MACROS ///////////////////////////////
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define vv vector
#define exist(s,e) (s.find(e)!=s.end())
using ll=long long; using dd=double;
using pii=pair<int,int>; using pll=pair<ll,ll>;
typedef vector<int> vi;
const ll INFLL=(ll)2e18, MOD=1'000'000'007;
const int INF=0x3f3fffff;
/////////////////// DEBUG MODE ///////////////////////////////////
#define D(x) cerr<<"DEBUG: "<<#x<<" is: "<<x<<'\n';
#define DD(x,y) cerr<<"DEBUG:("<<#x<<","<<#y<<") are: "<<x<<" "<<y<<'\n';
/////////////////// GLOBAL VARIABLES ////////////////////////////
vector<vector<int>> adj; vector<bool> vis;
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1},dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};
/////////////////// FUNCTIONS ////////////////////////////////////
inline ll mexp(ll x,ll n,ll m){ll res=1;while(n){if(n&1)res=(res*x)%m;n>>=1;x=((x%m)*(x%m))%m;}return res;}
bool ispow2(ll x){ return x && (!(x&(x-1)));}
ll gcd(ll x, ll y){ pll p{x,y}; while(p.ss) p={p.ss,p.ff%p.ss}; return p.ff;}

/////////////////// MAIN STARTS //////////////////////////////////
int main(){
  ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
  cout<<fixed;cerr<<fixed; cout<<setprecision(8); cerr<<setprecision(3);
  srand(time(NULL)); rand();

#ifdef DEBUG
  clock_t tStart = clock(); //freopen("op.txt","w",stdout);
#endif

  int n,k,l=0,r=0; cin>>n>>k;
  r=n-l-1;
  if (k==n) {
    cout<<1<<'\n';
  }
  else{
    cout<<1+(int)ceil(((dd)n-k)/(k-1))<<'\n';
  }

#ifdef DEBUG
	cerr<<"\nExecution time: "<<(((double)clock() - tStart)/CLOCKS_PER_SEC)*1e3<<"ms.\n";
#endif
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using ll = long long;
using namespace std;

int main(void)
{
  ll N, K;
  cin >> N >> K;
  ll i;
  ll array[100001] = {};
  for (i = 0; i < N; i++)
  {
    ll a, b;
    cin >> a >> b;
    array[a] += b;
  }
  for (i = 0; i < 100001; i++)
  {
    K -= array[i];
    if (K <= 0)
    {
      cout << i << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 1152
#include <iostream>
#include <string>

using namespace std;

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

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

    string ans = "Yes";
    for (int i = 1; i < n; i++){
        if (w[i - 1][w[i - 1].size() - 1] != w[i][0]){
            ans = "No";
            break;
        } else {
            for (int j = 0; j < i; j++){
                if (w[j] == w[i]){
                    ans = "No";
                    break;
                }
            }
            if (ans == "No"){
                break;
            }
        }
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdlib.h>
#include <stdio.h>
#include <sys/time.h>
#include <bits/stdc++.h>
#include <algorithm>

using namespace std;

int main() {
    int n;
    scanf("%d", &n);

    int temp_n = n;
    int fn=0;
    while (temp_n!=0) {
        fn += temp_n%10;
        temp_n /= 10;
    }    

    if (n%fn==0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}



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

const long long LINF = 0x3f3f3f3f3f3f3f3f;

int main() {
  int n;
  long long a, ma = -LINF, mi = LINF, sum = 0;
  cin >> n;
  for (int i=0; i<n; i++) {
    cin >> a;
    ma = (ma < a) ? a : ma;
    mi = (mi > a) ? a : mi;
    sum += a;
  }
  cout << mi << " " << ma << " " << sum << endl;
  return 0;
}

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

int main() {
	int n, a[100];
	cin >> n;
	for (int i = 0; i <= n-1; i++) {
		cin >> a[i];
	}
	
	int count = 0;
	for (int i = 0; i <= n-1; i++) {
		int flag = 1;
		while (flag) {
			flag = 0;
			for (int j = n-1; j >= 1; j--) {
				if (a[j] < a[j-1]) {
					int tmp = a[j];
					a[j] = a[j-1];
					a[j-1] = tmp;
					flag = 1;
					count++;
				}
			}
		}
	}
	
	for (int i = 0; i <= n-1; i++) {
		cout << a[i];
		if (i < n-1) {
			cout << " ";
		} else {
			cout << endl;
		}
	}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 3100
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>
 
#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>
 
#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
  int n;
  scanf("%d", &n);
  if (!(n & (n - 1))) {
    puts("No");
    return 0;
  }
  puts("Yes");
  int m = n;
  printf("%d %d\n", 1 + n, 3);
  if (n % 2 == 0) --m;
  for (int i = 2; i < m; i += 2) {
    printf("%d %d\n", i, i + 1);
    printf("%d %d\n", i, 1);
    printf("%d %d\n", i + n, i + 1 + n);
    printf("%d %d\n", i + n + 1, 1);
  }
  if (n % 2 == 0) {
    int x = n & -n;
    int y = n - x;
    printf("%d %d\n", x, n);
    printf("%d %d\n", y + n + 1, n * 2);
  }
  return 0;
}


Measured memory_bytes: 2304
S = input()
if (S[0] == S[1]) & (S[1] != S[2]) & (S[2] == S[3]):
  print("Yes")
elif (S[0] == S[2]) & (S[1] != S[2]) & (S[1] == S[3]):
  print("Yes")
elif (S[0] == S[3]) & (S[0] != S[2]) & (S[1] == S[2]):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include <cstdio>

#pragma warning(disable: 4996)

#define MAX_N 1500
#define MAX_D 1000

#define MAX_R MAX_N * MAX_D

int N, M, H[MAX_N], W[MAX_N];

int dp[2][MAX_R + 1];

int main()
{
	while (true)
	{
		scanf("%d", &N);
		scanf("%d", &M);

		if (N == 0 && M == 0) { break; }

		for (int i = 0; i < N; i++) { scanf("%d", &H[i]); }
		for (int i = 0; i < M; i++) { scanf("%d", &W[i]); }

		for (int i = 0; i <= N; i++)
		{
			int dist = 0;

			for (int j = i; j < N; j++)
			{
				dist += H[j];

				dp[0][dist] += 1;
			}
		}

		for (int i = 0; i <= M; i++)
		{
			int dist = 0;

			for (int j = i; j < M; j++)
			{
				dist += W[j];

				dp[1][dist] += 1;
			}
		}

		int count = 0;

		for (int i = 0; i <= MAX_R; i++)
		{
			count += dp[0][i] * dp[1][i];

			dp[0][i] = 0;
			dp[1][i] = 0;
		}

		printf("%d\n", count);
	}

	return 0;
}

Measured memory_bytes: 14336
#include <iostream>
using namespace std;
int main(void){
    int r,D;
    int x[10]={0};
    cin >> r >> D >> x[0];
    for (int i=1; i<11 ; i++){
        x[i]=r*x[i-1]-D;
        cout << x[i] << endl;
    }
return 0;}

Measured memory_bytes: 888
#define NUM_ANTENNA 5
#define OK 0
#define BAD 1
#include<iostream>
#include<math.h>
//#inclde<map>                                                                                                         
using namespace std;

int main()
{
  // 入力                                                                                                              
  int x[NUM_ANTENNA];
  int k;

  for(int k=0; k<NUM_ANTENNA; k++)
    cin >> x[k];

  cin >> k;

  int i, j;
  int ans = OK; //初期値はOK                                                                                 

  for(i=0; i<NUM_ANTENNA-1; i++){
    for(j=i+1; j<NUM_ANTENNA; j++){
      if((x[j]-x[i]) > k)
        ans = BAD;
    }
  }

  //出力                                                                                                               
  if (ans == OK)
    cout << "Yay!" << endl;
  else if (ans == BAD)
    cout << ":(" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;


class Mod
{
public:
    static const ll DIVISOR = 1e9 + 7;

    ll value = 0;

    Mod(const ll value) : value(value % DIVISOR)
    {
        if (this->value < 0)
        {
            this->value += DIVISOR;
        }
    }

    operator const ll() { return value; }

    inline Mod& operator+=(const ll rhs)
    {
        *this = *this + rhs;
        return *this;
    }

    inline Mod &operator-=(const ll rhs)
    {
        *this = *this - rhs;
        return *this;
    }

    inline Mod &operator*=(const ll rhs)
    {
        *this = *this * rhs;
        return *this;
    }

    inline Mod &operator/=(const ll rhs)
    {
        *this = *this / rhs;
        return *this;
    }

    Mod pow(const ll n)
    {
        Mod res = 1;
        Mod mul = *this;

        for (int i = 0; 1 << i <= n; i++)
        {
            if ((1 << i) & n)
            {
                res *= mul;
            }
            mul *= mul;
        }

        return res;
    }
};

Mod operator+(const Mod &lhs, const ll &rhs) { return Mod(lhs.value + rhs); }
Mod operator-(const Mod &lhs, const ll &rhs) { return Mod(lhs.value - rhs); }
Mod operator*(const Mod &lhs, const ll &rhs) { return Mod(lhs.value * rhs); }
Mod operator/(const Mod &lhs, const ll &rhs) { return lhs * Mod(rhs).pow(Mod::DIVISOR - 2); }

Mod operator+(const ll &lhs, const Mod &rhs) { return rhs + lhs; }
Mod operator-(const ll &lhs, const Mod &rhs) { return Mod(lhs - rhs.value); }
Mod operator*(const ll &lhs, const Mod &rhs) { return rhs * lhs; }
Mod operator/(const ll &lhs, const Mod &rhs) { return Mod(lhs) / rhs.value; }

ll perm_mod(ll n, ll r, ll mod)
{
    Mod res = Mod(1);
    for (int i = 0; i < r; i++)
    {
        res *= n - i;
    }
    return res.value;
}


ll comb_mod(ll n, ll r, ll mod)
{
    r = min(r, n - r);
    return Mod(perm_mod(n, r, mod)) / perm_mod(r, r, mod);
}


int main()
{
    const ll MOD = 1e9 + 7;
    ll n, a, b;
    cin >> n >> a >> b;
    cout << (Mod(2).pow(n) - 1LL - comb_mod(n, a, MOD) - comb_mod(n, b, MOD)).value << endl;
}


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

using namespace std ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	int n ;
	cin>>n ;
	long long arr[n] ;
	for(int i = 0 ; i < n ; ++i)
		cin>>arr[i] ;
	long long ans = 0ll ;
	sort(arr, arr + n) ;
	while(true)
	{
		bool t = true ;
		for(int i = 0 ; i < n ; ++i)
			t &= (arr[i] < n) ;
		if(t)
			break ;
		long long now = arr[n-1] / n ;
		ans += now ;
		arr[n-1] -= now * n ;
		for(int i = 0 ; i < n-1 ; ++i)
			arr[i] += now ;
		sort(arr , arr + n) ;
	}
	return cout<<ans<<"\n" , 0 ;
}

Measured memory_bytes: 256
N = int(input())
H = [int(j) for j in input().split()]
maximum = 0
cnt = 0
for i in range(0,N-1):
    
    if H[i] >=H[i+1]:
        cnt+=1
        if maximum < cnt:
            maximum = cnt
    else:
        cnt=0
        
print(maximum)

Measured memory_bytes: 14252
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#define int long long
#define N 100009
using namespace std;

int n;
string s;
int ans;
map<string, int > mp;
char ss[10000];
signed main() {
	cin>>n;
	for(int i=1; i<=n; i++) {
		cin>>s;
		for(int j=0; j<s.length(); j++) {
			ss[j]=s[j];
		}
		int chang=s.length();
		sort(ss,ss+chang);
		s.clear();
		for(int j=0; j<chang; j++) {
			s+=ss[j];
		}
		mp[s]=mp[s]+1;
	}
	int itt=0;
	for (map<string, int >::iterator it=mp.begin(); it != mp.end(); it++) {
		//cout<<it->second<<endl;
		itt=it->second;
		//cout<<itt<<endl;
		ans+=((itt)*(itt-1))/2;
		//cout<<ans<<" ansans"<<endl;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
 
 
int main(){
 
  int n; cin>>n;
  int arr[n];
  for(int i=0;i<n;i++) cin>>arr[i];
  
  int ans = 1e9;
  for(int k=-100;k<=100;k++){
		int cost = 0;
    	for(int i=0;i<n;i++) cost += (k-arr[i])*(k-arr[i]);
    	ans = min(ans,cost);
  }
  cout<<ans;
  
 return 0; 
}

Measured memory_bytes: 3620