akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstring>
#include<queue>
using namespace std;

int main(){
  int x,y;
  int dx[] = {1,0,1,-1,0,-1};
  int dy[] = {0,1,1,0,-1,-1};
  int map[200][200];
  int t,n,ans;
  queue<int> qx,qy;

  while(1){
    cin >> t >> n;
    if(!t && !n)break;

    memset(map,0,sizeof(map));
    for(int i=0;i<n;i++){
      cin >> x >> y;
      map[100+y][100+x] = -1;
    }

    cin >> x >> y;
    map[100+y][100+x] = 1;
    qx.push(x);
    qy.push(y);

    ans = 1;
    while(qx.size()){
      x = qx.front();
      y = qy.front();
      qx.pop();
      qy.pop();

      if(map[100+y][100+x]<=t){
	for(int i=0;i<6;i++){
	  if(map[100+y+dy[i]][100+x+dx[i]] == 0){
	    qx.push(x+dx[i]);
	    qy.push(y+dy[i]);
	    map[100+y+dy[i]][100+x+dx[i]] = map[100+y][100+x] + 1;
	    ans++;
	  }
	}
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1076
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
// constexpr long double EPS = 1e-15;
// const long double PI = acos(-1);
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;
//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair
    ll n,m;

void solve() {
    cin >> n >> m;
    priority_queue<ll> pq;
    REP(i,n) {
        ll k;
        cin >> k;
        pq.push(k);
    }
    ll ans = 0;
    REP(i,m) {
        ll tp = pq.top();
        pq.pop();
        pq.push(tp/2);
    }
    while (!pq.empty()) {
        ans += pq.top();
        pq.pop();
    }
    cout << ans << endl;
}

int main(int argc, char *argv[]){
    // /* Regular */
    // int case_num = 1;
    // if (argc > 1 && stoi(argv[1])) cin >> case_num;
    // REP(case_no, case_num) {
    //   cerr << endl << "case " << case_no + 1 << endl;
    //   solve();
    // }
    /* AOJ */
    solve();
    return 0;
}

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

int main(){
  long long i,n,k,p,r,z=0;
  scanf("%lld %lld",&n,&k);

  for(i=k+1;i<=n;i++){
    p=n/i;
    r=n%i;
    z+=p*max(0LL,i-k);
    z+=max(0LL,r-k+1);
  }
  if(k==0) z-=n;
  printf("%lld",z);
  return 0;
}


Measured memory_bytes: 256
F =-> {gets.split.map &:to_i}
N,W = F[]
D = Hash.new W+1
D[0] = 0
N.times {
	w,v = F[]
	D.keys.sort.reverse_each {|i| D[i+v] > x=D[i]+w and D[i+v]=x}
}
p D.keys.max

Measured memory_bytes: 58328
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(v) v.begin(), v.end()
//#define mod 1000000007
#define mod2 1000000006
#define inf 1000000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<lli>
#define vii vector<int>
#define is indexed_set
#define eps 0.000001
#define endl '\n'
#define mo 998244353
#define pi 3.141592653589793
#define fi first
#define se second
using namespace std ;
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
lli m=1000000007;
lli parent[200001],rnk[200001];
void make_set(int v) {
    parent[v] = v;
    rnk[v] = 0;
}
int find_set(int v) {
    if (v == parent[v])
        return v;
    return find_set(parent[v]);
}
void union_sets(int a, int b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
        if (rnk[a] < rnk[b])
        swap(a, b);
        parent[b] = a;
        rnk[a]+=rnk[b];
    }
}
void solve()
{
	lli n,m;
	cin>>n>>m;
	for(lli i=0;i<=n;i++)parent[i]=i,rnk[i]=1;
	for(lli i=0;i<m;i++){
		lli x,y;
		cin>>x>>y;
		if(find_set(x)==find_set(y))continue;
		union_sets(x,y);

	}
	lli ani=0;
	for(lli i=1;i<=n;i++){
		ani=max(ani,rnk[find_set(i)]);
	}
	cout<<ani;

}
 
int main()
{
/////////////////////////////////////
    fastio;
    
/////////////////////////////////////  
    lli t,m;
    //cin>>t;
    t=1;
    while(t--)
    {
    	solve();  
    	m++;  
    	cout<<endl;
    }
}

Measured memory_bytes: 5164
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

int main()
{
	int n;
	cin >> n;
	vector<int> b(n);
	rep(i,n)cin >> b[i];
	rep(i,n)
	{
		if(b[i]>i+1)
		{
			cout<<-1<<endl;
			return 0;
		}
	}
	vector<int> ans;
	//ans.push_back(0);
	rep(i,n)
	{
		ans.insert(ans.begin()+b[i]-1,b[i]);
	}
	rep(i,n)cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int d = scan.nextInt();
		int e = scan.nextInt();
		int k = scan.nextInt();
		
		if(e-a > k) System.out.println(":(");
		else System.out.println("Yay!");
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	int T;
	cin >> T;
	while(T--){
		int p, q;
		cin >> p >> q;
		bool flag = false;
		for(int m = -150; !flag && m <= 150; ++m){
			for(int n = -150; !flag && n <= 150; ++n){
				if(m == 0 && n == 0){ continue; }
				if((m == 1 || m == -1) && n == 0){ continue; }
				if((n == 1 || n == -1) && m == 0){ continue; }
				if(p ==  m && q ==  n){ continue; }
				if(p == -n && q ==  m){ continue; }
				if(p == -m && q == -n){ continue; }
				if(p ==  n && q == -m){ continue; }
				const int a = m * p + n * q, b = m * q - n * p;
				if(__gcd(a, b) % (m * m + n * n) == 0){ flag = true; }
			}
		}
		cout << (flag ? "C" : "P") << endl;
	}
	return 0;
}

Measured memory_bytes: 1184
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    LLONG N, A, B; cin >> N >> A >> B;
    LLONG setNum = N / (A + B);
    LLONG remNum = N % (A + B);
    LLONG ans = A * setNum;
    ans += min(remNum, A);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
typedef pair<int,int> P;
typedef long long ll;
const int INF = 1001001001;
const ll INFL = 1e17;
const int MOD = 1e9+7;


int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> e(1000001);

    rep(i,n){
        cin >> a[i];
        e[a[i]]++;
    }
    bool pairwise = true;
    for(int i=2; i<=1000001; i++){
        int count = 0;
        for(int j=i; j<=1000001; j+=i){
            count += e[j];
        }
        if(count >= 2) pairwise = false;
    }

    if(pairwise){
        cout << "pairwise coprime" << endl;
        return 0;
    }
    int gcda = 0;
    rep(i,n) gcda = __gcd(gcda,a[i]);
    if(gcda!=1) cout << "not coprime" << endl;
    else cout << "setwise coprime" << endl;
    return 0;
}

Measured memory_bytes: 11132
#include<bits/stdc++.h>
#include<cmath>
#include<string>
using namespace std;
#define f first
#define s second
#define MOD 1000000007
#define fast ios::sync_with_stdio(0),cout.tie(0),cin.tie(0)
#define pb push_back
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define mp make_pair
#define mkt make_tuple
#define deb(x) cerr<<#x<<" "<<x<<"\n"
#define debi cerr<<"wait\n"
#define nax 100
typedef long long ll;
typedef unsigned long long ull;

class solution{
public:
	void solve(){
		ll n,a,b;
		cin>>n>>a>>b;
		ll val = a+b;
		ll ans = (n/(val))*a + min(n%(val),a);
		cout<<ans;	
	}

};

int main()
{
    fast;
	ll i=0;
	int t=1;
	//cin>>t;
	while(t--){
		solution s;
		s.solve();
	}

 return 0;
}



Measured memory_bytes: 256
;; C - Guess The Number

(defun solve (n sc)
  (loop for i from 0 below (expt 10 n)
        for digits = (map 'vector #'digit-char-p (princ-to-string i))
     when (and (= (length digits) n)
               (zerop
                 (loop for (s . c) in sc
                   count (not (eql c (aref digits (1- s)))))))
     do (return i)
     finally (return -1)))

(let* ((n  (read))
       (m  (read))
       (sc (loop repeat m collect (cons (read) (read)))))
  (princ (solve n sc)))


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

typedef vector<int> vi;

bool checkLikeDigs(int N, vi &d) {
	string num = to_string(N);
	for (int i = 0; i < num.size(); i++) {
		if (d[num[i] - '0'])
			return false;
	}
	return true;
}

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int N, K, i, e;
	vi dislike(10);
	cin >> N >> K;
	for (i = 0; i < K; i++) {
		cin >> e;
		dislike[e] = 1;
	}
	for (; N <= 999999; N++) {
		if (checkLikeDigs(N, dislike))
			break;
	}
	cout << N << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC return 0;
using namespace std;
inline bool Ok(string s) {
    return s[2] == s[3] && s[4] == s[5];
}
string s;
int main() {
    DAU
    cin >> s;
    if (Ok(s))
        cout << "Yes";
    else cout << "No";
    PLEC
}


Measured memory_bytes: 256
N,M,C = map(int,input().split())
B = [int(i) for i in input().split()]
A = [[int(i) for i in input().split()] for _ in range(N)]

ans = 0
for i in range(N):
    cnt = 0
    for a,b in zip(A[i], B):
        cnt += a*b
    if cnt + C > 0:
        ans += 1

print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
#define N 36

typedef struct{
  char mark;
  int num;
}Card;

void bubbleSort(Card *, int);
void selectionSort(Card *, int);

int main(){
  int i, n, count=0;
  Card cardb[N], cards[N];

  scanf("%d", &n);
  for(i=0; i<n; i++){
    scanf(" %c%d", &cardb[i].mark, &cardb[i].num);
    cards[i] = cardb[i];
  }

  bubbleSort(cardb, n);
  selectionSort(cards, n);

  for(i=0; i<n; i++){
    printf("%c%d", cardb[i].mark, cardb[i].num);
    if(i == n-1)printf("\n");
    else printf(" ");
  }
  printf("Stable\n");
  for(i=0; i<n; i++){
    printf("%c%d", cards[i].mark, cards[i].num);
    if(i == n-1)printf("\n");
    else printf(" ");
    if(cardb[i].mark == cards[i].mark && cardb[i].num == cards[i].num)count++;
  }
  if(count == n)printf("Stable\n");
  else printf("Not stable\n");

  return 0;
}

void bubbleSort(Card *A, int n){
  int i, flag=1;
  Card a;

  while(flag){
    flag = 0;
    for(i=n-1; i>0; i--){
      if(A[i].num < A[i-1].num){
	a = A[i];
	A[i] = A[i-1];
	A[i-1] = a;
	flag = 1;
      }
    }
  }
}

void selectionSort(Card *A, int n){
  int i, j, minj;
  Card a;

  for(i=0; i<n; i++){
    minj = i;
    for(j=i; j<n; j++){
      if(A[j].num < A[minj].num) minj = j;
    }

    if(A[i].num != A[minj].num){
      a = A[i];
      A[i] = A[minj];
      A[minj] = a;
    }
  }
}



Measured memory_bytes: 2036
#include<iostream>

using namespace std;

int main () {

    int i, j;
    int n, S[10000], q, T[500], count = 0;

    cin >> n;
    for (i = 0; i < n; i++) {

        cin >> S[i];

    }

    cin >> q;
    for (i = 0; i < q; i++) {

        cin >> T[i];

    }

    for (i = 0; i < q; i++) {

        for (j = 0; j < n; j++) {

            if (T[i] == S[j]) {

                count++;

                break;

            }

        }

    }

    cout << count << endl;

    return 0;

} 

Measured memory_bytes: 3080
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
const double eps = 1e-8;
const double pi = acos(-1.0);
const int inf = 0x3f3f3f3f;
typedef long long ll;
int sgn(double x){
    if(fabs(x)<eps){
        return 0;
    }
    if(x<0){
        return -1;
    }else{
        return 1;
    }
}
struct Point{
    double x,y;
    Point(){}
    Point(double _x,double _y){
        x = _x;
        y = _y;
    }
    void input(){
        scanf("%lf%lf",&x,&y);
    }
    bool operator < (Point b)const{
        // return sgn(x-b.x)==0?sgn(y-b.y)<0:x<b.x;
        return sgn(y-b.y)==0?x<b.x:y<b.y;
    }
    bool operator == (Point b)const{
        return sgn(x-b.x)==0&&sgn(y-b.y)==0;
    }
    Point operator -(const Point &b)const{
        return Point(x-b.x,y-b.y);
    }
    double operator ^(const Point &b)const{
        return x*b.y-y*b.x;
    }
    Point operator /(const double& k)const{
        return Point(x/k,y/k);
    }
    double distance(Point p){
        return hypot(x-p.x,y-p.y);
    }
};
struct Line{
    Point s,e;
    Line(){}
    Line(Point _s,Point _e){
        s  = _s;
        e = _e;
    }
    Point crosspoint(Line v){
        double a1 = (v.e-v.s)^(s-v.s);
        double a2 = (v.e-v.s)^(e-v.s);
        return Point((s.x*a2-e.x*a1)/(a2-a1),(s.y*a2-e.y*a1)/(a2-a1));
    }
};
struct polygon{
    int n;
    vector<Point> p;
    void input(int _n){
        n = _n;
        Point tt;
        for(int i = 0;i < n;++i ){
            tt.input();
            p.push_back(tt);
        }
    }
    //直线切多边形
    vector<Point> convexCut(const vector<Point> &ps,Point q1,Point q2){
        vector<Point> qs;
        int n = ps.size();
        for(int i = 0;i < n;++i ){
            Point p1 = ps[i],p2 = ps[(i+1)%n];   //!!!开始是这里没对n取模
            int d1 = sgn((q2-q1)^(p1-q1)),d2 = sgn((q2-q1)^(p2-q1));
            if(d1>=0){
                qs.push_back(p1);
            }
            if(d1*d2<0){
                qs.push_back(Line(p1,p2).crosspoint(Line(q1,q2)));
            }
        }
        return qs;
    }
};
int main(){
    int N;
    scanf("%d",&N);
    polygon pp;
    pp.input(N);
    int q;
    scanf("%d",&q);
    vector<Point> ans;
    Point tmp1,tmp2;
    while(q--){
        tmp1.input();
        tmp2.input();
        ans = pp.convexCut(pp.p,tmp1,tmp2);
        // for(int i = 0;i < ans.size();++i ){
        //     printf("%lf %lf\n",ans[i].x,ans[i].y);
        // }
        double res = 0;
        if(ans.size() == 0){
            printf("%.8f\n",res);
            continue;
        }
        ans.push_back(ans[0]);
        int len = ans.size();
        for(int i = 0;i < len-1;++i ){
            res += (ans[i]^ans[i+1]);
        }
        res /= 2;
        if(res<0){
            res = -res;
        }
        printf("%.8f\n",res);
    }
     return 0;
}


Measured memory_bytes: 3220
#include<stdio.h>
 
int main(void){
  int X,A,B;
  if(scanf("%d %d %d",&X,&A,&B));
  if(X>=1 && X<=1000000000 && A>=1 && A<=1000000000 && B>=1 && B<=1000000000){
    if(X<(B-A))
      printf("dangerous");
    else if(A>=B)
      printf("delicious");
    else
      printf("safe");
  }
  return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<iomanip>
#include<cassert>

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

	int n;//単語の個数
	bool flag = true;
	std::string previous_str;
	std::string current_str;

	std::cin >> n;
	std::vector<std::string> str(n);

	//input
	for (int i = 0; i < n; i++){
		std::cin >> str[i];
	}

	//単語のつながりをチェック
	for (int i = 1; i < n; i++){//**1**からn-1まで
		previous_str = str[i - 1];
		current_str = str[i];
		if (previous_str[previous_str.length() - 1] != current_str[0]){//前の単語とつながっていない場合
			flag = false;
			//ルールに従っていない場合ループを抜け出す
			break;
		}
	}

	if (flag == true){
		//単語の重複をチェック
		for (int i = 0; i < n - 1; i++){
			for (int j = i + 1; j < n; j++){
				if (str[i] == str[j]){
					flag = false;
					//ルールに従っていない場合ループを抜け出す
					break;
				}
			}

			//ルールに従っていない場合ループを抜け出す
			if (flag == false)
				break;
		}
	}

	if (flag == true){
		std::cout << "Yes\n";
	}
	else{
		std::cout << "No\n";
	}

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <list>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(d) string(1,d)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
  string s;
  cin>>s;
  rep(i,0,4){
  	cout << s[i];
  }
  cout << " ";
  rep(i,4,12){
  	cout << s[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n;  cin>>n;
    string s; cin>>s;
    string ans;
    stack<char>st;
    for(int i=0;i<s.size();i++){
        if(s[i]=='('){st.push('(');ans+="(";continue;}
        if(st.empty()){string temp; temp+="(";temp+=ans; temp+=")";ans=temp;}
        else{
            ans+=")"; st.pop(); continue;
        }
       // cout<<ans<<endl;
    }
    rep(i,st.size()){ans+=")";}
    cout<<ans<<endl;
}

Measured memory_bytes: 256
n = int(input())
l = []
for i in range(n):
    x,y = map(int,input().split())
    l.append((x,y))
for i in range(n-2):
    if l[i][0] == l[i][1] and l[i+1][0] == l[i+1][1] and l[i+2][0] == l[i+2][1]:
        print('Yes')
        exit()
print('No')

Measured memory_bytes: 62548
#include<bits/stdc++.h>
using namespace std;
int main(){
  priority_queue<double, vector<double>, greater<double>>p;
  int n;
  cin>>n;
  double a, b, c;
  for(int i=0;i<n;i++){
    cin>>a;
    p.push(a);
  }
  while(1){
    if(n==1)break;
    n--;
    a=p.top();
    p.pop();
    b=p.top();
    p.pop();
    c=(a+b)/2;
    p.push(c);
    // cout<<c<<endl;
  }
  cout<<p.top()<<endl;
}


Measured memory_bytes: 256
r, g, b, n = (int(i) for i in input().split())  
 
rmax = int(n/r)
count = 0
 
for i in range(0, rmax + 1):
  gmax = (n - r * i) // g
  for j in range(0, gmax + 1):
    tmp = n - r * i - g * j
    if (tmp % b == 0 and tmp >=0):
      count += 1
  
print(count)

Measured memory_bytes: 3060
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <utility>
#include <vector>

int main() {
  int n;
  scanf("%d", &n);

  std::vector<int> a(n);
  for (int i = 1; i < n; ++i) {
    size_t j;
    scanf("%zu", &j);
    --j;
    ++a[j];
  }

  for (auto ai: a) printf("%d\n", ai);
}


Measured memory_bytes: 3540
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int n,m,i,j,k,p=0,s,ans=0;
    cin >> n >> m;
    vector<int> a(n);
    for(i=0;i<m;i++){
        cin >> k;
        for(j=0;j<k;j++){
            cin >> s;
            s--;
            a[s] |= 1<<i;
        }
    }
    for(i=0;i<m;i++){
        cin >> s;
        p |= s<<i;
    }
    for(i=0;i<(1<<n);i++){
        int t=0;
        for(j=0;j<n;j++){
            if(i>>j&1) t^=a[j];
        }
        if(t==p) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define si(x) (ll)((x).size())
#define pb push_back
#define F first
#define S second
#define rep(i,n) for(ll i=0;i<n;i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per1(i,n) for(ll i=n;i>=1;i--)
#define all(x) (x).begin(), (x).end()
#define make_unique(x) (x).resize(unique(all(x))-(x).begin())
const int N = 2e5;
struct cc
{
    ll x,  y, count;
};
void solve()
{
    ll n, x, y, w, h, maxlevel = 0;
    cin >> n;
    std::vector<vector<ll>> v(n);
    map<ll, ll> comp;
    for(auto &i : v)
    {
        i.resize(2);
        cin >> x >> y;
        i[0] = x - y ;
        i[1] = x + y;

        comp[i[0]] = 1;
        comp[i[1]] = 1;
    }
    sort(all(v));
    ll j = 0;
    for(auto &i : comp)
        comp[i.first] = j++;

    rep(i, n)
    v[i][0] = comp[v[i][0]], v[i][1] = comp[v[i][1]];

    ll dp[comp.size() + 100];
    memset(dp, 0, sizeof dp);

    ll id = 0, ans = 0;
    rep(i, comp.size() + 1)
    {

        while(id < n and i == v[id][0])
        {
            // cout<<"*";
            dp[v[id][1]] = max(dp[v[id][1]], dp[i] + 1);
            

            id++;
        }
        dp[i + 1] = max(dp[i + 1], dp[i]);

        // rep(k, j + 1)
        // cout << dp[k] << " ";
        // cout << endl;

    }
    rep(i,comp.size()+1)
    {
    	ans=max(ans,dp[i]);
    }
    cout << ans << endl;










}

int main()
{


    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;

    while(t--)
    {
        solve();
        // cout << endl;
    }


}




Measured memory_bytes: 19840
import math

def isPrime(x):
	if x == 2:
		return True

	if x < 2 or x % 2 == 0:
		return False

	i = 3
	while i <= math.sqrt(x):
		if x % i == 0:
			return False
		i = i + 2

	return True

if __name__ == '__main__':
	n = int(input())
	A = [int(input()) for i in range(n)]

	cnt = 0
	for i in range(n):
		if isPrime(A[i]) == True:
			cnt = cnt + 1

	print(cnt)

Measured memory_bytes: 8024
def connected_components(graph)
	components = []
	visited = [false] * graph.size
	graph.size.times do |i|
		next if visited[i]
		visited[i] = true
		queue = [i]
		component = []
		until queue.empty?
			j = queue.pop
			component << j
			graph[j].each do |k|
				unless visited[k]
					visited[k] = true
					queue << k
				end
			end
		end
		components << component
	end
	components
end

n, m = gets.split.map &:to_i
graph = n.times.map {[]}
m.times do
  a, b = gets.split.map &:to_i
  a -= 1
  b -= 1
  graph[a] << b
  graph[b] << a
end

p connected_components(graph).map(&:size).max

Measured memory_bytes: 40728
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int D = sc.nextInt();

        boolean turn = true;
        while(true){
            if(turn){
                C -= B;
                turn = false;
            }else{
                A -= D;
                turn = true;
            }
            if(C <= 0) {
                System.out.println("Yes");
                break;
            }
            if(A <= 0) {
                System.out.println("No");
                break;
            }
        }


    }
}

Measured memory_bytes: 35748
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    long long q = abs(a-b); n--;
    for (long long i = 0; i <= n; i++) {
        long long u = c * (n-i);
        long long v = d * (n-i);
        long long x = -c * i;
        long long y = -d * i;
        if (u+y <= q && q <= v+x) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int pa = Integer.MAX_VALUE;
        int pz = -1;
        for(int i=0;i<s.length();i++){
            if(s.charAt(i)=='A') pa = Math.min(pa,i);
            if(s.charAt(i)=='Z') pz = Math.max(pz,i);
        }
        System.out.println(pz-pa+1);
    }
}


Measured memory_bytes: 28464
#include <iostream>
#include <iostream>

int main() {
  std::string s;
  std::cin >> s;
  while(s.size() >= 5) {
    if (s.size() >= 7 && s.substr(s.size() - 7, s.size()) == "dreamer") {
      s = s.substr(0, s.size() - 7);
    } else if (s.size() >= 5 && s.substr(s.size() - 5, s.size()) == "erase") {
      s = s.substr(0, s.size() - 5);
    } else if (s.size() >= 6 && s.substr(s.size() - 6, s.size()) == "eraser") {
      s = s.substr(0, s.size() - 6);
    } else if (s.size() >= 5 && s.substr(s.size() - 5, s.size()) == "dream") {
      s = s.substr(0, s.size() - 5);
    } else {
      break;
    }
  }
  if (s.size() == 0) {
    std::cout << "YES" << std::endl;
  } else {
    std::cout << "NO" << std::endl;
  }
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <map>
using namespace std;


int main() {
    long long n;
    cin>>n;
    string s;
    cin>>s;
    map<char, long long> cnt;
    for(char c:s) {
        cnt[c] += 1;
    }
    long long ans = cnt['R'] * cnt['G'] * cnt['B'];
    for(long long i=0; i<n; ++i) {
        for(long long j=i+1; 2*j-i<n; j++) {
            long long k = j + (j-i);
            if(s[i] != s[j] && s[j] != s[k] && s[k] != s[i]) --ans;
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define hell 1000000007
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define ll long long int
#define pi 3.1415926536
using namespace std;

/*ll merge(vector<ll> &v,ll l,ll m,ll r)
{
	ll n1=m-l+1;
	ll n2=r-m;
	ll inv=0;
	vector<ll> a(n1),b(n2);
	for(ll i=0;i<n1;i++)
	a[i]=v[l+i];
	for(ll i=0;i<n2;i++)
	b[i]=v[m+1+i];
	ll i=0,j=0,k=l;
	while(i<n1&&j<n2)
	{
		if(a[i]<=b[j])
		{
			v[k]=a[i];
			i++;
		}
		else
		{   inv+=(m-i+1);
			v[k]=b[j];
			j++;
		}
		k++;
	}
	while(i<n1)
	{
		v[k]=a[i];
		i++;
		k++;
	}
	while(j<n2)
	{
		v[k]=b[j];
		j++;
		k++;
	}
	return inv;
}
ll mergesort(vector<ll> &v,ll l,ll r)
{  ll inv=0;
	if(l<r)
	{
		ll m=l+(r-l)/2;
		inv=mergesort(v,l,m);
		inv+=mergesort(v,m+1,r);
		inv+=merge(v,l,m,r);
	}
	return inv;
}*/
void solve()
{ll t,n,k,x,y,ans,z,d=0,p,q,l=INT_MIN,mini=0,prev;
  cin>>n; string s;
  map<string,ll> m;
  ll a[26];
  for(ll i=0;i<n;i++)
  {  //memset(a,0,sizeof(a));
  	cin>>s;
  	sort(s.begin(),s.end());
  	m[s]++;
  }
  ans=0;
  for(auto i:m)
  {
  	x=i.second;
  	ans+=((x*(x-1))/2);
  }
  cout<<ans;
}

int main()
{
  fast
ll t=1;

while(t--)
{solve();
 //cout<<ma<<endl;
}
return 0;}

Measured memory_bytes: 11264
#include <iostream>
#include <string>

int main() {
    int n;
    std::string s;
    std::cin >> n;
    std::cin >> s;
    for (int i = 0; i < s.size(); i++) {
        s[i] = s[i] + n;
        if (s[i] > 'Z') {
            s[i] = 'A' + s[i] - 'Z' - 1;
        }
    }
    
    std::cout << s << std::endl;
}


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

int main() {
  // 入力
  int n, m;
  cin >> n >> m;
  vector<int> P(m), Y(m);
  rep(i, m) cin >> P[i] >> Y[i], --P[i];

  // vals[v] := P[i] = v であるような i についての Y[i] の値を集めたもの
  vector<vector<int> > vals(n);
  rep(i, m) vals[P[i]].push_back(Y[i]);

  // 各 p の値に対して
  rep(v, n) {
    sort(vals[v].begin(), vals[v].end());

    // 今回は不要だが、通常は数のダブりをなくす
    vals[v].erase(unique(vals[v].begin(), vals[v].end()), vals[v].end());
  }

  // 答え
  rep(i, m) {
    int v = P[i];
    printf("%06d", v + 1);

    // 座標圧縮して導いた答え
    int id =
        lower_bound(vals[v].begin(), vals[v].end(), Y[i]) - vals[v].begin();
    printf("%06d\n", id + 1);
  }
}

Measured memory_bytes: 9432
nums_str = input()
nums_str_arr = nums_str.split(' ')
a = int(nums_str_arr[0])
b = int(nums_str_arr[1])

sum_score = 0

for i in range(2):
    if a > b:
        sum_score += a
        a -= 1
    else :
        sum_score += b
        b -= 1

print(sum_score)

Measured memory_bytes: 3060
import itertools

n=int(input())
p=tuple(int(x) for x in input().split())
q=tuple(int(x) for x in input().split())
all=list(itertools.permutations(range(1,n+1)))
for idx,item in enumerate(all):
  if item==p:
    cp=idx
  if item==q:
    cq=idx
print(abs(cp-cq))

Measured memory_bytes: 8052
N,C = map(int,input().split())
D = []
for i in range(C):
    D.append(list(map(int,input().split())))
c = []
for i in range(N):
    c.append(list(map(int,input().split())))

import itertools
current_minimum = 1000 * 500 * 500 + 1
Z = []
Z.append([0]*C)
Z.append([0]*C)
Z.append([0]*C)
#print(Z)

for (i,j) in itertools.product(range(N),range(N)):
	cur_mod = ((i+1)+(j+1)) % 3
	cur_color = c[i][j]
	#print(cur_mod)
	#print(cur_color)
	Z[cur_mod][cur_color-1] += 1

current_minimum = 1000 * 500 * 500 + 1
for (c0,c1,c2) in itertools.permutations(range(C), 3):
	tmp = 0
	color = [c0,c1,c2]
	for cur_mod in range(3):
		target_color = color[cur_mod]
		for cur_color in range(C):
			tmp += Z[cur_mod][cur_color] * D[cur_color][target_color]
	if current_minimum >= tmp:
		current_minimum = tmp
print(current_minimum)


Measured memory_bytes: 5620
#include<iostream>
#include<cmath>
#include<cstdio>
#include<string>
#include<algorithm>


using namespace std;

int GCD(int a, int b);

int main()
{
  int a,b;
  while(cin >> a >> b)
  {
    if(a>b)
        swap(a,b);
    int x = GCD(a, b);
    cout << x << " " << (a/x)*b << endl;
  }
   return 0;
}

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

Measured memory_bytes: 3000
#include <stdio.h>

int change(char MARK){
    if (MARK=='S') return 0;
    else if (MARK=='H') return 1;
    else if (MARK=='C') return 2;
    else if (MARK=='D') return 3;
    else return 4;
}

char re_change(int NUM){
    if (NUM==0) return 'S';
    else if (NUM==1) return 'H';
    else if (NUM==2) return 'C';
    else if (NUM==3) return 'D';
    else return EOF;
}

int main(void){
    int i, j, k, n, suit;
    char mark;
    int CARD[4][13]={};
    
    scanf("%d\n", &n);
    
    for(i=0; i<n; i++){
        scanf("%c %d\n", &mark, &suit);
        CARD[change(mark)][suit-1]=1;
    }
    
    for(j=0; j<4; j++){
        for(k=0; k<13; k++){
            if(CARD[j][k]!=1){
                printf("%c %d\n", re_change(j), k+1);
            }
        }
    }
    return 0;
}


Measured memory_bytes: 2100
n = int(input())
li = list(map(int,input().split()))
count = 0
for i in range(n):
    for ii in range(n-i):
        if li[i] != li[i+ii]:
            for iii in range (n-i-ii):
                if li[i] != li[i+ii+iii] and li[i+ii]!=li[i+ii+iii]:
                    tri = []
                    tri.append(li[i])
                    tri.append(li[i+ii])
                    tri.append(li[i+ii+iii])
                    if max(tri)<(sum(tri)-max(tri)):
                        count +=1
print(count)


Measured memory_bytes: 68676
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	ll n, a, b;
	cin >> n >> a >> b;
	if(a == b){
		cout << 2 << endl;
		return 0;
	}
	else{
		if(abs(a - b) % 2 == 0){
			cout << abs(a - b) / 2 << endl;
		}
		else{
			//like 2 and 3, they go to 1 or n, whichever is closer
			if(a > b) swap(a, b); //a is less
			cout << min((a - 1 + ((abs(a - b) + 1) / 2)), (n - b + ((abs(a - b) + 1) / 2))) << endl;
		}
	}
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
#include<iostream>
#include<functional>
#include<utility>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<list>
using namespace std;
constexpr auto MOD = 1000000007;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
#define rep(i,n) for(int i = 0; i < (n);i++)
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VLL;

class SegmentTree {
private:
   ll n;
   vector<ll> node;

public:
   // 元配列 v をセグメント木で表現する
   SegmentTree(vector<ll> v) {
	  // 最下段のノード数は元配列のサイズ以上になる最小の 2 冪 -> これを n とおく
	  // セグメント木全体で必要なノード数は 2n-1 個である
	  ll sz = v.size();
	  n = 1; while (n < sz) n *= 2;
	  node.resize(2 * n - 1, 0);

	  // 最下段に値を入れたあとに、下の段から順番に値を入れる
	  // 値を入れるには、自分の子の 2 値を参照すれば良い
	  for (int i = 0; i < sz; i++) node[i + n - 1] = v[i];
	  for (int i = n - 2; i >= 0; i--) node[i] = max(node[2 * i + 1], node[2 * i + 2]);
   }
   void update(ll x, ll val) {
	  // 最下段のノードにアクセスする
	  x += (n - 1);

	  // 最下段のノードを更新したら、あとは親に上って更新していく
	  node[x] = val;
	  while (x > 0) {
		 x = (x - 1) / 2;
		 node[x] = max(node[2 * x + 1], node[2 * x + 2]);
	  }
   }
   // 要求区間 [a, b) 中の要素の最小値を答える
// k := 自分がいるノードのインデックス
// 対象区間は [l, r) にあたる

   ll getmin(ll a, ll b, ll k = 0, ll l = 0, ll r = -1) {
	  // 最初に呼び出されたときの対象区間は [0, n)
	  if (r < 0) r = n;

	  // 要求区間と対象区間が交わらない -> 適当に返す
	  if (r <= a || b <= l) return 0;

	  // 要求区間が対象区間を完全に被覆 -> 対象区間を答えの計算に使う
	  if (a <= l && r <= b) return node[k];

	  // 要求区間が対象区間の一部を被覆 -> 子について探索を行う
	  // 左側の子を vl ・ 右側の子を vr としている
	  // 新しい対象区間は、現在の対象区間を半分に割ったもの
	  ll vl = getmin(a, b, 2 * k + 1, l, (l + r) / 2);
	  ll vr = getmin(a, b, 2 * k + 2, (l + r) / 2, r);
	  return max(vl, vr);
   }
};



int main() {
   int n;
   cin >> n;
   VLL h(n);
   VLL a(n);
   ll t;
   rep(i, n) {
	  cin >> t;h[t-1]=i;
   }
   rep(i, n)cin >> a[i];
   SegmentTree seg(VLL (n,0));
   for (int i = 0; i < n; i++)
   {
	  seg.update(h[i],seg.getmin(0,h[i])+a[h[i]]);
   }
   cout << seg.getmin(0, n)<<endl;
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;

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

	long long res = 1;
	int r = 0, b = 0, g = 0;
	for (int i = 0; i < n; i++)
	{
		int c = (r == a[i]) + (b == a[i]) + (g == a[i]);
		res = res * c % MOD;
		if(r == a[i]) r++;
		else if(b == a[i]) b++;
		else g++;
	}
	cout << res << endl;
	return 0;
}



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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define cinv(n,vec) VL (vec)(n);for(auto&v:vec)cin>>v;
#define int long long
#define itn int
#define pb push_back
#define m_p make_pair
#define m_t make_tuple
#define eb emplace_back
#define p_p(a,b) pb(m_p(a,b))
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a),greater<>())
#define UNIQUE(a) a.erase(unique(all(a)),a.end())
#define SZ(a) (ll)(a.size())
#define ENDL cout<<endl
#define debg(a) cout<<#a<<" "<<a<<endl;
#define debgp(a) cout<<#a<<" "<<a.fi<<" : "<<a.se<<endl
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define out(a) cout<<(a)<<endl
#define cont const auto
#define fi first
#define se second
#define V vector
#define P pair
#define T tuple
#define VV(type,name,y,x,a) vector<vector<type>> name = vector<vector<type>>(y,vector<type>(x,a))
#define PQ priority_queue
typedef long long ll;
typedef double D;
typedef long double LD;
typedef string str;
typedef vector<ll> VL;
typedef pair<ll,ll> PL;
typedef vector<pair<ll,ll>> VP;
typedef tuple<ll,ll,ll> T3;
typedef tuple<ll,ll,ll,ll> T4;
const long long INF = 1LL<<60;
const long long MOD = 1e9+7;
void Yes(){cout<<"Yes"<<endl;}
void No(){cout<<"No"<<endl;}
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n,m;
  cin>>n>>m;
  VL a(m);
  rep(i,m)cin>>a[i];

  SORT(a);
  bool cant=false;
  rep(i,m-1)if(a[i]+1==a[i+1])cant=true;
  if(cant){
    cout<<0<<endl;
    return 0;
  }
  set<ll> st;
  rep(i,m)st.insert(a[i]);

  ll x=1,y=0;
  VL ans(n+3,0);
  reps(i,n){
    if(st.find(i)==st.end()){
      ans[i]=x+y;
      y=x;
      x=ans[i];
      ans[i]%=MOD;
      x%=MOD;
      y%=MOD;
    }
    else{
      //if(st.find(i+1)==st.end()){
        if(st.find(i+2)==st.end()){
          ans[i+1]=x;
          ans[i+2]=x;
          i+=2;
          y=x;
          ans[i+1]%=MOD;
          ans[i+2]%=MOD;
          x%=MOD;
          y%=MOD;
        }
        else{
          ans[i+1]=x;
          ans[i+3]=x;
          i+=3;
          y=0;
        }
      //}
      
      
    }
  }
  out(ans[n]);
  //call(ans);
  
  
  
  return 0;
}



Measured memory_bytes: 3840
x,y = map(int, input().split()) 
ans = 0

if x == 1 and y == 1:
  print(10**6)
else:

  x = 0 if x >= 4 else 4 - x
  y = 0 if y >= 4 else 4 - y
  print(x*10**5 + y*10**5)
  



Measured memory_bytes: 2940
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end

# 入力値を文字の配列で返却する
def gets_nsp_list()
  gets.chomp.split("")
end

A, B = gets_i_list
codes = gets_nsp_list
numbers = ("0".."9").to_a

A.times do
  c = codes.shift
  unless numbers.include?(c)
    puts "No"
    exit
  end
end

c = codes.shift
if c != "-"
  puts "No"
  exit
end

B.times do
  c = codes.shift
  unless numbers.include?(c)
    puts "No"
    exit
  end
end

if codes.empty?
  puts "Yes"
else
  puts "No"
end

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

long long n;
int a[200010];

int main()
{
    cin>>n;
    for(long long i=1;i<=n;i++) scanf("%d",&a[i]);
    long long l=1,r=1,sum=0,num=0,Xor=0,ans=0;
    while(l<=n){
        while(sum==Xor&&r<=n){
            sum+=a[r];
			Xor^=a[r];
			r++;
			num++;
        }
        if(sum==Xor) ans+=num--;
        else ans+=--num;
        r--;
        sum-=a[r];
        Xor^=a[r];
        l++;
        sum-=a[l-1];
        Xor^=a[l-1];
		num--;
    }
	cout<<ans<<endl;
	return 0;
}

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

int solve(string str,int l,int h)
{
    while (h > l)
    {
        if (str[l++] != str[h--])
        {
            return 0;
        }
    }
    return 1;
}

int main()
{

    string s;
    int n;
    cin>>s;
    n=s.length();
    if(solve(s,0,n-1)&&solve(s,0,((n-1)/2)-1)&&solve(s,((n+3)/2)-1,n-1))
    {
        cout<<"Yes"<<endl;
    }
    else
        cout<<"No"<<endl;



    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=998244353;


int main(){
  ll N,A[100000];
  cin>>N;
  for (int i(0);i<N;i++) cin>>A[i];
  sort(A,A+N);
  if (N%2==0){
    ll tmp(0ll);
    tmp+=A[N/2];
    tmp-=A[N/2-1];
    for (int i(0);i<N/2-1;i++){
      tmp-=2*A[i];
    }
    for (int i(N/2+1);i<N;i++){
      tmp+=2*A[i];
    }
    cout << tmp << endl;
  }else{
    ll tmp(0ll);
    for (int i(N/2+1);i<N;i++){
      tmp+=2*A[i];
    }
    tmp-=(A[N/2]+A[N/2-1]);
    for (int i(0);i<N/2-1;i++){
      tmp-=2*A[i];
    }

    ll tmp2(0ll);
    for (int i(0);i<N/2;i++){
      tmp2-=2*A[i];
    }
    tmp2+=(A[N/2]+A[N/2+1]);
    for (int i(N/2+2);i<N;i++){
      tmp2+=A[i]*2;
    }
    cout << max(tmp,tmp2) << endl;
  }
  return 0;
}


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

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

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

int main() {
    int n;
    cin>>n;
    int arr[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>arr[i];
    }
    int dp[n+1];
    dp[1]=0;
    dp[2]=abs(arr[1]-arr[2]);
    for(int i=3;i<=n;i++)
    {
        dp[i]=min(dp[i-1]+abs(arr[i-1]-arr[i]),dp[i-2]+abs(arr[i-2]-arr[i]));
    }
    cout<<dp[n]<<endl;
    return 0;
}


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

int main() {
    int h,w;
    while(true){
        cin >> h >> w;
        if(h==0&&w==0){
            return 0;
        }
        for (int i = 0; i < h;i++){
            for (int j = 0; j < w;j++){
                if(i==0 || i==h-1 || j==0 || j==w-1){
                    cout << "#";
                }else{
                    cout << ".";
                }
            }
            cout << endl;
        }
            cout << endl;
    }
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

const int iinf = 1 << 29;
const ll linf = 1l << 61;

int K;
int d[100000]; //dp[i] : K で割った余りが i になる数の桁の総和の最小値
// (nk + i) * 10 = i * 10 (mod K)
// (nk + i) + 1 = i + 1 (mod K)
// dp[(i * 10) % K] = dp[i];
// dp[(i + 1) % K] = 1 + dp[i];
// nord : i -> (i * 10) % K : 0
//      : i -> (i + 1) % K : 1

int main(int argc, char* argv[])
{
	scanf("%d", &K);
	fill(d, d + K, iinf);
	typedef pair<int, int> P;
	deque<P> q;
	q.emplace_back(1, 1);
	d[1] = 1;
	while(!q.empty())
	{
		int v = q.front().second;
		int c = q.front().first;
		q.pop_front();
		if(d[v] < c) continue;
		int ten = (v * 10) % K;
		if(d[ten] > c)
		{
			d[ten] = c;
			q.emplace_front(c, ten);
		}
		int inc = (v + 1) % K;
		if(d[inc] > c + 1)
		{
			d[inc] = c + 1;
			q.emplace_back(c + 1, inc);
		}
	}
	printf("%d\n", d[0]);

	return 0;
}


Measured memory_bytes: 1024
#define KAKUSUKO
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 12, MAX_M = 1000;
int N, M;
int a[MAX_M+1], b[MAX_M+1];
int bit[MAX_M+1];

int dp[1 << 12];

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

  cin >> N >> M;
  rep(i, 1, M) {
    cin >> a[i] >> b[i];
    rep(j, b[i]) {
      int t;
      cin >> t;
      bit[i] += 1 << (t-1);
    }
  }

  for (int j = 0; j < (1<<N); ++j) dp[j] = INFINT;

  dp[0] = 0;
  for (int i = 1; i <= M; ++i) {
    for (int j = 0; j < (1<<N); ++j) {
      int newBit = bit[i] | j;
      int cost = a[i] + dp[j];
      if (dp[newBit] > cost) {
        dp[newBit] = cost;
      }
    }
  }

  if (dp[(1<<N)-1] == INFINT) {
     cout << -1 << endl;
  } else {
    cout << dp[(1<<N)-1] << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
s = input()
n = len(s)
x = s[:n // 2]
y = s[(n + 2) // 2:]
ans = True
for i in range(len(s) // 2):
    if s[i] != s[~i]:
        ans = False
for i in range(len(x) // 2):
    if x[i] != x[~i]:
        ans = False
for i in range(len(y) // 2):
    if y[i] != y[~i]:
        ans = False
print(["No", "Yes"][ans])


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) cout << "Possible";
  else cout << "Impossible";
  cout << '\n';
  return 0;
}

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

int main() {
  
  int N;
  cin >> N;
  int count = 0;
  
  for (int i = 0; i < N; i++) {
    int l, r;
    cin >> l >> r;
    count += r - l + 1;
  }
  
  cout << count << endl;

}


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

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

	if (a == b && b == c)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

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

using namespace std;

const long long MOD = (long long)1e9 + 7;

long long mod_pow(long long x_, long long y_){
	if(y_ == 0) return 1;
	if(y_ % 2 == 0) return mod_pow(x_ * x_ % MOD, y_ / 2);
	else return x_ * mod_pow(x_ * x_ % MOD, y_ / 2) % MOD;
}

int main(){
	long long n, ans = 0;
	cin >> n;
	vector<long long> a(n);
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	vector<long long> p(n);
	p[0] = 1;
	for(int i = 1; i < n; i++){
		p[i] = (p[i - 1] + 1 * mod_pow(i + 1, MOD - 2)) % MOD;
	}
	long long kai = 1;
	for(int i = 2; i <= n; i++){
		kai = (kai * i) % MOD;
	}
	for(int i = 0; i < n; i++){
		ans += (a[i] * (p[i] + p[n - i - 1] - p[0])) % MOD;
		ans %= MOD;
	}
	ans = (ans * kai) % MOD;
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
int mod = 1000000000+7;

int main(){

	int n,m;
	cin>>n>>m;
	int a[n];
	double sum=0;
	rep(i,n){
		cin>>a[i];
		sum+=a[i];
	}
	sum=sum/(4*m);
	rep(i,n){
		if(a[i]>=sum)m--;
	}

	if(m<=0)cout<<"Yes";
	else cout<<"No";
	cout<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int a,b,c,k;
  int sum;

  cin >>a>>b>>c>>k;

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

  sum=a+b+c;

  cout << sum << endl;
  
  return 0;
}



Measured memory_bytes: 256