akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <bitset>

using namespace std;

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

    int a[M], b[M];
    vector<int> c[M];
    for(int i=0; i<M; i++){
        cin >> a[i] >> b[i];
        for(int j=0; j<b[i]; j++){
            int t;
            cin >> t;
            t--;
            c[i].push_back(t);
        }
    }

    int dp[M+1][(1<<N)+1];
    const int inf = 1000000005;
    for(int i=0; i<M+1; i++){
        for(int j=0; j<=(1<<N); j++){
            dp[i][j] = inf;
        }
        dp[i][0] = 0;
    }
    dp[0][0] = 0;

    for(int i=0; i<M; i++){
        for(int j=0; j<(1<<N); j++){
            int t = j;
            dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
            for(auto k : c[i]){
                t |= 1<<k;  
            }
            int mn = min(dp[i][t], dp[i+1][t]);
            dp[i+1][t] = min(mn, dp[i][j]+a[i]);
        }
    }

    if(dp[M][(1<<N)-1] == inf) cout << -1 << endl;
    else cout << dp[M][(1<<N)-1] << endl;

    return 0;
}

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

 int main(){
    int n;
    cin >> n;
    vector<int> x(n);
    vector<int> l(n);
    for(int i=0;i<n;i++){
        cin >> x[i] >> l[i];     
    }
    vector<pair<int,int>> sc(n);
    for(int i=0;i<n;i++){
        sc[i].second = max(0,x[i]-l[i]);
        sc[i].first = x[i]+l[i];
    }
    sort(sc.begin(),sc.end());
    int cnt=0;
    int endtime = 0;
    for(int i=0;i<n;i++){
        if(endtime<=sc[i].second){
            cnt++;
            endtime = sc[i].first;
        }
    }
    cout << cnt << endl;
    return 0;
 }

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

nxt = set()
prv = set()
for i in range(M):
    a, b = map(int, input().split())
    if a == 1:
        nxt.add(b)
    elif b == N:
        prv.add(a)

if nxt & prv:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


Measured memory_bytes: 19024
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
using ll = long long;
using lint = long long;
typedef pair<int,int> P;
const lint inf=1e18+7;
const int MOD=1000000007;
signed main(){
  string s;cin>>s;
  int res=inf;
  int cur=(s[0]-'0')*100+(s[1]-'0')*10+s[2]-'0';
  int n=s.length();
  res=min(res,abs(753-cur));
  rep(i,n){
      if(i<3)continue;
      cur%=100;cur*=10;
      cur+=s[i]-'0';
      res=min(res,abs(753-cur));
  }
  cout<<res<<"\n";
  return 0;
}

Measured memory_bytes: 3600
#[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")
    };
}

use std::cmp::min;


struct Dfs {
    n: usize,
    k: usize,
    h: Vec<i64>,
    dp: Vec<i64>,
}
impl Dfs {
    fn rec(&mut self, base: usize) -> i64 {

        if base == self.n - 1 { return 0; }

        if self.dp[base] != -1 { return self.dp[base]; }
        let mut min_val = std::i64::MAX;
        for diff in 1..self.k + 1 {
            let idx = base + diff;
            if idx == self.n { break; }
            let val: i64 = self.rec(idx) + (self.h[idx] - self.h[base]).abs();
            min_val = min(val, min_val);
        }
        self.dp[base] = min_val;
        return min_val;
    }
}

fn main() {
    input! {
        n: usize,
        k: usize,
        h: [i64; n],
    }
    let dp = vec![-1; n];
    let mut dfs = Dfs{ n: n, k: k, h: h, dp: dp };
    println!("{}", dfs.rec(0));
} 


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n), w(n);
  for (int i = 0; i < m; i++) {
    int p;
    string s;
    cin >> p >> s;
    p--;
    if (!a[p]) {
      if (s == "AC") {
        a[p] = 1;
      } else {
        w[p]++;
      }
    }
  }
  int x = 0, y = 0;
  for (int i = 0; i < n; i++) {
    if (!a[i]) continue;
    x += 1;
    y += w[i];
  }
  cout << x << ' ' << y << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include <algorithm> 
using namespace std;

# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;

int main()
{
    int n,q ; cin >> n >> q;
    string s; cin >> s;

    int res_set[100000];
    int res=0;
    for(int i=0;i<s.size()-1;i++){
        string tmp=s.substr(i,2);
        if(tmp=="AC") res++;
        res_set[i]=res;
    }


    int l[100000],r[100000];
    for(int i=0;i<q;i++){
        cin >> l[i] >> r[i];
    }

    for(int i=0;i<q;i++){
        p(res_set[r[i]-2]-res_set[l[i]-2])
    }
}

Measured memory_bytes: 2176
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
int INF = numeric_limits<int>::max() / 2;
ll LINF = numeric_limits<ll>::max() / 2;
int MOD = 1e9 + 7;

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

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

