akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

constexpr int P = 1000000007;

//dp[i][j] i個を設置して最後がjのときの通り数
int dp[101][70000];

int main() {
    int n, k;
    cin >> n >> k;

    int m = (int)sqrt(n);
    int l = m * 2 - 1;
    //for (int j = 0; j < m; j++) {
    //    dp[0][j] = 1;
    //    int j0 = m - j;
    //    dp[0][m + j] = (n / j0 - n / (j0 + 1));
    //}
    dp[0][0] = 1;
    for (int i = 0; i < k; i++) {
        ll s = 0;
        for (int j = m - 1; j >= 0; j--) {
            s += dp[i][l - m - j];
            if (s >= P) s -= P;
            int j0 = m - j;
            int t = n / j0 - n / (j0 + 1);
            if (j == 0) {
                t = n / j0 - m;
                //cout << t << endl;
            }
            dp[i + 1][m + j] = (int)(s * t % P);
        }
        for (int j = m - 1; j >= 0; j--) {
            s += dp[i][l - j];
            if (s >= P) s -= P;
            dp[i + 1][j] = (int)s;
        }
    }

    ll r = 0;
    for (int j = 0; j < m; j++) {
        r += dp[k][j] + dp[k][m + j];
    }

    cout << r % P << endl;

    //積がN以下になる正整数の組は列挙できる　列挙はできねーわｗ
    //そういう組だけでできているわけだが
    //たとえばN=10^9でA_0=10のとき、A_1は10^8以下である必要がある
    //この○○以下であるという○○のパターンはけっこう少ない　これでDPする
    //5以下で何通りかN/5以上で何通りか

    return 0;
}

