akhauriyash/Code-Regression huggingface dataset:
#[allow(unused)]
use std::cmp::{max, min};

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

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

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

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

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

    ($next:expr, 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")
    };
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

fn main() {
    input! {
        // usize
        // n: usize,
        // vec
        // v: [i64; n],
        n: i64,
        a: i64,
        b: i64,
    }

    println!("{}", std::cmp::min(n*a, b));
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
using namespace std;
int main(void){
  int N,M,X;
  cin >> N >> M >> X;
  
  vector<int>mass(N+1,0);
  
  int fee;
  for(int i=0;i<M;i++){
    cin >> fee;
    mass[fee] = 1;
  }
  
  int right = 0;
  int left = 0;
  for(int i=X;i<=N;i++){
    if(mass[i] == 1)
      right++;
  }
  
  for(int i=X;i>=0;i--){
    if(mass[i] == 1)
      left++;
  }
  
  if(right > left)
  cout << left << endl;
  else
  cout << right << endl;
  
  return 0;
}

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

#define ELEMENT_CNT_MIN 1
#define ELEMENT_CNT_MAX 10000
#define ELEMENT_MIN 2
#define ELEMENT_MAX 100000000

int get_int_sequence(int *p_num, int min, int max, int size);
int get_int(int *p_num, int min, int max);
int judge_constraint(int test_num, int min, int max);
int put_prime_cnt_in_list(int *p_num, int size);
int is_prime(int x);

int main(void){
    
    int element_num;
    int element[ELEMENT_CNT_MAX];
    
    if(get_int(&element_num, ELEMENT_CNT_MIN, ELEMENT_CNT_MAX) == -1)
    {
        return -1;
    }
    
    if(get_int_sequence(&element[0], ELEMENT_MIN, ELEMENT_MAX, element_num) == -1)
    {
        return -1;
    }
    
    printf("%d\n", put_prime_cnt_in_list(&element[0], element_num));
    
    return 0;
}

int is_prime(int x)
{
    int i;
    
    if(x == 2)
    {
        return 0;
    }
    if((x < 2) || (x % 2 == 0))
    {
        return 1;
    }
    /* target is odd num >= 3 */
    i = 3;
    while(i <= sqrt(x))
    {
        if(x % i == 0)
        {
            return 1;
        }
        i += 2;
    }
    
    return 0;
}

int put_prime_cnt_in_list(int *p_num, int size)
{
    int i;
    int cnt = 0;
    
    for(i = 0; i < size; i++)
    {
        if(is_prime(p_num[i]) == 0)
        {
            cnt++;
        }
    }
    
    return cnt;
}


int get_int_sequence(int *p_num, int min, int max, int size)
{
    int i;
    
    for(i = 0; i < size; i++)
    {
        if(get_int(&p_num[i], min, max) == -1)
        {
            return -1;
        }
    }
    
    return 0;
}

int get_int(int *p_num, int min, int max)
{
	scanf("%d", p_num);
	
	if(judge_constraint(*p_num, min, max) == -1)
    {
        return -1;
    }
	
	return 0;
}
int judge_constraint(int test_num, int min, int max)
{
    if(test_num < min || test_num > max)
    {
        return -1;
    }
    
    return 0;
}

Measured memory_bytes: 1856
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;
    if (e - a > k)
    {
        cout << ":(" << endl;
    }
    else
    {
        cout << "Yay!" << endl;
    }
    return 0;
}

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

const int INF = 1e9;
int main(){
  int w;
  scanf("%d",&w);
  vector<int> a(w),pop(w,0);
  for(int i=0;i<w;i++)scanf("%d",&a[i]);

  int t = 0;
  for(int i=0;i<w;i++){
    if(a[i]==0)t = INF;
    else if(a[i]<0)t = min(t,-a[i]);
    else{
      pop[i] = max(pop[i], t);
    }
    t--;
  }

  t = 0;
  for(int i=w-1;i>=0;i--){
    if(a[i]==0)t = INF;
    else if(a[i]<0)t = min(t,-a[i]);
    else{
      pop[i] = max(pop[i], t);
    }
    t--;
  }

  int ans = 0;
  for(int i=0;i<w;i++)ans += min(pop[i], abs(a[i]));
  cout << ans << endl;
}

Measured memory_bytes: 1796
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
ll mod = 1000000007;

