akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <math.h>

double differ(double alpha,double beta){
        beta-=alpha;
        if(beta < 0)
                beta*=-1;
        return beta;
}

int main(void){
        double x1,x2,y1,y2,dx,dy,dis;
        scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
        dx=differ(x1,x2);
        dy=differ(y1,y2);
        dx*=dx;
        dy*=dy;
        dis=sqrt(dx+dy);
        printf("%f\n",dis);
        return 0;
}

Measured memory_bytes: 652
#include<stdio.h>
int main()
{
    int n,m,l,i,j,k;
    scanf("%d %d %d",&n,&m,&l);
    int x[n][m],y[m][l];
    long long s=0,z[n][l];
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        {
            scanf("%d",&x[i][j]);
        }
    }
    for(i=0;i<m;i++)
    {
        for(j=0;j<l;j++)
        {
            scanf("%d",&y[i][j]);
        }
    }
    for(i=0;i<n;i++)
    {
        for(j=0;j<l;j++)
        {
            for(k=0;k<m;k++)
            {
                s=s+x[i][k]*y[k][j];
            }
            z[i][j]=s;
            s=0;
        }
    }
    for(i=0;i<n;i++)
    {
        for(j=0;j<l-1;j++)
        {
            printf("%lld ",z[i][j]);
        }
        for(j=l-1;j<l;j++)
        {
            printf("%lld\n",z[i][j]);
        }
    }
    return 0;
}


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

using namespace std;

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

