akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define int long long
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false),cin.tie(nullptr);
#endif
#define ff first
#define ss second
#define endl '\n'
#define all(c) c.begin(),c.end()
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" "; cout<<endl;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void solve(){
  int n;
  set<int> s;
  cin>>n;
  for(int i=0;i<n;i++){
	   int x;
	   cin>>x;
	   s.insert(x); 
	 }
	 cout<<(int)s.size()<<endl;
}
int32_t main(){
  IOS;
  solve();
  //debug();
 #ifdef LOCAL_DEFINE
 cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
 #endif	
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void)
{
	char a[27],s[1001];
	int d,f,g,h,i,j;
	for(i=0;i<26;i++)	a[i]='A'+i;
	scanf("%s",s);
	d=strlen(s);
	for(i=0;i<d;i++){
		for(j=0;j<26;j++){
			if(s[i]==a[j]){
				f=j;
				if(f<=2){
					f=f+26;
				}
				break;
			}
		}
		f=(f-3);
		s[i]=a[f];
	}
	printf("%s\n",s);
	return 0;
}

Measured memory_bytes: 948
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;

int main()
 {
 	int a,b,c,d,e;
 	cin>>a>>b>>c;
 	e=c;
 	d=a;
 	a=b;
 	b=d;
 	c=a;
 	a=e;
 	cout<<a<<" "<<b<<" "<<c<<" "<<endl;
 	return 0;
}
 	
 					

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n];
    int i;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    int count=1;
    for(i=0;i<n-1;i++)
    {
        if(a[i+1]!=a[i])
        {
            count++;
        }
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string a, b, c;
  cin >> a >> b >> c;
  if (a.back() == b[0] && b.back() == c[0])
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
function main()
RR,GG,BB,N=map(x->parse(Int,x),split(readline()))
num=[RR,GG,BB]
R=maximum(num)
G=minimum(num)
B=RR+GG+BB-R-G
ans=0
for r=0:R:N,g=0:G:N-r
  ans+=(N-r-g)%B==0
end
println(ans)
end
main()


Measured memory_bytes: 153100
#include"bits/stdc++.h"
#include"math.h"
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std; 
int main(){ int n,q; cin >>n>>q;
           vector<pair<char,int>> s(n);
             rep(i,n) cin >> s[i].first;
           vector<int>  l(q),r(q);
         for(int i=0;i<q;i++){
           int x,y;
           cin >> x >> y;
           l[i]=x;
           r[i]=y;}
           for(int i=0;i<n-1;i++){
             if(s[i].first=='A'){if(s[i+1].first=='C'){
               s[i+1].second=s[i].second+1;}
             else s[i+1].second=s[i].second;}
           else s[i+1].second=s[i].second;}
           for(int i=0;i<q;i++){
             int x=s[r[i]-1].second-s[l[i]-1].second;
             cout << x <<endl;}}
           




Measured memory_bytes: 2432
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
	int n;
	vector<int> v(3, 0);
	cin >> n >> v[0] >> v[1] >> v[2];
	vector<string> vs(n, "");
	for (int i = 0; i < n; i++) {
		cin >> vs[i];
	}
	string res;
	for (int i = 0; i < n; i++) {
		if (v[0] < 0 || v[1] < 0 || v[2] < 0) {
			cout << "No" << endl;
			return 0;
		}
		int i1 = vs[i][0] - 'A', i2 = vs[i][1] - 'A';
		if (v[i1] == 0) {
			v[i1] += 1;
			v[i2] -= 1;
			res.push_back('A' + i1);
		} else if (v[i2] == 0) {
			v[i1] -= 1;
			v[i2] += 1;
			res.push_back('A' + i2);
		} else if (v[i1] == 1 && v[i2] == 1 && i + 1 < n && vs[i + 1] != vs[i]) {
			int next_i1 = vs[i + 1][0] - 'A', next_i2 = vs[i + 1][1] - 'A';
			bool incre_i1 = true;
			if (i1 != next_i1 && i1 != next_i2) {
				if (next_i1 == i2) {
					if (v[next_i2] == 0) incre_i1 = false;
				} else {
					if (v[next_i1] == 0) incre_i1 = false;
				}
			} else {
				if (next_i1 == i1) {
					if (v[next_i2] > 0) incre_i1 = false;
				} else {
					if (v[next_i1] > 0) incre_i1 = false;
				}
			}
			if (incre_i1) {
				v[i1]++;
				v[i2]--;
				res.push_back('A' + i1);
			} else {
				v[i1]--;
				v[i2]++;
				res.push_back('A' + i2);
			}
		} else {
			if (v[i1] < v[i2]) {
				v[i1] += 1;
				v[i2] -= 1;
				res.push_back('A' + i1);
			} else {
				v[i1] -= 1;
				v[i2] += 1;
				res.push_back('A' + i2);
			}
			
		}
	}
	if (v[0] < 0 || v[1] < 0 || v[2] < 0) {
			cout << "No" << endl;
			return 0;
		}
	cout << "Yes" << endl;
	for (auto r : res) cout << r << endl;
}