int main(){
	int n;
	cin >> n;
	int ans = 1000000000;
	for (int i = 1; i < n; ++ i){
		int x = i, y = n - i, cnt = 0;
		while (x){
			cnt += x % 10;
			x /= 10;
		}
		while (y){
			cnt += y % 10;
			y /= 10;
		}
		ans = min(ans, cnt);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
w,h,n = map(int,input().split())
li = [list(map(int,input().split())) for _ in range(n)]
x1 = 0
x2 = w
y1 = 0
y2 = h
for i in range(n):
  if li[i][2] == 1:
    x1 = max(x1,li[i][0])
  elif li[i][2] == 2:
    x2 = min(x2,li[i][0])
  elif li[i][2] == 3:
    y1 = max(y1,li[i][1])
  else:
    y2 = min(y2,li[i][1])
if x2 <= x1 or y2 <= y1:
  print(0)
else:
  print((x2-x1)*(y2-y1))

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

int main() {
  int n, tmp;
  int flg = 0;
  cin >> n;
  vector<int> a(n);
  vector<int> prime(1000001,1);
  bitset<1000001> prime_num;
  prime_num.set();
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if(a[i]==1){
      if(flg==0){
        flg++;
      }else{
        cout << 0 << endl;
        return 0;
      }
    }
    if (prime_num[a[i]]) {
      prime[a[i]]++;
      tmp = a[i];
      for (int j = tmp * 2; j < 1000001; j += tmp) {
        prime_num.reset(j);
      }
    }
  }
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (prime[a[i]]==2&&prime_num[a[i]]) {
      cnt++;
    }
  }
  /*
  for (int i = 0;i<25;i++){
    cout << prime[i] << endl;
  }*/
  cout << cnt << endl;
  return 0;
}

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

using namespace std;

