akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long


int main(){
    string s; ll k;
    cin>>s>>k;
    ll ans=0,now=1;
    if(s.size()!=1){
        if(s[0]!=s[s.size()-1]){
            ll a=0,b=0;
            bool c=true;
            for(ll i=1;i<s.size();i++){
                if(s[i]==s[i-1]){
                    now++;
                    if(i==s.size()-1){
                        b=now;
                        //全部同じ文字ならa=0,b=s.size(),ans=0;
                    }
                }else{
                    if(c){
                        c=false;
                        a=now;
                        now=1;
                    }else{
                        ans+=now/2;
                        now=1;
                        if(i==s.size()-1){
                            b=1;
                        }
                    }
                }
            }
            //cout << ans  << endl;
            ans*=k;
            ans=ans+(a/2)*k+(b/2)*k;        
            //cout << a<<" "<<b<<" "<<now<<endl;//debug
            cout << ans << endl;
        }else{
            ll a=0,b=0;
            bool c=true;
            for(ll i=1;i<s.size();i++){
                if(s[i]==s[i-1]){
                    now++;
                    if(i==s.size()-1){
                        b=now;
                        //全部同じ文字ならa=0,b=s.size(),ans=0;
                    }
                }else{
                    if(c){
                        c=false;
                        a=now;
                        now=1;
                    }else{
                        ans+=now/2;
                        now=1;
                        if(i==s.size()-1){
                            b=1;
                        }
                    }
                }
            }
            //cout << ans  << endl;
            ans*=k;
            if(a==0){
                ans=b*k/2;
            }else{
                ans=ans+(a/2)+(b/2)+(((a+b)/2)*(k-1));
            }
            //cout << a<<" "<<b<<" "<<now<<endl;//debug
            cout << ans << endl;
        }
    }else{
        cout << s.size()*k/2 << endl;
    }
}


Measured memory_bytes: 256
/* JunsCoding325 */
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;

int N, K, num[500], sum, way[500];
vector<int> gcd;

void makeGcd (void)
{
    for (int i = sum; i >= 1; i--) 
        if ((sum % i) == 0)
            gcd.push_back(i);
}

int check (int pivot)
{
    //printf("\ncheck(%d)\n", pivot);
    if (pivot == 1)
        return true;

    int tmp = 0, ret = 0;
    for (int i = 0; i < N; i++) {
        way[i] = num[i] % pivot;
        tmp += way[i];
    }
    tmp /= pivot;
/*
    for (int i = 0; i < N; i++) {
        printf("%d: %d\n", i, way[i]);
    }
    */
    sort(way, way+N);
    for (int i = N-1; i >= N - tmp; i--) {
        ret += (pivot - way[i]);
    }
    //printf("ret = %d\n", ret);
    return ret;
}

int main (void)
{
    scanf("%d %d", &N, &K);
    sum = 0;
    for (int nn = 0; nn < N; nn++) {
        scanf("%d", &num[nn]);
        sum += num[nn];
    }
    
    makeGcd();
    /*
    for (int i = 0; i < gcd.size(); i++)
        printf("%d ", gcd[i]);
    printf("\n");
*/
    int ans;
    for (int i = 0; i < gcd.size(); i++) {
        if (check(gcd[i]) <= K) {
            ans = gcd[i];
            break;
        }
    }
    printf("%d\n", ans);
    return 0;
}


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

