akhauriyash/Code-Regression huggingface dataset:
//AtCoder-agc002F
#include <cstdio>
#define rg register

const int N=2018,M=N*N,p=1e9+7;
int inv[M],fac[M],f[N][N];
int n,m;

template <typename _Tp> inline void pls(_Tp&A,_Tp B){A=A+B<p?A+B:A+B-p;}

inline int qpow(int A,int B){
	int res(1);while(B){
		if(B&1)res=1ll*res*A%p;
		A=1ll*A*A%p;B>>=1;
	}return res;
}

void prework(){
	inv[0]=inv[1]=fac[0]=fac[1]=1;
	for(rg int i=2;i<M;++i)fac[i]=1ll*fac[i-1]*i%p;
	inv[M-1]=qpow(fac[M-1],p-2);
	for(rg int i=M-2;i;--i)inv[i]=1ll*inv[i+1]*(i+1)%p;
}

inline int c(int nn,int mm){return 1ll*fac[nn]*inv[mm]%p*inv[nn-mm]%p;}

int main(){
	prework();scanf("%d%d",&n,&m);
	if(m==1){puts("1");return 0;}
	f[0][0]=1;
	for(rg int i=1;i<=n;++i){
		pls(f[i][0],(int)(1ll*f[i-1][0]*c(i*m-i-1,m-2)%p));
		for(rg int j=1;j<=i;++j){
			f[i][j]=f[i][j-1];
			pls(f[i][j],(int)(1ll*f[i-1][j]*c(i*m+j-i-1,m-2)%p));
		}
	}printf("%lld\n",1ll*f[n][n]*fac[n]%p);
	return 0;
}

Measured memory_bytes: 46976
N, K = map(int, input().split())
A = list(map(int, input().split()))

m = 1000000007