Measured memory_bytes: 27392
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
const int V = 100005;
ll dy[8] = {1,0,-1,0,1,-1,1,-1};
ll dx[8] = {0,1,0,-1,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
#define INT_MAX 1<<30
const int mod = 1e9+7;

int main(){
    ll h,w; cin >> h >> w;
    vvl a(h,vl(w)), b(h,vl(w)), c(h,vl(w));
    rep(i,h) rep(j,w) cin >> a[i][j];
    rep(i,h) rep(j,w) cin >> b[i][j];
    vector<vvl> v(h+1,(vvl(w+1,vl(13081,0))));
    v[1][0][0] = 1; v[0][1][0] = 1;
    rep(i,h){
        rep(j,w) c[i][j] = abs(a[i][j]-b[i][j]);
    }
    rep(i,h){
        rep(j,w){
            rep(k,13001){
                if(v[i+1][j][k]==1){
                    if(k-c[i][j]>=0) v[i+1][j+1][k-c[i][j]]=1;
                    else v[i+1][j+1][c[i][j]-k]=1;
                    v[i+1][j+1][k+c[i][j]]=1;
                }
                if(v[i][j+1][k]==1){
                    if(k-c[i][j]>=0) v[i+1][j+1][k-c[i][j]]=1;
                    else v[i+1][j+1][c[i][j]-k]=1;
                    v[i+1][j+1][k+c[i][j]]=1;
                }
            }
        }
    }
    rep(k,13001){
        if(v[h][w][k]==1){
            cout << k << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 679552
#include<bits/stdc++.h>
using namespace std;
int n,a[10010],s,i;
int main()
{
	cin>>n;
	for(i=1;i<=n;i++)
	cin>>a[i];
	i=1;
	while(i<=n)
	{
		if(a[i]%2==0)
		{
			s++;
			a[i]/=2;
		}
		else
		i++;
	}
	cout<<s;
	return 0;
}

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

const ll MAX_N = 110;
const ll MAX_W = 1000100;
ll N, W;
ll w[MAX_N];
ll v[MAX_N];

ll dp[MAX_N][MAX_W];

ll rec(ll i, ll j) {
  if (dp[i][j] != -1) return dp[i][j];
  ll res;
  if (i == N) res = 0;
  else if (j < w[i]) res = rec(i+1, j);
  else res = max(rec(i+1, j), rec(i+1, j-w[i]) + v[i]);
  return dp[i][j] = res;
}

int main() {
  cin >> N >> W;
  for (ll i = 0; i < N; i++) cin >> w[i] >> v[i];

  memset(dp, -1, sizeof(dp));
  cout << rec(0, W) << endl;
}

Measured memory_bytes: 859648
from decimal import *

getcontext().prec = 20      # デフォルト28桁のところを20桁にする

a, b, c = map(int, input().split())

A = Decimal(a).sqrt()
B = Decimal(b).sqrt()
C = Decimal(c).sqrt()
if A+B < C:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 5076
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,ans,sum;
vector<ll> extra;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin>>n;
    ll a[n],b[n];for(ll i=0;i<n;i++)cin>>a[i];
    for(ll i=0;i<n;i++){
        cin>>b[i];
        if(a[i]>=b[i])extra.push_back(a[i]-b[i]);
        else{
            sum+=(b[i]-a[i]);
            ans++;
        }
    }
    sort(extra.rbegin(),extra.rend());
    for(ll i=0;i<(ll)extra.size();i++)if(sum>0)sum-=extra[i],ans++;
    if(sum>0)return cout<<"-1" , 0;
    cout<<ans;
}



Measured memory_bytes: 2680
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    int n,day,rem,ans;
    cin >> n >> day >> rem ; 
    ans = n;
    while (n--){
        int a; cin>>a;
        for (int i=a+1,j=2;i<=day;i=j*a+1,j++){
            ans++;
        }
    }
    cout << ans+rem << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;

int n, Ma, Mb;
int a[50], b[50], c[50];
// dp[i][j][k] := i番目までの薬局をみて, タイプAの薬がjグラムで, Bの薬がkグラムの時の最小費用  
int dp[50][500][500];

int main(void){
	cin >> n >> Ma >> Mb;
	rep(i, n) cin >> a[i] >> b[i] >> c[i];
	rep(i, 50)rep(j, 500)rep(k, 500)dp[i][j][k] = INF;
	dp[0][0][0] = 0;
	rep(i, n){
		rep(j, 500)rep(k, 500){
			if(dp[i][j][k] == INF) continue;
			//i番目の薬局を使う
			chmin(dp[i + 1][j + a[i]][k + b[i]], dp[i][j][k] + c[i]);
			//i番目の薬局を使わない
			chmin(dp[i + 1][j][k], dp[i][j][k]);
		}
	}

	int ans = INF;
	reps(i, 1, 50){
		int A = Ma * i, B = Mb * i;
		if(A > 490 || B > 490) break;
		chmin(ans, dp[n][A][B]);
	}
	if(ans == INF) printf("-1\n");
	else printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 49024
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <numeric>
#include <string>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
int main() {
    int N;
    cin >> N;
    string s[55];
    int t[55];
    rep(i, 0, N) { cin >> s[i] >> t[i]; }
    string x;
    cin >> x;
    bool sleep = false;
    int res = 0;
    rep(i, 0, N) {
        if(sleep) {
            res += t[i];
        }
        if(s[i] == x) {
            sleep = true;
        }
    }
    cout<<res<<endl;
}

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

int main() {
  int a,b;
  cin >> a >> b;
  if (a % 2 !=0 && b % 2 != 0) {
    cout << "Odd" << endl;
  }
  else {
    cout << "Even" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#define N 10000

int isPrime(int);

int main(){
  int i, j, k = 0, n;
  int A[N];

  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d",&A[i]);
    j = isPrime(A[i]);
    k += j;
  }
  printf("%d\n",k);

  return 0;
}

int isPrime(int x){
  int i = 3;
  if(x == 2) return 1;
  if(x < 2 || x % 2 == 0) return 0;
  while(i <= sqrt(x)){
    if(x % i == 0) return 0;
    i += 2;
  }
  return 1;
}

Measured memory_bytes: 628
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    int a, b;

    cin >> a >> b;

    if(a+b==15) cout << '+' << endl;
    else if(a*b==15) cout << '*' << endl;
    else cout << 'x' << endl;

    return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<char> s(n + 10,0);
    vector<int> east(n+10,0),west(n+10,0);
    int ecount = 0;
    int wcount = 0;
    for(int i = 1; i <= n; i++){
        cin >> s[i];
        if(s[i] == 'E'){
            ecount++;
        }
        else{
            wcount++;
        }
        east[i] = ecount;
        west[i] = wcount;
    }
    int min = n;
    int count;
    for(int i = 1; i <= n; i++){
        count = west[i-1] + east[n] - east[i];
        if(count < min) min = count;
    }
    cout << min << endl;
}

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

#define BUFSIZE 11

int main(int argc, char const *argv[]) {
    int a;
    char s[BUFSIZE];
    scanf("%d", &a);
    scanf("%s", s);
    if(a >= 3200) {
        printf("%s", s);
    } else {
        printf("red");
    }

    return 0;
}


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

int N, M;
int pre[100005];
int num[100005];

int find(int x) {
	int r = x;
	while (pre[r] != r) r = pre[r];
	int i = x, j;
	while (i != r) {
		j = pre[i];
		pre[i] = r;
		i = j;
	}
	return r;
}

void join(int x,int y) {
	int a = find(x);
	int b = find(y);
	if (a != b) {
		pre[b] = a;
	}
}


int main() {
	cin >> N >> M;
	for (int i = 1; i <= N; i++) cin >> num[i];
	for (int i = 0; i <= N; i++) pre[i] = i;
	for (int i = 0; i < M; i++) {
		int x, y;
		cin >> x >> y;
		join(x, y);
	}
	int ans = 0;
	for (int i = 1; i <= N; i++) {
		if (find(i) == find(num[i])) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
 
using namespace std;
 
int main(){
	
	string S;
	cin>>S;

	for(int i=0;i<S.size();i++){
		if(S[i]=='e'&&S[i+1]=='r'&&S[i+2]=='a'&&S[i+3]=='s'&&S[i+4]=='e'&&S[i+5]=='r'){
			S.erase(i,6);
			i=-1;
		}
	}
	
	for(int i=0;i<S.size();i++){
		if(S[i]=='e'&&S[i+1]=='r'&&S[i+2]=='a'&&S[i+3]=='s'&&S[i+4]=='e'){
			S.erase(i,5);
			i=-1;
		}
	}
	
	for(int i=0;i<S.size();i++){
		if(S[i]=='d'&&S[i+1]=='r'&&S[i+2]=='e'&&S[i+3]=='a'&&S[i+4]=='m'&&S[i+5]=='e'&&S[i+6]=='r'){
			S.erase(i,7);
			i=-1;
		}
	}
 
	for(int i=0;i<S.size();i++){
		if(S[i]=='d'&&S[i+1]=='r'&&S[i+2]=='e'&&S[i+3]=='a'&&S[i+4]=='m'){
			S.erase(i,5);
			i=-1;
		}
	}
		
	if(S.size()==0) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i =a; i<n; i++) 
#define ll long long
#define MOD 1000000007
using namespace std;
  
int main() {
  int M; cin >> M;
  ll keta =0, sum =0;
  ll d[M],c[M]; 
  rep(i,0,M) {
    cin >> d[i] >> c[i];
    keta += c[i]; sum += d[i] * c[i];
  }
 
  cout << keta + (sum-1)/9 -1 << endl;

}

Measured memory_bytes: 6740
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let xs: Vec<i64> = sc.vec(n);
    let mut cx = vec![0, 0, 0];
    let mut ans: i64 = 1;
    for i in 0..n {
        let x = xs[i];
        let m = cx.iter().filter(|&c| *c == x).count();
        // trace!(x, m, &cx);
        if m == 3 {
            ans = (ans * 3) % M;
            cx[0] += 1;
        } else if m == 2 {
            ans = (ans * 2) % M;
            if x == cx[0] {
                cx[0] += 1;
            } else if x == cx[1] {
                cx[1] += 1;
            } else {
                cx[2] += 1;
            }
        } else if m == 1 {
            if x == cx[0] {
                cx[0] += 1;
            } else if x == cx[1] {
                cx[1] += 1;
            } else {
                cx[2] += 1;
            }
        } else {
            ans = 0;
            break;
        }
    }
    put!(ans % M);
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 11768
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		new Main().run();
	}

	FastScanner sc;

	void run() {
		sc = new FastScanner();

		Map<Character, Integer> dic = new HashMap<Character, Integer>();

		String S = sc.next();

		int size = S.length();

		for (int i = 0; i < size; i++) {
			char c = S.charAt(i);
			if (dic.containsKey(c)) {
				dic.put(c, dic.get(c) + 1);
			} else {
				dic.put(c, 1);
			}
		}

		String ans = "Yes";
		for (Entry<Character, Integer> e : dic.entrySet()) {
			if (e.getValue() % 2 != 0) {
				ans = "No";
				break;
			}
		}

		System.out.println(ans);
	}

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

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

using namespace std;

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define rep(i, n) for(int i = 0; i < n; i++)
#define outl(x) cout<< (x) << '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007

template<typename Tn> Tn gcd(Tn a, Tn b)
{
  return (b ? gcd(b, a % b) : a);
}

template<typename Tn> Tn lcm(Tn a, Tn b)
{
  return a / gcd(a, b) * b;
}

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

int kcnt(int x)
{
  int rec = 0;
  
  while(x) {
    x /= 10;
    rec++;
  }

  return rec;
}

int main()
{
  llint n;
  ci >> n;

  llint m = sqrt(n) + 1;

  int mn = 10;

  for(int i = 1; i <= m; i++) {
    if(n % i) continue;
    
    int a = i;
    int b = n / i;

    a = kcnt(a);
    b = kcnt(b);
    mn = min(mn, max(a, b));
  }

  co << mn << en;
  
  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#define MAX 100
using namespace std;
typedef struct{
    string name;
    int point;
    int number;
}Restaurant;
int main(){
    int N;
    Restaurant restran[MAX];
    Restaurant temp;
    int i;
    int j;
    cin >> N;
    
    for(i=0;i<N;i++){
        cin >> restran[i].name >> restran[i].point;
        restran[i].number = i+1;
    }
    for(i=0;i<N-1;i++){
        for(j=i+1;j<N;j++){
            if( restran[i].name > restran[j].name){
                temp = restran[i];
                restran[i] = restran[j];
                restran[j] = temp;
            }else if(restran[i].name == restran[j].name && restran[i].point < restran[j].point){
                temp = restran[i];
                restran[i] = restran[j];
                restran[j] = temp;
            }
        }
    }
    for(i=0;i<N;i++){
        cout << restran[i].number << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define REV(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector <string>
#define vvs vector <vector<string>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define pq  priority_queue<int>
using ll = long long;
/* ----------------よく使う数字や配列----------------- */
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
const int INF = 2000000000;
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */
/*---------------------template----------------------*/
/*----------------------end--------------------------*/
/* --------------------ライブラリ--------------------*/
bool isprime(ll a)//素数判定、primeならtrue,違うならfalse
{
    if (a < 2) return false;
    else if (a == 2) return true;
    else if (a % 2 == 0) return false;
    double m = sqrt(a);
    for (int i = 3; i <= m; i += 2)
    {
        if (a % i == 0)
        {
            return false;
        }
    }
    // 素数である
    return true;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
/*---------------------臨時--------------------------*/
/*----------------------end-------------------------*/
signed main(){
  string S,T;cin>>S>>T;
  sort(all(S));
  sort(T.rbegin(),T.rend());
  int minsize=min(S.size(),T.size());
  bool b=false;
  string A=S.substr(0,minsize),B=T.substr(0,minsize);
  if(A==B){
    if(S.size()<T.size())puts("Yes");
    else puts("No");
  }
  else {
    rep(i,minsize){
      if(S[i]<T[i]){
        puts("Yes");
        break;
      }
      else if(S[i]>T[i]){
        puts("No");
        break;
      }
    }
  }
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    int a,b;
    cin>>a>>b;
    if(b%2!=0)
    {
        cout<<"No"<<endl;
    }
    else
    {
       if(b/2<a || b>(a*4))cout<<"No"<<endl;
       else
        cout<<"Yes"<<endl;
 
 
 
    }
   return 0;
}

Measured memory_bytes: 3652
n = int(input())-1
a = list(map(int,input().split()))

a_max = a[0]
a_min = a[0]

for i in range(n):
  if(a_max < a[i+1]):
    a_max = a[i+1]
  if(a[i+1] < a_min):
    a_min = a[i+1]

print(a_max - a_min)

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

string shuffle_string(string s, int n){
    string t;
    for (int i = 0; i < s.size(); i++)
    {
        t.push_back(s.at((i+n) % s.size()));
    }
    return t;
}

int main(){
    string s;
    int m, h;

    while(true){
        cin >> s;
        if(s == "-") break;
        cin >> m;
        for (int i = 0; i < m; i++)
        {
            cin >> h;
            s = shuffle_string(s, h);
        }
        cout << s << endl;
    }
}


Measured memory_bytes: 3184
#include <iostream>
#include <string>

int main()
{
    using std::cin;
    using std::cout;
    using std::string;

    string s;
    cin >> s;
    int K;
    cin >> K;

    for (string::size_type i = 0; i < s.size(); ++i) {
        int index = static_cast<int>(s[i] - 'a');
        if (i == s.size() - 1) {
            index = (index + K) % 26;
        } else if (index) { // index is not 'a'
            int diff = 26 - index;
            if (K >= diff) {
                index = 0;
                K -= diff;
            }
        }
        cout << static_cast<char>('a' + index);
    }
    cout << std::endl;

    return 0;
}

Measured memory_bytes: 640
import java.text.SimpleDateFormat;
import java.util.GregorianCalendar;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
        GregorianCalendar date =
            new GregorianCalendar(Integer.parseInt(s.substring(0, 4)), Integer.parseInt(s.substring(5, 7)), Integer.parseInt(s.substring(8, 10)));
        GregorianCalendar date2 = new GregorianCalendar(2019, 4, 30);

        if (0 <= date2.compareTo(date)) {
            System.out.println("Heisei");
        } else {
            System.out.println("TBD");
        }

    }

}


Measured memory_bytes: 23248
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

void solve()
{
    int64_t X;
    std::cin >> X;

    int64_t ans;
    if (400 <= X && X <= 599) ans = 8;
    if (600 <= X && X <= 799) ans = 7;
    if (800 <= X && X <= 999) ans = 6;
    if (1000 <= X && X <= 1199) ans = 5;
    if (1200 <= X && X <= 1399) ans = 4;
    if (1400 <= X && X <= 1599) ans = 3;
    if (1600 <= X && X <= 1799) ans = 2;
    if (1800 <= X && X <= 1999) ans = 1;

    std::cout << ans << std::endl;
}

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


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x,long long int y) 
{ 
    long long int res = 1;     // Initialize result 
  // x=x;
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x); 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x);  // Change x to x^2 
    } 
    return res; 
}
long long int power(long long int x,long long int y,long long int m) 
{ 
    long long int res = 1;     // Initialize result 
   x=x%m;
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x)%m; 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x)%m;  // Change x to x^2 
    } 
    return res; 
}
void primeFactors(int n)  
{  
    // Print the number of 2s that divide n  
    while (n % 2 == 0)  
    {  
        cout << 2 << " ";  
        n = n/2;  
    }  
  
    // n must be odd at this point. So we can skip  
    // one element (Note i = i +2)  
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {  
        // While i divides n, print i and divide n  
        while (n % i == 0)  
        {  
            cout << i << " ";  
            n = n/i;  
        }  
    }  
  
    // This condition is to handle the case when n  
    // is a prime number greater than 2  
    if (n > 2)  
        cout << n << " ";  
}

long long int gcd(long long int a, long long int b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);  
 } 
 long long int lcm(long long int a, long long int b)  
 { 
     long long int temp;
    
    return (a*b)/gcd(a, b);  
 }
 
