akhauriyash/Code-Regression huggingface dataset:
//#pragma GCC optimize("O3")
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#define int long long
#define x first
#define y second
#define pb push_back
#define N 1000000007
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;

template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.x<<','<< P.y<<')';}

#define maxn 1000000
int fact[maxn];
inline int ex(int a, int b){
	if(b==0||a==1){return 1;}
	if(a==0||b==1){return a;}
	int tmp=ex(a,(b/2));
	if(b%2){return ((((tmp*tmp)%N)*a)%N);}
	else{return ((tmp*tmp)%N);}
}
inline int inv(int k){
	if(k==1){return 1;}
	else{return ex(k,N-2);}
}
void ini()
{
	fact[0]=1;
	for(int i=1;i<maxn;++i){fact[i]=(fact[i-1]*i)%N;}
}
int c(int a,int b )
{
	if(a<b){return 0;}
	return (fact[a]*((inv(fact[b])*inv(fact[a-b]))%N))%N;
}
signed main()
{
    
	speed
	ini();
	int n,k;cin>>n>>k;
	std::vector<int>  inp(n);
	map<int,int> freq;
	set<int> st;
	for (int i = 0; i < n; ++i)
	{
		cin>>inp[i];st.insert(inp[i]);freq[inp[i]]++;
	}
	inp.clear();
	for(auto it:st){inp.push_back(it);}
	int ans=0;
	int b=0;
	for(int i=0;i<inp.size();++i)
	{
		int a=freq[inp[i]];
		ans+=(inp[i]*(c(a+b,k)-c(b,k)))%N;
		ans%=N; ans+=N ; ans%=N;
		b+=freq[inp[i]];
	}
	b=0;
	for(int i=inp.size()-1;i>=0;--i)
	{
		int a=freq[inp[i]];
		ans-=(inp[i]*(c(a+b,k)-c(b,k)))%N;
		ans%=N; ans+=N; ans%=N;
		b+=freq[inp[i]];
	}
	cout<<ans<<"\n";
	
}

Measured memory_bytes: 18944
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys

N = int(input())
A = list(map(int, input().split()))

for a in A:
    if a % 2 == 0:
        if a % 3 != 0 and a % 5 != 0:
            print('DENIED')
            break
else:
    print('APPROVED')


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
using namespace std;
const int MAX = 80;

int main() {
	int h, w;
	cin >> h >> w;
	vector<vector<int>> d(h, vector<int>(w));
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> d[i][j];
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			int b;
			cin >> b;
			d[i][j] = abs(d[i][j] - b);
		}
	}
	const int M = MAX*MAX*2+1;
	vector<vector<vector<bool>>> dp(h, vector<vector<bool>>(w, vector<bool>(M, false)));
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			for (int k = 0; k < M; k++) {
				int x = d[i][j];
				bool res = false;
				if (i == 0 && j == 0 && k == x) res = true;
				if (i > 0) {
					if (k+x < M) res |= dp[i-1][j][k+x];
					res |= dp[i-1][j][abs(k-x)];
				}
				if (j > 0) {
					if (k+x < M) res |= dp[i][j-1][k+x];
					res |= dp[i][j-1][abs(k-x)];
				}
				dp[i][j][k] = res;
			}
		}
	}
	int ans = 0;
	while (!dp[h-1][w-1][ans]) ans++;
	cout << ans << endl;
	return 0;
}

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

int main()
{
    long long int a,b,n,s;
    cin>>a>>b>>n;
    if(b>n){
    s=floor((a*n)/(b))-a*(floor((n)/(b)));
    }

   else if(b<=n){
    s=floor((a*(b-1))/(b));
    }
    cout<<s;

}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
ll n,a[200000];
int main(){
	cin >> n;
	REP(i,n) {
		cin >> a[i];
	}

	ll mode = 0;
	ll cou = 0;
	FOR(i,1,n) {
		if(mode == 0) {
			mode = a[i] - a[i - 1];
		}else if(mode > 0 && a[i - 1] > a[i]){
			mode = 0;
			cou++;
		}else if(mode < 0 && a[i - 1] < a[i]){
			mode = 0;
			cou++;
		}
	}
	cout << cou + 1 << endl;
	return 0;
}


Measured memory_bytes: 1152
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<utility>
#include<map>
#include<complex>
#include<stack>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vec;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define stop char nyaa;cin>>nyaa;
#define per(i,n) for(int i=n-1;i>=0;i--)
typedef long double ld;

