akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;

const long long INF = 100000000000000000;



class Data{
public:
  int point;
  bitset<9> explored;
  Data(){
    for (int i = 1; i <= 8;i++)
      explored.set(i);
  }
};

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

  //辺を持つかどうか
  bool V[N + 1][N + 1];

  for (int i = 1; i <= N;i++){
    for (int j = 1; j <= N;j++){
      V[i][j] = false;
    }
  }

  for (int i = 0; i < M; i++)
  {
    int a, b;
    cin >> a >> b;
    V[a][b] = true;
    V[b][a] = true;
  }

  stack<Data> que;
  Data start;
  start.point = 1;
  start.explored.reset(1);
  que.push(start);

  int answer = 0;
  while (!que.empty())
  {
    Data now = que.top();
    que.pop();
    bool ans = true;
    //cout << now.explored << endl;
    for (int i = 1; i <= N; i++)
    {
      if (now.explored[i] == 1)
        ans = false;
    }
    if(ans)
      answer++;

    for (int i = 1; i <= N; i++)
    {
      if(V[now.point][i]==true && now.explored[i]==1){
        //cout << "y" << endl;
        Data next;
        next.point = i;
        next.explored = now.explored;
        next.explored.reset(i);
        que.push(next);
      }
    }
  }

  cout << answer << endl;
}


Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define link(x) for(edge *j=h[x];j;j=j->next)
#define inc(i,l,r) for(int i=l;i<=r;i++)
#define dec(i,r,l) for(int i=r;i>=l;i--)
const int MAXN=3e5+10;
const double eps=1e-8;
const int mod=1e9+9;
#define ll long long
using namespace std;
struct edge{int t,v;edge*next;}e[MAXN<<1],*h[MAXN],*o=e;
void add(int x,int y,int vul){o->t=y;o->v=vul;o->next=h[x];h[x]=o++;}
ll read(){
    ll x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
    return x*f;
}




int n,k;

bool vis[MAXN];
int main(){
    n=read();k=read();
    inc(i,1,k){
	int num=read();int x;
	inc(j,1,num)vis[read()]=1;
    }
    int ans=0;
    inc(i,1,n)if(!vis[i])ans++;
    printf("%d\n",ans);
    return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
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 (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

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

    ll N;
    string S;
    cin >> N >> S;

    ll res = 0;
    REP(i, N){
    	int j = i;
    	while(j<N && S[i]==S[j]) j++;
    	res++;
    	i = j-1;
    }
    cout << res << endl;
    return 0;
}

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

int main(){
    int A,B;
    cin >> A >> B;

    int m;
    m = max(A,B);
    if(A == B){
        cout << A * 2 << endl;
    }
    else{
        cout << m + m - 1 << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define GET_ARRAY_SIZE(a)   (sizeof(a)/sizeof(a[0]))
#define LL long long
#define VI vector<int>
#define VL vector<LL>
#define VII vector< vector<int> >
#define VLL vector< vector<LL> >
#define VS  vector<string>
#define VSS vector< vector<string> >
#define PII pair<int,int>
#define PIS pair<int,string>
#define PSI pair<string,int>
#define PLL pair<LL,LL>
const LL MOD = 1000000007;
const LL INF = 1e16;
LL facctorialMethod(int k);
int main(){
    LL a,b,c;
    cin >> a >> b >> c;
    if(c-(a-b) >= 0) {
        cout << c-(a-b) << endl;        
    }else{
        cout << 0 << endl;
    }


    return 0;
}

LL facctorialMethod(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i){
        sum *= i;
    }
    return sum;
}


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

long long int gcd(long long int a,long long int b){
    if (a<b)
    {
        long long int c = a;
        a = b;
        b = c;
    }
    //a>b
    
    while (b!=0)    
    {
        long long int c = a%b;
        a = b;
        b = c;        
    }
    
    return a;
}

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

    long long int n_c = b/c-(a-1)/c;
    long long int n_d = b/d-(a-1)/d;
    long long int lcm_cd = c*d/gcd(c,d);
    long long int n_cd = b/lcm_cd-(a-1)/lcm_cd;
    long long int sum = n_c+n_d-n_cd;
    cout << b-a+1-sum << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=Integer.parseInt(sc.nextLine());
		Long[] B=Arrays.asList(sc.nextLine().split(" "))
				.stream().map(Long::valueOf).toArray(Long[]::new);
		long result=B[0];
		for(int i=0;i<N-2;i++) {
			result+=B[i]>B[i+1]?B[i+1]:Long.min(B[i], B[i+1]);
		}
		result+=B[N-2];
		System.out.println(result);
	}
}

Measured memory_bytes: 28500
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include<cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include <vector>

#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)

using namespace std;

