akhauriyash/Code-Regression huggingface dataset:
#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);}

map<string, int> generate(vector<int> v)
{
  map<string, int> T;
  if(v.size() == 1)
  {
    if(v[0] < 0) T["("+to_string(v[0])+")"] = v[0];
    else T[to_string(v[0])] = v[0];
    return T;
  }
  else
  {
    REP(i,v.size()-1)
    {
      vector<int> a,b;
      map<string, int> s,t;
      FOR(j,0,i) a.push_back(v[j]);
      FOR(j,i+1,v.size()-1) b.push_back(v[j]);
      s = generate(a);
      t = generate(b);
      for(auto m : s) for(auto n : t)
      {
        T["("+m.first+"*"+n.first+")"] = m.second * n.second;
        T["("+m.first+"+"+n.first+")"] = m.second + n.second;
        T["("+m.first+"-"+n.first+")"] = m.second - n.second;
      }
    }
    return T;
  }
}

void solve(vector<int> v)
{
  do
  {
    map<string, int> T = generate(v);
    for(auto a : T) if(a.second == 10)
    {
      printf("%s\n",a.first.c_str());
      return;
    }
  } while(next_permutation(v.begin(),v.end()));
  printf("0\n");
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> a(4);
  // FOR(i,1,9)FOR(j,1,9)FOR(k,1,9)FOR(l,1,9)
  // {
  //   a[0] = i; a[1] = j; a[2] = k; a[3] = l;
  //   solve(a);
  // }
  while(1)
  {
    REP(i,4) cin >> a[i];
    if(!accumulate(a.begin(),a.end(),0)) break;
    sort(a.begin(),a.end()); solve(a);
  }
  return 0;
}

Measured memory_bytes: 3288
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 1000000007
#define MAX 100
#define INF 800000000

