akhauriyash/Code-Regression huggingface dataset:
#include  <iostream>
#include  <stdio.h>
using namespace std;

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 
 

int main(){

    string S;
    cin >> S;
    string black = "0";
    string white = "1";

    int ans[2]={};
    int index;

    for( int si = 0 ; si < S.length() ; si++ ){
        index = si % 2;
        if(S.substr(si,1) == black){
            ans[index] = ans[index] + 1;
        }else{
            index = ( si + 1 ) % 2;
            ans[index] = ans[index] + 1;
        }
    }

    if(ans[0] > ans[1]){
        cout << ans[1];
    }else{
        cout << ans[0];
    }
    

}

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

using namespace std;

const int MAX = 100;

int main()
{
	int n, m, arr[MAX], s = 0, count = 0;
	cin >> n >> m;
	
	double check = 1 / (4.0 * (double)m);
	
	for (int i=0; i<n; ++i) {
		cin >> arr[i];
		s += arr[i];
	}

	for (int i=0; i<n; ++i) {
		double c = (double)arr[i] / s;
		if (c >= check) ++count;
	}
	
	count >= m ? cout << "Yes" : cout << "No";
	
	return 0;
}



Measured memory_bytes: 256
///apigs property
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0)
#define F first
#define S second
#define pb push_back
#define vll vector< ll >
#define vi vector< int >
#define pll pair< ll , ll >
#define pi pair< int , int >
#define all(s) s.begin() , s.end()
#define sz(s) s.size()
#define md (s + e) / 2
#define mid (l + r) / 2
using namespace std;
typedef long long ll;
ll q, dp[3005][3005][5], a[555555] , b[555555], k, l, m, n, o, p;
map < ll , ll > mp;
vll adj[555555];
const ll mod = 1e9+7;
ll mem(ll x , ll y , ll op){
	//cout << op << " ";
	if(x + y == n)return 0;
	ll &r = dp[x][y][op];
	if(r != -1)return r;
	ll i = x, j = n - y - 1;
	if(!op){
		r = max(mem(x + 1 , y , op ^ 1) + a[i] , mem(x , y + 1 , op ^ 1) + a[j]);
	}
	else {
		r = min(mem(x + 1 , y , op ^ 1) , mem(x , y + 1 , op ^ 1));
	}
	return r;
}
void solve(){
	memset(dp , -1 , sizeof dp);
	cin >> n;
	for(ll i = 0 ; i < n ; i++){
		cin >> a[i];
		k += a[i];
	}
	o = mem(0 , 0 , 0);
	//cout << o << endl;
	p = k - o;
	cout << o - p;
}
int main() {
    fast ;
	// cin >> q;
    q = 1;
    while(q--){
    	solve();
	}
}



Measured memory_bytes: 369520
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380


int main()
{
	cout << fixed << setprecision(10);
	char c;
	cin >> c;
	if ('Z' < c)
	{
		cout << 'a';
	}
	else
	{
		cout << 'A';

	}


	return 0;
}

Measured memory_bytes: 3616
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

const ll INF=1e9+7;


int main(){
    ll k,a,b;
    cin >> k >> a >> b;
    if(a-1>=k){
        cout << k+1 << endl;
        return 0;
    }
    k-=a-1;
    ll ans=a;
    if(b-a>=2){
        ll cnt=k/2;
        k-=cnt*2;
        ans+=cnt*(b-a);
    }
    ans+=k;
    cout << ans << endl;
}


Measured memory_bytes: 3568
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define INF 1000000000000
#define MOD 1000000007
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3)                                                 \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
         << x3 << endl
#define debug_4(x1, x2, x3, x4)                                             \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
         << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5)                                         \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
         << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

using namespace std;
using ll = long long;
template <class T>
void printVector(const vector<T>& v) {
    for (auto value : v) {
        cout << value << " ";
    }
    cout << endl;
}

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> vec;
    vector<ll> a(n), b(n), bcsum(n + 1, 0);
    map<ll, ll> cnt;
    rep(i, n) {
        // cin >> a[i] >> b[i];
        // bcsum[i + 1] = bcsum[i] + b[i];
        ll a, b;
        cin >> a >> b;
        cnt[a] += b;
    };

    ll sum = 0;
    for (auto i = cnt.begin(); i != cnt.end(); ++i) {
        sum += i->second;
        if (sum >= k) {
            cout << i->first << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 9164
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#define ll long long int
#define ull unsigned long long int
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define mod 1000000007
ll n,a[3333];
ll dp[3005][3005];
ll solve(ll s, ll e)
{
    if(s==e)return a[s];
    if(dp[s][e]!=-1)return dp[s][e];
    return dp[s][e]=max(a[s]-solve(s+1,e) , a[e]-solve(s,e-1));
}
int main()
{
    fast;
    cin>>n;
    memset(dp , -1 , sizeof dp);
    for(int i=0;i<n;i++)cin>>a[i];
    cout<<solve(0,n-1);
return 0;
}

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

int main(){
	int n;
	string str;
	
	cin >> n;
	cin.ignore();
	while(getline(cin,str)){
		int pos;
		while( (pos=str.find("Hoshino",0)) != string::npos ){
			str.erase(pos,7);
			str.insert(pos,"Hoshina");
		}
		
		cout << str << endl;
	}
}

Measured memory_bytes: 1224
macro_rules! scan {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };

    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
}

fn main() {
    let _ = scan!(usize);
    let mut vs = scan!(i64;;);

    for i in 1..vs.len() {
        vs[i] += vs[i - 1]
    }

    let mut diff = vec![];
    for k in 0..vs.len() - 1 {
        diff.push((vs[k] - (vs[vs.len() - 1] - vs[k])).abs())
    }

    println!("{}", diff.iter().min().unwrap())
}


Measured memory_bytes: 10492
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>
#include <fstream>
#include <cassert>
using namespace std;

//common

typedef int  i32;
typedef long long i64,ll;
typedef long double ld;

#define BR "\n"
#define ALL(c) (c).begin(),(c).end()
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,r) for(int i=(int)l;i<(int)(r);++i)
#define EACH(it,o) for(auto it = (o).begin(); it != (o).end(); ++it)
#define IN(l,v,r) ((l)<=(v) && (v)<(r))

