akhauriyash/Code-Regression huggingface dataset:
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[]]*num
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

r = I()
print(r**2)

Measured memory_bytes: 38384
#include<stdio.h>
int main(void){
  int S,a,b;
  scanf("%d",&S);
  a=S/100;
  b=S%100;
  if(a>=1 && a<=12){
    if(b>=1 && b<=12){
      printf("AMBIGUOUS\n");
    }else{
      printf("MMYY\n");
    }
  }else{
    if(b>=1 && b<=12){
      printf("YYMM\n");
    }else{
      printf("NA\n");
    }
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define ld          long double

int enc(pair<int,int>x)
{
	int a=min(x.first, x.second);
	int b=max(x.first, x.second);
	int r=1005*a+b;
	return r;
}

void solve()  
{
	int n; cin>>n;
	vector<vector<int>>g(2000000);
	vector<int>ind(2000000, 0);
	vector<int>vis(2000000, 0);
	vector<vector<int>>a(n, vector<int>(n-1));
	for(int i=0; i<n; i++)
	{
		for(int j=0; j<n-1; j++)
		{
			int x; cin>>x;
			x--;
			a[i][j]=x;
		}
	}
	vector<int>dp(n);
	for(int i=0; i<n; i++)
	{
		for(int j=0; j+1<n-1; j++)
		{
			int from=enc({i, a[i][j]});
			int to=enc({i, a[i][j+1]});
			g[from].push_back(to);
			ind[to]++;
		}
	}
	int mx=2000000;
	int days=0;
	int cnt=0;
	queue<int>q;
	for(int i=0; i<mx; i++)
	{
		if(ind[i]==0)
		{
			q.push(i);
		}
	}
	while(!q.empty())
	{
		days++;
		cnt+=q.size();
		queue<int>tq;
		while(!q.empty())
		{
			int f=q.front();
			vis[f]=1;
			q.pop();
			for(int d : g[f])
			{
				if(!vis[d])
				{
					ind[d]--;
					if(ind[d]==0)
					{
						tq.push(d);
					}
				}
			}
		}
		q=tq;
	}
	if(cnt==mx)
	{
		cout<<days<<endl;
	}
	else
	{
		cout<<-1<<endl;
	}
}
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);  
	ll T = 1;
	//cin>>T; 
	while(T--)
	    solve();
	return 0;
}


Measured memory_bytes: 88448
n, m = map(int,input().split())
h,w= [],[]
a = [list(input()) for i in range(n)]
b = [i for i in zip(*a)]
for i in range(n):
    if a[i].count(".") == len(a[i]):
        h.append(i)

h = sorted(h,reverse=True)
while h:
    del a[h[0]]
    del h[0]

for i in range(m):
    if b[i].count(".") == len(b[i]):
        w.append(i)

w = sorted(w,reverse=True)
while w:
    for i in range(len(a)):
        del a[i][w[0]]
    del w[0]

for i in range(len(a)):print("".join(a[i]))

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

int main() {
  string s,t;
  cin >> s >> t;
  int ans=0;
  for(int i=0;i<s.size();i++){
    if(s.at(i) != t.at(i)){
      ans++;
    }
  }
  
  cout << ans << endl;
  
  return(0);
}

Measured memory_bytes: 3912
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <math.h>
#include <utility>
#include <stack>
using namespace std;
typedef pair<int,int> P;
const int INF = ~(1<<31) / 2;

struct edge{int to,cost;};

int t[8];
vector<vector<edge> > g;
double dp[1<<8][30];

int main(){
    while(1){
        int n, m, p, a, b;
        scanf("%d %d %d %d %d",&n, &m, &p, &a, &b);
        if (n==0)break;
        a--;b--;

        g.clear();
        g.resize(m);
        for(int i=0;i<n;i++){
            scanf("%d", &t[i]);
        }
        for(int i=0;i<p;i++){
            int x,y,z;
            scanf("%d %d %d", &x, &y, &z);
            x--;y--;
            g[x].push_back((edge){y,z});
            g[y].push_back((edge){x,z});
        }

        for(int i=0;i<1<<n;i++)for(int j=0;j<m;j++)dp[i][j] = 10000;
        dp[(1<<n)-1][a] = 0;

        for(int i=(1<<n)-1;i>=0;i--){
            for(int j=0;j<m;j++){
                for(int k=0;k<n;k++){
                    if (dp[i][j]<10000 && i&(1<<k)){
                        int used = i&(~(1<<k));
                        for(int l=0;l<g[j].size();l++){
                            double d_next = dp[i][j] + (double)g[j][l].cost / t[k];
                            //printf("%d -> %d : %lf\n", j, g[j][l].to, d_next);
                            dp[used][g[j][l].to] = min(d_next, dp[used][g[j][l].to]);
                        }
                    }
                }
            }
        }

        double ans = 10000;
        for(int i=(1<<n)-1;i>=0;i--)ans = min(ans,dp[i][b]);
        if(ans >= 9000) printf("Impossible\n");
        else printf("%.3lf\n",ans);
    }
    return 0;
}

