akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

void update(char c, int& x, int& y, int& z){
  switch(c){
  case '(':
    x++;
    break;
  case ')':
    x--;
    break;
  case '{':
    y++;
    break;
  case '}':
    y--;
    break;
  case '[':
    z++;
    break;
  case ']':
    z--;
  }
}

bool collect(vector<string>& s, int p, int q, int r){
  int isp = 0, isq = 0, isr = 0, cnt = 0;
  for (int i = 0; i < s.size(); i++) {
    cnt = 0;
    bool flag = true;
    for (int j = 0; j < s[i].length(); j++) {
      if(s[i][j] == '.' && flag){
        cnt++;
        continue;
      }
      //std::cout << cnt << std::endl;
      if(flag && cnt != p*isp + q*isq + r*isr)return false;
      flag = false;
      //std::cout << s[i][j];
      update(s[i][j], isp, isq, isr);
    }
    //std::cout << std::endl;
    //std::cout << "isp:" << isp << " isq:" << isq << " isr:" << isr << std::endl;
  }

  return true;
}

int main(int argc, char *argv[]){
  int n, m;
  while(cin >> n >> m, n){
    vector<string> vn(n), vm(m);
    for (int i = 0; i < n; i++) {
      cin >> vn[i];
    }
    for (int i = 0; i < m; i++) {
      cin >> vm[i];
    }
    set<int> ans[m];
    for (int p = 1; p < 21; p++) {
      for (int q = 1; q < 21; q++) {
        for (int r = 1; r < 21; r++) {
          if(!collect(vn, p, q, r))continue;
          int isp = 0, isq = 0, isr = 0;
          for (int i = 0; i < m; i++) {
            //std::cout << isp*p + isq*q + isr*r << " ";
            ans[i].insert(isp*p + isq*q + isr*r);
            for (int j = 0; j < vm[i].length(); j++) {
              update(vm[i][j], isp, isq, isr);
            }
          }
          //std::cout << std::endl;
        }
      }
    }
    for (int i = 0; i < m - 1; i++) {
      if(ans[i].size() != 1)std::cout << -1 << " ";
      else std::cout << *ans[i].begin() << " ";
    }
    if(ans[m - 1].size() != 1)std::cout << -1;
    else std::cout << *ans[m - 1].begin();
    std::cout << std::endl;

  }
  return 0;
}

Measured memory_bytes: 1232
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define min(a,b) (a<b?a:b)
typedef struct b{int C,G;}b;
int N,K,i,j,dp[12][2014]={0},JB[14][2014]={0},s[14]={0};
b B[2014];
int c(const void *p,const void *q)
{
	b x=*(b*)p,y=*(b*)q;
	return x.G==y.G?y.C-x.C:x.G-y.G;
}
int dfs(int j,int t)
{
	if(dp[j][t]>0)
		return dp[j][t];
	if(t==0||j==11)
		return 0;
	int gs=0,ns,ts,i;
	for(i=0;i<=min(t,s[j]);i++)
	{
		ts=dfs(j+1,t-i)+JB[j][i];
		gs=gs<ts?ts:gs;
	}
	return dp[j][t]=gs;
}
 
int main()
{
	scanf("%d%d",&N,&K);
	for(i=0;i<N;i++)scanf("%d%d",&B[i].C,&B[i].G);
	qsort(B,N,sizeof(b),c);
	for(i=0;i<N;i++)
	{
		JB[B[i].G][s[B[i].G]+1]=JB[B[i].G][s[B[i].G]]+B[i].C+s[B[i].G]*2;
		s[B[i].G]++;
	}

	printf("%d\n",dfs(0,K));
	return 0;
}

Measured memory_bytes: 792
#include <iostream>
#include <string>
#include <cctype>

int main ()
{
  std::string str;

  getline(std::cin, str);
  // std::cout << str << std::endl;
  for (auto &c : str)
    {
      if (std::isupper(c))
        c = std::tolower(c);
      else if (std::islower(c))
        c = std::toupper(c);
    }

  std::cout << str << std::endl;

}




Measured memory_bytes: 3168
#include <iostream>

 

using namespace std;

 

int main()
{
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    
    if(x-r >= 0 && y-r >= 0 && y+r <= h && x+r <= w)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 3116
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, k, L[100009], R[100009], x, curR, curL;
stack<int> stk;
bool flag = false;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> x;
		if (x == 0) {
			flag = true;
			continue;
		}
		if (x < 0) stk.push(-x);
		else {
			R[curR] = x;
			curR++;
		}
	}
	if (flag) k--;
	while (!stk.empty()) { L[curL] = stk.top(); stk.pop(); curL++; }
	int ans = 1e9;
	for (int i = k - 1; i >= 0; i--) {
		if (i >= curL) continue;
		int j = k - i - 2;
		if (j >= curR) continue;
		ans = min(ans, L[i] + R[j] + min(L[i], R[j]));
	}
	if (curL >= k)
		ans = min(ans, L[k - 1]);
	if (curR >= k)
		ans = min(ans, R[k - 1]);
	cout << ans << E;
	//system("pause");
	return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-6;

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;}

const int64 mod = 1e9+7;

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