//config
//#define NDEBUG
//#define INF 1<<30
//#define EPS 1e-8
//const ll MOD =100000007;

//debug
#ifdef NDEBUG
#define DUMP(x)
#define DUMPLN(x)
#define DEBUG(x)
#define DEBUGLN(x)
#define LINE()
#define LINELN()
#define CHECK(exp,act)
#define STOP(e)
#else
#define DUMP(x)  cerr << #x << " = " << (x)
#define DUMPLN(x)  DUMP(x) <<endl
#define DEBUG(x) DUMP(x) << LINE() << " " << __FILE__
#define DEBUGLN(x) DEBUG(x)<<endl
#define LINE()    cerr<< " (L" << __LINE__ << ")"
#define LINELN()    LINE()<<endl
#define CHECK(exp,act)  if(exp!=act){DUMPLN(exp);DEBUGLN(act);}
#define STOP(e)  CHECK(e,true);if(!(e)) exit(1);
#endif

template<class T> inline string toString(const vector<T>& x) {
	stringstream ss;
	REP(i,x.size()){
		if(i!=0)ss<<" ";
		ss<< x[i];
	}
	return ss.str();
}

template<class T> inline string toString(const vector<vector<T> >& map) {
	stringstream ss;
	REP(i,map.size()){
		if(i!=0)ss<<BR;
		ss<< toString(map[i]);
	}
	return ss.str();
}
template<class K,class V>  string toString(map<K,V>& x) {
	string res;stringstream ss;
	for(auto& p:x)ss<< p.first<<":" << p.second<<" ";
	return ss.str();
}

string BITtoString(int bit){
    stringstream ss;
    while(bit!=0){ss<<(bit%2);bit/=2;}
    string res=ss.str();reverse(ALL(res));
    return res;
}

template<typename T,typename V> inline T pmod(T v,V MOD){
	return (v%MOD+MOD)%MOD;
}
#define nextInt(n) scanf("%d",&n)
#define defInt(n) int n;nextInt(n)
#define nextLong(n) scanf("%lld",&n)
#define defLong(n) ll n;nextLong(n)
#define nextDouble(n) scanf("%lf",&n)

class Main{
public:

	int N,M;
	void run(){
	//	ifstream cin("in");
	//	ofstream cout( "out" );	
        
        while(true){
            nextInt(N);nextInt(M);
			if(N==0)break;

			vector<vector<double> > gs(N,vector<double>(N));
			REP(i,N)REP(j,N)nextDouble(gs[i][j]);

			vector<vector<double>> dp(M,vector<double>(N,0));
			//初回
			fill(ALL(dp[0]),1);

			for(int c=1;c<M;c++){
				REP(i,N)REP(j,N){
					dp[c][i]=max(dp[c][i],dp[c-1][j]*gs[j][i]);
				}
			}

			double Mv=0;
			REP(i,N)Mv=max(Mv,dp[M-1][i]);

			cout <<round(Mv*100)/100<<endl;
		}
	}
};
int main(){
	cout <<fixed<<setprecision(2);
	ios::sync_with_stdio(false);
	Main().run();
	return 0;
}

Measured memory_bytes: 1444
#include<bits/stdc++.h>
using namespace std;
    int main(){
        string S;
            int x = 0;
                cin >> S;
                    for(int i = 0; i < 4; i++){
                        for(int j = 0; j < 4; j++){
                            if(S.at(i) == S.at(j)){
                                x += 1;
                            }
                        }
                    }
                        if(x == 8){
                            cout << "Yes" << endl;
                        }else{
                            cout << "No" << endl;
                        }
    return 0;}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_imports)]