int main(void) {
    int n; cin >> n;
    vector<string> w(n);
    set<string> s;
    for(int i = 0; i< n; ++i) {
        cin >> w[i];
        s.insert(w[i]);
    }
    if(s.size() != n) {
        cout << "No" << endl;
        return 0;
    }
    char start = w[0].back();
    for(int i = 1; i < n; ++i) {
        if(w[i][0] != start) {
            cout << "No" << endl;
            return 0;
        }
        start = w[i].back();
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> p;
typedef pair<int,p> p1;
typedef pair<p,p> p2;
int n,m;
vector<int>edge[100005];
int dp[100005];
int rec(int x)
{
  if(dp[x]>=0)return dp[x];
  if(edge[x].size()==0)return dp[x]=0;
  for(int i=0;i<edge[x].size();i++)
  {
int to=edge[x][i];
    dp[x]=max(dp[x],rec(to)+1);
  }
  return dp[x];
}
int main()
{
  cin>>n>>m;
  for(int i=0;i<m;i++)
  {
int a,b;cin>>a>>b;edge[a].push_back(b);
} 
  for(int i=1;i<=n;i++)
    dp[i]=-1;
  for(int i=1;i<=n;i++)
  {
rec(i);
}
  int ans=0;
  for(int i=1;i<=n;i++)ans=max(ans,dp[i]);
  cout<<ans<<"\n";
  return 0;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
ll f(ll a, ll b)
{
    ll x = max(a, b), y = min(a, b);
    if (x % y == 0)
        return y;
    return f(y, x % y);
}

int main()
{
    ll ans = 1ll << 30;
    int n, a;
    cin >> n;
    cin >> a;
    ans = a;
    n--;
    rep(i, n)
    {
        int b;
        cin >> b;
        ans = f(b, ans);
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    bool exist = false;
    for (int i = 0, count = 0; i < N; ++i) {
        int A, B;
        cin >> A >> B;
        if (A == B) {
            ++count;
            if (count >= 3) {
                exist = true;
            }
        } else {
            count = 0;
        }
    }
    if (exist) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 3640
a = [int(input()) for i in range(5)]
b = [a[i]%10 for i in range(5)]
bl = sorted(b)
bb = 0
for i in bl:
  if i > 0:
    bb = i
    break

t = 0
for i in range(5):
  if i != b.index(bb):
    t += a[i]
    if t%10!=0:
      t +=(10-t%10)
t+=a[b.index(bb)]
print(t)

Measured memory_bytes: 3060
//ABC153 B

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

long long H,N,A;
//int A[100000];
long long ans = 0;

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

  for(int i=0;i<N;i++){
    scanf("%lld",&A);
    ans += A;
  }

  if(ans >= H){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <limits.h>
using namespace std;
using ll=long long;
int main(){
    int n,m;
    cin>>n>>m;
    vector<int> h(n);
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    vector<int> e[n];
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        a--;
        b--;
        e[a].push_back(b);
        e[b].emplace_back(a);
    }
    int ret=0;
    for(int i=0;i<n;i++){
        bool ok=true;
        for(int j=0;j<e[i].size();j++){
            if(h[i]<=h[e[i][j]])ok=false;
        }
        if(ok)ret++;
    }
    cout<<ret<<endl;
}

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

using ll = long long;
#define repi(n) for (int i = 0; i < (n); i++)
#define repj(n) for (int j = 0; j < (n); j++)
#define repk(n) for (int k = 0; k < (n); k++)
#define rep(i, n) for (int i = 0; (i) < (n); i++)
#define repr(i, a, b) for (auto i = (a); i < (b); i++)
#define repv(itr) for (auto&& v : (itr))
#define updatemax(t, v) (t = max((t), (v)))
#define updatemin(t, v) (t = min((t), (v)))
const int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, -1, 1, -1, 1};
template <typename T>
T minptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i < *re) re = i;
  }
  return re;
}
template <typename T>
T maxptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i > *re) re = i;
  }
  return re;
}
int __vmax(int x) {
  return INT_MAX;
}
double __vmax(double x) {
  return 1e+300;
}
ll __vmax(ll x) {
  return LLONG_MAX;
}
int __vmin(int x) {
  return INT_MIN;
}
double __vmin(double x) {
  return -1e+300;
}
ll __vmin(ll x) {
  return LLONG_MIN;
}
template <typename T>
vector<T> lis(T begin, T end, bool allowequal = false, bool lds = false) {
  using V = typename iterator_traits<T>::value_type;
  int n = end - begin;
  vector<V> a(n, lds ? __vmin(*begin) : __vmax(*begin));
  vector<int> id(n);
  if (lds && allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (lower_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (lds) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (upper_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = upper_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  } else {
    for (int i = 0; i < n; i++) {
      id[i] = lower_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  }
  int m = *maxptr(id.begin(), id.end());
  vector<T> re(m + 1);
  for (int i = n - 1; i >= 0; i--) {
    if (id[i] == m) re[m--] = begin + i;
  }
  return re;
}
template <typename T>
class segtree {
 private:
  int n;
  vector<T> data, lazy;

 public:
  segtree(int n_) {
    n = pow(2, ceil(log2(n_)));
    data.resize(n);
    lazy.resize(n);
    auto __x = data[0];
    repi(n) {
      data[i] = __vmin(__x);
      lazy[i] = 0;
    }
  }
};

int main() {
  int n, re = 0;
  cin >> n;
  repr(i, 1, 10) {
    int t = pow(3, i);
    repj(t) {
      int x = 0;
      bool f[3] = {};
      int y = j;
      repk(i) {
        int v = y % 3;
        f[v] = true;
        x *= 10;
        x += v == 0 ? 3 : v == 1 ? 5 : 7;
        y /= 3;
      }
      if (f[0] && f[1] && f[2]) {
        // if (i <= 4) cout << " " << x << endl;
        if (x <= n) re++;
      }
    }
  }
  cout << re << endl;
}


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

int main()
{
    long long H, A,tmp=0,tmp2=0;
    cin >> H >> A;
    tmp = H / A;
    tmp2 = H % A;
    //cout << tmp << " "<< tmp2 << endl;
    if(tmp2>0){
        cout << tmp + 1 << endl;
    }
    else{
        cout << tmp << endl;
    }


}


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

int main(){
  int a,b;
  cin >>a>>b;
  if(a <= 0 && b >= 0){
    cout <<"Zero"<<endl;
  }
  if(b < 0){
    if((b-a)%2 == 0){
      cout << "Negative" <<endl;
    }
    else cout <<"Positive"<<endl;
  }
  if(a > 0) cout <<"Positive" <<endl;
}



Measured memory_bytes: 764
n, m = gets.split.map &:to_i
c = Array.new(m, 0)
n.times do
    a = gets.split.map &:to_i
    l = a.shift
    l.times do |i|
        c[a[i]-1] += 1
    end
end
cnt = 0

m.times do |i|
    cnt += 1 if c[i] == n
end
puts cnt


Measured memory_bytes: 1788
#include <iostream>
#include <set>
using namespace std;
int main()
{
    int n;
    set<int> s;
    while(cin>>n){
        s.clear();
        while(n--){
            int x;
            cin>>x;
            s.insert(x);
        }
        int sum=s.size();
        cout<<sum<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<functional>
#include<algorithm>
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define pf push_front
#define pb push_back
#define int long long
using namespace std;
const int INF=1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

signed main(){
  int n;
  cin>>n;
  REP(i,n){
    int x[10]={};
    bool f=true;
    REP(i,10)cin>>x[i];
    stack<int> B,C;
    B.push(x[0]);
    REP(i,9){
      if(x[i+1]<B.top()){
        if(C.empty()||(x[i+1]>C.top()&&!C.empty())){
          C.push(x[i+1]);
        }else{
          f=false;
          break;
        }  
      }else B.push(x[i+1]);
    }
    cout<<(f?"YES":"NO")<<endl;
  }
  return 0;
}

Measured memory_bytes: 3080
import java.util.*;


class Main{
    public static void main(String argv[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] p = new int[n];
        for(int i=0;i<n;i++){
            p[i]=sc.nextInt();
        }

        int count=0;
        for(int i=0;i<n-2;i++){
            int a=p[i];
            int b=p[i+1];
            int c=p[i+2];
            if(a<b && b<c)count++;
            if(a>b && b>c)count++;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 22736
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=3e5+10;

int32_t main()
{
	IOS;
	int a,b;
	cin>>a>>b;
	for(int i=1;i<=1000000;i++)
	{
		if(i*8/100==a&&i/10==b)
		{
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<"-1"<<endl;






}


Measured memory_bytes: 256
import math
while True:
    a, op, b = input().split()  # この時点では変数はstr型
    if op == "?":
        break
    if op == "+":
        print(int(a) + int(b))
    if op == "-":
        print(int(a) - int(b))
    if op == "*":
        print(int(a)*int(b))
    if op == "/":
        print(math.floor(int(a)/int(b)))
    


Measured memory_bytes: 5660
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n, ans=LLONG_MAX, dismini=100, dismax=0, tmp;
    cin >> n;
    ll a[n];
    for(ll i=0; i<n; i++){
      cin >> a[i];
      dismax = max(dismax, a[i]);
      dismini = min(dismini, a[i]);
    }

    for(ll i=dismini; i<=dismax; i++){
      tmp = 0;
      for(ll j=0; j<n; j++){
        tmp += (a[j]-i)*(a[j]-i);
      }
      ans = min(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
def input():
	return sys.stdin.readline()[:-1]

class Rsum():
	def __init__(self, size):
		#the number of nodes is 2n-1
		self.n = 1
		while self.n < size:
			self.n *= 2
		self.node = [0 for _ in range(2*self.n-1)]

	def Access(self, x):
		return self.node[x+self.n-1]

	def Add(self, x, val):
		x += self.n-1
		self.node[x] += val
		while x > 0:
			x = (x-1)//2
			self.node[x] = self.node[2*x+1] + self.node[2*x+2]
		return

	#[a, b)
	def Get(self, a, b, k=0, l=0, r=-1):
		if r < 0:
			r = self.n

		if a >= r or b <= l:
			return 0
		elif a <= l and b >= r:
			return self.node[k]
		else:
			vl = self.Get(a, b, 2*k+1, l, (l+r)//2)
			vr = self.Get(a, b, 2*k+2, (l+r)//2, r)
			return vl + vr

n, q = map(int, input().split())
SegT = Rsum(n)
for _ in range(q):
	c, x, y = map(int, input().split())
	if c == 0:
		SegT.Add(x-1, y)
	else:
		print(SegT.Get(x-1, y))


Measured memory_bytes: 10960
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

int main() {
  static int rewards[] = {300000, 200000, 100000};
  int x, y, r = 0;
  cin >> x >> y;
  if (x <= 3) r += rewards[x - 1];
  if (y <= 3) r += rewards[y - 1];
  if (x == 1 && y == 1) r += 400000;
  cout << r << endl;
  return 0;
}

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

int main() 
{
    string text;
    int alpha[100] = {};                                        //要素がアスキー文字の整数に対応.0で初期化。
    int trans = 'a' - 'A';                                      //大文字から小文字への変換

    while( cin >> text )
    {
        for( int i = 0; i < text.size(); i++ )
        {
            for( int j = 65; j <= 90; j++ )                     //65~90はA~Z
            {
                if( text[i] == j || text[i] == j + trans)
                    alpha[j]++;
            }
        }
    }

    for( int i = 65; i <= 90; i++ )
    {
        cout << (char)(i + trans) << " : " << alpha[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3196
#include<stdio.h>
#include<string.h>
int main(){
    char a[100],b[100],c[100];
    int i,m,n,flag=0,count=0;
    scanf("%s %s",a,b);
    m=strlen(a);
    n=strlen(b);
    while(count<m){
        if(strcmp(a,b)!=0){
            c[0]=b[n-1];
            for(i=1; i<n; i++){
                c[i]=b[i-1];
            }
            for(i=0; i<n; i++){
                b[i]=c[i];
            }
            count++;
        }
        else{
            flag=1;
            break;
        }
    }

    if(flag==1){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}


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

a=list(map(int,input().split()))

mindis=0

for i in range(len(a)):
  cw=0 #時計回り
  ccw=0#反時計

  if i==0:
    cw=a[len(a)-1]-a[0]
    ccw=k-(a[i+1]-a[i])

  elif i==len(a)-1:
    cw=k-(a[i]-a[i-1])
    ccw=a[i]-a[0]


  else:
    cw=k-(a[i+1]-a[i])
    ccw=k-(a[i]-a[i-1])

  #print(cw,ccw)

  if mindis==0:
    if ccw>cw:
      mindis=cw
    else:
      mindis=ccw

  if mindis>cw:
    mindis=cw
  if mindis>ccw:
    mindis=ccw

print(mindis)


Measured memory_bytes: 77388
#include <iostream>
#include <memory.h>
using namespace std;

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

int main(){
  int e[2][4];
  double x[2];
  memset(e, 0, sizeof(e));  
  while(cin >> x[0] >> x[1]){
    rep(i, 2){
      if(x[i] < 0.2){
	e[i][3]++;
      }else if(x[i] < 0.6){
	e[i][2]++;
      }else if(x[i] < 1.1){
	e[i][1]++;
      }else{
	e[i][0]++;
      }
    }
  }
  rep(i, 4){
    cout << e[0][i] << " " << e[1][i] << endl;
  }

  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define x first
#define y second
#define size(a) (ll)(a).size()

typedef long long ll;
typedef long double ld;

using namespace std;
int n;
string s;


int main()
{
    //ifstream cin("input.txt");
    //ofstream cout("output.txt");


    cin.tie(0);
    ios_base::sync_with_stdio(0);

    cin >> n;

    if (n == 0) {
        cout << 1;
    } else {
        cout << 0;
    }

}


Measured memory_bytes: 3608
#define INF 10000000000
#define MOD 1000000007

#if 1   // use_templates

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

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

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, up) for (ll i = 0; i < (up); ++i)
#define repp(i, up) for (ll i = 0; i <= (up); ++i)
#define rrep(i, lo, up) for (ll i = (lo); i < (up); ++i)
#define rrepp(i, lo, up) for (ll i = (lo); i <= (up); ++i)
#define eep(i, lo, up) for ((i) = (lo); (i) < (up); ++(i))
#define eepp(i, lo, up) for ((i) = (lo); (i) <= (up); ++(i))
#define feach(it, vec) for (auto it = (vec).begin(); it != (vec).end(); ++it)
#define emax(l, r) l = max(l, r)
#define vmin(l, r) l = min(l, r)

template<class T, class U>
bool contains(const T & vec, const U & value) {
    return vec.find(value) != vec.end();
}

ll gcd(ll a, ll b);

ll gcd(ll a, ll b)
{
    if (a < b) {
        return gcd(b, a);
    }
    ll r;
    while (r = a % b) {
        a = b;
        b = r;
    }
    return b;
}

#endif  // end of use_templates


int main()
{
    ll n;
    cin >> n;
    ll ans = 0;
    rrep(a, 1, n) {
        ans += (n - 1) / a;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3184
#include<iostream>
#include<algorithm>
using namespace std;
int num[100001];
#define m 1000000007
long long Mode(long long a,long long b)
{
    long long sum=1;
    a=a%m;
    while(b>0)
    {
        if(b%2==1)
        sum=(sum*a)%m;
        b/=2;
        a=(a*a)%m;
    }
    return sum;
}
int main()
{
    int N,flag=0;
    cin>>N;
    for(int i=1;i<=N;i++)
        cin>>num[i];
        sort(num+1,num+1+N);
    if(N%2==1)
    {
        if(num[1]==0)
        {
            for(int i=2;i<=N-1;i+=2)
                if(num[i]!=num[i+1])
            {
                flag=1;
                break;
            }
        }
        else flag=1;
        if(flag==1)
            cout<<"0";
        else
            cout<<Mode(2,(N-1)/2);
    }
    else if(N%2==0)
    {
        if(num[1]==1&&num[2]==1)
        {
            for(int i=3;i<=N-1;i+=2)
            {
                if(num[i]!=num[i+1])
                {
                    flag=1;
                    break;
                }
            }
        }
        else flag=1;
        if(flag==1)
            cout<<"0";
        else
            cout<<Mode(2,N/2);
    }
    return 0;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> roads(N);
  
  for (int i = 0; i < M; i++) {
    int tmp1, tmp2;
    cin >> tmp1 >> tmp2;
    
    roads.at(tmp1-1)++;
    roads.at(tmp2-1)++;
  }
  
  for (int i = 0; i < N; i++) cout << roads.at(i) << endl;
}


Measured memory_bytes: 256
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;
#define INF 100000000
#define MAXN 10010
typedef long long ll;

int n, q;
int par[MAXN], rank[MAXN];

void init(int s) {
    for (int i = 0; i < s; i++) {
        par[i] = i;
        rank[i] = 0;
    }
}

int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);
}

void unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return;
    if (rank[x] < rank[y]) par[x] = y;
    else {
        par[y] = x;
        if (rank[x] == rank[y]) rank[x]++;
    }
}

bool same(int x, int y) {
    return find(x) == find(y);
}

int main(void) {
    cin >> n >> q;
    init(n);
    for (int i = 0; i < q; i++) {
        int com, x, y;
        cin >> com >> x >> y;
        if (com == 0) {
            unite(x, y);
        } else {
            if (same(x, y)) cout << 1 << endl;
            else cout << 0 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1236
import sys
import math

for line in sys.stdin:
  a = line.split()
  if len(a) == 3:
    if (int(a[0])*int(a[0]) + int(a[1])*int(a[1])) == int(a[2])*int(a[2]) or (int(a[0])*int(a[0]) + int(a[2])*int(a[2])) == int(a[1])*int(a[1]) or (int(a[2])*int(a[2]) + int(a[1])*int(a[1])) == int(a[0])*int(a[0]):
    
        print("YES")
    else:
        print("NO")

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

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class DModSum {
public:
    static constexpr int kStressIterations = 0;

    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;
        int res = N * (N - 1) / 2;
        cout << res << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    DModSum solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
# Node
class Node
  attr_accessor :id, :edges, :visited, :cost

  def initialize(id, edges = [], visited = false, cost = nil)
    @id, @edges, @visited, @cost = id, edges, visited, cost
  end
end

# Edge
class Edge
  attr_accessor :to

  def initialize(to)
    @to = to
  end
end

# Graph
class Graph
  attr_accessor :nodes

  def initialize(data)
    @nodes = data.map do |id, edges|
      edges.map! { |edge| Edge.new(*edge) }
      Node.new(id, edges)
    end
  end

  def bfs(start)
    @nodes.each do |node|
      if node.id == start
        node.visited = true
        node.cost = 0
      else
        node.visited = false
        node.cost = -1
      end
    end

    queue = []
    queue << @nodes.find { |node| node.id == start }

    while queue.any?
      node = queue.shift
      node.visited = true
      node.edges.each do |edge|
        id = edge.to
        visited_node = @nodes.find { |item| item.id == id }
        unless visited_node.visited
          visited_node.cost = node.cost + 1 if visited_node.cost == -1
          queue << visited_node
        end
      end
    end
  end
end

n = gets.chop.to_i

data = {}

n.times do
  u, k, *v = gets.chop.split.map(&:to_i)
  data[u] = v
end

g = Graph.new data
g.bfs(1)

g.nodes.each do |node|
  puts "#{node.id} #{(node.visited) ? node.cost : -1}"
end

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

int main() {
  int n,k;
  cin >>n >>k;
  int cnt = 0;
  int num[n+1]={0};
  rep(i,k){
    int d;
    cin >>d;
    vector<int> a(d);
    rep(j,d) {
      cin >>a[j];
      num[a[j]]++;
    }
  }
  for(int i = 1; i<=n; i++){
    if(num[i]==0) cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
const int N=155;
int n,K,mo,f[N][N][N],i,j,k,ans,x,y;
inline void add(int&x,const int&y){x+=y-mo;x+=x>>31&mo;}
inline int calc(int n,int K){
	static int g[N][N];memset(g,0,sizeof g);g[0][0]=1;
	for(i=1;i<=n;++i)for(j=0;j<=K;++j){
		g[i][0]=(g[i][0]+g[i-1][j])%mo;
		if(j<K)g[i][j+1]=g[i-1][j];
	}
	int ans=0;for(j=0;j<=K;++j)ans=(ans+g[n][j])%mo;return ans;
}
int main(){
	scanf("%d%d%d",&n,&K,&mo);
	if(n==K){ans=1;for(i=1;i<=n;++i)ans=2ll*ans%mo;printf("%d\n",ans);return 0;}
	if(!(K&1)){K>>=1;printf("%lld\n",1ll*calc(n>>1,K)*calc(n+1>>1,K)%mo);return 0;}
	if(K==1){printf("%d\n",calc(n,2));return 0;}
	int lb1,rb1,lb2,rb2;
	lb1=(K>>1)+1;rb1=lb1+(n+1>>1)-1;
	lb2=1;rb2=lb2+(n>>1)-1;
	for(i=rb1+1,f[i][0][0]=1;i>1;--i)for(j=0;j<=n;++j)for(k=0;k<=n;++k)if(x=f[i][j][k]){
		bool b1=lb1<=i-1 && i-1<=rb1,b2=lb2<=i-1 && i-1<=rb2;
		add(f[i-1][0][0],x);
		if(b1)add(f[i-1][j+1][0],x);
		if(k+1<=K+1 && b2)add(f[i-1][0][k?k+1:0],x);
		y=std::max(j+2,k+1);
		if(y<=K+1 && b1 && b2)add(f[i-1][j+1][y],x);
	}
	for(j=0;j<=n;++j)for(k=0;k<=n;++k)add(ans,f[1][j][k]);printf("%d\n",ans);
	return 0;
}

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

int main() {
    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> A(N);
    for (int i = 0; i < Q; i++) {
        int a;
        cin >> a;
        a--;
        A[a]++;
    }

    for (int i = 0; i < N; i++) {
        if (Q - A[i] < K) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main () {
  int N;
  cin >> N;
  int mo;
  cin >> mo;
  int ans = N;
  int min = 1001;
  for (int i = 0; i < N; i ++) {
    int m;
    cin >> m;
    if (min > m) min = m;
    mo -= m;
  }
  ans += mo / min;
  cout << ans << endl;
}
    

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

#define N 100000
typedef struct{
  int par, left_child, right_sibling, depth;
  char status[15];
}Node;

Node tree[N];
int n, nchild[N];
char root[N];

void calc_depth(int p, int d){
  tree[p].depth = d;
  if(tree[p].right_sibling != -1) calc_depth(tree[p].right_sibling, d);
  if(tree[p].left_child != -1) calc_depth(tree[p].left_child, d+1);
}

void print_node(int p, int cnt, int size){
  if(cnt + 1 == size) printf("%d", p);
  else{
    printf("%d, ", p);
    print_node(tree[p].right_sibling, cnt + 1, size);
  }
}

main(){
  int i, j, r;
  scanf("%d", &n);
  memset(root, 1, n);
  for(i=0;i<n;i++) tree[i].left_child = tree[i].right_sibling = -1;
  for(i=0;i<n;i++){
    int idx;
    scanf("%d", &idx);
    scanf("%d", &nchild[idx]);
    if(nchild[idx] == 0) strcpy(tree[idx].status, "leaf");
    else strcpy(tree[idx].status, "internal node");
    for(j=0;j<nchild[idx];j++){
      int in, pre;
      scanf("%d", &in);
      tree[in].par = idx;
      root[in] = 0;
      if(j == 0) tree[idx].left_child = in;
      else tree[pre].right_sibling = in;
      pre = in;
    }
  }
  for(i=0;i<n;i++) if(root[i]) r = i;
  tree[r].par = -1;
  strcpy(tree[r].status, "root");
  calc_depth(r, 0);
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d, %s, [", i, tree[i].par, tree[i].depth, tree[i].status);
    if(tree[i].left_child != -1) print_node(tree[i].left_child, 0, nchild[i]);
    printf("]\n");
  }
  return 0;
}


Measured memory_bytes: 8484
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int ans=0;
		int now=0;
		Map<String,Integer> s = new HashMap<>();
		Map<String,Integer> t = new HashMap<>();

		for(int i=0;i<n;i++) {
			String word = sc.next();
			if(s.get(word)==null) {
				s.put(word,1);
			}else {
				s.put(word,s.get(word)+1);
			}
		}
		int m = sc.nextInt();
		for(int i=0;i<m;i++) {
			String word = sc.next();
			if(t.get(word)==null) {
				t.put(word,1);
			}else {
				t.put(word,t.get(word)+1);
			}
		}

		for(String key : s.keySet()) {
			if(t.containsKey(key)) {
				now=s.get(key)-t.get(key);
			}else {
				now=s.get(key);
			}
			if(ans<now) {
				ans=now;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
#include <stdio.h>
int main(void){
    int N, i, j, total;
    int d[100];
    
    scanf("%d", &N);
    total = 0;
    
    for(i = 0; i < N; i++){
        scanf("%d", &d[i]);
    }
    
    for(i = 0; i < N; i++){
        for(j = 0; j < i; j++){
            scanf("%d", &d[j]);
            total = total + d[i] * d[j];
        }
    }
    
    printf("%d", total);
}


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

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

  while(1) {
    int n, r; cin >> n >> r;
    if(n == 0 && r == 0) break;
    vector<int> a(n);
    for(int i=0;i<n;++i) {
      a[i] = n-i;
    }
    for(int i=0;i<r;++i) {
      int p, c; cin >> p >> c;
      vector<int> tmp = a;
      for(int j=0;j<c;++j) {
        tmp[j] = a[j+p-1];
      }
      for(int j=0;j<p-1;++j) {
        tmp[j+c] = a[j];
      }
      a = tmp;
    }
    cout << a[0] << endl;
  }
}



Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define F first
#define S second
#define ll long long
#define N 3010
using namespace std;
int n,m,dp[N][N];
pair<int,int> path[N][N];
string s,t,ans="";
int dfs(int x,int y)
{
	int rt;
	if(x<0||y<0)
	{
		return 0;
	}
	if(dp[x][y]!=-1)
	{
		return dp[x][y];
	}
	rt=dfs(x-1,y);
	if(dp[x][y]<rt)
	{
		dp[x][y]=rt;
		path[x][y]=make_pair(x-1,y);
	}
	rt=dfs(x,y-1);
	if(dp[x][y]<rt)
	{
		dp[x][y]=rt;
		path[x][y]=make_pair(x,y-1);
	}
	if(s[x]==t[y])
	{
		rt=dfs(x-1,y-1)+1;
		if(dp[x][y]<rt)
		{
			dp[x][y]=rt;
			path[x][y]=make_pair(x-1,y-1);
		}
	}
	return dp[x][y];
}
int main(){
	int i,j,x,y;
	cin>>s>>t;
	n=s.size();
	m=t.size();
	memset(dp,-1,sizeof(dp));
	dfs(n-1,m-1);
	i=n-1;
	j=m-1;
	while(i>=0&&j>=0)
	{
		x=i;
		y=j;
		i=path[x][y].F;
		j=path[x][y].S;
		if(x-i==1&&y-j==1)
		{
			ans+=s[x];
		}
	}
	reverse(ans.begin(),ans.end());
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 106880
#include <iostream>
#include <algorithm>

#define REP(i,n) for(int i = 0; i <= n; i++)
#define ll long long
#define PI M_PI

using namespace std;

int main(void){
    int K, S; cin >> K >> S;
    int X, Y, Z, ctr = 0;
    
    REP(i,K){
        REP(j,K){
            int k = S - i - j;
            if(0 <= k && k <= K) ctr++;
        }
    }
    
    cout << ctr << endl;
    return 0;
}

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

int sum(int num)
{
  string s=to_string(num);int su=0;
  for(int i=0;i<s.size();i++)su+=s[i]-'0';
  return su;
}

int main()
{
  int ans=0,N,A,B;scanf("%d %d %d",&N,&A,&B);
  for(int n,i=1;i<N+1;i++)
  {
    n=sum(i);
    if(n>=A&&n<=B)ans+=i;
  }
  printf("%d\n",ans);
}

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

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

const ll MAX_N = 5e3 + 15, inf = 1000000LL * 1000000LL * 1000000LL;
ll n, L, R, ans = inf, ind = 0;
ll IND[MAX_N];
ll Arr[MAX_N];
ll cntl[MAX_N][MAX_N];
ll cntb[MAX_N][MAX_N];

ll dp[MAX_N];

void processMin() {
	for (ll i = 0; i < n; i++) {
		ll l = 0, b = 0;
		for (ll j = i - 1; 0 <= j; j--) {
			l += (Arr[j] < Arr[i]);
			b += (Arr[j] > Arr[i]);
			
			cntl[i][j] = l;
			cntb[i][j] = b;
		}
	}
	
	for (ll i = 0; i < n; i++) {
		ll l = 0, b = 0;
		for (ll j = i + 1; j < n; j++) {
			l += (Arr[j] < Arr[i]);
			b += (Arr[j] > Arr[i]);
			
			cntl[i][j] = l;
			cntb[i][j] = b;
		}
	}
}

int main() {
//	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n >> L >> R;
	swap(L, R);
	
	for (ll i = 0; i < n; i++) {
		cin >> Arr[i];
		
		IND[Arr[i]] = i;
	}
	
	processMin();
	
	ind = Arr[0];
	for (ll i = 1; i < n; i++) {
		if (ind > Arr[i]) {
			dp[i] = cntb[i][0] * R;
			ind = Arr[i];
		}
		else
			dp[i] = inf;
			
		int Max = -1;
		for (ll j = i - 1; ~j; j--)
			if (Arr[j] < Arr[i] && Arr[j] > Max) {
				ll l = min(cntl[j][i - 1], cntl[i][j + 1]);
				ll b = min(cntb[j][i - 1], cntb[i][j + 1]);
				
				dp[i] = min(dp[i], dp[j] + l * L + b * R);
				Max = Arr[j];
			}
	}
	
	ind = -1;
	for (ll i = n - 1; ~i; i--) {
		if (Arr[i] > ind) {
			ans = min(ans, dp[i] + cntl[i][n - 1] * L);
			ind = Arr[i];
		}
	}
	
	cout << ans << "\n";
	return 0;
}

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

#define int long long
#define pii pair<int, int>
#define pb push_back

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    string s, t;
    cin >> s >> t;
    int ans = s.size();
    for (int i = 0; i + t.size() <= s.size(); i++) {
        int res = 0;
        for (int j = 0; j< t.size(); j++) {
            res += (s[i + j] != t[j]);
        }
        ans = min(ans, res);
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3612
#include <iostream>
using namespace std;
#define rep(i,q) for(int i = 0; q > i; i++)
int abss(int g){
  return (g < 0 ? g * -1 : g);
}
int main(){
  int H,W; cin >> H >> W;
  int A[H][W];
  rep(i,H){
    rep(j,W){
      cin >> A[i][j];
    }
  }
  
  int minCost;
  rep(i,H){
    rep(j,W){
      int allCost = 0;
      rep(k,H){
        rep(l,W){
          allCost += min(abss(k-i),abss(l-j)) * A[k][l];
        }
      }
      if(i == 0 && j == 0){
        minCost = allCost;
      } else if(minCost > allCost){
        minCost = allCost;
      } 
    } 
  }
  cout << minCost << endl;
}


Measured memory_bytes: 3096
# include <bits/stdc++.h>
# define mp make_pair
# define pb push_back
# define INF 0x3f3f3f3f
using namespace std;
typedef long long LL;
vector<pair<int,int> >v;
int main()
{
    int n, m, imax=-INF, imin = INF, id1, id2;
    scanf("%d",&n);
    for(int i=1; i<=n; ++i)
    {
        scanf("%d",&m);
        if(m > imax) imax=m, id1=i;
        if(m < imin) imin=m, id2=i;
    }
    if(imax > 0 && imin < 0)
    {
        int id = (imax+imin)>0?id1:id2;
        for(int i=1; i<=n; ++i)
            v.pb(mp(id, i));
    }
    if(imax+imin>0) for(int i=2; i<=n; ++i) v.pb(mp(i-1, i));
    else for(int i=n-1; i>=1; --i) v.pb(mp(i+1, i));
    printf("%d\n",v.size());
    for(auto it : v)
        printf("%d %d\n",it.first, it.second);
    return 0;
}


Measured memory_bytes: 256
L = input()

MOD = 10**9 + 7

N = len(L)
dp = [0 for _ in range(N + 1)]
dp[0] = 1
for i in range(1, N + 1):
    dp[i] = (3 * dp[i - 1]) % MOD

ans = 0
c = 1
for i in range(N):
    if L[i] == '1':
        ans = (ans + c * dp[N - i - 1]) % MOD
        c = (c * 2) % MOD

ans = (ans + c) % MOD

print(ans)


Measured memory_bytes: 46192
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		sc.close();

		Map<Character, Character> charList = new HashMap<>();

		for(int i = 0; i < S.length(); i++) {
			Character a = S.charAt(i);
			charList.put(a,a);
		}

		String answer = "None";

		for(char i = 'a'; i <= 'z'; i++) {
			if(charList.containsKey(i)) {
				//飛ばす
			}else {
				answer = String.valueOf(i) ;
				break;
			}
		}

		System.out.println(answer);


	}

}


Measured memory_bytes: 24016
import sys,queue,math,copy,itertools,bisect,collections,heapq
sys.setrecursionlimit(10**7)
INF = 10**18
MOD = 10**9 + 7
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())

N = NI()
p = []
for i in range(7,55555,10):
    for j in range(3,int(math.sqrt(i))+1):
        if i % j == 0: break
    else:
        p.append(i)

print(*p[:N])


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

int main()
{
  int N ;
  int K ;
  cin >> N ;
  K = N % 1000;
  if(K == 0)
  {
    K = 0;
  }
  else
  {
  K = 1000 - K;
  }
  cout << K << endl;
  return 0;
}


Measured memory_bytes: 3164
#include <iostream>
#include <queue>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>
#include <map>
#include <stack>
#include <iomanip>
#include <set>
#include <sstream>
#include <cmath>
#include <deque>
#include <list>
#include <bitset>
using namespace  std;
typedef pair<long long , long long> P;
typedef long long int64;
typedef long long lint;
#define REP(i, n) for(long long (i)=0; (i)<(n); ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define FST first
#define SND second

signed main(){
    lint N; cin >> N;
    vector<lint> A(N);
    map<lint, lint> m;
    REP(i, N){
        cin >> A[i];
        m[A[i]]++;
    } 
    lint cnt = 0;
    for(auto x: m){
        if(x.second>=2) cnt += x.second-1;
    }
    cout << N - (cnt + cnt%2) << endl;
    return 0;
}

Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N;
  cin>>N;
  int X[N+5];
  int i,j,k;
  int ans[N];
  for(i=0;i<N;i++)
  {
    cin>>X[i];
    ans[i]=X[i];
  }
  sort(ans,ans+N);
  i=N/2;
  for(k=0;k<N;k++)
  if(X[k]<=ans[i-1])
  {
    cout<<ans[i]<<endl;
  }else{
    cout<<ans[i-1]<<endl;
  }
  return 0;
}


Measured memory_bytes: 3712
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>

#define FOR(i,a,b) for(int i=(a);i<(b);++(i))
#define REP(i,n) FOR(i,0,n)

#define dump(x) cerr << #x << " = " <<(x)<<endl;
#define debug(x) cerr << #x << " = " <<(x) << "(L" << __LINE__ << ")" << __FILE__ << endl;

#define BIT_ON(x,b) ((x)|=(b))
#define BIT_OFF(x,b) ((x)&=~(b))
#define BIT_IS_ON(x,b) (((x)&(b))==(b))


using namespace std;

int main(void){
  string s;
  cin >> s;
  if(s.find('a') == string::npos) {cout << "No" << endl;return 0;}
  if(s.find('b') == string::npos) {cout << "No" << endl;return 0;}
  if(s.find('c') == string::npos) {cout << "No" << endl;return 0;}
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]
    N = int(input())
    a = list(int(_) for _ in str(N))
    if N%sum(a) ==0:
        print('Yes')
    else:
        print('No')
        
if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

typedef pair<int, int> P;

vector<int> G[100005];
int dist[100005];
int par[100005];

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

    int N, M;
    cin >> N >> M;

    vector<int> in(N);
    REP(i, N - 1 + M) {
        int from, to;
        cin >> from >> to;
        --from;
        --to;

        G[from].push_back(to);
        in[to]++;
    }

    int root = -1;
    REP(i, N) {
        if (in[i] == 0) {
            root = i;
            break;
        }
    }

    stack<int> st;
    st.push(root);
    while (!st.empty()) {
        int t = st.top();
        st.pop();

        for (auto k : G[t]) {
            in[k]--;
            if (in[k] == 0) {
                st.push(k);
                par[k] = t + 1;
            }
        }
    }

    REP(i, N) {
        cout << par[i] << endl;
    }

    return 0;
}


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

int main(){
    int r;
    double ans;
    cin >> r;
    ans = r * 2.0 * 3.1415;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3792
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
ll mod=2019;
//Combination
long long extGCD(long long a,long long mod,long long &x,long long &y){
    if(mod==0){
        x=1;
        y=0;
        return a;
    }
    long long d=extGCD(mod,a%mod,y,x);
    y-=(a/mod)*x;
    return d;
}
long long invmod(long long a,long long mod){
    long long x,y;
    extGCD(a,mod,x,y);
    x%=mod;
    if(x<0)x+=mod;
    return x;
}
ll fac[2000010],finv[2000010],inv[2000010];
void combinit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    REP(i,2,2000010){
        fac[i]=fac[i-1]*i%mod;
        inv[i]=invmod(i,mod);
        finv[i]=finv[i-1]*inv[i]%mod;
    }
}
ll comb(ll n,ll k){
    if(n<k)return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}
signed main(){
    combinit();
    string s;cin>>s;
    map<ll,ll>ma;
    ll ten=1;
    ll now=0;
    ma[0]=1;
    ll ans=0;
    rep(i,s.size()){
        now*=10;
        now%=mod;
        ten*=10;
        ten%=mod;
        now+=s[i]-'0';
        now%=mod;
        ll res=now*invmod(ten,mod);
        res%=mod;
        if(res<0)res+=mod;
        ans+=ma[res];
        ma[res]++;
    }
    cout<<ans<<endl;
}

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

int gcd(int a, int b) {
  while(b) {
    a %= b;
    swap(a, b);
  }
  return a;
}

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int n, x;
  cin >> n >> x;
  int g = 0;
  while(n--) {
    int y;
    cin >> y;
    g = gcd(abs(x - y), g);
  }
  cout << g << '\n';
}



Measured memory_bytes: 256
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    ll ans = 0;
    int tmp;
    string s;
	cin >> s;

	REP(i, s.size()){
		int l = i, r = s.size() - i - 1;
		for(int j = r; j>=0; j--){
			ans += (s[i]-'0') * pow(10, j) * pow(2, max(0,r - j - 1)) * pow(2, max(0,l));
			//cout << (s[i]-'0') * pow(10, j)  << " " << pow(2, max(0,r - j - 1)) << " " << pow(2, max(0,l)) << endl;
		} 
	}
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    ll B[110];
    cin >> N;
    rep(i,0,N) cin >> B[i];
    vector<ll> pos;
    rep(i,0,N) pos.push_back(B[i]);
    bool ok = true;
    vector<ll> ans;
    rep(t,0,N){
        ll pp = -1;
        rrep(i,N-t-1,0){
            if(pos[i] == i+1){
                pp = i+1;
                break;
            }
        }
        if(pp == -1){
            ok = false;
            break;
        }
        ans.push_back(pp);
        pos.erase(pos.begin() + pp-1);
    }
    if(not ok){
        print(-1);
        return 0;
    }
    reverse(ans.begin(), ans.end());
    rep(i,0,ans.size()) print(ans[i]);
    // vector<ll> v;
    // ll pos[110] = {};
    // rep(i,1,N+1) pos[i] = B[i-1];
    // bool ok = true;
    // vector<ll> ans;
    // rep(t,0,N){
    //     ll pp = -1;
    //     rrep(i,N-t,1){
    //         if(i == pos[i]){
    //             pp = i;
    //             break;
    //         }
    //     }
    //     if(pp == -1){
    //         ok = false;
    //         break;
    //     }
    //     ans.push_back(pp);
    //     rep(i,pp+1,N-t+1){
    //         pos[i-1] = pos[i];
    //     }
    // }
    // reverse(ans.begin(), ans.end());
    // if(!ok){
    //     print(-1);
    //     return 0;
    // }
    // rep(i,0,N){
    //     print(ans[i]);
    // }
    // rep(i,0,N) v.push_back(B[i]);
    // rep(t,0,N){

    // }
    
}

Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>
#define rep(i, n) for (int64_t i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int64_t N;
  cin >> N;

  vector<int> count(N + 1, 0);
  for (int64_t i = 1; i <= N; ++i) {
    for (int64_t j = i; j <= N; j += i) {
      count[j]++;
    }
  }
  int64_t answer = 0;
  for (int64_t i = 1; i <= N; ++i) {
    answer += i * count[i];
  }
  cout << answer << endl;
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  double res = 0;
  for (int i = 0; i < N; ++i) {
    double a; cin >> a;
    res += 1.0 / a;
  }
  cout << fixed << setprecision(10) << 1.0/res << endl;
}

Measured memory_bytes: 3784