int main() {
    int q; cin >> q;
    map<string, int> m;
    while (q--) {
        int a; cin >> a;
        if (a == 0) {
            string k;
            int x; cin >> k >> x;
            m[k] = x;
        } else if (a == 1) {
            string k; cin >> k;
            if (m.count(k) == 0) cout << 0 << endl;
            else cout << m[k] << endl;
        } else if (a == 2) {
            string k; cin >> k;
            m.erase(k);
        } else {
            string l, r; cin >> l >> r;
            auto b = m.lower_bound(l);
            auto e = m.upper_bound(r);
            for (auto i = b; i != e; i++) {
                cout << (*i).first << " " << (*i).second << endl;
            }
        }
    }
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k,q;
    int a[100005];
    cin>>n>>k>>q;
    for(int i=1;i<=n;i++)a[i]=k-q;
    rep(i,q){
        int tmp;cin>>tmp;
        a[tmp]++;
    }
    for(int i=1;i<=n;i++){
        if(a[i]>0)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 1024
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll N;
vector<pair<ll, ll>> V;
ll A, B;
ll sum = 0;

int main() {
	scanf("%lld", &N);
	for(int i = 0; i < N; i++) {
		scanf("%lld %lld", &A, &B);
		V.push_back(make_pair(B, A));
	}
	sort(V.begin(), V.end());
	for(int i = 0; i < N; i++) {
		sum += V[i].second;
		if(sum > V[i].first) {
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;

	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 6128
"use strict";

var input = require("fs").readFileSync("/dev/stdin", "utf8");
var cin = input.split(/ |\n/),
    cid = 0;

function next() {
    return +cin[cid++];
} // number一個取得
function nextstr() {
    return cin[cid++];
} // 文字列一個取得
function nextbig() {
    return BigInt(cin[cid++]);
} // BigInteger一個取得
// 長さnの配列として取得。aは文字列フラグ
function nexts(n, a) {
    return a ? cin.slice(cid, cid += n) : cin.slice(cid, cid += n).map(a => +a);
}
// 長さnのBigInt配列として取得。
function nextsbig(n) {
    return cin.slice(cid, cid += n).map(a => BigInt(a));
}
// w個ずつを組にして長さhの配列。aは文字列フラグ。
function nextm(h, w, a) {
    var r = [],
        i = 0;
    if (a)
        for (; i < h; i++) r.push(cin.slice(cid, cid += w));
    else
        for (; i < h; i++) r.push(cin.slice(cid, cid += w).map(a => +a));
    return r;
}
// 多次元配列。v,a1,a2,a3 なら、3次元。[[値vで長さa3の配列]をa2個並べた配列]をa1個並べた配列。
function xArray(v) {
    var a = arguments,
        l = a.length,
        r = "Array(a[" + --l + "]).fill().map(x=>{return " + v + ";})";
    while (--l) r = "Array(a[" + l + "]).fill().map(x=>" + r + ")";
    return eval(r);
}


console.log(main().toString());

function main() {
    let n = next(); //("00000" + nexts()).substr(-5).split("").map(x => +x);
    let min = next();
    let max = next();
    let ans = 0;
    let i;
    for (i = 1; i <= n; i++) {
        let v = 0;
        i.toString().split("").forEach(x => v += +x);
        if (min <= v && v <= max) {
            ans += i
        }
    }

    return ans;
}

Measured memory_bytes: 10296
N,M,K = map(int,input().split())

mod = 10**9+7
fact = [1]*(2*N*M+1)
for n in range(1,2*N*M+1):
    fact[n] = n*fact[n-1]%mod

def inv(n):
    n %= mod
    return pow(n,mod-2,mod)

ans = M*(M**2-1)*N**2%mod+N*(N**2-1)*M**2%mod
ans *= inv(6)*fact[N*M-2]*inv(fact[K-2]*fact[N*M-K])
ans %= mod

print(ans)

Measured memory_bytes: 18804
#ifndef LOCAL
    #pragma GCC optimize("O3")
    #endif
    #include "bits/stdc++.h"
    using namespace std;
    #define sim template <class c
    #define ris return *this
    #define dor > debug &operator<<
    #define eni(x)                                                                    \
        sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
        {
    sim > struct rge
    {
        c b, e;
    };
    sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
    sim > auto dud(c *x) -> decltype(cerr << *x, 0);
    sim > char dud(...);
    struct debug
    {
    #ifdef LOCAL
        ~debug()
        {
            cerr << endl;
        }
        eni(!=) cerr << boolalpha << i;
        ris;
    } eni(==) ris << range(begin(i), end(i));
    }
    sim, class b dor(pair<b, c> d)
    {
        ris << "(" << d.first << ", " << d.second << ")";
    }
    sim dor(rge<c> d)
    {
        *this << "[";
        for (auto it = d.b; it != d.e; ++it)
            *this << ", " + 2 * (it == d.b) << *it;
        ris << "]";
    }
    #else
        sim dor(const c &)
        {
            ris;
        }
    #endif
    }
    ;
    #define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
    #define fastio                        \
        ios_base::sync_with_stdio(false); \
        cin.tie(0);
    #define endl '\n'
    typedef long long ll;
    typedef long double ld;
    const ll MOD = 1e9 + 7;
    const ll N = 1e5 + 10;
    

    int main()
    {
        fastio
     string h;
     cin>>h;
     int len=h.length();
     for (int i = 0; i < len ; i++)
     {
         if(i%2==0)
         {
            if(h[i]!='R' && h[i]!= 'U' && h[i]!='D')
            return cout<<"No",0;
         }
         else if(i%2==1)
         {
            if(h[i]!='L'&& h[i]!= 'U' && h[i]!='D')
            return cout<<"No",0;
         }
     }
     cout<<"Yes"<<endl;
     

        return 0;
    }

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<unordered_map>
#include<functional>
#include<set>
#include<numeric>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define SUM(a) accumulate(all(a),0LL)
#define pb push_back
#define endl '\n'
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, cnt = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok = true, flag = false;
ll dx[9] = { 0,1,-1,0,0,1,1,-1,-1 }, dy[9] = { 0,0,0,1,-1,1,-1,1,-1 };
#pragma endregion
#define MAX 222222


ll a[MAX];

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


  cin >> n;
  rep(i, n) cin >> a[i];
  ll sum = 0;
  rep(i, n) sum += a[i];
  ll ab = inf;
  rep(i, n) {
    if (ab > abs(sum- a[i] * n)) {
      ab = abs(sum - a[i] * n);
      ans = i;
    }
  }

  cout << ans << endl;

  return 0;
}

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

using namespace std;

int count_bomb(vector<string>& v, int x, int y) {
    int count = 0;

    for (int i = x - 1; i <= x + 1; ++i) {
        if (i < 0 || i >= v.size())
            continue;
        for (int j = y - 1; j <= y + 1; ++j) {
            if (j < 0 || j >= v[0].length())
                continue;

            if (i == x && j == y)
                continue;
            if (v[i][j] == '#')
                ++count;
        }
    }
    return count;
}

int main() {
    int h, w;
    cin >> h >> w;

    vector<string> v(h);
    for (int i = 0; i < h; ++i)
        cin >> v[i];

    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (v[i][j] == '.')
                v[i][j] = '0' + count_bomb(v, i, j);
        }
    }

    for (int i = 0; i < h; ++i)
        cout << v[i] << '\n';
}


Measured memory_bytes: 256
S = input()

T = '*KIH*B*R*'
V = set()

for mask in range(1 << 4):
    cnt = 0
    v = []
    for t in T:
        if t == '*':
            if (mask & (1 << cnt)) != 0:
                v.append('A')
            cnt += 1
        else:
            v.append(t)
    V.add(''.join(v))

if S in V:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int INF = 1e9;
template<class T> inline void chmax(T &a,T b){if(a<b)a=b;}
template<class T> inline void chmin(T &a,T b){if(a>b)a=b;}

int dp[100010];
int deg[100010];
vector<vector<int> > G;

int main(){
    cin.tie(0); ios_base::sync_with_stdio(false);
    int N,M,x,y;
    cin >> N >> M;
    G.resize(N);
    
    for(int i = 0; i < M; ++i){
        cin >> x >> y;
        --x; --y;
        G[x].push_back(y);
        ++deg[y];
    }
    queue<int> que;
    for(int i = 0; i < N; ++i) if(deg[i]==0) que.push(i);
    while(!que.empty()){
        int v = que.front(); que.pop();
        for(int nv : G[v]){
            chmax(dp[nv],dp[v]+1);
            if(--deg[nv]==0) que.push(nv);
        }
    }
    int ans = 0;
    for(int i = 0; i < N; ++i) chmax(ans,dp[i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <deque>
#include <numeric>
#include <utility>
#define sign(a) ((a>0)-(a<0))
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define LL long long
#define INF (LL)(1LL<<60)
#define all(a) (a).begin(), (a).end()

using namespace std;

void solve(long long N, long long K, std::vector<long long> D){
    vector<LL> digs;
    LL d10=1;
    while(N>0){
        digs.emplace_back(N%10);
        N/=10;
        d10*=10;
    }
    reverse(all(digs));

    vector<LL> adigs;
    rep(i,10)if(find(all(D),i)==D.end())adigs.emplace_back(i);

    LL dp0=d10*(*upper_bound(all(adigs),0));
    LL dp1=0;

    for(auto d:digs){
        d10/=10;
        auto it = upper_bound(all(adigs),d);
        if(it != adigs.end())
            dp0 = min(dp0+d10*adigs[0], dp1+d10*(*it));
        else
            dp0 = dp0+d10*adigs[0];

        if(find(all(adigs),d)==adigs.end())
            dp1 = INF;
        else
            dp1 = dp1+d10*d;
    }
    cout << min(dp1, dp0) << endl;

}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> D(K);
    for(int i = 0 ; i < K ; i++){
        scanf("%lld",&D[i]);
    }
    solve(N, K, std::move(D));
    return 0;
}


Measured memory_bytes: 256
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

H, W = map(int, input().split())

A = [0] * H
for i in range(H):
    A[i] = list(input())


x = set()
for i in range(H):
    if all(True if a == '.' else False for a in A[i]):
        x.add(i)

ans = []
for i in range(H):
    if i in x:
        continue
    ans.append(A[i])

A = ans
x = set()
for i in range(W):
    if all(True if A[j][i] == '.' else False for j in range(len(A))):
        x.add(i)

ans = []
for i in range(len(A)):
    z = []
    for j in range(W):
        if j not in x:
            z.append(A[i][j])
    ans.append(z)

for i in ans:
    print("".join(i))

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

int main() {
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    
    string res;
    for(int i = 0; i < N; i++){
        if(i == K - 1){
            res += tolower(S[i]);
        }
        else{
            res += S[i];
        }
    }
    
    cout << res << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rem(i, m, n) for (int i = m; i < (n); i++)
#define eps (1e-7)
#define inf (1e9)
#define pi (acos(-1))
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

    ll a, b, c, k;
    cin >> a >> b >> c >> k;

    ll ans;
    if (k % 2 == 0)
    {
        ans = a - b;
    }
    else
    {
        ans = b - a;
    }

    if (ans > 1e18)
        cout << "Unfair"
             << "\n";
    else
        cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 256
import math
s = input()
t = input()

alp_s = []
alp_t = []
num_s = []
num_t = []
for i in range(len(s)):
    cnt = 0
    for j in alp_s:
        if s[i] == j:
            num_s[cnt] += 1
        cnt += 1
    if not s[i] in alp_s:
        alp_s.append(s[i])
        num_s.append(1)

    cnt = 0
    for j in alp_t:
        if t[i] == j:
            num_t[cnt] += 1
        cnt += 1
    if not t[i] in alp_t:
        alp_t.append(t[i])
        num_t.append(1)
    
    if num_s != num_t:
        print('No')
        quit()
print('Yes')    

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

template< typename T >
size_t longest_increasing_subsequence(const vector< T > &a, bool strict) {
  vector< T > lis;
  for(auto &p : a) {
    typename vector< T >::iterator it;
    if(strict) it = lower_bound(begin(lis), end(lis), p);
    else it = upper_bound(begin(lis), end(lis), p);
    if(end(lis) == it) lis.emplace_back(p);
    else *it = p;
  }
  return lis.size();
}

int main(){
  int N;
  cin>>N;
  vector<int> A(N);
  for(int i=N-1;i>=0;i--){
    cin>>A[i];
  }
  
  cout<<longest_increasing_subsequence(A,false)<<endl;
  return 0; 
}



Measured memory_bytes: 4156
#include<bits/stdc++.h>
typedef long long int ll;
#define pb push_back
#define pp pair<ll,ll>
#define vi vector<ll>
#define vvi vector<vi>
#define vb vector<bool>
#define vvb vector<vb>

using namespace std;

ll kp2(vi& profit,vi& wt,ll maxwt,ll maxv){
    int n=profit.size();
    vvi dp(n+1,vi(maxv+1,INT_MAX));
    ll ans=0;
    dp[0][0]=0;
    for(int i=1;i<=n;i++){
        for(ll j=0;j<=maxv;j++){
            if(j>=profit[i-1]){
                dp[i][j]=min(dp[i-1][j],dp[i-1][j-profit[i-1]]+wt[i-1]);
            }else{
                dp[i][j]=dp[i-1][j];
            }
           if(dp[i][j]<=maxwt){
            ans=max(ans,j);
        }
        }
    }
    return ans;
}

int main(){
  ll n,W;
  cin>>n>>W;
  ll tsum=0;
  vector<ll> p(n);
  vector<ll> w(n);
  for(int i=0;i<n;i++){
    cin>>w[i]>>p[i];
    tsum+=p[i];
  }
  cout<<kp2(p,w,W,tsum);
}


Measured memory_bytes: 80256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
using namespace std;


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


int main(){
  int n;
  cin >> n;
  vector<int> t(n), x(n), y(n);
  rep(i, n){
    cin >> t[i] >> x[i] >> y[i];
  }

  int nt = 0;
  int nx = 0;
  int ny = 0;
  bool ans = true;
  for(int i = 0; i < n; ++i){
    int dist = abs (nx + ny - x[i] - y[i]);

    if(nt + dist > t[i] || ((nt + dist) - t[i]) % 2 != 0)  ans = false;
    nt = t[i];
    nx = x[i];
    ny = y[i];
  }

  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;



}


Measured memory_bytes: 1408
import java.util.*;
import java.lang.Math;

public class Main
{
	public static void main(String args[])
	{
		Scanner s1=new Scanner (System.in);
		double n,r;
		n=s1.nextDouble();
		r=s1.nextDouble();
		double m = (Math.log(n)/Math.log(r));
		int count=(int)(Math.floor(m)+1);
		System.out.println(count);
	}
}

Measured memory_bytes: 23124
import java.util.*;

public class Main {
    public void main(Scanner sc) {
        int n = sc.nextInt();
        long sum = 0;
        for (int i = 0; i < n; i++) {
            sum += sc.nextInt();
        }

        System.out.println(sum - n);
    }

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


Measured memory_bytes: 25940
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext())
		{
			System.out.print(sc.next() + " ");
			int n = sc.nextInt();
			int m = sc.nextInt();
			System.out.print(Integer.toString(n + m) + " ");
			System.out.println(n * 200 + m * 300);
		}
	}
}

Measured memory_bytes: 12000
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin >> N;
  int cnt = 0;
  ll sum = 0LL;
  ll a[N];
  for(int i=0;i<N;i++){
    cin >> a[i];
    sum += abs(a[i]);
    if(a[i] < 0) cnt++;
    a[i] = abs(a[i]);
  }

  if(cnt % 2 == 0){
    cout << sum << endl;
  }
  else{
    cout << sum - *min_element(a, a+N) * 2 << endl;
  }

  return 0;


}

Measured memory_bytes: 1024
using System;
using System.Text;
using System.Collections.Generic;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        string[] str = Console.ReadLine().Split(' ');
        sb.Append((str[1] == "-" ? (int.Parse(str[0]) - int.Parse(str[2])) : (int.Parse(str[0]) + int.Parse(str[2])))+"\n");
    }
}