int main(){
  int N;
  cin>>N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  vector<int> color(3,0);
  ll ans=3;
  color.at(0)++;
  bool flag2=true;
  for(int i=1;i<N;i++){
    if(color.at(0)==color.at(1)&&color.at(1)==color.at(2)){
      if(A.at(i)!=color.at(0)){
        flag2=false;
        break;
      }
      color.at(0)++;
      ans*=3;
    }else if(color.at(0)==color.at(1)){
      if(A.at(i)==color.at(0)){
        color.at(0)++;
        ans*=2;
      }else if(A.at(i)==color.at(2)){
        color.at(2)++;
      }else{
        flag2=false;
        break;
      }
    }else if(color.at(1)==color.at(2)){
      if(A.at(i)==color.at(0)){
        color.at(0)++;
      }else if(A.at(i)==color.at(1)){
        color.at(1)++;
        ans*=2;
      }else{
        flag2=false;
        break;
      }
    }else{
      if(A.at(i)==color.at(0)){
        color.at(0)++;
      }else if(A.at(i)==color.at(1)){
        color.at(1)++;
      }else if(A.at(i)==color.at(2)){
        color.at(2)++;
      }else{
        flag2=false;
        break;
      }
    }
    ans%=MOD;
  }
  if(flag2&&A.at(0)==0){
    cout<<ans<<endl;
  }else{
    cout<<0<<endl;
  }
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdlib>
#include <stack>
using namespace std;

int main() {
    stack<int> S;
    int a, b, x;
    string s;

    while ( cin >> s ) {
        if (s[0] == '+') {
            a = S.top();
            S.pop();
            b = S.top();
            S.pop();
            S.push(a + b);
        }else if (s[0] == '-') {
            b = S.top();
            S.pop();
            a = S.top();
            S.pop();
            S.push(a - b);
        }else if (s[0] == '*') {
            a = S.top();
            S.pop();
            b = S.top();
            S.pop();
            S.push(a * b);
        }else {
            S.push(atoi(s.c_str()));
        }
    }
    cout << S.top() << endl;

    return 0;
}


Measured memory_bytes: 3152
S = gets.chomp.split("")
Q = gets.chomp.to_i

flag = 0

Q.times do |i|
    i = gets.chomp.split(" ") 
    if  i == ["1"]
        flag = flag == 0 ? 1 : 0
    else
        if i[1] == "1"
            S.unshift(i[2]) if flag == 0
            S.push(i[2]) if flag == 1
        elsif i[1] == "2"
            S.unshift(i[2]) if flag == 1
            S.push(i[2]) if flag == 0
        end
    end
end

if flag == 0
    puts S.join()
else
    puts S.join().reverse
end


Measured memory_bytes: 28924
import numpy as np
A, B, H, M = map(int,input().split())
time = 60*H + M #経過時間(分)

rad_h = 2*np.pi-(np.pi/360)*time
rad_m = 2*np.pi-(np.pi/30)*M

A_x = A*np.cos(rad_h)
A_y = A*np.sin(rad_h)
B_x = B*np.cos(rad_m)
B_y = B*np.sin(rad_m)

v = np.array([A_x-B_x,A_y-B_y])

l = np.linalg.norm(v)
  
print(l)

Measured memory_bytes: 27272
/**
*    created: 10.07.2020 19:04:10
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    char a; cin >> a;
    if (a == 'a' || a == 'i' || a == 'u' || a == 'e' || a == 'o') cout << "vowel" << endl;
    else cout << "consonant" << endl;
    return 0;
}

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

int main() {
  int x;
  std::cin >> x;
  if (x ==7 || x == 5 || x == 3) {
    std::cout << "YES" << std::endl;
  } else {
    std::cout << "NO" << std::endl;
  }
  return 0;
}


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

struct edge { ll from, to, cost;};
edge es [1000020];
ll d[400000];
int v,e;

void shortest_path(int s){
    for (int i=0;i<e;i++) d[i]=INF;
    d[s]=0;
    int o=0;
    while(true){
        o++;
        bool update=false;
        for (int i=0;i<e;i++){
            edge e=es[i];
            if (d[e.from]!=INF && d[e.to]>d[e.from]+e.cost){
                d[e.to]=d[e.from]+e.cost;
                update=true;
            }
        }
        if (!update) break;
        if (o>e+10) {
            for (int j=0;j<v+10;j++){
            for (int i=0;i<e;i++){
            edge e=es[i];
            if (d[e.from]!=INF && d[e.to]>d[e.from]+e.cost){
                d[e.to]=-INF;
                update=true;
            }
        }
            }
            break;
        }
    }
}

int main(){
    ll p;
    cin >> v >> e >> p;
    rep(i,e){
        cin >> es[i].from >> es[i].to >> es[i].cost;
        es[i].cost=p-es[i].cost;
    }
    shortest_path(1);
    if (d[v]==-INF) cout << -1 << endl;
    else if (d[v]<0) cout << d[v]*(-1) << endl;
    else cout << 0 << endl;
}


Measured memory_bytes: 2432
"use strict";
function Main(input) {
    let lines = input.split("\n");
    let N = lines.shift() - 0;
    let V = lines.shift().split(/\s/).map((v) => v - 0);
    let O = V.filter((v, i) => i < N && i % 2 != 0);
    let E = V.filter((v, i) => i < N && i % 2 == 0);
    const same = (v) => v.every((v, i, a) => v == a[0]);
    if (same(O) && same(E) && O[0] != E[0]) {
        console.log(0);
        return;
    }
    let Ev = new Array(1e5 + 1);
    let Ov = new Array(1e5 + 1);
    E.forEach((v) => { Ev[v] = Ev[v] || [v, 0]; Ev[v] = [v, Ev[v][1] + 1]; });
    O.forEach((v) => { Ov[v] = Ov[v] || [v, 0]; Ov[v] = [v, Ov[v][1] + 1]; });
    Ev.sort((a, b) => b[1] - a[1]);
    Ov.sort((a, b) => b[1] - a[1]);
    if (Ov[1] == undefined) Ov[1] = [1, 0];
    if (Ev[1] == undefined) Ev[1] = [1, 0];
    let ans = 0;
    let e0 = E.length - Ev[0][1];
    let e1 = E.length - Ev[1][1];
    let o0 = O.length - Ov[0][1];
    let o1 = O.length - Ov[1][1];
    if (Ev[0][0] != Ov[0][0]) {
        ans = Math.min(...[e0+o0, e0+o1, e1+o0, e1+o1]);
    } else {
        ans = Math.min(...[e0+o1, e1+o0]);
    }

    console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 48524
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
#include<utility>
#include<vector>
using namespace std;

const long mod = 1000000007;
const long indlim = 5368709119;
long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; }return x; }
long lcm(long x, long y) { return(x / gcd(x, y)) * y; }
long fact(long x) { if (x == 0) return 1; else return((fact(x - 1) * x) % mod); }
long mybase(long N, long B) { if (N == 0) return 0; string S = ""; while (N != 0) { string M = to_string(N % B); N -= N % B; N /= B; S = M + S; }return stol(S); }
void indexsort(long* first, long* last, long* func) { sort(first, last, [&](long a, long b) {return func[a] < func[b]; }); }
//--------------------

int main() {

	long res = 0;
	string S; cin >> S;
	long slen = S.length();

	long now = slen - 1;
	long BC = 0;

	for (int i = now; i >= 0; i--) {
		if (S[i] == 'A') {res += BC; continue;}
		if (i >= 1) if (S[i - 1] == 'B' && S[i] == 'C') { BC++; i = i - 1;continue; }
		BC = 0;
	}

	cout << res << endl;

}

Measured memory_bytes: 640
import java.util.*;

public class Main{
	public static int ppow(long a,long b,long MOD) {
		long res=1;
		while(b>=1) {
			if(b%2==1)res=(res*a)%MOD;
			a=(a*a)%MOD;
			b>>=1;
		}
		return (int)res;
	}
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		String s=sc.next();
		int b=0;
		for(int i=0;i<s.length();i++) {
			if(s.charAt(i)=='1')b++;
		}
		int sum1=0,sum2=0;
		for(int i=0;i<s.length();i++) {
			if(b>=2) {
				sum1=sum1*2+(s.charAt(i)-'0');
				sum1%=b-1;
			}
			sum2=sum2*2+(s.charAt(i)-'0');
			sum2%=b+1;
		}
		for(int i=0;i<s.length();i++) {
			int S,P;
			if(s.charAt(i)=='0') {
				P=b+1;
				S=(sum2+ppow(2,s.length()-i-1,P))%P;
			}
			else {
				P=b-1;
				if(P==0) {
					System.out.println(0);
					continue;
				}
				S=(sum1+P-ppow(2,s.length()-i-1,P))%P;
			}
			int cnt=1;
			while(S>=1) {
				cnt++;
				S=S%Integer.bitCount(S);
			}
			System.out.println(cnt);
		}
	}
}

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
ll mod = 1000000007;

vector<ll> a, b, c, d;
ll solve(vector<ll> v, ll m, ll n) {
    ll ans = 0;
    ll len = v.size();

    /* rep(i, len) { cout << v[i] << " "; } */
    /* cout << endl; */

    if (len == n) {
        ll temp = 0;
        rep(i, c.size()) {
            if (v[b[i]] - v[a[i]] == c[i]) {
                temp += d[i];
            }
        }
        return temp;
    }

    if (len == 0) {
        repd(i, 1, m + 1) { ans = max(ans, solve({i}, m, n)); }
    } else {
        repd(i, v[len - 1], m + 1) {
            vector<ll> v_copy = v;
            v_copy.push_back(i);
            ans = max(ans, solve(v_copy, m, n));
        }
    }
    return ans;
}