a = [e for e in A if e > 0]
b = [e for e in A if e < 0]
c = [e for e in A if e == 0]
# プラスルート
if len(a) >= K - (min(K, len(b)) // 2) * 2:
    a.sort(reverse=True)
    b.sort()
    result = 1
    i = 0
    j = 0
    k = 0
    while k < K:
        if k < K - 1 and i < len(a) - 1 and j < len(b) - 1:
            x = a[i] * a[i + 1]
            y = b[j] * b[j + 1]
            if y >= x:
                result *= y
                result %= m
                j += 2
                k += 2
            else:
                result *= a[i]
                result %= m
                i += 1
                k += 1
        elif k < K - 1 and j < len(b) - 1:
            y = b[j] * b[j + 1]
            result *= y
            result %= m
            j += 2
            k += 2
        elif i < len(a):
            result *= a[i]
            result %= m
            i += 1
            k += 1
        elif j < len(b):
            result *= b[j]
            result %= m
            j += 1
            k += 1
    print(result)
# 0 ルート
elif len(c) != 0:
    print(0)
# マイナスルート
else:
    a.sort()
    b.sort(reverse=True)
    result = 1
    i = 0
    j = 0
    k = 0
    while k < K:
        if i < len(a) and j < len(b):
            if a[i] <= -b[i]:
                result *= a[i]
                result %= m
                i += 1
                k += 1
            else:
                result *= b[j]
                result %= m
                j += 1
                k += 1
        elif i < len(a):
            result *= a[i]
            result %= m
            i += 1
            k += 1
        elif j < len(b):
            result *= b[j]
            result %= m
            j += 1
            k += 1
    print(result)


Measured memory_bytes: 31740
N,M = [int(i) for i in input().split()]
p = {}

for _ in range(M):
    a, b = map(int, input().split())
    if a in p:
        p[a].append(b)
    else:
        p[a] = [b]
    if b in p:
        p[b].append(a)
    else:
        p[b] = [a]

cnt = 0

def func(q,l,n):
    if n == N:
        global cnt
        cnt += 1
    for i in p[q]:
        if i not in l:
            func(i, l+[i], n+1)

func(1, [1], 1)
print(cnt)


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<string>
#include<set>
//int mod(int a,int b,int d);

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

int main() {
  int n;
  cin >> n;
  string c;
  cin >> c;
  int count=0;
  int i1,i2;
  i1=0;
  i2=n-1;
  while(i1<i2){
    while(c[i1]!='W' && i1<n) i1++;
    while(c[i2]!='R'&& i2>=0) i2--;
    if(i1>=i2) break;
    count++;
    //cout<<count<<" "<<i1<<" "<<i2<<endl;
    i1++;
    i2--;
  }
  cout<<count<<endl;

    

}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp make_pair
#define sz(x) ((int)(x).size())
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define all(x) x.begin(),x.end()
#define y1 omg
#define INF 1000000010
#define FOR(x, n) for(int x=0; x<n; x++)
#define ini(x, n) memset(x, n, sizeof(x));
#define ctoi(x) (x - '0')
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;

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

int n, ans;
vi v(200010);
unordered_map<int, int> M;

int main() {
	fastio;
	cin >> n;
	FOR(i, n) {
		cin >> v[i + 1];
		M[v[i + 1]]++;
	}
	for (int i = 1; i <= n; i++) {
		int flag = 1;
		for (ll j = 1; j * j <= v[i]; j++) {
			if (v[i] % j == 0) {
				//v[i]/j, j
				if (j == v[i] && M[j] >= 2 || j != v[i] && M[j] >= 1 || v[i]/j == v[i] && M[v[i]/j] >= 2 || v[i]/j != v[i] && M[v[i]/j] >= 1) {
					flag = 0;
					break;
				}
			}
		}
		if (flag) ans++;
	}
	cout << ans;
}

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

int main() {
  int N = 9;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  int Q;
  cin >> Q;
  while (Q--) {
    int b;
    cin >> b;
    for (int i = 0; i < N; i++) {
      if (A.at(i) == b) A.at(i) = -1;
    }
  }
  bool b = 0;
  if (A.at(0) + A.at(1) + A.at(2) == -3) b = 1;
  if (A.at(3) + A.at(4) + A.at(5) == -3) b = 1;
  if (A.at(6) + A.at(7) + A.at(8) == -3) b = 1;
  if (A.at(0) + A.at(3) + A.at(6) == -3) b = 1;
  if (A.at(1) + A.at(4) + A.at(7) == -3) b = 1;
  if (A.at(2) + A.at(5) + A.at(8) == -3) b = 1;
  if (A.at(0) + A.at(4) + A.at(8) == -3) b = 1;
  if (A.at(2) + A.at(4) + A.at(6) == -3) b = 1;
  cout << ((b) ? "Yes" : "No") << "\n";
}

Measured memory_bytes: 3628
import java.util.Scanner;


public class Main {



	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] x = new int[n];
		for (int i=0;i<n;i++) {
			x[i]=sc.nextInt();
		}
		
		long ans = Long.MAX_VALUE;
		for (int a=1;a<=100;a++) {
			long sum = 0;
			for (int i=0;i<n;i++) {
				sum+=((a-x[i])*(a-x[i]));
			}
			
			ans = Math.min(ans, sum);
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 22732
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define req(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define qer(i,a,n) for (int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=10000000000000000;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

int main(){
  	string s;cin>>s;cout<<s;
  	if(s[s.length()-1]=='s')cout<<"e";cout<<"s";
    return 0;
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1e11;
int main(){
    int n,m;
    string s;
    cin >> n >> m;
    cin >> s;
    vector<int> ans;
    int c = 0;
    int now = 0;
    int mark = 0;
    while(now != n){
        if (n == 1){
            PRINT(1);
            break;
        }
        now++;
        if (s[n-now] == '0') c = now - mark;
        if (now - mark == m){
            if (c == 0){
                PRINT(-1);
                break;
            }
            else{
                ans.push_back(c);
                mark += c;
                c = 0;
            }
        }
        if (now == n-1){
            ans.push_back(now - mark + 1);
            reverse(all(ans));
            for(int i:ans){
                cout << i << ' ';
            }
            break;
        }
    }
}


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

int main() {
    int N, L; cin >> N >> L;
    vector<string> S(N);
    for (int i = 0; i < N; i++) {
        cin >> S.at(i);
    }
    sort(S.begin(), S.end());
    string ans = "";
    for (auto s : S) {
        ans += s;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys

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


def main():
    A, B = map(int, readline().split())

    if B % A == 0:
        print(A + B)
    else:
        print(B - A)

    return


if __name__ == '__main__':
    main()


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

int main(){
  int n;
  // string s[1];
  cin >> n;
  string s[n];
  for (int i = 0; i < n; i++) cin >> s[i];

  int counter = 1;
  // bool flag = 0;
  // for(int i = 0; i < n; i++){
  //   flag = 0;
  //   for (int j = i; j < n; j++){
  //     if (s[i] == s[j]) flag = 1;
  //   }
  //   if (flag == 0) counter ++;
  // }

  sort(s,s+n);
  // for (int i = 0; i < n; i++){
  //   cout << s[i] << endl;
  // }
  for (int i = 1; i < n; i++){
    if(s[i] != s[i-1]) counter ++;
  }
  cout << counter << endl;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n,ans;
map<ll, bool> f;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    bool ok=1,ok1=1;
    for(ll i=2;i*i<=n;i++)
    {
            if(i==n)
                ok1=0;
            ll aux=n;
            while(n)
            {
                if(n%i==0)
                    n/=i;
                else
                {
                    if(n>=i)
                        n=n%i;
                    else
                        break;
                }
            }
            if(n==1&&f[i]==0)
            {
                ans++;
                //cout<<i<<" ";
                f[i]=1;
            }
            n=aux;
    }
    n--;
    for(ll i=1;i*i<=n;i++)
    {
        if(i*i!=n&&n%i==0)
        {
            ll div=n/i;
            if(f[n/i]==0)
                ans++;
            f[n/i]=1;
            //cout<<div<<" ";
        }
    }
    ans+=ok;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#define FOR(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;

int N, M, K, p, q, cnt;

struct UnionFind {
  // 各ノードの根、そのコンストラクタ
  vector<int> par;
  explicit UnionFind(int n) : par(n, -1) {}

  // 根を返す。mergeで初期化され各ノードの根は自分自身となる。
  int root(int x) {
    if (par[x] < 0)
      return x;
    else
      return par[x] = root(par[x]);
  }

  // 根が同じかどうか
  bool same(int x, int y) { return root(x) == root(y); }

  // 結合
  bool merge(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return false;

    // swap(x, y)。 vector以外のライブラリに拠らない構成にしてみた
    // swap使いたいなら #include<utility> 忘れないように
    if (par[x] > par[y]) {
      int tmp = x;
      x = y;
      y = tmp;
    }

    // 根を統一する。
    par[x] += par[y];
    par[y] = x;
    return true;
  }

  int size(int x) { return -par[root(x)]; }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> N >> M >> K;
  vector<int> ans(N, -1);
  UnionFind uf(N);
  // 友人とブロック関係が同一になることがないからこうしたが
  // その条件がない場合はsetの方がいいかもしれない
  vector<vector<int>> minus(N, vector<int>(0));
  FOR(i, M) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    minus[a].emplace_back(b);
    minus[b].emplace_back(a);
    uf.merge(a, b);
  }

  FOR(i, K) {
    int c, d;
    cin >> c >> d;
    c--;
    d--;
    if (!uf.same(c, d)) continue;
    minus[c].emplace_back(d);
    minus[d].emplace_back(c);
  }

  FOR(i, N) { ans[i] = uf.size(i) - minus[i].size() - 1; }

  FOR(i, N - 1) cout << ans[i] << " ";
  cout << ans[N - 1] << endl;
  return 0;
}

Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;

struct node {
	int x;
	int y;
}a[maxn];
int cmp(node xx, node yy) {
	return xx.x < yy.x;
}
int main() {
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> a[i].x;
		a[i].y = i;
	}
	sort(a+1, a+n+1, cmp);
	for(int i = 1; i <= n; i++) {
		cout << a[i].y << " ";
	}
	cout << endl;
}


Measured memory_bytes: 1536
#ABC045

s = [input() for _ in range(3)]
a = ["a","b","c"]
turn = 0
c = True
while c:
    if s[turn] == "":
        print(a[turn].upper())
        break
    else:
        x = s[turn][0]
        s[turn] = s[turn][1:]
        turn = a.index(x)

Measured memory_bytes: 3060
k=int(input())
num=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(num[k-1])

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

int n, m, d, ans;
string a = "";

int main()
{
    cin >> n >> m >> d;
    for (int i = 0; i < d; i++) a = a + ".";
    vector<string> v(n), u(m);
    for (int i = 0; i < m; i++) u[i] = "";
    for (int i = 0; i < n; i++){
        cin >> v[i];
        for (int j = 0; j + d <= m; j++){
            string t = v[i].substr(j, d);
            if (a == t) ans++;
        }
        for (int j = 0; j < m; j++){
            u[j] = u[j] + v[i][j];
        }
    }
    for (int i = 0; i < m; i++){
        for (int j = 0; j + d <= n; j++){
            string t = u[i].substr(j, d);
            if (a == t) ans++;
        }
    }
    cout << ans << endl;
}


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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int n;cin>>n;
    vl a(n);
    rep(i,n)cin>>a[i];
    vvl dp(n+10,vl(4,-L_INF));
    int m = n%2 + 1;//奇数なら2こ飛ばせる
    dp[0][0]=0;
    rep(i,n){
        rep(j,m+1){
            chmax(dp[i+1][j+1],dp[i][j]);
            ll now = dp[i][j];
            if((i+j)%2==0) now += a[i];
            chmax(dp[i+1][j],now);
        }
    }
    out(dp[n][m]);
}


Measured memory_bytes: 18780
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n,a,b;
  cin >> n >> a >> b;
  ll res = n - a;
  res = res - res / b * b;
  cout << res << endl;
}


Measured memory_bytes: 3560
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main()
{
	double x, h;
	while (true){
		cin >> x >> h;
		if (x == 0 && h == 0){
			break;
		}
		double ans = x*sqrt(4 * h*h + x*x) + x*x;
		printf("%lf\n", ans);
	}
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
	using namespace std;
	#define mod 1000000007
	#define fi first
	#define se second
	#define mp make_pair
	#define pb push_back
	#define ps push
	#define pll pair<long,long>
	typedef long long ll;
	#define PI 3.14159265
	
	
	const ll INF=(ll)1e16;
	
	
	int main()
	{
		ios::sync_with_stdio(0); 
		cin.tie(0); 
		cout.tie(0);
		
		ll x,y,a,b,c;
		cin>>x>>y>>a>>b>>c;
		vector<ll> v1(a+1),v2(b+1),v3(c+1);
		for(ll i=1;i<=a;i++)
		{
			cin>>v1[i];
		}
		for(ll i=1;i<=b;i++)
		{
			cin>>v2[i];
		}
		for(ll i=1;i<=c;i++)
		{
			cin>>v3[i];
		}
		sort(v1.begin()+1,v1.end(),greater<int>());
		sort(v2.begin()+1,v2.end(),greater<int>());	
		sort(v3.begin()+1,v3.end(),greater<int>());
		vector<ll> tmp;
		for(ll i=1;i<=x;i++)
		{
			tmp.pb(v1[i]);
		}
		for(ll i=1;i<=y;i++)
		{
			tmp.pb(v2[i]);
		}
		for(ll i=1;i<=c;i++)
		{
			tmp.pb(v3[i]);
		}
		sort(tmp.begin(),tmp.end(),greater<int>());
		ll s=0;
		for(ll i=0;i<(x+y);i++)
		{
			s+=tmp[i];
		}
		cout<<s;
	}
	


Measured memory_bytes: 8304
//ABC 044-B
#define _USE_MATH_DEFINES

#include <iostream>
#include <cmath>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cstring>
#include <numeric>
#include <string>
#include <map>
#include <sstream>
using namespace std;

int main() {
	string w;
	int check = 0;
	cin >> w;
	vector<int> Alphabet(100, 0);
	Alphabet[0] = 1;

	for (int i = 1; i < w.size(); i++) {
		for (int j = 0; j < i; j++) {
			if (w[i] == w[j]) {
				Alphabet[j]++;
				Alphabet[i] = -1;
				break;
			}
		}
		Alphabet[i] += 1;
	}
	for (int i = 0; i < w.size(); i++){
		check += Alphabet[i]%2;
	}
	if (check > 0) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI = acos(-1);
const ll MOD = 1000000007;

int main() {
  int H,W,K; cin >> H >> W >> K;
  vector<string> s(H);
  for (int i = 0; i < H; i++) cin >> s[i];
  
  vector<bool> check(H);
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (s[i][j] == '#') check[i] = true;
    }
  }
  
  int count = 0;
  vector<vector<int>> data(H,vector<int>(W));
  vector<int> y(K+1),x(K+1);
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (s[i][j] == '#') {
        count++;
        data[i][j] = count;
        y[count] = i;
        x[count] = j;
      }
    }
  }
  
  for (int i = 1; i <= K; i++) {
    int dx = x[i]-1;
    int dy = y[i];
    while (dx >= 0) {
      if (data[dy][dx] == 0) {
        data[dy][dx] = i;
        dx--;
      } else break;
    }
  }
  
  for (int i = 1; i <= K; i++) {
    int dx = x[i]+1;
    int dy = y[i];
    while (dx < W) {
      if (data[dy][dx] == 0) {
        data[dy][dx] = i;
        dx++;
      } else break;
    }
  }
  
  for (int i = 0; i < H; i++) {
    if (check[i]) {
      int dy = i + 1;
      while (dy < H) {
        if (!check[dy]) {
          check[dy] = true;
          for (int j = 0; j < W; j++) data[dy][j] = data[i][j];
          dy++;
        } else break;
      }
    }
  }
  
  for (int i = 0; i < H; i++) {
    if (check[i]) {
      int dy = i - 1;
      while (dy >= 0) {
        if (!check[dy]) {
          check[dy] = true;
          for (int j = 0; j < W; j++) data[dy][j] = data[i][j];
          dy--;
        } else break;
      }
    }
  }
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) cout << data[i][j] << " ";
    cout << endl;
  }
}

