akhauriyash/Code-Regression huggingface dataset:
#define _USR_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
#define MOD 1000000007

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

    ll N;
    cin >> N;
    
    vector<ll> position;
    map<ll,ll> group;
    
    rep(i,N){
        ll inp;
        cin >> inp;
        position.pb(inp);
        group[inp] = 1;
    }
    rep(i, N){
        ll inp;
        cin >> inp;
        position.pb(inp);
        group[inp] = 2;
    }
    
    sort(all(position));
    
    ll nowgroup = 0;
    ll cnt = 0;
    ll ans = 1;
    
    rep(i,position.size()){
        if(cnt == 0){
            nowgroup = group[position[i]];
            cnt ++;
            cerr<< "----" << 0 << cnt << endl;;
        }
        
        else if(nowgroup != group[position[i]]){
            ans *= cnt;
            ans %= MOD;
            cerr<< "----" << "diff" << cnt << endl;;
            cnt--;
        }
        
        else {
            cnt++;
            cerr<< "----" << "same" << endl;;
        }
    }
    
    cout << ans << endl;
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 14320
mod = 1000000007

def mod_power(a, n):
    if n == 0:
        return 1
    if n % 2:
        return a * mod_power(a, n - 1) % mod
    tmp = mod_power(a, n // 2)
    return tmp * tmp % mod


a, n = [int(i) for i in input().split()]
print(mod_power(a, n))


Measured memory_bytes: 5608
#include<bits/stdc++.h>
using namespace std;
#define sc(a) scanf("%d", &a)
#define sc2(a,b) scanf("%d%d", &a, &b)
#define sc3(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define pri(x) printf("%d\n", x)
#define mp make_pair
#define pb push_back
#define BUFF ios::sync_with_stdio(false);
#define imprime(v) for(int X=0;X<v.size();X++) printf("%d ", v[X]); printf("\n");
#define endl "\n"
const int INF= 0x3f3f3f3f;
const long double pi= acos(-1);
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector< vector< int > > vvi;
const int MOD=1e9+7;
const ll LINF=0x3f3f3f3f3f3f3f3f;

int tentaaux(string &s, char c)
{
  int ret=0;
  bool dif=false;
  for(int i=0;i<s.size();i++)
  {
    if(s[i]!=c) dif=true;
  }
  if(!dif) return 0;
  string nova;
  for(int i=0;i<(int)s.size()-1;i++)
  {
    if(s[i]==c or s[i+1]==c)
    {
      nova.pb(c);
    }
    else nova.pb(s[i]);
  }
  return tentaaux(nova,c)+1;
}

int tenta(string s, char c)
{
  string ss=s;
  for(int i=0;i<s.size();i++)
  {
    if(s[i]==c)
    {
      return tentaaux(ss,c);
    }
  }
  return 10000;
}

int main()
{
  string s;
  cin>>s;
  int resp=10000;
  for(char c='a';c<='z';c++)
  {
    resp=min(tenta(s,c),resp);
  }
  cout<<resp<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <math.h>
using namespace std;

int main()
{
	string S, T;
	bool flag = true;

	cin >> S >> T;

	for(int i =0; i<S.length(); i++){
		if(T[i]!=S[i]){
			flag = false;
			break;
		}
	}


	if(T.length()-1 != S.length()){
		flag = false;
	}

	cout << (flag?"Yes":"No");

	return 0;
	
}

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main() {
  string s;
  cin >> s;
  long long n1 = 0, n2 = 0, ans = 0;
  for (unsigned int i = 0; i < s.length()-1; ++i) {
    char c = s.at(i);
    if (c == '<') {
      ++n1;
    } else {
      ++n2;
      char c0 = s.at(i + 1);
      if (c0 == '<') {
        ans += n1 * (n1 - 1) / 2;
        ans += n2 * (n2 - 1) / 2;
        ans += max(n1, n2);
        n1 = 0;
        n2 = 0;
      }
    }
  }
  if (s.back() == '<') ++n1;
  else ++n2;
  ans += n1 * (n1 - 1) / 2;
  ans += n2 * (n2 - 1) / 2;
  ans += max(n1, n2);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 900
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define MOD 1000000007
#define itn int
#define enld endl
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
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;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int N; cin >> N;
    string s; cin >> s;
    int white = 0;
    int black = 0;
    rep(i,0,SZ(s)){
        if(s[i] == '.') white++;
    }
    int ans = black + white;
    rep(i,0,SZ(s)){
        if(s[i] == '.') white--;
        else black++;
        chmin(ans, black + white);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3756
n = int(input())
trees = [[]]
for i in range(n):
    edges = []
    s = list(map(int, input().split()))
    num = s[1]
    if s[1] != 0:
        edges = s[2:2+num]
    trees.append(edges)

d = [0] * (n+1)
f = [0] * (n+1)


def dfs(x, i=0):
    for y in trees[x]:
        if d[y] != 0:
            continue
        d[y] = i
        i += 1
        i = dfs(y, i)
    f[x] = i
    i += 1
    return i


i = 1
for j in range(1, n+1):
    if d[j] != 0:
        continue
    else:
        d[j] = i
        i += 1
    i = dfs(j, i)
for i in range(1, n+1):
    print(i, d[i], f[i])


Measured memory_bytes: 5656
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readC(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=rdsp;foreach(ref v;t)pick(r,v[i]);}}

void main()
{
  int d, g; readV(d, g); g /= 100;
  int[] p, c; readC(d, p, c); c[] /= 100;
  
  auto m = d.iota.map!(i => (i+1)*p[i]).sum + c.sum;
  auto dp = new int[][](d+1, m+1), inf = 10^^9;
  foreach (dpi; dp) dpi[] = inf;
  dp[0][0] = 0;

  foreach (i; 0..d) {
    auto s = i+1;
    foreach (j; 0..m+1) {
      foreach (k; 0..p[i])
        if (j-k*s >= 0)
          dp[i+1][j] = min(dp[i+1][j], dp[i][j-k*s]+k);
      if (j-(p[i]*s+c[i]) >= 0)
        dp[i+1][j] = min(dp[i+1][j], dp[i][j-(p[i]*s+c[i])]+p[i]);
    }
  }

  writeln(dp[d][g..$].reduce!min);
}


Measured memory_bytes: 6780
#include <iostream>
#include <numeric>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<long>a(3*n);
  for(int i=0; i<3*n; i++)cin >> a[i];
  priority_queue<long>leftq, rightq;
  vector<long>lefts(n+1), rights(n+1);
  for(int i=0; i<n; i++)leftq.push(-a[i]);
  lefts[0]=accumulate(a.begin(), a.begin()+n, 0L);
  for(int i=1; i<=n; i++){
    if(-leftq.top()<a[n+i-1]){
      lefts[i]=lefts[i-1]-(-leftq.top())+a[n+i-1];
      leftq.pop();
      leftq.push(-a[n+i-1]);
    }
    else lefts[i]=lefts[i-1];
  }
  for(int i=2*n; i<3*n; i++)rightq.push(a[i]);
  rights[0]=accumulate(a.begin()+2*n, a.begin()+3*n, 0L);
  for(int i=1; i<=n; i++){
    if(rightq.top()>a[2*n-i]){
      rights[i]=rights[i-1]-rightq.top()+a[2*n-i];
      rightq.pop();
      rightq.push(a[2*n-i]);
    }
    else rights[i]=rights[i-1];
  }
  long ret=lefts[0]-rights[n];
  for(int i=0; i<=n; i++){
    ret = max(ret, lefts[i]-rights[n-i]);
  }
  for(int i=0; i<=n; i++){
    cerr << lefts[i] << ' ' << rights[n-i] << endl;
  }
  cout << ret;
  return 0;
}


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

int main()
{
  int A, B, C, K;

  cin >> A >> B >> C >> K;

  int sum = 0;

  if (A >= K)
  {
    cout << K << endl;
    return 0;
  }
  else
  {
    if (B >= K - A)
    {
      cout << A << endl;
    }
    else
    {
      cout << A - (K - A - B) << endl;
    }
  }

}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
vector<int> dsk[205];
int f[205][205],c[205][205];
const int oo=1e8;
int maxflow=0;
int parent[205];
int visit[205],cnt=0;
int s[205];
int m,n;
void nhap()
{
    cin>>m>>n;
    for (int i=1;i<=m;i++)
    for (int j=1;j<=n;j++)
    {
        char kt;
        cin>>kt;
        if (kt=='o')
        {
            dsk[i].push_back(j+m);
            dsk[j+m].push_back(i);
            c[i][j+m]=c[j+m][i]=1;
        }
        if (kt=='S')
        {
            dsk[0].push_back(i);
            dsk[0].push_back(j+m);
            c[0][i]=c[0][j+m]=oo;
//            cout<<i<<j<<'S'<<endl;
        }
        if (kt=='T')
        {
            dsk[i].push_back(n+m+1);
            dsk[j+m].push_back(n+m+1);
            c[i][n+m+1]=c[j+m][n+m+1]=oo;
//            cout<<i<<j<<'T'<<endl;
        }
    }
}
bool Findpath()
{
    cnt++;
    queue<int> st;
    st.push(0);
    while (!st.empty())
    {
        int u=st.front();
        st.pop();
        if (u==n+m+1) return 1;
        for (int v:dsk[u])
        {
            if (visit[v]==cnt||c[u][v]==f[u][v]) continue;
            visit[v]=cnt;
            parent[v]=u;
            st.push(v);
        }
    }
    return 0;
}
void Increasemaxflow()
{
    s[1]=n+m+1;
    int d=1,x=n+m+1;
    while (x!=0)
    {
        x=parent[x];
        s[++d]=x;
    }
//    for (int i=d;i>=1;i--) cout<<s[i]<<' ';
//    cout<<endl;
//    for (int i=d;i>=2;i--) cout<<c[s[i]][s[i-1]]-f[s[i]][s[i-1]]<<endl;
    int mn=oo;
    for (int i=2;i<=d;i++)
        mn=min(mn,c[s[i]][s[i-1]]-f[s[i]][s[i-1]]);
    maxflow+=mn;
    for (int i=2;i<=d;i++)
    {
        f[s[i]][s[i-1]]+=mn;
        f[s[i-1]][s[i]]-=mn;
    }
}
int main()
{
   // freopen("splaytree.inp","r",stdin);
   // freopen("splaytree.out","w",stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    nhap();
    for (int i=1;i<=n+m;i++) if (c[0][i]==oo&&c[0][i]==c[i][n+m+1])
    {
        cout<<"-1";return 0;
    }
//    cout<<Findpath()<<endl;
//    for (int i=1;i<=n+m+1;i++) if (visit[i]==1)cout<<i<<' '<<parent[i]<<endl;
//    Findpath();Increasemaxflow();
//    cout<<maxflow<<' '<<f[1][6]<<' '<<f[4][3]<<endl;
//    Findpath();Increasemaxflow();
//    cout<<maxflow<<' '<<f[1][6]<<' '<<f[4][3]<<endl;
    while (Findpath()) Increasemaxflow();
    cout<<maxflow;
}


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

int main()
{
    ll A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    ll ans = 0;
    ll ans1 = A*X + B*Y;
    ll ans2 = (X > Y) ? X*2*C : Y*2*C;
    ans1 = min(ans1, ans2);
    if (X == Y) {
        ans = ans1;
    }
    else {
        if (X > Y) {
            ll dif = X - Y;
            ans = dif * A + (Y*2*C);
        }
        else {
            ll dif = Y - X;
            ans = dif * B + (X*2*C);
        }
        ans = min(ans1, ans);
    }
    cout << ans << endl;
 
    




}


Measured memory_bytes: 3564
n = int(input())
x = list(map(int, input().split())) 

hp = 0
hp2 = 0

p = sum(x)//n
for i in range(n):
    hp += (x[i-1]-p)**2
    hp2 += (x[i-1]-(p+1))**2

print(min(hp,hp2))

    

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;
typedef priority_queue<int, vector<int>, greater<int>> PQ;
const int MOD = 1000000007;

int main(){
    int X, Y, Z, K; cin >> X >> Y >> Z >> K;
    vector<ll> A(X), B(Y), C(Z);
    rep(i,X) cin >> A[i];
    rep(i,Y) cin >> B[i];
    rep(i,Z) cin >> C[i];

    sort(A.rbegin(), A.rend());
    sort(B.rbegin(), B.rend());
    sort(C.rbegin(), C.rend());

    vector<ll> ABC;
    rep(i,X){
        rep(j,Y){
            if ((i+1)*(j+1) > K) break;
            rep(k,Z){
                if ((i+1)*(j+1)*(k+1) > K) break;
                ABC.push_back(A[i]+B[j]+C[k]);
            }
        }
    }
    sort(ABC.rbegin(), ABC.rend());

    rep(i,K) cout << ABC[i] << endl;
}

Measured memory_bytes: 4336
// https://atcoder.jp/contests/abc111/tasks/abc111_b

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

int main()
{
  /* Magic word */
  // cin.tie(0);
  // ios::sync_with_stdio(false);
  /* ---------- */

  int n, r = 0;

  cin >> n;

  while (r < n)
    r += 111;

  cout << r << '\n';

  return 0;
}


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

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(ReadLine());

        var s = new string[N];

        for (int i = 0; i < N; i++)
            s[i] = ReadLine();

        string CharCount(string s)
        {
            var count = new int[26];

            foreach (var c in s)
                count[c - 'a']++;

            return count.Select((x, i) => (c: (char)(i + 'a'), x)).Aggregate("", (s, e) => s + e.c + e.x);
        }

        var charCounts = s.Select(s => CharCount(s)).ToArray();

        var freq = charCounts.GroupBy(x => x).ToDictionary(k => k.Key, e => e.Count());

        long getSum(long n) => (n - 1) * n / 2;

        var ans = 0L;

        foreach (var keyValuePair in freq)
            ans += getSum(keyValuePair.Value);

        WriteLine(ans);
    }
}