Measured memory_bytes: 2648
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(_,v.size())cout<<" "<<v[_];cout<<endl;
#define show2d(v) rep(__,v.size()){rep(_,v[__].size())cout<<" "<<v[__][_];cout<<endl;}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};

vi t;
bool f(int a){
	map<int,int>ma;
	stack<int>len;
	rep(i,t.size()){
		int w=t[i];
		ma[w]++;
		while(!len.empty()&&len.top()>w){
			ma.erase(len.top());
			len.pop();
		}
		len.push(w);
		while(w>0&&ma[w]==a){
			ma.erase(w);
			len.pop();
			ma[--w]++;
			if(len.empty()||len.top()-w)len.push(w);
		}
		if(ma[0])return 0;
	}
	return 1;
}
signed main(){
	int n;
	cin>>n;
	vi in(n);
	rep(i,n)cin>>in[i];
	rep(i,n-1)if(in[i]>=in[i+1])t.pb(in[i+1]);
	if(t.size()==0){
		cout<<1<<endl;
		return 0;
	}
	int l=1,r=n;
	while(r-l>1){
		int h=(l+r)/2;
		if(f(h))r=h;
		else l=h;
	}
	cout<<r<<endl;
}


Measured memory_bytes: 4976
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); 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 FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)                                                            \
  for (auto v : (V)) {                                                         \
    cout << v << " ";                                                          \
  }                                                                            \
  cout << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
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 (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > using vec = std::vector< T >;
template < class T > void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  vec< int > a(N + 2);
  int sum = 0;
  vec< int > skip(N);
  a[0] = 0;
  a[N + 1] = 0;
  REP(i, N) {
    cin >> a[i + 1];
    sum += abs(a[i + 1] - a[i]);
  }
  sum += abs(a[N + 1] - a[N]);
  REP(i, N) {
    print(sum - (abs(a[i + 2] - a[i + 1]) + abs(a[i + 1] - a[i])) +
          abs(a[i + 2] - a[i]));
  }
}