Measured memory_bytes: 6660
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
long long mod = 1000000007;
long long power(long long m,long long n){
    long long res = 1;
    if(n > 0){
        res = power(m,n / 2);
        if(n % 2 == 0){
            res = (res * res) % mod;
        }
        else{
            res = (((res * res) % mod) * m) % mod;
        }
    }
    return res;
}
//modはグローバル変数にしておく
int main(){
  ll n = 0;
  cin >> n;
  vector<ll> a(n);
  vector<ll> copy(n);
  for(int i = 0;i < n;i++)cin >> a[i],copy[i] = a[i];
  vector<ll> count(1000001);
  for(int i = 0;i < 1000001;i++)count[i] = 0;
  for(int i = 0;i < n;i++){
    for(int j = 2;j <= sqrt(a[i]);j++){
      ll now = 0;
      while(a[i] % j == 0){
        a[i] /= j;
        now++;
      }
      count[j] = max(count[j],now);
      //cout << j << endl;
    }
    count[a[i]] = max(count[a[i]],(ll)1);
  }
  ll gcd = 0;
  gcd = 1;
  for(int i = 2;i < 1000001;i++){
    gcd *= power(i,count[i]);
    gcd %= mod;
  }
  ll res = 0;
  for(int i = 0;i < n;i++){
    ll add = 0;
    add = gcd * power(copy[i],mod - 2);
    add %= mod;
    res += add;
    res %= mod;
  }
  //for(int i = 0;i < 20;i++)cout << i << " " << count[i] << endl;
  //cout << gcd << endl;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 8192
def main():
    mod = 10**9 + 7
    n = int(input())
    a = [int(i) for i in input().split()]
    _s = sum(a)
    s = [_s - ai for ai in a]
    ans = 0
    for i in range(n):
        ans = ((a[i] * s[i]) % mod + ans) % mod
    print(ans * pow(2, mod - 2, mod) % mod)


if __name__ == '__main__':
    main()


Measured memory_bytes: 31564
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	String top = sc.next();
        int price = 700;
        for(int i = 0; i < 3; i++){
        	if(top.charAt(i) == 'o'){
            	price += 100;
            }
        }
        System.out.println(price);
    }
}

Measured memory_bytes: 35504
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

#define for(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)    for(i, 0, n)
#define sz(x)        ((int)(x).size())
#define inf          1<<25

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

//typedef vector<int> vi;
//typedef vector<long long> vl;
//typedef vector<double> vd;
//typedef pair<int,int> pii;
//typedef pair<long,long> pll;
//typedef long long ll;

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