Measured memory_bytes: 2048
#include <iostream>
using namespace std;
int main(){
int A,B;
  cin>>A;
  cin>>B;
  if(A+B==3){cout<<'3'<<endl;}
  else if(A+B==4){cout<<'2'<<endl;}
  else if(A+B==5){cout<<'1'<<endl;}
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  vector<char> s(S.size());
  
  for (int i = 0; i < S.size(); i++){
    s.at(i) = S.at(i);
  }
  
  int count = 0;
  int rinzi = 0;
  for (int i = 0; i < S.size(); i++){   
    if (s.at(i) == 'A' || s.at(i) == 'C' || s.at(i) == 'T' || s.at(i) == 'G'){
      rinzi++;
    } else {
      if (rinzi > count){
        count = rinzi;
      }
      rinzi = 0;
    }
  }
  
  if (rinzi > count){
        count = rinzi;
  }
  
  cout << count << endl;      

}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,k,n) for(int (i)=(k);(i)<(n);(i)++)
using namespace std;
typedef long long int ll;

void foreach_permutation(int n, std::function<void(int *)> f) {
    int indexes[n];
    for (int i = 0; i < n; i++) indexes[i] = i+1;
    do {
        f(indexes);
    } while (std::next_permutation(indexes, indexes + n));
}



