akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        h: usize,
        a: usize,
    }
    let mut result = h / a;
    if h % a != 0 {
        result += 1;
    }
    println!("{}", result);
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <climits>

using namespace std;

int n, map[20], Min;

void search( int A, int B, int count )
{
	if(count == n) {
		Min = min(Min, abs(A-B));
		return;
	}
	search(A + map[count], B, count + 1);
	search(A, B + map[count], count + 1);
}

int main( void )
{
	while(cin >> n, n) {
		for (int i = 0; i < n; ++i) cin >> map[i];
		Min = INT_MAX;
		search(0, 0, 0);
		cout << Min << endl;
	}
	return 0;
}

Measured memory_bytes: 864
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
#define deb(x) cerr << "\n" \
                    << #x << "=" << x << "\n";
#define deb2(x, y) cerr << "\n"                   \
                        << #x << "=" << x << "\n" \
                        << #y << "=" << y << "\n";
#define w(x) \
  int x;     \
  cin >> x;  \
  while (x--)

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

  int n;
  long double m;
  cin >> n >> m;

  long double ans = n * m;

  int a = ans;
  cout << a;

  return 0;
}

Measured memory_bytes: 3724
from collections import deque
n,m=map(int,input().split())
G=[[] for i in range(n+1)]# 隣接リスト

for i in range(m):# 隣接リストを格納
    a,b=map(int,input().split())
    templ=G[a]
    templ.append(b)
    G[a]=templ
    templ=G[b]
    templ.append(a)
    G[b]=templ


dist=[-1 for i in range(n+1)]
prev=[-1 for i in range(n+1)]
q=deque([1])
dist[1]=0

while len(q)!=0:
    v=q.popleft()
    for nv in G[v]:
        if dist[nv]!=-1:
            continue
        dist[nv]=dist[v]+1
        prev[nv]=v
        q.append(nv)
print('Yes')
for i in range(2,n+1):
    print(prev[i])



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

int main(){
	int n,A[40];
	queue<int> Q;
	A[0]=1;
	cin>>n;
	while(n !=0){
		for(int i=1;i<n+1;++i){
			A[i]=A[i-1];
			if(i>1){
				A[i]+=A[i-2];
			}
			if(i>2){
				A[i]+=A[i-3];
			}
		}
		A[n]=1+(A[n]-1)/3650;
		Q.push(A[n]);
		cin>>n;
	}
	while(Q.empty()==0){
		cout<<Q.front()<<endl;
		Q.pop();
	}
}

Measured memory_bytes: 1200
#include <stdio.h>

inline static int read_int() {
    int x = 0, k;
    while ((k = getchar_unlocked() - '0') >= 0) {
        x = x * 10 + k;
    }
    return x;
}

inline static void put_int(int x) {
    int s = 0;
    char f[4];
    while (x) {
        f[s++] = x % 10;
        x /= 10;
    }

    while (s--) putchar_unlocked(f[s] + '0');
    putchar_unlocked('\n');
}

int highest[2000], streak[2000];

#pragma GCC optimize ("O3")
int main() {
    int h = read_int(), w = read_int(), max = 0, height, width, lastWall, i, res;
    short len;

    for (height = 0; height < h; height++) {
        lastWall = -1;

        for (width = 0; width < w; width++) {
            if (getchar_unlocked() != '.') {
                if (lastWall != width - 1) {
                    len = width - lastWall - 1;
                    for (i = lastWall + 1; i < width; i++) if (len > highest[i]) highest[i] = len;
                }

                res = highest[width] + streak[width];
                if (res > max) max = res;

                highest[width] = streak[width] = 0;
                lastWall = width;
            } else streak[width]++;
        }

        getchar_unlocked();

        if (lastWall != width - 1) {
            len = width - lastWall - 1;
            for (i = lastWall + 1; i < width; i++) if (len > highest[i]) highest[i] = len;
        }
    }

    for (width = 0; width < w; width++) {
        if (streak[width] != 0) {
            res = highest[width] + streak[width];
            if (res > max) max = res;
        }
    }

    put_int(max - 1);
}


Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    int x = 0;
    for(int i=0; i<3; ++i){
        int a;
        cin >> a;
        x *= 10;
        x += a;
    }

    if(x % 4 == 0)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 764
from math import gcd
from functools import reduce
from collections import Counter


class Osa_k:
    def __init__(self, maximum):
        self.table = [-1] * (maximum+1)
        for i in range(2, maximum+1):
            for j in range(2, int(i**0.5)+1):
                if i%j == 0:
                    self.table[i] = j
                    break

    def factorize(self, n):
        res = Counter()
        b = n
        while 1:
            if self.table[b] == -1:
                break
            res[self.table[b]] += 1
            b //= self.table[b]
        res[b] += 1
        return res


N = int(input())
*A, = map(int, input().split())
def f():
    cnt = Counter()
    ins = Osa_k(max(A))
    for i in A:
        res = ins.factorize(i) if i!=1 else {}
        for j in res.keys():
            cnt[j] += 1
            if cnt[j] >= 2:
                return False
    return True

cond1 = f()
cond2 = (reduce(gcd, A)==1)

if cond1:
    print("pairwise coprime")
elif cond2:
    print("setwise coprime")
else:
    print("not coprime")


Measured memory_bytes: 231340
#include <bits/stdc++.h>
using namespace std;
using lint = int64_t;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define all(v)    begin(v), end(v)
#define in        []{lint n; cin>>n; return n;}()

