akhauriyash/Code-Regression huggingface dataset:
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

# 
# a, b = map(int, input().split())
# s = input()

ans = 0
N = int(input())
for i in range(1, N+1):
    s = str(i)
    if len(s) % 2 == 1:
        ans += 1
print(ans)


Measured memory_bytes: 38768
use std::io::*;
use std::str::FromStr;
use std::collections::VecDeque;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let mut a: Vec<u64> = (0..n).map(|_| read()).collect();
    let mut between:VecDeque<u64> = VecDeque::with_capacity(n * 2);
    a.sort();
    let mut ans = 0;
    let val = a.pop().unwrap();
    between.push_front(val);
    for _ in 0..n-1{
        let t = a.pop().unwrap();
        ans += between.pop_back().unwrap();
        between.push_front(t);
        between.push_front(t);
    }
    print!("{}", ans);
}


Measured memory_bytes: 6556
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7;
int main(){
  ll n,m;
  cin >> n >> m;//s,c,6,8
  ll max=m/2;
  if(n*2 <= m){
    cout << (2*n+m)/4;
  }else{
    cout << m/2;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#define mod 1000000007
using namespace std;
long long int dp[101001][13];
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	string s;
	cin >> s;
	int n=s.length();
	dp[0][0]=1;
	for(int i= 0; i < n; i++)
	{
	    for(int j= 0; j < 13; j++)
	    {
	        if(s[i]=='?')
	            for(int k = 0; k < 10; k++)
	                dp[i+1][(10*j+k)%13]=(dp[i+1][(10*j+k)%13]+dp[i][j])%mod;
	        else
	            dp[i+1][(10*j+s[i]-'0')%13]=(dp[i+1][(10*j+s[i]-'0')%13]+dp[i][j])%mod;
	    }
	}
	cout << dp[n][5] << '\n';
}

Measured memory_bytes: 10704
s = input()
t = input()

S = list(sorted(s))+['a']
T = list(sorted(t))[::-1]+['a']

ans = 'No'
for i in range(min(len(S),len(T))):
    if S[i] < T[i]:
        ans = 'Yes'
        break
    
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#define ll long long
#define __ ios::sync_with_stdio(0), cin.tie(NULL);
#define endl "\n"
using namespace std;

int n;
int a[101],b[101];

int main(){
	cin >> n;
	for(int i=0; i<n; i++)
		cin >> a[i];
	for(int i=0; i<n; i++)
		cin >> b[i];
	for(int i=1; i<n; i++) a[i] += a[i-1];
	for(int i=n-1; i>=0; i--) b[i] += b[i+1];

	//for(int i=0; i<n; i++) cout << a[i] << " ";
	//cout << endl;
	//for(int i=0; i<n; i++) cout << b[i] << " ";
	//cout << endl;

	int ans = 0;
	for(int i=0; i<n; i++){
		ans = max(ans,a[i]+b[i]);
	}
	cout << ans << endl;
}

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

typedef long long int ll;


int main()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	
	ll a,b,c;
	cin>>a>>b>>c;
	
	ll x = a-b;
	
	cout<<c-min(x,c)<<endl;
	
}


Measured memory_bytes: 256
#include <iostream>
#include<deque>
using namespace std;
deque<long long>dq;
int main()
{
    int T,d,x,p,flag;
    cin>>T;
    while(T--)
    {
        cin>>flag;
        if(flag==0)
        {
            cin>>d>>x;
            if(d==0)
            {
                dq.push_front(x);
            }
            else
            {
                dq.push_back(x);
            }
        }
        else if(flag==1)
        {
            cin>>p;
            cout<<dq[p]<<endl;
        }
        else
        {
            cin>>d;
            if(d==0)
            {
                dq.pop_front();
            }
            else dq.pop_back();
        }
    }
    return 0;
}



Measured memory_bytes: 6184
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int siz=2e5;
const int inf=1e9;
long modpow(long x,int n){
	int i = 0;long res = 1;
	while(n >= (1<<i)){
		if(n & (1<<i)) (res *= x) %= mod;
		i++;
		x = (x * x) % mod;
	}return res;
}
int main(){
	int K; cin>>K;
	string s; cin>>s;
	int N = s.size();
	long ans = 0;
	long res = 1;
	long a = 1, b = modpow(26, K);
	rep(i,0,K+1){
		(ans += res * a % mod * b % mod) %= mod;
		(res *= modpow(i+1, mod-2) * (i + N) % mod) %= mod;
		(a *= 25) %= mod;
		(b *= modpow(26, mod-2)) %= mod;//cout<<ans<<endl;
	}cout<<ans<<endl;
}

Measured memory_bytes: 5336
import Control.Applicative
    
solve :: Int -> Int -> Int -> Int

solve a b c
    = length [x | x <- [a..b], mod c x == 0]

input :: Read a => IO [a]

input
    = map read.words <$> getLine

output :: Show a => a -> String

output x
    = show x
                
main :: IO ()
    
main
    = do
        [a, b, c] <- input
        putStrLn $ output $ solve a b c

Measured memory_bytes: 4164
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 100005



struct GROUP{
	vector<int> nodes;
};

GROUP group[NUM]; //強連結成分のグループ
int N;
vector<int> G[NUM];
vector<int> reverse_G[NUM];
stack<int> S;
map<pair<int,int>,bool> MAP;

bool check[NUM],SELF[NUM];
int table[NUM],work[NUM];
double sleep[NUM];

int group_index;