Measured memory_bytes: 74104
char W[9],V[9];Z[2*24],S,N,T,P,M;main(){
	int i,j,k,l,r,d;
	for(;scanf("%d%d%d%s%s%d%d",&S,&N,&T,W,V,&P,&M),S;printf("%.10f\n",1-pow(1-1.0/P,N*r))){
		memset(Z,0,sizeof(Z));
		l=*W=='A'?2:1;
		d=24*60*(*W=='A'?1:7);
		if(*V=='A')for(i=0;i<l;i++)for(j=0;j<24;j++)Z[i*24+j]=1;
		if(*V=='D')for(i=0;i<l;i++)for(j=0;j<12;j++)Z[(i*24+6)+j]=1;
		if(*V=='N')for(i=0;i<l;i++)for(j=0;j<6;j++)Z[i*24+j]=Z[(i*24+18)+j]=1;
		for(r=j=0;j<24*60;r=r>l?r:l,j++)for(k=j,l=i=0;i<M;i++){
			if(k<24*60)l+=Z[(k+S)%(2*24*60)/60]&Z[k/60];
			k=(k+T)%d;
		}
}exit(0);}

Measured memory_bytes: 692
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
using namespace std;

typedef pair<int, int> P;
//????????¢???
P next(int n,P p) {
	switch (n) {
	case 0:
		return p;
	case 1:
		if (p == P(0, 1))return P(-1, 0);
		if (p == P(1, 0))return P(0, 1);
		if (p == P(0, -1))return P(1, 0);
		if (p == P(-1, 0))return P(0, -1);
	case 2:
		return P(-p.first, -p.second);
	case 3:
		if (p == P(0, 1))return P(1, 0);
		if (p == P(1, 0))return P(0, -1);
		if (p == P(0, -1))return P(-1, 0);
		if (p == P(-1, 0))return P(0, 1);
	}
}
//????§??¬???????
int direction(P p) {
	if (p == P(1, 0))return 0;
	if (p == P(0, 1))return 1;
	if (p == P(-1, 0))return 2;
	if (p == P(0, -1))return 3;
}

