akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

class SelectionSort {
public:

	int sw = 0, minj, t,i,j;

	int Sort(int A[],int N) {
		for (i = 0; i < N; i++) {
			minj = i;
			for (j = i; j < N; j++) {
				if (A[j] < A[minj]) {
					minj = j;
				}
			}
			swap(A[i], A[minj]);
			if (i != minj) {
				sw++;
			}
		}
		return sw;
	}
};

int main() {
	int A[100], N,sw;

	cin >> N;

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

	SelectionSort ss;

	sw = ss.Sort(A, N);

	for (int i = 0; i < N; i++) {
			if (i) {
				cout << " ";
			}
			cout << A[i];
		}
	cout << endl;
	cout << sw;
	cout << endl;
}

Measured memory_bytes: 3084
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <complex>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
#include <iterator>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
string dp[11111];
int main(){
  int n,m,a[10]={};
  int cost[10]={0,2,5,5,4,5,6,3,7,6};
  cin>>n>>m;
  for(int i=0;i<m;i++){
    int t;
    cin>>t;
    a[t]=1;
  }

  fill_n(dp,11111,"0");
  dp[0]="";
  for(int i=0;i<n;i++){
    if(dp[i]=="0")continue;
    for(int j=1;j<=9;j++){
	 if(a[j]==0)continue;
	 int nj=cost[j];
	 string tmp=dp[i];
	 tmp.pb((char)('0'+j));//+(char)('0'+j);
	 if(dp[i+nj].size()>tmp.size())continue;
	 if(dp[i+nj].size()<tmp.size())dp[i+nj]=tmp;
	 else if(dp[i+nj]<tmp)dp[i+nj]=tmp;
    }
  }
  cout<<dp[n]<<endl;
  return 0;
}



Measured memory_bytes: 45184
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};
const ll INF = 1001001001;

int main(){
    int N;
    cin >> N;
    for(int A=1;A<=9;A++){
        if(N%A == 0){
            int B = N/A;
            if(B>=1 && B<=9){
                cout << "Yes" << endl;;
                exit(0);
            }
        }
    }
    cout << "No" << endl;
}


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------
int H, W, N;
set<pair<int, int>> F, cand;
ll ans[10];

void add_cand(int y, int x) {
   if (y >= 0 && y < H-2 && x >= 0 && x < W-2) cand.insert({y, x});
}

int main() {
   cin >> H >> W >> N;
   rep (i, N) {
      int a, b;
      cin >> a >> b;
      a--, b--;
      F.insert({a, b});
      for (int dy = 0; dy < 3; dy++) {
         for (int dx = 0; dx < 3; dx++) {
            add_cand(a-dy, b-dx);
         }
      }
   }

   ans[0] = (ll)(H-2) * (W-2);
   for (auto c : cand) {
      int y = c.first, x = c.second;
      int num = 0;
      for (int i = 0; i < 3; i++) {
         for (int j = 0; j < 3; j++) {
            if (F.count({y+i, x+j})) ++num;
         }
      }
      ans[0]--;
      ans[num]++;
   }

   for (int i = 0; i <= 9; i++) {
      printf("%lld\n", ans[i]);
   }

   return 0;
}