bool isnum(char t) {
	return ('0' <= t && t <= '9');
}
string s;
void solve() {
	string t;
	rep(i, s.length()) {
		if (s[i] == ' ')continue;
		if (s[i] == 'S' || isnum(s[i])) {
			if (t.size() >= 2 && t[t.length() - 1] == '>'&&t[t.length() - 2] == '>') {
				rep(j, 2)t.pop_back();
				t.push_back('*');
			}
			t.push_back(s[i]);
		}
		else t.push_back(s[i]);
	}
	ll cur = 0;
	stack<ll> st;
	int len = t.length(); bool f = false;
	stack<bool> b;
	//cout << t << endl;
	rep(i, len) {
		//cout << i << " " << cur << endl;
		if (t[i] == 'S') {
			st.push(cur);
			b.push(f);
			cur = 0;
			f = false;
			i++;
		}
		else if (isnum(t[i])) {
			int le = i;
			while (i + 1 < len&&isnum(t[i + 1]))i++;
			string u = t.substr(le, i - le + 1);
			ll val = stoll(u);
			if (f) {
				if (val > 32)val = 32;
				cur >>= val;
				f = false;
			}
			else {
				cur = val;
			}
		}
		else if(t[i]=='>'){
			ll pre = st.top(); st.pop();
			f = b.top(); b.pop();
			cur = cur * cur%mod;
			if (f) {
				if (cur > 32)cur = 32;
				pre >>= cur;
				f = false;
			}
			else {
				pre = cur;
			}
			cur = pre;
		}
		else if (t[i] == '*') {
			f = true;
		}
	}
	cout << cur << endl;
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	while (getline(cin, s)) {
		if (s == "#")break;
		solve();
	}
	//stop
		return 0;
}



Measured memory_bytes: 3552
#include<stdio.h>
int main()
{
    int n,i;
    scanf("%d",&n);
    int a[n+5],j;
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    int cnt=1,chk=a[0];
    for(i=1;i<n;i++)
    {
        if(a[i]<=chk)
        {
            cnt++;
            chk=a[i];
        }
    }
    printf("%d\n",cnt);
    return 0;
}


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

int main() 
{
	int n;
	cin >> n;
  	string s, s1, s2;
  	cin >> s;
  	
  	int a = n / 2;
  	for (int i = 0; i < a; i++) 
  	    s1.push_back(s[i]);
  	for (int i = a; i < n; i++)
  	    s2.push_back(s[i]);
    cout << (s1 == s2 && 0 == 0 && 1 == 1 && 1 < 2 && 3 > 1 ? "Yes" : "No");
  	
    return 1>>5;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

const string YES = "Yes";
const string NO = "No";
const ll mod = 1e9+7;



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

    ll n, k; cin >> n >> k;
    ll ans = 0;
    vll h(n);
    REP(i,n) cin >> h[i];
    sort(ALL(h));
    if (k >= n){
        cout << 0;
        return 0;
    }
    
    cout << accumulate(h.begin(), h.begin()+(n-k), 0LL) << endl;

    return 0;
}



Measured memory_bytes: 1792
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

//code by lynmisakura.wish to be accepted!
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

/***************************/
using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<long long> vl;
typedef pair<ll, ll> pi;
typedef vector<pair<ll, ll>> vpi;

//const long long INF = 1LL << 55;

#define itn ll
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ss second
#define ff first
#define dup(x,y) ((x) + (y) - 1)/(y)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(ll i = 0;i < n;i++)
#define rep(i,n) for(ll i = 0;i < n;i++)
#define flush fflush(stdout)
#define rrep(i,n) for(ll i = n - 1;i >= 0;i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define ioboost cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, ll mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }

#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

class DAnInvisibleHand {
public:
    static constexpr int kStressIterations = 0;
    static void generateTest(std::ostream& test) {
    }


    void solve(std::istream& cin, std::ostream& cout) {
        int n,t;cin >> n >> t;
        int a[100010];
        int m = 0,z = 0,s = 0;
        rep(i,n)cin >> a[i];
        for(int i=n-1;i >= 0;i--){
            m = max(m,a[i]);
            if(m -  a[i] > z)z = m - a[i],s = 1;
            else if(m - a[i] == z)s++;
        }
        cout << s << endl;

        return;
    }
};