Measured memory_bytes: 1316
#include<stdio.h>
int main()
{
    int i;
    char a[4],b[4];
    while(~scanf("%s%s",a,b))
    {
        if(a[1]==b[1]&&a[0]==b[2]&&a[2]==b[0])
        i=0;
    else
    i=1;
    if(i==1)
        printf("NO\n");
    else
    printf("YES\n");
    }

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
using namespace std;
typedef long long ll;
#define fori(n) for ( int i = 0; i < (n);i++)
#define forj(n) for ( int j = 0; j < (n);j++)
#define fork(n) for ( int k = 0; k < (n);k++)
#define forghj(n) for ( int ghj = 0; ghj < (n);ghj++)
#define fori1(n) for ( int i = (n)-1; i >= 0;i--)
#define all(vector) (vector).begin(),(vector).end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
/*
                            |~~~~~~~|
                            |       |
                            |       |
                            |       |
                            |       |
                            |       |
 |~.\\\_\~~~~~~~~~~~~~~xx~~~         ~~~~~~~~~~~~~~~~~~~~~/_//;~|
 |  \  o \_         ,XXXXX),                         _..-~ o /  |
 |    ~~\  ~-.     XXXXX`)))),                 _.--~~   .-~~~   |
  ~~~~~~~`\   ~\~~~XXX' _/ ';))     |~~~~~~..-~     _.-~ ~~~~~~~
           `\   ~~--`_\~\, ;;;\)__.---.~~~      _.-~
             ~-.       `:;;/;; \          _..-~~
                ~-._      `''        /-~-~
                    `\              /  /
                      |         ,   | |
                       |  '        /  |
                        \/;          |
                         ;;          |
                         `;   .       |
                         |~~~-----.....|
                        | \             \
                       | /\~~--...__    |
                       (|  `\       __-\|
                       ||    \_   /~    |
                       |)     \~-'      |
                        |      | \      '
                        |      |  \    :
                         \     |  |    |
                          |    )  (    )
                           \  /;  /\  |
                           |    |/   |
                           |    |   |
                            \  .'  ||
                            |  |  | |
                            (  | |  |
                            |   \ \ |
                            || o `.)|
                            |`\\\\) |
                            |       |
                            |       |
                            |       |
*/


int main() {
    ios::sync_with_stdio(false);
    int n;
    n = 3;
    int k;
    vector < int > a;
    a.resize(n);
    fori(n) cin >> a[i];
    sort(all(a));
    cin >> k;
    ll kek = 1;
    fori(k) kek*=2;
    cout << a[0]+a[1]+(a[2]*kek);
    cout << "\n";
    return 0;
}














Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input_byline {
    ($($r:tt)* ) => {
        let stdin = std::io::stdin();
        let mut q = std::collections::VecDeque::new();
        let mut next = || {
            if q.is_empty() {
                let mut s = String::new();
                stdin.read_line(&mut s);
                for v in s.split_whitespace() {
                    q.push_back(v.to_string());
                }
            }
            q.pop_front().unwrap()
        };
        input_inner!{next, $($r)*}
    };

}

#[allow(unused_macros)]
macro_rules! input {
    ($($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)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

trait Printable {
    fn p(&self);
}

impl<T: std::fmt::Display> Printable for T {
    fn p(&self) {
        println!("{}", self);
    }
}

impl<T: std::fmt::Display> Printable for [T] {
    fn p(&self) {
        for i in 0..self.len() {
            if i != 0 {
                print!(" ");
            }
            print!("{}", self[i]);
        }
        println!("");
    }
}

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

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;

fn main() {
    input! {
        n: usize,
        s: chars,
    }
    let mut ans = 0;
    for i in 0..10 {
        for j in 0..10 {
            for k in 0..10 {
                let v = vec![i, j, k];
                let mut cur = 0;
                for l in 0..n {
                    if s[l] as u8 - b'0' == v[cur] {
                        cur += 1;
                    }
                    if cur == 3 {
                        ans += 1;
                        break;
                    }
                }
            }
        }
    }

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


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

using namespace std;

int main(void){
    int A,B,K;
    cin>>K>>A>>B;
    bool flag=false;
    for(int i=A;i<=B;i++){
        if(i%K==0) {
            flag=true;
            break;
        }
    }
    if(flag) cout<<"OK"<<endl;
    else cout<<"NG"<<endl;
    return 0;
}


Measured memory_bytes: 3624
from sys import stdin

M, D = map(int, stdin.readline().rstrip().split())

if D < 22:
    print(0)
    exit(0)

cnt = 0
for i in range(21, D + 1):
    mod = i % 10
    if mod > 1 and mod * (i // 10) <= M:
        cnt += 1

print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  string s;
  cin >> s;
  string t = "";
  for (int i = 0; i < (int)s.size(); i++) {
    if (s[i] == 'B') {
      if (!t.empty()) t.pop_back();
    }
    else {
      t = t + s[i];
    }
  }
  dump(t);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define maxs(x,y) x = max(x, y)
#define mins(x,y) x = min(x, y)
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int n, m;
    cin >> n >> m;
    
    vector<int> k(m), p(m);
    vector<vector<int>> s(m);
    REP(i, m) {
        cin >> k[i];
        int temp;
        REP(j, k[i]) {
            cin >> temp; temp--;
            s[i].push_back(temp);
        }
    }
    REP(i, m) cin >> p[i];

    int res = 0;
    for(int bit = 0; bit < (1<<n); bit++){
        bool ok = 1;
        for(int i = 0; i < m; i++) {
            int con = 0;
            for (auto v : s[i]) {
                if (bit & (1<<v)) con++;
            }
            if (con % 2 != p[i]) ok = false;        
        }
        if (ok) res++;
    }

    cout << res << endl;

    return 0;
}

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

typedef long long ll;

const ll MOD = 1000000007;

int main() {
	int n;
	cin >> n;
	ll sum = 0, sum2 = 0;
	for (int i = 0; i < n; ++i) {
		ll a; cin >> a;
		sum = (sum + a) % MOD;
		sum2 = (sum2 + a * a) % MOD;
	}

	ll ans = (sum * sum) % MOD;
	ans -= sum2;
	while (ans < 0) ans += MOD;
	ans %= MOD;
	if (ans % 2) ans += MOD;
	ans = (ans / 2) % MOD;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,x,sum=0;
	cin>>a>>b>>c>>x;
	for(int i=0;i<=a;i++)
	for(int j=0;j<=b;j++)
	for(int k=0;k<=c;k++)
	if(500*i+100*j+50*k==x) sum++;
	cout<<sum<<endl;
	return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

using namespace std;

int main(){
  int A ,B,K;
  cin >> A >> B >> K;
  rep(i,K){
    if(i % 2 == 0){//taka
      if(A % 2 == 1){A--; B += A/2; A/=2;}
      else {B += A/2; A/=2;}
    }else{
      if(B % 2 == 1){B--;A += B/2; B/=2;}
      else {A += B/2; B/=2;}
    }
  }
  cout << A << ' ' << B << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

typedef struct shop{
  int fan,time;
};
shop sh[3005];

int bmemo[3005][3005];
int n,tt,s;

int main(void){
  int b,a;
  int ans=0;
  scanf("%d %d %d",&n,&tt,&s);
  for(int i=1;i<=n;i++){
    scanf("%d %d",&sh[i].fan,&sh[i].time);
  }
  memset(bmemo,0,sizeof(bmemo));

  for(int i=1;i<=n;i++){
    for(int t=1;t<=s;t++){
      if(sh[i].time>t) bmemo[i][t]=bmemo[i-1][t];
      else bmemo[i][t]=max(bmemo[i-1][t],bmemo[i-1][t-sh[i].time]+sh[i].fan);
    }
  }

  for(int i=n;i>=0;i--){
    for(int t=tt+1;t>=s+1;t--){
      if(sh[i].time>tt+1-t) bmemo[i][t]=bmemo[i+1][t];
      else bmemo[i][t]=max(bmemo[i+1][t],bmemo[i+1][t+sh[i].time]+sh[i].fan);
    }
  }

  for(int i=0;i<=n;i++){
	  ans=max(ans,bmemo[i][s]+bmemo[i+1][s+1]);
  }
  printf("%d\n",ans);
}

Measured memory_bytes: 35000
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int N = sc.nextInt();
        int[] A = new int[N];
        int sum = 0;
        for(int i=0; i<N; i++){
            A[i] = sc.nextInt();
            sum += A[i];
        }
        
        if(H <= sum) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }
}

Measured memory_bytes: 50484
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <complex>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;

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

  static bool ac[100002];
  fill(ac, ac + 100002, false);

  static int pen[100002];
  fill(pen, pen + 100002, 0);
  
  for (int i = 0; i < m; i++) {
    int p;
    string S;
    cin >> p >> S;
    p--;
    if (S == "WA" && !ac[p]) {
      pen[p]++;
    }
    if (S == "AC") {
      ac[p] = true;
    }
  }

  int correct = 0;
  int penSum = 0;
  for (int i = 0; i < n; i++) {
    if (ac[i]) {
      correct++;
      penSum += pen[i];
    }
  }
  cout << correct << " " << penSum << endl;
}


Measured memory_bytes: 768
#include<stdio.h>
#define MAX 100005
#define NIL -1
 
/*
 p: parent
 l: left-child
 r: right sibling
 */
 
struct Node{
    int p, l, r;
};
struct Node T[MAX]; // Tree
int dep,hileft,hiright;
 
 
int depth(int u){
  if(T[u].p == NIL)return 0;
   if(T[u].p != NIL){
     dep++;
    depth(T[u].p);
  }
  return dep;
}
 
int degree(int u){
    if (T[u].l == NIL && T[u].r == NIL)return 0;
    else if(T[u].l != NIL && T[u].r != NIL)return 2;
    else  return 1;
}
int sibling(int u){
  if(T[u].p == NIL) return NIL;
  else if(T[T[u].p].l==u)return T[T[u].p].r;
  else return T[T[u].p].l;
  //printf("%d",T[T[u].p].l);
}
 
/*int hight(int u){
 if(T[u].l == NIL && T[u].r == NIL)return 0;
 if(T[u].l != NIL){
   hileft= hight(T[u].l)+1;
  }
 if(T[u].r != NIL){
   hiright=hight(T[u].r)+1;
  }
 if(hiright>hileft)return hiright;
 else return hileft;
 }*/

int hight(int u){
  int hileft = 0, hiright = 0;
  if(T[u].l != -1) {
hileft = hight(T[u].l) + 1;
  }
  if(T[u].r != -1){
 hiright = hight(T[u].r) + 1;
  }
  if(hileft < hiright) return hiright;
  else return hileft;
}
 
 
 
void print(int u){
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("sibling = %d, ",sibling(u));
  printf("degree = %d, ",degree(u));
  dep=0;
  printf("depth = %d, ",depth(u));
  //hileft=hiright=0;
  printf("height = %d, ",hight(u));
 
  if(T[u].p == NIL)printf("root\n");
  else if(T[u].l == NIL && T[u].r == NIL)printf("leaf\n");
  else printf("internal node\n");
}
 
 
main(){
  int i, j, d, v, c, l, n,tmp;
     
    scanf("%d", &n);
     
    for ( i = 0; i < n; i++ ) {
        T[i].p = T[i].l = T[i].r = NIL;
    }
    for (i = 0; i <n ; i++){
      scanf("%d %d %d", &v, &d, &c);
             T[d].p=v;
	     T[c].p=v;
             T[v].l=d;
             T[v].r=c;
 
    }
     
    /*...*/
     
    for ( i = 0; i < n; i++ ) print(i);
    return 0;
}

Measured memory_bytes: 616
#include <bits/stdc++.h>
#define ll long double 
#define INF 1000000000000
#define MOD 1000000007
#define DEBUG(x) cerr<<'>'<<#x<<':'<<x<< endl
using namespace std;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n, m;
    cin >> n >> m;
    ll ar[n + 10];
    ll total = 0; 
    for(int i = 0; i < n; i++)
    {
        cin >> ar[i];
        total += ar[i];
    }    
    sort(ar, ar + n);
    bool possible = true;
    ll min_val = ((long double)total/(4*m));
    int pos = n - 1;
    while(m > 0)
    {
        if(ar[pos] >= min_val)
        {
            m -= 1;
            pos -= 1;
        }    
        else
        {
            possible = false;
            break;
        }
    }
    if(possible)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
const ll INF = 1e10;

int main() {
    string s; cin >> s;
    int n = s.size();
    bool flag = false;
    pint ans = {-1,-1};
    for (int i = 0; i < n - 1; i ++){
        if (s.at(i) == s.at(i + 1)) {
            ans = {i + 1, i + 2};
            flag = true;
            break;
        }
    }

    if (flag) {
        cout << ans.first << ' ' << ans.second << endl;
        flag = false;
    }
    else flag = true;
    
    for (int i = 0; i < n - 2; i ++) {
        if (s.at(i) == s.at(i + 2) ) {
            ans = {i + 1,i + 3};
            break;
        }
    }

    if (flag) cout << ans.first << ' ' << ans.second << endl;
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using lint = long int;

int N;
lint res;
lint a[3010];
lint dp[3010][3010];
bool calced[3010][3010] = {0};


lint dequeue_calc(int l, int r){
    if(calced[l][r]) return dp[l][r];
    
    /*l,r範囲は未到達*/
    calced[l][r] = 1;  //到達報告
    if(l == r) return a[l];  //これは確定値

    if(!calced[l][r-1]) dp[l][r-1] = dequeue_calc(l, r-1);
    if(!calced[l+1][r]) dp[l+1][r] = dequeue_calc(l+1, r);

    return dp[l][r] = max(a[r]-dp[l][r-1], a[l]-dp[l+1][r]);
}


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

    res = dequeue_calc(1, N);
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 58828
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1012345678;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

double W, H, x, y;

int main(){
  cin >> W >> H >> x >> y;
  printf("%lf %d\n",W*H/2,2*x == W && 2*y == H);

  
 
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
long long n,dp[100005][2];
vector<int>a[100005];
bool check[100005]={false};
void dfs(int node,int last){
    for(auto i=a[node].begin();i!=a[node].end();i++){
        if(*i!=last){
            dfs(*i,node);
            dp[node][0]=dp[node][0]*((dp[*i][1]+dp[*i][0])%mod)%mod;
            dp[node][1]=dp[node][1]*dp[*i][0]%mod;
        }
    }
}
int main(){
    cin>>n;
    for(int i=1;i<=n;i++) dp[i][0]=1,dp[i][1]=1;
    for(int i=1;i<n;i++){
        int x,y;
        cin>>x>>y;
        a[x].push_back(y);
        a[y].push_back(x);
    }
    dfs(1,-1);
    cout<<(dp[1][0]+dp[1][1])%mod;
    return 0;
}


Measured memory_bytes: 12800
def main():
    n, m = map(int, input().split())
    k = []
    for i in range(m):
        a, _ = map(int, input().split())
        c = sum([1<<i for i in map(lambda x: int(x)-1, input().split())])
        k.append((a, c))
    dp = [float("inf")]*(1<<n)
    dp[0] = 0
    for i in range(1<<n):
        for ki in range(m):
            c = dp[i] + k[ki][0]
            t = i | k[ki][1]
            dp[t] = min(dp[t], c)

    ans = dp[-1] if dp[-1]!=float("inf") else -1
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 45144
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define SIZE 100

//スタックの定義
typedef  struct stack{
  int size;
  int count;
  char data[SIZE];
  char *top;
}stack;

//スタックの初期化
void initialize_stack(stack *stk){
  stk->count = 0;
  stk->size = SIZE;
  stk->top = &(stk->data[SIZE]);
}

//データの追加
void push(stack *stk,char elem){
  if(stk->count >= stk->size){
    exit(1);
  }
  else{
    stk->top--;
    *(stk->top) = elem;
    stk->count++;
  }
}

//データの取り出し
char pop(stack *stk){
  char latest;
  latest = *(stk->top);
  stk->top++;
  stk->count--;
  return latest;
}
    
int main(void){
  char string[11];
  stack stk_1;
  int i;
  initialize_stack(&stk_1);
  scanf("%s",string);
  for(i=0;i<strlen(string);i++){
    if(string[i] != 'B'){
      push(&stk_1, string[i]);
    }
    else if(stk_1.count > 0){
      pop(&stk_1);
    }
  }
  for(i=0;i<stk_1.count;i++){
    printf("%c",stk_1.data[SIZE-1-i]);
  }
  return 0;
}

Measured memory_bytes: 1648
h,w=map(int,input().split())
b = []
for i in range(h):
    b.append(input())
    
for i in range(h+2):
    for j in range(w+2):
        if j==w+1:
            print('#')
        elif i==0 or i==h+1:
            print('#',end='')
        elif j==0:
            print('#',end='')
        else:
            print(b[i-1][j-1],end='')

Measured memory_bytes: 4340
def check(x, y):
    for i in range(6):
        order = [0, 0, 0]
        for j in range(3):
            if {x[j], x[-j-1]} != {y[z[i][j]], y[-z[i][j]-1]}:
                break
            if x[j] == y[z[i][j]]:
                order[j] = 1
                if x[j] == x[-j-1]:
                    order[j] = 2
        else:
            if 2 in order or (i < 3) == sum(order) % 2:
                return True
    return False

n = int(input())
x = [[] for i in range(n)]
for i in range(n):
    x[i] = list(map(int, input().split()))
z = [[0, 1, 2], [2, 0, 1], [1, 2, 0], [0, 2, 1], [2, 1, 0], [1, 0, 2]]
different = True
for i in range(n):
    for j in range(i+1, n, 1):
        if check(x[i], x[j]):
            break
    else:
        continue
    print('No')
    break
else:
    print('Yes')

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

int main(){
    
    int N, Y;
    cin >> N >> Y;
    
    for(int i=0;i<=N;i++){
        for(int j=0;j<=N-i;j++){
            if(9000*i+4000*j+1000*N==Y){
                cout << i << ' ' << j << ' ' << N-i-j << endl;
                goto Exit;
            }
        }
    }
    
    cout << -1 << ' ' << -1 << ' ' << -1 << endl;
    
Exit:
    ;
    return 0;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
static int MAX = 100;


void selectionSort(int *A,int N){
	int minj;
	int buf;
	int koukan=0;
	int count=0;
	for(int i=0;i < N-1;i++){
		minj = i;
		koukan=0;
		for(int j=i+1;j < N;j++){
			if(A[j] < A[minj]){
				minj = j;
				koukan = 1;
			}
		}
		count += koukan;
		buf = A[i];
		A[i] = A[minj];
		A[minj] = buf;
	}
	printf("%d",A[0]);
	for(int i = 1;i < N;i++){
		printf(" %d",A[i]);
	}
	printf("\n");
	std::cout << count << std::endl;

}
int main(){
	int A[MAX];
	int n;
	std::cin >> n;
	for(int i = 0;i < n;i++) std::cin >> A[i];

	selectionSort(A,n);


	return 0;
}

Measured memory_bytes: 3220
ary = Array.new(4).map {Array.new(13,true)}
n = gets.to_i
for i in 1..n
  s,r = gets.split
  k = r.to_i
  case s
  when "S"
    ary[0][k-1] = false
  when "H"
    ary[1][k-1] = false
  when "C"
    ary[2][k-1] = false
  when "D"
    ary[3][k-1] = false
  end
end
suit = ["S","H","C","D"]
for i in 0..3
  for j in 1..13
    if ary[i][j-1]
      puts suit[i] + " " + j.to_s
    end
  end
end

Measured memory_bytes: 6104
import collections
n=int(input())
f={}
for i in range(n):
  S=input() 
  s=list(S)
  c=collections.Counter(S)
  for j in range(len(c)):
    x=c.most_common()[j][0]
    y=c.most_common()[j][1]
    if i==0:
      f.setdefault(x,y)
    else:
      for k in f.keys():
        if k not in s:
          f[k]=0
        else:
          if f[k]>s.count(k):
            f[k]=s.count(k)
A=sorted(f)
li=[a*f[a] for a in A]
print("".join(li))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define str string
#define fi first
#define se second
#define pb push_back
#define SET(a, b) memset(a, b, sizeof(a))
#define eps 1e-6
#define pi atan(1) * 4
#define mod 1000000007
#define inf 1000000000
#define llinf 1000000000000000000
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
#define FORl(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORDl(i, a, b) for (ll i = (a); i >= (b); i--)
using namespace std;
int main () {
  int n;
  scanf("%d", &n);
  ll pdt = 1;
  bool ex = 0, zero = 0;
  FOR(i, 1, n) {
    ll t;
    scanf("%lld", &t);
    if (t == 0) zero = 1;
    if (pdt > 0 && t > llinf / pdt) ex = 1;
    pdt *= t;
  }
  if (zero) printf("0\n");
  else if (ex) printf("-1\n");
  else printf("%lld\n", pdt);
  return 0;
}

Measured memory_bytes: 3828
n = int(input())
ai = list(map(int, input().split()))
list.sort(ai, reverse=True)
end = (n-2) // 2 
kk = ai[0] + sum(ai[1:end+1]) * 2
if n % 2 == 1:
    kk += ai[end+1]
print(kk)    

Measured memory_bytes: 31384
#include<cstdio>
#include<algorithm>
#define MN 1000001
using namespace std;
 
const int MOD=1e9+7;
int n,f[MN],m;
inline void M(int &x){while(x>=MOD)x-=MOD;}
int main(){
    int i,j;
    scanf("%d",&n);f[n]=n;m=n-1;
    for (i=n-1;i;i--) f[i]=1LL*(n-1)*(n-1)%MOD,M(f[i]+=f[i+1]),M(f[i]+=m),M(m+=(i+2>n?1:f[i+2])-1);
    printf("%d\n",f[1]);
}

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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

template <typename T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <typename A, typename T, size_t size>
void fill(A (&ary)[size], const T &val) {
    fill((T *)ary, (T *)(ary + size), val);
}

void solve() {
    //constexpr i64 mod = 1'000'000'007;
    i64 N,M;
    cin >> N >> M;
    vector<i64> A(M),B(M);
    rep(i,0,M){
        cin >> A[i] >> B[i];
        --A[i];
        --B[i];
    }

    if(M%2!=0){
        cout << -1 << endl;
        return;
    }

    vector<vector<i64>> graph(N);
    rep(i,0,M){
        graph[A[i]].emplace_back(B[i]);
        graph[B[i]].emplace_back(A[i]);
    }

    vector<pair<i64,i64>> ans;

    vector<bool> visited(N);
    vector<bool> closed(N);
    vector<vector<int>> tree(N);
    vector<i64> out(N);
    function<void(i64,i64)> rec=[&](i64 u,i64 p){
        visited[u]=true;
        for(auto v:graph[u]){
            if(v==p) continue;
            if(closed[v]) continue;
            ++out[u];
            if(!visited[v]) {
                tree[u].emplace_back(v);
                rec(v, u);
            }else{
                ans.emplace_back(make_pair(u,v));
            }
        }
        closed[u]=true;
    };

    rec(0,-1);

    vector<i64> us;
    rep(i,0,N) if(out[i]%2==1) us.emplace_back(i);

    vector<pair<i64,i64>> ps;
    rep(i,0,us.size()/2){
        ps.emplace_back(make_pair(us[i],us[i+us.size()/2]));
    }

    vector<i64> sum(N);

    for(auto p:ps){
        i64 u=p.first,v=p.second;
        sum[u]--;
        sum[v]--;
    }

    function<i64(i64)> dfs=[&](i64 u){
        i64 res=sum[u];
        for(auto v:tree[u]){
            i64 tmp=dfs(v);
            if(tmp%2==0) ans.emplace_back(make_pair(u,v));
            else ans.emplace_back(make_pair(v,u));
            res+=tmp;
        }
        return res;
    };
    dfs(0);

    rep(i,0,ans.size()){
        cout << ans[i].first+1 << " " << ans[i].second+1 << endl;
    }
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


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

int main(){
  int n;
  
  cin >> n;
  
  switch(n%10){
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      cout << "hon" << endl;
      break;
    case 0:
    case 1:
    case 6:
    case 8:
      cout << "pon" << endl;
      break;
    case 3:
      cout << "bon" << endl;
      break;
  }
  return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i , j , n) for(long long i = j ; i <= n ; i++)
#define per(i , j , n) for(long long i = j ; i >= n ; i--)
const ll N = 123456;

int a[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll l , r;
    cin >> l >> r;

    const int mod = 2019;

    if(r - l >= 2019) {
        cout << 0 << endl;
    }
    else {
        vector < int > a;

        rep(i , l , r) {
            a.push_back(i % mod);
        }

        int ans = INT_MAX;
        rep(i , 0 , a.size() - 1) {
            rep(j , i + 1 , a.size() - 1) {
                ans = min(ans , (a[i] * a[j]) % mod);
            }
        }

        cout << ans << endl;
    }

    return 0;
}


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

long long pw(long long n,int k){
  assert(k>=0);
  long long res=1;
  while(k){
    if(k&1)res*=n;
    n*=n;
    k>>=1;
  }
  return res;
}

signed main(){
  long long n;cin>>n;
  string ans;
  for(int i=1;;i++){
    long long a=pw(26,i);
    if(n<=a){
      n--;
      while(i--){
        ans+=(char)('a'+n%26);
        n/=26;
      }
      reverse(ans.begin(),ans.end());
      cout<<ans<<endl;return 0;
    }
    else n-=a;
  }
}


Measured memory_bytes: 3628
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

ll check(vector <ll> &a, ll med) {
    ll ret = 0;
    ll n = a.size();
    for (int i = 0; i < n; i++) {
        ret += a.end() - lower_bound(a.begin(), a.end(), med - a[i]);
    }
    return ret;
}

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

    ll n, m;
    cin >> n >> m;

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

    sort(a.begin(), a.end());

    ll l = 0, r = 1LL << 40;
    while (r - l > 1) {
        ll med = (l + r) / 2;

        ll c = check(a, med);
        if (c < m) {
            r = med;
        } else {
            l = med;
        }
    }

    ll diff = check(a, l) - m;

    vector <ll> sm(n + 1);
    for (int i = n - 1; i >= 0; i--) {
        sm[i] = sm[i + 1] + a[i];
    }

    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ll idx = lower_bound(a.begin(), a.end(), l - a[i]) - a.begin();
        ans += sm[idx];
        ans += (n - idx) * a[i];
    }

    cout << ans - diff * l << "\n";
    return 0;
}

Measured memory_bytes: 1920
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder.Contest.D
{
	static class Program
	{
		public static void Solve(Scanner cin)
		{
			int n = cin.ReadInt();
			var a = cin.ReadIntArray(n);
			int m = n - a.Distinct().Count();
			Console.WriteLine(n - (m + 1) / 2 * 2);
		}

		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);
			var cin = new Scanner();
			Solve(cin);
			Console.Out.Flush();
		}
	}

	class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string Read() => ReadString();

		public string ReadString()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return ReadString();
			i = 0;
			return s[i++];
		}

		public string[] ReadStringArray(int N)
		{
			string[] Array = new string[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = ReadString();
			}
			return Array;
		}

		public int ReadInt()
		{
			return int.Parse(ReadString());
		}

		public int[] ReadIntArray(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = ReadInt() + add;
			}
			return Array;
		}

		public long ReadLong()
		{
			return long.Parse(ReadString());
		}

		public long[] ReadLongArray(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = ReadLong() + add;
			}
			return Array;
		}

		public double ReadDouble()
		{
			return double.Parse(ReadString());
		}

		public double[] ReadDoubleArray(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = ReadDouble() + add;
			}
			return Array;
		}

		public T1 ReadValue<T1>() => (T1)Convert.ChangeType(ReadString(), typeof(T1));

	}
}