int main() {
	int N;
	cin >> N;
	cout << 1110 - N << endl;


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 100020
#define ll long long
using namespace std;
inline int read(){
  int x=0,f=1;char ch=getchar();
  while(ch>'9'||ch<'0')ch=='-'&&(f=0)||(ch=getchar());
  while(ch<='9'&&ch>='0')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
  return f?x:-x;
}
int a[3][N], f[N];
bool rev[2];

int main(int argc, char const *argv[]) {
  int n = read();
  for (int i = 1; i <= n; ++ i) {
    a[0][i] = read();
  }
  for (int i = 1; i <= n; ++ i) {
    a[1][i] = read();
  }
  for (int i = 1; i <= n; ++ i) {
    a[2][i] = read();
  }

  for (int i = 1; i <= n; ++ i) {
    if (a[1][i] % 3 != 2 || abs(a[0][i] - a[1][i]) > 1
        || abs(a[2][i] - a[1][i]) > 1) {
      return puts("No"), 0;
    }
    f[i] = a[1][i] / 3 + 1;

    if ((f[i] & 1) != (i & 1)) {
      return puts("No"), 0;
    }

    if (a[0][i] > a[1][i]) {
      rev[f[i] & 1] ^= 1;
    }
  }

  for (int i = 1; i <= n; ++ i) {
    while (f[i] != i) {
      rev[i&1^1] ^= 1;
      swap(f[i], f[f[i]]);
    }
  }

  if (rev[0] || rev[1]) {
    puts("No");
  } else {
    puts("Yes");
  }

  return 0;
}
/*

将每一列变成 x/3+1，如果是倒序则加个负号。

一次操作可以看做：

1 2 3 4 5 -> -3 -2 -1 4 5

let's do some buffs

[ 1  2  3] 4  5
 -3 -2[-1  4  5]
[-3 -2 -5]-4  1
  5  2[ 3 -4  1]
[ 5  2 -1] 4 -3
  1 -2[-5  4 -3]
  1 -2  3 -4  5


*/

Measured memory_bytes: 1920
import sys
def input():
    return sys.stdin.readline()[:-1]
h,w=map(int,input().split())
s=[input() for i in range(h)]
# print(40**3)

def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

# n,w = map(int,input().split()) #n:頂点数　w:辺の数
n=h*w
d = [[float("inf") for i in range(h*w)] for i in range(h*w)]
# print(d)
#d[u][v] : 辺uvのコスト(存在しないときはinf)
for i in range(h):
    for j in range(w):
        if i+1<h:
            if s[i][j]!="#" and s[i+1][j]!="#":
                d[i*w+j][(i+1)*w+j]=1
                d[(i+1)*w+j][i*w+j]=1
        if j+1<w:
            if s[i][j]!="#" and s[i][j+1]!="#":
                d[i*w+j][i*w+j+1]=1
                d[i*w+j+1][i*w+j]=1
# for i in range(w):
#     x,y,z = map(int,input().split())
#     d[x][y] = 1
#     d[y][x] = 1
for i in range(h*w):
    d[i][i] = 0 #自身のところに行くコストは０
# print(d)
li=warshall_floyd(d)
ans=0
for i in range(len(li)):
    for j in range(len(li[i])):
        if li[i][j]!=float("inf"):
            ans=max(ans,li[i][j])

print(ans)

Measured memory_bytes: 135148
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int A, B, K;
  cin >> A >> B >> K;
  vector<int> ret;
  REP(i,1,min(A,B)+1){
    if(A%i==0 && B%i==0){
      ret.push_back(i);
    }
  }

  reverse(ALLOF(ret));
  
  cout << ret[K-1] << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
  	int a;
  scanf("%d",&a);
  if(a % 10 == 2 || a % 10 == 4 || a % 10 == 5 || a % 10 == 7 || a % 10 == 9){
    	printf("hon");
  }else if(a % 10 == 0 || a % 10 == 1 || a % 10 == 6 || a % 10 == 8){	
    	printf("pon");
  }else{
		printf("bon");
  }
return 0;
}

Measured memory_bytes: 1732
// Contest.cpp : アプリケーションのエントリ ポイントを定義します。
//

#include"iostream"
#include"string"
#include"vector"

using namespace std;

int main()
{	
	int n;
	cin >> n;
	if (n == 2)
	{
		int a, b;
		cin >> a >> b;
		cout<<a+b<<endl;
	}
	else
	{
		cout<<"Hello World"<<endl;
	}
	return 0;
}




Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int i,j,k,n,x,cnt;
	for(;;){
		cnt=0;
		scanf("%d %d",&n,&x);
		if(n==0 && x==0)break;
		for(i=1;i<=n;i++){
			for(j=1;j<=n;j++){
				if(i==j)continue;
				for(k=1;k<=n;k++){
					if(i==k || j==k)continue;
					else if(i+j+k==x){
						cnt++;
					}
				}
			}
		}
		cnt=cnt/6;
		printf("%d\n",cnt);
	}
	return 0;
}
	


