akhauriyash/Code-Regression huggingface dataset:
/*氏名：保坂優介, 学籍番号：200441141
  概要：チェック模様を描く*/

#include<stdio.h>

int main(void)
{
    int i, j, H, W;     //変数の宣言

    scanf("%d %d", &H, &W);//入力

    while (H * W != 0)
    {
        for (i = 0; i < H; i++)        //0 0が入力されるまで繰り返す
        {
            for (j = 0; j < W; j++)
            {
                if (i % 2  == j % 2)
                {
                    printf("#");
                }

                else
                {
                    printf(".");
                }
            }
            
            printf("\n");
        }

        printf("\n");       //改行

        scanf("%d %d", &H, &W);     //入力


    }

    return 0;
}


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

int main(){
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int kk=0;
    while(b<=a){
        b*=2;
        kk++;
    }
    while(c<=b){
        c*=2;
        kk++;
    }
    if(kk<=k) cout<<"Yes";
    else cout<<"No";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3620
fun main(args : Array<String>) {
    val n = readLine()!!.toInt()
    val aa = readLine()!!.split(" ").map { it.toInt() }
    val pairs = mutableSetOf<Int>()

    aa.forEachIndexed { index, i ->
        if (aa[i-1] == index + 1) {
            pairs.add(index + 1)
            pairs.add(i)
        }
    }

    println(pairs.size / 2)
}

Measured memory_bytes: 58092
//#include <tourist>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
struct edge {
    int to, cost;
};
ll n, W;
vector<ll> w(100), v(100);
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>W;
    for (int i = 0; i < n; i++)
    {
        cin >> w[i]>>v[i];
    }
    ll dp[n+1][100001];
    for(int i=0;i<=100000;i++){
        for(int j=0;j<=n;j++)
            dp[j][i]=INF;
    }
    dp[0][0]=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<=100000;j++){
            dp[i+1][j]=min(dp[i][j],dp[i+1][j]);
            if(j+v[i]<=100000){
                dp[i+1][j+v[i]]=min(dp[i+1][j+v[i]],dp[i][j]+w[i]);
            }
        }
    }
    /*
    for(int i=0;i<=100;i++){
            cout<<dp[n][i]<<"\n";
    }
    */
    for(int i=100000;i>=0;i--){
        if(dp[n][i]<=W){
            cout<<i<<"\n";
            return 0;
        }
    }
}



Measured memory_bytes: 79232
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)
#define INF 1<<29;

int main()
{
    int n,k;
    cin >> n >> k;
    vector<int> x(n);
    rep(i,n) cin >> x[i];
    
    int p = n;
    rep(i,n)
        if(x[i] >= 0)
        {
            p = i;
            break;
        }

    int d[2][k];
    rep(i,2) rep(j,k) d[i][j] = INF;

    for(int i=p;i<min(n,p+k);++i)
        d[1][i-p] = x[i];
    for(int i=p-1;i>=max(0,p-k);--i)
        d[0][p-1-i] = -x[i];

    int min_d = INF;
    rep(i,k+1)
    {
        int tmp_d = 0;
        if(i > 0) tmp_d += d[0][i-1];
        if(i < k) tmp_d += d[1][k-i-1];
        if(i > 0 && i < k) tmp_d += min(d[0][i-1], d[1][k-i-1]);
        min_d = min(tmp_d, min_d);
    }

    cout << min_d << endl;
    return 0;
}

Measured memory_bytes: 1408
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

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

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        s: chars
    }
    let mut g = 0;
    let mut p = 0;
    for c in s {
        if c == 'g' {
            g += 1;
        } else {
            p += 1;
        }
    }
    println!("{}", (g - p) / 2);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int N,M;