int main(void) {
  string S, S1, S2;
  int i, n;
  
  cin >> S;
  n = S.length();

  for (i = 0; i < n; i++) {
    S1.push_back( i % 2 ? '0' : '1');
    S2.push_back( i % 2 ? '1' : '0');
  }
  
  
  int c1 = 0, c2 = 0;
  for (i = 0; i < n; i++) {
    if (S[i] != S1[i]) {
      c1++;
    }
    if (S[i] != S2[i]) {
      c2++;
    }
  }
  cout << min(c1, c2) << endl;
  return 0;

}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int ctoi(const char c) {
    if ('0' <= c && c <= '9') return (c - '0');
    return -1;
}
vector<int> input(int n) {
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }
    return vec;
}
void output(vector<int> vec) {
    for (int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    return;
}
vector<vector<int>> input(int n, int m) {
    vector<vector<int>> table(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> table. at(i).at(j);
        }
    }
    return table;
}
void output(vector<vector<int>> table) {
    for (int i = 0; i < table.size(); i++) {
        for (int j = 0; j < table.at(0).size(); j++) {
            cout << table.at(i).at(j) << " ";
        }
        cout << endl;
    }
}
long long perm(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long perm = 1;
    for (int i = n; i > n - r; i--) {
        perm *= i;
    }
    return perm;
}
long long comb(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long comb = perm(n,r);
    for (int i = r; i > 0; i--) {
        comb /= i;
    }
    return comb;
}
long long homo(int n, int r) {
    return comb(n + r - 1, n - 1);
}
long long fact(int n) {
    long long fact = 1;
    for (int i = n; i > 0; i--) {
        fact *= i;
    }
    return fact;
}
int gcd(int a, int b)
{
    if (a % b == 0)
    {
        return(b);
    }
    else
    {
        return(gcd(b, a % b));
    }
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int main() {
  int w,a,b;
  cin >> w >> a >> b;
  if(a-b-w<0&&b-a-w<0){
    cout << 0 << endl;
  }else{
    cout << min(abs(a-b-w),abs(b-a-w)) << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,bg,ed) for(int i=bg;i<ed;i++)
#define REP(i,n) FOR(i,0,n)
constexpr int MAX_N = 2*1123456;
namespace prime{
 bool is[MAX_N];
 struct latte{
   latte(){
    REP(i,MAX_N)is[i]=true;
    is[0]=is[1]=false;
    REP(i,MAX_N)if(is[i]){
     	for(int j=i+i;j<MAX_N;j+=i)is[j]=false; 
    }
   }
 }malta;
}
namespace maze{
int r[MAX_N];
int c[MAX_N];
constexpr int dr[]={0,-1,0,1};
constexpr int dc[]={1,0,-1,0};
int maze[2123][2123];
struct latte{
  latte(){
    REP(i,2123)REP(j,2123)maze[i][j]=MAX_N;
    r[1]=c[1]=0;
    int rm = 0;
    int cm = 0;
    int d = 0;
    int v = 2;
    FOR(i,1,1200){
      REP(j,i){
        r[v] = r[v-1]+dr[d];rm = min(rm,r[v]);
        c[v] = c[v-1]+dc[d];cm = min(cm,c[v]);
        v++;
      }
      d++;
      REP(j,i){
        r[v] = r[v-1]+dr[d];rm = min(rm,r[v]);
        c[v] = c[v-1]+dc[d];cm = min(cm,c[v]);
        v++;
      }      
      d++;
      d%=4;
    }
  
  	FOR(i,1,v){
      r[i]-=rm - 5,c[i]-=cm - 5;
      maze[r[i]][c[i]] = i;
    }
  }
}malta;
}
typedef pair<int,int> P;
P dp[2123][2123];
constexpr int INF = 1e8;
int main(){
  int n,m;
  while(cin>>m>>n,n+m){
    int r = maze::r[n];
    int c = maze::c[n];
    REP(i,2123)REP(j,2123)dp[i][j]={-INF,-1};
    dp[r][c] = {0,0};
    if(prime::is[n])dp[r][c]={1,n};
    P ret = dp[r][c];
    REP(i,2123)REP(j,2123){
      const int v = maze::maze[i][j];
      if(v>m)continue;
      P mx = max({dp[i-1][j-1],dp[i-1][j],dp[i-1][j+1]});
      if(prime::is[maze::maze[i][j]]){
      	dp[i][j]=max(dp[i][j],{mx.first+1,v});
      }
      else{
        dp[i][j]=max(dp[i][j],mx);
      }
      ret = max(ret,dp[i][j]);
    }
    cout<<ret.first<<" "<<ret.second<<endl;
  }
}


Measured memory_bytes: 69328
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, x, *A = map(int, read().split())

    if A[0] > x:
        ans1 = A[0] - x
        prev = x
    else:
        ans1 = 0
        prev = A[0]
    for i in range(1, N):
        if prev + A[i] > x:
            ans1 += prev + A[i] - x
            prev = x - prev
        else:
            prev = A[i]

    if A[-1] > x:
        ans2 = A[-1] - x
        prev = x
    else:
        ans2 = 0
        prev = A[-1]
    for i in range(N - 2, -1, -1):
        if prev + A[i] > x:
            ans2 += prev + A[i] - x
            prev = x - prev
        else:
            prev = A[i]

    print(min(ans1, ans2))
    return


if __name__ == '__main__':
    main()


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

int main() {
  int a[2], b[2];
  cin >> a[0] >> a[1];
  cin >> b[0] >> b[1];
  
  if (a[0] == b[0]) {
    cout << 0 << endl;
  } else {
    cout << 1 << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int data[3];
	int i,j,temp;
	
	for(i=0;i<3;i++){
		scanf("%d",&data[i]);
	}
	for(i=0;i<2;i++){
		for(j=i+1;j<3;j++){
			if(data[i]>data[j]){
				temp=data[i];
				data[i]=data[j];
				data[j]=temp;
			}
		}
	}
	for(i=0;i<2;i++){
		printf("%d ",data[i]);
	}
	printf("%d\n",data[2]);
	return 0;
}

Measured memory_bytes: 596
S = input()
N = len(S)
C = [0] * N
c = 0
for i in range(N):
    if S[i] == 'R':
        c = i
    else:
        C[c + (i - c) % 2] += 1
for i in range(N - 1, -1, -1):
    if S[i] == 'L':
        c = i
    else:
        C[c - (c - i) % 2] += 1
print(*[str(c) for c in C])

Measured memory_bytes: 11880
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define uniq(x) (x).erase(unique(ALL(x)),(x).end())
#define SORT(x) sort(ALL(x))
#define REV(x) reverse(ALL(x))
#define foreach(it,x) for(__typeof((x).begin()) it=(x).begin();it!=(x).end();it++)
#define debug(x) cerr<<#x<<"="<<(x)<<endl
#define gett() cerr<<"Time:"<<clock()<<"ms."<<endl
vector<pair<long long,int> > deli,tp;
vector<pair<long long,int> > s[100100];
int n,k;
bool vis[100100];
int daihao[100100];
pair<long long,int> sushi[100100];
#define sqr(x) ((x)*(x))
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>k;
	int cnt=0;
	for(int i=1;i<=n;i++)
	{
		cin>>sushi[i].second>>sushi[i].first;
	}
	sort(sushi+1,sushi+n+1);
	for(int i=1;i<=n;i++){
		if(!vis[sushi[i].second]){
			vis[sushi[i].second]=true;
			daihao[sushi[i].second]=cnt;
			cnt++;
		}
		s[daihao[sushi[i].second]].push_back(make_pair(sushi[i].first,i));
	}
	long long num=0;
	long long sum=0;
	for(int i=0;i<cnt;i++){
		sort(s[i].begin(),s[i].end());
		for(int j=0;j<s[i].size();j++){
			if(s[i][j].second>n-k&&j!=s[i].size()-1)
				tp.push_back(s[i][j]);
			if(s[i][j].second<=n-k&&j==s[i].size()-1)
				deli.push_back(s[i][j]);
			if(s[i][j].second>n-k&&j==s[i].size()-1)
				num++;
			if(s[i][j].second>n-k)
				sum+=s[i][j].first;
		}
	}
	sort(tp.begin(),tp.end());
	sort(deli.begin(),deli.end());
	long long ans=sum+sqr(num);
	for(int i=deli.size()-1,j=0;i>=0&&j<tp.size();i--,j++){
		sum+=deli[i].first-tp[j].first;
		num++;
		ans=max(ans,sum+sqr(num));
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 8952
//by xxj
#include<bits/stdc++.h>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ll long long
#define pii pair<int,int>
#define lowbit(x) x&-x
const int inf=1e9+7;
const double eps=1e-10;
const ll linf=1e18+7;
const ll hh=523;
//const int mod=;
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	string s;
	cin>>s;
	int cnt=0;
	for (int i=0;i<s.size();i++){
		if (s[i]=='x'){
			cnt++;
		}
	}
	if (cnt<=7){
		puts("YES");
	}
	else{
		puts("NO");
	}
	return 0;
}
/*
input:
*/


Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        String S = sc.next();
        PrintWriter pw = new PrintWriter(System.out);
        for (char c : S.toCharArray()) {
            int i = c+N;
            pw.print((char) (i > 90 ? i-26 : i));
        }
        pw.println();
        pw.flush();
    }
}


Measured memory_bytes: 23764
#!/usr/bin/env python3
import copy
from itertools import product
import sys
# from pprint import pprint
sys.setrecursionlimit(10**6)

h, w = list(map(int, input().split()))
map_ = [list(map(int, input().split())) for i in range(10)]

min_ = [[10**4]*10 for i in range(10)]


# dq = [0, 0, set([0])]


# while(dq):
#     num, value, lists = dq.pop()
#     for i in range(10):
#         if i == 1:


def dfs(start=0, now=0, value=0):
    for i in range(10):
        value_tmp = value+map_[now][i]
        if value_tmp < min_[start][i]:
            min_[start][i] = value_tmp
            dfs(start, now=i, value=value_tmp)


for i in range(10):
    dfs(start=i, now=i, value=0)

count = [0]*10
for i in range(h):
    tmp = list(map(int, input().split()))
    for i in tmp:
        if i != -1:
            count[i] += 1

ans = 0
for i in range(10):
    ans += min_[i][1]*count[i]
print(ans)


Measured memory_bytes: 9220
#include<iostream>
#include<string>
#include <algorithm>
#include <list>
#include <fstream>
#include <sstream>

using namespace std;
int main(){
	int n;
	std::istream & c_in = cin;
	string s;
	getline(c_in,s);
	sscanf(s.c_str(),"%d",&n);

	std::list<long> dq;
	for(int i=0;i<n;++i){
		getline(c_in,s);

		int value;
		if (s[0] == 'i') {				//"insert"
			//sscanf(s.substr(6).c_str(),"%d",&value);
			sscanf(&(s[7]),"%d",&value);
			dq.push_front(value);
		} else if (s[0] == 'd') {		//deletexx
			char s6 = s[6];
			if (s6 == ' ') {			//delete
				sscanf(&(s[7]),"%d",&value);
				std::list<long>::iterator it = find(dq.begin(),dq.end(),value);
				if (it != dq.end()) {
					dq.erase(it);
				}
			} else if (s6 == 'F') {	//"deleteFirst"
				//if (!dq.empty()) 
				{
					dq.pop_front();
				}
			} else //if (s6 == 'L')
			{	//"deleteLast"
				//if (!dq.empty()) 
				{
					dq.pop_back();
				}
			}
		}
	}
	if (!dq.empty()) {
		std::list<long>::iterator it = dq.begin(),ite=dq.end();
		cout << *it;
		it++;
		ite = dq.end();
		for(;it != ite;++it) {
			//cout << " " << *it;
			//sprintf_s(buf,32," %d",*it);
			//cout << buf;
			printf(" %d",*it);
		}
	}
	cout << std::endl;
}

Measured memory_bytes: 32436
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  ll n;
  cin >> n;
  vector<ll> a(n);
  REP(i, n) cin >> a[i];
  sort(ALL(a));
  ll d = (ll)(1e18);
  ll m;
  REP(i, n-1){
    ll t = labs(a[i]-a[n-1]/2.0);
    if(t < d){
      d = t;
      m = i;
    }
  }
  cout << a[n-1] << " " << a[m] << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

const lint MOD = 998244353;

lint modpow(lint a, lint x)
{
    if (x == 0)
        return 1;

    if (x % 2 == 1)
        return a * modpow(a, x - 1) % MOD;

    lint ret = modpow(a, x / 2);
    return ret * ret % MOD;
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N, M, K;
    cin >> N >> M >> K;

    VEC(lint) Fac(N + 1);
    Fac[0] = 1;
    FOR(i, 1, N + 1) {
        Fac[i] = Fac[i - 1] * i  % MOD;
    }

    lint ret = 0;
    FOR(g, N - K, N + 1) {
        lint add = M * modpow(M - 1, g - 1) % MOD;
        lint fac = Fac[N - 1] * modpow(Fac[g - 1], MOD - 2) % MOD;
        fac = fac * modpow(Fac[N - g], MOD - 2) % MOD;
        ret = (ret + add * fac % MOD) % MOD;
    }

    cout << ret << endl;
    return 0;
};

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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

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

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

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

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    string s;
    cin>>s;

    rep(i,s.length()-1){
        if(s[i]!=s[i+1])ans++;
    }

    cout<<ans<<endl;

    //cout <<fixed<<setprecision(16)<< << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;

    return 0;
}