int main() {
   long long int i,j;
 
   
 //long long int b[1000000];
 //set<long long int >s;
       long long int f=0,p=0,z,o=0;
       double pie=3.141592653589793238;
    long long int n,m,l=0,k,c,min1=10000000000000,max2=-100;
    for(i=0;i<5;i++)
    {
    cin>>n;
    
        if(n==0)
        cout<<(i+1);
    }
  
 return 0;
}


Measured memory_bytes: 3688
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>
#include<string.h>

typedef int32_t i32;
typedef int64_t i64;

#define ALLOC(size,type) ((type*)calloc((size),sizeof(type)))

void run (void) {
  char *s = ALLOC (100000 + 1, char);
  scanf ("%s", s);
  const i32 p = 13;
  i64 *dp = ALLOC (p, i64);
  i64 *next = ALLOC (p, i64);
  dp[0] = 1;
  const i32 mod = 1000000007;
  for (i32 i = 0; s[i] != '\0'; ++i) {
    memset (next, 0, sizeof (i64) * p);
    if (s[i] != '?') {
      i32 d = s[i] - '0';
      for (i32 j = 0; j < p; ++j) {
        next[(10 * j + d) % p] += dp[j];
      }
    } else {
      for (i32 d = 0; d < 10; ++d) {
        for (i32 j = 0; j < p; ++j) {
          next[(10 * j + d) % p] += dp[j];
        }
      }
    }
    for (i32 j = 0; j < p; ++j) {
      dp[j] = next[j] % mod;
    }
  }
  printf ("%" PRIi64 "\n", dp[5]);
}