P job[100100]; 
set<int> s;
int main(){
	cin >> N >> M;
	for(int i=0;i<N;i++){
		cin >> job[i].sec >> job[i].fi;
	}
	sort(job,job+N,greater<P>());
	for(int i=0;i<M;i++){
		s.insert(i);
	}
	int ans = 0;
	for(int i=0;i<N;i++){
		int b = M-job[i].sec;
		set<int>::iterator it = s.upper_bound(b);
		if(it!=s.begin()){
			it--;
			ans += job[i].fi;
			s.erase(it);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5760
# include <bits/stdc++.h>
# 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 ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 1LL << 60;

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

uintmax_t combination(unsigned int n, unsigned int r) {
  if ( r * 2 > n ) r = n - r;
  uintmax_t dividend = 1;
  uintmax_t divisor  = 1;
  for ( unsigned int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}

int modPow(long long a, long long n, long long p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
  long long t = modPow(a, n / 2, p);
  return (t * t) % p;
}

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

int main()
{
    ll n,y;
    cin >> n >> y;
    ll p = y/10000 + 1;
    ll q;
    ll a1,a2,a3;
    bool ans = false;

    rep(i,p){
        for(int j = 0; j <= n -i; j++){
            q = 10000*i + 5000*j + 1000*(n-i-j);
            if(q == y){
                a1 = i;
                a2 = j;
                a3 = n-i-j;
                ans = true;
                break;
            }
        }
        if(ans) break;
    }

    if(ans) cout << a1 << " " << a2 << " " << a3 << endl;
    else cout << "-1 -1 -1" << endl;
 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,x;
    cin>> n >> x;
    int u[n];
    for(int a=0;a<n;a++) cin>> u[a];
    sort(u,u+n);
    int cnt=0,a=0;
    while(a<n){
        if(x<u[a]) break;
        cnt++,x-=u[a];
        a++;
    }
    if(x>0 && a==n) cnt--;
    cout<< cnt <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
int main(){ 
    int n;
    cin>>n;
    string s;
    cin>>s;
    int a=0;
    int b=0;
    for(int i=0;i<n;i++){
    if(s[i]=='I'){
        a++;
    }else{
        a--;
    }
    b=max(a,b);
    }
    cout<<b;
    return 0;
}


Measured memory_bytes: 256
//psudora
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define mod 1000000007
#define fast ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)

int main(){
	 int x;
 scanf("%d",&x);
 int c500 = x/500; 
 int r500 = x%500; 
 int c5 = r500/5; 
 printf("%d\n",c500*1000+c5*5);
 }


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <bitset>
#include <stack>

typedef long long ll;

int main(int argc, char* argv[])
{
  ll n, m;
  std::cin >> n >> m;

  ll count = m >= n * 2 ? n : m / 2;
  n -= count;
  m -= count * 2;

  std::cout << count + m / 4 << std::endl;
  return 0;
}


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

using namespace std;
const int maxn = 500010, inf = 1e9 + 233;
int n, T;
int a[maxn], mn[maxn];

int main()
{
	scanf("%d%d", &n, &T);
	
	for (int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	
	mn[0] = inf;
	for (int i = 1; i <= n; i++)
		mn[i] = min(mn[i - 1], a[i]);
		
	int mx = 0;
	for (int i = 2; i <= n; i++)
		mx = max(mx, a[i] - mn[i - 1]);
		
	int ans = 0;
	for (int i = 2; i <= n; i++)
	{
		if (a[i] - mn[i - 1] == mx) ans++;
		//printf("%d %d\n", a[i], mn[i - 1]);
	}
		
	printf("%d\n", ans);
}

Measured memory_bytes: 4460
# https://atcoder.jp/contests/abc138/tasks/abc138_c
# その時点で一番価値の低い2つを消費して新たに錬成するのが一番良さそう
# 価値が高いものを何回も割ってしまうと価値がどんどん下がるので。

N = int(input())
V = list(map(int, input().split()))

while len(V) > 1:
    V.sort(reverse=True)
    new = (V[-1] + V[-2]) / 2
    V = V[:-2]
    V.append(new)

print(V[0])


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using pp=pair<ll,pair<int,int>>;
using Graph=vector<vector<pair<int,ll>>>;

int main(){
  int N;
  cin>>N;
  vector<int> A(N);
  map<int,int> m;
  for(int i=0;i<N;i++){
    cin>>A.at(i);
    m[A.at(i)]++;
  }
  sort(A.begin(),A.end());
  reverse(A.begin(),A.end());

  int ans=0;
  for(int i=0;i<N;i++){
    if(m[A.at(i)]>0){
      int n=1;
      while(n<=A.at(i)){
        n<<=1;
      }
      if(m[n-A.at(i)]>0&&A.at(i)!=n-A.at(i)){
        ans++;
        m[A.at(i)]--;
        m[n-A.at(i)]--;
      }else if(m[n-A.at(i)]>=2){
        ans++;
        m[A.at(i)]-=2;
      }
    }
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 19712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
const ll INF=1e15+7;
const ll N = 87;
ll r[N],n;

int main(){
	cin>>n;
	r[0]=2;
	r[1]=1;
	FOR(i,2,N){
		r[i]=r[i-1]+r[i-2];
	}
	cout<<r[n]<<endl;
	return 0;
}

Measured memory_bytes: 256
/******techknight@3******/
#include<bits/stdc++.h>
using namespace std;
#define lld               long long int
#define ld                long double
#define pb                push_back
#define ppb               pop_back
#define mp                make_pair
#define F                 first
#define S                 second
#define nl                '\n'
#define all(c)            (c).begin(),(c).end()
#define rall(c)           (c).rbegin(),(c).rend()
#define sz(c)             (c).size()
#define tr(x,a)           for(auto &a : x)
#define psnt(x,a)         (x).find(a)!=(x).end()
#define vpsnt(x,a)        find(all(x),a)!=(x).end()
#define lexichar(x,y)     lexicographical_compare(x,x+strlen(x),y,y+strlen(y)) //modify the ranges
#define lexistr(x,y)      lexicographical_compare(x.begin(),x.end(),y.begin(),y.end()) 
#define MOD               1000000007
#define pi                3.1415926536
#define tod               1
#define itr(i,a,b)        for(lld i=a;i<=b;i++)
#define itrn(i,a,b)       for(lld i=a;i>=b;i--)
#define iot(n)            for(lld i=0;i<n;i++)
#define pls(n,arr)        lld arr[n]; iot(n)  cin>>arr[i];
#define bye               fflush(stdout)

typedef pair<lld,lld>     pii;
typedef pair<string,lld>  psi;
template <typename T>
bool mycomp(T x,T y){ 
   return (x==y);  //give your condition here
}
bool paircomp(const pair<lld,lld> &x,const pair<lld,lld> &y){ 
return x.second<y.second;
}

int main(){
       ios_base::sync_with_stdio(false);
             cin.tie(0);
            cout.tie(0);
      lld t=1; //cin>>t;  
      while(t--){
          lld a,b; cin>>a>>b;
           cout<<a*b<<nl;
      }
}



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

int main(){
  int n;
  cin >> n;
  int x[n];
  for(int i=0;i<n;i++){
    cin >> x[i];
  }
  
  int cnt=0;
  for(int j=0;j<n-2;j++){
    if(x[j]<x[j+1] && x[j+1]<x[j+2]){
      cnt++;
    }else if(x[j+2]<x[j+1] && x[j+1]<x[j]){
      cnt++;
    }
  }
  
  cout << cnt;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vout(v) VOUT(v,z);
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL);
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) { a = b; return true; }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) { a = b; return true; }
    return false;
}


void solve_WA(long long N, long long M, std::vector<long long> a){
    ll lcm_val=a[0];
    for (ll i = 1; i < N; i++) {
        lcm_val = lcm(a[i], lcm_val);
    }
    // debg(lcm_val);
    ll cnt_tmp = M*2 / lcm_val;
    // debg(cnt_tmp);
    ll cnt = (cnt_tmp + 2 - 1) / 2;
    cout << cnt << "\n";
}

void solve_WA2(long long N, long long M, std::vector<long long> a){
    ll lcm_val=a[0];
    for (ll i = 1; i < N; i++) {
        lcm_val = lcm(a[i], lcm_val);
    }
    // debg(lcm_val);
    ll cnt_tmp = M / (lcm_val/2);
    // debg(cnt_tmp);
    ll cnt = (cnt_tmp + 2 - 1) / 2;
    cout << cnt << "\n";
}

void solve(long long N, long long M, std::vector<long long> a){
    ll lcm_val=a[0]/2;
    for (ll i = 1; i < N; i++) {
        lcm_val = lcm(a[i]/2, lcm_val);
    }
    // debg(lcm_val);
    ll cnt_tmp = M / lcm_val;
    // debg(cnt_tmp);

    for (ll i = 0; i < N; i++) {
        if((lcm_val/(a[i]/2))%2==0){
            cout << 0 << "\n";
            return;
        }
    }

    ll cnt = (cnt_tmp + 2 - 1) / 2;
    cout << cnt << "\n";
}

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


Measured memory_bytes: 1024
import sys
import itertools
import numpy as np


read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, M, Q = map(int, readline().split())
A = np.array(list(itertools.combinations_with_replacement(range(1, M + 1), N)))
n = len(A)
score = np.zeros(n, np.int32)
m = map(int, read().split())
for a, b, c, d in zip(m, m, m, m):
    cond = A[:, b - 1] - A[:, a - 1] == c
    score += d * cond
print(score.max())


Measured memory_bytes: 46768
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
typedef long long ll ;
int main() {
 
  int N ;
  cin >> N ;
  //map型で出現回数を記録する．
  map<string,int> mp ;
  rep(i,N){
    string S ;
    cin >> S ;
    mp[S] = mp[S] + 1 ;
  }
  int count = 0 ;
  //出現した回数の最大値をcountに入れる．
  //入力1ならcountは2になる．
  //入力2ならcountは8になる．
  for(auto p : mp){
    auto A = p.second ;
    count = max(count,A) ;
  }
  vector<string> vec ;
  //出現した回数の最大値が同じものをvecに入れる．
  //入力1ならvecにbeetとvet が入る．
  //入力2ならbuffaloが入る.  
  for(auto p : mp){
    auto B = p.first ;
    auto C = p.second ;
    if(C == count) vec.push_back(B) ;//その文字が出現した回数と最大値が同じならvecに入れる
  }
  //辞書順になるようにsortする．
  sort(vec.begin(),vec.end());
  rep(i,vec.size()) cout << vec.at(i) << endl;
}

Measured memory_bytes: 26868
a,b,c,x,y=map(int,input().split())
num1=a*x+b*y
if x>y:
    num2=c*y*2+a*(x-y)
else:
    num2=c*x*2+b*(y-x)
num3=max(x,y)*c*2
print(min(num1,num2,num3))


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
long double dp[310][310][310];
int a[3],n;
int main(){
	cin>>n;
	rep(i,n){
		int x;
		cin>>x;
		x--;
		a[x]++;
	} 
	rep(i,301)
	rep(j,301)
	rep(k,301){
				long double tot=i+j+k;
				if(!tot)
				continue;
				if(k)
				dp[k][j][i]+=dp[k-1][j][i]*k/(long double)(n);
				if(j)
				dp[k][j][i]+=dp[k+1][j-1][i]*j/(long double)(n);
				if(i)
				dp[k][j][i]+=dp[k][j+1][i-1]*i/(long double)(n);
				dp[k][j][i]=(dp[k][j][i]+1)*(long double)(n)/tot;
			}
	
	cout<<fixed<<setprecision(10)<<dp[a[0]][a[1]][a[2]];
	re 0;
}



Measured memory_bytes: 452864
#include<bits/stdc++.h>
using namespace std;
#define ll long long
vector<int>q[200000];
int color[200000];
int flag[200000];
int n,m;
int v[200000],d[200000],c[200000];
void dfs(int x,int cnt,int c)
{
   if(!color[x])
   {
       color[x]=c;
   }
   if(flag[x]>=cnt)
   {
       return;
   }
   if(cnt==0)
   {
       return;
   }
   flag[x]=cnt;
   for(int u:q[x])
   {
       dfs(u,cnt-1,c);
   }
}
int main()
{
    std::ios::sync_with_stdio(false);
    cin>>n>>m;
    for(int i=1;i<=m;i++)
    {
        int x,y;
        cin>>x>>y;
        q[x].push_back(y);
        q[y].push_back(x);
    }
    int q;
    cin>>q;
    for(int i=1;i<=q;i++)
    {
       cin>>v[i]>>d[i]>>c[i];
    }
    for(int i=q;i>=1;i--)
    {
        dfs(v[i],d[i],c[i]);
    }
    for(int i=1;i<=n;i++)
    {
        cout<<color[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 11896
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int M = scan.nextInt();
        int[] L = new int[M];
        int[] R = new int[M];
        int minL = 0;
        int minR = N;
        for (int i = 0; i < M; i++) {
            L[i] = scan.nextInt();
            R[i] = scan.nextInt();
            minL = Math.max(minL, L[i]);
            minR = Math.min(minR, R[i]);
        }
        System.out.println(Math.max(minR - minL + 1, 0));
    }
}


Measured memory_bytes: 74960
import java.util.Scanner;

class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		long N = sc.nextLong(),
				x = 1,
				y = 1,
				max_p=2;
		boolean f=false;
		for(int i=1;i<=(long)Math.pow(N, 0.5);i++) {
			if(N%i==0) {
				max_p = i;
				f=true;
			}
		}
		x=max_p-1;
		y=N/max_p-1;
		System.out.println(f?x+y:N-1);
	}
}

Measured memory_bytes: 23892
#include<stdio.h>
int main(void)
{
	char ch[1001];
	int sum,i;
	while(1){
		scanf("%s",ch);
		if(ch[0] == '0') break;
		sum = 0; i = 0;
		while(ch[i]){
		sum += ch[i] - '0';
		i++;
		}
		printf("%d\n",sum);
	}
	return 0;
}

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

int main() {
    // input
    int N, M;
    cin >> N;
    vector<int> T(N);
    int sum = 0;
    for (int i = 0; i < N; ++i) {
        cin >> T[i];
        sum += T[i];
    }
    cin >> M;

    // solve & output
    int ans = 0;
    for (int i = 0; i < M; ++i) {
        int P, X;
        cin >> P >> X;
        if (T[P - 1] > X) ans = sum - abs(T[P - 1] - X);
        else ans = sum + abs(T[P - 1] - X);
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    vector<bool> flags(10000000,false);
    for(int i=0;i<n;i++){
        cin>>a[i];
        flags[a[i]]=true;
    }
    sort(a.begin(),a.end());
    for(int now=a[0];now<1000005;){
        now+=a[0];
        flags[now]=false;
    }
    for(int i=1;i<n;i++){
        int now=a[i];
        if(now==a[i-1]){
            flags[now]=false;
            continue;
        }
        while(now<1000005){
            now+=a[i];
            flags[now]=false;
        }
    }
    int ans=0;
    for(int i=0;i<1000005;i++){
        if(flags[i]) ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 5368
//By solving easier problem to solve harder problem
#include<iostream>
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
const int maxn = 2e5 + 10;
int n;
ll a[maxn], sum[maxn];

int main()
{
	cin>>n;
	for(int i=1; i<=n; i++) cin>>a[i], sum[i] = sum[i-1] + a[i];
	long long ans = 1e15;
	int l = 1, r = 3;
	for(int i=2; i<n-1; i++) {
		while(sum[l] < sum[i] - sum[l] && l < i-1) l++;
		while(sum[r] - sum[i] < sum[n] - sum[r] && r < n) r++;
		if(sum[l-1] > sum[i] - sum[l]) l--;
		if(sum[r-1] - sum[i] > sum[n] - sum[r]) r--;
		ans = min(ans, max(max(max(sum[i] - sum[l], sum[r] - sum[i]), sum[l]), sum[n] - sum[r]) - min(min(min(sum[l], sum[i] - sum[l]), sum[r] - sum[i]), sum[n] - sum[r]));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
using namespace std;
int main(){
  string s;
  cin >> s;
  if(s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I')cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
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 main(){
  while(1){
    int t, h;
    int sumt=0; //taro
    int sumh=0; //hanako
    cin >> t >> h;
    if(t==0&&h==0) break;
    int tcard[100]={0};
    int hcard[100]={0};
    REP (i,t) {
      cin >> tcard[i];
      sumt += tcard[i];
      //      cout << sumt << endl;//debug
    }
    REP (j,h){
      cin >> hcard[j];
      sumh += hcard[j];
      //      cout << sumh << endl;//debun
    }

    int a=100,b=100;
    bool was = false;

    REP(k,t){
      REP(l,h){
	if(((sumt-tcard[k]+hcard[l])==(sumh+tcard[k]-hcard[l])) && (tcard[k]+hcard[l] < a+b)){
	  a=tcard[k];
	  b=hcard[l];
	  was = true;
	  //	  cout << a << " " << b << endl;
	}
      }
    }
    if(was){
      cout << a << " "<< b << endl;
    }else{
      cout << "-1" <<endl;
    }
  }
}

Measured memory_bytes: 1160
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

ostream& operator <<(ostream& out, const pair<int, int>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const set<T>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

int main() {
  int64 n, m = 1;
  cin >> n;
  int64 ret = 0;
  while (n) {
    ret += m;
    n /= 2;
    m *= 2;
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll n;
int main()
{
	scanf("%lld",&n);
	for(int i=1;i<=3500;i++)
		for(int j=1;j<=3500;j++)
		{
			ll a=4ll*i*j-n*j-n*i,b=n*i*j;
			if(a<=0)continue;

			if(b%a==0)
			{
				printf("%d %d %lld\n",i,j,b/a);
				exit(0);
			}
		}
	return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int k = in.nextInt();

            for (int i = 0; i < k; i++) {
                if ((i & 1) == 0) {
                    a = a >> 1;
                    b += a;
                } else {
                    b = b >> 1;
                    a += b;
                }
            }

            out.printf("%d %d\n", a, b);
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public long nextLong() {
            long n = 0;

            int b = readByte();
            while (isSpaceChar(b))
                b = readByte();

            boolean minus = (b == '-');
            if (minus)
                b = readByte();

            while (b >= '0' && b <= '9') {
                n *= 10;
                n += b - '0';
                b = readByte();
            }

            if (!isSpaceChar(b))
                throw new NumberFormatException();

            return minus ? -n : n;
        }

        public int nextInt() {
            long n = nextLong();

            if (n < Integer.MIN_VALUE || n > Integer.MAX_VALUE)
                throw new NumberFormatException();

            return (int) n;
        }

    }
}



Measured memory_bytes: 22996
#include <iostream>
#include <algorithm>
#include <vector>

int main(){
	int n, m;
	while(std::cin >> n >> m, n){
		int total = 0;
		std::vector<int> pvec;
		for(int i=0;i<n;i++){
			int p;
			std::cin >> p;
			pvec.push_back(p);
			total += p;
		}

		std::sort(pvec.begin(), pvec.end(), std::greater<int>());

		int i = 1, discount = 0;
		for(;i*m<=n;i++){
			discount += pvec[i*m-1];
		}
	
		std::cout << total - discount << std::endl;
	}
}

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

#define INF 1145141919
using LL = long long int;
#define II pair<int, int>

using namespace std;

string S;

int main()
{
  cin >> S;

  int ans = 0;
  int L = 0, R = S.length()-1;

  while(L < R) {
    if(S[L] != S[R] && S[L] != 'x' && S[R] != 'x') {
      cout << -1 << endl;
      return 0;
    }
    else if(S[L] == S[R]) {
      L++; R--;
    }
    else if(S[L] == 'x') {
      ans++;
      L++;
    }
    else if(S[R] == 'x') {
      ans++;
      R--;
    }
  }

  cout << ans << endl;

  return 0;
}


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

const ll MOD = 1e9 + 7;

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<ll> x(n), y(m);
    rep(i, n) cin >> x[i];
    rep(i, m) cin >> y[i];
    ll multiplier = -n + 1;
    ll acc_X = 0;
    rep(i, n) {
        acc_X = (acc_X + multiplier * x[i]) % MOD;
        multiplier += 2;
    }
    multiplier = -m + 1;
    ll acc_Y = 0;
    rep(i, m) {
        acc_Y = (acc_Y + multiplier * y[i]) % MOD;
        multiplier += 2;
    }
    ll ans = (acc_X * acc_Y) % MOD;
    if (ans < 0) ans += MOD;
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <memory>
#include <vector>
class Suspect {
public:
	Suspect(const int &m) :prev(0), sus(m), id{ 0 }, order{ 0 } {
		for (auto i = 1; i <= m; ++i) {
			sus.at(i - 1) = std::make_shared<Suspect>(Suspect(i, true));
		}
	}
	void add_evidence(const int &a, const int &b) {
		sus.at(a - 1)->prev.push_back(sus.at(b - 1));
	}
	std::vector<int> search() {
		std::vector<int> res(sus.size());
		std::vector<int> ord(sus.size());
		for (auto i = 0; i < sus.size(); ++i) {
			ord.at(i) = sus.at(i)->cul_order();
			res.at(i) = i + 1;
		}
		for (auto i = 0; i < sus.size(); ++i) {
			auto min = i;
			for (auto j = i + 1; j < sus.size(); ++j) {
				if (ord.at(j) > ord.at(min)) {
					min = j;
				}
			} 
			auto temp = res.at(i);
			res.at(i) = res.at(min);
			res.at(min) = temp;
			ord.at(min) = ord.at(i);
		}
		return res;
	}
private:
	const int id;
	int order;
	std::vector<std::shared_ptr<Suspect>> prev;
	std::vector<std::shared_ptr<Suspect>> sus;
	Suspect(const int &i, const bool &b) : prev(0), sus(0), id{ i }, order{ 0 } {};
	int cul_order() const {
		if (id == 2) {
			return 0;
		}
		else {
			int res = 0;
			for (auto &p : prev) {
				if (p->cul_order() > res) {
					res = p->cul_order();
				}
			}
			return res + 1;
		}
	}
};
int main() {
	int m, n;
	std::cin >> m >> n;
	Suspect neko(m);
	for (auto i = 0; i < n; ++i) {
		int a, b;
		std::cin >> a >> b;
		neko.add_evidence(a, b);
	}
	for (const auto &i : neko.search()) {
		std::cout << i << '\n';
	}
	return 0;
}

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

#define MAX_NUM (1000000000 + 7)

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

template <typename T>
static inline T ArraySum(vector<T>& A) {
  T res = 0;
  for (auto itr = A.begin(); itr < A.end(); ++itr) res += *itr;
  return res;
}

bool Sec_compare(pair<uint64_t, uint64_t> a, pair<uint64_t, uint64_t> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

u64 dec_dig(u64 num) {
  u64 res = 0;
  while (num > 0) {
    num /= 10;
    ++res;
  }
  return res;
}

u64 gcd(u64 a, u64 b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }

  return b ? gcd(b, a % b) : a;
}

int main() {
  cout << setprecision(18);
  i64 X;
  cin >> X;
  for (i64 A = -1000; A <= 1000; ++A) {
    i64 tmpA = A * A * A * A * A;
    for (i64 B = -1000; B <= 1000; ++B) {
      i64 tmpB = B * B * B * B * B;
      if (tmpA - tmpB == X) {
        cout << A << " " << B << endl;
        return 0;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 3592
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        
        for(int i = 1; i <= n; i++){
            int x = i;
            if(x % 3 == 0){
                System.out.print(" " + i);
                continue;
            }
            while(x > 0){
                boolean flag = false;
                if(x % 10 == 3){
                    System.out.print(" " + i);
                    flag = true;
                }
                if(flag)break;
                x /= 10;
            }
        }
        System.out.println("");
    }
}



Measured memory_bytes: 28796
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <bitset>
#include <iostream>
#include <deque>
#include <functional>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <string>
#include <vector>
#include <vector>

using namespace std;

#define int long long

#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

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

#define debug(x) cerr << #x << ": " << x << endl;

const int MOD = 1e9 + 7;

signed main(void)
{

  int num;
  int n; cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; ++i) cin >> p[i];

  num = 0;
  for (int i = 1; i < n - 1; ++i) {
    if ((p[i - 1] <= p[i] && p[i] <= p[i + 1]) || (p[i + 1] <= p[i] && p[i] <= p[i - 1])) ++num;

  }

  cout << num << endl;
  
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;

int MOD = 998244353;

signed main(){

    ll n;
    string s;
    cin >> n >> s;

    if(n >= 3200)cout <<s << endl;
    else cout << "red" << endl;
    

    return 0;
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://cf17-final-open.contest.atcoder.jp/tasks/cf17_final_a
// rm -r -f test;oj dl http://abc138.contest.atcoder.jp/tasks/abc138_b

Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
ans, val0, val1 = 0, 0, 0

for j, i in enumerate(h):
    if val0 > i:
        ans += val0-val1
        val1 = i
    elif j == len(h)-1:
        val0 = i
        ans += val0-val1
    val0 = i
print(ans)


Measured memory_bytes: 9116
//bottom up solution
#include<iostream>
#include<algorithm>
using namespace std;
#define inf 1e9
int ans  =  inf;
int solve(int* arr, int n, int k)
{
	int dp[n + 1];
	dp[1] = 0;
	for(int i = 2; i <= n; i++){
		dp[i] = inf;
		for(int j = 1; j <= k; j++){
			if(i - j >= 1){
				dp[i] = min(abs(arr[i] - arr[i-j]) + dp[i-j], dp[i]);
			}
		}
	}
	return dp[n];
}
int main()
{
	int n, k;
	cin >> n >> k;
	int arr[n + 1];
	for(int i = 1; i <= n; i++)cin >> arr[i];
	cout << solve(arr, n, k);
	return 0;
}

Measured memory_bytes: 3916
import math
from collections import defaultdict
ml=lambda:map(int,input().split())
ll=lambda:list(map(int,input().split()))
ii=lambda:int(input())
ip=lambda:(input())

"""========main code==============="""
a=ii()
n=ll()
ans=0
for i in n:
    ans+=1/i
print(1/ans)    

Measured memory_bytes: 38384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int input = sc.nextInt();
		sc.close();
		
		for(int div = 1; div < 10 ;div++){
			if(input % div == 0 && input / div < 10){
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
	}
}


Measured memory_bytes: 23636
n,m = map(int,input().split())
alis = sorted(list(map(int,input().split())))
lis = []
clis = []
for x in range(m):
    b,c = map(int,input().split())
    lis.append((b,c))
lis = sorted(lis,reverse=True,key=lambda x:x[1])
for b,c in lis:
    for _ in range(b):
        if len(clis) > n:
            break
        clis.append(c)
    else:
        continue
    break
l = len(clis)
ans = 0
for x,y in zip(alis,clis):
    ans += max(x,y)

if n>l:
    ans += sum(alis[l:])
print(ans)


Measured memory_bytes: 23260
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSR(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int n,m;
string s;
char ch[200005];
char dr[200005];

int main(){
	cin>>n>>m>>s;
	for(int i=0;i<m;i++){
		scanf(" %c %c",&ch[i],&dr[i]);
	}
	//(lb,ub]
	int lb = -1,ub = n;
	while(ub-lb > 1){
		int mid = (lb+ub)/2;
		int cur = mid;
		for(int i=0;i<m && 0<=cur && cur < n;i++){
			if(s[cur] == ch[i]){
				if(dr[i] == 'L') cur--;
				else cur++;
			}
		}
		if(cur >= 0){
			ub = mid;
		}
		else{
			lb = mid;
		}
	}
	//ub以上は残る
	int mn = ub;
	//[lb,ub)
	lb = -1; ub = n;
	while(ub-lb > 1){
		int mid = (lb+ub)/2;
		int cur = mid;
		for(int i=0;i<m && 0<=cur && cur < n;i++){
			if(s[cur] == ch[i]){
				if(dr[i] == 'L') cur--;
				else cur++;
			}
		}
		if(cur < n){
			lb = mid;
		}
		else{
			ub = mid;
		}
	}
	//lb以下は残る
	int ans = 0;
	for(int i=0;i<n;i++){
		if(i >= mn && i <= lb){
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 900
from math import log, ceil
N, K = [int(n) for n in input().split()]
ans = 0
for i in range(1, N+1):
    tmpans = ceil(log(K/i, 2))
    # print(i, tmpans)
    if tmpans < 0:
        ans += 1/N
    else:
        ans += 1/N * (1/2)**tmpans
print(ans)


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

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

const int INF=1e9;
const int MOD=1e9+7;

int main(){
    string s; cin >> s;
    int ans=INF;
    for(int i=0;i<26;i++){
        char tmp='a'+i;
        int N=s.size();
        bool flag=false;
        for(int i=0;i<N;i++){
            if(s[i]==tmp){
                flag=true;
                break;
            }
        }
        if(!flag) continue;
        string c=s;
        int cnt=0;
        while(true){
            flag=true;
            string cur="";
            for(int i=0;i<N-1;i++){
                if((c[i]==tmp)||(c[i+1]==tmp)){
                    cur+=tmp;
                }else{
                    cur+=c[i];
                }
            }
            for(int i=0;i<N-1;i++){
                if(cur[i]!=tmp){
                    flag=false;
                    break;
                }
            }
            if(flag||N==0) break;
            cnt++;
            c=cur;
            N--;
        }
        ans=min(ans,cnt);
    }
    if(ans==0){
        cout << 0 << endl;
    }else{
        cout << ans+1 << endl;
    }
    
}

Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));


		while (true) {
			String[] inputNum = br.readLine().split(" ");
			int H = Integer.parseInt(inputNum[0]);
			int W = Integer.parseInt(inputNum[1]);

			if (H == 0 && W == 0) {
				break;
			}

			for(int i = 0; i < H; i++){
				for(int j = 0; j < W; j++){
					System.out.print("#");
				}
				System.out.println("");
			}
			System.out.println("");

		}



	}

}

Measured memory_bytes: 25972
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
typedef pair<ll,mp> mypair;
#define MAXN 1001024
#define INF 1000000007
int gcd(int a,int b){
	if(b==0)return a;
	else return gcd(b,a%b);
}
ll extgcd(ll a,ll b,ll &x,ll &y){
	if(b==0){
		x=1;
		y=0;
		return a;
	}
	ll d = extgcd(b,a%b,y,x);
	y -= a/b * x;
	return d;
}
//ax+by = c
mypair extgcd(ll a,ll b){
  ll x,y;
  ll d = extgcd(a,b,x,y);
  mp tmp = mp(x,y);
  return mypair(d,tmp);
}

//素数列挙
ll prime[MAXN] ;
bool is_prime[MAXN];
int sieve(int n){
	int res = 0;
	fill(is_prime,is_prime+MAXN,true);
	is_prime[0] = is_prime[1] = false;
	for(int i = 2;i<=n;i++){
		if(!is_prime[i])continue;
		prime[res++] = i;
		for(int j = 2*i;j<=n;j+=i)is_prime[j] = false;
	}
	return res;	
}
bool is_prime_ab[MAXN]; //segment_sieveの場合 [a,b) x(x>a)が素数かどうかはis_prime_ab[x-a]になる。
ll segment_sieve(ll a,ll b){
	fill(is_prime,is_prime+MAXN,true);
	fill(is_prime_ab,is_prime_ab+MAXN,true);
	for(int i=2;i*i <= b-1 ;i++){
		if(!is_prime[i]) continue;
		for(ll j = 2*i;j*j<=b-1;j+=i)is_prime[j] = false;
		for(ll j = a-a%i;j<b;j += i){
			if(j< a) continue;
			if(is_prime_ab[j-a]) is_prime_ab[j-a] = false;
		}
	}
	ll res = 0;
	for(ll i = a;i< b ;i++ )if(is_prime_ab[i-a] ) prime[res++] = i;
	return res;
}
// nが素数かどうか判定
bool is_primef(ll n){
	if(n==1) return false;
	for(ll i=2;i*i<=n;i++)
		if(n%i==0)return false;
	return true;
}

vector<ll> divisors(ll n){
	vector<ll> res;
	for(ll i=1;i*i<=n;i++){
		if(n%i != 0) continue;
		res.push_back(i);
		if(n/i== i)continue;
		res.push_back(n/i);
	}
	return res;
}
map<ll,ll> prime_factors(ll n){
	map<ll,ll> res;
	if(n<=1){
		res[n] = 1;
		return res;
	}
	
	//for(int i=2,_n = n;i*i<=_n;i++){
	for(ll i=2;i*i<=n;i++){
		while(n%i==0){
			res[i]++;
			n /= i;
		}
	}
	if(n!=1)res[n] = 1;
	return res;
}

//1からnまででnと互いにそなものの数
ll euler_phi(ll n){
	ll cnt = n;
	map<ll,ll> res = prime_factors(n);
	for(auto it = res.begin(),end = res.end();it!=end;it++){
		cnt = cnt/it->first*(it->first-1);
	}
	return cnt;
}
ll pow(ll n,ll m){
	vector<ll> a(33);
	a[0] = n;
	for(int i=1;i<32;i++){
	a[i] = (a[i-1]*a[i-1])%INF;
	}
	ll res = 1;
	for(int i=0;i<32;i++){
	if( ( m&(1<<i) ) ){
		res = (res*a[i])%INF;
		}
	}
	return res;
}


int main(){
	ll n,m;
	cin>>n;
	ll res = sieve( 200000 );
	auto it = lower_bound( prime , prime + res , n );
	cout<<*it<<endl;
	//cout<<pow(n,m)<<endl;
	return 0;
}

Measured memory_bytes: 3328