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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

using namespace std;

#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;i++)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;i++)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main(){
#define int ll
  int n,x; cin >> n >> x;
  vi a(n); rep(i,n) cin >> a[i];
  int ans = 0;
  if(a[0] > x){
    ans += a[0] - x;
    a[0] = x;
  }
  rep(i,n-1)
    if(a[i] + a[i+1] > x){
      ans += a[i] + a[i+1] - x;
      a[i+1] = x - a[i];
    }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<28;
const ll INF=1ll<<50;
const double pi=acos(-1);
const double eps=1e-8;
const int mod=1e9+7;
const vi emp;
const int dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
const int DX[8]={-1,-1,-1,0,0,1,1,1},DY[8]={1,0,-1,1,-1,1,0,-1};

string func(string s,bool t,bool I){
	if(I) s=s+((t)?"#":".");
	else s=((t)?"#":".")+s;
	return s;
}

int n;

int main(){
	cin>>n;
	string s,t;
	bool flag=1;
	for(int i=0;i<n;i++){
		for(int i=0;i<4;i++){
			string cs=func(s,i/2,flag),ct=func(t,i%2,flag);
			printf("%s\n%s\n",cs.c_str(),ct.c_str());
			fflush(stdout);
			string c;
			cin>>c;
			if(c=="T"){
				s=cs;
				t=ct;
				break;
			}
			else if(c=="end") return 0;
		}
		if(s.size()!=i+1){
			flag=0;
			i--;
		}
	}
}

Measured memory_bytes: 596
using System;
using System.Linq;

class D
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var l = Console.ReadLine().Split().Select(int.Parse).OrderBy(x => -x).ToArray();

		var r = 0;
		for (int i = 0; i < n - 2; i++)
			for (int j = i + 1, k = n - 1; j < k; j++)
			{
				while (j < k && l[i] >= l[j] + l[k]) k--;
				r += k - j;
			}
		Console.WriteLine(r);
	}
}


Measured memory_bytes: 13408
#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++)
using ll = long long;
int a[100001];
int x[100001];
int y[100001];
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

int main() {
    int N;
    cin >> N;
    rep(i, N) cin >> a[i];
    x[0] = a[0];
    rep2(i, N - 1) {
        x[i] = gcd(x[i - 1], a[i]);
    }
    y[N-1] = a[N-1];
    for (int i = N-2; i >= 0; --i) {
        y[i] = gcd(y[i + 1], a[i]);
    }
    int ans = 0;
    for (int i = 1; i < N-1; i++) {
        ans = max(ans, gcd(x[i - 1], y[i + 1]));
    }
    ans = max(ans, y[1]);
    ans = max(ans, x[N-2]);
    cout << ans << endl;
}

Measured memory_bytes: 4712
#include <stdio.h>

int main()
{
    char s[3][11], ret[4];
    scanf("%s %s %s", s[0], s[1], s[2]);
    for (int i = 0; i < 3; i++)
        ret[i] = s[i][0] - 'a' + 'A';
    ret[3] = 0;
    printf("%s\n", ret);
    return 0;
}

Measured memory_bytes: 128
s = input()
t = input()
S,T = len(s),len(t)
dp = [[0]*(T+1) for _ in range(S+1)]
for i in range(S):
    for j in range(T):
        if s[i]==t[j]:
            dp[i+1][j+1] = 1 + dp[i][j]
        else:
            dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j])
ans = ''
i,j = S,T
while dp[i][j]:
    if dp[i][j] ==dp[i][j-1]:
        j-=1
    elif dp[i][j] == dp[i-1][j]:
        i-=1
    else:
        ans = s[i-1] + ans
        i-=1
        j-=1
print(ans)

Measured memory_bytes: 144592
#include<stdio.h>
 
int main(void)
{
    int i, j = 0, seisu[10000], max = -10000000, min = 10000000, num;
    long int sum = 0;
    scanf("%d", &i);
 
    while(j != i)
    {
        scanf("%d", &seisu[j]);
 
        j++;
    }
 
    j = 0;
 
    for(j=0; j<i; j++)
    {
        num = seisu[j];
 
        if(max < num)
        {
            max = num;
        }
         
        if(min > num)
        {
            min = num;
        }
 
        sum = sum + num;
    }
 
    printf("%d %d %ld\n", min, max, sum);
 
    return 0;
}

Measured memory_bytes: 640
// Goods things are coming, just keep believing 
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
 
#define FOR(i, x, n) for(ll i = x; i < n; i++) 
#define pb push_back
#define pf push_front
#define ll long long
#define hii cout << "hii" << endl
#define okay cout << "okay" << endl
// #define hey cout << "hey" << endl
#define pii pair<int, int>
#define pll pair<ll, ll>
#define mp make_pair
#define endl '\n'
#define ff first 
#define int long long
#define ss second
#define vi vector<int>
#define all(s) s.begin(), s.end()
#define si size()
 #define ld long double
#define INF 1000000000;
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; } 
 
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE
 
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
 
 
 
const int N = 2e5 + 5;
const int LG = 20;
const int mod = 1e9 + 7;

int arr[N];
// int n, m;
vector<pair<int, int>> v;

int h, n;
int DP[N];

int f(int h)
{
	if(h <= 0)
	{
		return 0;
	}
	if(DP[h] != -1)
	{
		return DP[h];
	}
	int ans = mod * mod;
	for(int i = 0; i < n; i++)
	{
		ans = min(ans, v[i].second + f(h - v[i].first));
	}
	return DP[h] = ans;
}