Measured memory_bytes: 1760
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
const int INF = 100000000;
const int MAX_N = 100;
typedef pair<int , int> P;
typedef long long ll;
 
int main () {
  int a;
  cin >> a;
  printf("%d\n", a + a*a + a*a*a);
  return 0;
}


Measured memory_bytes: 3760
//https://atcoder.jp/contests/nikkei2019-qual/tasks/nikkei2019_qual_b
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}}star;
#define DEBUG if(0)
#endif
#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}
class reverse_range {private:struct I {int x;int operator*() {return x-1;}bool operator!=(I& lhs) {return x>lhs.x;}void operator++() {--x;}};I i, n;public:reverse_range(int n) :i({ 0 }), n({ n }){}reverse_range(int i, int n) :i({ i }), n({ n }){}I& begin() {return n;}I& end() {return i;}};
class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }reverse_range operator!(){return reverse_range(*i,*n);}};


int main(){
    int N;
    string A,B,C;
    cin>>N>>A>>B>>C;
    int ret=0;
    for(int i:range(N)){
        set<char> s;
        s.insert(A[i]);
        s.insert(B[i]);
        s.insert(C[i]);
        ret+=(s.size()-1);
    }
    cout<<ret<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int INF = 1e9 +7;
bool used[1000][1000][1000];
signed main(){
    int x,y,z,k,p,r,s,t;
    cin>>x>>y>>z>>k;
    int a[x],b[y],c[z];
    
    for(int at=0;at<x;at++)for(int bt=0;bt<y;bt++)for(int ct=0;ct<z;ct++)used[at][bt][ct]=false;
   
    for(int i=0;i<x;i++)cin>>a[i];
   for(int i=0;i<y;i++)cin>>b[i];
   for(int i=0;i<z;i++)cin>>c[i];
   sort(a,a+x,greater<int>());sort(b,b+y,greater<int>());sort(c,c+z,greater<int>());
   priority_queue<pair<int,int>> que;
   que.push(make_pair(a[0]+b[0]+c[0],0));
    used[0][0][0]=true;
   for(int i=0;i<k&&!que.empty();i++){
       p=que.top().second;
       r=p/(1000*1000);s=(p/1000)%1000;t=p%1000;
       cout<<que.top().first<<endl;
       //used[r][s][t]=true;
       que.pop();
       if(r<x-1&&!used[r+1][s][t]) {que.push(make_pair(a[r+1]+b[s]+c[t],p+1000*1000)); used[r+1][s][t]=true;}
       if(s<y-1&&!used[r][s+1][t]) {que.push(make_pair(a[r]+b[s +1]+c[t],p+1000)); used[r][s+1][t]=true;}
       if(t<z-1&&!used[r][s][t+1]) {que.push(make_pair(a[r]+b[s]+c[t+1],p+1)); used[r][s][t+1]=true;}
   }
  

    
   return 0;
}

Measured memory_bytes: 977024
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)n; i++)
#define REPR(i, n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i, m, n) for(int i=(int)m; i<(int)n; i++)
#define FORR(i, m, n) for(int i=(int)m-1; i>=(int)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
typedef long long ll;
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
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 (a>b) { a = b; return 1; } return 0; }