use ascii::AsciiChar;
use ascii::AsciiStr;
use itertools::Itertools as _;
use permutohedron::LexicalPermutation as _;
use petgraph::algo::dijkstra;
use petgraph::algo::min_spanning_tree;
use petgraph::data::FromElements;
use petgraph::graph::NodeIndex;
use petgraph::graph::UnGraph;
use petgraph::unionfind::UnionFind;
use proconio::fastout;
use proconio::input;
use proconio::marker::Chars;
use proconio::marker::Usize1;
use std::cmp::max;
use std::cmp::min;
use std::cmp::Reverse;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use superslice::Ext as _;

#[fastout]
fn main() {
    input! {
        H: usize,
        W: usize,
        Fieldsz: [Chars; H],
    }

    // 初期の'#'から一番「遠い」点との距離は? という問題
    // 幅優先みたいにやりたいけど、スタート地点が複数あるのが困る
    // いや困らないわ。制約的に間に合いそう。
    // ダイクストラ感がある

    let mx: i64 = (H * W + 1) as i64;

    // 最も近い'#'からの距離
    let mut distsz: Vec<Vec<i64>> = vec![vec![mx; W]; H];

    // まず、'#'を抽出してくる
    let mut heap: BinaryHeap<Reverse<(i64, isize, isize)>> = BinaryHeap::new();

    for h in 0..H {
        for w in 0..W {
            if Fieldsz[h][w] == '#' {
                distsz[h][w] = 0;

                let rev = Reverse((0i64, h as isize, w as isize));
                heap.push(rev);
            }
        }
    }

    // HW個の要素を取り出してくるので、O(HW log(HW))
    // 間に合う見込み

    while !heap.is_empty() {
        let Reverse((dist, h, w)) = heap.pop().unwrap();

        let neibours: Vec<(usize, usize)> = vec![(h - 1, w), (h + 1, w), (h, w - 1), (h, w + 1)]
            .iter()
            .filter(|&&(h, w)| 0 <= h && h < H as isize && 0 <= w && w < W as isize)
            .map(|&(h, w)| (h as usize, w as usize))
            .collect();

        for &(neibour_h, neibour_w) in neibours.iter() {
            if distsz[neibour_h][neibour_w] > dist + 1 {
                distsz[neibour_h][neibour_w] = dist + 1;
                let tpl = (dist + 1, neibour_h as isize, neibour_w as isize);
                heap.push(Reverse(tpl));
            }
        }
    }

    let mut ans = 0;
    for h in 0..H {
        for w in 0..W {
            ans = max(ans, distsz[h][w]);
        }
    }

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


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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#ifdef LOCAL
#define dmp(x) cerr << __LINE__ << " " << #x << " " << x << endl
#else
#define dmp(x) void(0)
#endif

template <class t, class u>
void chmax(t &a, u b)
{
  if (a < b)
    a = b;
}
template <class t, class u>
void chmin(t &a, u b)
{
  if (b < a)
    a = b;
}

template <class t>
using vc = vector<t>;
template <class t>
using vvc = vc<vc<t>>;

using vi = vc<int>;
int gcd(int a, int b)
{
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
int lcm(int a, int b)
{
  return (a * b) / gcd(a, b);
}
int fact(int n)
{
  if (n == 0)
    return 1;
  return n * fact(n - 1);
}
int main()
{
  int n, m;
  cin >> n >> m;
  if((n == 1&& m== 2)||(m == 1&& n == 2)){
  	cout << 3 <<endl;
  }else if((n == 2&& m== 3)||(m == 2&& n == 3)){
  	cout << 1 <<endl;
  }else if((n == 1&& m== 3)||(m == 1&& n == 3)){
  	cout << 2 <<endl;
  }
}

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

#define ll long long
#define F first
#define S second

const int mod = 1000000007;
const int M = 100005;

int main() {
	int T = 1;
	// cin>>T;
	while(T--)
	{
		int n;	cin>>n;
		vector<int> v(n);
		for(int i=0; i<n; i++)	cin>>v[i];
		
		vector<int> dp(n);
		
		dp[0] = 0;
		dp[1] = abs((v[1]-v[0]));
		for(int i=2; i<n; i++)
		{
			dp[i] = min(dp[i-1]+abs(v[i-1]-v[i]), dp[i-2]+abs((v[i-2]-v[i])));
		}
		
		cout<<dp[n-1];
	}
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
   
double r,are,circ;
int main() {
cin >> r;
are = M_PI * r * r;
circ = 2 * M_PI * r;
cout << fixed << setprecision(6) << are << " " << circ << endl;
}

Measured memory_bytes: 1288
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String N = sc.next();
		if (Arrays.asList(N.split("")).stream().filter(e -> e.equals("7")).count() > 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 35904
#include "bits/stdc++.h"
using namespace std;
#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
typedef long long ll;

const int INF = 1e9 + 7;
const long long LLINF = 1e18;

ll a, b, c;
int main() {
    cin>>a>>b>>c;

    if(a%2==0 && b%2==0 && c%2==0){

        if(a==b && b==c){
            cout<<-1<<endl;
        }
        else{
            ll cnt=0;
            while(a%2==0 && b%2==0 && c%2==0){
                ll na=b/2+c/2;
                ll nb=a/2+c/2;
                ll nc=a/2+b/2;

                cnt++;

                a=na;
                b=nb;
                c=nc;
            }
            cout<<cnt<<endl;
        }
    }
    else{
        cout<<0<<endl;
    }
    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
	string s;cin>>s;
	if(s[2]==s[3]&&s[4]==s[5]){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

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

    StringBuffer result = new StringBuffer();
    result.append(C1.charAt(0));
    result.append(C2.charAt(1));
    result.append(C3.charAt(2));
    System.out.println(result.toString());

  }
}


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

int main() 
{
    string str;
    cin>>str;
    int x=str.length();
    int p=x/2;
    int sum=0;
    for(int i=0;i<p;i++)
    {
      if(str[i]==str[x-i-1])
      {
        
      }
      else
      {
        sum++;
      }
    }
    cout<<sum;
}

Measured memory_bytes: 3596
N, K = gets.chomp.split(" ").map(&:to_i)
MOD = 10 ** 9 + 7

a = []
(1..Math.sqrt(N).floor).each{|i|
  a << [i, 0]
  a << [N / i, 0] if N / i != i
}
a = a.sort{|a, b| b[0] <=> a[0]}
b = 0
(a.size - 1).downto(0){|i|
  a[i][1] = a[i][0] - b
  b = a[i][0]
}
z = a.map{|e| e[1]}

bef = a.map{|e| [e[0], 0]}
bef[-1] = [1, 1]
K.times{|c|
  b = 0
  nxt = []
  bef.each_with_index{|e, idx|
    b = (b + e[1]) % MOD
    nxt.unshift([N / e[0], (b * z[idx]) % MOD])
  }
  bef = nxt
}

ans, b = [0, 0]
bef.sort{|a, b| b[0] <=> a[0]}.each_with_index{|e, idx|
  b += e[1]
  ans = (ans + b * a[idx][1]) % MOD
}

puts ans


Measured memory_bytes: 31064
//https://onlinejudge.u-aizu.ac.jp/challenges/sources/PCK/Prelim/0358?year=2017

#include <bits/stdc++.h>

using namespace std;

int main() {
    int x, y, price;
    cin >> x >> y >> price;

    if (x + y < price) {
        cout << "NA" << endl;
    } else if (x >= price) {
        cout << 0 << endl;
    } else {
        cout << price - x << endl;
    }
    return 0;
}

/*
 *
 */


Measured memory_bytes: 3072
from math import sqrt

def gcd(x, y):
    while y > 0:
        x, y = y, x%y
    return x
a,b = [int(i) for i in input().split()]

x = gcd(a,b)
res = 0
if (x % 2 == 0):
    res += 1
    while (x % 2 == 0):
        x = x / 2

k = int(sqrt(x)) + 1
for i in range(3, k, 2):
    if (x % i == 0):

        res += 1
        while (x % i == 0):
            x = x / i

if (x > 2):
    res += 1
print(res+1)

Measured memory_bytes: 39408
from collections import deque
import sys
q = int(input())

ans = []
A = deque()
for i in range(q):
    query = sys.stdin.readline()
    if query[:3] == '0 0':A.appendleft(query[4:])
    elif query[:3] == '0 1':A.append(query[4:])
    # if query[0] == '0':
    #     if query[2] == '0':A.insert(0, query[4:])
    #     else:A.append(query[4:])
    elif query[0] == '1':
        # ans.append(A[int(query[2:])])
        print(A[int(query[2:])].strip())
    elif query[:3] == '2 0':A.popleft()
    else:A.pop()
        # if query[2] == '0':A = A[1:]
        # else:A.pop()

# for i in ans:
#     print(i.strip())




Measured memory_bytes: 34676
#include <iostream>
#include <vector>
#include <utility>

using namespace std;

typedef pair<int, int> P_ii;
typedef pair<string, int> P_si;

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

    int n = N;
    int cnt = 0;
    while (n / 10 != 0) {
        cnt++;
        n /= 10;
        cerr << n << endl;
    }
    if (cnt <= 1) {
        cout << min(9, N) << endl;
    } else if (cnt <= 3) {
        cout << min(N-99+9, 909) << endl;
    } else if (cnt <= 5) {
        cout << min(N-9999+909, 90909) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define rep3(i, s, n) for (int i = s; i > (int)(n); i--)
#define all(obj) obj.begin(), obj.end()
#define from1(obj) obj.begin() + 1, obj.end()
#define db(x) cerr << #x << ":" << x << " "
#define dbl(x) cerr << #x << ":" << x << "\n"
#define dbp(p) cerr << #p << ":(" << p.first << ", " << p.second << ") "
#define dbpl(p) cerr << #p << ":(" << p.first << ", " << p.second << ")\n"
#define dbt3(t3) cerr << #t3 << ":(" << get<0>(t3) << ", " << get<1>(t3) << ", " << get<2>(t3) << ") "
#define dbt3l(t3) cerr << #t3 << ":(" << get<0>(t3) << ", " << get<1>(t3) << ", " << get<2>(t3) << ")\n"
#define dbt4(t4) cerr << #t4 << ":(" << get<0>(t4) << ", " << get<1>(t4) << ", " << get<2>(t4) << ", " << get<3>(t4) << ") "
#define dbt4l(t4) cerr << #t4 << ":(" << get<0>(t4) << ", " << get<1>(t4) << ", " << get<2>(t4) << ", " << get<3>(t4) << ")\n"
#define dbv(vec) cerr << #vec << ":{ "; for (auto e : vec) cerr << e << ", "; cerr << "}\n"
#define dbvv(vv) cerr << #vv << ":{\n"; for (auto vec : vv) { cerr << "{ "; for (auto e : vec) cerr << e << ", "; cerr << "}\n"; } cerr << "}\n"
#define dbm(map) cerr << #map << ":{ "; for (auto p : map) cerr << "(" << p.first << ", " << p.second << "), "; cerr << "}\n"
#define YN(f) cout << (f ? "YES" : "NO") << "\n"
#define Yn(f) cout << (f ? "Yes" : "No") << "\n"
#define yn(f) cout << (f ? "yes" : "no") << "\n"
using ll = long long;
using vi = vector<int>; using vl = vector<ll>; using vs = vector<string>; using vb = vector<bool>;
using vvi = vector<vi>; using vvl = vector<vl>; using vvb = vector<vb>;
using pii = pair<int, int>; using pil = pair<int, ll> ; using pll = pair<ll, ll>; using pli = pair<ll, int>;
using vpii = vector<pii>; using vpll = vector<pll>;
using ti3 = tuple<int, int, int>; using tl3 = tuple<ll, ll, ll>;
using ti4 = tuple<int, int, int, int>; using tl4 = tuple<ll, ll, ll, ll>;
using mii = map<int, int>; using mil = map<int, ll>; using mll = map<ll, ll>; using mli = map<ll, int>;

int main() {
	const int INF = 1e3 * 10;
	int H, W; cin >> H >> W;
	vvi c(10, vi(10));
	rep(i, 10) rep(j, 10) cin >> c[i][j];
	vvi A(H, vi(W));
	rep(i, H) rep(j, W) cin >> A[i][j];
	dbvv(A); dbvv(c);		
	rep(k, 10) {
		rep(j, 10) {
			rep (i, 10) {
				c[j][i] = min(c[j][i], c[j][k] + c[k][i]);	
			}
		}
	}
	int ans = 0;
	rep(i, H) rep(j, W) if (A[i][j] != -1) ans += c[A[i][j]][1];
	cout << ans << endl;
}

Measured memory_bytes: 384
# スペース区切りの整数の入力
N = int(input())


SP_list=[]

for i in range(N):
  S,P = map(str, input().split())
  SP_list.append([S,int(P),i+1])
  
SP_list.sort(key=lambda x:(x[0],-x[1]))

for i in range(N):
  print(SP_list[i][2])

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

int main() {
  vector<string> S = {"Sunny", "Cloudy", "Rainy"};
  string S_in;
  cin >> S_in;
  string S_out = (S_in == "Sunny") ? "Cloudy" : (S_in == "Cloudy") ? "Rainy" : "Sunny";
  cout << S_out << endl;
}


Measured memory_bytes: 256
#include<set>
#include<map>
#include<deque>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<complex>
#include<iostream>
#include<algorithm>
#define ll long long
#define __ %=Mod
using namespace std;

const int maxn = 110000;
const ll Mod = 1e9+7;

int n,m;
int a[maxn],b[maxn];
ll ca,cb;

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=m;i++) scanf("%d",&b[i]);
	
	for(int i=1;i<n;i++) (ca+=(ll)i*(n-i)%Mod*(a[i+1]-a[i])%Mod)__;
	for(int i=1;i<m;i++) (cb+=(ll)i*(m-i)%Mod*(b[i+1]-b[i])%Mod)__;
	printf("%lld\n",ca*cb%Mod);
	
	return 0;
}


Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"math/big"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	sum := big.NewInt(1)

	over := big.NewInt(1000000000)
	over.Mul(over, over)

	a := make([]int, N)
	for i := 0; i < N; i++ {
		a[i] = getInt()
		if a[i] == 0 {
			out(0)
			return
		}
	}
	for i := 0; i < N; i++ {
		b := big.NewInt(int64(a[i]))
		sum.Mul(sum, b)
		if sum.Cmp(over) > 0 {
			out(-1)
			return
		}
	}
	out(sum)
}


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

int gcd(int x,int y){
    if(y==0) return x;
    else return gcd(y,x%y);
}

int main(){
    int n; cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int ans=a[0];
    for(int i=1;i<n;i++){
        ans=gcd(ans,a[i]);
    }
    cout<<ans<<endl;
}

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

using namespace std;

int main(void) {
  string a, b; cin >> a >> b;
  a += b;

  int n = atoi(a.c_str());
  for (int i = 1; i*i <= n; i++) {
    if (i*i == n) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
function Main(input) {
  input = input.split("\n");
  var X = parseInt(input[0]);
  var ans = "Yes";
  if(X<30){
    ans = "No";
  }

  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 30336
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	float c=float(a)/b;
	if(a%b==0) cout<<c;
	else
	{
		int d=int(c)+1;
		cout<<d;
	}
 } 

Measured memory_bytes: 256
S = [int(i) for i in list(input())]

for i in range(2 ** 3):
    OP = ["-"] * 3
    for j in range(3):
        if (i >> j) & 1:
            OP[3 - 1 - j] = "+"

    formula = ""
    for num, op in zip(S, OP + [""]):
        formula += str(num) + op
    if eval(formula) == 7:
        print(formula + "=7")
        break


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<list>
#include<queue>
#include<string.h>
#include<functional>
#include<stack>
#include<deque>
#include<string>
#include<limits.h>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#define mod 100000
using namespace std;

int dp[2][1 << 19][2];//??????m-1??????JO????????£??????????????¨??????J???????????? ??????????????°?????°??????
string s[20];
int n, m;
signed main() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i++)cin >> s[i];
	dp[0][0][0] = 1;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			for (int x = 0; x < (1 << (m - 1)); x++) {
				dp[((i*m+j)+1) % 2][x][0] = dp[((i*m+j) + 1) % 2][x][1] = 0;
			}
			for (int k = 0; k < (1 << (m - 1)); k++) {
				for (int l = 0; l < 2; l++) {
					dp[(i*m+j)%2][k][l] %= mod;
					switch (s[i][j]) {
					case 'J':dp[((i*m+j) + 1) & 1][(k << 1) % (1 << (m - 1))][1] += dp[(i*m+j) % 2][k][l]; break;
					case 'O':if (!l||j == 0) {
						dp[((i*m+j) + 1) & 1][(k << 1) % (1 << (m - 1))][0] += dp[(i*m + j) % 2][k][l];
					}
							 else {
								 dp[((i*m+j) + 1) & 1][(k << 1) % (1 << (m - 1)) + 1][0] += dp[(i*m+j) % 2][k][l];
							 }break;
					case 'I':
						if (j + 1 == m) {
							dp[((i*m+j) + 1) & 1][(k << 1) % (1 << (m - 1))][0] += dp[(i*m+j) % 2][k][l];
						}
						else {
							if ((k & (1 << (m - 2))) == 0) {
								dp[((i*m+j) + 1) & 1][(k << 1) % (1 << (m - 1))][0] += dp[(i*m+j) % 2][k][l];
							}
						}
						break;
					case '?':
						dp[((i*m+j) + 1) & 1][(k << 1) % (1 << (m - 1))][1] += dp[(i*m+j) % 2][k][l];
						if (!l||j==0) {
							dp[((i*m+j) + 1) & 1][(k << 1) % (1 << (m - 1))][0] += dp[(i*m + j) % 2][k][l];
						}
						else {
							dp[((i*m+j) + 1) & 1][(k << 1) % (1 << (m - 1)) + 1][0] += dp[(i*m+j) % 2][k][l];
						}
						if (j + 1 == m) {
							dp[((i*m+j) + 1) & 1][(k << 1) % (1 << (m - 1))][0] += dp[(i*m+j) % 2][k][l];
						}
						else {
							if ((k & (1 << (m - 2))) == 0) {
								dp[((i*m+j) + 1) & 1][(k << 1) % (1 << (m - 1))][0] += dp[(i*m+j) % 2][k][l];
							}
						}break;
					}
				}
			}
		}
	}
	int ans = 1;
	for (int i = 0; i < n; i++) {
		for (char j : s[i]) {
			if (j == '?') {
				ans = ans * 3 % mod;
			}
		}
	}
	for (int i = 0; i < (1 << (m - 1)); i++) {
		ans -= dp[n*m % 2][i][0] + dp[n*m % 2][i][1];
		ans %= mod;
	}
	ans %= mod;
	if (ans < 0)ans += mod;
	printf("%d\n", ans);
}