Measured memory_bytes: 21088
/**
 *   Author: praveen_ojha
 *   Created: 16 January 2019
 *   Time: 19:02:07
**/
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define PI 3.141592653589793238510
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define MAX 100005
int a[MAX][3];
int dp[100005][4];
int n;
int solve(int day,int act){
	if(day==n){
		//cnt0=cnt1=cnt2=0;
		return 0;
	}	if(dp[day][act]!=-1)
		return dp[day][act];

		int ans0=0,ans1=0,ans2=0;
		if(act!=0){
		//cnt0++;
		dp[day+1][0]=solve(day+1,0);
		ans0=a[day][0]+dp[day+1][0];
		//cnt0=0;
		}
		if(act!=1){
		//cnt1++;
		dp[day+1][1]=solve(day+1,1);
		ans1=a[day][1]+dp[day+1][1];
		//cnt1=0;
		}
		if(act!=2){
		//cnt2++;
		dp[day+1][2]=solve(day+1,2);
		ans2=a[day][2]+dp[day+1][2];
		//cnt2=0;
		}
		//cout<<"Max at end of day "<<day<<" "<<max(ans0,max(ans1,ans2))<<"\n";
		return max(ans0,max(ans1,ans2));
	
}
int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    memset(dp,-1,sizeof dp);
    cin>>n;
    for(int i=0;i<n;i++)
    	cin>>a[i][0]>>a[i][1]>>a[i][2];
    cout<<solve(0,3);
    // for(int i=0;i<n;i++)
    // 	cout<<a[i][0]<<" "<<a[i][1]<<" "<<a[i][2]<<"\n";