void solve(long long N, std::vector<long long> A){
	vector<ll> p(N);
	REP(i, N) {
		p[A[i]-1] = i+1;
	}
	cout << p[0];
	FOR(i, 1, N) {
		cout << " " << p[i];
	}
	cout << "\n";
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 2432
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T, class U> inline bool chmax(T& a,U b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class U> inline bool chmin(T& a,U b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int k;
    cin >> k;
    queue<long long> que;
    for (int i = 1; i < 10; i++) que.emplace(i);
    
    long long val;
    for (int i = 0; i < k; i++) {
        val = que.front();
        que.pop();
        int n = val % 10;
        if (n > 0) que.emplace(val * 10 + n - 1);
        que.emplace(val * 10 + n);
        if (n < 9) que.emplace(val * 10 + n + 1);
    }
    cout << val << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define INF 1e9
#define MOD 1000000007
#define ll long long
using namespace std;
typedef unsigned long long ull;
typedef pair<ll,ll> pr;

int p[100];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int ans=0;
    for(int i=0;i<n;i++){
        cin>>p[i];
        ans+=p[i];
    }
    int q=*max_element(p,p+n);
    ans-=q/2;cout<<ans;

    return 0;
}

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

using namespace std;

int N, M;
vector<bool> flag;
vector<vector<int>> graph;

int dfs(int u, int cnt) {
  if (cnt == N) return 1;
  int res = 0;
  for (int v : graph[u]) {
    if (flag[v]) continue;
    flag[v] = true;
    res += dfs(v, cnt + 1);
    flag[v] = false;
  }
  return res;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> M;
  flag.assign(N, false), graph.assign(N, vector<int>());
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    graph[a].emplace_back(b);
    graph[b].emplace_back(a);
  }
  flag[0] = true;
  cout << dfs(0, 1) << '\n';
  return 0;
}


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

using namespace std;

void solve(int a[3], int m)
{
    while (a[0] >= a[1] && m > 0) {
        a[1] *= 2;
        m--;
    }
    if (a[0] >= a[1]) {
        cout << "No" << endl;
        return;
    }
    while (a[1] >= a[2] && m > 0) {
        a[2] *= 2;
        m--;
    }
    if (a[1] >= a[2]) {
        cout << "No" << endl;
        return;
    }
    cout << "Yes" << endl;
}

int main()
{
    int r, g, b;
    int m;

    while (cin >> r >> g >> b >> m) {
        int a[3] = {r, g, b};
        solve(a, m);
    }

    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    int m,n;
    string q;
    while(cin>>m>>n,m){
        int x=1,y=1,dir=0,cnt;
        while(getline(cin,q),q!="STOP"){
            if(q[0]=='F'){
                cnt=atoi(q.substr(8).c_str());
                if(dir%2==0){
                    cnt=dir==0?cnt:-cnt;
                    y=min(n,max(1,y+cnt));
                }
                else{
                    cnt=dir==1?cnt:-cnt;
                    x=min(m,max(1,x+cnt));
                }
            }
            else if(q[0]=='B'){
                cnt=atoi(q.substr(9).c_str());
                if(dir%2==0){
                    cnt=dir==0?-cnt:cnt;
                    y=min(n,max(1,y+cnt));
                }
                else{
                    cnt=dir==1?-cnt:cnt;
                    x=min(m,max(1,x+cnt));
                }
            }
            else if(q=="RIGHT") dir=(dir+5)%4;
            else if(q=="LEFT") dir=(dir+3)%4;
        }
        cout<<x<<' '<<y<<endl;
    }
    return 0;
}

Measured memory_bytes: 3104
import java.util.*;
import java.io.*;
 
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static final long mod=1000000007;
    
    public  static void main(String[] args)   throws Exception, IOException{
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        // int n=sc.nextInt();
        // char c[][] = new char[h][w];
        // char c[]=sc.nextString().toCharArray();
        // int d[]=new int[n];
        // for(int i=0; i<n; i++) {d[i]=sc.nextInt();}

        int a=sc.nextInt();
        int b=sc.nextInt();
        int c=sc.nextInt();
        int d[]={a,b,c};
        sort(d); 

        out.println(d[2]*10+d[1]+d[0]);
        out.flush();
    }


    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }  

    static long gcd(long a, long b){
        if(min(a,b) == 0)return max(a,b);
        return gcd(max(a,b) % min(a,b),min(a,b));
    }
}