int main() {
    int n, ans = 0;
    cin >> n;
    int p[n];
    rep(i, n) {
        cin >> p[i];
    }

    rep(i, n) {
        if(i == n-1 && p[i] == n) {
            ans++;
            break;
        }

        if(p[i] == i+1) {
            swap(p[i], p[i+1]);
            ans++;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    int n; cin>>n;
    vector <int> h(n); rep(i,n)cin>>h[i];
    vector <int> cost(n,0);
    cost[1] = abs(h[1]-h[0]);
    for(int i = 2; i<n; ++i){
        cost[i] = min(cost[i-1]+abs(h[i]-h[i-1]), cost[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<cost[n-1]<<endl;return 0;
}


Measured memory_bytes: 1024
if __name__ == "__main__":
    N = int(input())
    i = 1
    ans = 10
    while i*i <= N:
        if N%i == 0:
            f = max(len(str(i)), len(str(N//i)))
            ans = min(f, ans)
        i += 1
    
    print(ans)


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

class UnionFind{
public:
    vector<int> uni;
    UnionFind(int s);
    int root(int a);
    bool connect(int a, int b);
    bool isConnect(int a, int b);
    int size(int a);
};

inline UnionFind::UnionFind(int s) : uni(s, -1) {}

inline int UnionFind::root(int a) {
    if(uni[a] < 0) return a;
    else return uni[a] = root(uni[a]);
}

inline bool UnionFind::connect(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;
    if(uni[a] > uni[b]) swap(a, b);
    uni[a] = uni[a] + uni[b];
    uni[b] = a;
    return true;
}

inline bool UnionFind::isConnect(int a, int b){
    return root(a) == root(b);
}

inline int UnionFind::size(int a){
    return -uni[root(a)];
}

void solve() {
    int N, M;
    cin >> N >> M;
    vector<long long> ans(M);
    vector<int> A(M), B(M);
    for(int i = 0; i < M; ++i) {
        cin >> A[i] >> B[i];
        --A[i], --B[i];
    }
    UnionFind uf(N);
    map<int, int> ma;
    for(int i = M - 1; i >= 0; --i) {
        if(uf.isConnect(A[i], B[i])) continue;
        ans[i] = (long long)uf.size(A[i]) * uf.size(B[i]);
        uf.connect(A[i], B[i]);
    }
    for(int i = 0; i < M; ++i) {
        if(i) ans[i] += ans[i - 1];
        cout << ans[i] << '\n';
    }
}

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


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int,int> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb push_back;
#define sp " ";
void vout(vector<int> v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    int ans=0,n;
    cin>>n;
    rep(i,n){
        int ai;
        cin>>ai;
        while(true){
            if(ai%2==0){
                ans+=1;
                ai/=2;
            }
            else{break;}
        }
    }
    cout<<ans;
}

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

int main() {
	string s;
	int ans = 0;
	cin >> s;
	for (int i = 0;i < 4;i++) {
		if (s[i] == '+') ans++;
		else ans--;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int N=0;
	int h[201];
	int m[201];
	int M=0;
	int k[201];
	int g[201];
	int L=0;
	cin>>N;
	int tem=0;
	int i=0;
	
	int AH[201];
	int AM[201];
	int DH=100;
	int DM=100;
	for(int i=0;i<N;i++){
		cin>>h[i]>>m[i];
	}
	
	cin>>M;
	for(int i=0;i<M;i++){
		cin>>k[i]>>g[i];
	}
	int A=N+M;
	for(int i=0;i<M;i++){
		h[N+i]=k[i];
		m[N+i]=g[i];
	}
	
	for(int i=0;i<A-1;i++){
		for(int q=i;q<A-1;q++){
			 if(h[i]>h[q+1]){
				tem=h[i];
				h[i]=h[q+1];
				h[q+1]=tem;
				tem=m[i];
				m[i]=m[q+1];
				m[q+1]=tem;
				
			}
			
		}
	}
	for(int i=0;i<A-1;i++){
		for(int q=i;q<A-1;q++){
			if((h[i]==h[q+1])&&(m[i]>m[q+1])){
				tem=m[i];
				m[i]=m[q+1];
				m[q+1]=tem;
			}		
		}
	}
	
	int cont=0;
	for(int i=0;i<A;i++){
		if((DH!=h[i])||(DM!=m[i])){
			AH[cont]=h[i];
			DH=h[i];
			AM[cont]=m[i];
			DM=m[i];
			cont++;
		}
	}
	for(int i=0;i<cont;i++){
		if(AM[i]<=9){
			cout<<AH[i]<<":0"<<AM[i];
		}
		else{
			cout<<AH[i]<<":"<<AM[i];
		}
		if(i<cont-1){
			cout<<" ";
		}	
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    int N;
    ll h1, h2;
    cin >> N;
    int h[100000], c[100000];
    for(int i=0;i<N;i++)
        cin >> h[i];
    for(int i=1;i<N;i++){
    	if(i==1){
    	    c[i] = abs(h[i] - h[0]);
        }else{
        	h1 = c[i-1] + abs(h[i] - h[i-1]);
            h2 = c[i-2] + abs(h[i] - h[i-2]);
            if(h1 < h2)
                c[i] = h1;
            else
                c[i] = h2;
        }    
    }
    
    cout << c[N-1] << endl;
    return 0;
}

Measured memory_bytes: 1024
using System;
using System.IO;

namespace MinPro2019D
{
    public class Program
    {
        void Solve(StreamScanner ss, StreamWriter sw)
        {
            //---------------------------------
            var L = ss.Next(int.Parse);
            var dp = new long[5];

            for (var i = 0; i < L; i++)
            {
                var A = ss.Next(long.Parse);
                var x = A == 0 ? 2 : A & 1;

                dp[0] += A;
                dp[1] += x;
                dp[2] += (x & 1) ^ 1;
                dp[3] += x;
                dp[4] += A;

                for (var t = 1; t < 5; t++)
                {
                    dp[t] = Math.Min(dp[t], dp[t - 1]);
                }
            }

            sw.WriteLine(dp[4]);
            //---------------------------------
        }

        static void Main()
        {
            var ss = new StreamScanner(new StreamReader(Console.OpenStandardInput()));
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            new Program().Solve(ss, sw);
            sw.Flush();
        }
    }

    public class StreamScanner
    {
        static readonly char[] Separator = { ' ' };
        readonly TextReader textReader;

        string[] line = new string[0];
        int index = 0;

        public StreamScanner(TextReader textReader)
        {
            this.textReader = textReader;
        }

        public T Next<T>(Func<string, T> parser)
        {
            if (index < line.Length) return parser(line[index++]);
            index = 0;
            line = textReader.ReadLine().Split(Separator, StringSplitOptions.RemoveEmptyEntries);
            return Next(parser);
        }

        public T[] Next<T>(Func<string, T> parser, int x)
        {
            var ret = new T[x];
            for (var i = 0; i < x; ++i) ret[i] = Next(parser);
            return ret;
        }

        public T[][] Next<T>(Func<string, T> parser, int x, int y)
        {
            var ret = new T[y][];
            for (var i = 0; i < y; ++i) ret[i] = Next(parser, x);
            return ret;
        }
    }
}


Measured memory_bytes: 17344
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
 LL a[7],n,ans=0;
int main()
{
    cin>>n;
    LL ma=999999999999999999;
    for(int i=2;i<=6;i++)
        {cin>>a[i];
         ma=min(ma,a[i]);
        }
    if (n%ma==0) ans=n/ma;
    else ans=(n/ma+1);
  cout<<ans+4<<endl;

    //cout << "Hello world!" << endl;
    return 0;
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int64_t x,k,d; cin>>x>>k>>d; x=abs(x);
	int64_t mn=(x+d-1)/d;
	if(mn>k){
		cout<<x-k*d;
	}
	else{
		if((mn+k)%2)cout<<abs(x-d*(mn-1));
		else cout<<abs(x-d*mn);
	}
	cout<<"\n"s;
}


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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left != NIL)
    x = x->left;
  return x;
}

Node treeMaximum(Node x){
  while(x->right != NIL)
    x = x->right;
  return x;
}

Node treeSearch(Node u, int k){
  if(u == NIL || k == u->key)
    return u;
  if(k < u->key)
    return treeSearch(u->left, k);
  else
    return treeSearch(u->right, k);
}

Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL)
    return treeMinimum(x->right);

  y = x->parent;

  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted                                                                  
  Node x; // child of y                                                                          



}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key)
      x = x->left;
    else
      x = x->right;
  }
  z->parent = y;

  if(y == NIL)
    root = z;
  else if(z->key < y->key)
    y->left = z;
  else
    y->right = z;
}

void inorder(Node u){
  if(u != NIL){
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
  }
}
void preorder(Node u){
  if(u != NIL){
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
  }
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



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

int a[105];

int main() {

    int x, n;
    cin>>x>>n;

    for(int i=1; i<=n; i++) {
        cin>>a[i];
    }

    int c = 0;

    while(1) {

        bool flag = true;
        int n1 = x-c;

        for(int i=1; i<=n; i++) {

            if(a[i] == n1) {
                flag = false;
                break;
            }
        }

        if(flag) {
            cout<<n1<<endl;
            return 0;
        }

        int n2 = x+c;
        flag = true;

        for(int i=1; i<=n; i++) {
            if(a[i] == n2) {
                flag = false;
                break;
            }
        }

        if(flag) {
            cout<<n2<<endl;
            return 0;
        }

        c++;
    }
}


Measured memory_bytes: 3628
from collections import deque

N, Q, *ABPX = map(int, open(0).read().split())
AB, PX = ABPX[:2 * (N - 1)], ABPX[2 * (N - 1):]

E = [[] for _ in range(N + 1)]
for a, b in zip(*[iter(AB)] * 2):
    E[a].append(b)
    E[b].append(a)

C = [0] * (N + 1)
for p, x in zip(*[iter(PX)] * 2):
    C[p] += x

ans = [0] * (N + 1)
visited = [False] * (N + 1)

Q = deque([(1, 0)])
while Q:
    v, c = Q.popleft()
    visited[v] = True

    ans[v] = c + C[v]

    for u in E[v]:
        if visited[u]:
            continue
        Q.append((u, c + C[v]))

print(*ans[1:])

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

int main() {
  vector<int>n(32);
  int K;
  cin >> K;
  n={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout << n.at(K-1) << endl;
}

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

int main() {

  int H,W;
  cin >> H >> W;

  int num = 0;
  vector<pair<int,int>> from(0),to(0);
  vector<vector<int>> a(H,vector<int>(W));
  for(int i = 0;i < H;i++) {
    for(int j = 0;j < W;j++) {
      cin >> a.at(i).at(j);
    }
  }

  for(int i = 0;i < H;i++) {
    for(int j = 0;j < W;j++) {
      if(a.at(i).at(j) % 2 != 0) {
        if(j < W-1) {
          from.push_back(make_pair(i,j));
          to.push_back(make_pair(i,j+1));
          a.at(i).at(j+1)++;
        }else if(i < H-1 && j == W-1) {
          from.push_back(make_pair(i,j));
          to.push_back(make_pair(i+1,j));
          a.at(i+1).at(j)++;
        }
        if(i == H-1 && j == W-1) break;
        num++;
      }
    }
  }

  cout << num << endl;
  for(int i = 0;i < num;i++) {
      cout << from.at(i).first+1 << " " << from.at(i).second+1 << " " << to.at(i).first+1 << " " << to.at(i).second+1 << endl;
  }
}


Measured memory_bytes: 5228
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <regex>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;

const int MAX = 100000;

int main() {
	int N, K;
	int A[MAX];

	cin >> N >> K;
	for (int i = 0; i < N; i++)cin >> A[i];

	int ans = (N - 1) / (K - 1);
	if ((N - 1) % (K - 1))ans += 1;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
# define MOD 1000000007
int dp[21][10000001];
int util(int** arr, int n,int i, int mask){
    if(i == n) return 1;
    if(dp[i][mask] != -1) return dp[i][mask];
    int res = 0;
    for(int j=0;j<n;j++){
        int curr_bit = 1<<j;
        if(arr[i][j] == 1 and (mask&curr_bit) == 0){
            mask += curr_bit;
            res = (res + util(arr, n, i+1, mask))%MOD;
            mask -= curr_bit;
        }
    }
    return dp[i][mask] = res;
}
int main() {
	int n;
	cin>>n;
	int** arr = new int*[n];
	for(int i=0;i<n;i++){
	    arr[i] = new int[n];
	    for(int j=0;j<n;j++){
	        cin>>arr[i][j];
	    }
	}
	memset(dp, -1, sizeof(dp));
	int res = util(arr, n, 0, 0);
	cout<<res;
	return 0;
}

Measured memory_bytes: 820608
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    long long n, k;
    cin >> n >> k;
    if(k == 0){
        cout << n * n;
        return 0;
    }
    long long ans = 0;
    for(long long i = k + 1; i <= n; i++){
        long long j = (n - k + i) / i;
        int x = (k + i * (j - 1) + i - k - 1 - n);
        ans += (i - k) * j - max(0, x);
    }
    cout << ans;
    
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,a,ak,h;
    cin>>n>>k>>a;
    h=a;
    for(int i=2;i<=n;i++)
    {
        cin>>ak;
        a=__gcd(a,ak);
        h=max(ak,h);
    }
    if(k%a==0&&k<=h)cout<<"POSSIBLE"<<endl;
    else cout<<"IMPOSSIBLE"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main()
{
   string S;
   cin>>S;
   if(S=="Sunny"){
    cout<<"Cloudy";
   }
   if(S=="Cloudy"){
    cout<<"Rainy";
   }
   if(S=="Rainy"){
    cout<<"Sunny";
   }
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys

def io_generator():
	while True:
		yield raw_input()

#+++++++++++++++++++

def main(io):
	a, b,c= map(int, io.next().split())
	return str((a*b*c)/(2*max(a,b,c)))


#++++++++++++++++++++

if __name__ == "__main__":
	io=io_generator()
	print main(io)


Measured memory_bytes: 2568
#pragma comment(linker, "/stack:200000000")

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define int long long
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) return cout<<a,0;

using namespace std;

mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

typedef pair < int , int > pii ;
typedef pair < long long  , long long > pll ;

const int N = 2e5 + 123;	
int n , m ,  k;
bool was[1000];
int get(vector < int > &v , int pos){
    int l = 0 , r = sz(v) - 1 , res = -1;
    while(l <= r){
		int m = (l + r) >> 1;
		if(v[m] > pos){
			res = v[m];
			r = m - 1;
		}
		else 
			l = m + 1;
    }
    return res;
}
main(){
	ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
	string s , t;
	cin >> s >> t;
	vector < int > gr[80];
	for(int i = 0 ; i < sz(s) ; i++){
		was[s[i]] = 1;
		gr[s[i] - 'a'].pb(i);
	}
	for(int i = 0 ; i < sz(t) ;i++){
		if(!was[t[i]])
			ret(-1);
	}
	int x = -1;
	x = gr[t[0] - 'a'][0];
	int ans = 1;
	for(int i = 1 ; i < sz(t) ; i++){
		int tmp = get(gr[t[i] - 'a'] , x);
		if(tmp == -1){
			ans++;
			x = gr[t[i] - 'a'][0];
		}
		else {
			x = tmp;
		}
	}
	cout << (ans - 1)* (sz(s)) + x + 1;
}

Measured memory_bytes: 1736
sx, sy, tx, ty = map(int, input().split())

ans = ''
if sx <= tx and sy <= ty:
    ans += 'R'*abs(sx-tx) + 'U'*abs(sy-ty) + 'L'*abs(sx-tx) + 'D'*abs(sy-ty)
    ans += 'L' + 'U'*(abs(ty-sy)+1) + 'R'*(abs(tx-sx)+1) + 'D'
    ans += 'R' + 'D'*(abs(ty-sy)+1) + 'L'*(abs(tx-sx)+1) + 'U'
    print(ans)
elif sx > tx and sy <= ty:
    ans += 'L'*abs(sx-tx) + 'U'*abs(sy-ty) + 'R'*abs(sx-tx) + 'D'*abs(sy-ty)
    ans += 'R' + 'U'*(abs(ty-sy)+1) + 'L'*(abs(tx-sx)+1) + 'D'
    ans += 'L' + 'D'*(abs(ty-sy)+1) + 'R'*(abs(tx-sx)+1) + 'U'
    print(ans)
elif sx > tx and sy > ty:
    ans += 'L'*abs(sx-tx) + 'D'*abs(sy-ty) + 'R'*abs(sx-tx) + 'U'*abs(sy-ty)
    ans += 'R' + 'D'*(abs(ty-sy)+1) + 'L'*(abs(tx-sx)+1) + 'U'
    ans += 'L' + 'U'*(abs(ty-sy)+1) + 'R'*(abs(tx-sx)+1) + 'D'
    print(ans)
elif sx <= tx and sy > ty:
    ans += 'R'*abs(sx-tx) + 'D'*abs(sy-ty) + 'L'*abs(sx-tx) + 'U'*abs(sy-ty)
    ans += 'L' + 'D'*(abs(ty-sy)+1) + 'R'*(abs(tx-sx)+1) + 'U'
    ans += 'R' + 'U'*(abs(ty-sy)+1) + 'L'*(abs(tx-sx)+1) + 'D'
    print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


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

    ll ans = k;
    rep(i, n-1){
        ans *= k-1;
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
<?php
$nums = explode(' ', trim(fgets(STDIN)));
sort($nums);

if($nums[0] <= $nums[1] && $nums[1] == $nums[2])
{
    echo $nums[0] + (10 * $nums[1] + $nums[2]);
}
else
{
    echo (10 * $nums[2] + $nums[1]) + $nums[0];
}

Measured memory_bytes: 3828
N, M = map(int, input().split())

# print(N)
# print(M)

A = []
for i in range(N):
	tmp = input()
	# print(tmp)
	A.append(tmp)

B = []
for i in range(M):
	tmp = input()
	# print(tmp)
	B.append(tmp)
	
# print(A)
# print(B)
# print(''.join(B))


flag = False
for i in range(N - M + 1):
	for j in range(N - M + 1):
		# print(i)
		# print(j)
		
		lst = []
		for k in range(M):
			for l in range(M):
				lst.append(A[k + i][l + j])
		# print(lst)
		# print(''.join(lst))
		# print(''.join(B) == ''.join(lst))
		if ''.join(B) == ''.join(lst):
			flag = True
			
if flag:
	print('Yes')
else:
	print('No')


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin >> n;
	string s[n];
	for(int i=0;i<n;i++)	cin >> s[i];
	sort(s,s+n);
	int ans=1,c=1;
	for(int i=0;i<n-1;i++){
		if(s[i]==s[i+1])	c++;
		else{
			ans++;
			c=1;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 9880
// We only fail when we stop trying
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()

const int N = 1e5 + 5;

int n;
int cost[N][3];
int dp[N][3];

int main()
{
  cin >> n;
  for(int i = 0 ; i < n ; i++)
    for(int j = 0 ; j < 3 ; j++)
      cin >> cost[i][j];
  for(int i = 1 ; i <= n ; i++) {
    for(int j = 0 ; j < 3 ; j++) {
      dp[i][j] = 0;
      for(int last = 0; last < 3; last++)
        if(last != j)
          dp[i][j] = max(dp[i][j], dp[i - 1][last] + cost[i - 1][j]);
    }
  }
  cout << max(max(dp[n][0], dp[n][1]), dp[n][2]);
  return 0;
}


Measured memory_bytes: 2560
import sys
from heapq import *

input = sys.stdin.readline

N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

dif = [x-y for (x,y) in zip(A,B)]
difh = []
for i, d in enumerate(dif):
	heappush(difh, (d,i))

ans = 0
while difh[0][0]!=0:
	tv, ti = difh[0]
	if ti==0:
		ll, rr = B[-1], B[1]
	elif ti==N-1:
		ll, rr = B[N-2], B[0]
	else:
		ll, rr = B[ti-1], B[ti+1]

	plus = int((-tv)/(ll+rr))
	if plus==0:
		ans=-1
		break
	else:
		tv += (ll+rr)*plus
		ans += plus
		B[ti] = A[ti]-tv
		heappushpop(difh, (tv, ti))

print(ans)

Measured memory_bytes: 124708
#include <bits/stdc++.h>
using namespace std;
using ii = long long;
const ii mod = 1e9+7;
ii _dp[2][100100];
#define dp _dp[z]
#define pd _dp[!z]
int main()
{
    int n, k, z = 1;
    cin >> n >> k;
    dp[0] = 1;
    for (int i = 1; i <= n; ++i) {
        z = !z;
        int x;
        cin >> x;
        ii s = 0;
        for (int j = 0; j <= k; ++j) {
            s += pd[j];
            s %= mod;
            dp[j] = s;
            if (j >= x) {
                s = (s - pd[j - x] + mod) % mod;
            }
        }
    }
    cout << dp[k] << "\n";
}


Measured memory_bytes: 1792
// dile a la jardinera que traigo flores

#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define sz(x) int(x.size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define FER(i,a,b) for(int i = int(a); i < int(b); ++i)
#define IFR(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;


int main(){	
	fastio;
	int a,b;cin>>a>>b;
	int val1=2*a-1;
	int val2=2*b-1;
	int val=a+b;
	cout<<max(val1,max(val2,val))<<endl;
	return 0;
}


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

using namespace std;

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (auto &a : A) cin >> a;

  int g = A[0];
  for (int i = 1; i < N; i++) {
    g = gcd(g, A[i]);
  }
  cout << g << endl;

  return 0;
}
/* vim:set fdm=marker: */


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

int A[100010];
int ans;
int MIN = 0;

int main()
{
    int N;
    scanf("%d",&N);
    for(int i = 0; i < N; i++)
    {
        scanf("%d",A + i);
        ans += A[i];
        if(MIN < A[i])MIN = A[i];
    }
    printf("%d\n",ans - MIN / 2);
    return 0;
}


Measured memory_bytes: 256
import sys

input = lambda: sys.stdin.readline().rstrip()


def kaibun(s):
    if list(s) == list(reversed(s)):
        return True
    else:
        return False


def solve():
    S = input()
    N = len(S)

    flag = True
    flag &= kaibun(S)

    s2 = S[0:(N - 1) // 2]
    flag &= kaibun(s2)

    s3 = S[(N + 3) // 2 - 1:N]
    flag &= kaibun(s3)

    if flag:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int n,M[101][101];
int visit[101],d[101],f[101],t;
const int WHITE=0;//未訪問
const int BLACK=1;//訪問した

void dfs(int u){
  visit[u]=BLACK;//訪問はした
  d[u]=++t;//発見した時刻
  for(int v=0;v<n;v++){
    if(M[u][v]==0) continue;//辺がない
    if(visit[v]==WHITE){//訪問していない
      dfs(v);//vを始点として探索
    }
  }
  f[u]=++t;//訪問完了時刻
}



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

  for(int i=0;i<n;i++){
    cin>>u>>k;
    u--;
    for(int j=0;j<k;j++){
      cin>>v;
      v--;
      M[u][v]=1;
    }
  }

 
 
  for(int i=0;i<n;i++){
    if(visit[i]==WHITE){//訪問していないか
      dfs(i);
    }
  }
  for(int i=0;i<n;i++){
    cout<<i+1<<" "<<d[i]<<" "<<f[i]<<endl;
  }

  
  return 0;
}
  


Measured memory_bytes: 3112
import math as m

x = int(input())

def isPrime(x):
	if x <= 2:
		return True
	
	if x % 2 == 0:
		return False
	
	n = m.floor(m.sqrt(x))
	
	for i in range(3, n, 2):
		if x % i == 0:
			return False
	
	return True



for i in range(x, 2 * x - 1):
	if isPrime(i):
		print(i)
		break



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

using namespace std;

const int maxn=1e5+10; 

#define pt pair<double,double> 
#define x first 
#define y second 

double cross2( pt o , pt a , pt b ){
	return ( a.x - o.x )*( b.y - o.y ) - ( a.y - o.y )*( b.x - o.x );
} 
pt p[ maxn ];
int n; 
vector<pt> hull; 
void convexhull(){ 
	hull.push_back( p[ 0 ] ); 
	for( int i = 1 ; i < n ; i++ ){ 
		while( hull.size() > 1 && cross2( hull[ hull.size()-2 ] , hull.back() , p[ i ] ) > 0){
			hull.pop_back(); 
		}
		hull.push_back( p[ i ] );
	}
	int hs = hull.size(); 
	for( int i = n-2 ; i >= 0 ; i-- ){ 
		while( hull.size() > hs && cross2( hull[ hull.size()-2 ] , hull.back() , p[ i ] ) > 0){
			hull.pop_back();
		}
		hull.push_back( p[ i ] );
	}
} 
int main(){
	//printf("Double value is %lf \n", dbl);
	//printf("Integer value is %d\n" , no);
	//printf("%lf can be written %le\n", dip, dip);
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n; 
	for( int i = 0 ; i < n ; i++ ){
		cin >> p[ i ].x >> p[ i ].y;
	}
	sort( p , p+n ); 
	convexhull(); 
	//the first point is repeated at last! 
	hull.pop_back(); 
	cout << hull.size() << endl; 
	int my = 1e6 , mx = 1e6 , ind; 
	for( int i = 0 ; i < hull.size() ; i++ ){
		if( hull[i].y < my ){
			my = hull[i].y , mx = hull[ i ].x , ind = i;
		}
		else if( hull[ i ].y == my && mx > hull[ i ].x ){
			mx = hull[ i ].x , ind = i;
		}
	}
	for( int i = ind , cnt = hull.size() ; cnt ; cnt-- , i = ( i-1 + hull.size() ) % hull.size() ){
		cout << hull[ i ].x << " " << hull[ i ].y << endl;
	}
}


Measured memory_bytes: 6080
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

#include <complex>
typedef complex<double> Point;
typedef vector<Point> Polygon;
static const double INF = 1e+5;

#define CURR(P, i) (P[i])
#define NEXT(P, i) (P[(i + 1) % P.size()])

struct Line : public vector<Point> {
  Line() {;}
  Line(Point a, Point b) { push_back(a); push_back(b); }
};

inline double cross(const Point &a, const Point &b) {
  return imag(conj(a) * b);
}

inline double dot(const Point &a, const Point &b) {
  return real(conj(a) * b);
}

int ccw(Point a, Point b, Point c) {
  b -= a; c -= a;
  if (cross(b, c) > 0) { return 1; }
  if (cross(b, c) < 0) { return -1; }
  if (dot(b, c) < 0) { return 2; }
  if (norm(b) < norm(c)) { return -2; }
  return 0;
}

Point crosspointSS(const Line &l, const Line &m) {
  double A = cross(l[1] - l[0], m[1] - m[0]);
  double B = cross(l[1] - l[0], l[1] - m[0]);
  if (abs(A) < EPS && abs(B) < EPS) { return m[0]; }
  return m[0] + B / A * (m[1] - m[0]);
}

Polygon convex_cut(const Polygon &P, const Line &l) {
  Polygon Q;
  REP(i, P.size()) {
    Point A = CURR(P, i), B = NEXT(P, i);
    if (ccw(l[0], l[1], A) != -1) { Q.push_back(A); }
    if (ccw(l[0], l[1], A) * ccw(l[0], l[1], B) < 0) {
      Q.push_back(crosspointSS(Line(A, B), l));
    }
  }
  return Q;
}

Line move(Line l, double dist) {
  Point vect2 = l[1] - l[0];
  Point vect = vect2 * Point(0, 1);
  vect *= dist / abs(vect);
  l[0] += vect;
  l[1] += vect;
  l[1] += vect2 * INF;
  l[0] -= vect2 * INF;
  return l;
}

Polygon iniP;
bool cut(Polygon poly, double l) {
  REP(i, iniP.size()) {
    poly = convex_cut(poly, move(Line(CURR(iniP, i), NEXT(iniP, i)), l));
    if (poly.size() == 0) { return false; }
  }
  return true;
}

int main() {
  int n;
  while (scanf("%d", &n), n) {
    iniP.clear();
    REP(i, n) {
      double x, y;
      scanf("%lf %lf", &x, &y);
      iniP.push_back(Point(x, y));
    }
    double left = 0;
    double right = 1e+5;
    REP(i, 100) {
      double mid = (left + right) / 2.0;
      if (cut(iniP, mid)) {
        left = mid;
      } else {
        right = mid;
      }
    }
    printf("%.5f\n", left);
  }
}

Measured memory_bytes: 1004
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

map<ll,ll> prime_factor(ll n) {
	map<ll,ll> res;
	for(ll i=2; i*i <= n; i++) {
		while(n%i == 0) {
			res[i]++;
			n /= i;
		}
	}

	if(n != 1) res[n] = 1;
	return res;
}

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

	rep(i, n) {
		int m, n;
		cin >> m >> n;

		int s = m * m + n * n;
		int cnt = 0;

		REP(i, 1, s + 1) {
			if(s % i == 0) {
				map<ll, ll> ret = prime_factor(s / i);
				map<ll, ll>::iterator ite;
				bool flag = true;
				for(ite = ret.begin(); ite != ret.end(); ite++) {
					if(ite->first  % 4 != 3) continue;
					if(ite->second % 2 == 0) continue;
					flag = false;
				}

				if(flag) {
					cnt++;
				}
			}
		}

		if(cnt >= 3) cout << "C" << endl;
		else cout << "P" << endl;
	}

	return 0;
}

Measured memory_bytes: 1188
def isMM(N0,N1):
  if N0*10 + N1>= 13:
    return False
  elif N0==0 and N1==0:
    return False
  else:
    return True
    
S = input()

N0 = int(S[0:1])
N1 = int(S[1:2])
N2 = int(S[2:3])
N3 = int(S[3:4])

D0 = isMM(N0,N1)
D1 = isMM(N2,N3)

if D0 and D1:
  print('AMBIGUOUS')
elif not(D0) and not(D1):
  print('NA')
elif D0:
  print('MMYY')
else:
  print('YYMM')




Measured memory_bytes: 3064
/*Author - Shubham Gupta (@shubham107)*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<ll> vl;      typedef vector<int> vi;
typedef vector<vl> vvl;     typedef vector<vi> vvi;
typedef pair<ll, ll> pll;   typedef pair<int, int> pii;
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(int i=1;i<=n;i++)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define INF ll(1e18)
#ifdef SHUBHAM107
#include "../trace.h"
#else
#define trace(args...)
#endif
void solve() {
    int n;
    cin >> n;
    ll ans = 0;
    vi divs(n + 1, 0);
    for(int i = 1; i <= n; i++) {
        for(int j = i; j <= n; j += i) {
            divs[j]++;
        }
        ans += divs[i] * 1LL * i;
    }
    cout << ans;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifdef SHUBHAM107
    freopen("inp.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("err.txt", "w", stderr);
#endif
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}


Measured memory_bytes: 42260
#define taskname "test"

#include <bits/stdc++.h>

using namespace std;

#define sz(x) (int)x.size()
#define fi first
#define se second

typedef long long lli;
typedef pair<int, int> pii;

string s, t;

void read_input()
{
    cin >> s;
    cin >> t;
}

void solve()
{
    int ans = sz(t);
    for(int i = 0; i < sz(s); ++i)
    {
        if(i + sz(t) - 1 >= sz(s)) break;
        int cnt = 0;
        for(int j = 0; j < sz(t); ++j)
            if(s[i + j] != t[j]) ++cnt;
        ans = min(ans, cnt);
    }
    cout << ans << '\n';
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    read_input();
    solve();
}



Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define len(array) (sizeof(array) / sizeof(array[0]))

int main() {
  int n;cin>>n;
  int cnt = 50;
  long a;
  rep(i,n) {
    cin>>a;
    int k = 0;
    while (a%2==0) {
      k++;
      a /= 2;
    }
    cnt = min(cnt, k);
  }
  cout << cnt;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <utility>
#include <stack>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i ++)
using ll = long long;
int N;
double P[3000];
double dp[3000][3000];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> N;
    rep(i, N) cin >> P[i];
    rep(i, N) dp[0][i] = 0.0;
    dp[0][0] = 1.0;
    for (int i = 1; i <= N; i ++) {
        for (int j = 0; j <= i; j ++) {
            dp[i][j] = dp[i-1][j] * (1 - P[i-1]);
            if (j > 0) dp[i][j] += dp[i-1][j-1] * P[i-1];
        } 
    }
    double ans = 0;
    for (int j = N / 2 + 1; j <= N; j ++) {
        ans += dp[N][j];
    }
    cout.precision(17);
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define range(i, m, n) for(int i = m; i < n; i++)
#define husk(i, m, n) for(int i = m; i > n; i--)

int n;

int main() {
  cin >> n;
  vector<int> a(n), b(n);
  range(i, 0, n) {
    cin >> a[i];
  }
  range(i, 0, n) {
    cin >> b[i];
  }
  vector<int> pos;
  range(i, 0, n) {
    if(a[i] == b[i]) continue;
    else {
      int s = b[(i + n - 1) % n] + b[(i + 1) % n];
      if(b[i] > s) pos.push_back(i);
    }
  }
  auto pull = [&](int p) {
    if(b[p] == a[p]) return;
    int pr = (p + n - 1) % n, nxt = (p + 1) % n;
    if(b[p] > b[pr] + b[nxt]) pos.push_back(p);
  };
  long long cnt = 0;
  while(pos.size()) {
    int p = pos.back();
    pos.pop_back();
    int pr = (p + n - 1) % n, nxt = (p + 1) % n;
    int s = b[pr] + b[nxt];
    int c = b[p] % s;
    if(a[p] >= c) {
      if(a[p] % s == c) {
        cnt += (b[p] - a[p]) / s;
        b[p] = a[p];
      } else {
        cout << -1;
        return 0;
      }
    } else {
      cnt += (b[p] - c) / s;
      b[p] = c;
    }
    pull(pr);
    pull(nxt);
  }
  range(i, 0, n) {
    if(a[i] != b[i]) {
      cout << -1;
      return 0;
    }
  }
  cout << cnt;
  return 0;
}


Measured memory_bytes: 2428
#include <string>
#include <iostream>
#include <vector>

using namespace std;

int main(){
  long int A, B, K;
  cin >> A >> B >> K;
  
  /*
  for(long int i=0;i<K;i++){
    if(A>=1) A-=1;
    else if(B>=1) B-=1;
  }
  */
  
  if(K < A) cout << A-K << " " << B << endl;
  else if(K-A < B) cout << 0 << " " << B-(K-A) << endl;
  else cout << 0 << " " << 0 << endl;
  
  //cout << A << " " << B << 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)
using ll = long long;
using P = pair<int,int>;

int main(){
  int n,t;
  cin >> n >> t;
  vector<int> c(n);
  vector<int> d(n);
  rep(i,n){
    cin >> c[i] >> d[i];
    if(d[i] > t) c[i] = 1001;
  }
  sort(c.begin(),c.end());
  if(c[0] == 1001) puts("TLE");
  else cout << c[0] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
char mp[100][100];
int n,m;
bool check(int i,int j){
    if(i-1>=0&&mp[i-1][j]=='#')return true;
    if(i+1<n&&mp[i+1][j]=='#')return true;
    if(j-1>=0&&mp[i][j-1]=='#')return true;
    if(j+1<m&&mp[i][j+1]=='#')return true;
    return false;
}
int main(){

    cin>>n>>m;
    int cnt = 0;

    for(int i = 0;i < n;i++)
        for(int j = 0;j < m;j++) {
            cin>>mp[i][j];
            if(mp[i][j] == '#') cnt++;
        }
    if(cnt==1)printf("Yes");
    else{
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                if(mp[i][j]=='#'&&!check(i,j)){
                        printf("No");
                        return 0;
                }
            }
        }
    }
    printf("Yes");

    return 0;
}


Measured memory_bytes: 256
s=input()
t=input()
d={}
l=[]
for i in range(len(s)):
  if s[i] in d and d[s[i]]!=t[i]:
    print('No') 
    exit()
  d[s[i]]=t[i]
if len(d.values())!=len(set(d.values())):
  print('No')
  exit()
print('Yes')

Measured memory_bytes: 3632
s = str(input())

flg = 0

for i in range(len(s)):
    #偶数
    if i%2 == 0 and s[i] == "L":
        flg = 1
    #奇数        
    elif i%2 ==1 and s[i] == "R":
        flg = 1


if flg == 1:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 2940
n=gets.to_i
score={}
n.times do |i|
  s,p=gets.chomp.split
  p = p.to_i
  if !score.has_key?(s)
    score[s] = []
  end
  score[s] << [p,i+1]
end
score.keys.sort.each do |k|
  score[k].sort {|a,b| a[0] <=> b[0]}.reverse.each do |ss,pp|
    puts pp
  end
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
 
const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

int n, m;
vector<int> e[100000];

bool dfs(int pos, int g, int pre, int ori) {
    rep(i,e[pos].size()) {
        if (e[pos][i] == pre) continue;
        if (e[pos][i] == g) continue;
        if (e[pos][i] == ori) return true;
        if (dfs(e[pos][i], g, pos, ori)) return true;
    }
    return false;
}

int main() {
    cin >> n >> m;
    rep(i,m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        e[a].push_back(b);
        e[b].push_back(a);
    }
    int res = 0;
    rep(i,n) {
        if (e[i].size()%2) {
            cout << "No" << endl;
            return 0;
        }
        res += e[i].size()-2;
    }
    if (res > 4) {
        cout << "Yes" << endl;
    } else {
        if (res == 4) {
            int x = -1, y;
            rep(i,n) {
                if (e[i].size() == 6) {
                    cout << "Yes" << endl;
                    return 0;
                }
                if (e[i].size() == 4) {
                    if (x == -1) x = i;
                    else y = i;
                }
            }
            if (dfs(x, y, -1, x)) cout << "Yes" << endl;
            else cout << "No" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}



Measured memory_bytes: 7680
#include <iostream>
        #include <vector>
        #include <string>
        #include <stack>
        #include <bits/stdc++.h>
        #include <algorithm>
        using namespace std;
        #define M 1000000007

        int binarySearch(vector<int> input, int target){
            int start = 0;
            int end = input.size() -1;
            int result = -1;
            while(start<=end){
                int mid = end - (end-start)/2;
                if(input[mid]==target){
                    result = mid;
                    start = mid+1;
                }else if(input[mid]>target){
                    end = mid-1;
                }else{
                    start = mid+1;
                }
            }
            return result;
        }
        int lis(vector<int> v, int n, int maxVal){
            if(n==0)
                return 0;
            if(v[n-1]<maxVal){
                return max( 1+lis(v, n-1, v[n-1]), lis(v, n-1, maxVal) );
            }else
            return lis(v, n-1, maxVal);
        }
        void sw(string &s, int i, int j){
            char temp = s[i];
            s[i] = s[j];
            s[j] = temp;
        }
        void swap(string &s, int i, int j){
            for(int l=j; l>i; l--){
                sw(s, l, l-1);
            }
        }

        int get(int n){
            if(n%2==1)
                return n;
            return get(n/2);
        }

void dfs(vector<vector<int>> &graph, vector<bool> &visited, int start, int curr, int &max){
    if(visited[start])
    return;


    visited[start] = true;
    for(auto i: graph[start]){
        dfs(graph, visited, i, curr+1, max);
    }
}
long long dp[405][405];
long long solve(long long a[], long long  psum[], int i, int j){
    if(i>=j)
        return 0;

    long long minVal = LLONG_MAX;
    if(dp[i][j]!=-1)
        return dp[i][j];
    for(int k=i; k<j; k++){
        long long tempAns = solve(a, psum, i,k) + solve(a, psum, k+1, j) + psum[j] - psum[i]
        + a[i];
        if(tempAns<=minVal)
            minVal = tempAns;
    }
    return dp[i][j] = minVal;
}

    int main(){
            #ifndef ONLINE_JUDGE
            freopen("input.in", "r", stdin);
            freopen("output.in", "w", stdout);
            #endif

            for(int i=0; i<405; i++){
                for(int j=0; j<405; j++){
                    dp[i][j] = -1;
                }
            }
            int n;
            cin>>n;
            long long  a[n];
            long long  psum[n];
            for(int i=0; i<n; i++)
                cin>>a[i];
            psum[0] = a[0];
            for(int i=1; i<n; i++){
                psum[i] = psum[i-1] + a[i];
               // cout<<psum[i]<<" ";
            }
            long long  t = solve(a, psum, 0, n-1);
            cout<<t<<"\n";

   }


Measured memory_bytes: 4928
from math import gcd
from collections import defaultdict

N, M = map(int, input().split())
S = input()
T = input()
g = N//gcd(N, M)*M
ans = defaultdict(bool)
for i in range(N):
    ans[i*g//N] = S[i]
ok = True
for i in range(M):
    idx = i*g//M
    if ans[idx] and ans[idx] != T[i]:
        ok = False
        break
if ok:
    print(g)
else:
    print(-1)


Measured memory_bytes: 19860