int main (void) {
  run();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
double a[10][10];
int d;
bool func(int x, int y)
{
	double s = 0;
	for (int i = 0; i < d; i++)
	{
		s += (a[x][i] - a[y][i]) * (a[x][i] - a[y][i]);
	}
	s = sqrt(s);
	int s1 = s;
	if (s - s1 == 0) return true;
	return false;
}
int main() {
	int n, ct = 0;
	cin >> n >> d;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < d; j++)
		{
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < n - 1; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			if (func(i, j)) ct++; 
		}
	}
	cout << ct;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
double p[3000],f[3000][3000];
int n;
int main()
{
	int i,j;
	double ans=0.0;
	scanf("%d",&n);
	f[0][0]=1;
	for(i=1;i<=n;i++)
	{
		scanf("%lf",&p[i]);
	}
	for(i=1;i<=n;i++)
	{
		for(j=0;j<=i;j++)
		{
			if(j==0)
				f[i][j]=f[i-1][j]*(1-p[i]);
			else
			{
				f[i][j]=f[i-1][j]*(1-p[i])+f[i-1][j-1]*p[i];
			}
		}
	}
	for(i=n/2+1;i<=n;i++)
	{
		ans=ans+f[n][i];
	}
	printf("%.10lf",ans);
}

Measured memory_bytes: 68864
#include <iostream>
using namespace std;
int main()
{
  int N;
  cin >> N;
  int a[N];
  for (int i = 0; i < N; i++)
    cin >> a[i];
  int ans = 0;
  for (int i = 0; i < N; i++)
  {
    while (a[i] % 2 == 0)
    {
      ans++;
      a[i] /= 2;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())

costs = [[0, 0, 0] for _ in range(N + 1)]  # [[0,0,0], [10,20,30]]
for n in range(1, N + 1):
    a, b, c = map(int, input().split())
    if n == 1:
        costs[1][0] = a
        costs[1][1] = b
        costs[1][2] = c
        continue
    max_value = 0
    for i in range(3):
        if i == 0:
            tmp_max_b_a = costs[n - 1][1] + a
            tmp_max_c_a = costs[n - 1][2] + a
            max_value = max(tmp_max_b_a, tmp_max_c_a)
            costs[n][0] = max_value
        if i == 1:
            tmp_max_a_b = costs[n - 1][0] + b
            tmp_max_c_b = costs[n - 1][2] + b
            max_value = max(tmp_max_a_b, tmp_max_c_b)
            costs[n][1] = max_value
        if i == 2:
            tmp_max_a_c = costs[n - 1][0] + c
            tmp_max_b_c = costs[n - 1][1] + c
            max_value = max(tmp_max_a_c, tmp_max_b_c)
            costs[n][2] = max_value
print(max(costs[-1]))


Measured memory_bytes: 59276
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main() {

	int n;
	
	cin >> n;

	vector<int> a(n);
	string s = "YES";

	int i, j, max = 0;
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}

	sort(a.begin(), a.end());
	for (i = 0; i < n - 1; i++) {
		if (a[i] == a[i + 1]) {
			s = "NO";
		}
	}


	cout << s << endl;
	
	return 0;
}

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

using namespace std;

#define ll long long int

int main()
{
	ll a,b,c,d;
	cin >>  a ;
	vector<ll> v;
	for(ll i=0;i<a;i++)
	{
		cin >> b;
		v.push_back(b);
	}
	
	ll dp[a][a];
	dp[a-1][a-1]=v[a-1];
	
	for(ll i=a-1;i>=0;--i)
	{
		for(ll j=i;j<a;j++)
		{
			if(i==j)
			{
				dp[i][j]=v[i];
			}
			else
			dp[i][j]=max(v[i]-dp[i+1][j],v[j]-dp[i][j-1]);
		}
	}
	cout << dp[0][a-1];
}

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

int main() {
  long N;cin>>N;
  vector<long> A(N);
  for(int i=0;i<N;i++) cin>>A.at(i);
  long ans=0;
  for(int i=0;i<N-1;i++){
    if(A.at(i)>A.at(i+1)){
      ans+=A.at(i)-A.at(i+1);
      A.at(i+1)=A.at(i);
    }
  }
  cout<<ans<<endl;
}


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

int main() {
    string card;
    int n, m;
    
    while (true) {
        cin >> card;
        if (card == "-") break;
        cin >> m;
        int h[m];
        for (int i = 0; i < m; i++) {
            cin >> h[i];
            int a = h[i];
            string b = card.substr(0, a);
            card.erase(0, a);
            for (int j = 0; j < b.size(); j++) {
                card.insert(card.end(), b[j]);
            }
        }
        cout << card << endl;
    }
    
}


Measured memory_bytes: 3220
#include <iostream>
#include <string>

using namespace std;

int main(){
  string s;
  cin >> s;
  if(s == "SUN")cout << '7' << endl;
  if(s == "MON")cout << '6' << endl;
  if(s == "TUE")cout << '5' << endl;
  if(s == "WED")cout << '4' << endl;
  if(s == "THU")cout << '3' << endl;
  if(s == "FRI")cout << '2' << endl;
  if(s == "SAT")cout << '1' << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <cmath>
using namespace std;
int main() {
    int size;
    scanf("%d", &size);
    vector<int> a, b;
    for (int i = 0; i < size; i++) {
        int tmp;
        scanf("%d", &tmp);
        a.push_back(tmp);
    }
    for (int i = 0; i < size; i++) {
        int tmp;
        scanf("%d", &tmp);
        b.push_back(tmp);
    }
    double sum = 0;
    for (int i = 0; i < size; i++) {
        if (a[i] > b[i]) {
            sum += a[i] - b[i];
        } else {
            sum -= a[i] - b[i];
        }
    }
    printf("%f\n", sum);
    sum = 0;
    for (int i = 0; i < size; i++) {
        sum += (a[i] - b[i]) * (a[i] - b[i]);
    }
    printf("%f\n", sqrt(sum));
    sum = 0;
    for (int i = 0; i < size; i++) {
        if (a[i] > b[i]) {
            sum += (a[i] - b[i]) * (a[i] - b[i]) * (a[i] - b[i]);
        } else {
            sum -= (a[i] - b[i]) * (a[i] - b[i]) * (a[i] - b[i]);
        }
    }
    printf("%f\n", pow(sum, 1.0 / 3.0));
    double max = 0;
    for (int i = 0; i < size; i++) {
        if (max < a[i] - b[i] || max < b[i] - a[i]) {
            max = fabs(a[i] - b[i]);
        }
    }
    printf("%f\n", max);
}

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

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

const int INF = 1e9 + 7;

using namespace std;

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

	ll a, b, x;
	cin >> a >> b >> x;

	ll res =  b / x;
	if (a == 0)
		res += 1;
	else
		res -= (a - 1) / x;

	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0 ,-1};
signed main(){
    int X;
    cin >> X;
    int ans = 1;
    for(int i = 2; i*i <= X; i++) {
        int Y = i*i;
        while(Y <= X) {
            ans = max(Y,ans);
            Y*=i;
        }
    }
    cout << ans << endl;
}


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

int mod = 1000000007;
int64_t large = 9223372036854775807;

int main()
{
    int N, sum = 0, tmp = 0, ans = mod;
    cin >> N;
    vector<int> list(N);
    for (int i = 0; i < N; i++)
    {
        cin >> list[i];
        sum += list[i];
    }
    for (int i = 0; i < N; i++)
    {
        tmp += list[i];
        ans = min(ans, abs(tmp - (sum - tmp)));
    }
    cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,L>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator
#define VL vector<LL>::iterator
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
V<LL>v,u;
int main()
{
    FAST;
    LL n,m,i,j,k,p,q,o,l,s,t,z;
    cin>>n;
    n++;
    for(i=0;i<n;i++)
    {
        cin>>o;
        v.PSB(o);
    }
    sort(v.B,v.E);
    k=999999999999;
    for(i=1;i<n;i++)
    {
      u.PSB(v[i]-v[i-1]);
    }
    k=u[0];
    for(i=1;i<u.SZ;i++)
    {
        k=__gcd(k,u[i]);
    }
    cout<<k<<endl;
    return 0;
}


Measured memory_bytes: 2548
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
int n,m,X,Y,x,y;
vector<int>a;
vector<int>b;
cin>>n>>m>>X>>Y;
for(int i=0;i<n;i++)
{
    cin>>x;
    a.push_back(x);

}
for(int i=0;i<m;i++)
{
     cin>>y;
    b.push_back(y);
}
sort(a.begin(),a.end());
sort(b.begin(),b.end());
if(b.front()>a.back()&&b.front()>X&&b.front()<=Y)
    cout<<"No War"<<endl;
else
    cout<<"War"<<endl;
return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, x;
    cin >> a >> b >> x;
    if ((x - a <= b) && (a <= x)) {
      cout << "YES" << '\n';
    } else {
      cout << "NO" << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<map>
#define pii pair<int,int>
using namespace std;
int curU, curD;
int n;
map<pii, int>Map, T;
map<int, pii>Z;
void Put(int a, int b, int c) {
	if (!T.count({ a,b }) || T[{a, b}] > c)T[{a, b}] = c;
}
int main() {
	int i;
	scanf("%d", &n);
	Map[{0, 0}] = 0;
	for (i = 1; i <= n; i++) {
		int a;
		T.clear();
		scanf("%d", &a);
		for (auto &t : Map) {
			int A = t.first.first;
			int B = t.first.second;
			int c = t.second;
			if (A <= a) {
				pii tp = { A,a - A };
				int c2 = c;
				if ((B == 0 && a - A > 0) || B > a - A)c2++;
				Put(A, a - A, c2);
			}
			if (a >= B) {
				pii tp = { a - B,B };
				int c2 = c;
				if (A < a - B)c2++;
				Put(a - B, B, c2);
			}
			pii tp = { 0, a };
			int c2 = c;
			if ((B == 0 && a > 0) || B > a)c2++;
			Put(0, a, c2);

			tp = { a,0 };
			c2 = c;
			if (A < a)c2++;
			Put(a, 0, c2);
		}
		Z.clear();
		Map.clear();
		for (auto &t : T) {
			pii tp = t.first;
			if (tp.first == 0 || tp.second == 0) {
				Map[t.first] = t.second;
				continue;
			}
			int u = t.second;
			if (Z.count(u)) {
				pii t2 = Z[u];
				if (tp.first <= t2.first)continue;
			}
			Z[u] = tp;
		}
		int Mn = 1e9;
		for (auto &z : Z) {
			if (Mn > z.first)Mn = z.first;
			if (z.first > Mn + 1) continue;
			Map[z.second] = z.first;
		}
	}
	int res = 1e9;
	for (auto &t : Map) {
		res = min(res, t.second);
	}
	printf("%d\n", res);
	
}

Measured memory_bytes: 256
//auto 関数名 = [(&:ラムダ外の引数をとる時))](引数の型1 引数名1, 引数の型2, 引数名2, ...) { 関数の処理 }; //inside main() define function. take care of };
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//   bitset<ビット数> s(tmp);
//   // (ビット列sに対する処理)
// }
// sort(配列変数.begin(), 配列変数.end());
// do {
//   // 順列に対する処理
// } while (next_permutation(配列変数.begin(), 配列変数.end()));
//const double PI = acos(-1); M_PI
// cout << fixed << setprecision(10);
#include <bits/stdc++.h>
#include <regex>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define _GLIBCXX_DEBUG 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end() //sort(all(vec)); ,reverse(all(vec));etc
int main(){
 string s;
 cin>>s;
 int a;
 int sum=0;
 rep(i,s.size()){
   a=s.at(i)-48;
   sum+=a;
 }
 //cout<<sum<<endl;
 if(stoi(s)%sum==0){
   cout<<"Yes"<<endl;
 }else{cout<<"No"<<endl;}
}


Measured memory_bytes: 3620
a=[],m=l=0,n=c='';require("fs").readFileSync("/dev/stdin","utf8").trim().split(' ').map(function(i){a[i]?++a[i]>m?m=a[n=i]:0:a[i]=1;(t=i.length)>l?(c=i,l=t):0});console.log(n+' '+c)

Measured memory_bytes: 7648
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int a, b, c, d, x, y, s;
	cin >> a >> b >> c >> d;
	x = max(a, c);
	y = min(b, d);
	s = max(0, y - x);
	cout << s << "\n";

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll ;
typedef double db;
const double pi = 3.141592654;
#define pb         push_back
#define forab(i,a,b)       for(int i=(a);i<=(b);i++)
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)
#define pcase(z,x)     printf("Case %ld: %lld\n",z,x)
#define nw	 "\n"
#define mod 1000000007

int main(void)
{
	CIN;
	ll tc,l,k,sum=0,x=0,y,z=0,m=1,n=0,ans=0,cnt=0;
	cin>>n>>m;
	string s,t,p;
	for(ll i=0;i<n;i++){
			cin>>s;
			cout<<s<<nw<<s<<nw;
		
	}


}

Measured memory_bytes: 3652
n,k = map(int, input().split())
w = [int(input()) for _ in range(n)]

def check(p):
    c = t = 0
    for wi in w:
        t += wi
        if t > p:
            t = wi
            c += 1
            if c >= k:
                return False
    return True

s = max(w)
l = sum(w)
m = l + (s-l)*k//n
while s < l:
    if check(m):
        l = m
    else:
        s = m+1
    m = (s+l)//2
print(m)

Measured memory_bytes: 11596
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> PII;
typedef long long ll;

int main(void){
  string s;
  cin >> s;
  int c[50] = {};
  for(int i = 0;i < (int)s.size();++i){
    ++c[s[i] - 'a'];
  }
  int res = 0;
  for(int i = 0;i < 50;++i){
    if(c[i] % 2 != 0)++res;
  }
  cout << max(res/2,0) << endl;
  return 0;
}

Measured memory_bytes: 3140
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();
 
        int inputInt;
        int i = 1;
        for (;;) {
            inputInt = Integer.parseInt(sc.nextLine());
            if (inputInt == 0) {
                break;
            }
            sb.append("Case " + i + ": " + inputInt + "\n");
            i++;
        }
 
        System.out.print(sb);
    }
}