Measured memory_bytes: 47104
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    float sum = v[0];
    for(int i=1; i < n; i++){
        sum = (sum + v[i]) / 2;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
ll MOD  = 1000000007;
vector<int> dy = {0,0,1,-1};
vector<int> dx = {1,-1,0,0};

int main(void){
    cin.tie(0);
   	ios::sync_with_stdio(false);
   	int a,b,c,d;
   	cin >> a >> b >> c >> d;
   	cout << min(a, b) + min(c, d) << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int d;
	cin >> d;

	if(d==22) cout << "Christmas Eve Eve Eve" << endl;
	if(d==23) cout << "Christmas Eve Eve" << endl;
	if(d==24) cout << "Christmas Eve" << endl;
	if(d==25) cout << "Christmas" << endl;
}

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

int main(){
    int N, A, B, C;
    std::cin >> N >> A >> B >> C;
    std::vector< int > L(N);
    for(int i=0; i<N; i++){
        std::cin >> L[i];
    }
    
    int min = 1e9;
    for(int i=0; i<(int)std::pow(2, N*2); i++){
        std::vector< int > length(4, 0);
        std::vector< int > cnt(4, 0);
        for(int j=0; j<N; j++){
            int mask = 3 << (j*2);
            int index = (i & mask) >> (j*2);
            length[index] += L[j];
            cnt[index]++;
        }
        if(cnt[0] && cnt[1] && cnt[2]){
            std::sort(length.begin(), length.end()-1);
            int useMP =   std::abs(length[2] - A)
                        + std::abs(length[1] - B)
                        + std::abs(length[0] - C)
                        + 10 * (cnt[0] + cnt[1] + cnt[2] - 3);
            if(min > useMP){
                min = useMP;
            }
        }
    }
    
    std::cout << min << std::endl;;
    
    return 0;
    
}


Measured memory_bytes: 4020
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

char s[112345];

int main(){
	int n, k; scanf("%d%d%s", &n, &k, s+1);
	s[0] = 'R'; s[n+1] = 'L';
	int ans = 0;
	FOR(i, 1, n+1) {
		if(s[i] == 'L' && s[i-1] == 'L') ans++;
		if(s[i] == 'R' && s[i+1] == 'R') ans++;
	}
	REP(i, k) if(ans+2<=n) ans+=2;
	if(ans==n) ans--;
	printf("%d\n", ans);
}


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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
typedef long long ll;

int main(){
  int n,p;
  cin >> n;
  int sum = 0;
  int mx = 0;
  rep(i,n){
    cin >> p;
    mx = max(mx,p);
    sum += p;
  }
  cout << sum-mx/2 << endl;
}


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

int main()
{
  int N, K;
  cin >> N >> K;

  vector<int> A(N+1);
  int index_A;
  for (int i = 0; i < N; i++) {
    cin >> index_A;
    A[index_A]++;
  }

  sort(A.begin() + 1, A.end());
  // for (int i = 0; i <= N; i++) {
  //   cout << A[i] << ' ';
  // } cout << endl;

  int sum = 0;
  for (int i = N - K; 0 < i; i--) { // begin with index 1
    if (A[i] == 0) break; // 降順で0に来たら足さなくてよい
    sum += A[i];
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cassert>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define POW(n) ((n) * (n))
#define ALL(a) (a).begin(), (a).end()
#define dump(v) (cerr << #v << ": " << v << endl)
#define cerr                                                                   \
  if (true)                                                                    \
  cerr

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;

// ll n = to_T<ll>("114514")
template <class T> T to_T(const string &s) {
  istringstream is(s);
  T res;
  is >> res;
  return res;
}
template <class T> string to_s(const T &a) {
  ostringstream os;
  os << a;
  return os.str();
}

void solve(long long N, vector<long long> A) {
  map<int, int> M;
  deque<int> q;

  sort(ALL(A));
  REP(i, N) { M[A[i]]++; }

  for (auto itr = M.begin(); itr != M.end(); ++itr) {
    if (itr->second == 1)
      continue;
    REP(i, itr->second - 1)
    q.push_back(itr->first);
  }

  sort(ALL(q));

  ll ans = N - q.size();
  if (q.size() % 2 != 0)
    ans--;

  cout << ans << endl;
}

int main() {
  ios::sync_with_stdio(false);
  long long N;
  cin >> N;
  vector<long long> A(N - 1 + 1);
  for (int i = 0; i <= N - 1; i++) {
    cin >> A[i];
  }
  solve(N, A);
  return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <cstdio>
using namespace std;
int main(void){
    char ch;
    while (1) {
        scanf("%c", &ch);
        if ('a' <= ch && ch <= 'z') {
            ch = ch - 'a' + 'A';
        } else if ('A' <= ch && ch <= 'Z') {
            ch = ch - 'A' + 'a';
        }
        cout << ch;
        if (ch == '\n') break;
    }
}

Measured memory_bytes: 3144
n = gets.to_i
n.times do
  gx, gy = gets.split.map(&:to_i)
  k = gets.to_i
  forbidden = {}
  k.times do
    x1, y1, x2, y2 = gets.split.map(&:to_i)
    x1, y1, x2, y2 = x2, y2, x1, y1 if x2 + y2 < x1 + y1
    forbidden[[x1, y1, x2, y2]] = 1
  end
  a = (0..gx+1).map {(0..gy+1).map { 0 } }
  a[0][0] = 1
  (0..gx).each do |x|
    (0..gy).each do |y|
      a[x+1][y] += a[x][y] unless forbidden[[x, y, x+1, y]]
      a[x][y+1] += a[x][y] unless forbidden[[x, y, x, y+1]]
    end
  end
  puts a[gx][gy] == 0 ? 'Miserable Hokusai!' : a[gx][gy]
end


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

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

using ll = long long;
using lb = long double;
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

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

int main(){
    ll N,X,M;
    cin>>N>>X>>M;
    map<ll,bool> done;
    vector<ll> v;
    v.push_back(X%M);
    done[X%M] = true;
    while(true){
        ll t = *v.rbegin();
        if(done[(t*t)%M]) {
            v.push_back((t*t)%M);
            break;
        }
        else{
            v.push_back((t*t)%M);
            done[(t*t)%M] = true;
        }
    }
    ll ans = 0;
    ll t = *v.rbegin();
    ll p = 0;
    rep(i,v.size()){
        if(v[i] == t) {
            p = i;
            break;
        }
    }
    rep(i,p) ans += v[i];
    ll loop = v.size() - p - 1;
    ll loopsum = 0;
    for(int i = p; i < (int)v.size() - 1; i++) loopsum += v[i];
    ans += ((N-p)/loop)*loopsum;
    rep(i,(N-p)%loop){
        ans += v[p+i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 6768
#include<iostream>
using namespace std;
int A[1005][1005];
int main(){
  int N,M,X;
  cin>>N>>M>>X;
  for(int i=0; i<N; i++){
    cin>>A[i][0];
    for(int j=1; j<=M; j++){
      cin>>A[i][j];
    }
  }
  int v=0;
  int res=-1;
  while(v<(1<<N)){
    int tmp=v;
    int cnt=0;
    int sum=0;
    int valc[1005]={0};
    while(tmp!=0){
      if(tmp%2==1){
        sum+=A[cnt][0];
        for(int i=1; i<=M; i++){
          valc[i]+=A[cnt][i];
        }
      }
      cnt++;
      tmp>>=1;
    }
    bool c=true;
    for(int i=1; i<=M; i++){
      if(valc[i]<X){
        c=false;
        break;
      }
    }
    if(c){
      if(res==-1 || res>sum) res=sum;
    }
    v++;
  }
  cout<<res;
  return 0;
}


Measured memory_bytes: 3676
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jeel Vaishnav
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABiscuitGenerator solver = new ABiscuitGenerator();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABiscuitGenerator {
        public void solve(int testNumber, InputReader sc, PrintWriter out) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            int t = sc.nextInt();

            int ans = t / a * b;
            out.print(ans);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 21332
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
typedef long long ll;
const ll MAXN=100000,INF=100000000000001;
ll a[MAXN+5],sum1[MAXN+5],sum2[MAXN+5];
ll n,k,Min=INF,Max=-INF,temp;
int main()
{
	scanf("%lld%lld",&n,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		if(a[i]>0)
		{
			sum1[i]=sum1[i-1]+a[i];
			sum2[i]=sum2[i-1];
		}
		else
		{
			sum1[i]=sum1[i-1];
			sum2[i]=sum2[i-1]+a[i];
		}
		if(i>=k)
		{
			temp=sum1[i]-sum1[i-k];
			Min=min(Min,temp);
			temp=sum2[i]-sum2[i-k];
			Max=max(Max,temp);
		}
	}
	printf("%lld\n",max(sum1[n]+Max,sum1[n]-Min));
	return 0;
}


Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int p = sc.nextInt(), q = sc.nextInt(), r = sc.nextInt();
        System.out.println(p + q + r - Math.max(p, Math.max(q, r)));
    }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,n) for(int i=s;i<n;i++)
int main(){
    int K;
    string S;
    cin>>K>>S;
    int str_len=S.length();
    if(str_len<=K){
        cout<<S<<endl;
        return 0;
    }else{
        for(int i=0;i<K;i++)
            cout<<S[i];
        cout<<"..."<<endl;
        return 0;
    }
      
}

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

int main(){
    int n;
    cin >> n;
    set<string> st;
    for(int i=0; i<n; i++){
        string s;
        cin >> s;
        st.insert(s);
    }
    cout << st.size() << endl;
    return 0;
}

Measured memory_bytes: 19248
#pragma comment(linker, "/stack:247474112")
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < n; ++i)
#define RANGE(i, x, n) for(ll i = x; i < n; ++i)
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> A(n, 0);
    REP(i, n) {
        cin >> A[i];
    }
    REP(i, n) {
        if(A[i] > i+1) {
            cout << -1 << endl;
            return 0;
        }
    }
    vector<int> ans(n, 0);

    for(int i = n-1; i >= 0; --i) {
        int pos = A[i]-1;
        REP(j, n) {
            if(ans[j] == 0) {
                --pos;
            }
            if(pos < 0) {
                ans[j] = A[i];
                break;
            }
        }
    }
    for(auto x: ans) {
        cout << x << endl;
    }
}


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

using namespace std;

template<typename T>
vector<int> kmp(T &str){
	int n=str.size();
	vector<int> res(n+1,-1);
	for(int i=0,j=-1;i<n;res[++i]=++j){
		while(j>=0 && str[i]!=str[j]) j=res[j];
	}
	return res;
}
vector<int> sol(vector<long long> a,vector<long long> b){
	int n=a.size();
	vector<int> res;
	vector<long long> aa(n),bb(n*2);
	for(int i=0;i<n;i++){
		aa[i]=a[i]^a[(i+1)%n];
		bb[i]=b[i]^b[(i+1)%n];
	}
	for(int i=0;i<n;i++){
		bb[i+n]=bb[i];
	}
	vector<int> k=kmp(aa);
	aa.push_back(-1);
	int i=0,p=0;
	while(i<bb.size() && p<aa.size()){
		if(bb[i]==aa[p]){
			i++;
			p++;
		}else if(p==0){
			i++;
		}else{
			p=k[p];
		}
		if(p==n){
			//cout << "! " << i << "\n";
			res.push_back(i-n);
		}
	}
	return res;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	cin >> n;
	vector<long long> a(n),b(n);
	for(int i=0;i<n;i++) cin >> a[i];
	for(int i=0;i<n;i++) cin >> b[i];
	
	vector<int> res=sol(a,b);
	vector<pair<int,int>> res2;
	for(int i=0;i<res.size();i++){
		if(res[i]>=n) break;
		res2.push_back(make_pair((n-res[i])%n,a[0]^b[res[i]]));
	}
	sort(res2.begin(),res2.end());
	for(int i=0;i<res2.size();i++){
		cout << res2[i].first << " " << res2[i].second << "\n";
	}
	return 0;
}

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

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

using ll = long long;

int main() {
  int H, W, N;
  cin >> H >> W >> N;
  vector<int> v(N);
  for(int i = 0; i < N; i++) {
    cin >> v.at(i);
  }
  vector<vector<int>> vv(H, vector<int>(W));
  int cnt = 0;
  int num = 1;
  for(int i = 0; i<H; i++) {
    for(int j = 0; j < W; j++) {
      vv.at(i).at(j) = num;
      cnt++;
      if(v.at(num-1) == cnt){
        cnt=0;
        num++;
      }
    }
  }
  for(int i = 0; i < H; i++) {
    if(i%2 == 1) reverse(vv.at(i).begin(), vv.at(i).end());
  }
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      cout << vv.at(i).at(j) << " ";
    }
    cout << endl;
  }
}

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

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;
typedef double              DOUBLE;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)

using namespace std;

int main() {

	SINT32 N = 0;
	SINT32 ANS = 0;
	SINT8 S[101];

	cin >> N;
	cin >> S;

	for (SINT32 i = 0; i < N; i++) {
		SINT32 XD[26];
		SINT32 YD[26];
		SINT32 BUF = 0;
		for (SINT32 j = 0; j < 26; j++) {
			XD[j] = 0;
			YD[j] = 0;
		}

		for (SINT32 j = 0; j < N; j++) {
			if (j < i) {
				XD[S[j]-'a']++;
			} else {
				YD[S[j]-'a']++;
			}
		}

		for (SINT32 j = 0; j < 26; j++) {
			if ((XD[j] >= 1) && (YD[j] >= 1)) {
				BUF++;
			}
		}
		ANS = MAX(ANS,BUF);
	}

	cout << ANS << endl;
	return 0;
}

//	sort(DATA.begin(),DATA.end());
//	sort(DATA.begin(),DATA.end(),std::greater<SINT32>());
//	__gcd(ANS,DATA[i]);

//	// DATA.emplace_back(BUF);	//後ろに追加

//  DATA.erase(std::unique(DATA.begin(), DATA.end()), DATA.end());

//	vector<vector<SINT32>> DP(N,vector<SINT32>(3));　//2次元配列

/*
	SINT32 M = 3;
	vector<pair<SINT32,SINT32>> DATA2(M);
	for (SINT32 i = 0; i < M; i++) {
		cin >> DATA2[i].first;
		cin >> DATA2[i].second;
	}
	sort(DATA2.begin(),DATA2.end());
	cout << DATA2[0].first << endl;
	cout << DATA2[0].second << endl;
*/

// 	vector<pair<int,pair<int,int>>> DATA(M);
//	cin >> DATA[i].first;
//	cin >> DATA[i].second.first;
//	cin >> DATA[i].second.second;


//		APOSI = lower_bound(ADATA.begin(),ADATA.end(),QDATA[i]) - ADATA.begin();
//		BPOSI = lower_bound(BDATA.begin(),BDATA.end(),QDATA[i]) - BDATA.begin();


/* 文字列回転
	string N;
	cin >> N;
	N = N[N.length()-1] + N.substr(0,N.length()-1);
*/

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

using namespace std;
int main(){

	double N=0,K=0;
	double count = 0;

	cin >> N;
	cin >> K;
	vector<int> h(N);

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

	for (int i = 0; i < N; i++)
	{
		if (h[i]>=K)
		{
			count++;
		}
	}

	cout << count;
	return 0;
}

Measured memory_bytes: 640
import std.algorithm;
import std.array;
import std.bigint;
import std.bitmanip;
import std.conv;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T diff(T)(const ref T a, const ref T b) { return a > b ? a - b : b - a; }

T[] readToArray(T)() {
    return readln.split.to!(T[]);
}

void readInto(T...)(ref T ts) {
    auto ss = readln.split;
    foreach(ref t; ts) {
        t = ss.front.to!(typeof(t));
        ss.popFront;
    }
}

// 冪乗をmod取りつつ計算
@nogc @safe pure ulong modPow(ulong a, ulong n, ulong m) {
    ulong r = 1;
    while (n > 0) {
        if(n % 2 != 0) r = r * a % m;
        a = a * a % m;
        n /= 2;
    }
    return r;
}

// フェルマーの小定理から乗法逆元を計算
// 定理の要請により法は素数
@nogc @safe pure ulong modInv(ulong a, ulong m) {
    return modPow(a, m-2, m);
}

// mod取りつつ順列を計算
@nogc @safe pure ulong modPerm(ulong n, ulong k, ulong m) {
    if (n < k) return 0;

    ulong r = 1;
    for (ulong i = n-k+1; i <= n; i++) {
        r *= i;
        r %= m;
    }
    return r;
}

// mod取りつつ順列を計算
@nogc @safe pure ulong modFact(ulong n, ulong m) {
    return modPerm(n, n, m);
}

// mod取りつつ組み合わせを計算
// modInvを使っているので法は素数
@nogc @safe pure ulong modComb(ulong n, ulong r, ulong m) {
    return modPerm(n, r, m)*modInv(modFact(r, m), m) % m;
}

immutable ulong MOD = 1000000007;

void main() {
    ulong n, d;
    readInto(n, d);
    writeln((n+2*d)/(2*d+1));
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import static java.lang.System.in;

public class Main {
    ArrayList<Integer>[] graph;
    HashSet<Integer> cycle;
    int[] prev;
    PrintWriter out = new PrintWriter(System.out);
    // no self-loop or multiple edges
    public static void main(String[] args) throws Exception {
        Main main = new Main();
//        main.solve();
        System.out.println(main.solve());
    }
    long solve(){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i=0;i<n;i++) a[i] = sc.nextInt();
        long ans = 0;
        int mini = Integer.MAX_VALUE;
        for(int i=0;i<n;i++){
            if(a[i]<=mini) ans += 1;
            mini = Math.min(mini,a[i]);
        }
        return ans;
    }
}



Measured memory_bytes: 77204
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=(0);i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int N=605,mod=1e9+7;
int f[N][N],g[N][N],c[N][N],mn[N][N],mx[N][N],h[N],L[N],R[N];
int n,m,a,b,ans;

int main(){
	read(n),read(m),n*=2;
	h[0]=1;
	rep(i,1,n)h[i]=(ll)h[i-1]*(2*i-1)%mod;
	memset(mn,0x3f,sizeof mn);
	rep(i,1,m){
		read(a),read(b);
		if(a>b)swap(a,b);
		R[a]=b,L[b]=a;
		mx[a][a]=b,mn[b][b]=a;
	}
	rep(i,1,n+1){
		if(!L[i]&&!R[i])c[i][i]=1;
		g[i][i-1]=1;
	}
	per(l,n,1)rep(r,l+1,n){
		c[l][r]=c[l][r-1]+c[r][r];
		mn[l][r]=min(mn[l][r-1],mn[r][r]);
		mx[l][r]=max(mx[l][r-1],mx[r][r]);
		if((r-l+1)%2||mn[l][r]<l||mx[l][r]>r)continue;
		f[l][r]=g[l][r]=h[c[l][r]/2];
		rep(k,l+1,r-1)
			f[l][r]=(f[l][r]+mod-(ll)f[l][k]*g[k+1][r]%mod)%mod;
		ans=(ans+(ll)f[l][r]*h[(n-2*m-c[l][r])/2])%mod;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 7424
import re
s = input()
p = re.compile('[a-z]+')
ans = ''
if s[0] == 'A' and s[2:-1].count('C') == 1:
  s = s.replace('A', '').replace('C', '')
  if p.fullmatch(s):
    ans = 'AC'
  else:
    ans = 'WA'
else:
  ans = 'WA'
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define PI 3.1415926535897932384626433
#define mod 1000000007
 
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
 
int lcm(int a, int b) { return a * b / gcd(a, b); }
 
int main(){
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }

    int cnt = 0;
    for (int i = 0; i < n - 1; i++){
        if(a[i] == a[i+1]){
            a[i + 1] = 200;
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n=INT()
    if n%2==0:
        print(n)
    else:
        print(2*n)
if __name__ == '__main__':
    do()

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

#define ll long long int
#define mp make_pair
#define pb push_back
using namespace std;

int fun(int n)
{
    int c = 0;
    for (int i = 1; i*i <= n; ++i) {
        if(n%i == 0){
            if(n/i != i){
                c+=2;
            }
            else{
                c+=1;
            }
        }
    }
    return c;
}
int main() {
    int n;
    cin>>n;
    int ans = 0;
    for (int i = 1; i <= n; i+=2) {
        int c = fun(i);
        if(c == 8){
            ans++;
        }
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 256
/**    epsileer 10 August 2019  17:30:23  **/    
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair<LL,LL> PII;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define TEST int t = 1; while(t--) solve()

void solve(){
    LL a,b;cin>>a>>b;
    cout<<max(a+b, max(a-b, a*b));
}

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); TEST;
return 0;
}

Measured memory_bytes: 256
N, X, D = gets.split.map(&:to_i)

(puts X == 0 ? 1 : N + 1; exit) if D == 0
h = Hash.new{|h, k| h[k] = []}
(0 .. N).each do |n|
  l = n*X + n*(n - 1)/2*D
  r = n*X + n*(N - n + N - 1)/2*D
  h[l % D] << [l/D, r/D + 1]
end
ans = 0
h.values.each do |a|
  ee = -10**18
  a.sort.each do |s, e|
    next if ee > e
    ans += e - [s, ee].max
    ee = e
  end
end
puts ans

Measured memory_bytes: 54524
#include <stdio.h>

int main()
{
    int n, m;
    int yymm = 0;
    int mmyy = 0;

    scanf("%2d %2d", &n, &m);

    if (n >= 1 && n <= 12) {
        mmyy = 1;
    }

    if (m >= 1 && m <= 12) {
        yymm = 1;
    }

    if (yymm && mmyy) {
        puts("AMBIGUOUS");
    }
    else if (yymm) {
        puts("YYMM");
    }
    else if (mmyy) {
        puts("MMYY");
    }
    else {
        puts("NA");
    }

    return 0;
}


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

int main(){

for(;;){
int x,y;
cin>>x>>y;
if(x==0 && y==0)break;
	for(int i=0;i<x;i++){
		for(int g=0;g<y;g++){
		int a=g%2+i%2;
		if (a==0||a==2){cout<<"#";}
		else{cout<<".";}
		}
		cout<<endl;
		}
cout<<endl;
}
return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mod 1000000007
// #define mod 998244353
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	if (s[1] == s[0])
	{
		cout << 1 << " " << 2 << endl;
		return 0;
	}
	for (int i = 2; i < s.length(); i++)
	{
		if (s[i] == s[i - 1])
		{
			cout << i << " " << i + 1 << endl;
			return 0;
		}
		else if (s[i] == s[i - 2])
		{
			cout << i - 1 << " " << i + 1 << endl;
			return 0;
		}
	}
	cout << -1 << " " << -1 << endl;
	return 0;
}

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

using namespace std;

int main()
{
	unsigned long long K, S, ans = 0;
	cin >> K >> S;

	if (S <= K) {
		ans = (S + 2)*(S+1)/2;
	} else if (S >= K * 2) {
		ans = (K*3-S+2)*(K*3-S+1)/2;
	} else {
		ans = ((S + 2)*(2*K-S+1)+(3*K-S+1)*(S-K))/2;
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define lint long long
#define low lower_bound
#define upp upper_bound
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define Rep(i, n) for (int i = int(n); i >= 0; --i)
#define all(vec) (vec).begin(), (vec).end()
#define cend printf("\n");
#define prique(T) priority_queue<T, vector<T>, greater<T>>
#define prique2(T) priority_queue<T>

struct edge { int to; double cost; };
#define P pair<int, int>
#define D pair<double, double>
#define DI pair<double, int>
//const lint mod = 998244353LL;
const lint mod = 1000000007LL;
const lint inf = 3LL * mod * mod;

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

lint modpow(lint x, lint n, lint m) {
	lint ans = 1;
	while (n > 0) {
		if (n & 1) {
			ans *= x;
			if (m <= ans) ans %= m;
		}
		x *= x;
		if (m <= x) x %= m;
		n >>= 1;
	}
	return ans;
}

lint fact[1000000];
void f_init(lint n) {
	if (1000000 <= n) return;
	fact[0] = fact[1] = 1;
	for (lint i = 2; i <= n; ++i) {
		fact[i] = i * fact[i - 1];
		if (mod <= fact[i]) fact[i] %= mod;
	}
	return;
}

lint inver[1000000]; bool inve[100000];
lint inv(lint x) {
	if (x == 0) return 0;
	else if (inve[x]) return inver[x];
	else {
		inve[x] = true;
		return inver[x] = modpow(x, mod - 2, mod);
	}
}

lint comb(lint n, lint r) {
	if (n < r) return 0;
	if (n == r) return 1;
	lint ans = fact[n] * inv(fact[n - r]) % mod * inv(fact[r]) % mod;
	if (ans < 0) return ans + mod;
	return ans;
}

lint nck[1010][1010];
void comb(lint n) {
	rep(i, n + 1) {
		rep(j, i + 1) {
			if (j == 0 || i == j) nck[i][j] = 1;
			else nck[i][j] = nck[i - 1][j - 1] + nck[i - 1][j];
		}
	}
}

lint gcd(lint a, lint b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

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

bool pri(lint p) {
	for (lint i = 2; i * i <= p; i == 2 ? ++i : i += 2) if (p % i == 0) return false;
	return p > 1;
}

map<lint, lint> factring(lint n) {
	map<lint, lint>ans;
	for (lint i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			n /= i;
			++ans[i];
		}
	}
	if (n != 1) ++ans[n];
	return ans;
}

double dis(D a, D b) { return sqrt((a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second)); }

int n, q;
P p[100010];
double d[100010];
int main() {
	cin >> n;
	d[0] = 1;
	rep(i, n) {
		int t, a;
		cin >> t >> a;
		p[i] = P(t, a);
		d[i + 1] = (10.0 - a) / 10. * d[i];
	}
	cin >> q;
	rep(i, q) {
		int l, r;
		cin >> l >> r;
		int a = low(p, p + n, P(l, -1)) - p;
		int b = upp(p, p + n, P(r, 8)) - p;
		printf("%.10lf\n", 1e9 * d[b] / d[a]);
	}
}


Measured memory_bytes: 4768
//#pragma once
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cctype>
#include <cstdlib>      // srand,rand


using namespace std;
#define modd 1000000007



typedef pair<long long, long long> pl;


typedef string::const_iterator State;
class ParseError {};




#define ll long long




class UnionFind {
public:
	vector <ll> par;
	vector <ll> siz;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL){
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};


class SegmentTree {
private:
	int n;
	vector <ll> node;

public:
	// 元の配列　v をセグメントツリーで表現する。
	SegmentTree(vector<ll> v) {
		//最下段のノード数は元配列のサイズ以上になる最小の2冪->これをnとおく。
		//セグ木全体で必要なノード数は2n-1個である。
		int sz = v.size();
		n = 1; 
		while (n < sz)n *= 2;

	}

};




long long N, M, K, a, b, c, d, e, H, W, L,T;
ll A[300005] = {};
ll B[100005] = {};
ll C[2][300005] = {};
bool f, ff;
string S,SS;
set <long long>sll;
pl bufpl;
vector <long long>vl[100005];
vector <long long>vll;
vector <pl>vpl;
vector <string> vs;
set<ll> llset[50];
multiset<ll> llmset;


struct ST
{
	ll first;
	ll second;
	ll kaisuu;
	

	bool operator<(const ST& another) const
	{
		return first < another.first;//比較
	};

};



/*vector <ST> vst;
ST st[200005];
ST bufst;
bitset<5000> bits;*/


long long modinv(long long aa, long long mm) {
	long long bb = mm, uu = 1, vv = 0;
	while (bb) {
		long long tt = aa / bb;
		aa -= tt * bb; swap(aa, bb);
		uu -= tt * vv; swap(uu, vv);
	}
	uu %= mm;
	if (uu < 0) uu += mm;
	return uu;
}


ll minn, maxx;
double ansa;

ll zettai(ll aa) {

	if (aa < 0) {
		aa *= -1;
	}
	return aa;

}



int main() {
	
	cin >> N >> a >> b;
	
	c = min(b, N * a);

	cout << c << endl;

	//cout << fixed << setprecision(10) << ansa << endl;
	return 0;



}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, p;
  string s;
  int a[100001] = { 0 },w[100001] = { 0 };
  int ac = 0, wa = 0;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> p >> s;
    if (a[p] == 0) {
      if (s == "WA") {
        w[p]++;

      } else if (s == "AC") {
        a[p] = 1;
        ac++;
        wa+=w[p];
      }
    }
  }
  cout << ac << " " << wa;
  return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<int> v(n);
    for(int i=0;i<n;i++)
    cin>>v[i];
    int cnt=0;
    for(int i=1;i<n-1;i++)
    {
        int ma=max(v[i-1],max(v[i],v[i+1]));
        int mi=min(v[i-1],min(v[i],v[i+1]));
        if(mi!=v[i] && ma!=v[i])
        cnt++;
    }
    cout<<cnt;
    return 0;
}

Measured memory_bytes: 256
n, a, b = map(int, input().split())
p = 10**9 + 7

MOD = 10**9+7
from math import factorial

class Facts():
    # 階乗のメモ化
    # 組み合わせ数、順列数の計算を高速に行う
    def __init__(self, max_num=(2 * 10**5) + 1, p=10**9 + 7):
        self.p = p
        self.max_num = max_num
        self.fact = [1] * (self.max_num + 1)
        for i in range(1, self.max_num + 1):
            self.fact[i] = self.fact[i-1] * i
            self.fact[i] %= self.p

    def comb(self, n, k):
        # nCk mod p を求める
        if n < 0 or k < 0 or n < k:
            return 0
        if n == 0 or k == 0:
            return 1
        a = n
        for i in range(1, k):
            a *= (n-i)
            a %= MOD

        b = k
        for i in range(1, k):
            b *= (k-i)
            b %= MOD

        return (a*self.power_func(b, self.p-2)) % self.p


    def power_func(self, a, b):
        # a^b mod p　を繰り返し二乗法で求める
        if b == 0:
            return 1
        if b % 2 == 0:
            d = self.power_func(a, b//2)
            return d*d % self.p
        if b % 2 == 1:
            return (a*self.power_func(a, b-1)) % self.p

class FLT:
    #フェルマーの小定理
    # a^(-1) = a^(m-2) mod p
    def __init__(self, mod=10**9+7):
        self.mod = mod

    def rep_sqr(self, base, k):
        if k == 0:
            return 1
        elif k % 2 == 0:
            return (self.rep_sqr(base, k // 2) ** 2) % self.mod
        else:
            return (self.rep_sqr(base, k - 1) * base) % self.mod

    def inv(self, a):
        # 逆元を取る
        return self.rep_sqr(a, self.mod-2)

fact = Facts()
flt = FLT()
a_comb = fact.comb(n, a)
b_comb = fact.comb(n, b)

ans = (flt.rep_sqr(2, n) - 1 - a_comb - b_comb) % MOD
print(ans)



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

typedef long long int ll;

int main() {
    int N;
    cin >> N;
    map<pair<int,int>,ll> m;
    for (int i = 0; i < N; i++) {
        int x, y;
        cin >> x >> y;
        ll w;
        cin >> w;
        m[make_pair(x, y)] = w;
    }

    ll ans = 0;
    for (auto p: m) {
        int x = p.first.first;
        int y = p.first.second;

        ll w = 0;
        if (m.find(make_pair(x, y)) != m.end()) w += m[make_pair(x, y)];
        if (m.find(make_pair(x+1, y)) != m.end()) w += m[make_pair(x+1, y)];
        if (m.find(make_pair(x, y+1)) != m.end()) w += m[make_pair(x, y+1)];
        if (m.find(make_pair(x+1, y+1)) != m.end()) w += m[make_pair(x+1, y+1)];

        ll j = 0;
        if (m.find(make_pair(x, y)) != m.end()) j += m[make_pair(x, y)];
        if (m.find(make_pair(x-1, y)) != m.end()) j += m[make_pair(x-1, y)];
        if (m.find(make_pair(x, y+1)) != m.end()) j += m[make_pair(x, y+1)];
        if (m.find(make_pair(x-1, y+1)) != m.end()) j += m[make_pair(x-1, y+1)];

        ans = max(ans, max(j ,w));
    }

    cout << ans << " / 1" << endl;

    return 0;
}



Measured memory_bytes: 9360
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 1e6 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x < 2) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
int n;
int main(){
//	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	while(n){
		int x = n % 10;
		if(x == 7){
			cout << "Yes" << endl;
			return 0;
		}
		n /= 10;
	}
	cout << "No" << endl;
	return 0; 
}
//do smt instead of nothing! never give up!

Measured memory_bytes: 3632
N = int(input())
a = list(map(int, input().split()))

ans = 1
can = 1
zero = 0

if 0 in a:
    zero = 1
    ans = 0

if(zero==0):
    for i in range(N):
        ans = ans * a[i]
        if(ans>1000000000000000000):
            can = 0
            break

if(can==1):
    print(ans)
else:
    print(-1)


Measured memory_bytes: 21788
import itertools
import math

def resolve():
    n = int(input())
    fac = math.factorial(n)
    S = [list(map(int, input().split())) for _ in range(n)]

    ans = 0
    for p in itertools.permutations(range(n)):
        sum = 0
        for i in range(n-1):
            sum += math.sqrt((S[p[i]][0] - S[p[i+1]][0])**2 + (S[p[i]][1] - S[p[i+1]][1])**2)
        ans += sum

    print(ans/fac)

if __name__ == '__main__':
    resolve()

Measured memory_bytes: 3064
#include <cstdio>

int main()
{
  char s[5];
  scanf("%s", s);
  *(unsigned int*)s -= 0x30303030;
  
  for (int i = 0; i < 8; ++i)
  {
    int r =
      s[0] +
      (i & 1 ? -s[1] : s[1]) +
      (i & 2 ? -s[2] : s[2]) +
      (i & 4 ? -s[3] : s[3]);
    if (r == 7)
    {
      *(unsigned int*)s += 0x30303030;
      printf("%c%c%c%c%c%c%c=7\n", s[0], (i & 1 ? '-' : '+'), s[1], (i & 2 ? '-' : '+'), s[2], (i & 4 ? '-' : '+'), s[3]);
      return 0;
    }
  }
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

int main()
{
    int N;
    vector<long long> a(10000);
    int ans = 0;

    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    
    for (int i = 0; i < N; i++) {
        while(1) {
            if (a[i]%2 == 0) {
                a[i] = a[i]/2;
                ans++;
            }
            else break;
        }
    }
    
    cout << ans << endl;
    
    return 0;
}

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

const int N = 2e5 + 100, MOD = 1000 * 1000 * 1000 + 7;

int sum(int a, int b) {
	a += b;
	if (a < 0)
		a += MOD;
	else if (a >= MOD)
		a -= MOD;
	return a;
}
void _sum(int &a, int b) {
	a = sum(a, b);
}
int mul(int a, int b) {
	return 1LL * a * b % MOD;
}
void _mul(int &a, int b) {
	a = mul(a, b);
}

int n, X, Y, c, w, col[N], last, mn1 = -1, mn2 = -1, fac[N], inv[N];
bool mark[N];
vector<int> vec[N], dex[N], nei[N];

void input() {
	cin >> n >> X >> Y;
	for (int i = 0; i < n; i++) {
		cin >> c >> w;
		vec[--c].push_back(w);
	}
}

void ready() {
	for (int i = 0; i < n; i++) {
		if (vec[i].size()) {
			sort(vec[i].begin(), vec[i].end());
			if (mn2 == -1 || vec[i][0] < vec[mn2][0]) {
				mn2 = i;
				if (mn1 == -1 || vec[mn2][0] < vec[mn1][0])
					swap(mn1, mn2);
			}
		}
		for (int j = 0; j < vec[i].size(); j++) {
			col[last] = i;
			dex[i].push_back(last++);
		}
	}
}

void add_edge(int u, int v) {
	nei[u].push_back(v);
	nei[v].push_back(u);
}

void add_in() {
	for (int i = 0; i < n; i++)
		for (int j = 1; j < vec[i].size() && vec[i][0] + vec[i][j] <= X; j++)
			add_edge(dex[i][0], dex[i][j]);
}

void add_out() {
	for (int i = 0; i < n; i++)
		for (int j = 0; j < vec[i].size(); j++) {
			if (mn1 != -1 && i != mn1 && vec[i][j] + vec[mn1][0] <= Y)
				add_edge(dex[mn1][0], dex[i][j]);
			if (mn2 != -1 && i != mn2 && vec[i][j] + vec[mn2][0] <= Y)
				add_edge(dex[mn2][0], dex[i][j]);
		}
}

void pre_pro() {
	fac[0] = 1;
	for (int i = 1; i < N; i++)
		fac[i] = mul(fac[i - 1], i);

	inv[0] = inv[1] = 1;
	for (int i = 2; i < N; i++)
		inv[i] = mul(MOD - MOD / i, inv[MOD % i]);
	for (int i = 2; i < N; i++)
		_mul(inv[i], inv[i - 1]);
}

int C(int n, int m) {
	return (n > m? 0: mul(fac[m], mul(inv[n], inv[m - n])));
}

void dfs(int v, vector<int> *vec) {
	vec->push_back(col[v]);
	mark[v] = true;
	for (int u: nei[v])
		if (mark[u] == false)
			dfs(u, vec);
}

int f(vector<int> vec) {
	int res = 1, rem = vec.size();
	unordered_map<int, int> cnt;
	for (int x: vec)
		cnt[x]++;
	for (auto p: cnt) {
		_mul(res, C(p.second, rem));
		rem -= p.second;
	}
	return res;
}

void solve() {
	int ans = 1;
	for (int i = 0; i < n; i++)
		if (mark[i] == false) {
			vector<int> vec;
			dfs(i, &vec);
			_mul(ans, f(vec));
		}
	cout << ans;
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	input();
	ready();
	add_in();
	add_out();
	pre_pro();
	solve();
}


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

#define fio ios_base::sync_with_stdio(false);cin.tie(NULL)
// #define int long long 

using namespace std;

int32_t main()
{
	fio;
	string str;
	cin>>str;
	if(str=="ABC")
	{
		cout<<"ARC"<<endl;
	}
	else
	{
		cout<<"ABC"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3604
n = int(input())
s = input()
r, g, b = set(), set(), set()
for i in range(n):
    if s[i] == "R":
        r.add(i)
    elif s[i] == "G":
        g.add(i)
    else:
        b.add(i)

ans = len(r)*len(b)*len(g)
for i in r:
    for j in g:
        chk = j - i
        if chk + j in b:
            ans -= 1
        if i - chk in b:
            ans -= 1
        if (i + j)/2  in b:
            ans -= 1

print(ans)


Measured memory_bytes: 9536
#include<bits/stdc++.h>
#define int long long
using namespace std;
int x[50005],y[50005],mp[50005],tot=31;
int xx[4]={0,0,1,-1};
int yy[4]={1,-1,0,0};
char s[4]={'U','D','R','L'};
void work(int x,int y)
{
	for(int i=1;i<=tot;i++)
	{
		int minn=1e18,mn;
		for(int j=0;j<4;j++)
		{
			int sum=abs(x-xx[j]*mp[i])+abs(y-yy[j]*mp[i]);
			if(sum<minn) minn=sum,mn=j;
		}
		x-=xx[mn]*mp[i],y-=yy[mn]*mp[i];
		printf("%c",s[mn]);
	}
	printf("\n");
}
signed main()
{
	int n;
	scanf("%lld",&n);
	for(int i=1;i<=n;i++) scanf("%lld%lld",x+i,y+i);
	for(int i=1;i<=n;i++) if(((x[i]+y[i])&1!=((x[i-1]+y[i-1])&1))&&i!=1){printf("-1\n");return 0;}
	for(int i=1;i<=31;i++) mp[i]=1<<(31-i);
	if(((x[1]+y[1])&1)==0) mp[++tot]=1;
	printf("%lld\n",tot);
	for(int i=1;i<=tot;i++) printf("%lld ",mp[i]);printf("\n");
	for(int i=1;i<=n;i++) work(x[i],y[i]);
	return 0;
}

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

using namespace std;

long long gcd(long long a, long long b){
    long long r;
    if(a >= b){
        r = a%b;
        if(r == 0){
            return b;
        }else{
            return gcd(b,r);
        }
    }else{
        r = b%a;
        if(r == 0){
            return a;
        }else{
            return gcd(a,r);
        }
    }
}

int main(void){
    long long n, x;
    cin >> n >> x;
    vector<long long> vec(n);
    for(int i=0; i<n; i++){
        cin >> vec.at(i);
    }

    long long ans = abs(vec.at(0)-x);
    for(int i=1; i<n; i++){
        ans = gcd(ans, abs(vec.at(i)-x));
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
#define ll long long
#define pb push_back

int main()
{
    int n,m,tmp;
    vector<string> x;
    while (1)
    {
        cin >> n >> m;
        if (n == 0)
        {
            break;
        }
        vector<int> a;
        for(int i=0; i<n; i++){
            cin >> tmp;
            a.push_back(tmp);
        }
        sort(a.begin(),a.end());
        int value = 0;
        int nearest = 0;
        for(int i=0; i<n; i++){ // O(n^2)かかるが少し早くなるようにしている
            for(int j=i+1; j<n; j++){
                value = a[i] + a[j];
                if(value == m){
                    nearest = value;
                    break;
                }
                if(value > nearest && value < m ){
                    nearest = value;
                }
                if(value > m){ // mを超えたら次の値を見る
                    j = n-1;
                }
                // cout << i << " " << j << endl;
            }
        }
        if(nearest!=0){
            char str[30];
            sprintf(str, "%d", nearest);
            x.push_back(str);
        } else {
            x.push_back("NONE");
        }

    }
    for (int i = 0; i < x.size(); i++)
    {
        cout << x[i] << endl;
    }
}



Measured memory_bytes: 3268