int main() {
	DAnInvisibleHand solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

typedef long long ll;

const string YES = "Yes";
const string NO = "No";

void solve(long long D, long long T, long long S){
  bool rv = S * T >= D;
  cout << (rv ? "Yes" : "No") << endl;
}

int main() {
  long long D;
  scanf("%lld",&D);
  long long T;
  scanf("%lld",&T);
  long long S;
  scanf("%lld",&S);
  solve(D, T, S);
  return 0;
}


Measured memory_bytes: 3764
#include<bits/stdc++.h>
#define eps 0.000000001
using namespace std;
typedef double ld;
typedef pair<int,int> p;
typedef pair<ld,p> P;

int n;
ld px[200],py[200],pz[200],vx[200],vy[200],vz[200],r[200],vr[200];

ld getlen(int a,int b,ld M){
  ld ax=px[a]+vx[a]*M,ay=py[a]+vy[a]*M,az=pz[a]+vz[a]*M,ar=r[a]-vr[a]*M;
  ld bx=px[b]+vx[b]*M,by=py[b]+vy[b]*M,bz=pz[b]+vz[b]*M,br=r[b]-vr[b]*M;
  ld dx=ax-bx,dy=ay-by,dz=az-bz;
  return sqrt(dx*dx+dy*dy+dz*dz)-(ar+br);
}

ld check(int a,int b){
  ld L=0,R=100,M;
  int s=0;
  while(s++<50){
    M=(L+R)/2;
    ld len=getlen(a,b,M),len1=getlen(a,b,M+eps);
    if(len<len1||len<0)R=M;
    else L=M;
  }
  if(getlen(a,b,R)>0)return 100;
  return R;
}

int main(){
  while(cin>>n,n){
    for(int i=0;i<n;i++)
      cin>>px[i]>>py[i]>>pz[i]>>vx[i]>>vy[i]>>vz[i]>>r[i]>>vr[i];
    priority_queue<P,vector<P>,greater<P> > q;
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++)
	q.push(P(check(i,j),p(i,j)));
      q.push(P(r[i]/vr[i],p(i,i)));
    }
    ld used[200]={};
    while(!q.empty()){
      ld t=q.top().first;
      int a=q.top().second.first,b=q.top().second.second;
      q.pop();
      if(used[a]||used[b])continue;
      used[a]=used[b]=t;
    }
    for(int i=0;i<n;i++)printf("%.10lf\n",used[i]);
  }
  return 0;
}

Measured memory_bytes: 3748
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

N = I()
S = list(input())
Q = I()
k = LI()

cumD = [0]*N
cumM = [0]*N
cumDM = [0]*N

cumD[0] = 1 if S[0] == 'D' else 0
cumM[0] = 1 if S[0] == 'M' else 0

Clist = []
for i in range(1,N):
    cumD[i] = cumD[i-1]
    cumM[i] = cumM[i-1]
    cumDM[i] = cumDM[i-1]
    if S[i] == 'D':
        cumD[i] += 1
        continue
    if S[i] == 'M':
        cumM[i] += 1
        cumDM[i] += cumD[i-1]
        continue
    if S[i] == 'C':
        Clist.append(i)

for j in range(Q):
    ans = 0
    for i in Clist:
        if i-k[j] >= 0:
            ans += cumDM[i-1] - (cumD[i-k[j]])*(cumM[i-1]-cumM[i-k[j]]) - cumDM[i-k[j]]
        else:
            ans += cumDM[i-1]
    print(ans)

Measured memory_bytes: 162348
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int par[100010];

int root(int x) {
  return par[x] == x ? x : par[x] = root(par[x]);
}

void merge(int x, int y) {
  x = root(x); y = root(y);
  if (x == y) return;
  par[y] = x;
}

struct edge {
  int from, to, cost;
  edge() {}
  edge(int f, int t, int c): from(f), to(t), cost(c) {}
};

int N;
pii p[100010];
int ord[100010];
vector<edge> es;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> p[i].first >> p[i].second;
  }
  iota(ord, ord + N, 0);
  sort(ord, ord + N, [&](int a, int b) {
    return p[a].first < p[b].first;
  });
  for (int i = 0; i + 1 < N; i++) {
    int a = ord[i], b = ord[i + 1];
    es.emplace_back(a, b, p[b].first - p[a].first);
  }
  sort(ord, ord + N, [&](int a, int b) {
    return p[a].second < p[b].second;
  });
  for (int i = 0; i + 1 < N; i++) {
    int a = ord[i], b = ord[i + 1];
    es.emplace_back(a, b, p[b].second - p[a].second);
  }
  sort(es.begin(), es.end(), [&](edge a, edge b) {
    return a.cost < b.cost;
  });
  iota(par, par + N, 0);
  ll ans = 0;
  for (edge e : es) {
    if (root(e.from) == root(e.to)) continue;
    merge(e.from, e.to);
    ans += e.cost;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 6132
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



string s;
int n, res = 114514;

signed main() {
	cin >> s;
	n = s.size();
	rep(i,n-2) chmin(res, abs(753 - stoi(s.substr(i,3))));
	cout << res << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a==b){
		printf("%d\n",c);
	}
	else if(a==c){
		printf("%d\n",b);
	}
	else{
		printf("%d\n",a);
	}
	return 0;
}

Measured memory_bytes: 128
n = int(input())
a = []
b = []
c = []
for i in range(n):
    x = list(map(int, input().split()))
    a.append(x[0])
    b.append(x[1])
    c.append(x[2])
dp = [[0 for i in range(3)] for j in range(n)]
dp[0][0] = a[0]
dp[0][1] = b[0]
dp[0][2] = c[0]
for i in range(1,n):
    dp[i][0] = a[i] + max(dp[i-1][1], dp[i-1][2])
    dp[i][1] = b[i] + max(dp[i-1][0], dp[i-1][2])
    dp[i][2] = c[i] + max(dp[i-1][0], dp[i-1][1])
print(max(dp[n-1]))