class P implements Comparable<P>{
    int id, d;
    P(int  id, int d) {
        this.id=id;
        this.d=d;
    }
    public int compareTo(P p){
        return d-p.d; //des
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 21460
#include <iostream>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#define fr first
#define sc second
#define mp make_pair
#define INF (2 << 28)
using namespace std;

typedef pair<int,int> iP;
struct node{
  int cost,pass;
  vector <int> rd,edge;
};

int n,k,costed[5001];
bool used[5001];
vector <node> info(5001);

void init(){
  for(int i=0;i<5001;i++)
    costed[i] = INF;
}
  
void make_graph(){
  queue <iP> que;
  for(int i=1;i<n+1;i++){
    memset(used,1,sizeof(used));
    que.push(mp(i,info[i].pass));
    while(!que.empty()){
      iP p = que.front(); que.pop();
      if(!p.sc) continue;
      for(int j=0;j<info[p.fr].rd.size();j++){
	if(used[info[p.fr].rd[j]]){
	  used[info[p.fr].rd[j]] = 0;
	  que.push(mp(info[p.fr].rd[j],p.sc-1));
	  info[i].edge.push_back(info[p.fr].rd[j]);
	}
      }
    }
  }
}

int Dijkstra(){
  priority_queue<iP,vector<iP>,greater<iP> > que;
  que.push(mp(1,0));
  while(!que.empty()){
    iP p = que.top(); que.pop();
    if(p.fr == n) return p.sc;
    for(int i=0;i<info[p.fr].edge.size();i++){
      if(p.sc + info[p.fr].cost < costed[info[p.fr].edge[i]]){
	que.push(mp(info[p.fr].edge[i],p.sc + info[p.fr].cost));
	costed[info[p.fr].edge[i]] = p.sc + info[p.fr].cost;
      }
    }
  }
}

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

  for(int i=0;i<n;i++)
    cin >> info[i+1].cost >> info[i+1].pass;
  
  for(int i=0;i<k;i++){
    int a,b; cin >> a >> b;
    info[a].rd.push_back(b);
    info[b].rd.push_back(a);
  }

  make_graph();

  cout << Dijkstra() << endl;

}

Measured memory_bytes: 68876
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#include <queue>
#include <cstdio>
using namespace std;

template <class T> using V = vector<T>;
template <class S, class T> using P = pair<S, T>;
template <class... T> using TP = tuple<T...>;

using ll = long long;
using db = double;
using ldb = long db;
using str = string;
using ch = char;
using vll = V<ll>;
using vvll = V<V<ll>>;
using vvvll = V<V<V<ll>>>;
using pll = P<ll,ll>;
using tpll = TP<ll,ll,ll>;
using vpll =V<pll>;
using vvpll = V<vpll>;
using vtpll = V<tpll>;
using vst = V<str>;
using vch = V<ch>;
using vvch = V<vch>;
using qll = queue<ll>;
using vqll = V<qll>;

#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin() 
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl
#define pb(a) push_back(a)
#define pob pop_back()
#define mp make_pair
#define mt make_tuple
#define pbmp(a,b) push_back(mp(a,b))
#define subs(a,b) substr(a,b)
#define cfs(a) cout<<fixed<<setprecision(a) //
/*vvll v(n,vll(m)) n行m列  continue
A.erase(A.begin()+i); 配列Aのi番目を消せる
std::binary_search(v.bgn,v.en,a); 二分探索
abs(a,b)   pow(a,n)  to_string  stoll
auto Iter=lower_bound(v.bgn,v.en,a); v[i]>=aとなる初のv[i]
v.insert(lower_bound(v.bgn,v.en,a),b); bを入れられる
lower upper  co(*Iter) co(Iter-v.bgn) v[i]>=aとなる初のi
vvll v(100001,vll(0)); v[a].pb(b); v[b].pb(a);
priority_queue<ll> pque; pque.push(ai); pque.top(); pque.pop();
priority_queue<ll,vll,greater<ll>> pque; 昇順
vqll q(3);  q[0].push(0); q[0].push(2); q[0].push(1);
q[0].front()→0 q[0].back()→1 q[0].pop(); q[0].front()→2
que.pop() que.sz while(!que.empty())
ll a=1,b=2,c=4,xo; xo=a^b^c; if(a^b^c==0)co(xo)→7 if(xo==0)co(xo)→なし
*/

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void Comuse() {
    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;
    }
}
#define comuse Comuse()
ll combi(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;
}
ll pow_mod(ll a,ll n,ll mod){
  ll res=1;
  for(;n>0;n/=2){
    if(n%2==1)res=(res*a)%mod;
    a=(a*a)%mod;
  }
  return res;
}
ll digit_sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0)break;
  }
  return m;
}
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}

int main(){
  ll n;
  cin>>n;
  ll ans=0;
  ans=n*(n-1)/2;
  co(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int alice =0;
    int bob = 0;
    int n;
    cin >> n;
    int arr[n];
    for(int i = 0;i< n;i++)
    {
        cin>> arr[i];
    }
    sort(arr,arr +n);
    reverse(arr,arr+n);
    
    for(int i = 0;i< n;i++)
    {
        if(i%2==0)
        {
            alice += arr[i];
        }
        else if(i%2==1)
        {
            bob += arr[i];
        }
    }
    
    cout << alice-bob<< endl;
}


Measured memory_bytes: 3636
#include "bits/stdc++.h"
#define ll long long
#define lld long double
#define MOD 1000000007
#define inf 1000000000000000000ll
#define pii pair<int,int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
ll power(ll x,ll y, ll md=inf){ll res = 1;x%=md;while(y){if(y&1)res = (res*x)%md;x *= x; if(x>=md) x %= md; y >>= 1;}return res;}
 
using namespace std;


#define endl '\n'
#define int ll

signed main() {
	fast;

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

	vector<pii> v(h);
	for(int i=0;i<h;i++) cin>>v[i].f>>v[i].s;

	map<int,int> mp;
	for(int i=1;i<=w;i++) mp[i] = 0;

	map<int, int> mini;
	mini[0] = w;

	for(int i=0;i<h;i++) {
		int l = v[i].f;
		int r = v[i].s;

		auto it = mp.lower_bound(l);
		int mn = inf;

		while(it!=mp.end()) {
			if(it->f > r) break;
			mn = min(mn, r+1-(it->f)+(it->s));
			auto it1 = it;
			it++;
			mini[it1->s]--;
			if(mini[it1->s]==0) mini.erase(it1->s);
			mp.erase(it1);
		}

		if(r+1<=w && mn<inf) {
			if(mp.count(r+1) && mp[r+1] > mn) {
				mini[mp[r+1]]--;
				if(mini[mp[r+1]]==0) mini.erase(mp[r+1]);
				mini[mn]++;
				mp[r+1] = mn;
			}
			else if(!mp.count(r+1)){
				mp[r+1] = mn;
				mini[mn]++;
			}
		}

		if(mini.size()) cout<<mini.begin()->f+i+1<<endl;
		else cout<<-1<<endl;

	}
}

Measured memory_bytes: 18672
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;


#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    if(s.length() == 6 && s[2] == s[3] && s[4] == s[5] && s[0] != s[1] && s[0] != s[2] && s[0] != s[4] && s[1] != s[2] && s[1] != s[4]) {
    	cout<<"Yes\n";
    } else {
    	cout<<"No\n";
    }
}