Measured memory_bytes: 61548
def main():
    N = int(input())
    H = list(map(int, input().split()))[::-1]
    for i in range(1, N):
        if H[i] - H[i-1] >= 2:
            print('No')
            exit()
        elif H[i] - H[i-1] == 1:
            H[i] -= 1
    print('Yes')


if __name__ == '__main__':
    main()


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

int main(){
    int w,h,n;
    cin >> w >> h >> n;
    int x,y,a;
    int x_min = w,x_max = 0,y_min = h,y_max = 0;
    for (int i = 0;i < n;i++){
        cin >> x >> y >> a;
        if (a == 1){
            x_max = max(x_max,x);
        }
        if (a == 2){
            x_min = min(x_min,x);
        }
        if (a == 3){
            y_max = max(y_max,y);
        }
        if (a == 4){
            y_min = min(y_min,y);
        }
    }
    cout << max(0,x_min-x_max)*max(0,y_min-y_max) << endl;
}

Measured memory_bytes: 256
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define SORTD(a) sort(a.rbegin(), a.rend());
#define UNIQUE(a) unique(a.begin(), a.end())
#define ll long long
#define INF 1000000000000000000
#define INT_MAX 2147483647

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <cctype>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <utility>
#include <ios>
#include <iomanip>

using namespace std;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;