int main() {
	int w, h;
	while (cin >> w >> h, w) {
		//??\?????¨??????
		vector<vector<int>>command(w, vector<int>(h));
		vector<vector<vector<int>>>memo(w, vector<vector<int>>(h, vector<int>(4)));
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				int buf; cin >> buf;
				command[j][i] = buf;
				for (int k = 0; k < 4; k++) {
					memo[j][i][k] = 10000;
				}
			}
		}
		vector<int>cost(4);
		for (int i = 0; i < 4; i++) {
			int buf; cin >> buf;
			cost[i] = buf;
		}
		//???????????????????????§??¨??¢?´¢
		queue<P> q; q.push(P(0, 0));
		queue<P> q_dir; q_dir.push(P(1, 0));
		memo[0][0][0] = 0;
		while (!q.empty()) {
			P now = q.front();
			P dir = q_dir.front();
			int nd = direction(dir);
			for (int i = 0; i < 4; i++) {
				P neo = next(i, dir);
				int d = direction(neo);
				int next_x = now.first + neo.first;
				int next_y = now.second + neo.second;
				if (next_x >= 0 && next_y >= 0 && next_x < w && next_y < h) {
					bool flag = 0;
					if (i != command[now.first][now.second]) {
						if (memo[now.first][now.second][nd] + cost[i] < memo[next_x][next_y][d]) {
							memo[next_x][next_y][d] = memo[now.first][now.second][nd] + cost[i];
							flag = 1;
						}
					}
					else {
						if (memo[now.first][now.second][nd] < memo[next_x][next_y][d]) {
							memo[next_x][next_y][d] = memo[now.first][now.second][nd];
							flag = 1;
						}
					}
					if (flag) {
						q.push(P(next_x, next_y)); q_dir.push(neo);
					}
				}
			}
			q.pop(); q_dir.pop();
		}
		int ans = 10000;
		for (int i = 0; i < 4; i++) {
			ans = min(ans, memo[w - 1][h - 1][i]);
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3084
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */


#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class APluralForm {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      string s; cin >> s;
      if (s.back() == 's') {
        s.push_back('e');
      }
      s.push_back('s');
      cout << s << endl;
    }
};

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