Measured memory_bytes: 2816
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int[] a = new int[N];
    for (int i = 0; i < N; i++) {
      a[i] = scanner.nextInt() - 1;
    }
    int num = 0;
    for (int i = 0; i < N; i++) {
      if (a[a[i]] == i) num++;
    }
    System.out.println(num / 2);
  }
}


Measured memory_bytes: 51616
#include <bits/stdc++.h>
using namespace std;
 
//#define int long long
#define F first
#define S second

int main() {
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int x;
	vector <int> vec1, vec2;
	for (int i = 0; i < n; i++) {
		cin >> x;
		vec1.push_back(x);
	}
	for (int i = 0; i < n; i++) {
		cin >> x;
		vec2.push_back(x);
	}
	if (vec1 > vec2)
		swap(vec1, vec2);
	int ans = 0;
	while(vec1 != vec2) {
		std::next_permutation(vec1.begin(), vec1.end());
		ans++;
	}
	cout << ans;
}



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


using namespace std;
double pi=3.14159265358979323846264338;


inline void ex(){cout<<"NO"<<endl;exit(0);}
long long n,m,mon;
long long arr[100001],arr2[100001];
long long calc(long long k){
	long long cnt=0;
	for(long long i=0;i<k;i++){
		cnt+=max((long long)0,arr2[k-i]-arr[n-i]);
	}
	return cnt;
}
long long calc2(long long k){
	long long cnt=0;
	for(long long i=0;i<k;i++){
		cnt+=arr2[k-i];
	}
	return cnt-mon;
}
int main(){
	cin>>n;
	if(n==1)cout<<"0"<<endl;
	else cout<<"1"<<endl;
	return 0;
			
}