Measured memory_bytes: 11400
#include <stdio.h>

int main()
{
    int i, max, min, size;
    double sum=0;
    scanf("%d", &size);
    int arr[size];

    for(i=0; i<size; i++)
    {
        scanf("%d", &arr[i]);
    }

    max = -9999999999;
    min=9999999999;

    for(i=0; i<size; i++)
    {
        if(arr[i] > max)
        {
            max = arr[i];
        }

        if(arr[i] < min)
        {
            min = arr[i];
        }
        sum=sum+arr[i];
    }

    printf("%d %d %.0lf\n",min,max,sum);

    return 0;
}



Measured memory_bytes: 2084
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a,b;
    while(~scanf("%d%d",&a,&b))
    {
        if(a==2&&b==2)
            printf("Yes\n");
        else if(a==2||b==2)
            printf("No\n");
        else  if((a==1||a==3||a==5||a==7||a==8||a==10||a==12
                 )&&(b==1||b==3||b==5||b==7||b==8||b==10||b==12))
            printf("Yes\n");
        else if((a==4||a==6||a==9||a==11)
                &&(b==4||b==6||b==9||b==11))
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
n,m = map(int,input().split())
arr = []
for i in range(m):
	ls = list(map(int,input().split()))+[i]
	arr.append(ls)

arr.sort(key=lambda x:x[1])

def st(a):
	b = list(str(a))
	while len(b) <= 5:
		b.insert(0,'0')
	c= ''.join(b)
	return c

dic = {}
for j in range(m):
	if arr[j][0] in dic:
		dic[arr[j][0]] += 1
		arr[j] += [dic[arr[j][0]]]
	else:
		dic[arr[j][0]] = 1
		arr[j] += [dic[arr[j][0]]]

arr.sort(key=lambda x:x[2])

for y in range(m):
	print('{}{}'.format(st(arr[y][0]), st(arr[y][3])))




Measured memory_bytes: 35604
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int S = sc.nextInt();
		int W = sc.nextInt();
		if (S > W) {
			System.out.println("safe");
		} else {
			System.out.println("unsafe");
		}
	}

}