Measured memory_bytes: 3640
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc =new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		int yakusu=0;
		int kaisu=0;
		for(int x=a;x<=b;x++) {
			yakusu=c%x;
			if(yakusu==0) {
				kaisu++;
			}
		}
		System.out.println(kaisu);
	}
}



Measured memory_bytes: 26304
mod = 10**9+7
n = int(input())
# frac = [1]*(n+1)
# finv = [1]*(n+1)
# for i in range(n):
#     frac[i+1] = (i+1)*frac[i]%mod
# finv[-1] = pow(frac[-1],mod-2,mod)
# for i in range(1,n+1):
#     finv[n-i] = finv[n-i+1]*(n-i+1)%mod
# def nCr(n,r):
#     if n<0 or r<0 or n<r: return 0
#     r = min(r,n-r)
#     return frac[n]*finv[n-r]*finv[r]%mod
C = list(map(int,input().split()))
C.sort(reverse = True)
ans = 0

for i,c in enumerate(C):
    ans += c*(i+2)
ans *= pow(4,n-1,mod)
print(ans%mod)


Measured memory_bytes: 105036
while 1:
    n = int(input())
    if n == 0:
        break

    ans = -1000000000
    a = [0]
    for i in range(n):
        a.append(int(input())) # a = [input() for i in range(n)]
        a[i+1] += a[i]
        
        for j in range(0,i+1):
            ans = max(ans, a[i+1]-a[j])

    print(ans)