Measured memory_bytes: 3636
n = int(input())
a = list(map(int, input().split()))
ans = 1
lis = [0] * (n+1)


for i in range(n):
    if a[i] == 0:
        lis[i+1] += 1
    lis[i+1] += lis[i]
#print(lis)
if lis[-1] > 0:
    print(0)
    exit()
for i in range(n):
    ans *= a[i]
    if lis[-1]-lis[i+1] == 0:
        if ans > int(1e18):
            print(-1)
            exit()
print(ans)


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

#define MAXN 10010
#define ll long long
#define mod 1000000007

using namespace std;

int n, m, k, tot, ans, sum;

int a[MAXN][MAXN];
int h[MAXN], l[MAXN];
int b[MAXN];
int s[MAXN];

int count(int sta) {
	memset(b, 0, sizeof(b));
	memset(s, 0, sizeof(s));
	int now = 1, res = 0;
	for (int i = 0; i < n; i++) {
		b[i + 1] = now;
		if ((sta >> i) & 1) ++now;
	}
	
	for (int i = 1; i <= m; i++) {
		for (int j = 1; j <= n; j++) s[b[j]] += a[j][i];
		bool f = 1;
		for (int j = 1; j <= n; j++)
			if (s[b[j]] > k) {
				res++;
				f = 0;
				break;
			}
		if (!f) {
			memset(s, 0, sizeof(s));
			for (int j = 1; j <= n; j++) {
				s[b[j]] += a[j][i];
				if (s[b[j]] > k) return n + m;
			}	
		}
	}
	return res;
}

int main() {
	int t, now = 0;
	scanf("%d%d%d", &n, &m, &k);
	ans = n + m;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++) {
			char c;
			cin >> c;
			a[i][j] = c - '0';
		}
	
	for (int i = 0; i < (1 << (n - 1)); i++) {
		int num = 0;
		for (int j = 0; j < n; j++)
			if ((i >> j) & 1) num++;
		ans = min(ans, count(i) + num);
	} 
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
def convert(n):
    return chr(ord('a') + int(n))


def main():
    n = int(input())
    ans = ''
    n -= 1
    # ans += chr(ord('a') + (n - 1) % 26)
    ans = convert(n % 26)
    n = n // 26
    while n > 0:
        n -= 1
        ans += convert(n % 26)
        n = n // 26
    ans = ans[::-1]
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9184
from itertools import chain

H, W = map(int, input().split())
M = [list(input()) for _ in range(H)]
inf = float('inf')

def flatten(list_of_lists):
    "Flatten one level of nesting"
    return chain.from_iterable(list_of_lists)


def bfs(start, end):
    distance = [[inf for i in range(W)] for j in range(H)]
    queue = [(end, start)]
    distance[end][start] = 0

    while queue:
        y, x = queue.pop()
        for i in range(0, 4):
            nx, ny = x + [1, 0, -1, 0][i], y + [0, 1, 0, -1][i]
            if 0 <= nx < W and 0 <= ny < H and M[ny][nx] != '#' and distance[ny][nx] == inf:
                queue.insert(0, (ny, nx))
                distance[ny][nx] = distance[y][x] + 1
    return distance


m = 0
for i in range(W):
    for j in range(H):
        if M[j][i] != "#":

            for length in list(flatten(bfs(i, j))):
                if length != inf and m < length:
                    m = length

print(m)


Measured memory_bytes: 3064
import sys
N = int(input())
height = list(map(int, input().split()))
pre_h = 0
now_h = height[0]

for i in range(1, N):
    next_h = height[i]
    if now_h > next_h:
        now_h -=1
        if now_h > next_h or pre_h > now_h:
            print("No")
            sys.exit()
    elif now_h > pre_h:
        now_h -= 1
    pre_h = now_h
    now_h = next_h
print("Yes")

Measured memory_bytes: 15020
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <string>

#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <time.h>

#include <string>

bool area[100][100];

const int MAX_N = 100050;
int A[MAX_N];
int N;

int main(int argc, char **argv) {
    std::cin >> N;

    for (int i = 1; i <= N; i++) {
        std::cin >> A[i];
    }

    A[0] = 0; A[N+1] = 0;
    int total = 0;

    for (int i = 1; i <= N+1; i++) {
        total += abs(A[i] - A[i-1]);
    }

    int B[MAX_N];
    for (int i = 1; i <= N; i++) {
        B[i] = abs(A[i] - A[i-1]) + abs(A[i+1] - A[i]) - abs(A[i+1] - A[i-1]);
    }

    for (int i = 1; i <= N; i++) {
        std::cout << total - B[i] << std::endl;
    }
    
    return 0;

}



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