int main() {
  int N;
  cin >> N;
  ll sum = 0;
  for(int i=1;i<=N;i++){
      if(i%3!=0&&i%5!=0){
          sum+=i;
      }
  }
    cout << sum << endl;

}


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

#define PI 3.14159265359
#define eps 1e-8
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
typedef long long int ll;
const int INF = 1<<29;
typedef long long ll;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int a,b,s,t;

int main(){
	ios_base::sync_with_stdio(false); //Fast I/O
	cin.tie(NULL);
	//freopen("in.txt","r",stdin);
	//freopen("output.txt","w",stdout);	
	
    cin >> a >> b >> s >> t;

    FOR(i,a,s)  cout << "R";
    FOR(i,b,t)  cout << "U";
    FOR(i,a,s)  cout << "L";
    FOR(i,b,t)  cout << "D";
    cout << "D";
    FORN(i,a,s) cout << "R";
    FORN(i,b,t) cout << "U";
    cout << "L";
    cout << "U";
    FORN(i,a,s) cout << "L";
    FORN(i,b,t) cout << "D";
    cout << "R";

	return 0;
}



Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a string
	var b string
	var c string

	fmt.Scan(&a, &b, &c)

	if a[len(a)-1] == b[0] && b[len(b)-1] == c[0] {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}

}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main()
    {
        //ABC065
        Scanner cin = new Scanner();
        long N = cin.Long();
        long M = cin.Long();
        var n = N;
        var m = M;

        if (Math.Abs(N - M) > 1) Console.WriteLine(0);
        else
        {
            long ans = 1;
            while(M >= 1)
            {
                ans = ans * M % 1000000007;
                M--;
            }
            while(N >= 1)
            {
                ans = ans * N % 1000000007;
                N--;
            }
            Console.WriteLine(Math.Abs(n - m) == 1 ? ans : 2 * ans % 1000000007);
        }
        Console.ReadLine();
    }
}