Measured memory_bytes: 6512
def check(pt, brackets):
    brackets.sort(reverse=True)
    for m, t in brackets:
        if pt + m < 0:
            return -1
        pt += t
    return pt


n = int(input())
brackets_p = []  # (始めを0として、( = +1, ) = -1 として、最後はいくつか, 途中の最小値はいくつか)
brackets_m = []
pt = 0
mt = 0
for _ in range(n):
    s = input()
    total = 0
    mini = 0
    for c in s:
        if c == '(':
            total += 1
        else:
            total -= 1
            mini = min(mini, total)

    if total >= 0:
        if mini == 0:
            pt += total
        else:
            brackets_p.append((mini, total))
    else:
        total, mini = -total, mini - total
        if mini == 0:
            mt += total
        else:
            brackets_m.append((mini, total))

pt = check(pt, brackets_p)
mt = check(mt, brackets_m)

if (pt == -1) or (mt == -1) or (pt != mt):
    print('No')
else:
    print('Yes')


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

int main() {
  int A, B, C, X, N ,count = 0;
  cin >> A >> B >> C >> X;
 
  for(int a = 0; a < A+1; a++){
    for(int b = 0; b < B+1; b++){
      for(int c = 0; c < C+1; c++){
        
        if(500*a + 100*b + 50*c == X){
          count ++;
        }
        
      }
    }
  }
  
  cout << count << endl;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


fn main() {
    let n = read::<i32>();

    for i in 0..n/4+1 {
        for j in 0..n/7+1 {
            if 4*(i) + 7*(j) == n {
                println!("Yes");
                return;
            }
        }
    }
    println!("No");
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
#define PI acos(-1)
#define oo LLONG_MAX
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*

*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  ll N, K;
  cin >> N >> K;
  vector<ll> P(N+1, 0), C(N+1, 0);
  rep(i, N) cin >> P[i+1];
  rep(i, N) cin >> C[i+1];
  ll ans = -4e18;
  rep(i, N){
    ll k = K, tmp = 0, now = i+1, next = P[now];
    vector<int> seen(N+1, 0);
    while (seen[next] < 2 && k > 0){
      seen[next]++;
      tmp += C[next];
      now = next;
      next = P[now];
      chmax(ans, tmp);
      k--;
    }
    ll loop = 0, add = 0;
    rep(i, N+1){
      if (seen[i] == 2){
        loop++;
        add += C[i];
      }
    }
    ll cnt = 0;
    if (loop > 0)
      cnt = k/loop;
    cnt--;
    if (cnt > 0){
      tmp += add * cnt;
      k -= loop * cnt;
    }
    chmax(ans, tmp);
    while (k > 0){
      tmp += C[next];
      now = next;
      next = P[now];
      chmax(ans, tmp);
      k--;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
const int INF=999999999;

int main() {
 int N;
 string S;
 cin>>N>>S;
 int x=0;int ans=0;
 for(int i=0;i<N;i++){
   if(S.at(i)=='I'){x++;}
   if(S.at(i)=='D'){x--;}
 ans=max(x,ans);
 }
 cout<<ans<<endl;
 return 0;}

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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define f(i,a,b) for(int i=a;i<b;i++)
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}


ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

int main(){
  int n,k;
  cin>>n>>k;
  vi a(n);
  rep(i,n) cin>>a[i];
  sort(all(a));
  auto itr = lower_bound(a.begin(), a.end(), k);
   cout<<a.end() - itr<<endl;
}




Measured memory_bytes: 640
num = int(input())
counter = 3

for n in range(num):
  #データ読み取り
  x, y = map(int, input().split())
  if x == y:
    counter -=1
  else:
    counter = 3
  
  if counter <= 0:
    print('Yes')
    break

if counter > 0:
  print('No')

Measured memory_bytes: 9164
#include <bits/stdc++.h>
using namespace std;
char s[12][1002];
int sum[12];
int main(){
    int h, w, l;
    scanf("%d%d%d", &h, &w, &l);
    for(int i=0;i<h;i++){
        scanf("%s", &s[i]);
    }   
    int ans = 1e9;

    for(int i=0;i<(1<<(h-1));i++){
        memset(sum, 0, sizeof(sum));
        int res = __builtin_popcount(i);
        bool ok = 1;
        for(int j=0;j<w;j++){
            int idx = 0;
            for(int k=0;k<h;k++){
                sum[idx] += s[k][j]-'0';
                if((i>>k)&1) idx++;
            }
            bool add = 0;
            for(int k=0;k<=idx;k++){
                if(sum[k] > l) add = 1;
            }
            if(add){
                res++;
                idx = 0;
                sum[0] = 0;
                for(int k=0;k<h;k++){
                    sum[idx] += (s[k][j]-'0');
                    if(sum[idx] > l) ok = 0;
                    if((i>>k)&1) idx++, sum[idx] = 0;
                }
            }
        }
        if(ok) ans = min(ans, res);
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		int[] B = new int[N];
		int[] copyA = new int[N];
		for(int i = 0; i < N; i++){
			A[i] = sc.nextInt();
			B[i] = sc.nextInt();
			copyA[i] = A[i];
		}
		Arrays.sort(copyA);
		int idx = 0;
		for(idx = 0; idx < N; idx++){
			if(A[idx] == copyA[N-1]) break;
		}
		int max = A[idx] + B[idx];
		System.out.println(max);
    }
}

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

using namespace std;

typedef pair<int,int> P;
typedef long long ll; 

#define int ll

const ll mod = 1e9 + 7;

int n;
int ans[10001];

main(){
	cin >> n;
	
	for(int x=1;x<=101;x++){
		for(int y=1;y<=101;y++){
			for(int z=1;z<=101;z++){
				int t = x*x + y*y + z*z + x*y + y*z + z*x;
				if(t<=10000)ans[t]++;
			}
		}
	}

	for(int i=1;i<=n;i++){
		cout << ans[i] << endl;
	}

	return 0;
}


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

#define ll long long
#define ull unsigned long long
#define N 100005
#define mod 998244353 
#define boost ios_base::sync_with_stdio(false);cin.tie(0)
#define prec(n) fixed<<setprecision(n)

#define mii unordered_map<int,int>
#define mll unordered_map<ll,ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define pp pop_back
#define vii vector<int>
#define vll vector<ll>
#define vpp vector<pii>
#define all(c) c.begin(),c.end()
#define tr(it,c) for(it = c.begin() ; it!=c.end() ; it++)
int inf = INT_MAX ;
ll modulo(ll num,ll MOD=mod){ return ((num%MOD)+MOD)%MOD;} // for negative integer
ll power(ll b,ll e,ll MOD=mod){ll ans=1; while(e){if(e%2) ans=(ans*b)%MOD; b=(b*b)%MOD; e/=2;} return ans;}
ll inv(ll num,ll MOD=mod){ return power(modulo(num),MOD-2,MOD); }
ll gcd(ll a,ll b){ return ((b==0) ? a:gcd(b,a%b));}

int main(){
	boost;

	int n,m;
	cin>>n>>m;

	if(m==1){
		cout<<0;
		return 0;
	}

	int k = 0,i = 0;
	while(k<m){
		if(i==0)
			k = k+n;
		else
			k = k - 1 + n;
		i++;
	}

	cout<<i;
	return 0;
}

Measured memory_bytes: 256
//package csesCodes;// template code for cp;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.*;

public class Main {

    public static void main(String[] args) throws InterruptedException {
        FastScanner fs=new FastScanner();
        long a=fs.nextLong();
        long b=fs.nextLong();
        long c=fs.nextLong();
        long d=fs.nextLong();
        long p1,p2,p3,p4;
        p1=a*c;
        p2=a*d;
        p3=b*c;
        p4=b*d;
        long ans1=Math.max(p1,p2);
        long ans2=Math.max(p3,p4);
        long result=Math.max(ans1,ans2);
        System.out.println(result);



    }




    static class FastScanner {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");

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

        }

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

        public int[] readArray(int n) {
            int[] a=new int[n];
            for (int i=0; i<n; i++) a[i]=nextInt();
            return a;
        }

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

        public long[] readLongArray(int n) {
            long[] a=new long[n];
            for (int i=0; i<n; i++) a[i]=nextLong();
            return a;
        }
    }

}


Measured memory_bytes: 32836
#include <stdio.h>
int main(void){
    long long n,ans=0;
    scanf("%lld",&n);
    long long a[n+1];
    a[n]=0;
    for (long long i=0; i<n; i++){
        scanf("%lld",&a[i]);
    }
    if (n==1){
        if (a[0]==0){
            printf("0\n");
        } else {
            printf("-1\n");
        }
        return 0;
    }
    for (long long i=1; i<n; i++){
        if (a[i]>a[i-1]+1 || a[i]>i || a[0]!=0){
            printf("-1\n");
            return 0;
        } else if (a[i]>=a[i+1]){
            ans+=a[i];
        }
    }
    printf("%lld\n",ans); 
    return 0;   
}

Measured memory_bytes: 1664
# ABC 140: B – Buffet
n = int(input())
a, b = [[int(s) for s in input().split()] for _ in range(2)]
c = [int(s) for s in input().split()]

points = 0

for i in range(n):
    points += b[a[i] - 1]
    if i < n - 1:
        if a[i + 1] - a[i] == 1:
            points += c[a[i] - 1]

print(points)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vp;
typedef map<ll, ll> mll;
typedef map<string, ll> mstrll;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fir first
#define sec second
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
#define out(x) cout << (x)
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
ll gcd(ll a, ll b){return b != 0 ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
const ll INF = 1e16;
const ll MOD = 1e9 + 7;
ll a, b, c, n, m, x, y, z, w, h, ans, cnt, mx, mn;
string s, t;
vll dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
//vll dx = {-1, 0, 1, -1, 1, -1, 0, 1}, dy = {-1, -1, -1, 0, 0, 1, 1, 1};

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> n){
        ll cnt_2 = 0, cnt_4 = 0;
        rep(i, n){
            cin >> a;
            if(a % 2 == 0 && a % 4){
                cnt_2++;
            }
            if(a % 4 == 0){
                cnt_4++;
            }
        }
        cnt_2--;
        maxs(cnt_2, 0LL);
        print((n - cnt_2) / 2 <= cnt_4 ? "Yes" : "No");
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#define F 0
#define T 1

int eratos(int );

int main(){
    int n,z,i,cnt=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&z);
        if(eratos(z)) cnt++;
    }
    printf("%d\n",cnt);
    return 0;
}

int eratos(int n){
    int i;
    if(n<2) return F;
    else if(n==2) return T;
    if(n%2==0) return F;
    for(i=3;i*i<=n;i+=2){
        if(n%i==0) return F;
    }
    return T;
}





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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define DISP1(as)		for(auto it : as) cout<<it.f<<" "<<it.s<<") ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cout<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	2e+5 + 99;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

// <------------- Declare Variables Here ------------> //

ll T = 1;

// <---------------------- > //


// <------------- Start of main() -------------------> //

void MAIN() {
	vll a(5);
	for(ll i=0;i<5;i++) {
		cin>>a[i];
	}

	for(ll i =0 ;i<5;i++) {
		if(!a[i]) {
			cout<<i+1;
			return;
		}
	}
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define LL long long
#define P 1000000007
#define M 1000005
using namespace std;  
struct node{
	int x,y;
}s[M];
bool cmp(node A,node B){
	return A.y<B.y;
}
int main(){ 
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		scanf("%d %d",&s[i].x,&s[i].y);
	}
	sort(s,s+n,cmp);
	LL p=0;bool f=true;
	for(int i=0;i<n;i++){
		if(p+s[i].x<=s[i].y){
			p+=s[i].x;
		}else {
			f=false;break;
		}
	}
	puts(f?"Yes":"No");
	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

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

    int a = in.nextInt();
    int b = in.nextInt();
    int c = in.nextInt();

    int n = 0;
    for (int i = a; i <= b; i++) {
      if (c % i == 0) n++;
    }
    System.out.println(n);
  }
}