// BBBB,WW,BB,W,B,W,B,W,B,W,B,W,B,WW,BBB


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define For(i,a,b) for(int i=a;i<b;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
#define debug(x) cerr << x << endl
#define Complex complex<double>
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

/*
テストケース全てに目を通す
テストケースが2個以下だったらなんかある
N最小のコーナーケースがないか調べる
制約をしっかりと確認する（1からNまでの順列、全て異なる値などの制約も含め）
制約のn*mとn,mを読み違えない
操作の逆順を考える
オーバーフローしないか確かめる
Codeforcesではscanfを使う
modの引き算には+modをする
エラー出力は消す
エラー出力を消せ！！！！！
数値の区切り位置を誤読しない
木はn-1ノード
関数単位で調べる
cout << fixed;
cout << setprecision(n) << ans;
 */

int main() {
    int n,m;
    cin >> n >> m;
    cout << (n*(n-1)+m*(m-1))/2;



    
}

/*
*/



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int N; cin >> N;

	int p[N];
	rep(i, N) cin >> p[i];
	int a[N];
	int b[N];
	rep(i, N) a[i] = 40001 * (i + 1);
	rep(i, N) b[i] = (N - i) * 40001;
	rep(i, N) {
		a[p[i] - 1] += i;
		b[p[i] - 1] += i;
	}

	rep(i, N) cout << a[i] << " ";
	cout << endl;
	rep(i, N) cout << b[i] << " ";
	cout << endl;
	//rep(i, N) cout << a[i] + b[i] << " ";






    return 0;
}