class Scanner //標準入力
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int Int()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Int() + add;
        }
        return Array;
    }

    public long Long()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Long() + add;
        }
        return Array;
    }

    public double Double()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Double() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 13140
#include<stdio.h>
int main()
{
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	int max = a;
	if (max < b)max = b;
	if (max < c)max = c;
	int min = a + b + c - max;
	if (max == min)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a.at(i);
	}
	
	sort(a.begin(), a.end());

	int alice=0, bob=0;
	for (int i = 0; i < n; i++) {
		if (i % 2 == 0) {
			alice += a.at(i);
		}
		else {
			bob += a.at(i);
		}
	}

	cout << abs(alice - bob) << endl;
}

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

using namespace std;

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

const int MX = 105;
int n, u, v, lvl[MX], d[MX], p[MX];
int x = 1, y = 1;
int res, a, b;
ll mx[MX], mn = 1e18;
vi adj[MX];

void dfs (int u) {
	for (int v : adj[u])
		if (v != p[u]) {
			d[v] = d[u] + 1;
			p[v] = u;
			dfs(v);
		}
}

void wei (int u, int p, int l) {
	ll f = 0;
	for (int v : adj[u])
		if (v != p) {
			f++;
			wei(v, u, l+1);
		}
	mx[l] = max(mx[l], f);
}

ll obtRes () {
	ll acu = 1;
	for (int i = 0; i < res; i++)
		acu *= mx[i];
	return acu;
}

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> n;
	for (int i = 1; i < n; i++) {
		cin >> u >> v;
		adj[u].pb(v);
		adj[v].pb(u);
	}

	p[1] = -1;
	d[1] = 1;
	dfs(1);
	for (int i = 1; i <= n; i++)
		if (d[i] > d[x])
			x = i;
	
	memset(d, 0, sizeof(d));
	p[x] = -1;
	d[x] = 1;
	dfs(x);
	for (int i = 1; i <= n; i++)
		if (d[i] > d[y])
			y = i;

	res = (d[y] + 1) / 2;
	if (d[y] & 1) {
		u = y;
		while (u != -1) {
			if (d[u] == res) a = u;
			u = p[u];
		}

		mx[0] = 1;
		wei(a, a, 1);
		mn = obtRes();

		for (int b : adj[a]) {
			memset(mx ,0, sizeof(mx));

			mx[0] = 2;
			wei(a, b, 1);
			wei(b, a, 1);
			mn = min(obtRes(), mn);
		}
	} else {
		u = y;
		while (u != -1) {
			if (d[u] == res) a = u;
			if (d[u] == res + 1) b = u;
			u = p[u];
		}

		mx[0] = 2;
		wei(a, b, 1);
		wei(b, a, 1);
		mn = obtRes();
	}

	cout << res << " " << mn << endl;

	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <map>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <time.h>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,b,a) for(int i=(b)-1;i>=(a);--i)
#define FILL(A,val) memset(A,val,sizeof(A))
#define ITER(it,a) for(__typeof(a.begin()) it=a.begin();it!=a.end();++it)

#define ALL(V) V.begin(),V.end()
#define SZ(V) (int)V.size()
#define PB push_back
#define MP make_pair

typedef long long Int;
typedef unsigned long long UInt;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double Pi = acos(-1.0);
const int INF = 1000000000;

long long F(long long N, long long x) {
	//cout << N << ' ' << x << endl;
	long long cnt = N / x;

	if (cnt * x == N) return x * 2 * (cnt - 1) ;

	long long res = (cnt*2-1) * x + (N % x);
	res += F(x, N%x);

	return res;
}