Measured memory_bytes: 26252
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,n) for(int i=1;i<(int)(n);i++)

typedef long long ll;
using namespace std;

int gcd(int a, int b) { //最大公約数
  if (b==0) return a;
  else return gcd(b, a%b);
}

int lcm(int a, int b) { //最小公倍数
  return a * b / gcd(a, b);
}


int main()
{
  ll n,a[300];
  cin>>n;
  rep(i,n)cin>>a[i];

  ll m=1e15;
  rep(i,n){
    if(a[i]%2==1){
      cout<<0<<endl;
      return 0;
    }else{
      ll tmp=0;
      while(a[i]%2==0){
        a[i]/=2;
        tmp++;
      }
      m=min(tmp,m);
    }
  }
  cout<<m<<endl;

  return 0;
}


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


//番兵により比較回数の削減
int isin_Lsearch(std::vector<int> A, int n, int key){
  int i=0;
  A.push_back(key);
  while (A[i] != key) i++;
  return i != n;
}

int main(int argc, char const *argv[]) {
  int n, tmp, key, cnt=0;
  std::cin >> n;

  std::vector<int> S; S.reserve(10001);

  for (size_t i = 0; i < n; i++) {
    std::cin >> tmp;
    S.push_back(tmp);
  }

  int q;  std::cin >> q;

  for (size_t i = 0; i < q; i++) {
    std::cin >> key;
    if( isin_Lsearch(S, n, key) ) cnt++;
  }

  std::cout << cnt << '\n';

  return 0;
}



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