Measured memory_bytes: 256
fn main() {
    let s = {
        let mut s = String::new(); 
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_string()
    };

    let tokens = s.split(" ")
        .map(|num| num.parse().unwrap())
        .collect::<Vec<i32>>();

    let first = tokens[0];
    let second = tokens[1];
    println!("{} {}", first * second, (first * 2) + (second * 2));
}


Measured memory_bytes: 5028
extern crate core;

use core::cmp::max;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input!{
        p: usize,
        q: usize,
        r: usize,
    }
    let ans = max(max(p, q), r);
    println!("{}", p + q + r - ans);
}



Measured memory_bytes: 4352
#include <stdio.h>

int main(void)
{
    int N,i;
    
    scanf("%d",&N);
    
    for(i=1; i<=9; i++){
        if((N%i == 0) && (N/i < 10)){
            printf("Yes\n");
            return 0;
        }
    }
    
    printf("No\n");
    
    return 0;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,normal = 0,ans=0;
    bool special = 1;
    cin >> N;
    vector<string> S(N);
    vector<bool> A(N);
    vector<bool> B(N);
    REP(i,N){
        cin >> S.at(i);
        REP(j,S.at(i).size()-1){
            if(S.at(i).at(j) == 'A'&& S.at(i).at(j+1) == 'B')normal++;
        }
        if(S.at(i).at(0) == 'B')B.at(i) = 1;
        reverse(S.at(i).begin(),S.at(i).end());
        if(S.at(i).at(0) == 'A')A.at(i) = 1;
        if(A.at(i)!=B.at(i))special = 0;
    }
    ans = min(count(A.begin(),A.end(),1),count(B.begin(),B.end(),1));
    if(special == 1 && ans != 0)ans--;
    cout <<normal+ans<<  "\n";
}

Measured memory_bytes: 768
/*
AuThOr Gwj
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define debug_pair(A) cerr<<A.FIR<<" "<<A.SEC<<endl;
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int main(){
	fastio;
	LL now=100;
	LL x;
	cin>>x;
	int ye=0;
	while(now<x){
		now+=now/100;
		ye++;
	}
	cout<<ye<<endl;
	return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int i,N,k;
  vector<int> A;
  cin>>N;
  for(i=0;i<N;i++){
    int a;
    cin>>a;
    A.push_back(a);
  }
  sort(A.begin(),A.end());
  cout<<A[N-1]-A[0]<<endl;
  return 0;
}


Measured memory_bytes: 384
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

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

now=0
for i in range(102):
    if i not in p:
        if abs(x-now)>abs(x-i):
            now=i
    # print(i)
print(now)

Measured memory_bytes: 69016
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5+9;

int q;
bool prime[N];
int sum[N]; // 区間[1, n] の 2017-like の個数

int main() {
    cin >> q;

    fill_n(prime, N, true);
    prime[1] = false;
    for(int num = 2; num < N; num++) {
        if(!prime[num])  continue;
        for(int i = num*2; i <= N; i += num)  prime[i] = false;
    }

    sum[0] = 0;
    for(int num = 1; num < N; num++)
        sum[num] = sum[num-1] + (prime[num] & prime[(num+1)/2]);

    for(int i = 1; i <= q; i++) {
        int l, r; cin >> l >> r;
        cout << sum[r] - sum[l-1] << endl;
    }
}

Measured memory_bytes: 1152
/*
 * https://atcoder.jp/contests/abc157/tasks/abc157_d
 */
#include <bits/stdc++.h>
 
using namespace std;

// ショートハンド
// #define ll intに変えればメモリ節約
#define ll int

/* 
 * ループ系のマクロ
 * `REP(i, 10) { cout << i; }`のように、変数名,回数で動く
 */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/*
 * 正規表現系
 */
#define MATCH(_str, _ptn) regex_match(_str, regex(_ptn))
#define REPLACE(_str, _ptn, _replacement) regex_replace(_str, regex(_ptn), _replacement)

const int MOD = 1e9 + 7;

struct UnionFind {
    ll n;
    vector<ll> par,cnt;