Measured memory_bytes: 896
#include<iostream>

using ull = unsigned long long;

int main() {
	ull A, B, K;
	std::cin >> A >> B >> K;

	for (ull i{}; i < K; ++i) {

		if (i % 2 == 0) {
			A -= A % 2 == 1 ? 1 : 0;
			A /= 2;
			B += A ;
		}
		else {
			B -= B % 2 == 1 ? 1 : 0;
			B /= 2;
			A += B ;
		}
	}

	std::cout << A << " " << B << "\n";
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int n,b,f,r,v,i,j,k,Human[4][3][10]={{{0}}};
	scanf("%d",&n);
	for(i = 0;i < n;i++){
		scanf("%d %d %d %d",&b,&f,&r,&v);
		Human[b-1][f-1][r-1] += v;
	}
	for(i = 0;i < 4;i++){
		for(j = 0;j < 3;j++){
			for(k = 0;k < 10;k++){
				printf(" %d",Human[i][j][k]);
			}
			printf("\n");
		}
		if(i != 3){
			printf("####################\n");
		}
	}
	return 0;
}

Measured memory_bytes: 612
using namespace std;

#include <iostream>
#include <bits/stdc++.h>

int main(){
    int n;
    cin >> n;
    char a[n];
    char b[n];
    for ( int i = 0; i < n; i ++ ){
        cin >> a[i];
    }
    for ( int i = 0; i < n; i ++ ){
        cin >> b[i];
    }
    for ( int i = 0; i < n; i ++ ){
        cout << a[i] << b[i];
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf

int n;
int t, a;
double diff = 1e9;
int ansIndex;

int main() { 

  scanf("%d", &n);
  scanf("%d %d", &t, &a);

  for (int i = 0; i < n; i++) {
    int h;
    scanf("%d", &h);
    double tm = 1.0 * t - 1.0 * h * 0.006;
    tm = abs(tm - 1.0 * a);
    if (tm < diff) {
      diff = tm;
      ansIndex = i;
    }
  }

  cout << ansIndex + 1 << endl;

  return 0;
}


Measured memory_bytes: 256
package main

import (
        "bufio"
        "fmt"
        "os"
)

func solution(n int, a []int) int {
        const MOD = 1e9 + 7
        out := 0
        cur := make([]int, n+1)
        cur[0] = a[0]
        for i := 0; i < n; i++ {
                cur[i+1] = a[i] + cur[i]
        }
        for i := 0; i < n; i++ {
                sum := (cur[n] - cur[i+1]) % MOD
                out = (out + a[i]*sum) % MOD
        }
        return out
}

func main() {
        r := bufio.NewReader(os.Stdin)
        var n int
        fmt.Fscan(r, &n)
        a := make([]int, n)
        for i := range a {
                fmt.Fscan(r, &a[i])
        }
        fmt.Println(solution(n, a))
}

Measured memory_bytes: 7604
# 2020/03/14
# AtCoder Beginner Contest 141 - C

# Input
n, k, q = map(int,input().split())
a = list()
plist = [0] * n

# Calc
for i in range(q):
    a = int(input())
    plist[a-1] = plist[a-1] + 1

# Output
for i in range(n):
    if k - q + plist[i] > 0:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 4680
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
#define fs first
#define sc second
// 多倍長
#include <boost/rational.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using boost::rational;
using boost::multiprecision::cpp_int;

const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;


int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int l, r, d;
    cin >> l >> r >> d;
    int ans = 0;
    REP(i, l, r + 1){
      if(i % d == 0) ans++;
    }
    print(ans);
    

}


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

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

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n;
  cin >> n;
  vint a(n);
  vint sum(n+1);
  rep(i, n) {
    cin >> a[i];
    sum[i+1] = sum[i]+a[i];
  }
  int ans = inf;
  auto f = [&](int l, int m, int r) {
    return abs((sum[m]-sum[l])-(sum[r]-sum[m]));
  };
  reps(i, 2, n-1) {
    int mx = -inf, mn = inf;
    {
      int lb = 1, ub = i;
      while(lb+1 < ub) {
	int mb = (lb+ub)/2;
	if(f(0, mb, i) < f(0, mb-1, i)) lb = mb;
	else ub = mb;
      }
      chmax(mx, max(sum[lb]-sum[0], sum[i]-sum[lb]));
      chmin(mn, min(sum[lb]-sum[0], sum[i]-sum[lb]));
    }
    {
      int lb = i, ub = n;
      while(lb+1 < ub) {
	int mb = (lb+ub)/2;
	if(f(i, mb, n) < f(i, mb-1, n)) lb = mb;
	else ub = mb;
      }
      chmax(mx, max(sum[lb]-sum[i], sum[n]-sum[lb]));
      chmin(mn, min(sum[lb]-sum[i], sum[n]-sum[lb]));
    }
    chmin(ans, mx-mn);
  }
  cout << ans << endl;

  return 0;
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP (i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back

using namespace std;

typedef long long ll;

// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

int main() {
  ll r, d, x;
  cin >> r >> d >> x;

  rep (i, 10) {
    ll nx = r * x - d;
    cout << nx << endl;
    x = nx;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Int int64_t
#define ll long long
#define pb push_back
using namespace std;
const int MAXN=500005;


int main()
{
        Int N,M;cin>>N>>M;
        Int Sa,Sb;cin>>Sa>>Sb;
        --Sa;--Sb;
        Int Da,Db;cin>>Da>>Db;
        --Da;--Db;
        
        vector<vector<int>> board(N,vector<int>(M));
        for(int i=0;i<N;++i){
            for(int j=0;j<M;++j){
                char x;cin>>x;
                board[i][j]=(x=='.' ? 1:0);
            }
        }
        
        priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> q;
        q.push({Sa,Sb});
        vector<vector<int>> dis(N,vector<int>(M,1e9));
        dis[Sa][Sb]=0;
        vector<pair<int,int>> dir={{-1,0},{1,0},{0,1},{0,-1}};
        
        while(!q.empty()){
            
                  auto x=q.top();
                  q.pop();    
                 
                  for(auto itr:dir){
                      int i=x.first+itr.first;
                      int j=x.second+itr.second;
                      if(i<0||j<0||i>=N||j>=M||!board[i][j])  continue;
                      if(dis[i][j]>dis[x.first][x.second]){
                          dis[i][j]=dis[x.first][x.second];
                          q.push({i,j});
                      }
                  }
                  
                    for(int i=x.first-2;i<=x.first+2;++i){
                        for(int j=x.second-2;j<=x.second+2;++j){
                            if(i<0||j<0||i>=N||j>=M)  continue;
                            if(board[i][j]==0) continue;
                            if(dis[i][j]>dis[x.first][x.second]+1){
                                 dis[i][j]=1+dis[x.first][x.second];
                                  q.push({i,j});
                            
                            }
                        }
                    }
            }
             cout<<(dis[Da][Db]==1e9 ? -1:dis[Da][Db])<<"\n";
}

Measured memory_bytes: 11436
n,m = map(int, input().split())
a_s = sorted(list(map(int, input().split())), reverse=True)
cnt = 0
b = sum(a_s) * 1/(4 * m)

for i in range(m):
    if a_s[i] >= b:
        cnt += 1

if cnt >= m:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main() {
    int D, N; cin>>D>>N;
    int div=0;
    D == 0 ? div=1 : D == 1 ? div=100 : div=10000;
    N < 100 ? cout<<N*div<<endl : cout<<101*div<<endl;
    return 0;
}


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

int main() {
  set<int> kashi;

  int N, K;
  cin >> N >> K;

  vector<int> d(K);
  int tmp;
  for (int i = 0; i < K; ++i) {
    cin >> d.at(i);
    vector<int> A(d.at(i));
    for (int j = 0; j < d.at(i); ++j) {
      cin >> A.at(j);
    }
    for (int j = 0; j < d.at(i); ++j) {
      kashi.insert(A.at(j));
    }
  }
  cout << N - kashi.size() << endl;
}

Measured memory_bytes: 3636
import sys
input = sys.stdin.readline
S = list(map(int, list(input())[: -1]))

def check(x):
  t = S + []
  for i in range(len(t) - x):
    t[i] = 0
    t[-1 - i] = 0
  if t.count(0) == len(t):
    return True
  for i in range(len(t) - x):
    t[i] = 1
    t[-1 - i] = 1
  if t.count(1) == len(t):
    return True
  return False

ok = 1
ng = len(S) + 1
while ng - ok > 1:
  m = (ok + ng) // 2
  if check(m): ok = m
  else: ng = m
print(ok)

Measured memory_bytes: 53224
#pragma GCC optimize("O3", "unroll-loops")
#include <bits/stdc++.h>

using namespace std;
string s = "Christmas", t = " Eve";
int n;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	cout << s;
	for (int i = 0; i < 25 - n; i++)
		cout << t;
	cout << '\n';
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> cnt(1e6 + 1, 0);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        cnt[a[i]]++;
    }
    sort(begin(a), end(a));
    int ans = 0;
    vector<bool> prime(1e6 + 1, false);
    for (int i = 1; i <= (int)1e6; i++) prime[i] = true;
    for (auto x : a) {
        if (!prime[x]) continue;
        if (cnt[x] == 1) ans++;
        for (int j = x; j <= (int)1e6; j += x) prime[j] = false;
    }
    cout << ans << endl;
}

Measured memory_bytes: 8008
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

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

	if (n < 1000)
		cout << "ABC" << endl;
	else
		cout << "ABD" << endl;
}

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

	solve();
}

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