int main() {
    int64_t n, m;
    cin >> n >> m;
    if (n > m) swap(n, m);

    int64_t r = 0;
    if (n == 1 && m == 1) {
        r = 1;
    } else if (n == 1) {
        r = m - 2;
    } else {
        r = n * m - (n - 2 + m - 2) * 2 - 4;
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define setbits(x) __builtin_popcount(x)
#define mod 1000000000
#define endl "\n"

int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0);
   ll n;
   cin>>n;
   ll a[n];
   rep(i,0,n)
   {
       cin>>a[i];
   }
   vector<ll>dp(n,mod);
   dp[0] = 0;
	rep(i,0,n)
	{
		for (int j : {i+1, i+2})
        {
			 if (j < n)
            {
				dp[j] = min(dp[j], dp[i] + abs(a[i] - a[j]));
            }
		}
	}
	cout<<dp[n-1];
return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


string S,T;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>S>>T;
	T.pop_back();
	if(S==T) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

int digitSum(int n)
{
    int ret = 0;
    while (n != 0)
    {
        ret += n % 10;
        n /= 10;
    }
    return ret;
}

void Main()
{
    int n = in();
    if (n % digitSum(n) == 0)
        Yes;
    else
        No;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; i++ )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;

int n,m,ok[1000][1000],flag[1000],ng,cnt;
void dfs(int x,int y){
    flag[x]=y;
    cnt+=y;
    rep(i,n){
        if(!ok[x][i]){
            if(flag[i]==0){
                flag[i]=-y;
                dfs(i,-y);
            }
            else if(flag[i]==y){
                ng=true;
            }
        }
    }
}

int main(){
   cin>>n>>m;
   rep(i,m){
       int x,y;
       cin>>x>>y;
       x--;y--;
       ok[x][y]=true;
       ok[y][x]=true;
   }
   rep(i,n)ok[i][i]=true;
   vector<int> v;
   rep(i,n){
       if(flag[i]==0){
           cnt=0;
           dfs(i,1);
           if(ng){
               cout<<-1<<endl;
               return 0;
           }
           v.push_back(abs(cnt));
       }
   }
   int k=v.size();
   bitset<2000> dp[k+1];
   dp[0]=1;
   dp[0]<<=1000;
   rep(i,v.size()){
       dp[i+1]=(dp[i]<<v[i]);
       dp[i+1]|=(dp[i]>>v[i]);
   }
   int ret=0;
   rep(i,1000){
       if(dp[k][1000+i]|dp[k][1000-i]){
           ret=i;
           break;
       }
   }
   int l=(n+ret)/2,r=(n-ret)/2;
   cout<<l*(l-1)/2+r*(r-1)/2<<endl;
   return 0;
}

Measured memory_bytes: 3200
#include<iostream>
#include<cmath>
int main(){
	int x,tmp,ans=0;
	std::cin>>x;
	for(int i=0;i<x;i++){
		std::cin>>tmp;
		while(true){
			if(tmp%2==0){
				ans++;
				tmp/=2;
			}
			else break;
		}
	}
	std::cout<<ans<<std::endl;
}

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

using namespace std;

using ll = long long;

int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    for(ll i = 0; i < n; ++i){
        ll tmp; cin >> tmp;
        ans += tmp;
    }
    cout << ans - n;
    return 0;
}


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