int main() {
    int N;
    cin >> N;
    cout << N / 3 << endl;
}

Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
using namespace std;
#define eps 0.000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define seg_size 65536*16
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
	int n;
	cin >> n;
	string a, b, c;
	cin >> a >> b >> c;
	int ans = 0;
	for (int i = 0; i < a.length(); ++i) {
		int cnt = 0;
		if (a[i] == b[i]) {
			cnt++;
		}
		if (a[i] == c[i]) {
			cnt++;
		}
		if (b[i] == c[i]) {
			cnt++;
		}
		if (cnt == 1) {
			ans++;
		}
		else if(cnt == 0){
			ans += 2;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
code = r"""
# distutils: language=c++
# distutils: include_dirs=[/home/contestant/.local/lib/python3.8/site-packages/numpy/core/include, /opt/atcoder-stl]
from libcpp.vector cimport vector
from libcpp.string cimport string
cdef extern from "<atcoder/string>" namespace "atcoder" nogil:
    cdef vector[int] suffix_array(string s)
    cdef vector[int] suffix_array[T](vector[T] s)
    cdef vector[int] suffix_array(vector[int] s, int upper)
    cdef vector[int] lcp_array(string s, vector[int] sa)
    cdef vector[int] lcp_array[T](vector[T] s, vector[int] sa)
    cdef vector[int] z_algorithm(string s)
    cdef vector[int] z_algorithm[T](vector[T] s)
cdef string s = input().encode()
cdef long n = s.length()
cdef vector[int] sa = suffix_array(s)
cdef vector[int] la = lcp_array(s, sa)
cdef long a = n * (n + 1) // 2
for i in range(n - 1): a -= la[i]
print(a)
"""
import os, sys
if sys.argv[-1] == 'ONLINE_JUDGE':
    open('solve.pyx', 'w').write(code)
    os.system('cythonize -i -3 -b solve.pyx')
import solve

Measured memory_bytes: 22652
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>

using namespace std;

typedef long long ll;

ll to_int(string x){
    int n = x.size();
    ll t = 0, d = 1;
    for (int i = n - 1; i >= 0; i--){
        t += d*(x[i] - '0');
        d *= 10;
    }
    return t;
}

int main(){
    ll k;
    cin >> k;
    vector<string> x;
    for (int i = 0; i < 10; i++){
        string t = "";
        t += (char)(i + '0');
        x.push_back(t);
        
    }
    
    int t = 9;
    for (int i = 0; i <= 500000; i++){
        int curr = x[i][0] - '0';
        if (curr > 0){
            string l = "";
            l += (char)((curr - 1) + '0');
            l += x[i];
            x.push_back(l);
        }
            string l = "";
            l += (char)(curr + '0');
            l += x[i];
            x.push_back(l);
        if (curr < 9){
            string l = "";
            l += (char)((curr + 1) + '0');
            l += x[i];
            x.push_back(l);
        }
            
    }
    vector<ll> y;
    for (int i = 2; i < 11; i++)
        y.push_back(pow(10, i));
    for (int i = 0; i <= 500000; i++){
        y.push_back(to_int(x[i]));
    }
    sort(y.begin(), y.end());
    vector<ll> z;
    z.push_back(y[0]);
    for (int i = 1; i <= 500000; i++){
      while(y[i] == y[i - 1] && i < 500000)
        i++;
      z.push_back(y[i]);
      if (y[i] == 3234566667){
        break;
      }
      
    }
    cout << z[k];
    return 0;
}


Measured memory_bytes: 89956
#include <iostream>

int main(void){

  int n=0; 
  int a=0; 
  int w=0; 
  int t=0; 
  int r=0; 

  char x[100000][3];
  
  std::cin >> n;

  for(int i=0; i<n; i++){
    std::cin >> x[i];
    if (x[i][0]=='A') a++;
    if (x[i][0]=='W') w++;
    if (x[i][0]=='T') t++;
    if (x[i][0]=='R') r++;
  }
  std::cout << "AC x " << a << "\n";
  std::cout << "WA x " << w << "\n";
  std::cout << "TLE x " << t << "\n";
  std::cout << "RE x " << r << "\n";

  return(0);
}


Measured memory_bytes: 3924
/*  -*- coding: utf-8 -*-
 *
 * d.cc: D: Cake 123
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_X = 1000;
const int MAX_Y = 1000;
const int MAX_Z = 1000;

/* typedef */

typedef long long ll;

struct Stat {
  ll d;
  int x, y, z;
  Stat() {}
  Stat(ll _d, int _x, int _y, int _z): d(_d), x(_x), y(_y), z(_z) {}
  bool operator<(const Stat &s) const {
    return
      d < s.d ||
      (d == s.d && (x < s.x ||
       (x == s.x && (y < s.y || (y == s.y && z < s.z)))));
  }
};

typedef set<Stat> sset;

/* global variables */

ll as[MAX_X], bs[MAX_Y], cs[MAX_Z];
sset ss;

/* subroutines */

/* main */

int main() {
  int x, y, z, k;
  scanf("%d%d%d%d", &x, &y, &z, &k);

  for (int i = 0; i < x; i++) scanf("%lld", as + i);
  for (int i = 0; i < y; i++) scanf("%lld", bs + i);
  for (int i = 0; i < z; i++) scanf("%lld", cs + i);
  sort(as, as + x);
  sort(bs, bs + y);
  sort(cs, cs + z);

  Stat st(as[x - 1] + bs[y - 1] + cs[z - 1], x - 1, y - 1, z - 1);
  priority_queue<Stat> q;
  q.push(st);
  ss.insert(st);

  while (k > 0 && ! q.empty()) {
    Stat u = q.top(); q.pop();

    printf("%lld\n", u.d);
    k--;

    if (u.x > 0) {
      Stat v(as[u.x - 1] + bs[u.y] + cs[u.z], u.x - 1, u.y, u.z);
      if (ss.find(v) == ss.end()) {
	q.push(v);
	ss.insert(v);
      }
    }
    if (u.y > 0) {
      Stat v(as[u.x] + bs[u.y - 1] + cs[u.z], u.x, u.y - 1, u.z);
      if (ss.find(v) == ss.end()) {
	q.push(v);
	ss.insert(v);
      }
    }
    if (u.z > 0) {
      Stat v(as[u.x] + bs[u.y] + cs[u.z - 1], u.x, u.y, u.z - 1);
      if (ss.find(v) == ss.end()) {
	q.push(v);
	ss.insert(v);
      }
    }
  }
  return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> G[N];
    for(int i = 0; i < N - 1; i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<int> c(N);
    for(int i = 0; i < N; i++) cin >> c[i];
    sort(c.begin(), c.end(), greater<int>());
    queue<int> q;
    q.push(0);
    int now = 0;
    vector<int> score(N);
    score[0] = c[now];
    now++;
    vector<int> used(N);
    int ans = 0;
    while(!q.empty()){
        int v = q.front();
        q.pop();
        used[v] = 1;
        for(int j: G[v]){
            if(used[j] == 0){
                score[j] = c[now];
                now++;
                q.push(j);
                ans += min(score[v], score[j]);
            }
        }
    }
    cout << ans << endl;
    for(int i = 0; i < N; i++){
        if(i != N - 1) cout << score[i] << ' ';
        else cout << score[i] << endl;
    }
}

Measured memory_bytes: 4248
# coding: utf-8
# Your code here!
w,h,n=map(int,input().split())
x_max=0
x_min=w
y_max=0
y_min=h
flg=[0]*4
for i in range(n):
    x_,y_,a=map(int,input().split())
    if a==1:
        x_max=max(x_,x_max)
        flg[0]=1
    elif a==2:
        x_min=min(x_,x_min)
        flg[1]=1
    elif a==3:
        y_max=max(y_,y_max)
        flg[2]=1
    else:
        y_min=min(y_,y_min)
        flg[3]=1
if x_max>=x_min or y_max>=y_min:
    print(0)
else:
    print((x_min-x_max)*(y_min-y_max))

Measured memory_bytes: 38384
#include<iostream>
#include<vector>
#include<string>
#include<list>

// O(1) answer

int main(){
    int a, b;
    std::cin >> a >> b;
    double a_start = a / 0.08;
    double a_end = (a + 1) / 0.08;
    double b_start = b / 0.10;
    double b_end = (b + 1) / 0.10;

    std::list<int> x_a, x_b;
    for(int x = a_start; x <= a_end; x++){
        if(x * 8 / 100 == a) x_a.push_back(x);
    }
    for(int x = b_start; x <= b_end; x++){
        if(x * 10 / 100 == b) x_b.push_back(x);
    }

    for(auto aa : x_a){
        for(auto bb : x_b){
            if(aa == bb){
                std::cout << aa << std::endl;
                return 0;
            }
        }
    }

    std::cout << -1 << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define CHMAX 127
int main()
{
    string S;
    cin >> S;
    int K;
    cin >> K;
    vector<string> list;
    int len = S.size();
    for(int i = 0; i < len; ++i) {
        for(int j = 1; (i + j) <= len && j <= K; ++j) {
            list.push_back(S.substr(i, j));
        }
    }
    
    sort(list.begin(), list.end());
    unique(list.begin(), list.end());
    cout << list[K-1] << endl;
    return 0;
}

Measured memory_bytes: 1660
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

signed main() {
    int n, a, b; cin >> n >> a >> b;
    int x = n-2, y = b-a;
    if(a > b) cout << 0 << endl;
    else if(n == 1) {
        if(a == b) cout << 1 << endl;
        else cout << 0 << endl;
    }
    else cout << x * y + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,ans,a[200005];
int gcd(int x,int y){
	return y?gcd(y,x%y):x;
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	if (n==1) return puts("Second"),0;
	for (;;){
		int k0=0,k1=0,x;
		for (int i=1;i<=n;i++)
			if (a[i]&1) k1++,x=i;
			else k0++;
		if (k0&1){
			ans^=1;
			break;
		}
		if (k1>1||a[x]==1)
			break;
		a[x]--;
		int k=a[1]; ans^=1;
		for (int i=2;i<=n&&k>2;i++)
			k=gcd(k,a[i]);
		for (int i=1;i<=n;i++)
			a[i]/=k;
	}
	puts(ans?"First":"Second");
} 

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <stack>
#define INC(i, a, b) for(int i = a; i < b; ++i)
#define DEC(i, a, b) for(int i = a; i > b; --i)
#define REP(i, n)    for(uint i = 0; i < n; ++i)

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

using namespace std;

void TFprint(bool b, std::string T, std::string F){
    if(b){
        cout << T << endl;
    }else{
        cout << F << endl;
    }
}

int main(){
    uint len; cin >> len;
    stack<char> stk;
    string str;
    cin >> str;
    uint empty = 0;

    REP(i, len){
        if(str.at(i) == '('){
            stk.push('e');
        }else if(str.at(i) == ')'){
            if(stk.empty()){
                empty++;
            }else{
                stk.pop();
            }
        }
    }

    REP(i, empty){
        cout << '(';
    }
    cout << str;
    REP(i, stk.size()){
        cout << ')';
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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++)

using namespace std;

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> data(H, vector<char>(W));

  rep(i, H) {
    rep(j, W) {
      cin >> data.at(i).at(j);
    }
  }

  bool flg = true;
  unordered_set<int> rows;
  unordered_set<int> cols;
  rep(i, H) {
    rep(j, W) {
      if (data.at(i).at(j) == '#') {
        flg = false;
        break;
      }
    }
    if (flg) {
      rows.insert(i);
    } else {
      flg = true;
    }
  }

  rep(j, W) {
    rep(i, H) {
      if (data.at(i).at(j) == '#') {
        flg = false;
        break;
      }
    }
    if (flg) {
      cols.insert(j);
    } else {
      flg = true;
    }
  }

  rep(i, H) {
    if (rows.find(i) == rows.end()) {
      rep(j, W) {
        if (cols.find(j) == cols.end()) {
          cout << data.at(i).at(j);
        }
      }
      cout << endl;
    }
  }
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 60) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

string s;
set<char> ss;

int main() {
	cin >> s;
	rep(i, s.size()) {
		if (ss.find(s[i]) != ss.end()) {
			cout << "no" << endl;
			return 0;
		}
		ss.insert(s[i]);
	}
	cout << "yes" << endl;
}

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

int main() {
  int n;
  cin >> n;
  set<int> st;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    if (st.count(a)) {
      st.erase(a);
    } else {
      st.insert(a);
    }
  }
  cout << st.size() << endl;
}


Measured memory_bytes: 4864
n   = gets.to_i
ans = []

def check(ary)
  for i in 0 .. 8
    if ary[i] < 0
      break
    elsif ary[i] == 4
      ary[i]      = 0
      ary[i + 1] -= 1
      ary[i + 2] -= 1
    elsif ary[i] == 3
      ary[i]      = 0
    elsif ary[i] > 0
      ary[i + 1] -= ary[i]
      ary[i + 2] -= ary[i]
      ary[i]      = 0
    end
  end

  if ary.uniq == [0]
    return true
  else
    return false
  end
end

n.times do
  num   = gets.split.map(&:to_i)
  color = gets.chomp.split

  aryR = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
  aryG = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
  aryB = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

  9.times do |i|
    eval("ary" + color[i])[num[i] - 1] += 1
  end

  if check(aryR) && check(aryG) && check(aryB)
    ans << 1
  else
    ans <<  0
  end
end

ans.each do |a|
  puts a
end



Measured memory_bytes: 7148
#include <bits/stdc++.h>
using namespace std;
string a;
void solve()
{
    if (a[0]=='A')
    {
        int i,l=a.length(),num=0;
        if (a[1]=='C'||a[l-1]=='C') cout<<"WA";
        else
        {
            int res=0;
            if (a[1]>='a'&&a[1]<='z') res++;
            if (a[l-1]>='a'&&a[l-1]<='z') res++;
            for (i=2;i<l-1;i++)
                if (a[i]=='C') num++;
                else if (a[i]>='a'&&a[i]<='z') res++;
            if (num==1&&res==l-2) cout<<"AC";
            else cout<<"WA";
        }
    }
    else cout<<"WA";
    cout<<endl;
}
int main()
{
    while(cin>>a)
        solve();
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int n;
    scanf("%d",&n);
    int a[n],n4=0,no=0;
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        if(a[i]%4==0){
            n4++;
        }else if(a[i]%2==1){
            no++;
        }
    }
    
    if(n%2==1){
        if(n4>=no-1){
            printf("Yes");
            return 0;
        }
            printf("No");
            return 0;
    }else{
        if(n4>=no){
            printf("Yes");
            return 0;
        }
            printf("No");
            return 0;
    }
    
}

Measured memory_bytes: 512
# -*- coding: utf-8 -*-

infinity = pow(10, 9) + 1


def merge(ns, left, mid, right):
    global count
    left_ns = ns[left:mid] + [infinity]
    right_ns = ns[mid:right] + [infinity]
    i = j = 0
    for k in range(left, right):
        count += 1
        if left_ns[i] <= right_ns[j]:
            ns[k] = left_ns[i]
            i += 1
        else:
            ns[k] = right_ns[j]
            j += 1


def merge_sort(ns, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        merge_sort(ns, left, mid)
        merge_sort(ns, mid, right)
        merge(ns, left, mid, right)


n = int(input())
ns = [int(e) for e in input().split()]
# n = 10
# ns = [8, 5, 9, 2, 6, 3, 7, 1, 10, 4]
left = 0
right = len(ns)
count = 0
merge_sort(ns, left, right)

print(*ns)
print(count)

Measured memory_bytes: 63772
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll p=pow(10,9)+7;
ll phi(ll n) {
    ll result = n;
    for (ll i = 2; i * i <= n; i++) {
        if(n % i == 0) {
            while(n % i == 0)
                n /= i;
            result -= result / i;
        }
    }
    if(n > 1)
        result -= result / n;
    return result;
}
ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;      
    x = x % p;  
   while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p; 
    } 
    return res; 
} 

ll modInverse(ll n, ll p) 
{ 
    return power(n, p-2, p); 
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,i,j,k;
   cin>>n;
   ll arr[n];
   for(i=0;i<n;i++)
   cin>>arr[i];
  ll dp[n][n];
  for(i=n-1;i>=0;i--)
  {
      for(j=i;j<n;j++)
      {
          if(i==j)
          dp[i][j]=arr[i];
          else
          {
              dp[i][j]=std::max(arr[i]-dp[i+1][j],arr[j]-dp[i][j-1]);
          }
      }
  }
  cout<<dp[0][n-1];
  
      

   
  return 0;
    
}
    



Measured memory_bytes: 46464
#include <map>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>

#define x first
#define y second

#define INF 0x3f3f3f3f

using namespace std;

const int maxn = 1e5 + 10;

typedef long long LL;
typedef pair<int,int>PII;

string str;

int main(void) {
	cin >> str;
	bool vis = true;
	if(str.size() % 2 != 0) {
		cout << "No" << endl;
	} else {
		for(int i = 0; i < str.length(); i += 2) {
			if(str[i] == 'h' && str[i + 1] == 'i') {
				vis = true;
			} else {
				vis = false;
				break;
			}
		}
		if(vis) cout << "Yes" << endl;
		else cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 888
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

// input
reader.on('line', function(line) {
  var inputs = line.split(' ')
  var month = parseInt(inputs[0])
  var day = parseInt(inputs[1])
  var min = Math.min(month, day)
  console.log(min == month ? month : month - 1)
});

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

int main() {
  list<int> list_s;
  int list_s_count;
  cin >> list_s_count;
  for (int i = 0; i < list_s_count; i++) {
    int value;
    cin >> value;
    list_s.push_back(value);
  }

  int list_t_count;
  cin >> list_t_count;

  int count = 0;
  for (int i = 0; i < list_t_count; i++) {
    int value;
    cin >> value;
    for (auto it = list_s.begin(); it != list_s.end(); ++it) {
      if (*it == value) {
        count++;
        break;
      }
    }
  }
  cout << count << endl;

  return 0;
}


Measured memory_bytes: 3396
using System;

namespace ConsoleApp2
{
	class Program
	{
		static void Main(string[] args)
		{
			var nxt = Console.ReadLine().Split();
			var n = int.Parse(nxt[0]);
			var x = int.Parse(nxt[1]);
			var t = int.Parse(nxt[2]);

			Console.WriteLine((n + x - 1) / x * t);
		}
	}
}


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

int main(){
    int64_t N;
    cin >> N;
    N--;
    int64_t D = 1, P = 26;
    while(P <= N){
        N -= P;
        P *= 26;
        D++;
    }
    string ans;
    while(D--){
        ans.push_back('a'+(N%26));
        N /= 26;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int max=100001;
  vector<int> a(max,1);
  a[0]=0;
  a[1]=0;
  for(int i=2;i<max;i++){
    for(int j=i*2;j<max;j+=i) a[j]=0;
  }
  
  vector<int> b(max,0);
  for(int i=0;i<max;i++){
     if(i%2==0) continue;
    if(a[i]&&a[(i+1)/2]) b[i]=1;
  }
  
  vector<int> s(max+1,0);
  for(int i=0;i<max;i++) s[i+1]=b[i]+s[i];
  
  int q;
  cin>>q;
  for(int i=0;i<q;i++){
    int l,r;
    cin>>l>>r;
    r++;
    
    cout<<s[r]-s[l]<<endl;
  }
   return 0;
}


Measured memory_bytes: 1792
package main

import (
	"bufio"
	"os"
	"strings"
	"strconv"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

var (
	dx = []int{0, -1, 0, 1}
	dy = []int{1, 0, -1, 0}
)

func main() {
	for scanner.Scan() {
		buf := strings.Split(scanner.Text(), " ")
		w, _ := strconv.Atoi(buf[0])
		h, _ := strconv.Atoi(buf[1])
		if w == 0 && h == 0 {
			break
		}
		scanner.Scan()
		buf_ := strings.Split(scanner.Text(), " ")
		xs, _ := strconv.Atoi(buf_[0])
		ys, _ := strconv.Atoi(buf_[1])
		scanner.Scan()
		buf__ := strings.Split(scanner.Text(), " ")
		xg, _ := strconv.Atoi(buf__[0])
		yg, _ := strconv.Atoi(buf__[1])
		xs--
		ys--
		xg--
		yg--
		scanner.Scan()
		n, _ := strconv.Atoi(scanner.Text())
		field := make([][]int, 100)
		for i := range  field {
			field[i] = make([]int, 100)
		}
		visited := make([][]bool, 100)
		for i := range visited {
			visited[i] = make([]bool, 100)
		}
		for i := 0; i < n; i++ {
			scanner.Scan()
			buf___ := strings.Split(scanner.Text(), " ")
			c, _ := strconv.Atoi(buf___[0])
			d, _ := strconv.Atoi(buf___[1])
			x, _ := strconv.Atoi(buf___[2])
			y, _ := strconv.Atoi(buf___[3])
			x--
			y--
			switch d {
			case 0:
				for j := 0; j < 4; j++ {
					for k := 0; k < 2; k++ {
						field[x+j][y+k] = c
					}
				}
			case 1:
				for j := 0; j < 2; j++ {
					for k := 0; k < 4; k++ {
						field[x+j][y+k] = c
					}
				}
			}
		}
		if field[xs][ys] != field[xg][yg] || // スタートとゴールの色が等しくないと"NG"
			field[xs][ys] == 0 { // スタートの色が無職
			fmt.Println("NG")
			continue
		}
		Q := make([]Entry, 0)
		visited[xs][ys] = true
		Q = append(Q, Entry{xs, ys})
		for len(Q) > 0 {
			row := Q[0].x
			col := Q[0].y
			Q = Q[1:]
			for i := 0; i < 4; i++ {
				if 0 <= row+dx[i] && row+dx[i] < w &&
					0 <= col+dy[i] && col+dy[i] < h && // 移動可能な範囲内かどうか
					!visited[row + dx[i]][col + dy[i]] && // 訪問済みか
					field[row+dx[i]][col+dy[i]]==field[row][col] { // 色が同じかどうか
						visited[row+dx[i]][col+dy[i]] = true
						Q = append(Q, Entry{row+dx[i],col+dy[i]})
				}
			}
		}
		if visited[xg][yg] {
			fmt.Println("OK")
		} else {
			fmt.Println("NG")
		}
	}
}

type Entry struct {
	x, y int
}


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

using namespace std;
int main() {
int N;
string A,B,C;
std::cin >> N >> A >> B >> C;
int def=0;
for (size_t i = 0; i < N; i++) {
    if(A[i]!=B[i] && A[i]!=C[i] && B[i] != C[i])def=def+2;
    else if(A[i]!=B[i] && A[i]!=C[i] && B[i] == C[i])def=def+1;
    else if(A[i]!=B[i] && A[i]==C[i] && B[i] != C[i])def=def+1;
    else if(A[i]==B[i] && A[i]!=C[i] && B[i] != C[i])def=def+1;

    else if(A[i]!=B[i] && A[i]==C[i] && B[i] == C[i])def=def+1;
    else if(A[i]==B[i] && A[i]!=C[i] && B[i] == C[i])def=def+1;
    else if(A[i]==B[i] && A[i]==C[i] && B[i] != C[i])def=def+1;
    }
std::cout << to_string(def) << '\n';
    return 0;
}


Measured memory_bytes: 256
n = int(input())
arr = [list(map(int, input().split())) for i in range(n)]
arm = [list(map(int, input().split())) for j in range(n)]  # 入力

ans = -9999999999  # 最小
for item in range(1, 1024):  # 2 ** 10 == 1024
    fund = 0
    for i in range(n):  # 店の数
        cou = 0  # かぶる数
        for x in range(10):  # 月-金(5) * 2
            if (item >> x) % 2 == 1 and arr[i][x] == 1:  # その時間で被るかどうか
                cou += 1
        fund += arm[i][cou]
    ans = max(ans, fund)  # 最大値更新

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf=998244353;
const int mod=998244353;
int main(){
    while(1){
        ll n,k;cin>>n>>k;
        if(n==0&&k==0)break;
        vector<ll>a(k);
        bool f=0;
        vector<pair<pll,ll> >b(0);
        rep(i,k){
            cin>>a[i];
            if(a[i]==0)f=1;
        }
        sort(all(a));
        a.pb(inf);
        ll cnt=1;
        REP(i,1,k+1){
            if(a[i-1]==0)continue;
            if(a[i]==a[i-1]+1)cnt++;
            else{
                b.pb(mp(mp(a[i-1],a[i]),cnt));
                //cout<<a[i-1]<<' '<<a[i]<<' '<<cnt<<endl;
                cnt=1;
            }
        }
        ll ans=0;
        rep(i,b.size()){
            ans=max(ans,b[i].second);
        }
        if(f){
        rep(i,b.size()-1){
            if(b[i].first.first+2==b[i].first.second){
                ans=max(ans,b[i].second+b[i+1].second+1);
            }
        }
        }
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 4140
#include<cstring>
#include<cstdio>
#include<vector>
using namespace std;
const int N = 1000010;
int n, a[N];
bool res[N], b[N];
vector<int>g[N];
 
void solve1(int x, int pre) {
    res[x] = 0;
    for (int i = 0; i < g[x].size(); ++i) {
        int y = g[x][i];
        if (y == pre) continue;
        solve1(y, x);
        if (!res[y] && a[x] > a[y]) res[x] = 1;
    }
}
 
void solve2(int x, int pre) {
    b[x] = res[x];
    for (int i = 0; i < g[x].size(); ++i) {
        int y = g[x][i];
        if (y == pre) continue;
        bool d = res[y];
        if (!res[x] && a[y] > a[x]) res[y] = 1;
        solve2(y, x);
        res[y] = d;
    }
}
 
int main() {
//  freopen("C.in", "r", stdin);
//  freopen("C.out", "w", stdout);
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
    for (int i = 1; i < n; ++i) {
        int x, y; scanf("%d%d", &x, &y);
        g[x].push_back(y);
        g[y].push_back(x);
    }
    solve1(1, 0);
    solve2(1, 0);
    for (int i = 1; i <= n; ++i) if (b[i]) printf("%d ", i);
     
//  fclose(stdin), fclose(stdout);
    return 0;
}

Measured memory_bytes: 27136
#include <stdio.h>
#include <string.h>

void print(char *,char *);

int main(int argc, char const *argv[]) {

  char T[2000];
  char P[2000];
  int T_len;
  int P_len;

  scanf("%s",T);
  scanf("%s",P);

  print(T,P);


  return 0;
}

void print(char *T,char *P){

  int i,j;
  int count_len;
  int T_len = strlen(T);
  int P_len = strlen(P);

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

    if( T[i] == P[0] ){
      count_len = 1;
      for( j = 1 ; j < P_len ; j++ ){
        if( T[i+j] == P[j] ){
          count_len++;
        }
      }
      if( count_len == P_len ){
        printf("%d\n",i);
      }

    }

  }

}

Measured memory_bytes: 548
#include <bits/stdc++.h>
#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 pi 3.14159265359
#define all(i) i.begin(),i.end()
using namespace std;
const long long INF=1e9+7;
const string alp="abcdefghijklmnopqrstuvwxyz"; //26
const string ALP="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;


int main() {
  ll N,D;
  cin>>N>>D;
  ll x[N],y[N];
  rep(i,N) cin>>x[i]>>y[i];
  ll ans=0;
  rep(i,N){
    if(x[i]*x[i]+y[i]*y[i]<=D*D) ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 6808
N = int(input())
S = input()
eastcount = [0 for i in range(N+1)]

for i in range(N):
    if S[i] == "E":
        eastcount[i+1] = eastcount[i] + 1
    else:
        eastcount[i+1] = eastcount[i]
ans = 1000000
ans = min(ans, eastcount[N] - eastcount[1])
ans = min(ans, N - 1 - eastcount[N-1])
for i in range(1, N):
    ans = min(ans, (i-1 - eastcount[i-1]) + (eastcount[N] - eastcount[i]))
print(ans)


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

count = 0
for i in range(N):
  A = [int(_) for _ in input().split()] 
  sum = 0
  for j in range(M):
    sum += B[j]*A[j]
  if sum+C > 0:
    count += 1

print(count)

Measured memory_bytes: 3060
#pragma region header
#define _GLIBCXX_DEBUG 
#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;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define ts to_string
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector <string>
#define vvs vector <vector<string>>
#define pq  priority_queue<int>
using ll = long long;
/* ----------------よく使う数字や配列----------------- */
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */
/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
bool isprime(ll a)//素数判定、primeならtrue,違うならfalse
{
    if (a < 2) return false;
    else if (a == 2) return true;
    else if (a % 2 == 0) return false;
    double m = sqrt(a);
    for (int i = 3; i <= m; i += 2)
    {
        if (a % i == 0)
        {
            return false;
        }
    }
    // 素数である
    return true;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
ll kind(vi SYURUI) {//vector<int>型の配列の要素の種類数
    int size = SYURUI.size();
    sort(all(SYURUI));
    int cnt = 1;
    rep(i, size-1) {
        if (SYURUI[i] != SYURUI[i + 1])cnt++;
    }
    return cnt;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    int N, M; cin >> N >> M;
    vector<pair<int, int>>A(M); rep(i, M)cin >> A[i].first >> A[i].second;
    rep1(i, N) {
        int cnt = 0;
        rep(j, M) {
            if (A[j].first == i || A[j].second == i)cnt++;
        }
        cout << cnt << endl;
    }
}






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

int n, a[20][20];
long long ans = -1e18;
long long dp[1<<16];

long long func(int s){
//	cout << s << "\n";
	if(dp[s] != -1e18) return dp[s];
	long long res = 0;
	for(int i=0; i<n; ++i)
		for(int j=i+1; j<n; ++j)
			if((s >> i) % 2 == 1 && (s >> j) % 2 == 1)
				res += a[i][j];
	for(int i=(s-1)&s; i>0; i=(i-1)&s){
		res = max(res, func(i) + func(s-i));
	}
//	cout << s << " " << res << "\n";
	return dp[s] = res;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	for(int i=0; i<n; ++i)
		for(int j=0; j<n; ++j)
			cin >> a[i][j];
	for(int i=0; i<(1<<n); ++i)
		dp[i] = -1e18;
	cout << func((1<<n)-1) << "\n";
}

Measured memory_bytes: 768
#include<stdio.h>

int main(){
    int a ,b,c;
  scanf("%d %d",&a ,&b);
  if(a==2){
      a=10000;
  }else if(a==1){
      a=100;
  }else if(a==0){
      a=1;
  }
  
  
  if(b==100){
  c=a*(b+1);
  }else{
  c=a*b;
  }
  printf("%d",  c);

return 0;
}

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

#define loop(i,n) for(int i=1;i<=n;i++)
int ww[52],bb[52],rr[52];

int main(){
  int n,m;
  char c;
  cin>>n>>m;
  loop(i,n){
    ww[i]=bb[i]=rr[i]=0;
    loop(j,m){
      cin>>c;
      if(c=='W')ww[i]++;
      else if(c=='B')bb[i]++;
      else if(c=='R')rr[i]++;
    }
  }
  int maxk=0;
  for(int w=1;w+1+1<=n;w++){
    for(int b=1;w+b+1<=n;b++){
      int keep=0,i=1;
      for(;i<=w;i++)keep+=ww[i];
      for(;i<=w+b;i++)keep+=bb[i];
      for(;i<=n;i++)keep+=rr[i];
      if(maxk<keep)maxk=keep;
    }
  }
  cout<<(n*m-maxk)<<endl;
  return 0;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define LLMAX (1ll << 60) - 1
#define INTMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define vi vector<int>
#define print(x)    for(auto it=x.begin();it!=x.end();it++) cout<<*it<<' '; cout<<endl;
#define in(x,n)   for(int e=0;e<n;e++){int y;cin>>y;x.pb(y);}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,x;
    cin>>n;
    cout<<n*n*n;

    return 0;
}




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

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //cout<<fixed<<setprecision(10);
  ll res=0,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<ll>a(n);
  rep(i,0,n)cin>>a[i];
  ll diam=*max_element(ALL(a));
  vector<ll>d(diam+1);
  rep(i,0,n)d[a[i]]++;
  rep(i,0,diam/2)if(d[i]!=0)judge=false;
  if(diam%2==0&&d[diam/2]!=1)judge=false;
  if(diam%2==1&&d[(diam+1)/2]!=2)judge=false;
  rep(i,diam/2+1,diam+1)if(d[i]<2)judge=false;
  ans(judge,"Possible","Impossible");
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func bsearch(a []int, key int) int {
	left, right := 0, len(a)-1
	for left <= right {
		mid := (left + right) / 2
		if a[mid] == key {
			return mid
		} else if a[mid] < key {
			left = mid + 1
		} else {
			right = mid - 1
		}
	}
	return -1
}

func main() {
	var n int
	fmt.Scan(&n)
	S := make([]int, n)
	for i := range S {
		fmt.Scan(&S[i])
	}
	var q, ans int
	fmt.Scan(&q)
	for i := 0; i < q; i++ {
		var t int
		fmt.Scan(&t)
		if bsearch(S, t) >= 0 {
			ans++
		}
	}
	fmt.Println(ans)
}



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

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

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;

void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main()
{
 
	//cin.tie(0); ios_base::sync_with_stdio(false);
	string s;
	cin >> s;
	int sm =0, x = stoi(s);
	for(auto z: s) sm += z -'0';
	cout << (x%sm==0? "Yes": "No") <<"\n";
	return 0;
}

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<" : "<<x<<endl
#define ALL(v) (v).begin(),(v).end()

int mp[10][10];

bool check(int a,int b,int c,int d,int e){
  int x = 0;
  x = mp[x][a];
  x = mp[x][b];
  x = mp[x][c];
  x = mp[x][d];
  x = mp[x][e];
  return x==0;
}

int solve(int id){
  int a = id%10; id/=10;
  int b = id%10; id/=10;
  int c = id%10; id/=10;
  int d = id%10; id/=10;
  int e = id%10; id/=10;
  swap(a,e);
  swap(b,d);
  REP(i,10)if(a!=i && check(i,b,c,d,e))return 1;
  REP(i,10)if(b!=i && check(a,i,c,d,e))return 1;
  REP(i,10)if(c!=i && check(a,b,i,d,e))return 1;
  REP(i,10)if(d!=i && check(a,b,c,i,e))return 1;
  REP(i,10)if(e!=i && check(a,b,c,d,i))return 1;
  if(a!=b && check(b,a,c,d,e))return 1;
  if(c!=b && check(a,c,b,d,e))return 1;
  if(c!=d && check(a,b,d,c,e))return 1;
  if(e!=d && check(a,b,c,e,d))return 1;
  return 0;
}

int main(){
  REP(i,10)REP(j,10)scanf("%d",&mp[i][j]);
  int ans = 0;
  REP(id,10000){
    int a=id%10;
    int b=(id/10)%10;
    int c=(id/100)%10;
    int d=(id/1000);
    swap(a,d);
    swap(b,c);
    int e=mp[0][a];
    e=mp[e][b];
    e=mp[e][c];
    e=mp[e][d];
    ans += solve(id*10+e);
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 3224
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int L[] = new int[N];
		int R[] = new int[N];
		ArrayList<int[]> q = new ArrayList<int[]>(); 		
		for(int i=0;i<N;i++){
			L[i]=sc.nextInt();
			R[i]=sc.nextInt();
			int tmp[] = {L[i],R[i]};
			q.add(tmp);
		}
		sc.close();
		long ans = 0;

		//左端で降順にソート
		Collections.sort(q,(q1,q2)->q2[0]-q1[0]);
		int lmax[] = q.get(0);
		//右端で昇順にソート
		Collections.sort(q,(q1,q2)->q1[1]-q2[1]);
		int rmin[] = q.get(0);
		//幅で降順にソート
		Collections.sort(q,(q1,q2)->(q2[1]-q2[0])-(q1[1]-q1[0]));
		int wmax[] = q.get(0);
		//左端最大の区間と、右端最小の区間を同じコンテストに出題するとき
		if(N==2);//N=2なら何もしない
		else{
		int k=0;
		while(wmax==lmax|wmax==rmin){
			k++;
			wmax = q.get(k);
		}
		ans = Math.max((rmin[1]-lmax[0]+1),0) + (wmax[1]-wmax[0]+1);
		}
		//左端最大の区間と、右端最小の区間が異なるコンテストに出題するとき
		//左端で降順にソート
		Collections.sort(q,(q1,q2)->q2[0]-q1[0]);
		int remain_rmin = Integer.MAX_VALUE;
		int tmp_ans=0;
		for(int i=0;i<N;i++){
			int tmp[] = q.get(i);
			
			if(i<=1) remain_rmin = lmax[1] ;
			else{
				remain_rmin = Math.min(remain_rmin, q.get(i-1)[1]);
			}
			tmp_ans = Math.max((rmin[1]-tmp[0]+1),0) + Math.max((remain_rmin-lmax[0]+1),0);
			ans = Math.max(ans,tmp_ans);
 		}	
		System.out.println(ans);
	}
}


Measured memory_bytes: 96436