return 0;
}

Measured memory_bytes: 10752
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
//#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

string s;

int main(){
	cin>>s;
	int a=0;
	int b=s.size()-1;
	int ans=0;
	while(a<b){
		if(s[a]==s[b]){
			a++;b--;
		}else{
			if(s[a]=='x'){
				ans++;
				a++;
			}else if(s[b]=='x'){
				ans++;
				b--;
			}else{
				cout<<"-1"<<endl;
				return 0;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
#include<stdio.h>

char a[50][50];
int w,h;

void white(int p,int q);
void black(int p,int q);

int main(){
    while(1){
        int resb=0,resw=0;
        scanf("%d %d",&h,&w);
        if(w==0&&h==0) return 0;
        for(int i=0;i<w;i++) scanf("%s",&a[i][0]);
        for(int i=0;i<w;i++){
            for(int j=0;j<h;j++){
                if(a[i][j]=='W') white(i,j);
                if(a[i][j]=='B') black(i,j);
            }
        }
        for(int i=0;i<w;i++){
            for(int j=0;j<h;j++){
                if(a[i][j]=='b') resb++;
                if(a[i][j]=='w') resw++;
            }
        }
        printf("%d %d\n",resb,resw);
    }
}

void white(int p,int q){
    for(int i=-1;i<=1;i++){
        for(int j=-1;j<=1;j++){
            if((i==0||j==0)&&p+i>=0&&p+i<w&&q+j>=0&&q+j<h){
                if(a[p+i][q+j]=='.'){
                    a[p+i][q+j]='w';
                    white(p+i,q+j);
                }else if(a[p+i][q+j]=='b'){
                    a[p+i][q+j]='g';
                    white(p+i,q+j);
                }
            }
        }
    }
}


void black(int p,int q){
    for(int i=-1;i<=1;i++){
        for(int j=-1;j<=1;j++){
            if((i==0||j==0)&&p+i>=0&&p+i<w&&q+j>=0&&q+j<h){
                if(a[p+i][q+j]=='.'){
                    a[p+i][q+j]='b';
                    black(p+i,q+j);
                }else if(a[p+i][q+j]=='w'){
                    a[p+i][q+j]='g';
                    black(p+i,q+j);
                } 
            }
        }
    }
}

Measured memory_bytes: 1124
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i <=n;i++){
    num*=yakusu[i];
  }
  return num;
}



int main(){
  string S;cin>>S;
  int n=S.size();
  bool ok=true;
  rep(i,n/2)if(S[i]!=S[n-1-i])ok=false;
  rep(i,(n/2)/2)if(S[i]!=S[n/2-1-i])ok=false;
  f(i,(n+3)/2-1,(n+3)/2+(n/2)/2-1)if(S[i]!=S[n-1-i])ok=false;
  
  if(ok)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
N,Q = map(int, input().split())
ANS = (N-2)**2
R,C=N,N
RLEN=[]
CLEN=[]
for i in range(Q):
    RC,num = map(int, input().split())
    if RC==1:
        if R>num:
            for j in range(R-num):
                RLEN.append(C)
            ANS-=C-2
            R=num
        else:
            if len(RLEN)>0:
                ANS-=RLEN[N-num-1]-2
            else:
                ANS-=R-2
    else:
        if C>num:
            for j in range(C-num):
                CLEN.append(R)
            ANS-=R-2
            C=num
        else:
            if len(CLEN)>0:
                ANS-=CLEN[N-num-1]-2
            else:
                ANS-=C-2

print(ANS)



Measured memory_bytes: 99816
/*
ID: toooooEasy or RafaelSaddatimov
PROG:
*/
#include <bits/stdc++.h>
#define MAX 3009
#define MOD 1000000007
#define INF 2100000000
#define EPS 1e-12
#define ll long long
#define _l long
#define F first
#define S second
#define NLINE printf("\n")
#define BYE(v) return 0 * printf(v)
#define all(v) v.begin(), v.end()
#define pb push_back
using namespace std;

int main()
{
    ll q, h, s, d, n;
    scanf("%lld%lld%lld%lld%lld", &q, &h, &s, &d, &n);
    q *= 4;
    h *= 2;
    ll ss = min(q, min(h, s));
    printf("%lld", min(ss * n, (n / 2) * d + (n % 2) * ss));
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define int ll
#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    string s;
    cin>>s;
    map<int, int> mp;
    f(i, s.size()) mp[s[i]]++;
    if(mp.size() == 2) cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 256
//by Top1
#include <bits/stdc++.h>
          
#define f first
#define s second
#define int long long
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>
#define pll pair <long, long>
#define mp make_pair
#define pb push_back
#define pf push_front
#define pp pop_back
#define cerr cout
#define rev reverse
#define all(s) s.begin(), s.end()
#define sz(s) (int)s.size()
#define forn(i, a, b) for (int i = a; i <= b; i++)
#define boost ios_base::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define nxtp next_permutation
#define pvtp prev_permutation
#define KZ return 
#define x1 x21212121
#define y1 y21212121
#define sqr(x) x * x 
      
const int inf = (1e9) + 1;
const int mod = 479001599;
const int maxn = 3e6 + 111;
        
using namespace std;          

int n, k, a[maxn];
double b[maxn], pref[maxn], ans;

void solve(){
	cin >> n >> k;

	b[0] = 1.0;

	for (int i = 1; i <= n; i++){
		cin >> a[i];
		b[i] = a[i] * 1.0 * b[i - 1];
		pref[i] = pref[i - 1] + a[i] + 1.0;
	}

	double sum = .0, x = 1.0;

	for (int i = k; i <= n; i++){
		double y = b[i] / b[i - k - 1];
		ans = max(ans, (pref[i] - pref[i - k]) / 2.0);
	}

	cout << fixed << setprecision(9) << ans;
}                              
      
main(){
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

    boost;
    
    int q = 1;
 
    //cin >> q;
    
    while (q--){
        solve();
    }
}

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

using namespace std;
int main(int argc, char const *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string n;
  cin >> n;
  int ans = 1e9;
  for (int i = 0; i < n.length() - 2; i++) {
    int t = stoi(n.substr(i, 3));
    int diff = abs(t - 753);
    if ( diff < ans) ans = diff;
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256