int main(void){
	
	int A,B,X; cin >> A >> B >> X;
	for(int i = A;i < A + X;i++){
		if(i <= B){
		cout << i << endl;
		}
	}
	for(int i = B - X + 1;i <= B;i++){
		if(!(i < A + X)&&(i >= A)){
			cout << i << endl;
		}
	}
	return 0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}
struct edge {
  ll to, cost;
};

ll modpow(ll a, ll n, ll mod) {
  if(n == 0) {
    return 1;
  } else if(n % 2 == 1) {
    return modpow(a, n - 1, mod) * a % mod;
  } else {
    ll t = modpow(a, n / 2, mod);
    return t * t % mod;
  }
}

int main() {
  int N; cin >> N;
  vector<ll> D(N); REP(i, N) cin >> D[i];
  if(D[0] != 0) { // 1番目が0でなければ構築不可能
    cout << 0 << endl;
    return 0;
  }
  // それ以外の検査
  // ソートしてよい
  sort(all(D));
  vector<ll> res; ll cnt = 0;
  REP(i, N) { // 前処理
    cnt++;
    if(D[i] != D[i + 1]) {
      res.push_back(cnt);
      cnt = 0;
    }
  }
  bool flag = false;
  REP(i, N - 1) { // 連番になってなければ構築不可能。
    if(D[i + 1] - D[i] > 1) flag = true;
  }
  if(flag == true || D[1] == 0) {
    cout << 0 << endl;
    return 0;
  }

  // 判定パート
  ll ans = 1;
  const ll MOD = 998244353;
  REP(i, res.size() - 1) {
    ans *= modpow(res[i], res[i + 1], MOD);
    ans %= MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4952
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <stdio.h>

#define PB push_back
#define MP make_pair
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<30)
#define LLINF (1LL<<60)
#define MOD 1000000007
#define REP(i, n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;

int main() {
  string s;
  cin>>s;
  int ans=INF;
  for(int i=0;i<s.length()-2;i++){
    int t=atoi(s.substr(i,3).c_str());
    if(ans>abs(t-753))ans=abs(t-753);
  }
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

int main(int argc, char const *argv[])
{
	int n;
	cin >> n;
	int count = 0;
	while (n > 0){
		int aux = n%10;
		n /= 10;
		count += aux;
	}
	if (count == 1)
	{
		cout << 10 << endl;
	}else{
		cout << count << endl;
	}
	return 0;
}


Measured memory_bytes: 256