int main(void){
	char sent[1001];
	int i;
	
	for(i=0;i<1000;++i){
		sent[i] = '\0';
	}
	
	scanf("%[^\n]",sent);
	
	for(i=0;sent[i]!='\0';++i){
		if((sent[i] == 'a') && (sent[i+1] == 'p') && (sent[i+2] == 'p') && (sent[i+3] == 'l') && (sent[i+4] == 'e')){
			sent[i+0] = 'p';
			sent[i+1] = 'e';
			sent[i+2] = 'a';
			sent[i+3] = 'c';
			sent[i+4] = 'h';
			i = i+4;
		}
		if((sent[i] == 'p') && (sent[i+1] == 'e') && (sent[i+2] == 'a') && (sent[i+3] == 'c') && (sent[i+4] == 'h')){
			sent[i+0] = 'a';
			sent[i+1] = 'p';
			sent[i+2] = 'p';
			sent[i+3] = 'l';
			sent[i+4] = 'e';
			i = i+4;
		}
	}
	
	printf("%s\n", sent);
	
	return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int mod=1000000007;
inline void add(int &a,int b){
    a+=b;
    if(a>=mod)a-=mod;
}
int mpow(int n,int m,int mod){
    int ret=1;
    while(m){
        if(m&1)ret=ret*n%mod;
        n=n*n%mod;
        m>>=1;
    }
    return ret;
}
const int FACT_SIZE=1111111;
int fact[FACT_SIZE];
int inv[FACT_SIZE];
struct fact_exec{
    fact_exec(){
        fact[0]=1;
        for(int i=1;i<FACT_SIZE;i++)fact[i]=fact[i-1]*i%mod;
        inv[FACT_SIZE-1]=mpow(fact[FACT_SIZE-1],mod-2,mod);
        for(int i=FACT_SIZE-2;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;
    }
};
int nCk(int n,int k){
    if(n<0|k<0||k>n)return 0;
    return fact[n]*inv[k]%mod*inv[n-k]%mod;
}
int nPk(int n,int k){
    if(n<0||k<0||k>n)return 0;
    return fact[n]*inv[n-k]%mod;
}

int N;

int S[3333][3333];
int T[3333];

int po[3333*3333];

signed main(){
    cin>>N>>mod;
    fact_exec();

    S[0][0]=1;
    for(int i=1;i<3333;i++){
        for(int j=1;j<=i;j++)S[i][j]=(S[i-1][j-1]+j*S[i-1][j])%mod;
    }
    po[0]=1;
    for(int i=1;i<3333*3333;i++)po[i]=po[i-1]*2%mod;

    int ans=0;
    for(int i=0;i<=N;i++){
        int tmp=0;
        for(int j=0;j<=i;j++){
            add(tmp,S[i][j]*po[(N-i)*j]%mod);
            add(tmp,S[i][j+1]*(j+1)%mod*po[(N-i)*j]%mod);
        }
        tmp=tmp*nCk(N,i)%mod;
        tmp=tmp*mpow(2,mpow(2,N-i,mod-1),mod)%mod;

        if(i&1)add(ans,mod-tmp);
        else add(ans,tmp);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 191232
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------

signed main() {
	ld a;
	cin >> a;
	printf("%.20LF %.20LF\n", a * a * M_PI, 2 * a * M_PI);
}


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

using namespace std;

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

    if (a == b && b == c) {
        cout << "0" << endl;
    } else {
        int x = max({a,b,c});
        int k = (x - a) + (x - b) + (x - c);
        int ans = 0;
        if (k % 2 == 0) {
            ans = k / 2;
        } else {
            ans = k / 2 + 2;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
def solve(string):
    n, q, s, *lr = string.split()
    n = int(n)
    c = [0] * n
    count = 0
    for i in range(n):
        if i == 0:
            continue
        if s[i - 1:i + 1] == "AC":
            count += 1
        c[i] = count

    lr = list(map(int, lr))
    return "\n".join([str(c[r - 1] - c[l - 1]) for l, r in zip(lr[::2], lr[1::2])])


if __name__ == '__main__':
    n, m = map(int, input().split())
    print(solve('{} {}\n'.format(n, m) + '\n'.join([input() for _ in range(m + 1)])))


Measured memory_bytes: 27292
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                           \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
  cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A, B;
  cin >> A >> B;
  cout << A * B << endl;
  return 0;
}


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

const ll dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const ll dx[] = {1, 0, -1, 0, 1, 1, -1, -1};

inline bool inside(ll y, ll x, ll H, ll W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

char G[1005][1005];
ll cost[1005][1005];

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll h,w; cin>>h>>w;
  rep(i,h) rep(j,w) cin>>G[i][j];
  
  memset(cost,-1,sizeof(cost));
  
  queue<pll> q;
  rep(i,h) rep(j,w) if(G[i][j]=='#'){
    q.emplace(i,j);
    cost[i][j]=0;
  }
  
  while(!q.empty()){
    auto p=q.front(); q.pop();
    ll y=p.first, x=p.second;
    rep(i,4){
      ll ny=dy[i]+y, nx=dx[i]+x;
      if(inside(ny,nx,h,w)&&cost[ny][nx]==-1){
        cost[ny][nx]=cost[y][x]+1;
        q.emplace(ny,nx);
      }
    }
  }
  
  ll ans=0;
  rep(i,h) rep(j,w) chmax(ans,cost[i][j]);
  cout<<ans<<endl;
  
}

Measured memory_bytes: 25524
#include <bits/stdc++.h>
using namespace std;
//型に気を付けよう

#define rep(i,n) for(int i=0;i<n;i++)
typedef long long  ll;
const double pi=3.1415926535;
const ll  mod=1000000007;
//桁数指定　cout << fixed << setprecision(2)
int main() {
  int a,b,c,d,n;
  cin>>n;
  a=n/1000;
  n-=1000*a;
  b=n/100;
  n-=b*100;
  c=n/10;
  d=n%10;
  char op1,op2,op3;
  int flag=7;
  op1='+';
  op2='+';
  op3='+';    
  rep(i,8){
    int sum=a;
    if(flag/4){op1='+';sum+=b;}
    else {op1='-';sum-=b;}
    if(flag%4==2||flag%4==3){op2='+';sum+=c;}
    else {op2='-';sum-=c;}
    if(flag%2){op3='+';sum+=d;}
    else {op3='-';sum-=d;}
    if(sum==7)break;
    flag--;
  }
  cout<<a<<op1<<b<<op2<<c<<op3<<d<<"=7";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int n;

int is_prime[11000];

int main(){
	REP(i, 11000)is_prime[i] = 1;
	is_prime[0] = is_prime[1] = 0;
	for (int i = 2; i <= 10000; i++){
		if (is_prime[i]){
			for (int j = i * 2; j <= 10000; j += i)is_prime[j] = 0;
		}
	}

	while (cin >> n){
		int ans = 0;
		FOR(i, 1, n + 1){
			if (is_prime[i] && is_prime[n + 1 - i])ans++;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1200