    UnionFind(ll N) : par(N) {
        n = N;
        REP(i,n) par[i] = i;
    }

    ll root(ll x) {
        ll tmp = x;
        while(par[tmp] != tmp) {
            tmp = par[tmp];
        }
        return par[x] = tmp;
    }

    void unite(ll x, ll y) {
        ll rx = root(x);
        ll ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(ll x, ll y) {
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }

    void clean() {
        cnt.assign(n, 0);
        REP(i,n) {
            par[i] = root(i);
            cnt[par[i]]++;
        };
    }

    // 実行前にclean必須！
    ll count(ll x) {
        return cnt[root(x)];
    }
};

ll n,m,k;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> m >> k;

    UnionFind unionFind(n);
    vector<ll> blocks(n, 1);
    REP(i,m) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        unionFind.unite(a,b);
        blocks[a]++;
        blocks[b]++;
    }
    unionFind.clean();
    REP(i,k) {
        ll c,d;
        cin >> c >> d;
        c--;d--;
        if(unionFind.same(c,d)) {
            blocks[c]++;
            blocks[d]++;
        }
    }
    REP(i,n) {
        if(i > 0) cout << " ";
        cout << unionFind.count(i) - blocks[i];
    }
    return 0;
}

Measured memory_bytes: 2048
i = list(map(int,(input().split())))
word = list(input())
#print(word)
count = 0
ans = []
for n,moji in enumerate(word):
  if n == (i[1]-1):
    ans.append(moji.lower())
  else:
    ans.append(moji)
    
print(('').join(ans))   

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	ll n,k;
	cin>>n>>k;
	double ans=0;
	FOR(i,1,n+1){
		double now=1.0/n;
		int cnt=0;
		int cur=i;
		while(cur<k){
			cur*=2;
			cnt++;
		}
		rep(i,cnt) now/=2.0;
		ans+=now;
	}
	cout<<setprecision(15)<<ans<<endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import collections
import itertools
import math
import sys

INF = float('inf')