int main(void){
	int32 w, h;
	while(cin >> w >> h && w+h){
		vector<vector<int64>> f(h, vector<int64>(w));
		auto in = [&](int32 y, int32 x){ return 0<=y&&y<h&&0<=x&&x<w;};
		REP(i, h) REP(j, w) cin >> f[i][j];
		int32 py, px;
		REP(i, h) REP(j, w) if(f[i][j] == 2){ py = i; px = j; }
		int32 res = INF;
		function<void(int32, int32, int32, int32)> dfs = [&](int32 y, int32 x, int32 cnt, int32 fr){
			if(cnt == 10) return;
			REP(i, 4){
				//if(i == 3-fr) continue;
				int32 yy = y+dy[i], xx = x+dx[i];
				if(!in(yy, xx) || f[yy][xx] == 1) continue;
				while(in(yy, xx) && f[yy][xx] != 1){
					if(f[yy][xx] == 3){ res = min(res, cnt+1); return;}
					yy += dy[i]; xx += dx[i];
				}
				if(!in(yy, xx)) continue;
				f[yy][xx] = 0;
				dfs(yy-dy[i], xx-dx[i], cnt+1, i);
				f[yy][xx] = 1;
			}
		};
		dfs(py, px, 0, -1);
		cout << (res == INF ? -1 : res) << endl;
	}
}


Measured memory_bytes: 3116
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <functional>
#include <string>
#include <cmath>  //sqrt 
#include <iomanip> //setprecision
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define ALL(a)  (a).begin(),(a).end()

void _main(){
    int x,n; cin>>x>>n;
    vector<int> p(n); rep(i,n) cin >> p[i];
    int out;
    int mi = x;
    int pl = x;
    while(1){
        if(find(ALL(p),mi)==p.end()) {out = mi;break;}
        if(find(ALL(p),pl)==p.end()) {out = pl;break;}
        mi--;pl++;
    }
    cout << out << endl;
    return;
}
int main() {
    cout << fixed << setprecision(10);
    _main();
    return 0;
}
    

Measured memory_bytes: 3196
//
//AtCoder Beginner Contest 138
//C - Alchemist
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;

const double PI = 3.14159265358979323846;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

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

    vector<double> v(n);
    REP(i, n) cin >> v[i];
    
    sort(ALL(v));
    double ans = (v[0]+v[1])/2;
    FOR(i, 2, n-1){
        ans = (ans + v[i])/2;
    }
    cout << fixed;
    cout << setprecision(12) << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

typedef long long ll;

using namespace std;
//using namespace boost::multiprec

int main(){

    int n,m;
    cin >> n >> m;

    priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> pqd;
    priority_queue<pair<int,int>> pqv;

    rep(i,n){
        int a,b;
        cin >> a >> b;

        pqd.push(mpair(a, b));
    }

    int ans = 0;

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

        while(!pqd.empty()){
            if(pqd.top().first == i){
                pqv.push(mpair(pqd.top().second, pqd.top().first));
                pqd.pop();
            }else{
                break;
            }
        }

        if(!pqv.empty()){
            ans += pqv.top().first;
            pqv.pop();
        }

    }

    cout << ans << endl;


    
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  for (auto& e : a) cin >> e;

  vector<ll> x(n);
  ll l = 0, r = 1e9 + 1, m;
  while (true) {
    m = (l + r) / 2;
    x[0] = 2 * m;
    for (int i = 0; i + 1 < n; i++) {
      x[i + 1] = 2 * (a[i] - x[i] / 2);
    }
    if (x[0] / 2 + x[n - 1] / 2 < a[n - 1]) {
      l = m + 1;
    } else if (x[0] / 2 + x[n - 1] / 2 > a[n - 1]) {
      r = m;
    } else {
      break;
    }
  }

  for (auto e : x) cout << e << ' ';
  cout << endl;
}


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

int main() 
{
  int n;
  cin>>n;
  double a[n];
  double mul=1;
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    mul*=a[i];
  }
  double sum=0;
  for(int i=0;i<n;i++)
  {
    sum+=mul/a[i];
  }
  double answer=mul/sum;
  cout<<answer;
  return 0;
}
  

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <functional>
#include <queue>
#include <vector>
typedef long long lld;
typedef std::priority_queue<int> max_heap;
typedef std::priority_queue<int, std::vector<int>, std::greater<int>> min_heap;
max_heap mxh;
min_heap mnh;
int a, b, Q;
lld A, B;

// mxh: [3, 2, 1]
// mnh: [5, 8, D]


// [1, 2]  [3, 5, 6, 7, 8, D]

void update() {
    B += b;
    if (mxh.empty()) {
        mxh.push(a);
    } else if (mnh.empty() || (a <= mxh.top())) {
        A += std::abs(mxh.top() - a);
        mxh.push(a);
    } else {
        A += a - mxh.top();
        mnh.push(a);
    }
    while (mxh.size() >= (mnh.size() + 2u)) {
        mnh.push(mxh.top());
        mxh.pop();
        A -= 1LL * (mnh.top() - mxh.top()) * (mxh.size() - mnh.size());
    }
    while (mnh.size() > mxh.size()) {
        A -= 1LL * (mnh.top() - mxh.top()) * (mnh.size() - mxh.size());
        mxh.push(mnh.top());
        mnh.pop();
    }
}

int query() { return mxh.top(); }