int main()
{
	//freopen("in.txt","r",stdin);
	long long n, x;
	cin >> n >> x;
	long long res = x + F(n, n-x);

	cout << res << endl;

//	cout << F(10, 2) << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, k;
	scanf ( "%d %d", &n, &k );
	int d[k];
	for ( int i = 0; i < k; i++ )
		scanf ( "%d", &d[i] );
	bool used[10];
	for ( int i = 0; i < 10; i++ )
		used[i] = true;
	for ( int i = 0; i < k; i++ )
		used[d[i]] = false;
	for ( int i = n; ; i++ ) {
		string s = to_string ( i );
		bool ok = true;
		for ( int j = 0; j < s.size(); j++ ) 
			if ( !used[s[j] - '0'] ) 
				ok = false;
		if ( ok ) {
			printf ( "%d\n", i );
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 256
a=input()
b=[2,4,5,7,9]
c =[0,1,6,8]
d=[3]
for i in b:
	if i==int(a[-1]):
		print('hon')
for i in c:
	if i==int(a[-1]):
		print('pon')
for i in d:
	if i==int(a[-1]):
		print('bon')



Measured memory_bytes: 9060
#include"bits/stdc++.h"

typedef long long ll;

using namespace std;

#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, n) for(ll i=n; i>=0; i--)
#define reps(i, s, e) for(ll i=s; i<e; i++)
#define all(x) x.begin(),x.end()

int main(){
	int N;

	cin >> N;

	vector<int> v(N);
	vector<int> w(N);


	int l, i = 0;
	while (cin >> l) {
        v[i] = l;
        w[i] = l;

        i++;
        if (i >= N) {
            break;
        }
    }

    size_t v_len = v.size();
    ll count = 0;

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

    // rep(i,N) cout << v[i] << endl;

    rep(i,v_len){
    	reps(j,i+1,v_len){
    		reps(k,j+1,v_len){
    			if(abs(v[i] - v[j]) < v[k] && v[k] < v[i] + v[j] ){
    				count ++;
    			}
    			else if(v[k] >= v[i] + v[j]) break;
    		}
    	}
    }

    // sort(v.begin(), v.end() );
    // v.erase(unique(v.begin(), v.end()), v.end());

    // size_t v_len = v.size();

    // vector<int> x(v_len);

    // rep(i,v_len){
    // 	size_t n_count = count(w.begin(), w.end(), v[i]);
    // 	x[i] = n_count;
    // }

    // rep(i,v_len){
    // 	cout << v[i] << x[i] << endl;
    // }

    // ll count = 0;

    // rep(i,v_len){
    // 	// 正三角形
    // 	if(x[i] >= 3) count ++;

    // 	reps(j,i+1,v_len){
    // 		// 二等辺三角形			
    // 		if(x[i] >= 2 && v[j] < 2*v[i]) count ++;
    // 		if(x[j] >= 2 && v[i] < 2*v[j]) count ++;

    // 		reps(k,j+1,v_len){
    // 			if(abs(v[i] - v[j]) < v[k] && v[k] < v[i] + v[j] ){
    // 				count ++;
    // 			}
    // 			else if(v[k] >= v[i] + v[j]) break;
    // 		}
    // 	}
    // }

    cout << count << endl;

    return 0;
}	

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i<N; i++)
#define RVROOP(i, N) for(int i=N; i>=0; i--)
#define INF 1e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main() {
  int N,M; cin>>N>>M;
  vector<int> L(M), R(M);
  for(int i=0; i<M; i++){
    cin>>L[i]>>R[i];
  }
  sort(L.begin(), L.end());
  int l=L[M-1];
  sort(R.begin(), R.end());
  int r=R[0];
  int ans=max(0, r-l+1);
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=100005;

struct edge{
	int to, w, next;
}e[maxn<<1];
int head[maxn];
int cnt;

void init(){
	memset(head, -1, sizeof(head));
	cnt=0;
}

void add(int u, int v, int w){
	e[cnt].to=v;
	e[cnt].w=w;
	e[cnt].next=head[u];
	head[u]=cnt++;
}


ll dis[maxn];
int n, k, q;

void dfs(int u, int fa, ll d){
	dis[u]=d;
	for(int i=head[u];~i;i=e[i].next){
		if(e[i].to!=fa){
			dfs(e[i].to, u, d+e[i].w);
		}
	}
}

int main(){
	init();
	scanf("%d", &n);
	for(int i=1;i<n;i++){
		int x, y, c;
		scanf("%d%d%d", &x, &y, &c);
		add(x, y, c);
		add(y, x, c);
	}
	scanf("%d%d", &q, &k);
	dfs(k, 0, 0);
	while(q--){
		int u, v;
		scanf("%d%d", &u, &v);
		printf("%lld\n", dis[u]+dis[v]);
	}
}



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

int main() {
    int a, b;

    cin >> a >> b;

    int add = a + b;
    int sub = a - b;
    int mul = a * b;

    if (add >= sub) {
        if (add >= mul) {
            cout << add << endl;
        } else {
            cout << mul << endl;
        }
    } else {
        if (sub >= mul) {
            cout << sub << endl;
        } else {
            cout << mul << endl;
        }
    }

    return 0;
}


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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

int N, A[200005][70];
lint K;

int main() {
    cin >> N >> K;
    INIT(A, -1);
    for_(i,0,N) {
        cin >> A[i][0];
        --A[i][0];
    }

    for_(k,0,64) for_(i,0,N) {
        int x = A[i][k];
        A[i][k+1] = A[x][k];
    }

    int x = 0;
    for_(i,0,61) {
        if (K >> i & 1) {
            x = A[x][i];
        }
    }
    cout << x + 1 << endl;
}

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

int	main()
{
	int	A, B, M;
	cin >> A >> B >> M;
	vector<int> a(A), b(B);
	int	min_a, min_b;
	int	tmp_a, tmp_b;
	for (int i = 0; i < A; ++i) {
		cin >> tmp_a;
		a.at(i) = tmp_a;
		if (i == 0 || tmp_a < min_a)
			min_a = tmp_a;
	}
	for (int i = 0; i < B; ++i) {
		cin >> tmp_b;
		b.at(i) = tmp_b;
		if (i == 0 || tmp_b < min_b)
			min_b = tmp_b;
	}
	int	min_amount = min_a + min_b;
	int	amount;
	int	x, y, c;
	for (int i = 0; i < M; ++i) {
		cin >> x >> y >> c;
		amount = a.at(x - 1) + b.at(y - 1) - c;
		if (amount < min_amount)
			min_amount = amount;
	}
	cout << min_amount << endl;
}	


Measured memory_bytes: 1024
#ifdef __GNUC__
#include <bits/stdc++.h>
#endif // __GNUC_

int main() {

    std::string S;
    std::cin >> S;

    size_t zero = std::count(S.begin(), S.end(), '0');

    std::cout << std::min(zero, S.size() - zero)*2 << std::endl;

}

Measured memory_bytes: 512
S = input()
n = len(S)
ans = [0] * n
lr = "r"
for i in range(n):
    if (i == 0 or lr == "l") and S[i] == "R":
        c = 0
        lr ="r"
        while S[i+c] == "R":
            c += 1    
        ans[i+c] += c//2
        ans[i+c-1] += (c+1)//2
    elif lr == "r" and S[i] == "L":
        c = 0
        lr = "l"
        while i+c < n and S[i+c] == "L":
            c += 1
        ans[i] += (c+1)//2
        ans[i-1] += c//2
print(*ans)

Measured memory_bytes: 10808
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#include <bitset>
#include <complex>
#define ll long long
#define INF 1000000000000000001
#define MOD 998244353
using namespace std;


int main(){
    ll N;
    cin >> N;
    for(int i=0; i<50000; i++){
        if((int)((double)i*1.08)==N){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<":("<<endl;
    return 0;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(void){
	int n, m;
	while(cin >> n >> m){
		if(n+m == 0)break;
		cout << min(n,m) << " " << max(n,m) << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
using System;
class ProgramB
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            int n = int.Parse(input);
            
            string[] a = Console.ReadLine().Split(' ');
            double sum = 0;
            
            for(int i = 0;i < n;i++)
            {
                double ai = double.Parse(a[i]);
                sum += 1/ai;

            }

            Console.WriteLine(1.0/sum);
        }
    }

Measured memory_bytes: 11092
#include<iostream>
#include<vector>
#include<stack>
#include<algorithm>
#include<string>
#include<set>
#include<numeric>
#include<functional>
#include<unordered_map>
#include<cmath>
#include<cstdlib>
#include<cassert>
using namespace std;

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

	vector<bool> visited(N + 1, false);
	visited[1] = true;
	int ans = 0, curr = 1;
	while (true) {
		ans++;
		curr = a[curr];
		if (curr == 2)
			break;
		if (visited[curr]) {
			ans = -1;
			break;
		}
		visited[curr] = true;
	}
	cout << ans << endl;
}

Measured memory_bytes: 768
n = gets.to_i
s = n.times.map{gets.to_i}.sort

ans = s.inject(:+)
flag = false
if ans % 10 == 0
  n.times do |i|
    if s[i] % 10 != 0
      ans -= s[i]
      flag = true
      break
    end
  end
else
  flag = true
end

ans = 0 if !flag
puts ans

Measured memory_bytes: 1788
#include <iostream>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)

int main(void)
{
	int N;
	cin >> N;
	int ans = 1;

	int a, b;
	cin >> a;
	int dir = 0;
	int count_dir = 0;
	rep(i, N - 1){
		cin >> b;
		if(b == a) continue;
		if(a < b){
			if(count_dir == 0) count_dir = -1;
			if(count_dir == 1 && dir == -1) ans++, count_dir = 0;
			dir = 1;
		}else{
			if(count_dir == 0) count_dir = 1;
			if(count_dir == -1 && dir == 1) ans++, count_dir = 0;
			dir = -1;
		}
		a = b;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
  ll n,m,s=0;
  cin>>n>>m;
  ll a[m+1],i;
  for(i=0;i<m;i++)
  {
      cin>>a[i];
      s+=a[i];
  }
  if(n-s<0)
    cout<<-1<<endl;
  else
    cout<<n-s<<endl;

}


Measured memory_bytes: 3708
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5;
struct Element
{
    int u,v,opt;
} p[N+3];
int fa[N+3];
ll n,q,c,m;

int find(int u) {return fa[u]==u?u:fa[u]=find(fa[u]);}

int main()
{
    cin>>n>>m>>q;
    for(int i=1; i<=n; i++) fa[i] = i;
    for(int i=1; i<=q; i++)
    {
        scanf("%d%d%d",&p[i].u,&p[i].v,&p[i].opt); p[i].u++; p[i].v++;
        if(p[i].opt==0)
        {
            int uu = find(p[i].u),vv = find(p[i].v);
            if(uu!=vv) {fa[uu] = vv;}
        }
    }
    ll huan = 0; c = 0;
    for(int i=1; i<=n; i++) {if(i==find(i)) c++;}
    for(int i=1; i<=q; i++){
        if(p[i].opt==1){
            huan++;
            int uu = find(p[i].u),vv = find(p[i].v);
            if(uu==vv) {puts("No"); return 0;}
        }
    }
    ll l = huan?max(3ll,(ll)c):c-1ll,r = 1ll*c*(c-1ll)/2ll;
    if(m-(n-c)>=l && m-(n-c)<=r) {puts("Yes");}
    else {puts("No");}
    return 0;
}


Measured memory_bytes: 1920
#include <stdio.h>
int main(void){
    int n,x,i,j,k;
    int cnt = 0;
    while(1){
        scanf("%d %d" , &n , &x );
        if( n == 0 && x == 0 ) break;
        for( i = 1; i <= n ; i++ ){
            for( j = i + 1; j <= n ; j++ ){
                for( k = j + 1; k <= n ; k++ ){
                    if( i + j + k == x ){
                        cnt++;
                    }
                }
            }
        }
        printf( "%d\n" , cnt );
        cnt = 0;
    }
}


Measured memory_bytes: 2104
N = int(input())
Ss = input()

used1s = [False] * 10
used2s = [False] * 100
used3s = [False] * 1000

for S in Ss:
    S = int(S)
    for x in range(100):
        if used2s[x]:
            used3s[x*10+S] = True
    for x in range(10):
        if used1s[x]:
            used2s[x*10+S] = True
    used1s[S] = True

ans = used3s.count(True)
print(ans)


Measured memory_bytes: 43400
#include <bits/stdc++.h>
using namespace std;
string s;
int ans=0;
int n;
int main() {
  cin >>n>> s;
  for(int i = 0;i<(int)s.size()-1;++i){
    if(s.at(i) != s.at(i+1)){
      ++ans;
    }
  }
  cout << ans+1 << endl;
  return 0;
}


Measured memory_bytes: 3672
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<string>
#include<cstdio>
#include<queue>
#include<functional>
using namespace std;
int main() {
	int n, k, q,a[100001]; cin >> n >> k >> q;
	for (int i = 1; i <= n; ++i) a[i] = k;
	for (int i = 0; i < q; ++i) {
		int x; cin >> x;
		a[x]++;
	}
	for (int i = 1; i <= n; ++i)
		cout << (a[i]-q > 0 ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  string b;
  cin >> b;

  char c = b[0];
  char ans;
  switch(c){
    case'A': ans = 'T'; break;
    case 'C': ans = 'G'; break;
    case 'G': ans = 'C'; break;
    case 'T': ans = 'A'; break;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
/*
Author: Babin Dutta
*/

#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define f(i,n) for(int i=0;i<n;i++)
#define ff(i,a,b) for(int i=a;i<=b;i++)
#define all(v) v.begin(),v.end()
#define endl "\n"
#define inf 1e18


void solve(int tt){
	string s; cin>>s;
	if(s == "ABC") cout<<"ARC"<<endl;
	else cout<<"ABC"<<endl;
}


int main(){
	#ifdef JUDGE
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
    #endif
	boost;
	int t=1; //cin>>t;
	for(int i=1;i<=t;i++) solve(i);
	return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;

int main(){
    int N;
    string S;
    cin >> N;
    cin >> S;
    vector <char> q(N);

    int t = 0;
    for(int i=0; i<N; i++){
        if(i==0){
            q.at(t) = S.at(i);
        }
        else {
            if (q.at(t) != S.at(i)) {
                t++;
                q.at(t) = S.at(i);

            }
        }
    }
    cout << t + 1 << endl;
}

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

int main()
{
  int a, b, c; cin >> a >> b >> c;
  if (a == b && b == c) {
	cout << 1 << endl;
	return 0;
  }
  if (a == b && b != c) {
	cout << 2 << endl;
	return 0;
  }
  if (a == c && b != c) {
	cout << 2 << endl;
	return 0;
  }
  if (b == c && a != c) {
	cout << 2 << endl;
	return 0;
  }
  
  cout << 3 << endl;
  
  return 0;
}



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

int main() {
  int a,b,c,ans = 1;
  cin>>a>>b>>c;
  if (b!=a) ans++;
  if (c!=a && c!=b) ans++;
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

class Main{
  public static void main(String[] args) throws IOException {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    char R = 'R';
    char[] chars = s.toCharArray();
    int count;
    if(chars[0] == R && chars[1] == R && chars[2] == R){
      count =3;
    }
    else if( (chars[0] == R && chars[1] == R) || (chars[1] == R && chars[2] == R)){
      count =2;
    }
    else if( chars[0] == R || chars[1] == R || chars[2] == R){
      count =1;
    }
    else{
      count = 0;
    }
    System.out.println(count);
  }

  static class Scanner {
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s) {
      br = new BufferedReader(new InputStreamReader(s));
    }

    public Scanner(FileReader s) throws FileNotFoundException {
      br = new BufferedReader(s);
    }

    public String next() throws IOException {
      while (st == null || !st.hasMoreTokens())
        st = new StringTokenizer(br.readLine());
      return st.nextToken();
    }

    public int nextInt() throws IOException {
      return Integer.parseInt(next());
    }

    public long nextLong() throws IOException {
      return Long.parseLong(next());
    }

    public String nextLine() throws IOException {
      return br.readLine();
    }

    public double nextDouble() throws IOException {
      return Double.parseDouble(next());
    }

    public boolean ready() throws IOException {
      return br.ready();
    }
  }
}


Measured memory_bytes: 32788
import sys
inputs = list(map(lambda x: int(x.rstrip()), sys.stdin.readlines()))

# n = inputs[0]
r_min = inputs[1]
p_max = -10**9
for r in inputs[2:]:
    p_max = max(p_max, r-r_min)
    r_min = min(r_min, r)

print(p_max)


Measured memory_bytes: 27716
import java.util.Scanner;

class Main{
  public static void main(String[] args) {
    
	  Scanner sc = new Scanner(System.in);
	  
	  int x = -1;
	  
	  int y = 1;
	  
	  while(x!=0 || y!=0){
		  
		  x = sc.nextInt();
		  
		  y = sc.nextInt();
		  
		  if(x > y){
			  System.out.println(y+" "+x);
		  }else if (x < y){
			  System.out.println(x+" "+y);
		  }else if(x == y){
			  if(x==0 && y==0){
				  //何もしない
			  }else{
				  System.out.println(x+" "+y);
			  }
		  } 
		  
	  }
 

  }
}

Measured memory_bytes: 34316
#include<stdio.h>

int main(void){
	int a,b,c;

	scanf("%d %d %d",&a,&b,&c);
	if(a==b || b==c || c==a){
		if(a!=b || b!=c || c!=a){
			printf("Yes");
		}else{
			printf("No");
		}
	}else if(a!=b && b!=c && c!=a){
		printf("No");
	}

	



	return 0;
}

Measured memory_bytes: 128