int main() {
	int n, m;
	cin >> n >> m;
	int min = 0, max = INT_MAX;
	REP(i, m) {
		int l, r;
		cin >> l >> r;
		if (l > min) {
			min = l;
		}
		if (r < max) {
			max = r;
		}
	}
	if (max >= min) {
		cout << (max - min) + 1 << endl;
	}
	else {
		cout << "0" << endl;
	}
}

Measured memory_bytes: 256
S=input()

def ans141(S:str):
    judge=0

    for i in range(0,len(S)):
        if (i+1)%2==1:
            if S[i]=="R" or S[i]=="U" or S[i]=="D":
                continue
            else:
                judge+=1
        elif (i+1)%2==0:
            if S[i]=="L" or S[i]=="U" or S[i]=="D":
                continue
            else:
                judge+=1
    if judge>0:
        return "No"
    else:
        return "Yes"

print(ans141(S))

Measured memory_bytes: 9012
/*May The Force Be With Me*/
#include <bits/stdc++.h>
#include <stdio.h>
#include <ctype.h>
#pragma GCC optimize ("Ofast")
#define ll long long
#define MOD 1000000007
#define endl "\n"
#define vll vector<long long>
#define mll map<long long,long long>
#define pll pair<long long, long long>
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define pb push_back
#define f first
#define s second
#define inf INT_MAX
#define size_1d 10000000
#define size_2d 1000
//Snippets: delta, sieve, fastexp, dfs, bfs, dijkstra, floodfill