int main(){ cin.tie(0); ios::sync_with_stdio(false);
    int H = in, W = in, D = in;
    vector<pair<int,int>> A( H*W+1 );
    rep( y, H ) rep( x, W ) {
        int num = in;
        A[num] = pair<int,int>( y, x );
    }

    vector<int> B( H*W+1, 0 );
    for( int i=D+1; i<=H*W; i++ ) {
        B[i] = B[i-D];
        B[i] += abs( A[i-D].first  - A[i].first  );
        B[i] += abs( A[i-D].second - A[i].second );
    }

    int Q = in;
    rep( _, Q ) {
        int L = in, R = in;
        cout << B[R] - B[L] << "\n";
    }
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1100;
int n;
char st[N];
inline int read()
{
	int x=0,ff=1;
	char ch=getchar();
	while(!isdigit(ch)) {if(ch=='-') ff=-1;ch=getchar();}
	while(isdigit(ch)) {x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
	return x*ff;
}
inline bool check(int l,int r)
{
	int len=r-l+1;
	int o=r;
	for(int i=l;i<l+len/2;++i) if(st[i]!=st[o--]) return false;
	return true;
}
int main()
{
	//freopen("1.in","r",stdin);
	scanf("%s",st+1);
	n=strlen(st+1);
	if(check(1,n)&&check(1,(n-1)/2)&&check((n+3)/2,n)) puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define mp make_pair
using namespace std;

using ll = long long;
using ii = pair<int, int>;
const int INF = (int)10e9;
int N, W;
ll dp[105][100005];

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> N >> W;
    vector<int> w(N), v(N);
    for(int i = 0; i < N; i++) {
        cin>>w[i]>>v[i];
    }

    for(int i = 0; i < N; i++) {
        for(int j = 0; j <= W; j++) {
            if(i == 0) { if(j >= w[i]) dp[i][j] = v[i];}
            else if(j - w[i] >= 0) dp[i][j] = max(v[i] + dp[i-1][j-w[i]], dp[i-1][j]);
            else dp[i][j] = dp[i-1][j];
        }
    }

    cout<<dp[N-1][W]<<endl;

    return 0;
}

Measured memory_bytes: 81720
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//BEGIN CUT HERE
struct QuickFind{
  int n;
  vector<int> r,p;
  vector<vector<int> > v;
  QuickFind(){}
  QuickFind(int sz):n(sz),r(sz),p(sz),v(sz){
    for(int i=0;i<n;i++){
      r[i]=1,p[i]=i;
      v[i].resize(1,i);
    }
  }
  bool same(int x,int y){
    return p[x]==p[y];
  }
  void unite(int x,int y){
    x=p[x];y=p[y];
    if(x==y) return;
    if(r[x]<r[y]) swap(x,y);
    r[x]+=r[y];
    for(int i=0;i<(int)v[y].size();i++){
      p[v[y][i]]=x;
      v[x].push_back(v[y][i]);
    }
    v[y].clear();
  }
};
//END CUT HERE

signed main(){
  int n,q;
  cin>>n>>q;
  QuickFind qf(n);
  for(int i=0;i<q;i++){
    int c,x,y;
    cin>>c>>x>>y;
    if(c) cout<<qf.same(x,y)<<endl;
    else qf.unite(x,y);
  }
  return 0;
}
/*
verified on 2017/10/29
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_1_A&lang=jp
*/

Measured memory_bytes: 3752
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <iterator>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <random>
#include <cassert>
#include <limits>

using namespace std;

#define mp make_pair
#define pb push_back
#define repi(i, p, q) for (long i = p; i < q; i++)
#define repd(i, p, q) for (long i = p; i >= q; i--)
#define sz(x) x.size()
#define INF 2000000000
#define MOD 1000000007

typedef map<int, int> MI;
typedef pair<int, int> PI;
typedef long long int LLI;
typedef long int LI;
typedef int I;

int main()
{
    int n;
    cin >> n;
    for(int i = n ; i <= 999 ; i++){
        int flag = 0;
        int num = i;
        int first = num%10;
        while(num!=0){
            if(num%10 != first) {
                flag = 1;
            }
            num = num/10;
        }
        if(flag == 0) {
            cout << i;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main(void){
    int k, n;
    cin >> k >> n;
    VI a(n);
    REP(i,n) a[i] = in();
    int ans = a[n - 1] - a[0];
    REP(i,n-1){
        chmin(ans, k - (a[i + 1] - a[i]));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
n = int(input())
w = [input() for _ in range(n)]
import sys
li = [w[0]]
for i in range(n-1):
    if w[i+1][0]!=w[i][-1]:
        break
    if w[i+1] in li:
        break
    else:
        li.append(w[i+1])
else:
    print("Yes")
    sys.exit()
print("No")

Measured memory_bytes: 9132
n,k = list(map(lambda x:int(x),input().split()))
s = input()
if len(s) == 1:
    print(0)
    exit(0)
prev = ''
ans = ''
count = -1
flag = True
for i in range(len(s)):
    if s[i] != prev:
        count += 1
        prev = s[i]
        if count %2 == 1:
            k -= 1
            if k < 0:
                flag = False
                
    if count%2 == 1 and flag:
        if s[i] == 'L':
            ans += 'R'
        else:
            ans += 'L'
    else:
        ans += s[i]

count = 0
for i in range(1,len(ans)-1):
    if ans[i] == 'L' and ans[i-1] == 'L':
        count += 1
    elif ans[i] == 'R' and ans[i+1] == 'R':
        count += 1
if ans[0] == 'R' and ans[1] == 'R':
    count += 1
if ans[-1] == 'L' and ans[-2] == 'L':
    count += 1
print(count)

Measured memory_bytes: 3316
#![allow(unused_imports)]
#![allow(unused_variables)]

use itertools::Itertools;
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize, d: usize,
        xy: [(f64, f64); n],
    }
    // annotate for rust-analyzer
    let n: usize = n;
    let d: usize = d;
    let xy: Vec<(f64, f64)> = xy;

    let mut ans = 0;
    for (x, y) in xy {
        if (x.powi(2) + y.powi(2)).sqrt() <= d as f64 {
            ans += 1;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 7860
// #pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

using vii = vector<int>;

int main() {
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    // freopen("in.in", "r", stdin);

    int n;
    cin >> n;

    const int MAX = 1 << n, MOD = 1e9 + 7;
    
    auto cnt = [](int x) {
        short res = 0;
        while (x) res += x & 1, x >>= 1;
        return res;
    };
    
    vii v[n + 1];
    for (int i = 0; i < MAX; i++) {
        v[cnt(i)].push_back(i);
    }

    vii adj[n];
    for (short i = 0, j, b; i < n; i++) {
        for (j = 0; j < n; j++) {
            cin >> b;
            if (b) adj[i].emplace_back(1 << j);
        }
    }
    vii dp(MAX);
    dp[0] = 1;
    for (short i = 0; i < n; i++) {
        for (int j : v[i]) {
            for (int b : adj[i]) {
                if (j & b) continue;
                dp[j | b] = (dp[j | b] + dp[j]) % MOD;
            }
        }
    }

    cout << dp[MAX - 1] << '\n';
}

Measured memory_bytes: 17852
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {

      
 public static void main(String[] args) {
    
    Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
    int N = in.nextInt();
    in.nextLine();
    String S = in.nextLine();
    
    long R = 0, G= 0, B = 0;
    long total = 0;
    int sum = 0;
    
    for(int i = 0; i < N; i++) {
        if(S.charAt(i) == 'R') R++;
        else if(S.charAt(i) == 'G') G++;
        else B++;
    }
    
    total = R*G*B;
    
    for(int i = 0; i < N; i++) {
        for(int j = i+1; j < N; j++) {
            int k = 2*j - i;
            
            if(k < N &&  S.charAt(k) != S.charAt(i) && S.charAt(i) != S.charAt(j) && S.charAt(k) != S.charAt(j)) {
                total--;
            }
        }
    }
    
    System.out.println(total);
  }
  
}

Measured memory_bytes: 37232
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i = 0; i< (n);i++)
#define SORT(a) sort((a).begin(),(a).end());
#define che(a,string) cout<<string<<":"<<(a)<<endl;
#define ch(a,string) cout<<string<<":"<<(a)<<" ";
using namespace std;
typedef pair<int,int> p;
#define INF 2000000000
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
long long a[100010][3];  //ai,bi,ciをそれぞれ、a[i][0],a[i][1],a[i][2]に格納

//DP テーブル
long long	dp[100010][3];//一個前にaを選んだ時のi番目の幸福度の最大値をdp[i][0] 

	int main(){
//入力
int n;
 		cin>>n;
		for(int i = 0; i < n ; ++i){
			for(int j = 0 ; j<3 ;++j){
				cin>>a[i][j];
			}
		}
		for(int i = 0 ; i<n ; ++i){
			for(int j=0; j<3 ; ++j){	
				for (int k =0; k<3; ++k){
					if(j!=k){
						chmax(dp[i+1][k], dp[i][j]+ a[i][k]);
					}
				}
			}
		}

		//答え
		long long ans = 0 ;
		for(int j = 0; j < 3; ++j){
			chmax(ans, dp[n][j]);
		}
		cout<<ans<<endl;
	}



Measured memory_bytes: 4992
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
int A[100011];

void MAIN() {
    scanf("%d", &N);
    REP (i, N) scanf("%d", A+i);
    sort(A, A+N);
    
    int best = A[0];
    REP (i, N-1) {
	int cur = min(best, A[N-1]-best);
	int guess = min(A[i], A[N-1]-A[i]);
	if (cur < guess) best = A[i];
    }

    printf("%d %d\n", A[N-1], best);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string.h>
#include <algorithm>
#include <cstring>
#include <queue>
#include <assert.h>
#include <cmath>
#include <deque>
using namespace std;
using ll = long long;
using ld = long double;
const ll mxn = 200010;
const ll inf = 1e6+5;
ll h[mxn], dp[mxn];

struct Line
{
	ll a, b;
	ld left, right;
	ld operator* (const Line l) const {
		ld ret = ((ld) (b-l.b))/((ld) (l.a-a));
		return ret;
	}
	ll eval(ll x) {
		return a*x+b;
	}
};

deque<Line> dq;

void add(ll a, ll b) {
	Line new_line;
	new_line.a = a;
	new_line.b = b;
	if(dq.empty()) {
		new_line.left = (ld) -inf;
		new_line.right = (ld) inf;
		dq.push_back(new_line);
		return;
	}
	ld intersection = new_line*dq.back();
	while(intersection<=dq.back().left) {
		dq.pop_back();
		intersection = new_line*dq.back();
	}
	dq.back().right = intersection;
	new_line.left = intersection;
	new_line.right = inf;
	dq.push_back(new_line);
}

ll min_val(ll x) {
	ld new_x = (ld) x;
	while(new_x>=dq.front().right) {
		dq.pop_front();
		dq.front().left = (ld) -inf;
	}
	return dq.front().eval(x);
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll N, C;
	cin>>N>>C;

	for(ll i=1; i<=N; i++) cin>>h[i];

	dp[1] = 0ll;
	add(-2ll*h[1], h[1]*h[1]);
	for(ll i=2; i<=N; i++) {
		dp[i] = min_val(h[i])+C+h[i]*h[i];
		add(-2ll*h[i], h[i]*h[i]+dp[i]);
	}

	cout << dp[N] << '\n';

	return 0;
}

Measured memory_bytes: 10112
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main(){
  int n;
  cin >>n;
  int a;
  double cnt=0;
  rep(i,n){
    cin >> a;
    if(a%4==0){
      cnt++;
    }
    else if(a%2==0){
      cnt+=0.5;
    }
  }
  if((n/2)<=cnt){
    cout << "Yes" <<endl;
    return 0;
  }
  cout << "No" <<endl;
  return 0;
}

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a, b) accumulate(all(a), b)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
typedef unsigned long long ull;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
ll const INF = 1e18;

template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}

//Union-Find Tree
class UnionFind{
public:
    int N;              //頂点数
    vector<int> par;    //par[i]:iの親の番号
    vector<int> size;   //size[i]:iが属するグループと同じグループに属する頂点数

    UnionFind(int n) : N(n), par(n), size(n, 1){  //初期化時はすべて根とする
        for(int i=0; i<n; i++){
            par.at(i) = i;
        }
    }

    int root(int x){    //データxが属する木の根を再帰で得る
        if(par.at(x) == x){
            return x;
        }else{
            return par.at(x) = root(par.at(x)); //経路圧縮を同時に実行
        }
    }

    void unite(int x, int y){   //xの属する木とyの属する木を併合
        int rx = root(x), ry = root(y);
        if(rx != ry){   //xとyの属する木が異なるとき
            par.at(rx) = ry;    //xの木の根をyの根につける
            size.at(ry) += size.at(rx);   //sizeを更新
        }
    }

    int getSize(int x){         //xの属する木のサイズを返す
        return size.at(x) = size.at(root(x));
    }

    bool same(int x, int y){    //x,yが同じ木に属するときtrue, そうでなければfalse
        return root(x) == root(y);
    }
};

signed main(){
    int n, m;
    cin >> n >> m;
    UnionFind UF(n);
    REP(i, m){
        int a, b, c;
        cin >> a >> b >> c;
        UF.unite(a-1, b-1);
    }
    vector<int> v(n, 0);
    REP(i, n){
        v[UF.root(i)]++;
    }
    int ans = 0;
    REP(i, n){
        if(v[i] > 0) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
# coding:utf-8

import sys


input = sys.stdin.readline
INF = float('inf')


def inpl(): return list(map(int, input().split()))


# 整数(x, y)最大公約数を求める
def gcd(x, y):
    if x % y == 0:
        return y
    else:
        x, y = y, x % y
        return gcd(x, y)


def lcm(x, y):
    return x * y // gcd(x, y)


N, M = inpl()
S = input()
T = input()

L = lcm(N, M)
LCM = lcm(L//N, L//M)
# print(L, LCM)

ss = L // N
cnt = 0
tmp = 0
S_li = [S[0]]
while tmp <= L:
    tmp = ss * cnt + 1
    if tmp % LCM == 1:
        S_li.append(S[cnt])
    cnt += 1

tt = L // M
cnt = 0
tmp = 0
T_li = [T[0]]
while tmp < L:
    tmp = tt * cnt + 1
    if tmp % LCM == 1:
        T_li.append(T[cnt])
    cnt += 1

# print(S_li)
# print(T_li)
if S_li == T_li:
    print(L)
else:
    print(-1)




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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	int a,b,c;
	cin >> a >> b >> c;
	int ans = b / a;
	ans = min(ans, c);
	ANS(ans);
	return 0;
}


Measured memory_bytes: 256
//Subhash Suman
//Date: 13/02/19 ; Day: Wednesday ; Time: 12::49::32 
//Description : 

#include<bits/stdc++.h>
#define ll long long int
#define MAX INT_MAX
#define MIN INT_MIN
#define vi vector<int>
#define pii pair<int,int>
#define mii map<int,int>

using namespace std;
const int N = 3005;
double arr[N];

double dp[N][N];

int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
    int n;
    cin>>n;
    std::cout << std::setprecision(10);
    std::cout << std::fixed;
    for(int i = 1; i <= n; i++){
        cin>>arr[i];
    }
    dp[0][0] = 1.0;
    for(int i = 1; i <= n; i++){
        dp[i][0] = dp[i-1][0]*(1-arr[i]);
        for(int j = 1; j <= n; j++){
            if(j>i){
                dp[i][j] = 0;
            }
            dp[i][j] = dp[i-1][j]*(1.0-arr[i]) + arr[i]*dp[i-1][j-1];
        }
    }
    double ans = 0.0;
    
    for(int i = n/2 + 1; i <= n; i++){
        ans += dp[n][i];
    }
    cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
int main(){

    int i,n=0,w=0,s=0,e=0;
    string S;

    cin >> S;
    for(i = 0; i < sizeof(S); i++){
        if(S[i] == 'N'){
            n++;
        }else if(S[i] == 'W'){
            w++;
        }else if(S[i] == 'S'){
            s++;
        }else if(S[i] == 'E'){
            e++;
        }
    }

    if(((n > 0 && s > 0) || (n == s)) && ((e > 0 && w > 0) || (e == w))){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


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

const int MAX = 5100;
int mod = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % mod;
    inv[i] = mod - inv[mod%i] * (mod / i) % mod;
    finv[i] = finv[i - 1] * inv[i] % mod;
  }
}

ll com(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

int main() {
  int n;
  cin >> n;
  COMinit();
  ll ans = 0;
  for (int i = 1; 3*i <= n; ++i) {
    ans += com(n-2*i-1, n-3*i);
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3736
#include <iostream>
int main(int argc, char *argv[])
{
    using namespace std;
    std::ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, a;
    cin >> n >> a;
    cout << (a >= n % 500 ? "Yes\n" : "No\n");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
 
int main()
{
  int i,j,k;
  std::cin >> i >> j >> k;  
  
  if((i -j) == (j-k))
  {
  	std::cout << "YES" <<std::endl;
  }
  else
  {
  	std::cout << "NO" <<std::endl;
  
  }
  return 0;
 
}

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

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

  int cnt = 0;
  for(int i=0;i<N-2;i++){
      if((S.at(i) == 'A') && (S.at(i+1) == 'B') && (S.at(i+2) == 'C')){
          cnt++;
      }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int qnt_turn(int v, int d) {
 return (v / d) + (v % d > 0 ? 1 : 0); 
}
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int ao = qnt_turn(a, d);
  int ta = qnt_turn(c, b);
  // cout << ta << " " << ao << endl;
  cout << (ta <= ao ? "Yes" : "No") << endl;
}


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

using namespace std;
typedef long long ll;
ll mod = 1e9 + 7;

int main(void)
{
    ll N,W;cin>>N>>W;
    vector<ll> Wn(W+1,0);
    for(int i=0;i<N;i++){
        vector<ll> WnOld = Wn;
        ll v,w;cin>>v>>w;
        for(int j=0;j<=W;j++){
            if(j<w)Wn[j]=WnOld[j];
            else Wn[j] = max(WnOld[j],WnOld[j-w]+v);
        }
    }
    cout << Wn[W] << endl;
}


Measured memory_bytes: 3276
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
#pragma optimize("JARU SOSISONI")

using namespace std;

#define int long long
#define fast cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#define geometry cout.setf(ios::fixed); cout.precision(15);
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;

const int INF = 1e9 + 100;
const int MOD = 998244353;
const int MOD1 = 1e9 + 7;
const int N = 52;
const int nul = 0;
const int SIZE = 1e6 * 3;

int n, x;

int sub(int i, int k) {
    if (i - k >= 0) return i - k;
    else return i - k + n;
}

vector<vector<int> > dp;
vector<int> a;

int check(int k) {
    for (int i = 0; i < n; i++) {
        dp[i][k] = min(dp[i][k - 1], a[sub(i, k)]);
    }
    int ans = 0;
    for (int i = 0; i < n; i++) ans += dp[i][k];
    return ans;
}

signed main() {
#ifdef parasha
    freopen("A.in", "r", stdin);
#endif // parasha
    fast;
    cin >> n >> x;
    a.resize(n);
    dp.resize(n, vector<int>(n, INF));
    for (int &i : a) cin >> i;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        dp[i][0] = a[i];
        ans += a[i];
    }
    for (int k = 1; k < n; k++) {
        ans = min(ans, k * x + check(k));
    }
    cout << ans << endl;

}


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

class UnionFind {
 private:
  unsigned size_;
  std::vector<unsigned> par, rank;

 public:
  UnionFind()
      : size_(0), par(std::vector<unsigned>()), rank(std::vector<unsigned>()){};
  UnionFind(unsigned size__) : size_(size__) {
    par.resize(size_);
    rank.resize(size_);
    for (unsigned i = 0; i < size_; i++) par[i] = i, rank[i] = 0;
  }
  unsigned size() { return size_; }
  unsigned root(unsigned x) { return par[x] == x ? x : par[x] = root(par[x]); }
  bool same(unsigned x, unsigned y) { return root(x) == root(y); }
  void unite(unsigned x, unsigned y) {
    x = root(x), y = root(y);
    if (x == y) return;
    if (rank[x] < rank[y])
      par[x] = y;
    else if (rank[x] == rank[y])
      par[y] = x, rank[x]++;
    else
      par[y] = x;
  }
  bool operator==(const UnionFind &u) { return par == u.par; }
  bool operator!=(const UnionFind &u) { return par != u.par; }
};

int N, K, L, p, q;
int main() {
  cin >> N >> K >> L;
  UnionFind uf1(N), uf2(N);
  for (int i = 0; i < K; i++) {
    cin >> p >> q;
    p--, q--;
    uf1.unite(p, q);
  }
  for (int i = 0; i < L; i++) {
    cin >> p >> q;
    p--, q--;
    uf2.unite(p, q);
  }
  map<pair<int, int>, int> cnt;
  for (int i = 0; i < N; i++) {
    cnt[make_pair(uf1.root(i), uf2.root(i))]++;
  }
  for (int i = 0; i < N; i++) {
    cout << cnt[make_pair(uf1.root(i), uf2.root(i))];
    if (i == N - 1) {
      cout << endl;
    } else {
      cout << " ";
    }
  }
  return 0;
}


Measured memory_bytes: 15104
//Created by Aminul on 9/13/2020.

import java.io.*;
import java.util.*;

import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int n = in.nextInt();
        long mod = (long) 1e9 + 7;
        pw.println(solve(n, mod));

        pw.close();
    }

    static long solve(long n, long mod) {
        if (n < 2) return 0;
        long res = bigMod(10, n, mod);
        res -= 2* bigMod(9, n, mod);
        res = (res % mod + mod) % mod;
        res += bigMod(8, n, mod);
        res %= mod;
        return res;
    }

    static long bigMod(long a, long p, long m) { // returns (a^p) % m
        long res = 1 % m, x = a % m;
        while (p > 0) {
            if ((p & 1) > 0) res = (res * x) % m;
            x = (x * x) % m;
            p >>= 1;
        }
        return res;
    }

    static void debug(Object... obj) {
        System.err.println(Arrays.deepToString(obj));
    }
}

Measured memory_bytes: 35764
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			long a = cin.Long();
			long b = cin.Long();
			if ((a - b) % 2 == 0) {
				Console.WriteLine((a + b) / 2);
			} else {
				Console.WriteLine("IMPOSSIBLE");
			}
		}
	}

	public class Scanner
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private string[] buf_;
		private int index_;
		
		public Scanner()
		{
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = Console.ReadLine();
			while (st == "") {
				st = Console.ReadLine();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int()
		{
			return int.Parse(Next());
		}
		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long Long()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double Double()
		{
			return double.Parse(Next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}


Measured memory_bytes: 11220
n = int(input())
a = list(map(lambda x: int(x), input().split(' ')))

m = {}

count = 0

for i, v in enumerate(a):
  p = i + v

  if not p in m:
    m[p] = 1
  else:
    m[p] += 1

for i, v in enumerate(a):
  p = i - v

  if p in m:
    count += m[p]

print(count)

Measured memory_bytes: 40340
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let ab:Vec<u32> = read_vec::<u32>();
    if ab[0] < ab[1] {
        println!("0");
    } else {
        println!("10");
    }
}

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

int main(){
	string str;
	string moto;
	int size,Msize;
	cin >> str;
	size=str.size();
	cin >> moto;
	Msize=moto.size();
	for(int i=0;i<size;i++){
		if(moto[0]==str[i]){
			for(int j=1;j<Msize;j++){
				if(moto[j]!=str[(i+j)%size]) goto LOOP;
			}
			cout << "Yes" <<endl;
			return 0;
		}
		LOOP:;
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 1184
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <cmath>
#include <limits>
#include <tuple>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;

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

int main()
{
	int N;
	cin >> N;
	string S;
	cin >> S;
	int ans = 0;
	rep(i, N) {
		set<char> a, b;
		for (int j=0; j<i; j++) {
			a.insert(S[j]);
		}
		for (int j = i; j<N; j++) {
			b.insert(S[j]);
		}
		set<char> result;

		// aとbの積集合を作る
		std::set_intersection(a.begin(), a.end(), b.begin(), b.end(),
			std::inserter(result, result.end()));
		ans = max(ans, (int)result.size());
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> P;
#define rep(i,s,e) for(int i = (s);i <= (e);i++)

int n;
i64 t[101010];
i64 a[101010];

int main()
{
    cin >> n;
    rep(i,1,n) cin >> t[i];
    rep(i,1,n) cin >> a[i];

    if(t[n] != a[1])
    {
        cout << 0 << endl;
        return 0;
    }

    vector<i64> MAX(n + 1,1e18);
    bitset<101010> bit;

    rep(i,1,n)
    {
        MAX[i] = t[i];
        if(t[i - 1] != t[i])
        {
            bit[i] = true;
        }
        else
        {
        }
    }

    for(int i= n;i >= 1;i--)
    {
        if(bit[i] && a[i] < t[i])
        {
            cout << 0 << endl;
            return 0;
        }
        MAX[i] = min(MAX[i],a[i]);
        if(a[i + 1] != a[i])
        {

            bit[i] = true;
        }
        else
        {
        }
    }

    i64 result = 1;
    i64 MOD = 1e9 + 7;
    rep(i,1,n)
    {
        if(!bit[i])
            result = (result * MAX[i]) % MOD;
    }

    cout << result << endl;
    

}

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

#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

//#define int long long
using namespace std;
const int INF = 2e9;
const int MOD = 1e9 + 7;
const int MB = 60;
const int X = 80 * 80;
const int lim = 2 * 80 * 80 + 2;
bool dp[81][81][lim];

void solve() {
	int n, m;
	cin >> n >> m;
	vector<vector<int>> a(n + 1, vector<int>(m + 1));
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			cin >> a[i][j];
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			int x;
			cin >> x;
			a[i][j] -= x;
		}
	}

	dp[0][1][X] = dp[1][0][X] = true;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			for (int c = 0; c < lim; c++) {
				if (c + a[i][j] >= 0 && c + a[i][j] < lim) dp[i][j][c] |= dp[i - 1][j][c + a[i][j]] | dp[i][j - 1][c + a[i][j]];
				if (c - a[i][j] >= 0 && c - a[i][j] < lim) dp[i][j][c] |= dp[i - 1][j][c - a[i][j]] | dp[i][j - 1][c - a[i][j]];
			}
		}
	}

	int ans = INF;
	for (int i = 0; i < lim; i++) {
		if (dp[n][m][i]) ans = min(ans, abs(X - i));
	}
	cout << ans;
}

signed main() {
	/*
	freopen("search.in", "r", stdin);
	freopen("search.out", "w", stdout);
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout << fixed;
	cout.precision(12);
	solve();
}


Measured memory_bytes: 81280
# include <iostream>
# include <vector>
# include <algorithm>
# include <cmath>

using namespace std;
void The_longest_distance()
{
	int N = 0;
	cin >> N;
	vector<pair<double, double>> points;
	for (int i = 0; i < N; ++i)
	{
		int x, y;
		cin >> x >> y;
		points.emplace_back(make_pair(x, y));
	}
	double maxLen = std::numeric_limits<double>::lowest();
	for (int i = 0; i < N; ++i)
	{
		for (int j = i + 1; j < N; ++j)
		{
			auto len = (points[i].first - points[j].first) * (points[i].first - points[j].first) +
				(points[i].second - points[j].second) * (points[i].second - points[j].second);
			maxLen = std::max(maxLen, len);
		}
	}
	cout << sqrt(maxLen);
}
void Sum_of_Three_Integers()
{
	int K = 0;
	int S = 0;
	cin >> K >> S;
	int cnt = 0;
	for (int x = 0; x <= K; ++x)
	{
		for (int y = 0; y <= K; ++y)
		{
			int z = S - x - y;
			if (0 <= z && z <= K)
			{
				++cnt;
			}
		}
		if (x > S)
		{
			break;
		}
	}
	cout << cnt;
}
int main()
{
	int N = 0;
	int Y = 0;
	cin >> N >> Y;
	Y /= 1000;
	int tenThousand = 10;
	int thousand = 1;
	int fiveThousand = 5;
	for (int i = 0;; ++i)
	{
		for (int j = 0;; ++j)
		{
			int numThousand = Y - tenThousand * i - fiveThousand * j;
			if (numThousand >= 0 && numThousand + i + j == N)
			{
				cout << i << ' ' << j << ' ' << numThousand;
				return 0;
			}
			if (numThousand < 0)
			{
				break;
			}
		}
		if (i > Y)
		{
			cout << -1 << ' ' << -1 << ' ' << -1;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
import sys

H, W = map(int, input().split())
a = [line for line in sys.stdin.readlines()]

row = [False] * H
column = [False] * W

for i, temp_row in enumerate(a):
    for j, c in enumerate(temp_row):
        if c == "#":
            row[i] = True
            column[j] = True

for i, exist_row in enumerate(row):
    if not exist_row:
        continue
    for j, exist_column in enumerate(column):
        if exist_column:
            print(a[i][j], end = "")
    print()


Measured memory_bytes: 4468
#include<iostream>
int main()
{
	int v1, v2, v3, v4, v5;
	std::cin >> v1 >> v2 >> v3 >> v4 >> v5;
	if ( v5 <= v3 && v5 <= v4 && v3 + v5 <= v1 && v4 + v5 <= v2 )
	{
		std::cout << "Yes" << std::endl;
	}
	else
	{
		std::cout << "No" << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3100
import math

n = int(input())
n_check = n
num = []
for i in range(int(math.log10(n)+1)+1):
    num.append(n % 10)
    n /= 10
    n -= num[i]/10
if n_check%int(sum(num)) == 0:
    ans = 'Yes'
else:
    ans = 'No'
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using lint=long long;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    std::string s;std::cin>>s;
    std::string t=std::string(s.rbegin(),s.rend());
    lint n=(s.length()-1)/2;
    std::cout<<(s==t&&s.substr(0,n)==t.substr(n+1,2*n+1)?"Yes":"No")<<'\n';
}


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

int main()
{
  int N,M,C[16],x[20002];
  long long DP[2][256];
  long long mi,a,b,y,ans;

  while(1){
    cin>>N>>M;
    if(N==0 && M==0)break;
    for(int i=0;i<M;i++)cin>>C[i];
    for(int i=1;i<N+1;i++)cin>>x[i];
    for(int i=0;i<256;i++)DP[0][i]=1000000000;
    DP[0][128]=0;
    for(int i=1;i<N+1;i++){
      for(int j=0;j<256;j++)DP[i%2][j]=1000000000;
      for(int j=0;j<256;j++){
	if(DP[(i-1)%2][j]!=1000000000){
	  for(int k=0;k<M;k++){
	    a=j+C[k];
	    if(a<0)a=0;
	    if(a>255)a=255;
	    b=DP[(i-1)%2][j]+(a-x[i])*(a-x[i]);
	    DP[i%2][a]=min(DP[i%2][a],b);
	  }
	}
      }
    }
    ans=1000000000;
    for(int i=0;i<256;i++)ans=min(ans,DP[N%2][i]);
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1236
#include <stdio.h>
#include <math.h>

#define M_PI 3.141592653589793

int main(){
    int A, B, H, M;
    scanf("%d %d %d %d", &A, &B, &H, &M);

    double x_A, x_B, y_A, y_B;
    x_A = -(double)A*sin(((double)H/12.0 + (double)M/(12.0*60.0))*2.0*M_PI);
    y_A = (double)A*cos(((double)H/12.0 + (double)M/(12.0*60.0))*2.0*M_PI);


    x_B = -(double)B*sin((double)M/60.0*2.0*M_PI);
    y_B = (double)B*cos((double)M/60.0*2.0*M_PI);

    #ifdef _DEBUG
    printf("%lf\n", ((double)H/12.0 + (double)M/(12.0*60.0)));
    printf("%lf\n", ((double)M/60.0));
    printf("%lf  %lf\n", x_A, y_A);
    printf("%lf  %lf\n", x_B, y_B);
    #endif

    printf("%.16f", sqrt((x_A - x_B)*(x_A - x_B) + (y_A - y_B)*(y_A - y_B)));
}

Measured memory_bytes: 2476
#include <stdio.h>
int main(){
	int i,cnt;
	while(1){
		scanf("%d\n",&i);
		if(!i)break;
		cnt=0;
		i=1000-i;
		if(i/500){cnt+=1;i-=500;}
		if(i/100){cnt+=i/100;i-=100*(i/100);}
		if(i/50){cnt+=1;i-=50;}
		if(i/10){cnt+=i/10;i-=10*(i/10);}
		if(i/5){cnt+=1;i-=5;}
		if(i/1){cnt+=i/1;i-=1*(i/1);}
		printf("%d\n",cnt);
	}
	return 0;
}

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

#define LL long long

int main(){

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

	int n;
	cin>>n;

	vector<LL> l,r;
	for(int i=0;i<n;i++){
		int x,y;cin>>x>>y;
		l.push_back(x);
		r.push_back(y);
	}
	sort(l.begin(),l.end());
	sort(r.begin(),r.end());

	LL ans = 0;
	LL curr=0;

	for(int i=0;i<n;i++){
		curr+=(2*l[n-i-1]);
		ans = max(ans,curr);
		if((2*i + 1)>=n){break;}
		curr-=(2*r[i]);
		ans = max(ans,curr);
	}

	curr=0;
	for(int i=0;i<n;i++){
		curr-=(2*r[i]);
		ans = max(ans,curr);
		if((2*i + 1)>=n){break;}
		curr+=(2*l[n-i-1]);
		ans = max(ans,curr);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 2036
import sys
import heapq, functools, collections
import math, random
from collections import Counter, defaultdict

# available on Google, not available on Codeforces
# import numpy as np
# import scipy


def solve(n,x,m):  # fix inputs here
    console("----- solving ------")
    if m == 1:
        return 0

    arr = [x]
    pos = {}

    for i in range(min(n-1, 2*m)):
        x = arr[-1]
        new = (x*x)%m
        if new in pos:
            break
        pos[new] = i           
        arr.append(new)

    sumarr = sum(arr)
    lenarr = len(arr)

    if len(arr) == n:
        console(arr)
        return sumarr

    m = len(arr) - pos[new] - 1

    cycles = (n-lenarr) // (m)
    remainder = (n-lenarr) % (m)

    console(m, cycles, remainder)
    sumarr += cycles*sum(arr[-m:])
    sumarr += sum(arr[-m:-m+remainder])

    console(492443256176507 - sumarr)
    # return a string (i.e. not a list or matrix)
    return sumarr 


def console(*args):  # the judge will not read these print statement
    # print('\033[36m', *args, '\033[0m', file=sys.stderr)
    return

# fast read all
# sys.stdin.readlines()

for case_num in [1]:
    # read line as a string
    # strr = input()

    # read line as an integer
    # k = int(input())
    
    # read one line and parse each word as a string
    # lst = input().split()

    # read one line and parse each word as an integer
    n,x,m = list(map(int,input().split()))

    # read matrix and parse as integers (after reading read nrows)
    # lst = list(map(int,input().split()))
    # nrows = lst[0]  # index containing information, please change
    # grid = []
    # for _ in range(nrows):
    #     grid.append(list(map(int,input().split())))

    res = solve(n,x,m)  # please change
    
    # Google - case number required
    # print("Case #{}: {}".format(case_num+1, res))

    # Codeforces - no case number required
    print(res)


Measured memory_bytes: 86308
import java.util.Scanner;
 
class Main {
        public static void main(String args[]) {
                Scanner sc = new Scanner(System.in);
                int a = 5000, b = 5000;
                for (int i = 0; i < 3; i++) {
                        a = Math.min(a, sc.nextInt());
                }
                for (int i = 0; i < 2; i++) {
                        b = Math.min(b, sc.nextInt());
                }
                System.out.println(a + b - 50);
 
 
        }
}


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

using namespace std;

int N, A, B, C, D, mod = 1e9 + 7, fac[2017], inv[2017], grp[1009][1009], dp[1009][1009];

int add (int x, int y) {int ans = x + y; if (ans >= mod) ans -= mod; return ans;}
int substract (int x, int y) {if (x >= y) return x - y; return x - y + mod;}
int mul (int x, int y) {return 1LL * x * y % mod;}

int pow (int a, int b)
{
    int p = 1;
    for (int i=0; (1<<i) <= b; i++)
    {
        if (b & (1 << i)) p = mul (p, a);
        a = mul (a, a);
    }
    return p;
}

void Prec (int lim){fac[0] = inv[0] = 1;for (int i=1; i<=lim; i++)fac[i] = mul (fac[i - 1], i);
inv[lim] = pow (fac[lim], mod - 2);for (int i=lim - 1; i>=1; i--)inv[i] = mul (inv[i + 1], i + 1);}
int comb (int N, int K){int ans = mul (fac[N], inv[N - K]);ans = mul (ans, inv[K]);return ans;}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d %d %d %d", &N, &A, &B, &C, &D), Prec (2001);
grp[0][0] = 1;
for (int i=1; i<=N; i++)
    for (int j=0; j<=N; j+=i)
    {
        if (j == 0) grp[i][0] = 1;
        else grp[i][j] = mul (grp[i][j - i], comb (j - 1, i - 1));
    }
dp[A - 1][0] = 1;
for (int i=A; i<=B; i++)
    for (int j=0; j<=N; j++)
    {
        dp[i][j] = dp[i - 1][j];
        for (int k=C; k<=D && k * i <= j; k++)
            dp[i][j] = add (dp[i][j], mul (dp[i - 1][j - k * i], mul (comb (N - j + k * i, k * i), grp[i][k * i])));
    }
printf ("%d\n", dp[B][N]);
return 0;
}


Measured memory_bytes: 8192