void solve()
{
	memset(DP, -1, sizeof(DP));
	cin >> h >> n;
	for(int i = 0; i < n; i++)
	{
		int a, b;
		cin >> a >> b;
		v.push_back({a, b});
	}
	cout << f(h) << endl;
}

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

	int t = 1;
	// cin >> t;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define mod 1000000007
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
#define ff first
#define endl "\n"
#define ss second
#define all(v) v.begin(), v.end()
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res % p;
}
int lcm(int a, int b)
{
    return a / __gcd(a, b) * b;
} 
void solve()
{
    int a, b, c,k;
    cin >> a >> b >> c>>k;
    int g = 0;
    while(b<=a){
        b = b * 2;
        g++;
    }
    while(c<=b){
        c = c * 2;
        g++;
    }
    if(g<=k){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tc;
    tc = 1;
    //cin >> tc;
    while (tc--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 3640
S=input()
stack =[]
for s in S:
    if not stack and s=='B':
      #continue文は、for文やwhile文のブロック処理中に使用。
      #continue文を使用すると、それ以降の処理を行わず、for文やwhile文のブロックの先頭に戻る。
      continue
    elif s=='B':
        stack.pop()
    else:
        stack.append(s)
#''.join(list)でlistを文字列化
print(''.join(stack))

Measured memory_bytes: 2940
#include <iostream>                                             
#include <cstdio>                                               
using namespace std;                                            
                                                                
int main() {                                                    
  long long  n;                                                 
  scanf("%lld", &n);                                            
  long long R[n];                                               
  for (int t=0; t<n; t++) {                                     
    scanf("%lld", &R[t]);                                       
  }                                                             
  long long  minv = R[0];                                       
  long long  maxv = R[1]-R[0];                             
  for (long long j=1; j<n; j++) {                               
    maxv = (long long)max(maxv,R[j]-minv);                      
    minv = (long long)min(minv,R[j]);                           
  }                                                             
  printf("%lld\n", maxv);                                       
  return 0;                                                     
}                                                               
                                                                
                                                                
                                

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

int main(){
int N, T;
cin >> N >> T;
int ans, cost = 1000;
bool flag = false;
for(int i = 0; i < N; i++){ 
     int c, t;
     cin >> c >> t;
     if(t <= T && cost >= c){
        cost = c;
        flag = true;
     }

}

if(flag == false)cout << "TLE" << endl; 
else cout << cost << endl; 
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  char S[4];
  int s[4],c1=0,c2=0;
  cin >> S;
  for(int i = 0; i < 4; i++) s[i] = (int)S[i];
  if(s[0] == s[1]){
      if(s[2] == s[3] && s[0] != s[2]){
          cout << "Yes\n" << endl;
          return 0;
      }
  }
  else if(s[0] == s[2]){
      if(s[1] == s[3] && s[0] != s[1]){
          cout << "Yes\n" << endl;
          return 0;
      }
  }
  
  else if(s[0] == s[3]){
      if(s[1] == s[2] && s[0] != s[1]){
          cout << "Yes\n" << endl;
          return 0;
      }
  }
  cout << "No\n" << endl;
  
  
  return 0;
}


Measured memory_bytes: 256
//!!WA
// consider the case of n,k=2,6
#include <bits/stdc++.h>
#define pq priority_queue
#define mp make_pair
#define cauto const auto &

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

#define clr(ar, val) memset(ar, val, sizeof(ar))

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

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

using namespace std;

typedef long long int64;
typedef long long lint;
typedef long long lli;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

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

ll n, k;
int main() {
    cin >> n >> k;
    if (k & 1) {
        cout << (n / k) * (n / k) * (n / k);
        return 0;
    }
    cout << (n / (k / 2) - n / k) * (n / (k / 2) - n / k) *
                    (n / (k / 2) - n / k) +
                (n / k) * (n / k) * (n / k);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char S[100010];
int main()
{
	int sum=1;
	int n;
	scanf("%d",&n);
	scanf("%s",S);
	for (int i=1;i<n;i++)
	  if (S[i]!=S[i-1]) sum++;
	cout<<sum;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
cin>>s;
int ans;
if(s=="SAT") ans=1;
if(s=="FRI") ans=2;
if(s=="THU") ans=3;
if(s=="WED") ans=4;
if(s=="TUE") ans=5;
if(s=="MON") ans=6;
if(s=="SUN") ans=7;
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 256
def main():
    N = 20; M = 15
    MP = [[-1]*M for i in range(N)]
    L = 0
    for i in range(N-1):
        s = input()
        for j in range(M):
            c = s[j]
            if c == 'O':
                sx = j; sy = i
            elif c == 'X':
                MP[i][j] = L
                L += 1

    dd = ((-1, 0), (-1, -1), (0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, 1))

    INF = 30
    D = {}
    def dfs(state, x, y):
        key = (state, x, y)
        if key in D:
            return D[key]
        if y >= N-2:
            return 0
        r = INF
        for dx, dy in dd:
            nx = x + dx; ny = y + dy
            if not 0 <= nx < M or not 0 <= ny < N:
                continue
            k = MP[ny][nx]
            if k == -1 or state & (1 << k) == 0:
                continue
            n_state = state ^ (1 << k)
            nx += dx; ny += dy
            while 0 <= nx < M and 0 <= ny < N:
                k = MP[ny][nx]
                if k == -1 or state & (1 << k) == 0:
                    break
                n_state ^= (1 << k)
                nx += dx; ny += dy
            else:
                if (nx == -1 or nx == M) and ny == N-1:
                    return 1
                continue
            r = min(r, dfs(n_state, nx, ny) + 1)
        D[key] = r
        return D[key]
    r = dfs(2**L-1, sx, sy)
    print(r if r < INF else -1)
main()



Measured memory_bytes: 16696
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define ALL(a) a.begin(), a.end()
ll dx[4] = { 0, 1, 0, -1 };
ll dy[4] = { 1, 0, -1, 0 };
const ll INF = 1e14;
const ll MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i, N) { cin >> A[i]; }
    // X <= K であるとは
    // XとKのbitで初めて一致しなかった桁をdとすると
    // dより上位の桁についてはXとKと一致
    // d桁目についてはXは0でKは1
    // dより下位の桁についてはXは何でも良い
    ll cur = 1;
    while ((cur << 1) <= K) { // Kまでcurを左シフトする
        cur <<= 1;
    }
    ll x = 0;
    while (cur > 0) { // A[i]のビットを一つずつ調べる
        int zero = 0, one = 0; // 0と1の数を数える
        for (int i = 0; i < N; ++i) { // A[i]のビットを調べる
            if ((cur & A[i]) == 0) {
                ++zero;
            } else {
                ++one;
            }
        }
        if (zero > one) {
            if (x + cur <= K) {
                x += cur;
            }
        }
        cur >>= 1;
    }
    ll ret = 0;
    for (int i = 0; i < N; i++) {
        ret += (x ^ A[i]);
    }

    std::cout << ret << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;

#define RMAX 500
int tid[RMAX];
int pid[RMAX];
int time[RMAX];
int ok[RMAX];

#define TMAX 50
#define PMAX 10


int pen[TMAX][PMAX];
int pent[TMAX];
int cor[TMAX];


#define TEST 0

struct Dat{
	int team;
	int cor;
	int pent;
	Dat(int team,int cor,int pent):team(team),cor(cor),pent(pent){}
	bool operator<(const Dat& ano)const{
		if(cor!=ano.cor)return cor>ano.cor;
		if(pent!=ano.pent)return pent<ano.pent;
		return team<ano.team;
	}
};


int main(void){
	int t,p,r;
	while(scanf("%d%d%d",&t,&p,&r)==3&&(t||p||r)){
		for(int i=0;i<r;i++){
			scanf("%d%d%d",tid+i,pid+i,time+i);
			int ch;
			while((ch=getchar())<=' '){}
			ok[i]=ch=='C'?1:0;
			while(getchar()>' '){}
		}
		if(TEST){
			for(int i=0;i<r;i++){
				printf("%d\n",ok[i]);
			}
		}
		for(int i=0;i<t;i++){
			pent[i]=0;
			cor[i]=0;
			for(int j=0;j<p;j++){
				pen[i][j]=0;
			}
		}
		for(int i=0;i<r;i++){
			int team=tid[i]-1;
			int prob=pid[i]-1;
			if(ok[i]){
				cor[team]++;
				pent[team]+=pen[team][prob]+time[i];
			}else{
				pen[team][prob]+=1200;
			}
		}
		vector<Dat> vec;
		for(int i=0;i<t;i++){
			vec.push_back(Dat(i,cor[i],pent[i]));
		}
		sort(vec.begin(),vec.end());
		for(int i=0;i<vec.size();i++){
			printf("%d %d %d\n",vec[i].team+1,vec[i].cor,vec[i].pent);
		}
	}
	return 0;
}

Measured memory_bytes: 1048
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int n, m;
int p[maxn], belong[maxn];
int fa[maxn];
int fd(int f){
    return f == fa[f] ? f : fa[f] = fd(fa[f]);
}
int main()
{
    ios::sync_with_stdio(false);
    cin >> n >> m;
    for(int i = 1; i <= n; ++i){
        cin >> p[i];
        fa[i] = i;
    }
    for(int i = 1; i <= m; ++i){
        int a, b;
        cin >> a >> b;
        int fl = fd(a), fr = fd(b);
        fa[fl] = fr;
    }
    for(int i = 1; i <= n; ++i){
        int f = fd(i);
        belong[p[i]] = f;
    }
    int ans = 0;
    for(int i = 1; i <= n; ++i){
        if(belong[i] == fd(i))
            ++ans;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>
#define max(a, b) ((a)>(b)?(a):(b))
#define min(a, b) ((a)>(b)?(b):(a))
const long INF = 1l<<60;
int N, K, P[5555], C[5555];
int main(){
	scanf("%d%d", &N, &K);
	for(int i=1; i<=N; i++)scanf("%d", P+i);
	for(int i=1; i<=N; i++)scanf("%d", C+i);
	long ans = -INF;
	for(int i=1; i<=N; i++){
		int t = i, l = 0;
		long s = 0;
		do{
			t = P[t];
			s += C[t];
			l++;
		}while(t != i);
		long score = 0, k = min(K, l);
		if(s > 0){
			score = max(0, (long)(K-l) / l * s);
			if(K > l){
				k = K % l + l;
			}
		}
		while(k--){
			t = P[t];
			score += C[t];
			ans = max(ans, score);
		}
	}
	printf("%ld\n", ans);
	return 0;
}

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

namespace AtTest.ABC_170
{
    class A
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int[] xs = ReadInts();
            for(int i = 0; i < 5; i++)
            {
                if (xs[i] != i + 1)
                {
                    WriteLine(i + 1);
                    return;
                }
            }
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 27564
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  ll s = b-a+1;
  ll nbc = b/c - (a-1)/c, nbd = b/d - (a-1)/d;
  ll cd = c*d/__gcd(c,d);
  ll nbcd = b/cd - (a-1)/cd;
  cout << s - nbc - nbd + nbcd;
  return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int eval(string s){
    rep(i,s.size())if(s[i]=='+')s[i]=' ';
    stringstream ss(s);

    int res=0;
    int val;
    while(ss>>val)res+=val;
    return res;
}

signed main(){
    string S;
    cin>>S;

    int N=S.size();
    int ans=0;
    rep(i,1<<(N-1)){
        string s=string(1,S[0]);
        for(int j=1;j<N;j++){
            if(i>>(j-1)&1)s+="+";
            s+=S[j];
        }
        ans+=eval(s);
    }
    cout<<ans<<endl;
    return 0;
}


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

vector<int> topological_sort(const vector<vector<int>>& g)
{
    vector<int> ideg(g.size());
    for (const auto& v : g) {
        for (const auto& u : v) {
            ideg[u]++;
        }
    }
    vector<int> sorted;
    for (int i = 0; i < g.size(); i++) {
        if (ideg[i] == 0) {
            sorted.push_back(i);
        }
    }
    int i = 0;
    while (i < sorted.size()) {
        int v = sorted[i];
        for (const auto& u : g[v]) {
            assert(ideg[u] > 0);
            if (--ideg[u] == 0) {
                sorted.push_back(u);
            }
        }
        i++;
    }
    if (i != g.size()) sorted.clear();
    return sorted;
}

int main()
{
    int N, M; cin >> N >> M;
    vector<vector<int>> g(N+1);
    for (int i = 0; i < N-1+M; i++) {
        int a, b; cin >> a >> b;
        g[a].push_back(b);
    }
    vector<int> topo = topological_sort(g);
    vector<int> ord(topo.size());
    for (int i = 0; i < topo.size(); i++) {
        ord[topo[i]] = i;
    }
    vector<int> ans(N+1);
    for (int i = 0; i < N+1; i++) {
        for (const auto& v : g[i]) {
            if (ans[v] == 0 || ord[ans[v]] < ord[i]) {
                ans[v] = i;
            }
        }
    }
    for (int i = 1; i < ans.size(); i++) {
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 7404
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int taro_score = 0;
        int hanako_score = 0;
        for(int i = 0; i < n; i++){
            String taro = sc.next();
            String hanako = sc.next();
            int judge = taro.compareTo(hanako);
            if(judge == 0){
                taro_score++;
                hanako_score++;
            }else if(judge < 0){
                hanako_score += 3;
            }else{
                taro_score += 3;
            }
        }
        System.out.println(taro_score + " " + hanako_score);
    }
}


Measured memory_bytes: 29324
A=[[int(i) for i in input().split()] for _ in range(3)]
N=int(input())
for _ in range(N):
    b=int(input())
    for i in range(3):
        for j in range(3):
            if A[i][j]==b:
                A[i][j]=-1
flag=False
for h in range(3):
    cnt=0
    for w in range(3):
        if A[h][w]==-1:
            cnt+=1
    if cnt==3:
        flag=True
for w in range(3):
    cnt=0
    for h in range(3):
        if A[h][w]==-1:
            cnt+=1
    if cnt==3:
        flag=True
cnt=0
for d in range(3):
    if A[d][d]==-1:
        cnt+=1
if cnt==3:
    flag=True
cnt=0
for d in range(3):
    if A[d][2-d]==-1:
        cnt+=1
if cnt==3:
    flag=True
print('Yes' if flag else 'No')


Measured memory_bytes: 3064
import math
a,b = map(int,input().split())
lis = [list(map(int,input().split())) for i in range(a)]
num = 0
ans = 0
for i in range(a-1):
    for j in range(i+1,a):
        num = 0
        for k in range(b):
            num += (lis[i][k] - lis[j][k]) ** 2
        if math.ceil(math.sqrt(num)) == math.floor(math.sqrt(num)):
            ans += 1
print(ans)

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

using namespace std;

typedef long long ll;
#define mkp make_pair
const ll modl = 1e9 + 7;


ll compat[22][22];
ll dp[22][(1 << 22)];

ll solve(ll man, ll subsetWomen, ll n) {

	if (man == n) {
		if (subsetWomen == 0) return 1;
		return 0;
	}

	if (dp[man][subsetWomen] != -1) return dp[man][subsetWomen];

	ll ans = 0ll;
	for (int i = 0; i < n; i++) {

		if (((1 << i) & subsetWomen) and (compat[man][i])) {
			ans += solve(man + 1, (subsetWomen ^ (1 << i)), n);
		}
	}

	return dp[man][subsetWomen] = (ans % modl);
}

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

	for (ll i = 0; i < n; i++)
		for (ll j = 0; j < n; j++)
			cin >> compat[i][j];


	cout << solve(0, (1 << n) - 1, n) << endl;
	return 0;
}


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

#define fo(i,s,t) for(int i = s; i <= t; ++ i)
#define fd(i,s,t) for(int i = s; i >= t; -- i)
#define bf(i,s) for(int i = head[s]; i; i = e[i].next)
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pb push_back
#define VI vector<int>
#define sf scanf
#define pf printf
#define fp freopen
#define SZ(x) ((int)(x).size())
#ifdef MPS
#define D(x...) printf(x)
#else
#define D(x...)
#endif
typedef long long ll;
typedef double db;
typedef unsigned long long ull;
const int inf = 1<<30;
const ll INF = 1ll<<60;
const db Inf = 1e20;
const db eps = 1e-9;

void gmax(int &a,int b){a = (a > b ? a : b);}
void gmin(int &a,int b){a = (a < b ? a : b);}

int L, n, m;
struct edge{int u, v, w;}e[65];

int main()
{
	cin >> L;
	int V = 0;
	while((1<<V) <= L) ++ V; 
	-- V;
	pf("%d ", V+1);
	int x = (1<<V);
	fo(i,1,V) e[++m] = (struct edge){i,i+1,(1<<(i-1))}, e[++m] = (struct edge){i,i+1,0};
	while(x != L)
	{
		int l = 1, r = V, mid, p;
		while(l <= r)
		{
			mid = (l + r) >> 1;
			if(x + (1<<(mid-1))-1 < L)
			{
				p = mid;
				l = mid + 1;
			}
			else r = mid - 1;
		}
		e[++m] = (struct edge){p,V+1,x};
		x += (1<<(p-1));
	}
	pf("%d\n",m);
	fo(i,1,m) pf("%d %d %d\n",e[i].u,e[i].v,e[i].w);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI acos(-1)
#define eq(x,y) (fabs((x)-(y)) < eps)
#define debug(x) cerr<<#x<<" = "<<x<<endl;
#define pb push_back
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define bump cout<<"bleh\n"
#define all(v) (v).begin(),(v).end()

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

using namespace std;

typedef long long ll;
typedef unsigned long long llu;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
const int nmax=1e5+10;
const int eps=1e-8;
const ll infll=1e15;


int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;

    map<string,int>mp;
    vector<string>v;

    int maxx=-inf;

    for(int i=0;i<n;i++){
        string t;
        cin>>t;

        mp[t]++;
        maxx=max(maxx,mp[t]);
    }

    for(auto i: mp){
        if(i.second==maxx){
            v.pb(i.first);
        }
    }

    sort(all(v));

    for(auto i: v)
        cout<<i<<"\n";


    return 0;
}


Measured memory_bytes: 25584
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps=1e-8;
int main() {
	int n, m; cin >> n >> m;
	int chk[1001] = {};
	rep(i, m) {
		int s, t; cin >> s >> t; chk[s]++; chk[t]--;
	}
	Rep(i, 1, n + 1) {
		chk[i] += chk[i - 1];
	}
	int cnt = 0;
	rep(i, n + 1) {
		if (chk[i]) {
			cnt += 3;
		}
		else {
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3120
n, m = list(map(int, input().split()))
l = [200000 for i in range(0, n-1)]

for i in range(0, m):
    a, b = list(map(int, input().split()))
    l[a-1] = min([l[a-1], b-2])

right = -1
count = 0

for i in range(0, n-1):
    if i > right and not l[i] == 200000:
        count += 1
        right = l[i]
    elif i <= right and not l[i] == 200000:
        right = min([l[i], right])

print(count)


Measured memory_bytes: 7088
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		int h = sc.nextInt();
		int a = sc.nextInt();
		int count = 0;

		if (h % a == 0) {
			count = h / a;
		} else {
			count = h / a + 1;
		}
		System.out.println(count);

		sc.close();

	}

}


Measured memory_bytes: 35624
use strict;

$_ = <>;
chomp;

my ($n, $k) = split(/\s+/);

my @all;

for (my $i = 0; $i < $k; $i++) {
    my $num = <>;
    my $liststr = <>;

    chomp $num;
    chomp $liststr;

    my @tmp = split(/\s+/, $liststr);
    push(@all, @tmp);
}

my %list = ();
for (@all) { $list{$_} = 1 }

my @x = keys %list;
my $cnt = $n - @x;
print "$cnt\n";



Measured memory_bytes: 5740
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int64_t,int64_t> pll;
typedef vector<int64_t> vl;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
const long double PI = acos(-1);
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define ALL(a) begin(a),end(a)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

void solve() 
{
    int n;cin>>n;
    set<int>a;REP(i,n){int s;cin>>s;a.insert(s);}
    cout<<(a.size()!=n?"NO":"YES")<<endl;

}

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


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

// main.cpp

int main() {
  std::int_fast64_t n;
  std::cin >> n;
  std::vector<std::int_fast64_t> a, b, c;
  a.reserve(n);
  b.reserve(n);
  c.reserve(n);
  std::copy_n(std::istream_iterator<std::int_fast64_t>(std::cin), n, std::back_inserter(a));
  std::copy_n(std::istream_iterator<std::int_fast64_t>(std::cin), n, std::back_inserter(b));
  std::copy_n(std::istream_iterator<std::int_fast64_t>(std::cin), n, std::back_inserter(c));
  std::sort(a.begin(), a.end());
  std::sort(b.begin(), b.end());
  std::sort(c.begin(), c.end());

  std::vector<std::int_fast64_t> b2c;
  b2c.reserve(n);
  for (const std::int_fast64_t& b_i : b) {
    b2c.push_back(std::distance(std::upper_bound(c.begin(), c.end(), b_i), c.end()));
  }

  std::vector<std::int_fast64_t> b2c_sum({0});
  b2c_sum.reserve(n + 1);
  std::reverse(b2c.begin(), b2c.end());
  for (const std::int_fast64_t& b2c_i : b2c) {
    b2c_sum.push_back(b2c_sum.back() + b2c_i);
  }
  std::reverse(b2c_sum.begin(), b2c_sum.end());

  std::vector<std::int_fast64_t> a2b2c;
  a2b2c.reserve(n);
  for (const std::int_fast64_t& a_i : a) {
    a2b2c.push_back(b2c_sum[std::distance(b.begin(), std::upper_bound(b.begin(), b.end(), a_i))]);
  }

  std::cout << std::accumulate(a2b2c.begin(), a2b2c.end(), static_cast<std::int_fast64_t>(0)) << std::endl;
  return 0;
}

Measured memory_bytes: 4992
#include <stdio.h>
 
#define MAX 1000000
int prime[MAX]; 

int main(void) {
  int n, i, j, cnt;
  prime[0] = prime[1] = 0;
  for (i = 2; i < MAX; i++) prime[i] = 1;
  for (i = 2; i < 1001; i++)
    if (prime[i])
      for (j = 2 * i; j < MAX; j += i)
        prime[j] = 0;
  while (scanf("%d", &n) != EOF) {
    cnt = 0;
    for (i = 2; i <= n; i++)
      cnt += prime[i];
    printf("%d\n", cnt);
  }
  return 0;
}

Measured memory_bytes: 4500
<?php

list($n, $m) = explode(" ", trim(fgets(STDIN)));

$a = array();
for ($i = 0; $i < $n; $i++) {
    $a[] = explode(" ", trim(fgets(STDIN)));
}

$b = array();
for ($i = 0; $i < $m; $i++) {
    $b[] = explode(" ", trim(fgets(STDIN)));
}

$c = array();
for ($i = 0; $i < $n; $i++) {
    $sum = 0;
    for ($j = 0; $j < $m; $j++) {
        $sum += $a[$i][$j] * $b[$j][0];
    }
    $c[] = $sum;
}

foreach ($c as $row) {
    echo $row . "\n";
}


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

int main(){
  int K, T;
  cin >> K >> T;
  vector<int> A(T);
  for(int i=0; i<T; i++){
    cin >> A.at(i);
    A.at(i)=-A.at(i);
  }
  sort(A.begin(), A.end());
  for(int i=0; i<T; i++){
    A.at(i)=-A.at(i);
  }
  if(A.at(0)<=(K+1)/2){
    cout << 0 << endl;
  }
  else{
    if(K%2==0 && A.at(0)<K){
      cout << (A.at(0)-K/2)*2-1 << endl;
    }
    else if(K%2==1 && A.at(0)<K){
      cout << (A.at(0)-(K+1)/2)*2 << endl;
    }
    else{
      cout << K-1 << endl;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int n;
  int a[105]={0},b[105]={0};
  cin>>n;
  rep(i,n)cin>>a[i];
  REP(i,1,n)a[i]+=a[i-1];
  rep(i,n)cin>>b[i];
  for(int i=n-2;i>=0;i--)b[i]+=b[i+1];
  int ans=0;
  rep(i,n){
    ans=max(ans,a[i]+b[i]);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
S = input().strip()
Q = int(input())

head = ""
tail = ""
rev = False
for _ in range(Q):
	query = input().strip().split()
	if query[0] == "1":
		rev = not rev
	else:
		if query[1] == "1":
			if rev:
				tail = tail + query[2]
			else:
				head = query[2] + head
		else:
			if rev:
				head = query[2] + head
			else:
				tail = tail + query[2]

result = head + S + tail

if rev:
	result = "".join(reversed(result))

print(result)


Measured memory_bytes: 6240
#include <stdio.h>
long long int min(long long int a, long long int b){return a < b ? a : b;}
int max(int a, int b){return a > b ? a : b;}
int main(void){
    int n, k;
    scanf("%d%d", &n, &k);
    int a[15];
    int i, j;
    for(i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }
    long long int ans = 999999999999999;
    int bit;
    int a_temp[15];
    int can_see = 0;
    int maxh = 0;
    long long int cost;
    for(bit = 0; bit < (1 << n); ++bit){
        cost = 0;
        can_see = 0;
        for(i = 0; i < n; i++){
            a_temp[i] = a[i];
        }
        for(i = 0; i < n; i++){
            if(bit & (1 << i)){
                can_see++;
                //0番目から(i-1)番目までの建物の高さの最大値を求める
                //ただしi = 0のときは0
                maxh = 0;
                for(j = 0; j <= i - 1; j++){
                    maxh = max(maxh, a_temp[j]);
                }
                //i番目の高さをmaxh+1以上にする
                if(a_temp[i] < maxh + 1){
                    cost += maxh + 1 - a_temp[i];
                    a_temp[i] = maxh + 1;
                }
            }
        }
        if(can_see >= k){
            ans = min(ans, cost);
        }
    }
    printf("%lld\n", ans);
    return 0;
}

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

int main() {
  long A, B, C, X, Y; cin >> A >> B >> C >> X >> Y;
  int z = min(X,Y);
  cout << min({A*X+B*Y, 2*C*z+A*(X-z)+B*(Y-z), 2*C*max(X,Y)}) << endl;
}

Measured memory_bytes: 3604
n=int(input())
a,b=map(int,input().split())
p=list(map(int,input().split()))
x=0
y=0
z=0
for i in range(n):
  if p[i]<=a:
    x+=1
  elif a+1<=p[i]<=b:
    y+=1
  else:
    z+=1
print(min(x,y,z))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <bits/stdc++.h>

using namespace std;
using ll = long long ;
const int INF = 1001001001;

int main() {

    int n ;
    cin >> n ;
    vector<int> a(n) ;
    vector<int> c(1000005) ;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i] ;
        //c[a[i]] = 1 ;
    }

    for (int  x : a)
    {
        if(c[x]!=0){
            c[x] = 2 ;
            continue ;
        }
        for (int j = x; j < c.size(); j+= x) c[j]++ ;        
    }

    int ans = 0 ;
    for (int x: a)
    {
        if(c[x]==1) ans++ ;
    }
    
     cout << ans << endl ;
    
       return 0; 
}

Measured memory_bytes: 7952
import copy
import numpy as np
N, L = map(int, input().split())
taste = []
for i in range(N):
  taste.append(L + i)

pie = []
for i in range(N):
  temp = copy.deepcopy(taste)
  del temp[i]
  pie.append(abs(sum(taste) - sum(temp)))
del taste[np.argmin(pie)]
print(sum(taste))

Measured memory_bytes: 12468
#include<stdio.h>
double dp[2][100];
int main(){
	while(1){
	int n;
	scanf("%d",&n);
	if(n==0)return 0;
	int i,j;
	double ans=0.0f;
	for(j=0;j<100;j++)dp[0][j]=0.0f;
	dp[0][1]=1.0f;
	for(i=0;i<n-1;i++){
		for(j=0;j<100;j++)dp[(i+1)%2][j]=0.0f;
		dp[(i+1)%2][1]+=dp[i%2][0];
		for(j=1;j<99;j++){
			double p=1.0f/(1<<j);
			dp[(i+1)%2][j+1]+=dp[i%2][j]*p;
			dp[(i+1)%2][0]+=dp[i%2][j]*(1-p);
			ans+=dp[i%2][j];
		}
	}
	for(j=1;j<100;j++)ans+=dp[(n+1)%2][j];
	printf("%lf\n",ans);
	}
}

Measured memory_bytes: 1060
def check(x):
  n=len(x)
  for i in range(n//2):
    if x[i]!=x[n-1-i]:
      return False
  else:
    return True
s=input()
if check(s) and check(s[:len(s)//2]) and check(s[len(s)//2+1:]):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
import sys
# from bisect import *
# from collections import *
# from copy import deepcopy
# from heapq import *
# from itertools import *
# from math import *
# from operator import *
# from pprint import *

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    H,W = map(int, input().split())
    grid = [list(input().rstrip()) for _ in range(H)]
    q = []
    visited = [[False]*W for _ in range(H)]
    for y in range(H):
        for x in range(W):
            if grid[y][x] == '#':
                q.append((y,x))
                visited[y][x] = True
    ans = -1
    while q:
        ans += 1
        nq = []
        for y,x in q:
            if 0 < x and not visited[y][x-1]:
                visited[y][x-1] = True
                nq.append((y,x-1))
            if x < W-1 and not visited[y][x+1]:
                visited[y][x+1] = True
                nq.append((y,x+1))
            if 0 < y and not visited[y-1][x]:
                visited[y-1][x] = True
                nq.append((y-1, x))
            if y < H-1 and not visited[y+1][x]:
                visited[y+1][x] = True
                nq.append((y+1,x))
        if nq:
            q = nq[:]
        else:
            break
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 116860
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define FFOR(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define rep(i,n) FOR(i,0,n-1)
#define int long long
#define MOD 998244353
#define MAXN  100005
#define P pair<int,int>
 
 
signed main(){
	
	int n;cin>>n;
	
	int cnt=0;
	int tm=n;
	while(tm)cnt+=tm%10,tm/=10;
	
	cout << (n%cnt==0?"Yes":"No") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n) for(ll i=0;i<(n);i++)
#define For1(i,n) for(ll i=1;i<(n);i++)
int main(){
    ll n;cin>>n;
    vector<vector<ll>> a(n,vector<ll> (n-1));
    For(i,n){
        For(j,n-1){
            cin>>a.at(i).at(n-2-j);a.at(i).at(n-2-j)--;
        }
    }
    ll ans=0,vs=0;
    vector<int> match;
    For(i,n) match.push_back(i);
    while(true){
        vector<int> nextmatch,flag(n,0);
        for(auto i:match){
            if(flag.at(i)==0){//iが未試合
            int rival=a.at(i).at(a.at(i).size()-1);
                if(flag.at(rival)==0){//iの対戦相手が未試合
                    if(a.at(rival).at(a.at(rival).size()-1)==i){//iの対戦相手がiと戦う
                        if(a.at(i).size()>1) nextmatch.push_back(i);//対戦表が残っていたらiを翌日の対戦候補に入れる
                        if(a.at(rival).size()>1) nextmatch.push_back(rival);//対戦表が残っていたら対戦相手を翌日の対戦候補に入れる
                        a.at(i).pop_back();a.at(rival).pop_back();//対戦表を消す
                        flag.at(i)++;flag.at(rival)++;//対戦済みフラグを立てる
                        vs++;//消化数を増やす
                    }
                }
            }
        }
        ans++;
        if(nextmatch.size()==0){
            if(vs==(n*(n-1))/2) break;
            else{
                cout<<-1<<endl;
                return 0;
            }
        }
        match=nextmatch;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 8064
import math
a,b,h,m=map(int,input().split())
h_ang=30*(h+m/60)
m_ang=360*(h+m/60)
ang=(h_ang-m_ang)%360
ang=(ang/180)*math.pi
l=(a**2+b**2-2*b*a*math.cos(ang))**0.5
print(l)

Measured memory_bytes: 9408
#include<iostream>
using namespace std;
#include<string>
#include<utility>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bits/stdc++.h>
#include<stdio.h>
 
int main(){
    int N;
    cin >> N;
    long double x[N],y[N];
    for(int i=0;i<N;++i){
        cin >> x[i] >> y[i];
    }
    long double ans=0;
    int num=0;
    long double dx=0;
    long double dy=0;
    long double dx_2=0;
    long double dy_2=0;
    for(int i=0;i<N;++i){
        for(int j=0;j<N;++j){
            dx=abs(x[i]-x[j]);
            dx_2=pow(dx,2);
            dy=abs(y[i]-y[j]);
            dy_2=pow(dy,2);
            ans+=sqrt(dx_2+dy_2);
        }
    }
    long double h=0;
    h=(long double) N;
    ans=ans/(h);
    cout << fixed << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define ALL(a) (a).begin(),(a).end()
#define P pair<int, int>
typedef long long ll;
using namespace std;

int main()
{
	int n, a, b; cin >> n >> a >> b;
	int ans_ma = min(a, b);
	int ans_mi = max(a + b - n, 0);
	cout << ans_ma <<" "<< ans_mi << endl;
	return 0;
}

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

int main() {
  char ch;
  int counter[26];
  for(int i = 0; i < 26; i++) {
    counter[i] = 0;
  }

  while(cin >> ch) {
    if('a' <= ch && ch <= 'z') {
      int num = ch - 'a';
      counter[num]++;
    } else if ('A' <= ch && ch <= 'Z') {
      int num = ch - 'A';
      counter[num]++;
    }
  }

  for(int i = 0; i < 26; i++) {
    printf("%c", 'a' + i);
    cout << " : " << counter[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 3096
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

constexpr int INF = 1e9;
constexpr ll INFLL = 1e18;
constexpr int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

int main(){
    ios::sync_with_stdio(false); cin.tie(nullptr);
    //cout << fixed << setprecision(6);
    int n; cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];

    int MAX = 1000005;
    vi cnt(MAX, 0);
    for(int i : a){
        if(cnt[i] != 0){
            cnt[i] = 2;
            continue;
        }
        for(int x = i; x < MAX; x += i)
            cnt[x]++;
    }
    int ans = 0;
    for(int i : a){
        if(cnt[i] == 1) ans++;
    }

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

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

struct dsu {
    vector<int> g;
    dsu(int n) : g(n, -1) {}
    int find(int u) {
        return g[u] < 0 ? u : g[u] = find(g[u]);
    }
    bool unite(int u, int v) {
        u = find(u), v = find(v);
        if (u == v) return false;
        if (g[u] > g[v]) swap(u, v);
        g[u] += g[v];
        g[v] = u;
        return true;
    }
    bool same(int u, int v) {
        return find(u) == find(v);
    }
};

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int n, q;
    cin >> n >> q;
    dsu s(n);
    while (q--) {
        int t, u, v;
        cin >> t >> u >> v;
        if (t == 0) {
            s.unite(u, v);
        } else {
            cout << s.same(u, v) << '\n';
        }
    }
    return 0;
}

Measured memory_bytes: 3976
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define upperlimit 1000100
#define INF 1000000100
#define INFL 1000000000000000100LL
#define eps 1e-8
#define endl '\n'
#define sd(n) scanf("%d",&n)
#define slld(n) scanf("%lld",&n)
#define pd(n) printf("%d",n)
#define plld(n) printf("%lld",n)
#define pds(n) printf("%d ",n)
#define pllds(n) printf("%lld ",n)
#define pdn(n) printf("%d\n",n)
#define plldn(n) printf("%lld\n",n)
#define REP(i,a,b) for(i=a;i<=b;i++)
#define mp make_pair
#define pb push_back
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define F first
#define S second
#define clr(a) memset(a,0,sizeof(a))
#define FILEIO(name) \
    freopen(name".in", "r", stdin); \
    freopen(name".out", "w", stdout);

using namespace std;

ll gcd(ll n1,ll n2){
    if(!n1)return n2;
    if(!n2)return n1;
    if(n1%n2==0)return n2;
    return gcd(n2,n1%n2);
}
ll powmod(ll base,ll exponent){
    base%=mod;
    ll ans=1;
    while(exponent){
        if(exponent&1)ans=(ans*base)%mod;
        base=(base*base)%mod;
        exponent/=2;
    }
    ans%=mod;
    return ans;
}
int main()
{
	int a,b;
	sd(a);sd(b);
	if(a*b==15)printf("*");
	else if(a+b==15)printf("+");
	else printf("x");
	return 0;
}

Measured memory_bytes: 256