int main() {
source:
    ll n, m, q;
    cin >> n >> m >> q;
    a.resize(q);
    b.resize(q);
    c.resize(q);
    d.resize(q);
    rep(i, q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--;
        b[i]--;
    }
    ll ans = solve({}, m, n);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3616
import fractions
a,b,c,d=map(int,input().split())
e=c*d//fractions.gcd(c,d)
num_c = b//c-(a-1)//c
num_d = b//d-(a-1)//d
num_e = b//e-(a-1)//e

count=b-a+1-num_c-num_d+num_e
print(count)

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

int main(){
int N;
  cin >> N;
  vector<pair<int,int>> p(N);
  rep (i,N) cin >> p.at(i).second >> p.at(i).first ;
  
  sort(p.begin(),p.end());
  
  int t = 0;
  bool check = true;
  rep(i,N){
    t += p.at(i).second;
    if (t > p.at(i).first) check = false;
  }
  cout << ( check ? "Yes" : "No" ) << endl;
  
  return 0;  
}

Measured memory_bytes: 1792
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

def main():
	s = input()
	ret='x'*len(s)
	print(ret)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 38256
N, W = map(int, input().split())
A = [list(map(int, input().split())) for i in range(N)]
dp = [[-1]*(W+1) for i in range(N+1)]
dp[0][0] = 0
for i in range(1,N+1):
  w,v = A[i-1]
  for j in range(W+1):
    dp[i][j] = dp[i-1][j]
    if j >= w and dp[i-1][j-w] != -1:
      dp[i][j] = max(dp[i-1][j-w]+v,dp[i][j])
print(max(dp[-1]))

Measured memory_bytes: 120300
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define f(a,b) for(int i = a; i < b; i++)
#define mod 1000000007
#define inf (1LL<<60)
#define all(x) (x).begin(), (x).end()
#define prDouble(x) cout << fixed << setprecision(10) << x
#define triplet pair<ll,pair<ll,ll>>
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
const int MAXN = 500005;
using namespace std;
int arr[MAXN],dp[MAXN];
int main() {
   /*ifstream cin("input.txt");
   ofstream cout("output.txt");*/
   fast_io;
   bool flag=true;
   std::vector<ll> suffix;
   ll n,mini=INT_MAX;cin>>n;
   ll arr[n];
   for(int i=0;i<n;i++){
   		cin>>arr[i];
   }
   for(int i=n-1;i>=0;i--){
   		mini=min(mini,arr[i]);
   		suffix.pb(mini);
   }
   reverse(suffix.begin(),suffix.end());
   for(int i=0;i<n-1;i++){
   		if(arr[i]>suffix[i+1]&&abs(arr[i]-suffix[i+1])>=2){
   			flag=false;
   			break;
   		}
   }
   if(flag){
   		cout<<"Yes"<<endl;
   }
   else{
   		cout<<"No"<<endl;
   }
   return 0;
}


   	



Measured memory_bytes: 4928
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

void test(){
    int n;
    cin >>n;
    auto IN = [&](int x){
        return 0<=x && x<n;
    };

    for(int sub=1; sub<n; ++sub){
        for(int a=1; a<n; ++a){
            int b = a-sub;
            if(b <= 0) continue;

            vector<bool> used(n);
            int p = 0;
            bool f = true;
            bool ok = true;
            while(p!=n-1){
                if(!IN(p) || used[p]){
                    ok = false;
                    break;
                }
                used[p] = true;
                if(f) p += a;
                else p -= b;
                f = !f;
            }

            if(ok){
                printf(" ab %d %d:", a, b);
                used[p] = true;
                rep(i,n)if(used[i]) printf(" %d", i);
                printf("\n");
            }
        }
    }
}

int main(){
    // test();

    int n;
    cin >>n;
    vector<ll> s(n);
    rep(i,n) cin >>s[i];

    auto IN = [&](int x){
        return 0<=x && x<n;
    };

    ll ans = 0;
    for(int w=1; w<n; ++w){
        int a = n-1, b = a-w;
        int l=0,r=n-1;
        ll t=0;
        unordered_set<int> vis;
        while(b>0 && l!=r && IN(l) && IN(r) && !vis.count(l) && !vis.count(r)){
            t += s[l];
            t += s[r];
            ans = max(ans, t);
            vis.insert(l);
            vis.insert(r);

            l += w;
            r -= w;
            b -= w;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5168
n,a,b,c,d = map(int,input().split())
s = str(input())
if "##" in s[min(a,b):max(c,d)-1]:
  print("No")
  exit()
if c > d:
  if "..." in s[b-2:d+1]:
    print("Yes")
  else:
    print("No")
else:
  print("Yes")

Measured memory_bytes: 3572
n = int(input())
a = list(map(int,input().split()))
count = 0
r = 1
l = 0
now = a[0]
while l < n:

    while True:
        if r < n and now + a[r] == now^a[r]:
            now += a[r]
            count += r-l
            r += 1
        else:
            break
    if l == r:
        now = a[l]
        r += 1
    elif l < n:
        now -= a[l]
        l += 1
print(count+n)

Measured memory_bytes: 24580
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <array>
#include <cassert>
#include <utility>
#include <vector>
// #include <atcoder/all>

template <class InputIterator>
std::ostream& range_output(std::ostream& os_arg, InputIterator first_arg, InputIterator last_arg){ if(first_arg != last_arg){ do{ os_arg << *(first_arg++); if(first_arg == last_arg) break; os_arg << ' '; } while(true); }  return os_arg; }
template <class Tp> std::ostream& operator << (std::ostream& os_arg, const std::vector<Tp>& arr_arg){ return range_output(os_arg, arr_arg.cbegin(), arr_arg.cend()); }
template <class Tp, std::size_t Size> std::ostream& operator << (std::ostream& os_arg, const std::array<Tp, Size>& arr_arg){ return range_output(os_arg, arr_arg.cbegin(), arr_arg.cend()); }
template <class S, class T> std::ostream& operator << (std::ostream& os_arg, const std::pair<S, T>& pair_arg){ return os_arg << '(' << pair_arg.first << ", " << pair_arg.second << ')'; }

#ifndef ONLINE_JUDGE
    template <typename Head> void dump_out(Head head_arg){ std::cerr << head_arg << '\n'; }
    template <typename Head, typename... Tail>
    void dump_out(Head head_arg, Tail... tail_args){ std::cerr << head_arg << ", "; dump_out(tail_args...); }
    #define dump(...) do { std::cerr << "[in line " << __LINE__ << "] " << #__VA_ARGS__ << " : "; dump_out(__VA_ARGS__); } while(false)
#else
    #define dump(...) (void(0))
#endif


constexpr int mod = 998244353;

int main(void){
    std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); 
    std::cout << std::fixed << std::setprecision(16);
    
    int n, k; std::cin >> n >> k;
    std::vector<std::pair<int, int>> S(k);
    for(int i = 0; i < k; ++i) std::cin >> S[i].first >> S[i].second;
    // [n - r, n - l]
    std::vector<long long int> D(2 * n + 100, 0), E(2 * n + 100, 0);
    const int centor = n + 10;
    D[centor] = 1; E[centor] = 1;
    for(int i = 2, I = centor + 1; i <= n; ++i, ++I){
        for(int idx = 0; idx < k; ++idx){
            D[I] += E[I - S[idx].first] - E[I - S[idx].second - 1];
        }
        D[I] %= mod; if(D[I] < 0) D[I] += mod;
        E[I] = (D[I] + E[I - 1]) % mod;
    }
    std::cout << D[2 * n + 9] << '\n';


    

    return 0;
}

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

int main()
{
    int N, K;
    int number = 1;
    cin >> N >> K;
    for (int i = 0; i < N; i++)
    {
        if(number + K < number * 2){
            number += K;
        }
        else{
            number *= 2;
        }
    }
    cout << number;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int A[200050];
int main()
{
	int N;
	scanf("%d",&N);
	for(int i=1;i<=N;i++)
		scanf("%d",&A[i]);
	int Bow=1;
	for(int i=1;i<=N;i++)
		if(A[i]==Bow)
			Bow++;
	if(Bow==1) cout<<-1;
	else cout<<N-Bow+1;
	return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
 
#define pb push_back
#define mk make_pair
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define sf(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define pf(a) printf("%d\n",a);
#define pfl(a) printf("%lld\n",a);
#define TEST int test; cin >> test;while(test--)
#define ii pair<int,int>
#define iil pair<ll,ll>
#define loop(i,a,b) for(int i = a ; i < b ; i++)
#define INF 2147483647
 
 
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const double pi = acos(-1.0);
 
 
void solve()
{
   string s;
   cin >> s;
   if(s =="ABC") cout << "ARC" <<endl;
   else cout <<"ABC" <<endl;
}
 
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //TEST
    solve();
    return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<cstring>
#include<stdio.h>
using namespace std;
string getsw(string s)
{
	for(int i=0;i<s.length();i++)
	{
		if(s[i]>='A'&&s[i]<='Z')
		s[i]=s[i]+32;
	}
	return s;
}
int main()
{
	int cnt=0;
	int j;
	string s,s1;
	char a;
	cin>>s;
	s=getsw(s);
	while(cin>>s1)
	{
		if(s1=="END_OF_TEXT")
		break;
		s1=getsw(s1);
		if(s1[s1.length()-1]=='.')
		s1=s1.substr(0,s1.length()-1);
		j=s.compare(s1);
		if(j==0)
		cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int h,w;
    cin >> h >> w;
    vector<int> a(h*w);
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            if(i%2) cin >> a[i*w+w-1-j];
            else    cin >> a[i*w+j];
        }
    }
    vector<string> ans;
    for(int i = 0; i < h*w-1; i++) {
        if(a[i]%2){
            a[i]--;
            a[i+1]++;
            int r=i/w;
            int c=i%w;
            int nr=(i+1)/w;
            int nc=(i+1)%w;
            if(r%2) c=w-1-c;
            if(nr%2) nc=w-1-nc;
            string tmp=to_string(r+1)+" "+to_string(c+1)+" "+to_string(nr+1)+" "+to_string(nc+1);
            ans.emplace_back(tmp);
        }
    }
    cout << ans.size() << "\n";
    for(int i = 0; i < ans.size(); i++) cout << ans[i] << "\n";

    return 0;
}

Measured memory_bytes: 8484
package main

import (
	"fmt"
	"sort"
)

type factor struct {
	num int
	count int
}

type Factors []factor

func (f Factors) Len() int {
	return len(f)
}

func (f Factors) Less(i, j int) bool {
	return f[i].num < f[j].num
}

func (f Factors) Swap(i, j int) {
	f[i], f[j] = f[j], f[i]
}

func main() {
	var N, K int
	fmt.Scanf("%d %d", &N, &K)

	var a, b int
	factors := make([]factor, 0)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d %d", &a, &b)
		f := factor{a, b}
		factors = append(factors, f)
	}

	sort.Sort(Factors(factors))

	cur := 0
	for _, v := range factors {
		cur += v.count
		if cur >= K {
			fmt.Println(v.num)
			return
		}
	}
}


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

const int N = 200233, mod = 1000000007;
int n, m, f[N];
char s[N];

int main() {
  scanf("%d%d%s", &n, &m, s + 1);
  if (*min_element(s + 1, s + 1 + m) == *max_element(s + 1, s + 1 + m)) {
    int x = 2, y = 1;
    for (int i = 1; i <= n; i++) {
      y = (y + x) % mod;
      x = (mod + y - x) % mod;
    }
    printf("%d\n", x);
    return 0;
  }
  int limit, x = 1;
  while (x + 1 <= m && s[x + 1] == s[1]) x++;
  limit = x | 1;
  for (int i = x + 1, j = 0; i <= m; i++) {
    if (s[i] != s[1]) {
      if (j & 1) limit = min(limit, j);
      j = 0;
    } else {
      ++j;
    }
  }
  if (n & 1) {
    puts("0");
    return 0;
  }
  n >>= 1;
  limit = min(n, (limit + 1) >> 1);
  f[0] = 1;
  for (int i = 1; i <= n; i++) {
    f[i] = ((long long) mod + f[i - 1] + f[i - 1] - (i > limit ? f[i - limit - 1] : 0)) % mod;
  }
  int ans = 0;
  for (int i = 1; i <= limit; i++) {
    ans = (ans + (long long) (mod + f[n - i] - (n > i ? f[n - i - 1] : 0)) * i * 2) % mod;
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 896
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			int n = Integer.parseInt(br.readLine());
			String[] x = br.readLine().split("\\s");
			String[] y = br.readLine().split("\\s");
			double d = 0;
			List<Double> mdList = new ArrayList<>();
			
			// マンハッタン距離（p = 1 のとき）
			for (int i = 0; i < n; i++) {
				d += Math.abs(Double.parseDouble(x[i]) -Double.parseDouble(y[i]));
			}
			mdList.add(d);
			d = 0;
			
			// ユークリッド距離（p = 2 のとき）
			for (int i = 0; i < n; i++) {
				d += Math.pow(Math.abs(Double.parseDouble(x[i]) -Double.parseDouble(y[i])), 2);
			}
			mdList.add(Math.sqrt(d));
			d = 0;
			
			// ユークリッド距離（p = 3 のとき）
			for (int i = 0; i < n; i++) {
				d += Math.pow(Math.abs(Double.parseDouble(x[i]) -Double.parseDouble(y[i])), 3);
			}
			mdList.add(Math.cbrt(d));
			d = 0;
			
			// チェビシェフ距離（p = ∞）
			for (int i = 0; i < n; i++) {
				d = Math.max(d, Math.abs(Double.parseDouble(x[i]) -Double.parseDouble(y[i])));
			}
			mdList.add(d);
			
			for (Double md: mdList) {
				System.out.printf("%.10f\n", md);
			}
			
		} catch (NumberFormatException | IOException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}
		
		
	}

}



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

typedef long long ll;
typedef pair<int, int> P;

int MOD = 1e9 + 7;
ll INF = 1e18;

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

int main(){
    ll n, m; cin>>n>>m;
    vector<int> a(n+10);
    for(int i=0; i<n; i++) cin>>a[i];

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

    map<int, ll> mod_sum;
    set<int> s;
    for(int i=0; i<=n; i++) {
        mod_sum[sum[i] % m]++;
        s.insert(sum[i] % m);
    }

    ll ans=0;
    for(auto i : s){
        ans += (mod_sum[i]*(mod_sum[i] - 1)) / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 8320
#include <stdio.h>
int main(void)
{
  int n, i;
  scanf("%d", &n);
  
  for (i = 1; i <= 9; i++) {
    if (n % i == 0 && n / i <= 9) {
      printf("Yes");
      break;
    }
  }
  if (i >= 10) {
    printf("No");
  }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll n,ans=0;
    cin >> n;
    ll a[n];
    for (ll i=0;i<n;i++){
        cin >> a[i];
    }
    for (ll i=0;i<n;i++){
        if (a[a[i]-1]==i+1)ans++;
    }
    cout << ans/2 << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<bitset>
using namespace std;
const int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};
#define INF 1e+8
#define EPS 1e-8
#define rep(i,j) for(int i = 0; i < (j); i++)
#define reps(i,j,k) for(int i = (j); i < (k); i++)
typedef long long ll;
typedef pair < int , int > Pii;
class P{
    public:
    int num;
    int cnt;
    bool used[10];
    P(){}
    P(int num,int cnt,bool a[10]):num(num),cnt(cnt){
        for(int i = 0; i < 10; i++){
            used[i] = a[i];
        }
    }
};
int bond(int x,int y){
    stringstream ss1;
    ss1 << x;
    stringstream ss2;
    ss2 << y;
    string ans = ss1.str() + ss2.str();
    stringstream Ans;
    Ans << ans;
    int res;
    Ans >> res;
    return res;
}
int main(){
    int n;
    int m;
    while(scanf("%d%d",&n,&m),(n|m)){
        int card[10];
        set<int> S;
        queue<P> Q;
        for(short i = 0; i < n; i++){
            bool x[10]={0};
            x[i] = 1;
            scanf("%d",&card[i]);
            Q.push(P(card[i],1,x));
        }
        short ans = 0;
        while( Q.size() ){
            P p = Q.front();Q.pop();
            if(p.cnt == m){
                if(S.find(p.num) == S.end())ans++,S.insert(p.num);
            }
            else{
                for(int i = 0; i < n; i++){
                    if(p.used[i] == 0){
                        p.used[i] = 1;
                        Q.push(P(bond(p.num,card[i]),p.cnt+1,p.used));
                        p.used[i] = 0;
                    }
                }
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 1444
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

Int n, ans;
vector<Int> a;
map<Int, Int> m;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	a.resize(n);
	for(auto &i:a) cin >> i;
	for(Int i=0; i<n; ++i){
		if(m.empty() || a[i] < m.begin()->first){
			m.insert(make_pair(a[i], 1));
			++ans;
			continue;
		}
		if(a[i] == m.begin()->first){
			++m[a[i]];
			++ans;
			continue;
		}
		auto j = m.lower_bound(a[i]);
		--j;
		if(j->second == 1){
			m.erase(j->first);
		}else{
			--m[j->first];
		}
		if(m.find(a[i]) == m.end()){
			m.insert(make_pair(a[i], 1));
		}else{
			++m[a[i]];
		}
	}
	cout << ans << "\n";
}

Measured memory_bytes: 7168
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}
const int INF = 1001001001;

int main(){
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    int ans = INF;
    rep(div, 1<<h-1) {
        int g = 0;
        vector<int> id(h);
        rep(i, h) { 
            id[i] = g;
            if (div>>i&1) ++g;
        }
        ++g;

        vector<vector<int>> c(g, vector<int>(w));
        rep(i, h)rep(j, w) c[id[i]][j] += s[i][j] - '0';

        int num = g-1;
        vector<int> now(g);
        auto add = [&](int j) {
            rep(i, g) now[i] += c[i][j];
            rep(i, g) {
                if (now[i] > k) {
                    num++;
                    now = vector<int>(g);
                    return false;
                }
            }
            return true;
        };
        rep(j, w) {
            if (!add(j)) {
                if (!add(j)) { 
                    num = INF;
                    break;
                }
            }
        }
        chmin(ans, num);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
int main()
{
cin>>n;
if(n==25 )cout<<"Christmas"<<endl;
if(n==24 )cout<<"Christmas Eve"<<endl;
if(n==23 )cout<<"Christmas Eve Eve"<<endl;
if(n==22 )cout<<"Christmas Eve Eve Eve"<<endl;
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define REP1(j,n) for(int j=0;j<(int)n;++j)
#define REPD(i,n) for(int i=n;i>=0;--i)
#define REPD1(j,n) for(int j=n;j=>0;--j)
#define REPS(i,n) for(int i=1;i<=(int)n;++i)
#define REPS1(j,n) for(int j=1;j<=(int)n;++j)
#define rep(i,a,n) for(int i=a;i<=(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;

int main(void) {
	int n;
	cin >> n;
	int a, mx=0, mn=10000;
	REP(i, n) {
		cin >> a;
		mn = min(mn, a);
		mx = max(mx, a);
	}
	cout << mx - mn << endl;
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
using ll=long long;
using ii=pair<ll,ll>;

int main() {
    int answers[] = {0,1,2,3};
    int a, b;
    //scanf("%d", &a);
    //scanf("%d", &b);
    cin>>a;
    cin>>b;
    answers[a] = 0;
    answers[b] = 0;
    for (int i = 0; i < 4; i++) {
        if (answers[i] != 0) {
            printf("%d", answers[i]);
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;

int n, m, u, v;
int a[100050], fa[100050], pos[100050];

int find(int x){
	if(fa[x] == x) return x;
	else return fa[x] = find(fa[x]);
}
 
int main(){
	scanf("%d %d", &n, &m);
	for(int i = 1; i <= n; i ++){
		scanf("%d", &a[i]);
		fa[i] = i;
		pos[a[i]] = i;
	}
	for(int i = 1; i <= m; i ++){
		int u, v;
		scanf("%d %d", &u, &v);
		fa[find(u)] = find(v);
	}
	int res = 0;
	for(int i = 1; i <= n; i++){
		if(find(i) == find(pos[i])) res++;
	}
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_que<int> pque;//これは大きい順
//typedef priority_que<int, vector<int>, greater<int>> pque;//これは小さい順


int main(){
	int x[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k;
	cin >> k;
	cout << x[k-1] << endl;

  return 0;
}


Measured memory_bytes: 256
def f(a,x):
    l=[]
    while x!=0:
        l.append(x%a)
        x//=a
    return sum(l)

def main():
    N=int(input())
    MIN=100000
    for k in range(N+1):
        MIN=min(MIN,f(9,k)+f(6,(N-k)))
    return MIN

if __name__=="__main__":
    print(main())

Measured memory_bytes: 9140
#include <bits/stdc++.h>
#define inf (long long)(1e9)
using namespace std;

long long n, cnt = 0;
vector<string> v;
long long memo[205][205] = {0};

long long solve();

int main() {
  cin >> n;
  v.resize(n);
  for(int i = 0; i < n; ++i) cin >> v[i];
  for(int i = 0; i < n; ++i)
    for(int j = 0; j < n; ++j)
      if(i == j)
        memo[i][j] = 0;
      else if(v[i][j] == '1')
        memo[i][j] = 1;
      else
        memo[i][j] = inf;
  cout << solve() << endl;
  return 0;
}

long long solve() {
  for(int k = 0; k < n; ++k)
    for(int i = 0; i < n; ++i)
      for(int j = 0; j < n; ++j) {
        memo[i][j] =
            min(memo[i][j], memo[i][k] + memo[k][j]);
      }
  for(int i = 0; i < n; ++i)
    for(int j = 0; j < n; ++j)
      for(int k = 0; k < n; ++k)
        if(memo[i][j] != inf &&
           (memo[i][j] % 2) !=
               (memo[i][k] + memo[k][j]) % 2)
          return -1;
  long long ans = 0;
  for(int i = 0; i < n; ++i)
    for(int j = 0; j < n; ++j) {
      ans = max(ans, memo[i][j]);
    }
  return ans + 1;
}


Measured memory_bytes: 768
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val a = Array.fill(n)(sc.nextLong())

  val mod = 1000000007
  def plus(a: Long, b: Long): Long = (a + b) % mod

  val b = a.scanRight(0L)(plus)
  var ans = 0L

  for {
    i <- 0 until n
  } {
    ans = plus(ans, a(i) * b(i+1))
  }

  println(ans)
}


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

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SIZE(a) ((int)(a).size())

const int N = 200005;

int n;

int fenw[N];

int go(int pos) {
	int result = 0;
	for (int i = pos + 1; i <= n; i += i & -i) {
		result += fenw[i];
	}
	return result;
}

void inc(int pos) {
	for (int i = pos + 1; i > 0; i -= i & -i) {
		++fenw[i];
	}
}

ll inv(vector<int> a) {
	fill(fenw, fenw + n + 1, 0);
	ll result = 0;
	for (auto& e : a) {
		result += go(e);
		inc(e);
	}
	return result;
}

ll compute(string a, string b) {
	map<char,int> cnt, now;
	map<pair<char,int>, int> ids;
	vector<int> arr;
	REP(i, SIZE(a)) {
		char c = a[i];
		ids[{c, cnt[c]}] = i;
		++cnt[c];
	}
	REP(i, SIZE(b)) {
		char c = b[i];
		arr.push_back(ids[{c, now[c]}]);
		++now[c];
	}
	return inv(arr);
}

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

	string s;
	cin >> s;
	n = SIZE(s);
	map<char,int> cnt;
	for (auto& c : s) ++cnt[c];
	int odd = 0;
	char center;
	for (auto& item : cnt) {
		if (item.second % 2) ++odd, center = item.first;
	}
	if (odd > 1) {
		cout << -1 << '\n';
		return 0;
	}
	string t;
	map<char, int> now;
	for (auto& c : s) {
		if (now[c] < cnt[c]/2) t += c;
		++now[c];
	}
	string half = t;
	reverse(half.begin(), half.end());
	if (odd) t += center;
	t += half;

	cout << compute(s, t) << '\n';

	return 0;
}

Measured memory_bytes: 16268
#include "bits/stdc++.h"
#define REP(i,n,N) for(int i=(n); i<(N); i++)
#define RREP(i,n,N) for(ll i=(N-1); i>=n; i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define p(s) cout<<(s)<<endl
#define p2(a,b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll mod=1e9+7;
const int inf=1e9;

int dp[310][310];
int n;
int w[310];
int main() {
    while(cin>>n, n){
        REP(i,0,n) REP(j,0,n) dp[i][j] = 0;
        REP(i,0,n) cin>>w[i];
        for(int k=1;k<n;k++){
            REP(L,0,n-k){
                int R = L + k;
                if(dp[L+1][R-1] == k-1) dp[L][R] = max(dp[L][R], dp[L+1][R-1] + (abs(w[L]-w[R]) <= 1)*2);
                REP(i,L,R) dp[L][R] = max(dp[L][R], dp[L][i] + dp[i+1][R]);
            }
        }
        p(dp[0][n-1]);
    }


    return 0;
}


Measured memory_bytes: 3448
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll n,r;
    cin>>n>>r;
    if(n>=10)cout<<r<<endl;
    else{
        cout<<r+100*(10-n)<<endl;
    }
}


Measured memory_bytes: 256
N = int(input())
s = input()
t = input()

mod = int(1e9)+7

ans = 1
bef = 0
i = 0
while i < N:
    ##print(bef,ans,i)
    if bef == 0:##最初
        if s[i] == t[i]:##たてならべ
            bef = 1
            ans *= 3
        else:
            bef = 2
            ans *= 6
            i += 1
    elif bef == 1:##前がたてならべ
        if s[i] == t[i]:
            ans = (ans*2)%mod
        else:
            bef = 2
            ans = (ans*2)%mod
            i += 1
    else:##前がよこならべ
        if s[i] == t[i]:
            bef = 1
        else:
            ans = (ans*3)%mod
            i += 1
    i += 1

print(ans%mod)

Measured memory_bytes: 3064
import itertools
from collections import defaultdict


def main():
    N = int(input())
    if N == 1:
        print(1)

    else:
        XY = [list(map(int, input().split())) for _ in range(N)]

        dd = defaultdict(int)

        for xy1, xy2 in itertools.combinations(XY, 2):
            a = (xy2[0] - xy1[0], xy2[1] - xy1[1])
            b = (-a[0], -a[1])
            dd[a] += 1
            dd[b] += 1

        print(N - max(dd.values()))


main()


Measured memory_bytes: 3828
use proconio::input;

fn main() {
    input! {
        hp1: i64,
        atk1: i64,
        hp2: i64,
        atk2: i64,
    }
    let (s1, s2) = ((hp1-1)/atk2, (hp2-1)/atk1);
    let ans = if s1 >= s2 { "Yes" } else { "No" };
    println!("{}",ans)

}

Measured memory_bytes: 2176
N = int(input())
A = list(map(int,input().split()))
Asum = sum(A)
Asum2 = 0
c = 0
for mid in range(len(A)):
    if 2*Asum2 > Asum:
        c =1
        Asum3 = Asum2
        mid -= 1
        Asum2 -= A[mid]
        break
    Asum2 += A[mid]
if c == 0:
    if 2*Asum2 > Asum:
        Asum3 = Asum2
        mid -= 1
        Asum2 -= A[mid]
if abs(Asum - 2*Asum2) <= abs(Asum - 2*Asum3):
    Asuma = Asum2
else:
    Asuma = Asum3
c = abs(Asum - 2*Asuma)
print(c)
        
    

Measured memory_bytes: 26220
#include<stdio.h>
#include<string.h>
int main(void)
{
  char a[10];
  scanf("%s",a);
  if(strcmp(a,"Sunny")==0){
    printf("Cloudy");
  }
  if(strcmp(a,"Cloudy")==0){
    printf("Rainy");
  }
  if(strcmp(a,"Rainy")==0){
    printf("Sunny");
  }  
  
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
       
    using namespace std;
    #define ll long long
    #define ld long double
    #define pll pair<long long,long long>
    #define vll vector<long long>
    #define pb push_back
    #define mp make_pair
    #define ff first
    #define ss second
    #define deb(x) cout << #x << "=" << x << endl
    #define F(i,a,b) for(ll i=a;i<=b;i++)
    #define RF(i,a,b) for(ll i=a;i>=b;i--)
    #define in(a,n) F(i,0,n-1)cin>>a[i]
    #define vi vector<int>
    #define out(a,n) F(i,0,n-1)cout<<a[i]<<" ";cout<<endl
    #define mod 998244353
    #define trace1(x)                cerr<<#x<<": "<<x<<endl
    #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
    #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
    #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
    #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
    #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
    #define int long long
    set < ll> primes;
     
   // int n,m;
    
   
    int ans;
    vector<int>d;
    vector<vector<int>>v;
    vector<int>par;
    vector<int>tin,tout;
     
     
    void dfs(int u,int p,int dep)
    {
        //cout<<"h\n";
        //trace3(u,p,dep);
        par[u]=p;
        d[u]=dep;
        tin[u]=++ans;
        for(auto x:v[u])
        {
            if(x==p)continue;
            
          dfs(x,u,dep+1);
        }
        tout[u]=++ans;
    }
    
    bool isancesstor(int u,int v)
    {
        return (tin[u]<=tin[v] and tout[u]>=tout[v]);
    }
    int32_t main()
    {
    	ios::sync_with_stdio(false);
        cin.tie(NULL);
        
        int t=1;
        //cin>>t;
        while(t--)
        {
            string s,t;
            cin>>s>>t;
            int n=s.size();
            int ans=0;
            for(int i=0;i<n;i++)
            {
                if(s[i]!=t[i])
                {
                    ans++;
                }
            }
            cout<<ans<<'\n';
           
        }
        
        
       
    }

Measured memory_bytes: 3812
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String name[] = new String[3];
		for (int i = 0; i < 3; i++) {
			name[i] = sc.next();
		}
		for (int i = 0; i < 3; i++) {
			System.out.print(name[i].charAt(0));
		}

	}

}


Measured memory_bytes: 9680
from collections import deque, Counter as cnt
from collections import defaultdict as dd
from operator import itemgetter as ig
from bisect import bisect_right as bsr
from math import factorial, ceil, floor
import sys
sys.setrecursionlimit(1000000)

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)


def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]


def nlist(n, v):
    if not n:
        return [] if type(v) is list else v
    return [nlist(n[1:], v) for _ in range(n[0])]


def yesno(v, yes="Yes", no="No", upper=False):
    if upper:
        print([yes.upper(), no.upper()][not v])
    else:
        print([yes, no][not v])


def main():
    """エントリーポイント"""
    N, K = input(int, int)
    H = input([int, N])
    H.sort()
    if N <= K:
        print(0)
        return
    if K == 0:
        print(sum(H))
        return
    print(sum(H[:-K]))


if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()


Measured memory_bytes: 27484
# https://atcoder.jp/contests/agc017/tasks/agc017_a

from math import factorial
n, p = map(int, input().split())

nums = [int(i) for i in input().split()]

odd = 0
even = 0
for num in nums:
    if num % 2 == 0:
        even += 1
    else:
        odd += 1
# ans = 0
# if p == 0:
#     e = 2 ** even
#     o = 0
#     for i in range(0, odd + 1, 2):
#         o += factorial(odd) // (factorial(odd - i) * factorial(i))
#     ans += e * o
# elif p == 1:
#     e = 2 ** even
#     o = 0
#     for i in range(1, odd + 1, 2):
#         o += factorial(odd) // (factorial(odd - i) * factorial(i))
#     ans += e * o
# print(ans)

# 別解
ans = 0
if p == 0 and odd == 0:
    ans += 2 ** even
else:
    ans += (2 ** even) * (2 ** odd // 2)
print(ans)

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

int main() {
  int n, m;
  cin >> n;
  string result;
  m = n % 10;

  if(m == 3){
      result ="bon";
  }else if(m ==0 || m==1 || m==6 || m==8){
      result = "pon";
  }else{
      result = "hon";
  }

  cout << result << endl;
}


Measured memory_bytes: 3592