def solve(N: int, A: "List[int]"):
    c = collections.Counter(A)
    return "\n".join([f'{c[i+1]}' for i in range(N)])


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N - 2 + 1)]  # type: "List[int]"
    print(solve(N, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 124988
#include<stdio.h>
#include<stdlib.h>
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

ll dp[101000];
ll v[110],w[110];

int main(){
	int n,W;
	scanf("%d%d",&n,&W);
	rep(i,0,n)scanf("%d%d",w+i,v+i);
	
	if(w[0]>=1000){
		ll q=W/w[0],r=W%w[0];
		if(r>500)r=500;
		W=900*q+r;
		rep(i,1,n)w[i]=900+(w[i]-w[0]);
		w[0]=900;
	}
	
	dp[0]=1;
	rep(i,0,n)for(ll k=100000;k>=0;k--)if(dp[k])dp[k+w[i]]=max(dp[k+w[i]],dp[k]+v[i]);
	W=min(W,100000);
	ll ans=0;
	rep(i,0,W+1)ans=max(ans,dp[i]);
	printf("%d\n",ans-1);
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<cmath>
#include<stack>
#include<string.h>
#include <iomanip>
#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
using namespace std;
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; }



int main() {
    int N;
    string S;
    cin >> N >> S;
    vector<int>a(N);
    rep(i,N) {
        if(S[i]=='R') a[i] = 0;
        if(S[i]=='G') a[i] = 1;
        if(S[i]=='B') a[i] = 2;
    }
    vector<ll>cnt(3);
    rep(i,N) cnt[a[i]]++;
    ll ans = 1;
    rep(i,3) ans *= cnt[i];
    rep(j,N) {
        rep(i,j) {
            int k = j+j-i;
            if(k<N) {
                if(a[i] == a[j]) continue;
                if(a[j] == a[k]) continue;
                if(a[i] == a[k]) continue;
                ans--;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3648
import sys

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


def main():
    S = readline().strip()

    g, p = 0, 0
    ans = 0
    for c in S:
        if g > p:
            p += 1
            if c == 'g':
                ans += 1
        else:
            g += 1
            if c == 'p':
                ans -= 1

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9176
import numpy as np
def main():
  h,w,k = map(int, input().split())
  c = []
  for i in range(h):
    c.append(list(input()))
  c = np.array(c)=='#'
  
  count = 0
  for i in range(2**(h+w)):
    tmp = np.array(list(bin(4096+i)))=='1'
    row = tmp[(h+w)*-1:w*-1]
    col = tmp[w*-1:]
    if c[np.ix_(row,col)].sum()==k:
      count += 1
  print(count)
main()

Measured memory_bytes: 27308
function Main(input) {
    const lines = input.split("\n");
    const xs = lines[1].split(' ').map(v => +v);
    const min = Math.min(...xs);
    const max = Math.max(...xs);
    let minCost = Infinity;
    
    for (let i = min; i <= max; i++) {
        const cost = xs.reduce((acc, x) => (x - i) ** 2 + acc, 0);
        minCost = Math.min(minCost, cost);
    }

    console.log(minCost);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
#include<iostream>
#include<cmath>
#define f(x) (x)*(x)
using namespace std;
int n,a[1001],cnt,ans,tt=0x7fffffff;
int main()
{
    cin>>n;
    int mi=tt,ma=-tt;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        cnt+=a[i];
        if(a[i]<mi) mi=a[i];
        if(a[i]>ma) ma=a[i];
    }
    int t=cnt/n;
    for(int k=mi;k<=ma;k++)
    {
        ans=0;
        for(int i=1;i<=n;i++)
        {
            ans+=f(a[i]-k);
        }
        if(ans<tt) tt=ans;
    }
    cout<<tt;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
using namespace std;

int main() {
   int N,A,B;
   cin>>N>>A>>B;
   int X=0;
   int Y=0;
   int Z=0;

    vector<int>P(N);
    for(int i=0;i<N;i++){
        cin>>P[i];
    }
    for(int i=0;i<N;i++){
        if(P[i]<=A){
            X++;
        }
        else if(P[i]>A&&P[i]<=B){
            Y++;
        }
        else{
            Z++;
        }
    }
    cout<<min(X,min(Y,Z))<<endl;
}

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

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
template <class T>
using max_priority_queue = priority_queue<T>;
template <class T>
using min_priority_queue = priority_queue<T, std::vector<T>, std::greater<T>>;

const int INF = 1 << 29;
const ll LL_INF = 1LL << 60;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
ll N, M;
map<ll, ll> cnts;
int main()
{
  cin >> N >> M;
  ll res = 0;
  ll sum = 0;
  cnts[0]++;
  for (int i = 0; i < N; i++)
  {
    ll a;
    cin >> a;
    sum += a;
    sum %= M;
    
    ll key = sum;
    res += cnts[key];
    //cerr << i << " " << res << " " << sum << " " << key << " " << cnts[key] << endl;
    cnts[sum]++;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 4224
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <iomanip> 

using ll = long long;
using ull = unsigned long long;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline void print(T&& x){cout<<x<<endl;}// 改行付き出力
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
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; }
int ctoi(char c){return c-'0';}


// TODO: write
int main() {
  #define int ll
  int n,m;cin>>n>>m;
  vector<int> a(n);rep(i,n)cin>>a[i];
  vector<pair<int,int>> cb(m);rep(i,m){
    int b,c;cin>>b>>c;
    cb[i].fi = c;
    cb[i].se = b;
  }
  sort(all(a));
  sort(all(cb),greater<pair<int,int>>());
  
  int cnt = 0;
  rep(i,m){
    rep(j,cb[i].se){
      if(a[cnt] < cb[i].fi){
        a[cnt++] = cb[i].fi;
      }else goto end;
    }
  }
  end:
  print(SUM(a));
  return 0;
}

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

int num[9]={2,5,5,4,5,6,3,7,6};
bool comb(int l,int r){return num[l-1]<num[r-1];}

vector<int> canuse;

vector<int> calc(int cur,int n){
	vector<int> res;
	if(n==0){
		res.push_back(canuse[cur]);
		return res;
	}else if(n<0) return res;
	for(int i=cur;i<canuse.size();i++){
		if(res.size()>n/num[canuse[i]-1]) break;
		vector<int> tmp=calc(i,n-num[canuse[i]-1]);
		if(tmp.size()>0 && n-num[canuse[i]-1]>0) tmp.push_back(canuse[i]);
		if(res.size()<tmp.size()) res=tmp;
		else if(res.size()>0 && res.size()==tmp.size()){
			sort(res.begin(),res.end(),greater<int>());
			sort(tmp.begin(),tmp.end(),greater<int>());
			for(int j=0;j<tmp.size();j++) {
				if(tmp[j]==res[j])continue;
				if(tmp[j]>res[j]) res=tmp;
				break;
			}
		}
	}
	return res;
}

int main(){
	int n,m;
	cin >> n >> m;
	for(int i=0;i<m;i++){
		int a;
		cin >> a;
		canuse.push_back(a);
	}
	sort(canuse.begin(),canuse.end(),greater<int>());
	sort(canuse.begin(),canuse.end(),comb);
	int pre=0;
	for(int i=0;i<canuse.size();i++){
		if(num[canuse[i]-1]==pre){
			canuse.erase(canuse.begin()+i);
			i--;
		}
		pre=num[canuse[i]-1];
	}
	vector<int> v=calc(0,n);
	sort(v.begin(),v.end(),greater<int>());
	for(int x:v) cout << x;
	cout << endl;
	return 0;
}


Measured memory_bytes: 896