Measured memory_bytes: 36228
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll mod = 1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<int> ch(1010101);

  sort(a.begin(), a.end());

  rep(i,n) {
      if (i > 0) {
          if (a[i-1] == a[i]) {
              ch[a[i]] = 100;
              continue;
          }
      }
      for (int j = a[i]*2; j <= 1000000; j += a[i]) {
          ch[j]++;
      }
  }

  int ans = 0;
  rep(i,n) {
      if (!ch[a[i]]) ans++;
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 7988
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
using namespace std;
using LL = long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1000000000;
const double PI = acos(-1);

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


int main() {
	int x, y;
	cin >> x >> y;
	int ans = x + y + 2;
	int g = gcd(x, y);
	cout << ans - g - 1 << endl;
}

Measured memory_bytes: 3112
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		if (A == 1) {
			A = 14;
		}
		if (B == 1) {
			B = 14;
		}
		if (A > B) {
			System.out.println("Alice");
			return;
		}
		if (B > A) {
			System.out.println("Bob");
			return;
		} if(A == B) {
			System.out.println("Draw");
		}
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int main()
{
    vector<int> A(3);
    cin >> A[0] >> A[1] >> A[2];

    sort(A.begin(), A.end(), greater<int>());

    cout << stoi(to_string(A[0]) + to_string(A[1])) + A[2];

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define rep1(n) for(ll i=0;i<n;++i)
#define rep2(i,n) for(ll i=0;i<n;++i)
#define rep3(i,a,b) for(ll i=a;i<b;++i)
#define rep4(i,a,b,c) for(ll i=a;i<b;i+=c)
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define LD(...) ld __VA_ARGS__;in(__VA_ARGS__)
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
void vout(vl V) {
	for (ll i = 0; i < (ll)V.size(); i++) cout << V[i] << " ";
	cout << endl;
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//bitSearch, bitList, nod, gcdlcm, isPrime, primeFactorize, Npow, divisor, modinv, dfs, bfs, eratos//
//dijkstra, WarshallFloyd, BellmanFord, UnionFind, COM, digitDP ,RMQ//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007; ll INF = 1LL << 62; ll ans = 0; ll z = 0, o = 1;
vl flag, color; vll path; vl A; vl dp; vl Ans;
//***********//
int main() {
	string S;
	cin >> S;
	string Ans;
	for (i = 0; i < S.length(); i++) {
		if (S[i] != 'B') {
			Ans.push_back(S[i]);
		}
		else if(Ans.length()>0){
			Ans.pop_back();
		}
	}
	cout << Ans << endl;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init));

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string str;
  while(getline(cin,str)){
    if(str == "END OF INPUT") break;
    ll cnt = 0,f = 0;
    rep(i,str.size()){
      if(str[i] != ' '){
        ++cnt;
      }
      else{
        cout << cnt;
        cnt = 0;
      }
    }
    if(cnt)
      cout << cnt << endl;
    else cout << endl;
  }
  return 0;
}

Measured memory_bytes: 3180
// AOJ 2815 AOR's Score
// 2018.3.9 bal4u

#include <stdio.h>
#include <string.h>

#define QMAX 1000
typedef struct { int t, s; } QUE;
QUE que[QMAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;
	QUE qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].t < que[i].t) min = l; else min = i;
	if (r < qsize && que[r].t < que[min].t) min = r;
	if (min != i) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		min_heapify(min);
	}
}

void deq()
{
	que[0] = que[--qsize];
	min_heapify(0);
}

void enq(int s, int t)
{
	int i, min;
	QUE qt;

	i = qsize++;
	que[i].s = s, que[i].t = t;
	while (i > 0 && que[min = PARENT(i)].t > que[i].t) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		i = min;
	}
}

#define INF 0x10101010
#define MAX 205
typedef struct { int to, rev; int cap, cost; } EDGE;
EDGE edge[MAX][MAX]; int hi[MAX];
int V;				// 頂点数
int potential[MAX], dist[MAX], prevv[MAX], preve[MAX];

void add_edge(int from, int to, int cap, int cost)
{
	int f, t;
	EDGE *ep;

	f = hi[from]++, t = hi[to]++;
	ep = &edge[from][f], ep->to = to, ep->cap = cap, ep->cost = cost, ep->rev = t; 
	ep = &edge[to][t], ep->to = from, ep->cap = 0, ep->cost = -cost, ep->rev = f;
}

