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

int main(){
  string s;
  cin >> s;
  int n=0;
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='1'){
      n++;
    }
  }
  cout << n << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ll N, K;
    cin >> N >> K;
    int scale = 1;
    ll m = K;
    while(m <= N) {
        m *= K;
        scale++;
    }
    cout << scale << endl;
    return 0;
}


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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)

using ll = long long;
using P = std::tuple<int,int>;

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

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

    ll x;
    std::cin >> x;

    // if minimizing, lb satisfies lb > ub
    // if maximizing, lb satisfies lb < ub
    ll lb = 1000000000000000ll, ub = 0ll;
    
    while(std::abs(ub - lb) > 1){
        ll mid = (lb + ub) / 2;

        ll score = mid / 2 * 11 + mid % 2 * 6;
        
        if(score >= x){
            lb = mid;
        }else{
            ub = mid;
        }
    }

    std::cout << lb << std::endl;

}


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

int main() {
  int N;
  cin >> N;
  
  int sum = 0;

  for (int i = 0; i < 9; i++) {
    int x = N;
    
    for (int j = 0; j < i; j++) {
      x /= 10;
    }
    
    x %= 10;
    sum += x;
  }
  
  if ( N % sum == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}



Measured memory_bytes: 256
from collections import deque

K = int(input())
q = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])

for i in range(K):
    runrun = q.popleft()
    rem = runrun % 10
    if rem == 0:
        q.append(runrun * 10)
        q.append(runrun * 10 + rem + 1)
    elif rem == 9:
        q.append(runrun * 10 + rem - 1)
        q.append(runrun * 10 + rem)
    else:
        q.append(runrun * 10 + rem - 1)
        q.append(runrun * 10 + rem)
        q.append(runrun * 10 + rem + 1)

print(runrun)


Measured memory_bytes: 18748
import java.util.Scanner;

class Dice{
	int[] box = new int[7];
	
	void Setdice(int[] dice)
	{
		for(int i = 1;i< 7;i++)
		{
			box[i] = dice[i - 1];
		}
	}
	
	void diceroll(char[] roll)
	{
		for(int i = 0;i < roll.length;i++)
		{
			int[] temp = new int[7];
			if(roll[i] == 'N'){
				temp[1] = box[1];
				temp[2] = box[2];
				temp[5] = box[5];
				temp[6] = box[6];
				box[1] = temp[2];
				box[2] = temp[6];
				box[5] = temp[1];
				box[6] = temp[5];
			}else if(roll[i] == 'E'){
				temp[1] = box[1];
				temp[3] = box[3];
				temp[4] = box[4];
				temp[6] = box[6];
				box[1] = temp[4];
				box[3] = temp[1];
				box[4] = temp[6];
				box[6] = temp[3];
			}else if(roll[i] == 'S'){
				temp[1] = box[1];
				temp[2] = box[2];
				temp[5] = box[5];
				temp[6] = box[6];
				box[1] = temp[5];
				box[2] = temp[1];
				box[5] = temp[6];
				box[6] = temp[2];
			}else if(roll[i] == 'W'){
				temp[1] = box[1];
				temp[3] = box[3];
				temp[4] = box[4];
				temp[6] = box[6];
				box[1] = temp[3];
				box[3] = temp[6];
				box[4] = temp[1];
				box[6] = temp[4];
			}
		}
	}
	
	int Getans(int num)
	{
		return box[num];
	}
}

public class Main {
	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		int[] box = new int[6];
		Dice dice = new Dice();
		
		for(int i = 0;i < 6;i++)
		{
			box[i] = scan.nextInt();
		}
		
		String roll = scan.next();
		
		dice.Setdice(box);
		dice.diceroll(roll.toCharArray());
		System.out.println(dice.Getans(1));
	}
}