void dfs(int node_id){
	check[node_id] = true;

	for(int i = 0; i < G[node_id].size(); i++){
		if(!check[G[node_id][i]])dfs(G[node_id][i]);
	}
	S.push(node_id);
}

void reverse_dfs(int node_id){
	check[node_id] = true;

	table[node_id] = group_index;
	group[group_index].nodes.push_back(node_id); //group[group_index]にノードを突っ込む

	for(int i = 0; i < reverse_G[node_id].size(); i++){
		if(!check[reverse_G[node_id][i]])reverse_dfs(reverse_G[node_id][i]);
	}
}


int main(){

	scanf("%d",&N);

	int num,pre_node;

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

		SELF[i] = false;

		scanf("%d",&num);

		for(int k = 0; k < num; k++){
			scanf("%d",&pre_node);
			pre_node--;

			if(pre_node == i){

				SELF[i] = true;
			}

			auto at = MAP.find(make_pair(pre_node,i));
			if(at != MAP.end())continue;

			MAP[make_pair(pre_node,i)] = true;

			G[pre_node].push_back(i);
			reverse_G[i].push_back(pre_node);
		}
	}

	for(int i = 0; i < N; i++)check[i] = false;

	for(int i = 0; i < N;i++){
		if(!check[i])dfs(i);
	}

	for(int i = 0; i < N;i++)check[i] = false;

	group_index = -1;

	while(!S.empty()){
		if(!check[S.top()]){
			group_index++;

			reverse_dfs(S.top());
		}
		S.pop();
	}

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

		work[i] = -BIG_NUM;
	}

	for(int i = 0; i < N; i++){
		for(int k = 0; k < reverse_G[i].size(); k++){
			int tmp_node = reverse_G[i][k];

			if(tmp_node > i || table[i] != table[tmp_node])continue;

			work[i] = max(work[i],tmp_node);
		}
	}

	int tmp = -1;
	int ans = 0;

	for(int i = 0; i < N; i++){
		if(work[i] == -BIG_NUM)continue;
		if(tmp < work[i]){
			ans++;
			tmp = i;
		}
	}

	printf("%d\n",ans);

	return 0;
}



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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

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

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

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

    if (a > 0) {
        cout << "Positive" << endl;
    } else if (a <= 0 && b >= 0) {
        cout << "Zero" << endl;
    } else {
        if ((b-a)%2 == 0) {
            cout << "Negative" << endl;
        } else {
            cout << "Positive" << endl;
        }
    }
    return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  
  if(a > 12)
    cout << b << endl;
  else if(a > 5)
    cout << b / 2 << endl;
  else
    cout << 0 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

double y,r,ans,genri;
int n,t,b,ansn;

int main(void){

  while( cin >> n , n ){

    cin >> y; // 預ける年数
    ans = 0;

    for( int i = 0 ; i < n ; i++ ){
    
      cin >> b >> r >> t;
      
      switch(t){
      case 1: // 単利
	genri = 10000 * ( 1 + y * (r / 100) );
	break;
      case 2: // 複利
	genri = 10000 * pow( (double)( 1 + r / 100 ), y );
	break;
      }
      // cout << genri << endl;
      if( ans < genri ){
	ans = genri;
	ansn = b;
      }
    }
    cout << ansn << endl;
  }
  return 0;
}

Measured memory_bytes: 1320
#include <iostream>

int main(int argc, char **argv){
	int a = 0;
	int b = 0;
	char op = 0;

	while(std::cin >> a >> op >> b, op != '?'){
		switch(op){
			case '+':
				std::cout << a + b << std::endl;
				break;
			case '-':
				std::cout << a - b << std::endl;
				break;
			case '*':
				std::cout << a * b << std::endl;
				break;
			case '/':
				std::cout << a / b << std::endl;
				break;
			default:
				break;
		}
	}
	return 0;
}

Measured memory_bytes: 3104
n = int(input())
alpha = [0 for i in range(26)]
s = input()
for j in range(len(s)):
    alpha[ord(s[j])-ord("a")] += 1
for i in range(1, n):
    s = input()
    tmpAlpha = [0 for i in range(26)]
    for j in range(len(s)):
        tmpAlpha[ord(s[j]) - ord("a")] += 1
    for j in range(len(alpha)):
        alpha[j] = min(alpha[j], tmpAlpha[j])
out = ""
for i in range(len(alpha)):
    for j in range(alpha[i]):
        out += chr(i + ord("a"))
print(out)

Measured memory_bytes: 3064
#include <cstdio>