Measured memory_bytes: 35748
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e18;
int mod = 998244353;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int D,T,S;
    cin >> D >> T >> S;
    if(D <= T*S) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i < n; i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define P pair<int, int>
typedef long long ll;
const ll mod = 1e9+7;

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//ngcd n個の最大公約数
ll ngcd(vector<ll> a){
  ll res;
  res = a[0];
  for(ll i = 1; i < a.size() && res != 1; i++) {
    res = gcd(a[i], res);
  }
  return res;
}
//nlcm n個の最小公倍数
ll nlcm(vector<ll> a) {
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size(); i++) {
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(ll x){
  ll i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
ll digsum(ll x){
  ll res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}

int main(){
  string s, t;
  cin >> s >> t;
  sort(all(s));
  sort(rall(t));
  if(s < t) cout << "Yes" << endl;
  else cout << "No" << endl;

}



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

pate, slice = [1], [1]
for _ in range(n + 1):
    pate.append(2 * pate[-1] + 1)
    slice.append(2 * slice[-1] + 3)

ans = 0
while n * x > 0:
    if x >= slice[n - 1] + 2:
        ans += pate[n - 1] + 1
        x -= slice[n - 1] + 2
    elif x < slice[n - 1] + 2:
        x -= 1
    n -= 1
print(ans + (x > 0))


Measured memory_bytes: 9116
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {

    void solve() throws IOException {
        int n = ni();

        out.println(n * 800 - 200 * (n / 15));
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 22484
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);i++)
#define erep(i,a,b) for(int i=a;i<=(int)(b);i++)
#define per(i,a,b) for(int i=(b)-1;i>(a);i--)
#define eper(i,a,b) for(int i=((int)(a));i>=b;i--)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
using namespace std;
typedef long long ll;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}

bool card[100][100]; 
char c[] = {'S', 'H', 'C', 'D'};
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    int n; cin >> n;
    rep(i, 0, 4) {
        erep(j, 1, 13) {
            card[i][j] = false;
        }
    }
    rep(i, 0, n) {
        char s; int x;
        cin >> s >> x;
        rep(j, 0, 4) 
            if (s == c[j]) 
                card[j][x] = true;
    }
    rep(i, 0, 4) {
        erep(j, 1, 13) {
            if (!card[i][j])
                printf("%c %d\n", c[i], j);
        }
    }
    return 0;
}


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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(ll i = (m); i < (n); ++i)