using namespace std;
using ll = long long;

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

    vector<ll> dogs(N,0);
    ll xor_sum = 0;
    for(int i=0; i<N; i++){
        cin >> dogs.at(i);
        xor_sum = xor_sum ^ dogs.at(i);
    }

    for(int i=0; i<N; i++){
        cout << (xor_sum ^ dogs.at(i)) << " ";
    }
}

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

int main() {
    ll n,k;
    cin>>n>>k;
    ll ar[n+1];
    for(ll i=1;i<=n;i++)cin>>ar[i];
    ll dp[n+1];
    for(ll i=1;i<=n;i++)dp[i]=(ll)1e18;
    dp[1]=0;
    for(ll i=2;i<=n;i++)
    {   //cout<<dp[i]<<endl;
        for(ll j=max((ll)1,i-k);j<=i-1;j++)
       {   // if(i-j<=0)break;
           dp[i]=min( dp[j]+abs(ar[i]-ar[j]) ,dp[i]);
           
       }
       
    }
    cout<<dp[n];
    
}

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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

bool check(char ox, char c, char m, char a){
	if(ox == 'o'){
		if(m == 'S'){
			return c == a;
		}else{
			return c != a;
		}
	}else{
		if(m == 'S'){
			return c != a;
		}else{
			return c == a;
		}

	}
}

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	
	
	int n;
	cin >> n;

	string s;
	cin >> s;

	vector<string> ans;

	ans.pb("SS");
	ans.pb("SW");
	ans.pb("WS");
	ans.pb("WW");

	for(int i=0; i<4; i++){
		for(int j=2; j<n; j++){
			if(ans[i][j-1] == 'S'){
				if(s[j-1] == 'o'){
					ans[i] += ans[i][j-2];
				}else{
					if(ans[i][j-2] == 'S'){
						ans[i] += 'W';
					}else{
						ans[i] += 'S';
					}
				}
			}else if(ans[i][j-1] == 'W'){
				if(s[j-1] == 'o'){
					if(ans[i][j-2] == 'S'){
						ans[i] += 'W';
					}else{
						ans[i] += 'S';
					}
				}else{
					ans[i] += ans[i][j-2];
				}
			}
		}

		bool f = true;
		for(int j=1; j<n-1; j++){
			if(!check(s[j], ans[i][j-1], ans[i][j], ans[i][j+1])) f =false;
		}
		if(!check(s[0], ans[i][n-1], ans[i][0], ans[i][1])) f = false;
		if(!check(s[n-1], ans[i][n-2], ans[i][n-1], ans[i][0])) f = false;
		if(f){
			cout << ans[i] << endl;
			return 0;
		}
	}

	puts("-1");
	
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>

using namespace std;
typedef long long ll;

ll MOD = 1000000007;

ll K, N, M;
ll fact[200001], factinv[200001];

ll modpow(ll a, ll b) {
	ll ret = 1, kakeru = a;
	while (b > 0) {
		if (b & 1)ret *= kakeru, ret %= MOD;
		kakeru *= kakeru, kakeru %= MOD;
		b >>= 1;
	}
	return ret;
}

void setfact() {
	fact[0] = 1, fact[1] = 1;
	for (int i = 2; i <= 200000; i++) {
		fact[i] = fact[i - 1] * i;
		fact[i] %= MOD;
	}
	factinv[200000] = modpow(fact[200000], MOD - 2);
	for (int i = 200000 - 1; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * (i + 1);
		factinv[i] %= MOD;
	}
}

ll comb(ll a, ll b) {
	
	ll ret = fact[a];
	ret *= factinv[b], ret %= MOD;
	ret *= factinv[a - b], ret %= MOD;
	return ret;
}