int main (){
    int N,L;
    scanf("%d %d",&N,&L);
    int aji=N*(2*L+N-1)/2;
    if(L>=0) aji-=L;
    else if(L+N<=0) aji-=L+N-1;
    printf("%d",aji);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long int

using namespace std;

int main ()
{
	ll n, sum;
	cin >> n;
	for (ll i=sqrt(n); i>=1; i--){
		if (n % i == 0){
			sum = i + n/i - 2;
			cout << sum << endl;
			break;
		}
	}
}

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

using namespace std;
using ll = long long;
using pii = std::pair<int, int>;

#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define pb push_back

const int mn = 1e5 + 5;


int main() {
#ifdef trote
    freopen("../1.txt", "r", stdin);
#endif
    int n;
    string s;
    cin >> n >> s;
    for (auto &i:s) {
        for (int j = 1; j <= n; j++) {
            i++;
            if (i == 'Z' + 1) i = 'A';
        }
    }
    cout << s << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
#include <assert.h>
#include <deque>
using namespace std;

/*
using PAIR = pair<string, int>;
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long ll;

#define fi first
#define se second
#define rep(i, n) for (ll i = 0; i < n; i++)
#define debugA() cerr << "AAAAA" << endl
#define debug_() cerr << "-------------" << endl
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v)                   \
    for (int i = 0; i < v.size(); i++) \
    {                                  \
        cout << v[i] << " ";           \
    }                                  \
    cout << endl;

using Graph = vector<vector<int>>;

int main()
{
    int n;
    cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; i++)
    {
        cin >> p[i];
    }
    int ans = 0;
    for (int i = 1; i <= n - 2; i++)
    {
        if (p[i] < p[i - 1] && p[i] > p[i + 1])
        {
            ans++;
        }
        if (p[i] > p[i - 1] && p[i] < p[i + 1])
        {
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main(){
int W,H,x,y,r;
std::cin >> W >> H >> x >> y >> r;

if( 0<=x-r && x+r<=W && 0<=y-r && y+r<=H){
std::cout << "Yes" << std::endl;
}else{std::cout << "No" << std::endl;}
}

Measured memory_bytes: 1156
N, x = map(int,input().split())
A = list(map(int,input().split()))
ans = 0

if A[0]>x:
    ans += A[0] - x
    A[0] = x

for k in range(1,N):
    if A[k-1] + A[k] > x:
        ans += (A[k-1] + A[k]) - x
        A[k] = x - A[k-1]

print(ans)


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

INF = 1 << 20
dp = [[INF] * 51 for _ in range(1 << N)]
dp[0][0] = 0

for bit in range(1 << N):
    # 左詰めソートされている数
    con = bin(bit).count("1")

    # bitに含まれないカード
    ords = []
    iters = con
    for i in range(N):
        if not (bit & (1 << i)):
            ords.append([i, iters])
            iters += 1

    for s in range(51):
        if dp[bit][s] >= INF:
            continue

        for p in ords:
            # p[0]: 元々のindex, p[1]: dp[bit][s]の状態でのindex
            # con: bitの中身の数（既に詰まっているindexの最後尾）
            # |i-j|が偶数ならばA[i], 奇数ならばB[i]
            ns = A[p[0]] if abs(p[0] - con) % 2 == 0 else B[p[0]]

            # bitの中身がcon枚なので，bitに含まれないものはcon+1から順に詰める
            # 新しく詰める値nsが，既に詰まっている値の最大値sよりも大きい場合，
            # その値を後ろに詰める．
            if ns >= s:
                # 詰める時の最小の操作回数をdpで調べる．
                dp[bit|(1 << p[0])][ns] = min(dp[bit|(1 << p[0])][ns],
                                              dp[bit][s] + abs(con - p[1]))

ans = min(dp[-1][s] for s in range(51))
print(ans if ans < INF else -1)


Measured memory_bytes: 164764
#include <bits/stdc++.h>
using namespace std;
int N,A,B;
long long cnt;
long long sum;
long long m[55];
long long c[55][55];
map<long long, int>mp;
long long C(int i,int j){
    if(!c[i][j])c[i][j]=C(i-1,j)+C(i-1,j-1);
    return c[i][j];
}
int main(){
    for(int i=0;i<55;i++)c[i][0]=c[i][i]=1;
    cin>>N>>A>>B;
    for(int i=0;i<N;i++){
        long long x;
        cin>>x;
        m[i]=x;
        mp[x]++;
    }
    sort(m,m+N,greater<>());
    for(int i=0;i<A;i++) sum+=m[i];
    long long x=m[A-1];
    long long y=m[B-1];
    int z=mp[x];
    if(m[0]==x){
        if(x==y){
            for(int j=A;j<=B;j++){
                cnt+=C(z,j);
            }
        }
        else{
            for(int j=A;j<=z;j++){
                cnt+=C(z,j);
            }
        }
    }
    else{
        B=A;
        for(int i=0;i<A;i++)if(m[i]>x)B--;
        cnt+=C(z,B);
    }
    printf("%.12f\n", 1.*sum/A);
    printf("%lld\n",cnt);
    return 0;
}


Measured memory_bytes: 256
# vim: set fileencoding=utf-8 :
n = int(raw_input())
a = map(int, raw_input().split())

diff = None
min_diff = 999999999999999999
x = 0
y = sum(a)

for i in range(n - 1):
    x += a[i]
    y -= a[i]
    diff = abs(x - y)
    if diff < min_diff:
        min_diff = diff

print(min_diff)


Measured memory_bytes: 18416
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> P3;
const ll MOD = ll(1e9+7);
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e4 + 5);
const double EPS = 1e-8;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

ll n, W, w[205], cum[205], dp[205][10005];

int main() {
    cin >> n >> W;
    REP(i,n) cin >> w[i];
    sort(w,w+n);
    reverse(w,w+n);
    REPR(i,n-1) cum[i] = cum[i+1] + w[i];
    REP(i,n+1)fill(dp[i],dp[i]+W+1,0);
    dp[0][0] = 1;
    REP(i,n){
        REP(j,W+1){
            if(j+w[i] <= W){  // 使う遷移
                dp[i+1][j+w[i]] += dp[i][j];
                dp[i+1][j+w[i]] %= MOD;
            }
            if(W-j < cum[i]){  // 使わない遷移
                dp[i+1][j] += dp[i][j];
                dp[i+1][j] %= MOD;
            }
        }
    }
    ll ans = 0;
    REP(i,W+1){
        ans += dp[n][i];
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 18760
// B. 

#include <sstream>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cstring>

using namespace std;

int main(int argc, char *argv[])
{
	map<int, int> m;
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		int a;
		cin >> a;
		m[a] += 1;
	}
	int ans = 0;
	for (int i = 30; i >= 0; --i) {
		int b = 1 << i;
		for (auto kv : m) {
			if (kv.first == b - kv.first) {
				int cnt = kv.second / 2;
				ans += cnt;
				m[kv.first] -= cnt * 2;
			} else {
				int r = b - kv.first;
				if (r < kv.first) {
					break;
				}
				if (r > 0 && m.find(r) != m.end()) {
					int cnt = min(kv.second, m[r]);
					ans += cnt;
					m[kv.first] -= cnt;
					m[r] -= cnt;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
typedef long long lint;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
const int INF = 999999999;
int main() {
    int n,m; cin >> n >> m;
    int key[1000] = {0};
    int cost[1000] = {0};
    rep(i,m) {
        int a,b; cin >> a >> b;
        cost[i] = a;
        rep(j,b) {
            int t; cin >> t;
            key[i] = key[i] | (1 << (t-1));
        }
    }
    int dp[4096]; rep(i,4096) dp[i] = INF;
    dp[0] = 0;
    rep(k,m) {
        for (int i=pow(2,n)-1; i >= 0; i--) {
            if (dp[i] != INF) {
                dp[i | key[k]] = min(dp[i | key[k]], dp[i] + cost[k]);
            }
        }
    }
    int ans = dp[(int)pow(2,n)-1];
    if (ans == INF) cout << -1 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 4032
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;

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

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main()
{
	int n,m;
	cin>>n>>m;
	vector<P> job(n);
	for (int i = 0; i < n; i++){
		cin>>job[i].first >> job[i].second;
	}
	priority_queue<ll> que;
	sort(all(job));
	// reverse(all(job));
	int day = 1;
	int pos = 0;
	ll ans = 0;
	while(day<=m){
		while(job[pos].first<= day && pos<n) que.push(job[pos].second), pos++;
		day++;
		if(que.empty()) continue;
		ans += que.top();
		que.pop();
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2936
# ContestName
# URL
import sys
#import numpy as np

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    a, b = i2nn()
    d = b - a
    h = int(d * (d - 1) / 2)
    snow = h - a
    print(snow)

main()


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

int prime[1300000];
signed main(void)
{
  prime[0] = prime[1] = 1;
  for (int i = 2; i * i <= 1300000; i++) {
  	if (!prime[i]) {
  		for (int j = 2 * i; j <= 1300000; j += i) {
  			prime[j] = 1;
  		}
  	}
  }

  //REP(i, 20) cout << prime[i] << " "; cout << endl;
  FOR(i, 1, 1300000) {
    if(prime[i] > 0) prime[i] = prime[i-1] + 1;
  }
  //REP(i, 20) cout << prime[i] << " "; cout << endl;
  for(int i=1299998; i>=0; --i) {
    if(prime[i+1] && prime[i]) prime[i] = prime[i+1];
  }
  //REP(i, 20) cout << prime[i] << " "; cout << endl;

  while(true) {
    int n;
    cin >> n;
    if(!n) break;
    if(prime[n]) {
      cout << prime[n] + 1 << endl;
    } else {
      cout << 0 << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 8156
#include <iostream>

int main() {
    long n;
    std::cin >> n;
    long long arr[n];

    for(long i = 0; i < n; ++i) {
        std::cin >> arr[i];
    }

    long long total = 0;

    for(long i = 0; i < n-1; ++i) {
        if(arr[i] > arr[i+1]) {
            total += arr[i] - arr[i+1];
            arr[i+1] = arr[i];
        }
    }

    std::cout << total << "\n";
}


Measured memory_bytes: 5184
#include <iostream>
#include <vector>
#include <math.h>
#define NMAX 15
#define rep(i, n) for(int i=0; i<(n); i++)

using namespace std;

int N;
int A[NMAX];
int x[NMAX][NMAX-1];
int y[NMAX][NMAX-1];

int main(void){
  cin >> N;
  for(int i=0;i<N;i++){
    int tmp;cin>>tmp;
    A[i]=tmp;
    for(int j=0;j<A[i];j++){
      cin >> x[i][j];
      cin >> y[i][j];
    }
  }

  int maxnum=0;

  rep(i, pow(2, N)){
    vector<int> v(N, 0);
    rep(j, N){
      if(i>>j&1){
        v[j] = 1;
      }
    }

    bool ans = true;
    int honest=0;
    rep(j, N){
      if(v[j]==1){
        honest++;
        rep(k, A[j]){
          if(v[x[j][k]-1]==y[j][k]){
            ans = ans and true;
          }else{
            ans = ans and false;
          }
        }
      }
    }

    if(ans){
      //rep(j, N){cout <<v[j]<<" ";}cout << endl;
      maxnum = max(maxnum, honest);
    }
    
  }

  cout << maxnum;
  
  return 0;
}


Measured memory_bytes: 256
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
m1,d1 = readInts()
m2,d2 = readInts()
print('1' if m1 != m2 else '0')


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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(ull i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define iter(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define riter(i,c) for(auto i=(c).rbegin(); i!=(c).rend(); ++i)

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

#define clr(a,i) memset((a), (i) ,sizeof(a))

int main(){
  string s,ans;
  std::cin >> s;
  rep(i,s.size()-1){
    if(s[i]==s[i+1]){
      i++;
      std::cout << i << " " << i+1<< std::endl;
      return 0;
      // loop(j,i,s.size()){
      //   if(s[i]!=s[j]){
      //     std::cout << i+1 << " " << j+1 << std::endl;
      //     return 0;
      //   }
      // }
      // for(int j=i; j>=0 ;j--){
      //   if(s[i]!=s[j]){
      //     std::cout << i+1 << " " << j+1 << std::endl;
      //     return 0;
      //   }
      // }
    }
    else if(i+2<=s.size()-1)if(s[i]==s[i+2]){
        i++;
        std::cout << i<<" " <<i+2<< std::endl;
        return 0;
    }
  }
  std::cout << "-1 -1" << std::endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
	#include <set>
	#define ll long long 
	#include <string>
	#define pb push_back
	#define mp make_pair
	# define pi 3.14159265358979323846
	#define mod 1000000007
    #define rep(i,n) for(i=0;i<n;i++)
    #define rep1(i,n) for(i=1;i<n;i++)
	using namespace std;
	ll int multiply(ll int a,ll int b)
{
	ll int ans=(a%mod*b%mod)%mod;
	return ans;
}
ll int add(ll int a, ll int b)
{
	ll int ans=(a%mod+b%mod)% mod;	
	return ans;
}

	int power(ll int x,  ll int y, ll int p)  
{  
    ll int res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  
	void fastio()
	{					
		#ifndef ONLINE_JUDGE
	    // for getting input from input.txt
	    freopen("input.txt", "r", stdin);
	    // for writing output to output.txt
	    freopen("output.txt", "w", stdout);
	    #endif
	    ios_base::sync_with_stdio(false);
	    cin.tie(NULL);
	    cout.tie(NULL);

	}
	vector<ll int> adj[100001];
	ll int vis[100001]={0};
	ll int indegree[100001]={0};
	ll int dist[100001]={0};
	void dfs(ll int n)
	{
		vis[n]=1;
		for(auto node: adj[n])
		{
			dist[node]=max(dist[node],dist[n]+1);
			indegree[node]--;
			if (indegree[node]==0)
				dfs(node);
		}
	}
	// ll dp[101][100001];
	double dp[3000][3000];
	void solve()
	{
		ll int n;
		cin>>n;
		double p[n];
		ll int i,j;
		rep(i,n)
		cin>>p[i];
		
		memset(dp,0,sizeof dp);
		
		for(i=0;i<=n;i++)
		{
			for(j=0;j<=i;j++)
			{
				if (i==0)
					{if (j==0)
						dp[i][j]=1;
					else
						dp[i][j]=0;
				}
			     else if (j==0)
					dp[i][j]=(1-p[i-1])*dp[i-1][j];
				else
				{
					
					dp[i][j]=(1-p[i-1])*dp[i-1][j] +p[i-1]*dp[i-1][j-1];

				}
			}
		}
		// rep(i,n+1)
		// {
		// 	rep(j,n+1)
		// 	cout<<dp[i][j]<<" ";
		// 	cout<<endl;
		// }
	
		double ans=0;
		rep(i,n+1)
		{
			rep(j,n+1)
			{
				if (i==n && j>n/2)
					ans+=dp[i][j];
			}
		}
		
		printf("%.10lf",ans);
    }
	int main()
	{
		fastio();
		ll int t;
		t=1;
		// cin>>t;
		
		while(t--)
		{
			solve();
		}
			
	}
			

Measured memory_bytes: 76452
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int r; cin >> r;
    cout << 3 * r * r << endl;

}


Measured memory_bytes: 892
n=int(input())
l=list(map(int,input().split()))
infin=10**9+7
s=0
for i in range(0,len(l)):
  s+=l[i]
ans=0
for i in range(len(l)-1,0,-1):
  s=s-l[i]
  ans=(ans+l[i]*s)%infin
print(ans)
  

Measured memory_bytes: 31708
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<cmath>
#include<string>

using namespace std;
#define pi 3.14159265359

int main(){
    int a,b,h,m;
    cin >> a >> b >> h >> m;

    double rad = (pi/6.0)*h+(pi/360)*m-(pi/30.0)*m;

    double c = sqrt(a*a+b*b-2*a*b*cos(rad));
    cout << fixed << setprecision(20) <<c << endl;

    return 0;
}



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

int main() {
  int64_t n, d = 1;
  cin >> n;
  for (int64_t i = 2; i * i <= n; i++) {
    if (n % i == 0) d = i;
  }
  cout << d + n / d - 2 << endl;
}


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

int main(){
  string s, t;
  cin >> s >> t;
  vector<int> dic(26, -1);
  vector<int> reverse_dic(26, -1);
  char base = 'a';
for (int i = 0; i < s.length(); i++){
  int a = (int)s[i] - (int)base;
  int b = (int)t[i] - (int)base;
  if (dic[a] != -1 || reverse_dic[b] != -1){
    if (dic[a] != b || reverse_dic[b] != a){
      cout << "No" << endl;
      return 0;
    }
  }
  dic[a] = b;
  reverse_dic[b] = a;
 }
  cout << "Yes" << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;

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

int main()
{
  int N, A; scanf("%d %d", &N, &A);
  vector<int> X(N);
  for (int i = 0; i < N; ++i) {
    scanf("%d", &X[i]);
  }
  vector<vector<vector<ll>>> dp(N + 5,
                                vector<vector<ll>>(N + 5, vector<ll>(N * A + 5, 0)));
  for (int i = 0; i <= N; ++i) { dp[i][0][0] = 1; }

  for (int i = 0, upper =  N * A; i < N; ++i) {
    for (int j = 1; j <= i + 1; ++j) {
      for (int k = 0; k <= upper; ++k) {
        dp[i + 1][j][k] = dp[i][j][k];
        if (k - X[i] >= 0) {
          dp[i + 1][j][k] += dp[i][j - 1][k - X[i]];
        }
      }
    }
  }
  ll ans = 0;
  for (int i = 1; i <= N; ++i) {
    ans += dp[N][i][i * A];
  }
  printf("%lld\n", ans);
  return 0;
}


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

using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
//    freopen("in.inp", "r", stdin);
//    freopen("ou.out", "w", stdout)
    int n;
    cin>>n;
    cout<<n*n*n;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>

int main() {
    std::string str;
    std::cin >> str;

    int q;
    std::cin >> q;

    while (q--) {
        std::string odr;
        std::cin >> odr;

        int a, b;
        std::cin >> a >> b;


        if (odr[0] == 'p') {
            std::cout << str.substr(a, b - a + 1) << std::endl;
        } else if (odr[2] == 'v') {
            std::string r = str.substr(a, b - a + 1);
            reverse(r.begin(), r.end());
            str = str.substr(0, a) + r + str.substr(b + 1, str.size());
        } else {
            std::string p;
            std::cin >> p;
            for (int i = 0; i < p.size(); ++i) {
                str[i + a] = p[i];
            }
        }
    }
}




Measured memory_bytes: 3220
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>


using namespace std;
using namespace __gnu_pbds;


#define LL long long
#define N 100005
#define MOD 1000000007
#define dd double
#define rep(i, n) for(LL i = 0; i < n; i++)
#define REP(i,a,b) for(LL i=a;i<b;i++)
#define rep1(i,b) for(LL i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((LL)(x).size())
#define F first
#define S second
typedef tree<LL,null_type,less<LL>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

LL bin(LL a,LL p)
{
	if(a==0)
		return 1;
	else if(a==1)
		return 10%p;
	LL x = bin(a/2,p)%p;
	x = (x*1ll*x)%p;
	if(a%2)
		return (10*1ll*x)%p;
	else
		return (x)%p;
}

int main() {

ios_base::sync_with_stdio(false);
cin.tie(NULL);
	
	LL t=1;
	//cin>>t;
	while(t--){
		LL n,p;
		string s;
		cin>>n>>p>>s;
		if(p==2 || p==5)
			{	LL ans=0;
				for(int i=0;i<n;i++)
					{
						if((s[i]-'0')%p==0)
							ans = ans+i+1;
					}
				cout<<ans<<'\n';
				return 0;
			}
		vector <LL> v(s.size(),0);
		for(LL i=0;i<s.size();i++)
				{
					v[i]=bin(n-i-1,p);
					v[i] = ((s[i]-'0')*1ll*v[i])%p;
					//cout<<v[i]<<"\n";
				}
		vector <LL> pre(n+1,0);
		vector <LL> m(p,0);
		m[0]=1;
		long long int c=0;
		long long  ans=0;
		for(LL i=0;i<n;i++)
			{
                pre[i+1]=(pre[i]+v[i])%p;
                //cout<<pre[i+1]<<" "<<m[pre[i+1]]<<'\n';
               	ans = ans+m[((pre[i+1]%p))%p];
                ++m[(pre[i+1])%p];
			}
		//cout<<c<<'\n';
		cout<<ans<<'\n';
	}



return 0;
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -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; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  map<int, ll> mp;
  ll sum = 0;
  rep(i, n) {
    int a;
    cin >> a;
    mp[a]++;
    sum += a;
  }
  int q;
  cin >> q;
  rep(i, q) {
    int b, c;
    cin >> b >> c;
    sum += mp[b]*(c-b);
    mp[c] += mp[b];
    mp[b] = 0;
    cout << sum << '\n';
  }
  return 0;
}

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



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

    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    
    ll n,k;
    cin>>n>>k;

    vector<ll> cnt(1e5+1);

    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        cnt[a]+=b;
    }
    for(int i=1;i<=1e5;i++){
        if(k<=cnt[i]){
            cout<<i<<endl;
            break;
        }
        k-=cnt[i];
    }

}


Measured memory_bytes: 3964
while True:
    n=int(input())
    if n==0:
        break
    d0=0
    d1=0
    d2=0
    d3=0
    d4=0
    d5=0
    d6=0
    for i in range(n):
        x=int(input())
        if x<10:
            d0+=1
        elif x<20:
            d1+=1
        elif x<30:
            d2+=1
        elif x<40:
            d3+=1
        elif x<50:
            d4+=1
        elif x<60:
            d5+=1
        else:
            d6+=1
    print(d0)
    print(d1)
    print(d2)
    print(d3)
    print(d4)
    print(d5)
    print(d6)
        


Measured memory_bytes: 5608
#include<iostream>
    using namespace std;
     
    int main()
    {
      int n;
      cin>>n;
      if(n>=18) cout<<"Yes"<<endl;
      else if(n<=16&&n>=14) cout<<"Yes"<<endl;
      else if(n==11) cout<<"Yes"<<endl;
      else if(n%4==0) cout<<"Yes"<<endl;
      else if(n%7==0) cout<<"Yes"<<endl;
      else cout<<"No"<<endl;
      return 0;
    }

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

int main () {
  
  string a, s, c;
  cin >> a >> s >> c;
  
  if(a == "AtCoder"){
    if(c == "Contest"){
  cout << "A" << s.at(0) << "C" << endl;
    }else{
      cout << "errer" << endl;
    }
  }
}

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

char a[100][101], b[102][102];

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

    for(int i = 0; i < h; i++) {
        scanf("%s", a[i]);
    }

    for(int i = 0; i < h+2; i++){
        for(int j = 0; j < w+2; j++){
            b[i][j] = '#';
        }
    }

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            b[i+1][j+1] = a[i][j];
        }
    }

    for(int i = 0; i < h+2; i++){
        for(int j = 0; j < w+2; j++){
            cout << b[i][j] ;
        }
        cout << endl;
    }


}


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

#define MOD 1000000007
int main()
{
  long N, K;
  cin >> N >> K;
  long ans = 0;
  for (long i = K; i <= N+1; i++)
  {
    // cout << "i = " << i << endl;
    long min_sum = (i-1)*i/2;
    long max_sum = (N+(N-i+1))*i/2;
    // cout << "min = " << min_sum << ", max = " << max_sum << endl;
    ans += (max_sum - min_sum + 1);
    ans %= MOD;
  }
  cout << ans << endl;
}


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

#define N 500000
#define INFTY 1000000000
int count=0;
void merge(int*, int, int, int);
void mergeSort(int*, int, int);

int main(){
  int a,i,A[N];

  scanf("%d",&a);
  for(i=0;i<a;i++)
    scanf("%d",&A[i]);
  mergeSort(A,0,a);
  
  for(i=0;i<a-1;i++)
    printf("%d ",A[i]);
  printf("%d",A[i]);
  printf("\n");
  printf("%d",count);
  printf("\n");
  return 0;
}

void merge(int *A, int left, int mid, int right){
  int n,n1,n2,i,j,k,L[N],R[N];

  n1 = mid - left;
  n2 = right - mid;
  //L[0...n1], R[0...n2] を生成
  for(i=0;i<n1;i++)
    L[i] = A[left + i];

  for(i=0;i<n2;i++)
    R[i] = A[mid + i];

  L[n1] = INFTY;
  R[n2] = INFTY;
  i = 0;
  j = 0;
  for(k=left;k<right;k++){
    count++;
    if (L[i] <= R[j]){
      A[k] = L[i];
      i = i + 1;
    }
    else {
      A[k] = R[j];
      j = j + 1;
    }
  }
}

void mergeSort(int *A, int left, int right){
  int mid;
  
  if(left+1 < right){
    mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}



Measured memory_bytes: 5680
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

A,B = inputIL()

if A*B %2 == 1:
  print("Yes")
else:
  print("No")

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

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

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

struct T {
  int a;
  int t;
};

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

  T g[n][n] = {};
  rep(i, 0, n) {
    string s;
    cin >> s;
    rep(j, 0, n) g[i][j].a = s[j] == '1' ? 1 : 0;
  }
  int y = 0;
  rep(i, 0, n / 2) {
    rep(j, 0, n / 2) {
      if(g[i][j].a != g[n - i - 1][j].a) continue;
      if(g[i][j].a != g[i][n - j - 1].a) continue;
      if(g[i][j].a != g[n - i - 1][n - j - 1].a) continue;
      y++;
      g[i][j].t = true, g[n - i - 1][j].t = true;
      g[i][n - j - 1].t = true, g[n - i - 1][n - j - 1].t = true;
    }
  }

  int ans = 0;
  if(y == (n * n) / 4) ans++;

  rep(i, 0, c - 1) {
    int nn;
    cin >> nn;
    rep(j, 0, nn) {
      int a, b;
      cin >> a >> b;
      a--, b--;
      int f = 1;
      g[a][b].a = !g[a][b].a;
      if(g[a][b].a != g[n - a - 1][b].a) f = false;
      if(g[a][b].a != g[a][n - b - 1].a) f = false;
      if(g[a][b].a != g[n - a - 1][n - b - 1].a) f = false;

      if(g[a][b].t) {
        g[a][b].t = false;
        g[n - a - 1][b].t = false;
        g[a][n - b - 1].t = false;
        g[n - a - 1][n - b - 1].t = false;
        y--;
      }else if(f) {
        g[a][b].t = true;
        g[n - a - 1][b].t = true;
        g[a][n - b - 1].t = true;
        g[n - a - 1][n - b - 1].t = true;
        y++;
      }
    }
    if(y == (n * n) / 4) ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 11048
#	!/usr/bin/env python3
#	encoding: UTF-8
#	Modified: <19/May/2019 05:45:09 PM>


#	✪ H4WK3yE乡
#	Mohd. Farhan Tahir
#	Indian Institute Of Information Technology (IIIT), Gwalior


import sys


def get_array(): return list(map(int, sys.stdin.readline().split()))


def get_ints(): return map(int, sys.stdin.readline().split())


def input(): return sys.stdin.readline().strip()


def main():
    s = input()
    a = int(s[:2])
    b = int(s[2:])
    if (a > 12 and b > 12) or (a > 12 and b == 0) or (a == 0 and b > 12):
        print('NA')
        return

    if a == 0 and b <= 12 and b > 0:
        print("YYMM")
        return
    if b == 0 and a <= 12 and a > 0:
        print("MMYY")
        return

    if a <= 12 and b <= 12 and a > 0 and b > 0:
        print('AMBIGUOUS')
        return

    if a <= 12 and a != 0:
        print("MMYY")
        return
    if b <= 12 and b != 0:
        print("YYMM")
        return
    print('NA')


if __name__ == "__main__":
    main()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
int a[100001];
int main() {
	int n,m;
	cin>>n>>m;
	int x;
	priority_queue<int>q;
	for(int i=0;i<n;i++)
	{
		cin>>x;
		q.push(x);
	}
	int y;
	while(m>0)
	{
		y=q.top();
		q.pop();
		q.push(y/2);
		m--;
	}
	long long ans=0;
	while(!q.empty())
	{
		ans=ans+q.top();
		q.pop();
	}
	cout<<ans;
	return 0;
}

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


int main(){   
    int n,k;
    cin >> n >> k;
    vector<int> d(n);
    rep(i,k){
        int m;
        cin >> m;
        rep(j,m){
            int a;
            cin >> a;
            d[a-1] = 1;
        }
    }
    int ans = 0;
    rep(i,n) if(d[i] == 0) ++ans;
    cout << ans << endl;
}


Measured memory_bytes: 3640
#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 << "Left" << endl;
  }
  if(A + B == C + D) {
    cout << "Balanced" << endl;
  }
  if(A + B < C + D) {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
import itertools

n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

realnums = p.copy()
realnums.sort()
perm = list(map(list, itertools.permutations(realnums)))

print(abs(perm.index(q) - perm.index(p)))

Measured memory_bytes: 10228
#include<bits/stdc++.h>
#define int long long

using namespace std;

const int maxN = 1e5;

int readInt ()
{
    bool minus = false;
    int result = 0;
    char ch;
    ch = getchar();
    while (true)
    {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus = true;
    else result = ch-'0';
    while (true)
    {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus)
        return -result;
    else
        return result;
}
bool can(string p, string t) {
    if(p.size() != t.size())
        return false;
    for(int i = 0; i < t.size(); i++) {
        if(p[i] != '?' && p[i] != t[i])
            return false;
    }
    return true;
}
main() {
    string s, t;
    cin >> s >> t;
    int n = s.size(), m = t.size();
    if(n < m) {
        puts("UNRESTORABLE");
        return 0;
    }
    string ans(n, 'z');
    bool ok = false;
    for(int j = 0; j + m - 1 < n; j++) {
        string p = s.substr(j, m);
        if(can(p, t)) {
            ok = true;
            string f;
            for(int i = 0; i < j; i++)
                f += (isalpha(s[i]) ? s[i] : 'a');
            f += t;
            for(int i = j + m; i < n; i++)
                f += (isalpha(s[i]) ? s[i] : 'a');
            ans = min(ans, f);
        }
    }
    if(ok)
        puts(ans.c_str());
    else
        puts("UNRESTORABLE");
}


Measured memory_bytes: 256
N = int(input())
a = list(map(int,input().split()))

colors=[]
niji=[]
for i in a:
    if 1<=i<=399:
        colors.append('灰')
    elif 400<=i<=799:
        colors.append('茶')
    elif 800<=i<=1199:
        colors.append('緑')
    elif 1200<=i<=1599:
        colors.append('水')
    elif 1600<=i<=1999:
        colors.append('青')
    elif 2000<=i<=2399:
        colors.append('黄')
    elif 2400<=i<=2799:
        colors.append('橙')
    elif 2800<=i<=3199:
        colors.append('赤')
    elif 3200<=i:
        niji.append('虹')

colors_count =len(set(colors))
print(max(colors_count,1),colors_count+len(niji))

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  unordered_map<string, int> ws;
  ws.emplace("SUN", 7);
  ws.emplace("MON", 6);
  ws.emplace("TUE", 5);
  ws.emplace("WED", 4);
  ws.emplace("THU", 3);
  ws.emplace("FRI", 2);
  ws.emplace("SAT", 1);

  string S;
  cin >> S;

  cout << ws[S];
  

}
#endif


Measured memory_bytes: 256
#解説参照
k=int(input())
n=len(input())

mod=10**9+7
f=[1]+[1]
for i in range(2,n+k+1+26):
    f.append(f[-1]*i%mod)


inv = [0]+[1]
for i in range(2,n+k+2+26):
  inv += [inv[mod % i] * (mod - int(mod / i)) % mod]
 
inv_f=[1,1]
for i in range(2,n+k+2+26):
    inv_f.append(inv_f[-1]*inv[i]%mod)

def c(x,y):
    return f[x]*inv_f[x-y]*inv_f[y]
ans=0
prod=pow(25,k,mod)
for i in range(k+1):
    ans+=c(n+k-i-1,n-1)*prod#pow(25,k-i,mod)*pow(26,i,mod)
    prod*=26
    prod*=inv[25]
    prod%=mod
print(ans%mod)

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

int main(){
    int h,w;
    cin >> h >> w;
    vector<vector<char>>e(h,vector<char>(w));
    rep(i,h)rep(j,w) cin >> e[i][j];
    rep(i,h){
        rep(j,w){
            cout << e[i][j];
        }
        cout << endl;
        rep(j,w){
            cout << e[i][j];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(input())
b = list(input())
c = list(input())

cnt = 0

for i in range(n):
    if a[i] != b[i] and a[i] != c[i] and b[i] != c[i]:
        cnt += 2
    elif a[i] == b[i] and a[i] == c[i] and b[i] == c[i]:
        cnt += 0
    else:
        cnt += 1

print(cnt)


Measured memory_bytes: 3060