int minCostFlow(int S, int T, int F)
{
	int i, v, nv, t, nt, ret;
	EDGE *ep;

	ret = 0;
//	memset(potential, 0, V << 2);
  
	while (F > 0) {
		memset(dist, INF, V << 2);
		qsize = 0;
		dist[S] = 0;
		enq(S, 0);
		while (qsize) {
			v = que[0].s, t = que[0].t, deq();
			if (dist[v] < t) continue;
			for (i = 0; i < hi[v]; i++) {
				ep = &edge[v][i];
				if (ep->cap <= 0) continue;
				nv = ep->to;
				nt = t + ep->cost - potential[nv] + potential[v];
				if(dist[nv] > nt) {
					dist[nv] = nt;
					prevv[nv] = v, preve[nv] = i;
					enq(nv, nt);
				}
			}
		}
		if (dist[T] == INF) return -1;
		for (v = 0; v < V; v++) potential[v] += dist[v];

		t = F;
		for (v = T; v != S; v = prevv[v]) {
			ep = &edge[prevv[v]][preve[v]];
			if (t > ep->cap) t = ep->cap;
		}
		F -= t;

		ret += t * potential[T];
		for (v = T; v != S; v = prevv[v]) {
			ep = &edge[prevv[v]][preve[v]];
			ep->cap -= t;
			edge[v][ep->rev].cap += t;
		}
	}
	return ret;
}

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int a[102], b[102][102], t[102];

int main()
{
	int N, M, K, i, j;
	int friends, source, sink;

	N = in(), M = in(), K = in();
	friends = N+M, source = friends+1, sink = source+1, V = sink+1;

	for (i = 0; i < N; i++) a[i] = in();
	for (i = 0; i < M; i++) for (j = 0; j < N; j++) b[i][j] = in();
	for (i = 0; i < M; i++) t[i] = in();

	for (i = 0; i < N; i++) add_edge(source, M+i, 1, 100-a[i]);
	add_edge(source, friends, N-K, 0);
	for (i = 0; i < M; i++) add_edge(friends, i, t[i], 0);
	for (i = 0; i < M; i++) for (j = 0; j < N; j++)
		add_edge(i, M+j, 1, 100-b[i][j]);
	for (i = 0; i < N; i++) add_edge(M+i, sink, 1, 0);

	printf("%d\n", 100*N - minCostFlow(source, sink, N));
	return 0;
}


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