using namespace std;

ll n, k;

void Input() {
	cin >> n >> k;
}

void Solve() {
	vll a(n);
	for (ll i = 0; i < n; i++) cin >> a[i];
	sort(all(a));
	ll su = 0;
	for (ll i = 0; i < k; i++)su += a[i];
	cout << su;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ll T = 1;
	//cin >> T;
	//ll t = 1;
	while (T--) {
		Input();
		//cout << "Case " << t << ": ";
		Solve();
		//t++;
	}
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int n=0;
	int m=0;
	int a[10000];
	int sum=0;
	cin >> n >> m;
	for (int i = 0; i < m; i++)
	{
		cin >> a[i];
		sum += a[i];
	}
	if (sum > n)
	{
		sum = n + 1;
	}
	cout << n - sum << endl;
}

Measured memory_bytes: 3584
def func ( L00 , x0 , H  , W  , K , c0 ) :

	if sum(L00) == K :
		c0[0] += 1 ; 

	for r in range ( x0 , H + W ) : 

		if r >= H :
			y = r - H 
			L =L00[:];
			for c in range ( H ) :
				if L[ c * W + y ] == 1 :
					L[c * W + y ] = 0 ;
			func ( L , r+1 , H , W , K , c0 ) ;

		else :
			L =L00[:];
			for c in range ( W ) :
				if L[r * W + c] == 1 :
					L[r  * W + c ] = 0 ;
			func ( L , r+1 , H , W , K , c0 ) ;




	


H , W , K = map ( int , input().strip().split(" ") ) ;

L00 = [] ;
for x in range ( H ) :
	for c in input().strip() :
		if c =='#' :
			L00.append ( 1 ) ;
		else :
			L00.append ( 0 ) ;

c0 = [0] ;
func ( L00 , 0 , H , W , K , c0 ) ;
print ( c0[0] ) ;


Measured memory_bytes: 9244