#define INF 1e9

int main(){
  int N;
  cin >> N;
  vector<int> D(N);
  map<int, int> mp;
  REP(i, N){
    cin >> D[i];
    mp[D[i]]++;
  }
  int M;
  cin >> M;
  vector<int> T(M);
  REP(i, M){
    cin >> T[i];
  }

  REP(i, M){
    if(mp[T[i]] == 0){
      cout << "NO" << endl;
      return 0;
    }
    mp[T[i]]--;
  }
  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 11136
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  
  int a[m],b[m];
  rep(i,m){
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
  }
  
  vector<vector<int>> G(n);
  rep(i,m){
    G[a[i]].push_back(b[i]);
    G[b[i]].push_back(a[i]);
  }

  rep(i,G[0].size()){
    int to = G[0][i];
    if(to == n-1){
      cout << "POSSIBLE" << endl;
      return 0;
    }else{
      rep(j,G[ to ].size()){
        if(G[to][j] == n-1){
          cout << "POSSIBLE" << endl;
          return 0;
        }
      }
    }
  }
  
  cout << "IMPOSSIBLE" << endl;
  
  return 0;
}
  
  
  

Measured memory_bytes: 13552
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

#define MAX_N 100000

vector<int> G[MAX_N];
int depth[MAX_N];
int outdeg[MAX_N];
vector<pair<int,int>> ans;