int main() {

	setfact();

	cin >> N >> M >> K;
	
	ll ans = 0;

	for (int i = 1; i <= M - 1; i++) {
		ans += (i % MOD) * ((M - i) % MOD) * modpow(N, 2);
		ans %= MOD;
	}
	for (int i = 1; i <= N - 1; i++) {
		ans += (i % MOD) * ((N - i) % MOD) * modpow(M, 2);
		ans %= MOD;
	}
	cout << (ans * comb(N * M - 2, K - 2)) % MOD << endl;
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ULL;
const int MOD=1e9+7;
ULL sum(ULL M){ return ((M*(M+1))/2)%MOD; }
int main(){
ULL N, K, i, ans=0; cin >> N >> K;
for(i=K; i<=N+1; i++){
ULL A=sum(i-1), B=0;
if(i==N+1){ B=sum(N); }else{ B=(sum(N)+MOD-sum(N-i))%MOD; }
ans=(ans+(B+MOD-A+1))%MOD;
}
cout << ans << "\n";
}

Measured memory_bytes: 3636
N, M=map(int,input().split())
H=list(map(int,input().split()))
ans=[1]*N
for i in range(M):
  A, B=map(int, input().split())
  if H[A-1]>H[B-1]:
    ans[B-1]=0
  elif H[B-1]>H[A-1]:
    ans[A-1]=0
  elif H[A-1]==H[B-1]:
    ans[A-1]=0
    ans[B-1]=0
print(sum(ans))


Measured memory_bytes: 20112
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define rep1(n) for(ll i=0;i<n;++i)
#define rep2(i,n) for(ll i=0;i<n;++i)
#define rep3(i,a,b) for(ll i=a;i<b;++i)
#define rep4(i,a,b,c) for(ll i=a;i<b;i+=c)
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define LD(...) ld __VA_ARGS__;in(__VA_ARGS__)
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//bitSearch, bitList, nod, gcdlcm, isPrime, primeFactorize, Npow, divisor, modinv, dfs, bfs, eratos//
//dijkstra, WarshallFloyd, BellmanFord, UnionFind, COM, digitDP ,RMQ//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007; ll INF = 1LL << 62; ll ans = 0; ll z = 0, o = 1;
vl flag, color, D; vll path; ll pre = 0;
ll isPrime(ll x) {
	ll i;
	if (x < 2) {
		return 0;
	}
	else if (x == 2) {
		return 1;
	}
	else if (x % 2 == 0) {
		return 0;
	}
	else {
		for (i = 3; i * i <= x; i += 2) {
			if (x % i == 0) {
				return 0;
			}
		}
		return 1;
	}
}
int main() {
	cin >> Q;
	N = 100000;
	vl sum(N + 1);
	for (i = 1; i <= N; i++) {
		if (i % 2 == 1 && isPrime(i) && isPrime((i + 1) / 2)) sum[i] = sum[i - 1] + 1;
		else sum[i] = sum[i - 1];
	}
	for (i = 0; i < Q; i++) {
		ll l, r;
		cin >> l >> r;
		cout << sum[r] - sum[l - 1] << endl;
	}
}

Measured memory_bytes: 1408
A,B = map(int,input().split())
if int(A/0.08) == (A/0.08):
  A_min = int(A/0.08)
else:
  A_min = int(A/0.08)+1

A_max = int((A+1)/0.08)-1

  
  
if int(B/0.1) == (B/0.1):
  B_min = int(B/0.1)
else:
  B_min = int(B/0.1)+1

B_max = int((B+1)/0.1)-1

if (A_max < B_min) or (B_max < A_min):
  print(-1)
elif A_min >= B_min:
  print(A_min)
else:
  print(B_min)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//const int mod = 1e9+7;
ll a,b,v,w,t;

inline void quickread() {
    ios::sync_with_stdio(false);
    cin >> a>> v >> b >> w >> t;
    ll dis = abs(a- b);
    if(dis > t*(v-w)) {
        cout << "NO" << endl;
    } else {
        cout << "YES" << endl;
    }
    cin.tie(0);
}

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


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

int main() {
	ll N,r=1;
	bool ok = 1;
	cin >> N;
	vector<ll> A(N);

	rep(i,N) {
		cin >> A.at(i);
		if(A.at(i) == 0) {
			cout << 0 << endl;
			return 0;
		}
	}

	rep(i,N) {
		if((double)A.at(i) > (double)1e18/(double)r) {
			ok = 0;
			break;
		}
		r *= A.at(i);

		if(r > (ll)1e18) {
			ok = 0;
			break;
		}
	}

	cout << ((ok) ? r : -1) << endl;
}

Measured memory_bytes: 4060
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath> 
#include <cstdlib> // abs(int)
#include <numeric>
#include <iomanip>
#include <map>
#include <set>

using namespace std;

#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define assign_max(into, compared) (into = max((into), (compared)))
#define assign_min(into, compared) (into = min((into), (compared)))
#define rep(i,n) for(long long i = 0;i < n;++i)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(nullptr);
#define fix(n) fixed << setprecision(n)
#define ALL(v) v.begin(),v.end()

#define PI 3.14159265358979323846;

using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;


int main(void){
    FAST_IO
    
    ll n;
    cin >> n;

    map<string,bool> is_said;
    vector<string> s(n);
    rep(i,n) cin >> s[i];

    is_said[s[0]] = true;
    for(ll i = 1;i < n;i++){
        if(s[i-1].back() != s[i].front()) {
            cout << "No" << endl;
            return 0;
        }
        if(is_said[s[i]]){
            cout << "No" << endl;
            return 0;
        }
        is_said[s[i]] = true;
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3124
#include<iostream>
#include<algorithm>
#include<math.h>
#include<map>
using namespace std;

int main(){
    int n, sum;
    cin >> n;
    int x = n;
    while(n != 0){
        sum += n % 10;
        n /= 10;
    }
    if(x % sum == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdio>
#include <stack>

using namespace std;

int main()
{
	int	N;
	string S;
	int cnt = 0;
	int ans = 0;

	cin >> N;
	cin >> S;

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

		for (char str = 'a'; str <= 'z'; ++str) {
			bool left = false;
			bool right = false;

			for (int j = 0; j < i; ++j) {
				if (S[j] == str) {
					left = true;
				}
			}

			for (int j = i; j < N; ++j) {
				if (S[j] == str) {
					right = true;
				}
			}

			if (left == true && right == true) {
				cnt = cnt + 1;
			}

		}

		if (ans < cnt) {
			ans = cnt;
		}

	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
A, B, C, D = map(int, input().split())
mod = 998244353

dp = [[0] * (D+1) for _ in range(C+1)]

x, y = A, B
dp[x][y] = 1

for i in range(x, C+1):
    for j in range(y, D+1):
        if i == x and j == y:
            continue

        if i > x:
            dp[i][j] += dp[i-1][j] * j
        if j > y:
            dp[i][j] += dp[i][j-1] * i

        if i > x and j > y:
            dp[i][j] -= (i-1) * (j-1) * dp[i-1][j-1]

        dp[i][j] %= mod

print(dp[C][D])


Measured memory_bytes: 133872
import collections
import itertools
import numpy as np
import sys
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,M = IL()
ab = [IL() for i in range(N)]

ab.sort()

cnt = 0
ans = 0
for a,b in ab:
    while b>0:
        ans += a
        M -= 1
        b -= 1
        if M == 0:
            break
    if M==0:
        break

print(ans)

Measured memory_bytes: 36816
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;

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

    map<string, long long> mp;  // = {} を書く必要がない
 
    for(int i = 0; i < n; i++) {
        cin >> s;
        sort(s.begin(), s.end());
        mp[s]++;
    }
    
    long long ans = 0;
    for(auto x : mp) {
        long long n = x.second;
        ans += n * (n - 1) / 2;
        // cout << x.first << ": " << x.second << endl;
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 11136
#include<stdio.h>
#include<algorithm>
using namespace std;

struct str{
	int a, b, c;
};
str team[100];
int main(){
	int n, a, b, c, d, j;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		team[i].a = i;
	for (int i = 0; i < n*(n - 1) / 2; i++){
		scanf("%d%d%d%d", &a, &b, &c, &d);
		a--; b--;
		if (c - d)c>d ? team[a].b+=3 : team[b].b+=3;
		else{ team[a].b++; team[b].b++; }
	}
	sort(team, team + n, [](str a, str b){return a.b > b.b; });
	for (int i = 0; i < n; i++){
		j = i;
		while (j < n&&team[i].b == team[j].b){
			team[j].c = i + 1;
			j++;
		}
		i = j - 1;
	}
	sort(team, team + n, [](str a, str b){return a.a < b.a; });
	for (int i = 0; i < n; i++)
		printf("%d\n", team[i].c);
	return 0;
}

Measured memory_bytes: 2760
counters = {
    'hon': {2, 4, 5, 7, 9},
    'pon': {0, 1, 6, 8},
    'bon': {3},
}

N = input()
for k, v in counters.items():
    if int(str(N)[-1]) in v:
        print(k)
        break


Measured memory_bytes: 61880
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)



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


	ll N, K;
	cin >> N >> K;
	vector<ll>H(N);
	for (int i = 0; i < N; i++)cin >> H[i];
	sort(all(H));
	reverse(all(H));
	
	ll ans = 0;
	for (int i = 0; i < N; i++) {
		if (i >= K)ans += H[i];
	}
	puts(ans);
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).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; }

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

const ll INF = 1LL << 60;

vvi G;
vi color;

bool dfs(int v, int col = 1){
  color[v] = col;
  for(auto nv : G[v]){
    if(color[nv] != -1){
      if(color[nv] == col) return false;
    }
    else{
      if(!dfs(nv, 1-col)) return false;
    }
  }
  return true;
}

int main(){
  ll n; int m;
  cin >> n >> m;
  G.resize(n);
  rep(i, m){
    int a,b; cin >> a >> b;
    a--; b--;
    G[a].pb(b); G[b].pb(a);
  }

  color.resize(n, -1);
  bool biparticle;
  biparticle = dfs(0);
  ll ans;
  if(biparticle){
    ll cnt = 0;
    rep(i, n) cnt += color[i];
    ans = cnt*(n-cnt) - m;
  }
  else{
    ans = n*(n-1)/2 - m;
  }

  std::cout << ans << '\n';
}


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

int main(int argc, char const *argv[])
{
  	int a = 0;
	string s, t;
  	cin >> s >> t;
  	for(int i = 0; i < s.length(); i++)
    {
		a += (s[i] != t[i]);
    }
  
  	cout << a;
	return 0;
}


Measured memory_bytes: 3816
#include <bits/stdc++.h>
#include <set>
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 100000000
#define MOD 100000007

#define writeln(n) cout<<n<<endl

using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

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

llong pownew(llong m, llong n) {
    if (n == 0) { return 1; }
    if (n % 2 == 0) { return pow(m*m, n/2); }
    return pow(m, n-1) * m;
}

bool isprime(int p) {
    if (p == 1) return false;
    for (int i = 2; i < p; i++) {
        if (p%i == 0) return false;
    }
    return true;
}

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

const int inf=100000000;

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

llong gcd(llong a, llong b) {
    return b != 0 ? gcd(b, a % b) : a;
}
//setprecision(10);



int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    llong n; cin>>n;
    cout<<n*(n+1)/2-n<<endl;
    return  0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int a, b, d, r;
    double f;
    scanf("%d %d", &a, &b);
    d=a/b;
    r=a%b;
    f=1.00000*a/b;
    printf("%d %d %f", d, r, f);
    
    return 0;
}



Measured memory_bytes: 2148