int main() {
    scanf("%d", &Q);
    A = B = 0LL;
    for (int q = 1; q <= Q; ++q) {
        char cmd;
        scanf(" %c", &cmd);
        switch (cmd) {
        case '1':
            scanf(" %d%d", &a, &b);
            update();
            break;
        case '2':
            printf("%d %lld\n", query(), A + B);
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3452
#include<stdio.h>
#include<stdbool.h>


int maximum (int list[], int size){
    int loc_max = 0;
    for (int i = 0; i < size; ++i){
        if(list[i]>loc_max){
            loc_max = list[i];
        }
    }
    return loc_max;
}


bool isInBoth(int cut, int ceil, char letter, char list[]){

    bool foundL = false;
    bool foundR = false;

    for (int i = 0; i < cut; ++i){
        if (letter == list[i]) {
            foundL = true;
            break;
        }
    }
    for (int i = cut; i < ceil; ++i){
        if (letter == list[i]) {
            foundR = true;
            break;
        }
    }
    return foundL && foundR;
}


int main(void){

    int n; char s[100];

    scanf("%d", &n);
    scanf("%s", s);


    int i, j; int count[100];

    // Cut
    for (i = 0; i < n; ++i){
        // Count
        count[i] = 0;
        for (j='a';  j<='z'; ++j){
            if (isInBoth(i,n,j,s)) {count[i]++;}
        }
    }

    printf("%d\n", maximum(count,n));
    
}




Measured memory_bytes: 128
#include <stdio.h>

int linearSearch(int *, int, int);

int main(){
  int n, q, s[10000], t, a, count=0;
  
  scanf("%d",&n);
  for(a = 0; a < n; a++){
    scanf("%d",&s[a]);
  }
  scanf("%d",&q);
  for(a = 0; a < q; a++){
    scanf("%d",&t);
    if(linearSearch(s,n,t) != -1)count++;
  }

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

  return 0;

}

int linearSearch(int *p, int n, int key){
  int a=0;
  *(p+n) = key;
  while(*(p+a) != key){
    a++;
    if(a == n) return -1;
  }
  return a;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define ppb pop_back()
#define pf push_front
#define ppf pop_front()
#define fi first
#define se second
#define pi pair<int, int>
#define ppi pair<pi, pi>
#define rep(i, a, n) for(int i = a; i <= n; i++)
#define REP(i, a, n) for(int i = a; i < n; i++)
#define per(i, a, n) for(int i = a; i >= n; i--)
#define PER(i, a, n) for(int i = a; i > n; i--)
#define pqi priority_queue<int>
#define Y "Yes"
#define N "No"
#define PI 3.141592653589793238462643383279502884197
using namespace std;

int h1, m1, h2, m2, k;
 
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	cout << (h2 - h1) * 60 + m2 - m1 - k;	
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
int main () {
  
  ll N ;
  cin >> N ;
  ll a[N] ;
  for(int i =0 ; i < N ;i++)
    cin >> a[i] ;
  
  bool flag = true ;
  for(int i = N - 2; i >=0 ;i--){
    if(a[i] - a[i + 1] == 1) {
      a[i] = a[i + 1] ;
      continue ;
    }
    if(a[i] - a[i + 1] >= 2) {
     flag = false ;
    }
  }
  if(flag) cout<<"Yes\n" ;
  else cout<<"No\n" ;
  
  return 0 ;
}

Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Scanner;
 class Main {
		public static void main(String[]args) {
			Scanner scan = new Scanner(System.in);
			int n = scan.nextInt();			
			HashMap<String,Integer> hmap = new HashMap<>();
			
			for(int i = 0 ; i< n ; i++) {
				char[] c = scan.next().toCharArray();
				Arrays.sort(c);
				String s = String.valueOf(c);
				 
				if(hmap.containsKey(s)) {
					hmap.put(s, hmap.get(s)+1);
				}else {
					hmap.put(s,1);
				}
			}
			long count = 0 ;
			for(int a : hmap.values()) {
				count += (long)a*(a-1)/2 ;
			}
			System.out.println(count) ;
		}
}

Measured memory_bytes: 53536
def insertionsort(A):
    for i in range(1,len(A)):
        v = A[i]
        j = i-1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j -= 1
            A[j+1] = v
        print(*A,sep=" ")
    return A

N = int(input())
A = [int(i) for i in input().split()]
print(*A,sep=" ")
insertionsort(A)


Measured memory_bytes: 5984
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

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

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

fn main() {
    input! {
        s: chars,
    }
    let mut c = 0i64;
    for a in s{
        if a == '1'{
            c += 1
        }
    }
    println!("{}", c)
}


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

using namespace std;
using lli = int_fast64_t;
using ulli = unsigned long long;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = copy(x);cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl

constexpr lli MOD = (lli)1e9 + 7;
constexpr lli LIMIT = 1000000000000000000 * 5;


int main() {
	int N,K;
	cin >> N >> K;
	set<int> se;
	for (int i = 0; i < K; i++) {
		int d;
		cin >> d;
		for (int j = 0; j < d; j++) {
			int a;
			cin >> a;
			se.insert(a);
		}
	}
	cout << N - se.size() << endl;

	return 0;
}



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

int intring(int a, int b) {
    string AB = to_string(a) + to_string(b);
    int ab = stoi(AB);
    return ab;
}

int main() {
    int a, b;
    cin >> a >> b;
    int ab = intring(a, b);

    bool ans = false;
    for (int i = 1; i <= 1000; i++) {
        if (pow(i, 2) == ab) {
            ans = true;
        }
    }
    cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3636
using System;
using System.Linq;

namespace CSharp
{
    class Program
    {
        static void Main()
        {
            var input = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var N = input[0];
            var M = input[1];

            var A = Console.ReadLine().Split().Select(long.Parse).ToArray();
            Array.Sort(A);
            Array.Reverse(A);
            var sum = A.Sum();

            for (var i = 0; i < M; i++)
            {
                if (A[i] * 4 * M < sum)
                {
                    Console.WriteLine("No");
                    return;
                }
            }
            Console.WriteLine("Yes");
        }
    }
}


Measured memory_bytes: 13396
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<cmath>
#include<map> 
#include<string>
#include<queue>
#include<stack> 
#include<bitset>
#include<list>
#include<set>
#include<utility>
#include<iomanip>
#define IO ios::sync_with_stdio(false)
#define eps 1e-7
#define int long long
using namespace std;
int fa[10000007],ans,n;
signed main()
{
	cin>>n;
	for(int i=1;i*i<=n;i++)
	{
		for(int j=i;i*j<=n;j++)
		{
			fa[i*j]+=2;
			if(i==j)fa[i*j]--;
		}
	}
	for(int i=1;i<=n;i++)
	{
		ans+=i*fa[i];
	}
	cout<<ans;
}

Measured memory_bytes: 81744
#include<bits/stdc++.h>
using namespace std;
int sti(string a){
	int s=0;
	for(int i=0;i<a.size();i++)s=s*10+(a[i]-'0');
	return s;
}
int main()
{
	string x,y,z;cin>>x>>y;
	z=x+y;
	int d=sti(z);
	if(sqrt(d)==int(sqrt(d)))cout<<"Yes";else cout<<"No";
	return 0;
}

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

#define N 100000
#define MAX 1000000000000000000

int main (void)
{
    unsigned long long a, b_100;
    double b;
    char s[10];
    int i, dot = 0;

    scanf("%llu %s", &a, s);

    for (i = 0; s[i] != '\0'; i++) {
        if (s[i] == '.') {
            dot = i;
            s[i] = '\0';

            if (s[i + 2] == '\0') {
                s[i + 2] = '0';
                s[i + 3] = '\0';
            }
        }
    }

    if (dot != 0) {
        b_100 = (unsigned long long)(atoi(s) * 100) + atoi(&(s[dot + 1]));
    } else {
        b_100 = (unsigned long long)(atoi(s) * 100);
    }

    printf("%llu", a * b_100 / 100);

    return 0;
}


Measured memory_bytes: 1736
#include <stdio.h>

/* {1,2,3} -> ... -> {3,2,1} */
int next_permutation(int arr[],int n) {
	int target;
	int i;
	int temp;
	int* arr2;
	int n2;
	for(i=n-2;i>=0;i--) {
		if(arr[i]<arr[i+1])break;
	}
	if(i<0)return 0;
	target=i;

	/* inline reverse_arr */
	arr2=arr+target+1;
	n2=n-target-1;
	for(i=0;n2-i-1>i;i++) {
		int t;
		t=arr2[i];
		arr2[i]=arr2[n2-i-1];
		arr2[n2-i-1]=t;
	}

	for(i=target+1;i<n;i++) {
		if(arr[i]>arr[target])break;
	}
	temp=arr[i];
	arr[i]=arr[target];
	arr[target]=temp;
	return 1;
}

int main(void) {
	int N,M;
	int enable[20]={0};
	double color[20][3];
	int i,j,k;
	double max_score=0;
	if(scanf("%d%d",&N,&M)!=2)return 1;
	for(i=0;i<N;i++) {
		if(scanf("%lf%lf%lf",&color[i][0],&color[i][1],&color[i][2])!=3)return 1;
	}
	for(i=0;i<M;i++)enable[N-1-i]=1;
	do {
		double cur_score=0;
		for(i=0;i<N;i++) {
			if(!enable[i])continue;
			for(j=i+1;j<N;j++) {
				if(!enable[j])continue;
				for(k=0;k<3;k++) {
					cur_score+=(color[i][k]-color[j][k])*(color[i][k]-color[j][k]);
				}
			}
		}
		if(cur_score>max_score)max_score=cur_score;
	} while(next_permutation(enable,N));
	printf("%.15f\n",max_score);
	return 0;
}

Measured memory_bytes: 668
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).expect("");
    let iter = buf.split_whitespace();
    let mut v: Vec<T> = Vec::new();
    for i in iter {
        v.push(i.parse().ok().unwrap());
    }
    v
}

fn main() {
    let v:Vec<u128> = procon_read();
    let mut n = v[0];
    let mut v:Vec<char> = Vec::new();
    while n != 0 {
        if n%26 == 0 {
            // print!("z");
            v.push('z');
            n = n/26 - 1;
        }else{
            // print!("{}", (('a' as u8) - 1_u8 + (n%26) as u8) as char);
            v.push((('a' as u8) - 1_u8 + (n%26) as u8) as char);
            n = n /26;
        }
    }
    
    for i in (0..v.len()).rev() {
        print!("{}", v[i]);
    }
    println!("");
}

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

using namespace std;

#define ll long long

bool JudgeM(string s) {
	if (s[0] == '0') {
		if (s[1] == '0') return false;
		return true;
	}
	if (s[0] == '1') {
		return s[1] == '0' || s[1] == '1' || s[1] == '2';
	}
	return false;
}

int main() {
	string s;
	cin >> s;
	string h = s.substr(0,2);
	string t = s.substr(2,2);
	if (JudgeM(h) && JudgeM(t)) {
		cout << "AMBIGUOUS" << endl;
		return 0;
	}
	if (JudgeM(h) && !JudgeM(t)) {
		cout << "MMYY" << endl;
		return 0;
	}
	if (!JudgeM(h) && JudgeM(t)) {
		cout << "YYMM" << endl;
		return 0;
	}
	cout << "NA" << endl;
	return 0;
}

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

int main() {
  int a,b,c;
  cin>>a>>b>>c;
  if(max({a,b,c})==a+b+c-max({a,b,c})){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  
}

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

int main() {
  string S;
  cin >> S;
  if(S=="hi"||S=="hihi"||S=="hihihi"||S=="hihihihi"||S=="hihihihihi")
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    a,b=map(int,readline().split())
    if a%3==0 or b%3==0 or (a+b)%3==0:
        print("Possible")
    else:
        print("Impossible")
        
if __name__=="__main__":
    main()

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

#define rep(i, N) for (ll i = 0; i < N; i++)
#define rep1(i, N) for (ll i = 1; i <= N; i++)
#define repr(i, N) for (ll i = N-1; i >= 0; i--)
#define repr1(i, N) for (ll i = N; i > 0; i--)

#define MOD 1000000007

using ll = long long;
using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<P> vpi;


int main() {
    ll N,ans = 0,num = 0,sum = 0;
    cin >> N;
    vi a(N);
    rep(i,N) cin >> a[i];
    rep(i,N) sum += a[i];

    num = a[0];
    ans = abs(num - (sum-num));
    rep1(i,N-2){
        num += a[i];
        ans = min(ans, abs(num - (sum-num)));
    }
        

    cout << ans;
    //printf("%.15lf", ans);
    cout << "\n";
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll a,b,c,n;
ll ans;
int main(){
	scanf("%lld%lld%lld%lld",&a,&b,&c,&n);
	rep(i,0,3001)rep(j,0,3001){
		ll x=n-i*a-j*b;
		if(x>=0&&x%c==0)ans++;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 128
tenants = []
buildings = [[[0 for _ in range(10)] for _ in range(3)]for _ in range (4)]

n = int(input())

for _ in range(n):
    b, f, r, v = map(int, input().split())
    buildings[b-1][f-1][r-1] += v


for i in range(4):
    if i != 0:
        print("#"*20)
    for j in range(3):
        for k in range(10):
            print(" {}".format(buildings[i][j][k]), end='')
        print()



Measured memory_bytes: 5624
using System;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] RDX = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            int R = RDX[0];
            int D = RDX[1];
            int X = RDX[2];
            int tmp = 0;
            for(int i = 0; i < 10; i++)
            {
                tmp = X * R - D;
                Console.WriteLine(tmp);
                X = tmp;
            }
        }
    }
}

Measured memory_bytes: 13396
import numpy as np

n, m, c = map(int, input().split())
b = np.array(list(map(int, input().split())))
ans = []
for i in range(n):
    a = np.array(list(map(int, input().split())))
    if b.dot(a)+c > 0:
        ans.append(i+1)
print(len(ans))


Measured memory_bytes: 13160
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define ll long long
#define clr(x) memset((x),0,sizeof(x))
using namespace std;
template<class T>
inline void read(T &res){
	static char ch;T flag=1;
	while((ch=getchar())<'0'||ch>'9')if(ch=='-')flag=-1;res=ch-48;
	while((ch=getchar())>='0'&&ch<='9')res=res*10+ch-48;res*=flag;
}
inline int readin(){
	static char ch;int flag=1,res;
	while((ch=getchar())<'0'||ch>'9')if(ch=='-')flag=-1;res=ch-48;
	while((ch=getchar())>='0'&&ch<='9')res=res*10+ch-48;res*=flag;
	return res;
}
inline int readst(char *s){
	static char ch;int len=0;
	while((ch=getchar())<'a'||ch>'z');s[len++]=ch;
	while((ch=getchar())>='a'&&ch<='z')s[len++]=ch;
	return --len;
}
int n;
int main(){
	//freopen("test.in","r",stdin);
	read(n);
	cout<<"ABC"<<n<<endl;
	return 0;
}

Measured memory_bytes: 764
import math
N,D = map(int, input().split())
my_list = []
for i in range(N):
    my_list.append(list(map(int, input().split())))

ans = 0

for i in range(N):
    src = my_list[i]
    for j in range(i + 1, N):
        dst = my_list[j]
        sum = 0
        for k in range(len(src)):
            sum += (src[k] - dst[k]) **2
        if float.is_integer(math.sqrt(sum)):
            ans += 1
print(ans)
        

Measured memory_bytes: 3064
A = [[0]*3 for _ in range(3)]

for i in range(3):
    a1, a2, a3 = map(int, input().split())
    A[i][0] = a1
    A[i][1] = a2
    A[i][2] = a3
N = int(input())
for i in range(N):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if A[j][k] == b:
                A[j][k] = 0
for i in range(3):
    if A[i][0] == A[i][1] == A[i][2] == 0:
        print("Yes")
        exit()
    if A[0][i] == A[1][i] == A[2][i] == 0:
        print("Yes")
        exit()
if A[0][0] == A[1][1] == A[2][2] == 0:
    print("Yes")
    exit()
              
if A[0][2] == A[1][1] == A[2][0] == 0:
    print("Yes")
    exit()
            
print("No") 

Measured memory_bytes: 38724
#include<stdio.h>
#include<string.h>
int main(){
	int k;
	char chs[105];
	scanf("%d",&k);
	scanf("%s",chs);
	if(strlen(chs) > k){
		for(int i = 00; i < k ;i++){
			printf("%c",chs[i]);
		}
		printf("...\n");
	}else{
		printf("%s",chs);
	}
	return 0;
} 

Measured memory_bytes: 1732
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
using namespace std;
#define vel vector<long long>
#define vvel vector<vel>
#define int long long
#define rep(i,n) for(long long i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define V vector
long long p = 1000003;
vel kai(1000007, 1);
vel ink(1000007, 1);
template<typename T>
V<T> uni(V<T> &list) {
	if (list.size() == 0) { return list; }
	sort(list.begin(), list.end());
	V<T> ql(1, list[0]);
	rep(i, list.size() - 1) {
		if (list[i] != list[i + 1]) { ql.push_back(list[i + 1]); }
	}
	return ql;
}
int ru(int a, int r) {
	if (r == 0) { return 1; }
	int ans = ru(a, r / 2);
	ans *= ans; ans %= p;
	if (r % 2 == 1) { ans *= a; ans %= p; }
	return ans;
}
int inv(int a) {
	return ru(a, p - 2);
}
void make_kai() {
	rep(i, 1000006) { kai[i + 1] = (kai[i] * (i + 1)) % p; }
	rep(i, 1000007) { ink[i] = inv(kai[i]); }
}
int com(int n, int r) {
	int ans = kai[n] * ink[r];
	ans %= p;
	return ans;
}
signed main() {
	int q; cin >> q;
	make_kai();
	rep(i, q) {
		int x, d, n; cin >> x >> d >> n;
		if (d == 0) {
			cout << ru(x, n) << endl;
		}
		else {
			int a = (x * inv(d)) % p;
			if (a == 0) { cout << 0 << endl; }
			else if (a + n - 1 >= p) { cout << 0 << endl; }
			else {
				int ans = com(a + n - 1, a - 1);
				ans *= ru(d, n); ans %= p;
				cout << ans << endl;
			}
		}
	}
	return 0;
}


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

using namespace std;

int t[10][10];

int first(int a) {
	while (a >= 10)
		a /= 10;
	return a;
}

int last(int a) {
	return (a % 10);
}

int main() {
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	for (int i = 1; i <= n; i++)
		t[first(i)][last(i)]++;
	long long res = 0;
	for (int i = 1; i <= 9; i++)
	for (int j = 1; j <= 9; j++)
		res += (long long)t[i][j] * (long long)t[j][i];
		
	cout<<res;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin >> n;
  string s;cin >> s;
  for(int i=0;i<s.size();i++){
    int t=s[i]-'A';
    char c='A'+(t+n)%26;
    cout << c;
  }
  cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;


int main(void){
    stack<string>stk;
    int n;
    string s;
    cin>>n;
    bool flag=true;
    for(int i=0;i<n;i++){
        cin>>s;
        if(s=="A")stk.push(s);
        else{
            if(stk.empty())flag=false;
            else stk.pop();
        }
    }
    if(flag){
        if(stk.empty())cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
    else cout<<"NO"<<endl;
    return 0;
}


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

#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define DEBUG_PRINT(...) fprintf(stderr, __VA_ARGS__)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int, int> pi;
typedef vector<int> vi;
void print_pair(pi a){
  cerr<<"("<<a.first<<", "<<a.second<<") ";
}
template<int T1, int T2>
void print_2d(int a[T1][T2], int x, int y){
  For(i, x){
    For(j, y){
      cerr<<a[i][j]<<" ";
    }
    cerr<<endl;
  }
}
template<class T>
void print_array(T a[],size_t n){
  cerr<<"array:";
  REP(n-1)cerr<<a[i]<<",";
  cerr<<a[n-1]<<endl;
}

ll N;
ll a[100000];

int main(){
  cin>>N;
  int ans=0;
  REP(N){
    ll tmp;
    cin>>tmp;
    if(tmp%2==1){
      ans=1;
      break;
    }
  }
  if(ans==1){
    cout<<"first"<<endl;
  }else{
    cout<<"second"<<endl;
  }
  return 0;
}



Measured memory_bytes: 256
S = input()

# if len(S) % 2 != 0:

half_num = len(S) // 2
front = S[:half_num]
back = S[half_num+1:]


is_true = True
if front == back:
    for idx in range((len(S)-1)//2):
        if S[idx] != S[-(idx+1)]:
            is_true = False
else:
    is_true = False

if is_true:
    print('Yes')

else:
    print('No')


Measured memory_bytes: 3060
#include<cstdio>
int main(){
    long long k,a,b,ans;
    scanf("%lld%lld%lld",&k,&a,&b);
    if(a+1>=b||k<=a)ans=1+k;
    else if((k-(a-1))%2==0){
        ans=a+(b-a)*((k-(a-1))/2);
    }else{
        ans=a+1+(b-a)*((k-(a-1))/2);
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<queue>
using namespace std;

int main(){
    int d, n;
    while(cin >> d >> n, d+n){
        vector<int> a(n), e(n), r(n);
        for(int i = 0; i < n; i++)  cin >> a[i] >> e[i] >> r[i];
        vector<vector<int>> dp(d+1, vector<int>(101, 1<<30));
        dp[0][0] = 0;
        for(int du = 0; du <= d; du++){
            for(int ex = 0; ex < 101; ex++){
                for(int k = 0; k < n; k++){
                    if(dp[du][ex] == 1<<30 || r[k] > ex)    continue;
                    dp[min(du+a[k],d)][min(100,ex+e[k])] = 
                        min(dp[min(du+a[k],d)][min(100,ex+e[k])], dp[du][ex]+1);
                }
            }
        }
        int ans = 1<<30;
        for(int i = 0; i < 101; i++)    ans = min(ans, dp[d][i]);
        if(ans == 1<<30)    cout << "NA" << endl;
        else                cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
#define rep(i, N) for (int i = 0; i < N; i++)
using namespace std;
int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> a(M), b(N + 1);
    rep(i, M)
    {
        cin >> a[i];
    }
    b[0] = 1;
    b[1] = 1;
    for (int i = 2; i <= N; i++)
    {
        b[i] = b[i - 1] + b[i - 2];
    }
    rep(i, M)
    {
        b[a[i]] = 0;
    }

    for (int i = 2; i <= N; i++)
    {
        if (b[i] != 0)
        {
            b[i] = b[i - 1] + b[i - 2];
            b[i] %= 1000000007;
        }
    }
    cout << b[N] << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <utility>
#include <deque>
#include <stack>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef queue<int> qi;
typedef queue<ll> ql;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define rep(i,n) for (int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define INF 1000000009
int n;
ll a[100005],b[100005];
int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	rep(i,n) cin>>a[i];
	sort(a,a+n);
	int i=0,j=n-1,p=0;
	while(i<j){
		b[p++]=a[i++];
		b[p++]=a[j--];
	}
	if (i==j) b[p++]=a[i];
	ll ans=0;
	rep(ii,p-1) ans+=abs(b[ii]-b[ii+1]);
	if (abs(b[p-1]-b[p-2])<abs(b[p-1]-b[0])) ans+=abs(b[p-1]-b[0])-abs(b[p-1]-b[p-2]);
	if (i==j){
		ll newans=0;
		i=0,j=n-1,p=0;
		while(i<j){
			b[p++]=a[j--];
			b[p++]=a[i++];
		}
		b[p++]=a[i];
		rep(ii,p-1) newans+=abs(b[ii]-b[ii+1]);
		if (abs(b[p-1]-b[p-2])<abs(b[p-1]-b[0])) newans+=abs(b[p-1]-b[0])-abs(b[p-1]-b[p-2]);
		ans=max(ans,newans);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1920
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list=new ArrayList<Integer>();
		//Long[] array = new Long[6];
		String s = sc.next();
		String t = sc.next();
		System.out.println(t+s);
	}
}

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

int main(){
  string s;
  cin >> s;
  vector<string>x2(s.size());
  rep(i,s.size()) {
    x2.at(i) = "x";
    cout << x2.at(i);
  }
  cout << endl;
}


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

#define pb push_back
#define all(v) (v).begin(), (v).end()

int n, k;
int arr[500010];
int v[500010];
int ans[500010];

int f(int s, int e) {
    if(s >= e) return 0;

    vector<int> v1, v2, ret;
    //int p = s+e>>1;
    int p = rand() % (e-s+1) + s;

    int mx = v[p];
    for(int i=p-1; i>=s; i--) {
        if(v[i] >= mx+k) {
            v2.pb(v[i]);
        }
        else {
            v1.pb(v[i]);
            mx = max(mx, v[i]);
        }
    }

    reverse(all(v1));
    reverse(all(v2));

    int mn = v[p];
    for(int i=p+1; i<=e; i++) {
        if(v[i] <= mn - k) {
            v1.pb(v[i]);
        }
        else {
            v2.pb(v[i]);
            mn = min(mn, v[i]);
        }
    }

    for(int i=0; i<v1.size(); i++) {
        ret.pb(v1[i]);
    }
    ret.pb(v[p]);
    for(int i=0; i<v2.size(); i++) {
        ret.pb(v2[i]);
    }

    for(int i=s; i<=e; i++) {
        v[i] = ret[i-s];
    }

    f(s, s+v1.size()-1);
    f(e - v2.size() + 1, e);
}

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

    srand(time(NULL));
    cin >> n >> k;

    for(int i=0; i<n; i++) {
        cin >> arr[i];
        v[arr[i]] = i;
    }

    f(1, n);

    for(int i=1; i<=n; i++) {
        ans[v[i]] = i;
    }

    for(int i=0; i<n; i++) {
        cout << ans[i] << "\n";
    }
}


Measured memory_bytes: 31408
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

void print_front(vector<int>& line) {
  bool first = true;
  for (int i = 0; i < line.size(); i++) {
    if (!first) {
      cout << " ";
    }
    cout << line[i];
    first = false;
  }
  cout << endl;
}

void print_back(vector<int>& line) {
  bool first = true;
  for (int i = line.size() - 1; i >= 0; i--) {
    if (!first) {
      cout << " ";
    }
    cout << line[i];
    first = false;
  }
  cout << endl;
}

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

  int h, w, n;
  cin >> h >> w >> n;

  vector<int> a(n);

  for (auto& e : a) {
    cin >> e;
  }

  vector<int> line;
  bool odd = true;

  for (int i = 0; i < a.size(); i++) {
    for (int j = 0; j < a[i]; j++) {
      line.push_back(i+1);
      if (line.size() == w) {
        if (odd) {
          print_front(line);
        } else {
          print_back(line);
        }
        line.clear();
        odd = !odd;
      }
    }
  }
  return 0;
}



Measured memory_bytes: 384
from collections import defaultdict

n, m = map(int, input().split())
s = defaultdict(list)

for i in range(1, m + 1):
    _, *x = map(int, input().split())
    for j in x:
        s[j].append(i)

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


ans = []
for i in range(2**n):
    tmp = [0] * len(p)
    for j in range(n):
        if ((i >> j) & 1):
            for k in s[j + 1]:
                tmp[k - 1] += 1
    if all([x % 2 == y for x, y in zip(tmp, p)]):
        ans.append(True)
    else:
        ans.append(False)

print(sum(ans))

Measured memory_bytes: 9448
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

int64_t K;
std::string S;

void solve()
{
    std::cin >> K >> S;
	if ((int64_t)S.size() <= K)
	{
		std::cout << S << std::endl;
		return;
	}

	std::cout << S.substr(0, K) << "..." << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	solve();
}


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

int k, n, ans;

int main() {
  cin >> k >> n;
  vector<int> a(n);
  for (size_t i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  vector<int> dist(n + 1);
  for (size_t i = 0; i < n - 1; i++) {
    dist.at(i) = a.at(i + 1) - a.at(i);
  }
  dist.at(n) = k - (a.at(n - 1) - a.at(0));
  sort(dist.begin(), dist.end());
  ans = k - dist.at(n);
  cout << ans << endl;
  return 0;
}


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

int main()
{
  string n;
  cin >> n;
  string rev = n;
  reverse(rev.begin(), rev.end());
  if(n == rev) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>

using namespace std;

int solve()
{
  int N;
  cin >> N;
  int answer = 1;
  int prev = 0;
  int sign = 0;
  for (int i = 0; i < N; ++i) {
    int now;
    cin >> now;
    if (prev != 0) {
      int s = now - prev;
      if ((sign > 0 and s < 0) or (sign < 0 and s > 0)) {
        // cout << prev << " " << now << ": " << sign << " " << s << endl;
        sign = 0;
        ++answer;
        prev = now;
        continue;
      }
      if (sign == 0) sign = s;
    }
    prev = now;
  }
  return answer;
}

int main()
{
  cout << solve() << endl;
  return 0;
}

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

int main() {
  int t_sum = 0;
  int t_diff[5] = {};
  for (int i = 0; i < 5; ++i) {
    int time; cin >> time;
    
    t_diff[i] = ceil(time / 10.0) * 10 - time;
    t_sum += ceil(time / 10.0) * 10;
  }
  
  int max_diff = *max_element(t_diff, t_diff + 5);
  cout << t_sum - max_diff << endl;
  
  return 0;
}

Measured memory_bytes: 256
N, M = list(map(int, input().split()))
digits = [-1 for i in range(N)]

fail = False

for i in range(M):
    s, c = list(map(int, input().split()))
    s -= 1

    if (digits[s] != -1 and digits[s] != c):
        fail = True
    elif s >= N:
        fail = True
    else:
        digits[s] = c

if (N == 1 and (digits[0] == -1 or digits[0] == 0)):
    print(0)
    quit()

if (digits[0] == -1): digits[0] = 1
for i in range(1,N):
    if digits[i] == -1: digits[i] = 0

if digits[0] == 0:
    fail = True

if fail:
    print(-1)
else:
    print("".join(map(str, digits)))

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}

ll f(ll x, ll m){ return x*x % m;}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	ll n, x, m;
	cin >>n >>x >>m;
	
	VL cx(100100);
	cx[0] = x;
	rep(i, 100100) cx[i+1] = f(cx[i], m);
	//for(auto x :cx) cerr<<x<<" "; dbg();
	
	
	ll ans =0;
	if(n<100010){
		rep(i, n) ans += cx[i];
	}else{
	
		map<ll, int> mp;
		int st=0,ss=0;
		rep(i, 100999){
			if(mp.count(cx[i])){ st=mp[cx[i]]; ss=i; break;}
			mp[cx[i]] = i;
		}
		ll lp=ss - st;
		ll su = (n-st) / lp;
		ll sm =0;
		rep2(i, st, ss) sm += cx[i];
		ans = su * sm;
		ll am = (n-st)%lp;
		rep(i, st) ans += cx[i];
		rep2(i, st, st+am) ans += cx[i];
	}
	cout << ans <<"\n";
	return 0;
}



Measured memory_bytes: 7156
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
from math import atan,pi
def resolve():
    a,b,x=map(int,input().split())
    if(x<=a*a*b/2):
        print(atan((a*b*b)/(2*x))*180/pi)
    else:
        print(atan(2*(a*a*b-x)/(a**3))*180/pi)
resolve()

Measured memory_bytes: 38256
x, n = gets.chomp.split.map(&:to_i)

a = []
a = gets.chomp.split.map(&:to_i) if n != 0

i = 0
loop do
  t = x - i
  if !a.include?(t)
    puts t
    break
  end

  t = x + i
  if !a.include?(t)
    puts t
    break
  end

  i += 1
end


Measured memory_bytes: 14364
using System.Linq;
using System.Text;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Numerics;
using System.Runtime.CompilerServices;

namespace AtCoder
{
    class Program
    {

        const int BiggestMod = 1000000007;

        public static void Main()
        {

            Console.WriteLine(Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList().FindIndex(x => x == 0) + 1);

        }

    }

}


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

#define SIZE 300005
#define MOD 1000000007LL
#define INF INT_MAX / 3
#define LLINF 1LL << 60
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define FORALL(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FOREACH(i,c) for(auto (i) : (c))
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef valarray<int> Array;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cout<<a[i];if(i==a.size()-1)cout<<endl;else cout<<" ";}}
int gcd(int a,int b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
int lcm(int a,int b){return a==0||b==0?0:a*b/gcd(a,b);}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  map<char,int> T;
  T['I'] = 1;
  T['V'] = 5;
  T['X'] = 10;
  T['L'] = 50;
  T['C'] = 100;
  T['D'] = 500;
  T['M'] = 1000;
  while(cin >> s)
  {
    int ans = 0, p = 0;
    DOWN(i,s.size()-1,0)
    {
      if(T[s[i]] < p) ans -= T[s[i]];
      else ans += T[s[i]];
      p = T[s[i]];
    }
    printf("%d\n",ans);
  }
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
 
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define ll long long
 
#define pi pair < ll , ll >
#define pb push_back
#define mp make_pair
#define F first
#define S second
 
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
 
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
using namespace std;

int main()
{
    fastIO;
    ll st = 0, ed, md, i, j, k, n, a[200001], f[200001], ans=0;
    cin>>n>>k;fo(i,n)cin>>a[i];fo(i,n)cin>>f[i];
    sort(a,a+n);sort(f,f+n);reverse(f,f+n);
    fo(i,n)ans=max(ans,a[i]*f[i]);ed=ans;
    while(st<=ed) {
        md = st + ( ed - st ) / 2ll;
        ll trs = 0;
        fo(i,n) {
            ll xxx = min(md/f[i], a[i]);
            trs += a[i] - xxx;
        }
        if(trs<=k) {
            ans = min(ans, md);
            ed = md - 1;
        } else st = md + 1;
    }
    cout<<ans;
}   

Measured memory_bytes: 3328
#include <iostream>
//using the value of π
#include <bits/stdc++.h>
//using setprecision
#include <iomanip>

using namespace std;

int main (){
  double r;
  cin >> r;
  cout << fixed << setprecision(6)  << r * r * M_PI << " " << fixed << setprecision(6) <<  2 * M_PI * r << endl;
}



Measured memory_bytes: 3260