Measured memory_bytes: 17176
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;
typedef signed long long ll;
ul over = 1000000007;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int n, k;
  cin >> n >> k;
  ll x[n], y[n];
  for (int i=0; i<n; ++i) {
    cin >> x[i] >> y[i];
  }
  ll ans = -1;
  for (int i=0; i<n; ++i) {
    for (int j=i+1; j<n; ++j) {
      for (int s=0; s<n; ++s) {
        for (int t=s+1; t<n; ++t) {
          int isin = 0;
          ll x1 = min(x[i], x[j]), x2 = max(x[i], x[j]);
          ll y1 = min(y[s], y[t]), y2 = max(y[s], y[t]);
          for (int l=0; l<n; ++l) {
            if (x1 <= x[l] && x[l] <= x2 && y1 <= y[l] && y[l] <= y2) isin++;
          }
          if (isin>=k) {
            if (ans==-1) ans=(x2-x1) * (y2-y1);
            else ans = min(ans, (x2-x1) * (y2-y1));
          }
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};


int main(){
    int n0, m0, k0;
    cin >> n0>> m0 >> k0;
    mint n = n0, m = m0, k = k0;
    mint ans=0;
    vector<mint> c(n0+1);
    c[0] = 1;
    for(ll i = 1; i<n0+1; i++){
        c[i] = c[i-1];
        c[i] /= i;
        c[i] *= n0 - i;
    }
    rep(i, k0+1){
        mint memo = m;
        memo *= (m-1).pow(n0-1-i);
        memo *= c[i];
        ans += memo;
    }
    cout << ans.x << endl;
    return 0;
}

Measured memory_bytes: 4844
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main (String[] args){
	    Scanner scan = new Scanner(System.in);
	    int N = Integer.parseInt(scan.next());

	    ArrayList<Integer> SList = new  ArrayList<Integer>();
	    int seiseki = 0;
	    for(int i = 0; i < N; i++){
	    	int S = Integer.parseInt(scan.next());
	    	SList.add(S);
	    	seiseki = seiseki + S;
	    }
	    Collections.sort(SList);
	    
	    if(seiseki % 10 != 0){
	    	System.out.println(seiseki);
	    }else{
	    	for(int s : SList){
	    		if(s  % 10 != 0){
	    			seiseki = seiseki - s;
	    			System.out.println(seiseki);
	    			break;
	    		}
	    	}
	    	if(seiseki % 10 == 0){
	    		System.out.println(0);
	    	}
	    }
	}
}

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

int main() {
	int N, count = 0;
	double D;
	cin >> N >> D;

	for (int i = 0; i < N; ++i) {
		double X, Y;
		cin >> X >> Y;
		if (sqrt(X*X + Y*Y) <= D) {
			++count;
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 3812
using System;

class ABC
{
    static void Main()
    {
        string input = Console.ReadLine();
        string[] inputA = input.Split(' ');
        int N = int.Parse(inputA[0]);
        int M = int.Parse(inputA[1]);
        if (N == M)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 11092
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace paiza2
{
    class Program
    {
        static int Main(string[] args)
        {
            string m = Console.ReadLine();
            int second = ni(m);
            if (second == -1)
            {
                int third = san(m);
                if (third == -1)
                {
                    Console.WriteLine("-1 -1");
                    return 0;
                }
                else
                {
                    Console.WriteLine("{0} {1}", third, third + 2);
                    return 0;
                }
            }
            else
            {
                Console.WriteLine("{0} {1}", second, second + 1);
                return 0;
            }

        }
        static int ni(string m)
        {
            int output = -1;
            for (int c = 0; c < m.Length-1; c++)
            {
                if (m[c] == m[c + 1])
                {
                    output = c + 1;
                }
            }
            return output;

        }
        static int san(string m)
        {
            int output = -1;
            for (int c = 0; c < m.Length - 2; c++)
            {
                if (m[c] == m[c + 2])
                {
                    output = c + 1;
                }
            }
            return output;
        }

    }
}


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

int main(){
    int n;
    while(true){
        cin>>n;
        if(n==0){break;}
        int table[26]={0},max1=0,max2=0;
        char cha[n+1],m_cha[2];
        for(int i=0;i<n;i++)cin>>cha[i];
        for(int t=0;t<n;t++){
            table[cha[t]-'A']++;
            if(table[cha[t]-'A']>max1){
                max1=table[cha[t]-'A'];
                m_cha[0]=cha[t];
            }
            else if(table[cha[t]-'A']>max2)max2=table[cha[t]-'A'];
            if(max1-max2 >= n-t){
                cout<<m_cha[0]<<" "<<t+1<<endl;
                break;
            }
            if(t==n-1)
                if(max1==max2)
                    cout<<"TIE"<<endl;
        }
    }
}


Measured memory_bytes: 3084
#include<iostream>
using namespace std;
int main(void){
  int a;
  char c;
  string s;
  cin >> a >> s;
  int b = a;
  for(int i = 0;i < a - 1;i++){
    if(s.at(i) == s.at(i+1)){
      b--;
    }
  }
  cout << b;
}

Measured memory_bytes: 512
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000000000000000000000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)                                                                             
#define seg_size 524288
int main() {
	vector<int> geko;
	REP(i, 3) {
		int tmp;
		cin >> tmp;
		geko.push_back(tmp);
	}
	sort(geko.begin(), geko.end());
	if (geko[0] == geko[1]) {
		cout << geko[2] << endl;
	}
	else {
		cout << geko[0] << endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
 ll a,b,x;sc(a);sc(b);sc(x);
 if(a<=x&&a+b>=x)pY;
 else pN;
return 0;}

Measured memory_bytes: 3588
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;

namespace AtCoder
{
    class Program
    {

        const int BiggestMod = 1000000007;
        public static void Main()
        {

            var args = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();

            var separator = args[2];
            var min = args[0] - 1 + separator;
            var max = args[1] + separator;

            Console.WriteLine((max / separator) - (min / separator));

        }

    }

}

Measured memory_bytes: 13396
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define sz(x) (ll)(x).size()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;
typedef vector<ll> vl;
typedef vector<P> vp;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll n;
  cin >> n;
  vector<P> a(n);
  rep(i, n) {
    a[i].second = i;
    cin >> a[i].first;
  }
  a.emplace_back(0, n); // a[n] is added as sentinel.

  sort(all(a));
  reverse(all(a));
  ll l = 0;
  ll r = 0;
  vector<ll> ans(n);
  set<ll> st;
  while (l < n) {
    while (r < n && a[l].first == a[r].first) {
      st.insert(a[r].second);
      ++r;
    }
    // Here, r == n or a[l].first > a[r].first. [l, r) has same height.
    ll now = *st.begin(); // smallest in [l, r)
    ans[now] += r * (a[l].first-a[r].first);

    // Update for next
    l = r;
  }

  rep(i, n) {
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 9444
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

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

    vector<int> a(n),b(n),c(n-1);
    for(int i=0;i<n;i++){
        int tmp;
        cin >> tmp;
        a[i] = tmp - 1;
    }

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

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

    int ans = 0, tmp = 9999;
    for(int i=0;i<n;i++){
        ans += b[a[i]];
        if(tmp+1 == a[i]){
            ans += c[a[i]-1];
        }
        tmp = a[i];

    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define All(v) v.begin(), v.end()
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;

int N, M, S[12], p[12];
vector<int> E[12];

int dfs(int cur){
    if(cur==N){
        bool ok = true;
        for(int i=0;i<M;i++){
            int q = 0;
            for(auto u : E[i]) if(S[u]) q ^= 1;
            if(q!=p[i]) ok = false;
        }
        if(ok) return 1;
        else return 0;
    }

    int res = dfs(cur+1);
    S[cur] = 1;
    res += dfs(cur+1);
    S[cur] = 0;
    return res;
}

int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr);
    cin >> N >> M;
    for(int i=0;i<M;i++){
        int k; cin >> k;
        for(int j=0;j<k;j++){
            int s; cin >> s, s--;
            E[i].push_back(s);
        }
    }
    for(int i=0;i<M;i++) cin >> p[i];

    cout << dfs(0) << endl;
    return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d", $n);
$a = explode(' ', fgets(STDIN));

$lcm_value = lcm_n($a);

$temp = 0;
foreach ($a as $num) {
    $temp += $lcm_value / $num;
}
echo $lcm_value / $temp . "\n";

function gcd($a, $b) {
    if ($b === 0)
        return $a;

    return gcd($b, $a % $b);
}

function lcm($a, $b) {
    return $a * $b / gcd($a, $b);
}

function lcm_n($numbers) {
	
	$l = $numbers[0];
	for ($i = 1; $i < count($numbers); $i++) {
		$l = lcm($l, $numbers[$i]);
	}
	return $l;
}


Measured memory_bytes: 4604
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>

using namespace std;
using ll = long long int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)

#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define elif else if
#define itn ll
#define int ll
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
///                →,↑,←,↓,↗,↖,↙,↘
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };


int sumDigits(int n) {
	int sum = 0;
	while (n > 0) {
		sum += n % 10;
		n /= 10;
	}
	return sum;
}

signed main() {
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int mx = INF;
	for (ll i = 1; i <= n; i++) {
		int b = n - i;
		if (b > 0) {
			mx = min(mx, sumDigits(i) + sumDigits(b));
		}
	}
	cout << mx << '\n';
	return 0;
}

Measured memory_bytes: 256
// Undone
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
using namespace std;
signed main() {
  int N;
  cin >> N;

  vector<pair<int,int>> ball(N);
  for (int i = 0; i < N; i++) {
    int x,y; cin >> x >> y;
    ball[i] = make_pair(x,y);
  }
  sort(ball.begin(), ball.end());

  map<pair<int,int>,int> cnt;
  for (int i = 0; i < N-1; i++) {
    for (int j = i+1; j < N; j++) {
      int x = ball[j].first - ball[i].first;
      int y = ball[j].second - ball[i].second;
      cnt[make_pair(x,y)]++;
    }
  }

  int ans = 0;
  for(auto it = cnt.begin(); it != cnt.end(); it++) {
    ans = max(ans, it->second);
  }
  ans = N-ans;
  cout<<ans<<endl;
}


Measured memory_bytes: 384
n = int(input())
dic = {}
cnt = 0

for i in range(n) :
    s = input()
    if s[0] == "M" or s[0] == "A" or s[0] == "R" or s[0] == "C" or s[0] == "H" :
        if s[0] in dic :
            dic[s[0]] += 1
        else:
            dic[s[0]] = 1

lis = [x for x in dic.values()]

for j in range(len(lis) - 2) :
    for k in range(j + 1, len(lis) - 1) :
        for l in range(k + 1, len(lis)) :
            
            cnt += lis[j] * lis[k] * lis[l]
    
print(cnt)

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

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype

template <class T>
int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

const double EPS = 1e-10;
typedef long long ll;
typedef pair<int, int> pint;


int main()
{
	int n, m, c[2000];
	scanf("%d%d", &n, &m);
	for (int i = 0; i < 2*n; ++i)
		c[i] = i + 1;
	while (m--)
	{
		int k;
		scanf("%d", &k);
		int ori[2000];
		memcpy(ori, c, sizeof(ori));
		if (k == 0)
		{
			for (int i = 0; i < n; ++i)
			{
				c[2*i] = ori[i];
				c[2*i+1] = ori[n+i];
			}
		}
		else
		{
			for (int i = 0; i < k; ++i)
				c[2*n-k+i] = ori[i];
			for (int i = k; i < 2*n; ++i)
				c[i-k] = ori[i];
		}
	}
	for (int i = 0; i < 2*n; ++i)
		printf("%d\n", c[i]);
}

Measured memory_bytes: 0
n = int(input())
a = list(map(int, input().split()))
ans = 1
check = 0
for i in a:
  if i == 0 :
    check = 1

if check == 1:
  print(0)
else :
  for i in a:
    ans *= i
    if(ans > 10 ** 18):
      ans = -1
      break
  print(ans)

Measured memory_bytes: 21484
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdlib.h>
#define MOD 1000000007
void input_array(int how_data,int *data);
int get_random(int min, int max);
int factorial(int n);
int qsort_09(const int *sys1 , const int *sys2);
int qsort_90(const int *sys1 , const int *sys2);

long int total=0;

int main(void){
    int how_data;
    scanf("%d",&how_data);
    int size_data[how_data];
    input_array(how_data,size_data);
    //1匹ずつに対して生き残れるか判定
    //食べられる魚を食べて食べられなくなったら×　自分だけで〇
    //ソートしたほうがいいやつ
    //累積和で計算量減らす
    qsort(size_data,how_data,sizeof(int),(int (*)(const void *,const void *))qsort_09);
    int loop1,loop2;
    int ans=1;//最後の一匹(最大)は絶対残れる
    total-=size_data[how_data-1];
    //long int ruisekiwa=0;
    
    for(loop1=how_data-2;loop1>=0;loop1--){
        if(total*2>=size_data[loop1+1]){
            ans++;
        }else{
            loop1=-1;
        }
        total-=size_data[loop1];
    }
    printf("%d\n",ans);
    return 0;
}





//how_data個の配列data[]に標準入力
//input_array(how_data,data);
void input_array(int how_data,int *data){
    int loop;
    for(loop=0;loop<how_data;loop++){
        scanf("%d",&data[loop]);
        total+=data[loop];
    }
}

int get_random(int min, int max){   //指定の範囲から乱数を1つ返すやつ
    //srand((unsigned int)time(0));   //現在時刻で疑似乱数初期化
    rand();rand();rand();rand();    //乱数を空打ち
    return (rand()%(max+1-min))+min;
}


int factorial(int n){//n!のMOD10^9+7を返すやつ
    unsigned long long int ret=1;
    for(int i=1;i<=n;i++)ret=(ret*i)%1000000007;
    return (int)ret;
}

int qsort_09(const int *sys1 , const int *sys2){ //小さいのが上にくるやつ
    //qsort(data,how_data,sizeof(int),(int (*)(const void *,const void *))qsort_09);
    if(*sys1<*sys2){
        return -1;
    }else if(*sys1==*sys2){
        return 0;
    }else{
        return 1;
    }
}

int qsort_90(const int *sys1 , const int *sys2){ //大きいのが上にくるやつ
    //qsort(data,how_data,sizeof(int),(int (*)(const void *,const void *))qsort_90);
    if(*sys1<*sys2){
        return 1;
    }else if(*sys1==*sys2){
        return 0;
    }else{
        return -1;
    }
}


Measured memory_bytes: 892
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include <complex>
using namespace std;
 
#define FOR(i,a,b) for(LL i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it,a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB push_back
 
typedef long long LL;
typedef vector<int> VI;
typedef pair<int,int> PII;
 
const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MAX = 705;



map<pair<string, string>, int> M;

int main()
{
	//freopen("In.txt", "r", stdin);
	int n;
	string s;
	cin >> n >> s;
	
	FOR(msk, 0, 1 << n) {
		string R = "", B = "";
		FOR(i, 0, n) {
			if (msk & (1 << i)) R += s[i];
			else B += s[i];
		}
		M[MP(R, B)]++;
	}
	
	LL ans = 0;
	
	FOR(msk, 0, 1 << n) {
		string R = "", B = "";
		FOR(i, 0, n) {
			if (msk & (1 << i))R += s[n + n - i - 1];
			else B += s[n + n - i - 1];
		}
		ans += M[MP(R, B)];
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 91904
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll H, W, N;
    cin >> H >> W >> N;
    ll num = max(H, W);
    ll ans = (N + num - 1) / num;
    cout << ans << endl;
}


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

int main() {
    string s[7] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    string t; 
    cin >> t;
    for(int i = 0; i < 7; i++) {
        if(t == s[i]) {
            if(i == 0) {
                cout << 7 << endl;
            } 
            else {
                cout << 7 - i   << endl;
            }
        }
    }

    return 0;
}

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

using namespace std;

using ll = long long;

int main() {
    ll n;
    cin >> n;
    vector<ll> a(3 * n), sc(n + 1);
    for (int i = 0; i < 3 * n; ++i) cin >> a[i];

    priority_queue<ll> pq_l, pq_r;
    for (ll i = 0, sum[4] = {0, 0, 0, 0}; i < 2 * n; ++i) {
        sum[0] += a[i]; pq_l.push(-a[i]);
        sum[1] += a[3 * n - i - 1]; pq_r.push(a[3 * n - i - 1]);

        if (n <= i) {
            sum[2] -= pq_l.top(); pq_l.pop();
            sum[3] += pq_r.top(); pq_r.pop();
        }
        if (n - 1 <= i) {
            sc[i - n + 1] += sum[0] - sum[2];
            sc[2 * n - i - 1] -= sum[1] - sum[3];
        }
    }

    cout << *max_element(sc.begin(), sc.end()) << endl;

    return 0;
}


Measured memory_bytes: 5108
import sys
sys.stdin.readline

H, W = map(int, input().split())
board = [[[0,1][a == "#"] for a in input()] for i in range(H)]
Y = [[0]*W for _ in range(H)]

for i in range(H):
    for j in range(W):
        a = []
        if j == 0:
            pass
        else:
            if board[i][j-1] == False and board[i][j] == True:
                a.append(Y[i][j-1] + 1)
            else:
                a.append(Y[i][j-1])
        if i == 0:
            pass
        else:
            if board[i-1][j] == False and board[i][j] == True:
                a.append(Y[i-1][j] + 1)
            else:
                a.append(Y[i-1][j])
        if i + j == 0:
            if board[i][j]:
                a.append(1)
            else:
                continue
        Y[i][j] = min(a)


print(Y[H-1][W-1])


Measured memory_bytes: 9388
// #pragma GCC optimize(3,"Ofast","inline")
// #pragma GCC optimize(2)
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <string>
#include <iostream>
#include <list>
#include <cstdlib>
#include <bitset>
#include <assert.h>
#include <time.h>
#include <iomanip>
// #define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
// char buf[(1 << 21) + 1], * p1 = buf, * p2 = buf;
// #define int long long
#define lowbit(x) (x & (-x))
#define lson root << 1, l, mid
#define rson root << 1 | 1, mid + 1, r
#define pb push_back
typedef unsigned long long ull;
typedef long long ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;
typedef std::vector<ll> VI;
#define rep(i, a, n) for (int i = a; i < n; ++i)
#define SZ(x) ((int)((x).size()))
#define bug puts("BUG")
const long long INF = 0x3f3f3f3f3f3f3f3fLL;
const int inf = 0x3f3f3f3f;
const int mod = 998244353;
const double eps = 1e-6;
template <class T>
inline void read(T &x)
{
    int sign = 1;char c = getchar();x = 0;
    while (c > '9' || c < '0'){if (c == '-')sign = -1;c = getchar();}
    while (c >= '0' && c <= '9'){x = x * 10 + c - '0';c = getchar();}
    x *= sign;
}
#ifdef LOCAL
    FILE* _INPUT=freopen("input.txt", "r", stdin);
    // FILE* _OUTPUT=freopen("output.txt", "w", stdout);
#endif
using namespace std;
const int maxn = 2e6 + 10;
char s[maxn];
pii bracket[maxn];
bool cmp(pii a,pii b)
{
    return min(a.second, a.first + b.second) > min(b.second, b.first + a.second);
}
int main()
{
    int n;
    int sum = 0;
    read(n);
    for (int i = 0; i < n; ++i)
    {
        scanf("%s", s);
        int cur = 0, minn = inf;
        for (int j = 0; s[j]; ++j)
        {
            cur += s[j] == '(' ? 1 : -1;
            minn = min(minn, cur);
        }
        bracket[i] = pii(cur, minn);
        sum += cur;
    }
    if (sum)
        puts("No");
    else
    {
        sort(bracket, bracket + n, cmp);
        int cur = 0;
        bool ok = 1;
        for (int i = 0; i < n; ++i)
        {
            if (bracket[i].second + cur < 0)
            {
                ok = 0;
                break;
            }
            cur += bracket[i].first;
        }
        puts(ok ? "Yes" : "No");
    }
    
}

Measured memory_bytes: 11404
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
	public static void main(String[] args) {
		int MAX = 999999;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = null;
		int[] prime = new int[MAX + 1];
		int i = 0;
		
		try {
			//エラトステネスの篩
			for(i = 2; i * i <= MAX; i++ ){
		      if(prime[i] == 1 ) continue ;
		      for(int j = i * 2; j <= MAX; j += i ) prime[j] = 1;
		    }
			for(i = 2; i <= MAX; i++ ) 
				prime[i] = prime[i - 1] + (prime[i] == 0 ? 1 : 0);
			
			while ((line = br.readLine()) != null) {
				line = line.trim();
				int num = Integer.parseInt(line);
					
				System.out.println(prime[num]);
			}
			br.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

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

int main() {
	int n; cin >> n;
	vector<int>a(n); for (int i = 0; i < n; i++)cin >> a[i];
	sort(a.begin(), a.end());
	cout << a[n - 1] - a[0] << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int a[3];
	for(int i=0;i<3;i++)cin>>a[i];
	sort(a,a+3);
	if(a[0]==5&&a[1]==5&&a[2]==7)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <queue>
#include <map>
#include <cstdio>
#include <cmath>
#include <unordered_map>
#include <iomanip>
using namespace std;

int main(){
  int N;
  cin >> N;
  string S, T;
  cin >> S;
  cin >> T;
  for (int i = 0; i < N; i++){
    cout << S.at(i) << T.at(i);
  }
  cout << endl;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

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

using namespace std;
using ll=long long;

ll a[100010];

int main(void){
	ll n,l;
	cin >> n >> l;
	rep(i,n) cin >> a[i];

	ll idx=-1,cmax=0;
	rep(i,n-1) if(chmax(cmax,a[i]+a[i+1])) idx=i;

	vector<int> ans;

	if(cmax>=l){
		rrep(i,n-1){
			if(i==idx) break;
			ans.push_back(i+1);
		}

		rep(i,n-1){
			if(i==idx) break;
			ans.push_back(i+1);
		}

		ans.push_back(idx+1);
	}

	if(cmax>=l){
		cout << "Possible" << endl;
		assert(int(ans.size())==n-1);
		for(auto &it:ans) cout << it << endl;
	}else
		cout << "Impossible" << endl;

	return 0;
}

Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
long long n,k;

long long min1(long long a,long long b){
	return a<b?a:b;
}
int main(){
	
	scanf("%lld%lld",&n,&k);
	
	n%=k; 
	printf("%lld\n",min1(n,k-n));
	
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

int main() {
    ll a;
    cin >> a;
    cout << a+a*a+a*a*a << endl;
    return 0;
}



Measured memory_bytes: 3604
/**
 *   author: Shubham Srivastava
 *   created: 07 September 2019  19:20:21
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int n,k;cin>>n>>k;
    string s;cin>>s;
    int count=0;
    for(int i=1;i<n;i++){
        if(s[i] == s[i-1])
            count++;
    }
    cout<<min(n-1,count+2*k);
return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long ul;
// for文短縮類
#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--)
// iteratorのbeginとendをまとめて渡す
#define ALL(x) (x).begin(), (x).end()
//略
#define PB push_back  // vectorヘの挿入
#define MP make_pair  // pairのコンストラクタ
#define F first       // pairの一つ目の要素
#define S second      // pairの二つ目の要素
//出力
#define COUT(x) cout << (x) << endl
#define SCOUT(x) cout << (x) << " "
#define ENDL cout << endl
/************ Combination wtih MOD ************
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
// preprocess for some tables
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
// combination
long long COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
*******************************************************/
/********** UnionFind ***************
struct UnionFInd {
vector<ll> par;
UnionFInd(ll N) : par(N) {
for (ll i = 0; i < N; i++) {
par[i] = i;
}
}
ll root(ll x) {
if (par[x] == x) return x;
return par[x] = root(par[x]);
}
void unite(ll x, ll y) {
ll rx = root(x);
ll ry = root(y);
if (rx == ry) return;
par[rx] = par[ry];
}
bool same(ll x, ll y) {
ll rx = root(x);
ll ry = root(y);
return rx == ry;
}
};
*************************************/
int main(int argc, char *argv[]) {
  // input高速化。cinとcoutの結合解除。scanfとprintfは使えない。
  cin.tie(0);
  ios_base::sync_with_stdio(0);

  ll a, b, k;
  cin >> a >> b >> k;

  if(a >= k){
      cout << a - k << " " << b << endl;
      return 0;
  }

  k -= a;
  a = 0;

  if(b >= k){
    cout << a << " " << b - k << endl;
    exit(0);
  }

  cout << 0 << " " << 0 << endl;
}

Measured memory_bytes: 3604
from collections import deque
import sys
input = sys.stdin.readline

def putsarray(array):
    if len(array) == 0:
        print()
        return
    for i in range(len(array) - 1):
        print(int(array[i]), end=' ')
    print(int(array[-1]))

def main():
    stack = deque([])
    instr = input()
    is_same_lake = False
    result = 0

    lakes = deque([])

    for i in range(len(instr)):
        char = instr[i]
        if char == "\\":
            stack.append(i)
        elif char == "_":
            pass
        elif char == "/":
            if len(stack) == 0:
                is_same_lake = False
                continue
            down = stack.pop()
            result += i - down
            lake_area = i - down
            index = len(lakes) -1
            while True:
                if index < 0:
                    break
                lake = lakes[index]
                if down < lake[0] and lake[1] < i:
                    lake_area += lakes.pop()[2]
                else:
                    break
                index -= 1
                    
            lakes.append((down, i, lake_area))

    print(int(result))
    putsarray([len(lakes),] + [l[2] for l in lakes])

    

main()






Measured memory_bytes: 6864
N=int(input())
S=[]
s=input()
S.append(s)
ans=True
for i in range(1,N):
  s=input()
  if (s in S) or S[-1][-1]!=s[0]:
    ans=False
  else:
    S.append(s)
    
if ans:
  print("Yes")
else:
  print("No")

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

int a;
int b;
int product=1;

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

    for (int i=a; i<=b; i++)
    {
        if (i<0)
        {
            product=product*-1;
        }

        if (i==0)
        {
            cout<<"Zero"<<endl;
            return 0;
        }
    }

    if (product>0)
    {
        cout<<"Positive"<<endl;
    }

    else 
    {
        cout<<"Negative"<<endl;
    }
    
}

Measured memory_bytes: 3672
//
//  main.cpp
//  B - Balance
//
//  Created by Hashizo on 2019/06/09.
//  Copyright © 2019 Hashizo. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <regex>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define REPLACE(s, f, t) regex_replace(s, regex(f), t)

int main(int argc, const char * argv[]) {
	int n,t=0,a;
	cin >> n;

	int w[n];
	REP(i, n) {
		cin >> w[i];
		t += w[i];
	}
	a = t / 2;
	
	int h=0;
	int t1=0,t2=0,t3=0,t4=0;
	REP(i, n) {
		t1 += w[i];
		if(t1 >= a){
			t2 = t1;
			t1 = t1 - w[i];
			t3 += w[i];
			h = i + 1;
			break;
		}
	}
	FOR(j, h, n) {
		t3 += w[j];
		t4 += w[j];
	}
	
	if(abs(t1-t3) < abs(t2-t4)) {
		cout << abs(t1-t3) << endl;
	}
	else {
		cout << abs(t2-t4) << endl;
	}
	
	
	return 0;
}


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

using namespace std;

struct enban {
	int x, y, r, c;
};

int N;
enban ita[24];
int dp[1 << 24];
//若い番号の方が上になる[若い番号][大きい番号]
bool iscovered[24][24];

int main() {

	while (1) {

		for (int i = 0; i < (1 << 24); i++)dp[i] = -100;
		for (int i = 0; i < 24; i++)for (int j = 0; j < 24; j++)iscovered[i][j] = false;

		cin >> N;
		if (N == 0)break;
		for (int i = 0; i < N; i++) {
			cin >> ita[i].x >> ita[i].y >> ita[i].r >> ita[i].c;
		}

		for (int i = 0; i < N; i++) {
			for (int j = i + 1; j < N; j++) {
				if (pow(ita[i].x - ita[j].x, 2) + pow(ita[i].y - ita[j].y, 2) < pow(ita[i].r + ita[j].r, 2)) {
					iscovered[i][j] = true;
				}
			}
		}
		
		dp[0] = 0;

		for (int bit = 0; bit < (1 << N); bit++) {
			if (dp[bit] == -100)continue;

			bool cantuse[24] = {};
			for (int i = 0; i < N; i++) {
				//i枚目が使えるかどうか
				if ((bit >> i) & 1) {
					cantuse[i] = true;
					continue;
				}
				for (int j = 0; j < i; j++) {
					if (iscovered[j][i] && ((bit >> j) & 1) == 0) {
						//覆われていてかつ、覆ってるものがとられてない
						cantuse[i] = true;
						break;
					}
				}	
			}
			vector<int> candidate[4];//4色それぞれの候補
			for (int i = 0; i < N; i++)if (!cantuse[i])candidate[ita[i].c - 1].push_back(i);

			for (int i = 0; i < 4; i++) {
				//4色それぞれの候補を見る
				if (candidate[i].size() < 2)continue;
				for (int j = 0; j < candidate[i].size(); j++) {
					for (int k = j + 1; k < candidate[i].size(); k++) {
						//j番とk番を取り除く
						dp[bit + (1 << candidate[i][j]) + (1 << candidate[i][k])] = 
							max(dp[bit + (1 << candidate[i][j]) + (1 << candidate[i][k])], dp[bit] + 2);
					}
				}
			}

		}

		int ans = 0;
		for (int bit = 0; bit < (1 << N); bit++)ans = max(ans, dp[bit]);
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 68680
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int dp[105][105];
int p[105];
void calcu(int n)
{
  for(int i=0; i<=n; i++) dp[i][i] = 0;
  for(int num=2; num<=n; num++)// num to control the number of matrix involved in multiplication.
  {
    for(int i=1; i<=n-num+1; i++)
    {
      int j = i+num-1;
      dp[i][j] = (1 << 30);
      for(int k=i; k<j; k++)
      {
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k+1][j] + p[i-1]*p[k]*p[j]);
      }
    }

  }
  printf("%d\n", dp[1][n]);
}
int main()
{
  int n;
  scanf("%d", &n);
  for(int i=1; i<=n; i++)
  {
    scanf("%d%d", &p[i-1], &p[i]);
  }
  calcu(n);

  return 0;
}



Measured memory_bytes: 3212
#include <iostream>
#include <stdlib.h>
#include <math.h>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

int main(void){
    vector<int> v;
    
    int num;
    cin >> num;
    
    for(int i = 0;i < num;++i){
        int n;
        cin >> n;
        v.push_back(n);
    }
    
    bool isFirst = false;
    while (!v.empty()) {
        if(!isFirst){
            isFirst = true;
        }
        else{
            cout << " ";
        }
        cout << v.back();
        v.pop_back();
    }
    
    cout << endl;
    
    return 0;
}




Measured memory_bytes: 3056
n,q = map(int,input().split())
g=[[] for _ in range(n)]
ans = [0]*n
for i in range(n-1):
  a,b=map(int,input().split())
  g[a-1].append(b-1)
  g[b-1].append(a-1)
for j in range(q):
  p,x = list(map(int,input().split()))
  ans[p-1] += x
f=[1]*n
t=[0]
while t:
  v=t.pop()
  f[v]=0
  for k in g[v]:
    if f[k]:
      ans[k]+=ans[v]
      t.append(k)
print(*ans)

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

using namespace std;

using int64 = long long;
const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


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

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

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

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int N, M;
  cin >> N >> M;
  cout << N * M << endl;
}


Measured memory_bytes: 3212
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <math.h>
using namespace std;

int main(){
  int n;
  cin >> n;
  int A[n];
  for(int i = 0; i < n; i++){
    cin >> A[i];
  }
  int B[n];
  for(int i = 0; i < n; i++){
    cin >> B[i];
  }
  int C[n-1];
  for(int i = 0; i < n-1; i++){
    cin >> C[i];
  }

  int ans = 0;
  int memo = -10;
  for(int i = 0; i < n; i++){
    if(A[i] == memo + 1){
      ans += C[memo-1];
    }
    memo = A[i];
    ans += B[A[i]-1];
  }
  printf("%d\n", ans);
  return 0;
}


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

int main(){
  string a,b;
  cin >> a >> b;
  int c = stoi(a + b);
  for(int i = 1; i <= 1000 ; i++){
    if(c == i * i){
      cout << "Yes" <<endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 3600
A,B,M=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=min(a)+min(b)
for i in range(M):
	x,y,c=map(int,input().split())
	x-=1
	y-=1
	ans=min(ans,a[x]+b[y]-c)
print(ans)

Measured memory_bytes: 18612
#include<stdio.h>
int main()
{
    long long int sx,sy,tx,ty,x,y,n;
    scanf("%lld%lld",&sx,&sy);
    scanf("%lld%lld",&tx,&ty);
    x=tx-sx;
    y=ty-sy;
    //1st move
    for(n=0; n<y; n++)
    {
        printf("U");
    }
    for(n=0; n<x; n++)
    {
        printf("R");
    }
    //2nd move
    for(n=0; n<y; n++)
    {
        printf("D");
    }
    for(n=0; n<x; n++)
    {
        printf("L");
    }
    //3rd move
    printf("L");

    for(n=0; n<y+1; n++)
    {
        printf("U");
    }
    for(n=0; n<x+1; n++)
    {
        printf("R");
    }
    printf("D");
    //last move
    printf("R");
    for(n=0; n<y+1; n++)
    {
        printf("D");
    }
    for(n=0; n<x+1; n++)
    {
        printf("L");
    }
    printf("U\n");

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#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(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;

int main() {
    double A, B, H, M;
    cin >> A >> B >> H >> M;
    double hour = (60*H + M)/2/180*acos(-1);
    double minute = M*6/180*acos(-1);
    double ans = sqrt(A*A + B*B - 2*A*B*cos(hour - minute));
    printf("%.10f\n", ans);
    return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;

int main(){ 
  ll X;
  cin >>X;
  ll a=X/500;
  ll rem=X%500;
  ll b=rem/5;
  ll ans=a*1000+b*5;
  cout << ans <<endl;
}



Measured memory_bytes: 768