int     main() {
        vector<int> x(4,0);
        vector<int> y(4,0);
        cin >>x.at(0) >>y.at(0);
        cin >>x.at(1) >>y.at(1);
        x.at(2)=x.at(1)-(y.at(1)-y.at(0));
        y.at(2)=y.at(1)+(x.at(1)-x.at(0));
        x.at(3)=x.at(2)-(y.at(2)-y.at(1));
        y.at(3)=y.at(2)+(x.at(2)-x.at(1));
        cout << x.at(2) << " " << y.at(2) << " " << x.at(3) << " " << y.at(3) << endl;
        return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from bisect import bisect_right

S = [ord(x)-ord('a') for x in readline().rstrip().decode('utf-8')]
T = [ord(x)-ord('a') for x in readline().rstrip().decode('utf-8')]

index = [[] for _ in range(26)]
for i,x in enumerate(S):
    index[x].append(i)

LS = len(S)
for x in index:
    if x:
        x.append(x[0] + LS)

ptr = -1 # 最後に使った文字
complete = True
for t in T:
    seq = index[t]
    if not seq:
        complete = False
        break
    i = ptr%LS
    j = bisect_right(seq,i)
    ptr += seq[j]-i

if complete:
    answer = ptr + 1
else:
    answer = -1
print(answer)

Measured memory_bytes: 9004
n = int(input())
a = list(map(int, input().split()))
from collections import deque
d = deque()


if len(a) %2 == 0:
    d.extend(a[::2])
    d.extendleft(a[1::2])
else:
    d.extend(a[1::2])
    d.extendleft(a[::2])
print(*list(d))


Measured memory_bytes: 30968
#include<bits/stdc++.h>
using namespace std;
typedef signed long long int ll;

int INFp=1000000007;
int euclidean_gcd(int a, int b) {
    if(a < b) euclidean_gcd(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}
int main(){
    int n;
    int a[100005];
    cin>>n;
    for(int i=0;i<n;i++) cin>>a[i];
    int ans=euclidean_gcd(a[0],a[1]);
    for(int i=2;i<n;i++){
        ans=euclidean_gcd(ans,a[i]);
    }
    cout<<ans<<endl;
    return 0;
}


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

int main(void)
{
    int N;
    int i, j;
    int A, B;
    char Ab[7],Bb[7];
    int ans=90;

    scanf("%d", &N);

    for (i = 1; i <= N/2; i++) {
        A = i;
        B = N - A;
        snprintf(Ab,7,"%d",A);
        snprintf(Bb,7,"%d",B);

        A = 0;
        B = 0;
        for (j = 0; j < strlen(Ab); j++) {
            A+=Ab[j]-'0';
        }
        for (j = 0; j < strlen(Bb); j++) {
            B+=Bb[j]-'0';
        }
        if (ans > A+B)  ans = A+B;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int count = K;
        for(int i = 1;i < N;i++){
            count *= K-1; 
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 23764
#include <stdio.h>
#include <math.h>

int main(void){
    /*
    三角形の２辺 a, b とその間の角 C から、その三角形の面積 S、周の長さ L, a を底辺としたときの高さ h を求めるプログラムを作成して下さい。

Input
a の長さ, b の長さ, Cの大きさ（度）（整数）が空白区切りで与えられます。

Output
S, L, h をそれぞれ1行に出力して下さい。0.0001以下の誤差があってもよいものとします。
    
    */
    double PI = acos(-1);
    
    double x1,y1,x2,y2;
    int a,b,c;
    double s,l,h,rad;
    
    scanf( "%d %d %d" , &a, &b, &c );
    
    rad = c * PI / 180;

    s = sin( c * PI / 180.0 ) * a * b / 2;
    l = a + b + sqrt( a * a + b * b - 2*a*b * cos(rad));
    h = s / a * 2;
    
    
    printf("%f\n",s);
    printf("%f\n",l);
    printf("%f\n",h);
}



Measured memory_bytes: 2060
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n = 0;
	for(int i = 0; i < 3; i++){
		int num;
		cin >> num;
		n *= 2;
		n += num;
	}
	if(n == 6 || n == 1) cout << "Open" << endl;
	else cout << "Close" << endl;
	return 0;
}



Measured memory_bytes: 3116
# ------------------- fast io --------------------
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# ------------------- fast io --------------------
from math import gcd, ceil

def pre(s):
    n = len(s)
    pi = [0] * n
    for i in range(1, n):
        j = pi[i - 1]
        while j and s[i] != s[j]:
            j = pi[j - 1]
        if s[i] == s[j]:
            j += 1
        pi[i] = j
    return pi


def prod(a):
    ans = 1
    for each in a:
        ans = (ans * each)
    return ans

def lcm(a, b): return a * b // gcd(a, b)


def binary(x, length=16):
    y = bin(x)[2:]
    return y if len(y) >= length else "0" * (length - len(y)) + y


for _ in range(int(input()) if not True else 1):
    #n = int(input())
    #d, t, s = map(int, input().split())
    #a, b = map(int, input().split())
    #c, d = map(int, input().split())
    #a = list(map(int, input().split()))
    #b = list(map(int, input().split()))
    s = input()
    t = input()
    #print("Yes" if s*t >= d else "No")
    ans = len(s)
    st = set()
    for i in range(len(s) - len(t)+1):
        anss = 0
        for j in range(len(t)):
            if t[j] != s[i+j]:
                anss += 1
        ans = min(ans, anss)
    print(ans)



Measured memory_bytes: 67716
from collections import deque

N, M = map(int,input().split())
A=[0]*M
B=[0]*M
#隣接リスト
graph=[[] for i in range(N+1)]
d=[0]*M
for i in range(M):
    A[i], B[i] = map(int, input().split())
    #無向グラフなので両方書く
    graph[A[i]].append(B[i])
    graph[B[i]].append(A[i])

#幅優先
def BFS(top):
    queue = deque([top])
    dist = [-1]*(N+1)#未発見の頂点なら-1、それ以外は0に向かうための次に隣接する頂点番号を格納。ただしdist[1]=0
    dist[1]=0

    queue.extend(graph[top])#頂点1(top)と隣接する頂点を全てキューに追加
    
    while(queue):
        Now_vertex = queue.popleft()
        
        for j in range(len(graph[Now_vertex])):
            if(dist[graph[Now_vertex][j]]==-1):
                queue.append(graph[Now_vertex][j])
                dist[graph[Now_vertex][j]]=Now_vertex
            
    print("Yes")
    for i in range(2,len(dist)):
        print(dist[i])
    
        
    return



BFS(1)


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

int main()
{
    string s;
    cin >> s;
    int ans = 0;
    if (s == "SUN")
        ans = 7;
    if (s == "MON")
        ans = 6;
    if (s == "TUE")
        ans = 5;
    if (s == "WED")
        ans = 4;
    if (s == "THU")
        ans = 3;
    if (s == "FRI")
        ans = 2;
    if (s == "SAT")
        ans = 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3548
public class Main {


  private static void solve() {
    int n = ni();
    long[] a = nal(n);
    
    long min = Long.MAX_VALUE;
    int nega = 0;
    boolean zero = false;
    long sum = 0;
    for (int i = 0; i < n; i ++) {
      if (a[i] < 0) {
        nega ++;
      }
      if (a[i] == 0) {
        zero = true;
      }
      
      min = Math.min(min, Math.abs(a[i]));
      sum += Math.abs(a[i]);
    }
    
    if (zero || nega % 2 == 0) {
      System.out.println(sum);
    } else {
      System.out.println(sum - min * 2);
    }
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 41524
H, W = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(H)]
cnt = 0
done = [[0 for _ in range(W)] for _ in range(H)]
move = []

for i in range(H):
    for j in range(W):
        done[i][j] = 1
        if a[i][j] % 2 == 1:
            for i_d, j_d in [(0, 1), (0, -1), (1, 0), (-1, 0)]:
                if (0 <= i + i_d < H and 0 <= j + j_d < W
                and done[i + i_d][j + j_d] == 0):
                    cnt += 1
                    move.append([i + 1, j + 1, i + i_d + 1, j + j_d + 1])
                    a[i + i_d][j + j_d] += 1
                    break

print(cnt)
for m in move:
    print(" ".join(map(str, m)))

Measured memory_bytes: 31960
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <cstring>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <math.h>
using namespace std;

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

int main() {
  int l; string S; cin >> l >> S;

  int mid, ans = 0;
  for (int k = 1; k < l; k++) {
    set<int> s1, s2;
    int cnt = 0;
    for (int i = 0; i < k; i++) s1.insert(S[i]);
    for (int i = k; i < l; i++) s2.insert(S[i]);
    for (auto p:s2) {
      if (s1.find(p) != s1.end()) cnt++;
    }
    ans = max(ans, cnt);
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
a, b = map(int, input().split())  # 複数数値入力
str = list(input())

if str[b-1] <= 'z' and str[b-1] >='a':
    str[b-1] = str[b-1].upper()
else:
    str[b-1] = str[b-1].lower()

for s in str:
    print(s, end="")

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

using namespace std;

int main(void) {
	int h, w;
	char s[60][60];


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

	int c[8][2] = {
		{-1,-1},
		{-1,0 },
		{-1,1},
		{0,1},
		{1,1},
		{1,0},
		{1,-1},
		{0,-1}
	};

	for (int i = 0; i <= h; i++)
		for (int j = 0; j <= w; j++) {
			if (s[i][j] == '.') {
				int mine = 0;
				for (int k = 0; k < 8; k++) {
					int y = i + c[k][0];
					int x = j + c[k][1];
					if (0 <= y && y <= h
						&& 0 <= x && x <= w) {
						if (s[y][x] == '#') mine++;
					}
				}
				s[i][j] = '0' + mine;
			}
		}


	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cout << s[i][j];
		}
		cout << '\n';
	}
}

Measured memory_bytes: 3008
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;

int N,M,S=0,T[100005],P,X;
int main()
{
	scanf("%d",&N);
	for(int i=0;i<N;i++)
	{
		scanf("%d",&T[i]);
		S+=T[i];
	}
	scanf("%d",&M);
	for(int i=0;i<M;i++)
	{
		scanf("%d%d",&P,&X);
		printf("%d\n",S-T[P-1]+X);
	}
	return 0;
}




Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main()
{
	long long n;
	cin >> n;
  
  long long ans=0;
	if (n%2==0) {
		n/=2;
		while (n!=0) {
			ans+=n/5;
			n/=5;
		}
	}
	cout << ans << endl;
}

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

using namespace std;

int n;
typedef long long ll;
const ll mod = 1e9 + 7;

int main() {
  string s1,s2;
  cin >> n >> s1 >> s2;

  ll ans;
  bool ok = false;
  if(s1[0] == s2[0]) {
    ans = 3;
    ok = true;
  }
  else ans = 6;

  for(int i = 1; i < n; i++) {
    if(ok && i < n - 1 && s1[i] == s1[i+1]){
      ans = ans * 2 % mod;
      ok = false;
      continue;
    }
    if(!ok && i < n - 1 && s1[i] == s1[i+1]) {
      ans = ans * 3 % mod;
      continue;
    }

    if(!ok && s1[i] == s2[i]) {
      ok = true;
      continue;
    }

    if(ok && s1[i] == s2[i]) {
      ans = ans * 2 % mod;
    }
  }

    
    

  cout << ans << endl;
}
    


Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding:utf-8 -*-

import numpy

def main():
  n, m, q = map(int, input().split())
  counts = numpy.zeros((n+1, n+1), dtype=numpy.int)
  for _ in range(m):
    l, r = map(int, input().split())
    counts[l, r] += 1
  
  cusum = counts.cumsum(0).cumsum(1)
  for _ in range(q):
    p, q = map(int, input().split())
    
    if p-1 < 1:
      print(cusum[q, q])
    else:
      print(cusum[q, q] - cusum[p-1, q] - cusum[q, p-1] + cusum[p-1, p-1])

if __name__=='__main__':
  main()



Measured memory_bytes: 19052
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		String s = sc.next();
		
		sc.close();

		if(s.charAt(0) == s.charAt(1) || s.charAt(1) == s.charAt(2) || s.charAt(2) == s.charAt(3)) {
			out.println("Bad");
		}else {
			out.println("Good");
		}
		
	}

	public static void main(String[] args) {
		new Main()._main(args);
	}
	
	@SuppressWarnings("unused")
	private int[] nextIntArray(Scanner sc, int n) {
		int[] result = new int[n];
		for (int i = 0; i < n; i++) {
			result[i] = sc.nextInt();
		}
		return result;
	}

	@SuppressWarnings("unused")
	private int[] nextIntArray1origin(Scanner sc, int n) {
		int[] result = new int[n + 1];
		for (int i = 1; i <= n; i++) {
			result[i] = sc.nextInt();
		}
		return result;
	}
}


Measured memory_bytes: 23764
#include <stdio.h>
int main (void)
{
  int N = 0;
  int A[1100];
  int i;
  float z = 0;
  float x = 0;
  
  scanf("%d\n",&N);
  
  for(i=0; i < N; i++){
    scanf("%d",&A[i]);
    z += (float)1/A[i];
  }
   x = 1/z;
  
  printf("%f",x);
  return 0;
}

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

unordered_map<int, vector<int>> edge;

int main()
{
    int n, m;
    scanf("%d %d", &n, &m);
    for (int i = 0; i < m; i++)
    {
        int a, b;
        scanf("%d %d", &a, &b);
        edge[a].push_back(b);
        edge[b].push_back(a);
    }

    vector<int> e1 = edge[1];
    for (size_t i = 0; i < e1.size(); i++)
    {
        int v = e1[i];
        vector<int> e2 = edge[v];
        for (size_t i = 0; i < e2.size(); i++)
        {
            if (e2[i] == n)
            {
                cout << "POSSIBLE" << endl;
                return 0;
            }
        }
    }
    cout << "IMPOSSIBLE" << endl;
}

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

#ifdef DEBUG
    #define IFD if(true)
#else
    #define IFD if(false)
#endif

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

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

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

    vector<int> l_pre(N + 2);
    for(int i = 1; i <= N; i++) {
        l_pre[i] = gcd(A[i], l_pre[i - 1]);
        IFD cout << l_pre[i] << " ";
    }
    IFD cout << endl;

    vector<int> l_post(N + 2);
    for(int i = N; i >= 1; i--) {
        l_post[i] = gcd(l_post[i + 1], A[i]);
        IFD cout << l_post[i] << " ";
    }
    IFD cout << endl;

    int ans = -1;
    for(int i = 1; i <= N; i++) {
        ans = max(ans, gcd(l_pre[i - 1], l_post[i + 1]));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
#include<functional>
#include<unordered_map>
#include<cmath>

using namespace std;

int mod_num_counter[2030];

int main()
{
  //fill(mod_num_counter,mod_num_counter+2030,0);
  
  long long x;
  cin >> x;
  
  long long i=1;
  long long m=100;
  while(true)
  {
      m *= 1.01;
      if(m>=x)
      {
          break;
      }

    i++;
  }
  

        cout << i << endl;

    
  return 0;
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main(){
	int h,w,a,b;
	cin>>h>>w>>a>>b;
	for(int i=1;i<=h;i++)
	{
		if(i<=b)
		{
			for(int j=1;j<=a;j++)
			cout<<1;
			for(int j=a+1;j<=w;j++)
			cout<<0;
			cout<<endl;
		}
		else{
			for(int j=1;j<=a;j++)
			cout<<0;
			for(int j=a+1;j<=w;j++)
			cout<<1;
			cout<<endl; 
		}
	}
	return 0;
}

Measured memory_bytes: 1280
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt(), M = sc.nextInt();
		if(N>M){
			N^=M;
			M^=N;
			N^=M;
		}
		
		if(N==1 && M==1){
			System.out.println(1);
		}
		else if(N==1){
			System.out.println(M-2);
		}
		else{
			System.out.println((long)(N-2) * (M-2));
		}
	}

}


Measured memory_bytes: 21844
import itertools
import functools
import math
from collections import Counter
from itertools import combinations
import re


N = int(input())
S = []
for i in range(N):
    S.append(input())


C = Counter(S)
D = list(set(S))
D.sort()


max = 0
for i in range(len(D)):
    chk = C[D[i]]
    if max < chk:
        max = chk

for i in range(len(D)):
    chk = C[D[i]]
    if max == chk:
        print(D[i])


Measured memory_bytes: 49020
s = input()
q = int(input())
cou = 1
frt = ""
bck = ""
for i in range(q):
    t = list(input().split())
    #logging.debug(t)#
    if t[0] == "1":
        cou *= -1
    else:
        if (t[1] == "1" and cou == 1)or(t[1] == "2" and cou == -1):
            frt = t[2] + frt
        else:
            bck = bck + t[2]
#    logging.debug("s {},cou {}".format(s,cou))

s = frt + s + bck
#logging.debug(s)#
if cou == 1:
    print(''.join(s))
else:
    print(''.join(s[::-1]))

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

ll n, ans = 0;

bool ck(string str)
{
    int n3 = count(all(str), '3');
    int n5 = count(all(str), '5');
    int n7 = count(all(str), '7');
    return n3 > 0 and n5 > 0 and n7 > 0;
}

int keta(ll num)
{
    int tmp = 0;
    while (num)
    {
        tmp++;
        num /= 10;
    }
    return tmp;
}

void dfs(string str)
{
    if (1 <= str.size() and str.size() <= keta(n))
    {
        if (ck(str) and stoll(str) <= n)
            ans++;
    }
    else if (keta(n) < str.size())
    {
        return;
    }
    for (int i = 3; i < 9; i += 2)
    {
        string tmp = str;
        tmp += i + '0';
        dfs(tmp);
    }
    return;
}

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

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3636