void dfs(int v, int pre){
    for(auto to : G[v]){
        if(depth[to] == -1){
            depth[to] = depth[v] + 1;
            dfs(to, v);
        }else{
            if(depth[to] > depth[v]){
                ans.emplace_back(v, to);
                outdeg[v]++;
            }
        }
    }
    if(pre == -1) return;
    if(outdeg[v] % 2 == 1){
        ans.emplace_back(v, pre);
        outdeg[v]++;
    }else{
        ans.emplace_back(pre, v);
        outdeg[pre]++;
    }
}

signed main(){
    int n,m;
    cin >> n >> m;
    int a,b;
    rep(i,m){
        cin >> a >> b;
        a--;
        b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }
    if(m % 2 == 1){
        cout << -1 << endl;
        return 0;
    }
    fill(depth, depth + n, -1);
    depth[0] = 0;
    dfs(0, -1);
    rep(i,ans.size()){
        cout << ans[i].first + 1 << " " << ans[i].second + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 14836
int main(void){
  int i;
  char map[3][4],op;

  while(1){
    for(i=0;i<3;i++){
      scanf("%s",map[i]);
      if(map[i][0]=='0') return 0;
    }

    op = 0;
    if(map[0][0]!='+' && map[0][0]==map[1][1] && map[1][1]==map[2][2]) op=map[0][0];
    if(map[0][2]!='+' && map[0][2]==map[1][1] && map[1][1]==map[2][0]) op=map[1][1];
    for(i=0;i<3;i++){
      if(map[i][0]!='+' && map[i][0]==map[i][1] && map[i][1]==map[i][2]) op=map[i][0];
      if(map[0][i]!='+' && map[0][i]==map[1][i] && map[1][i]==map[2][i]) op=map[0][i];
    }
    if(op==0) printf("NA\n");
    else if(op=='w') printf("w\n");
    else printf("b\n");
  }

  return 0;
}

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

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

  int i = 0, j = (int)S.size() - 1;
  while (S[i] != 'A') i++;
  while (S[j] != 'Z') j--;

  cout << j - i + 1 << endl;
  return 0;
}

Measured memory_bytes: 640
N = int(input())
A = list(map(int, input().split()))

cnt = [0] * (2*(10 ** 5) + 10) 
for i in range(N):
    if A[i]+i >= 2*(10 ** 5):
        continue
    cnt[A[i]+i] += 1

ans = 0
for i in range(N)[1:]:
    if A[i]-i >= 0:
        continue
    ans += cnt[abs(A[i]-i)]

print(ans)

Measured memory_bytes: 32284
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
int main(){
    int n,a,b,c;cin >> n >> a >> b >> c;
    vector<int> l(n);
    for(int i=0;i<n;i++) cin >> l[i];
    
    int ans=INF;
    for(int bit1=0;bit1<(1<<n);bit1++){
        vector<int> b2;
        int sum1=0;
        int cnt1=0;
        for(int i=0;i<n;i++){
            if((bit1>>i)&1){
                sum1+=l[i];
                cnt1++;
            }
            else b2.push_back(l[i]);
        }
        if(cnt1==0) continue;
        int needA=abs(a-sum1)+10*(cnt1-1);
        int n2=b2.size();
        for(int bit2=0;bit2<(1<<n2);bit2++){
            vector<int> b3;
            int sum2=0;
            int cnt2=0;
            for(int j=0;j<n2;j++){
                if((bit2>>j)&1){
                    sum2+=b2[j];
                    cnt2++;
                }
                else b3.push_back(b2[j]);
            }
            if(cnt2==0) continue;
            int needB=abs(b-sum2)+10*(cnt2-1);
            int n3=b3.size();
            for(int bit3=0;bit3<(1<<n3);bit3++){
                int sum3=0;
                int cnt3=0;
                for(int k=0;k<n3;k++){
                    if((bit3>>k)&1){
                        sum3+=b3[k];
                        cnt3++;
                    }
                }
                if(cnt3==0) continue;
                int needC=abs(c-sum3)+10*(cnt3-1);
                ans=min(ans,needA+needB+needC);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;

int main(){
	cin.tie(0);					//cinとcoutの結び付きを解除
	ios::sync_with_stdio(false);//stdioとの同期を解除
	
	int n;
	cin >> n;
	
	int a,b,c,d;
	bool ans = false;
	
	a = n / 1000;
	b = (n - a*1000) / 100;
	c = (n - a*1000 - b*100) / 10;
	d = n - a*1000 - b*100 - c*10;
	
	/*
		abc
		 bcd
	*/
	if (a == b && a == c) ans = true;
	if (b == c && b == d) ans = true;
	
	if (ans == true){
		cout << "Yes";
	}else{
		cout << "No";
	}
	
	return 0;
	
}


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

int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a+b==c+d) cout<<"Balanced";
    else if(a+b>c+d)
    cout<<"Left";
    else
    cout<<"Right";
    return 0;
}

Measured memory_bytes: 256
// abc170_a
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF (ll)(1e9)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    vector<int> x(5);
    REP(i, 5) cin >> x[i];

    REP(i, 5){
        if (x[i] == 0){
            print(i+1);
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 3648
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

N = ii()

dev = sum(list(map(int, list(str(N)))))

if N % dev:
    print('No')
else:
    print('Yes')



Measured memory_bytes: 3064