akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define int long long
#define fi first
#define se second
#define pb push_back
#define ins insert
#define er erase

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;

const int oo = 1e18 + 7, mod = 1e9 + 7;

const int N = 3005;

int n, m, r[N], dp[N][N], pref[N];
string s;

signed main(){
	ios_base::sync_with_stdio(0);
	cin >> n >> m;
	cin >> s;
    s = '*' + s;
    for(int i = 1; i <= n; i++) pref[i] = (pref[i - 1] + (s[i] - '0'));
	for(int i = 1; i <= m; i++){
	    int le, ri;
	    cin >> le >> ri;
	    r[le] = max(r[le], ri);
	}
	for(int i = 2; i <= n; i++) if(i <= r[i - 1]) r[i] = max(r[i], r[i - 1]);
	dp[0][0] = 1;
	for(int i = 1; i <= n; i++){
	    for(int j = 0; j <= i; j++){
	        if(!r[i]){
	            if(j >= (s[i] - '0')) dp[i][j] = dp[i - 1][j - (s[i] - '0')];
	            continue;
	        }
	        else{
	            if(r[i] - pref[r[i]] < (i - j)) continue;
	            if(pref[r[i]] < j) continue;
	            dp[i][j] = (dp[i - 1][j] + dp[i - 1][j - 1]) % mod;
	        }
	    }
	}
	cout << dp[n][pref[n]];
}



Measured memory_bytes: 16528
import java.util.Scanner;
import java.util.ArrayList;
import java.lang.Math;
import java.util.Collections;


public class Main{   
	public static void main(String[] args){   
		ArrayList<Long> list = new ArrayList<Long>();

		long TMP=2;

		list.add(TMP);

		for(long i=3;i<=1000000;i++){
			boolean flag=true;
			for(long num :list){

				long tmp = (long)Math.sqrt(i);

				if(tmp<num){
					break;
				}

				if(i%num==0){
					flag=false;
					break;
				}
			}

			if(flag==true){
				list.add(i);
			}
		}

		
		//Collections.sort(list);
		Scanner scan = new Scanner(System.in);

		while(true){
			long n = scan.nextInt();
			long count=0;
			if(n==0){
				break;
			}

			for(long tmp:list){
				if(tmp>n && tmp<=2*n){
//					System.out.println(tmp);
					count++;	
				}
			}

			System.out.println(count);
		}


	}
}

Measured memory_bytes: 57584
fn main() {
    let s: String = read();
    let mut result = 0;

    for item in s.chars() {
        if item == '+' {
            result += 1;
        } else if item == '-' {
            result -= 1;
        }
    }

    println!("{}", result);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))
#define Max(x, y)(max(decltype(x)(0), max((x), (y))))
#define Min(x, y)(max(decltype(x)(0), min((x), (y))))
#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repit(x, y) for ((x) = (y).begin(); (x) != (y).end(); (x)++)
#define all(x) (x).begin(),(x).end()
#define _end '\n'
#define Out(x) cout<<(x)<<_end
template<typename T> inline bool _max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool _min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using vvec = vector<vector<T> >;

#define pb push_back
#define mp make_pair

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll x, y, len = 1e18;

    cin >> x >> y;

    if (x == y) {
        Out(-1);
    } else {
        if (x % y != 0) {
            Out(x);
        } else {
            Out(-1);
        }
    }

    return 0;
}


Measured memory_bytes: 256
(*
ocamlfind ocamlopt -package batteries -linkpkg main.ml -o a.out
*)
open Batteries

let slst = Str.split (Str.regexp "") (read_line ())

let rec f lst =
        match lst with
                  [] -> "yes"
                | first :: rest -> 
                        let exists = List.exists (fun elmnt -> elmnt = first) rest in
                                if exists then
                                        "no"
                                else
                                        f rest

let () =
        f slst
        |> Printf.printf "%s"


Measured memory_bytes: 3072
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define N 1010
inline int read(){
    int x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9'){
        if(c=='-')f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9'){
        x=(x<<3)+(x<<1)+c-'0';
        c=getchar();
    }
    return x*f;
}
int n,m,k,ans,a[N][N],p[15],b[15];
char s[N][N];
int check(int x){
	memset(p,0,sizeof(p));
	int now=1,ans=0;
	for(int i=1;i<=n;++i){
		b[i]=now;
		if((x>>(i-1))&1)++now;
	}
	for(int i=1;i<=m;++i){
		for(int j=1;j<=n;++j){
			p[b[j]]+=a[j][i];
		}
		bool ok=true;
		for(int j=1;j<=now;++j){
			if(p[j]>k){
				ok=false;
				break;
			}
		}
		if(!ok){
			++ans;
			memset(p,0,sizeof(p));
			for(int j=1;j<=n;++j){
				p[b[j]]+=a[j][i];
			}
			for(int j=1;j<=now;++j){
				if(p[j]>k)return n+m;
			}
		}
	}
	return ans;
}
int main(){
	n=read(),m=read(),ans=n+m,k=read();
	for(int i=1;i<=n;++i){
		scanf("%s",s[i]+1);
		for(int j=1;j<=m;++j){
			a[i][j]=s[i][j]-'0';
		}
	}
	int tot=(1<<(n-1))-1;
	for(int i=0;i<=tot;++i){
		int cnt=0;
		for(int j=1;j<=n-1;++j){
			if((i>>(j-1))&1)++cnt;
		}
		ans=min(ans,check(i)+cnt);
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
from collections import deque
N=int(input())
G=[[] for i in range(N)]
for i in range(N-1):
    a,b=map(int,input().split())
    a-=1;b-=1
    G[a].append(b)
    G[b].append(a)
j=0
for i in range(N):
    if len(G[i])>len(G[j]):
        j=i
c=sorted([int(i) for i in input().split()])
M=sum(c)-max(c)
d=[-1 for i in range(N)]
q=deque([j])
while(len(q)>0):
    r=q.popleft()
    d[r]=c.pop()
    for p in G[r]:
        if d[p]==-1:
            q.appendleft(p)
print(M)
print(" ".join([str(i) for i in d]))


Measured memory_bytes: 6252
s=list(input())
ans=[]
for i in range(len(s)):
    if s[i]=="0":
        ans.append("0")
    elif s[i]=="1":
        ans.append("1")
    else:
        if len(ans)==0:
            pass
        else:
            ans.pop(-1)
print("".join(ans))

Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#define SIZE 100005

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

vector <int> vec[SIZE];
int deg[SIZE];

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n-1;i++)
	{
		int x,y;
		scanf("%d %d",&x,&y);
		vec[x].push_back(y);
		vec[y].push_back(x);
		deg[x]++,deg[y]++;
	}
	int mx=0;
	for(int i=0;i<n;i++) mx=max(mx,deg[i]);
	if(mx<=2)
	{
		puts("1");
		return 0;
	}
	queue <int> que;
	for(int i=0;i<n;i++)
	{
		if(deg[i]==1)
		{
			que.push(i);
		}
	}
	while(!que.empty())
	{
		int v=que.front();que.pop();
		int to=0;
		for(int i=0;i<vec[v].size();i++)
		{
			to=vec[v][i];
			if(deg[to]!=1) break;
		}
		if(deg[to]==2)
		{
			deg[to]=1;
			que.push(to);
		}
	}
	int ret=0;
	for(int i=0;i<n;i++)
	{
		if(deg[i]==1) continue;
		int nm=0;
		for(int j=0;j<vec[i].size();j++)
		{
			int to=vec[i][j];
			if(deg[to]==1) nm++;
		}
		ret+=max(0,nm-1);
	}
	printf("%d\n",ret);
	return 0;
}


Measured memory_bytes: 7040
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int D[] = new int[K];
    for(int i=0;i<K;i++){
      D[i]=sc.nextInt();
    }
    for(int i=N;i<=100000;i++){
      if(isLike(i,D)){
        System.out.println(i);
        return;
      }
    }
  }
  
  public static boolean isLike(int n,int[] D){
     String v = String.valueOf(n);
    
    for(int i=0;i<v.length();i++){
      for(int j=0;j<D.length;j++){
        if(Integer.parseInt(v.substring(i,i+1))==D[j]){
          return false;
        }
      }
    }
    
    return true;
    
  }
  

  
}

Measured memory_bytes: 36916
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
void ABC50(void);
void ABC51(void);
void ABC52(void);
void ABC53(void);
void ABC54(void);
void ABC55(void);
void ABC56(void);
void ABC57(void);
void ABC58(void);
void ABC59(void);

int main(void){
    ABC56();
}

void ABC56(){
    int w,a,b;
    cin>>w>>a>>b;
    if(b>=a&&b<=a+w)cout<<0<<endl;
    else cout<<abs(a-b)-w<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
 int n;
 int result = 0;
 cin >> n;
 vector<int> a(n), b(n), c(n);
 
 for(int i = 0; i < n; i++){
   cin >> a.at(i);
 }
 for(int i = 0; i < n; i++){
   cin >> b.at(i); 
 }
 for(int i = 0; i < n; i++){
   cin >> c.at(i);
 }
 
 for(int i = 0; i < n; i++){
   result += b[a[i]-1];
 
   if(i != n - 1){
     if(a[i+1] == (a[i] + 1) ){
       result += c[a[i]-1]; 
     }
   }
 }
  
 cout << result << endl;
}

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

using namespace std;
#define ll long long int

ll arr[3001];
ll dp[3001][3001];

ll findMax(ll s,ll e){
    if(s==e){
        return arr[s];
    }
    if(s>e){
        return 0;
    }
    if(dp[s][e]!=-1){
        return dp[s][e];
    }
    
    
    ll ans1 = arr[s] + min(findMax(s+1,e-1),findMax(s+2,e));
    ll ans2 = arr[e] + min(findMax(s+1,e-1),findMax(s,e-2));
    dp[s][e] = max(ans1,ans2);
    return dp[s][e];
}

int main()
{
    memset(dp,-1,sizeof(dp));
    
    ll num;
    cin>>num;
    for(ll i=0;i<num;i++){
        cin>>arr[i];
    }
    
    ll ans1 = findMax(0,num-1);
    
    ll total = 0;
    for(ll i=0;i<num;i++){
        total += arr[i];
    }
    ll ans2 = total-ans1;
    cout<<ans1 - ans2;
    return 0;
}


Measured memory_bytes: 74156
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define ll              long long
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define mod             998244353
#define Mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define vpii            vector<pair<int,int> >
#define all(x)          x.begin(),x.end()
#define matrixprint(arr,a,b,c,d) for(int i=a;i<=c;i++){for(int j=b;j<=d;j++){cout<<arr[i][j]<<" ";}cout<<"\n";}
#define show(arr,x,y)   for(int i=x;i<=y;i++){cout<<arr[i]<<" ";}cout<<"\n"
#define sz               size()
#define inc(i,x,y)      for(int i=x;i<y;i++)
#define dec(i,x,y)      for(int i=x;i>=y;i--)

const int N = 2e5 + 5;

#define TRACE
#ifdef TRACE
#define deb(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << std::endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define deb(...)
#endif

void fast()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//#endif
}

//////////////////////////////code//////////////////////////////

int32_t main()
{
  fast();

  string a,b;
  cin>>a>>b;

  if(a == b.substr(0,b.size()-1))
    cout<<"Yes";
  else
    cout<<"No";

}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VL = vector<LL>;
using PII = pair<int, int>;
using PLL = pair<LL, LL>;

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second
#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, b) memset(a, b, sizeof(a))

void dout() { cerr << endl; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    VI a(n);
    VI b(n);
    FOR(i, 0, n)
        cin >> a[i] >> b[i];
    bool ok = false;
    FOR(i, 2, n)
        ok |= (a[i] == b[i]) && (a[i - 1] == b[i - 1]) && (a[i - 2] == b[i - 2]);
    if (ok)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#define INF 1.0e9
using namespace std;
typedef long long ll;

ll N;

vector<ll> divisor_modified(ll n) {
    vector<ll> ret;
    for (ll i = 1; i*i < n; i++) {
        if (n % i == 0) {
            ret.push_back(n/i);
        }
    }
    return ret;
}

int main() {
    cin >> N;
    vector<ll> vec = divisor_modified(N);
    ll ans = 0;
    for (int i = 0; i < (int)vec.size(); i++){
        if (N / vec[i] != vec[i] - 1){
            ans += vec[i] - 1;
        }
    }
    cout << ans << endl;
    return 0;
}

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

double stddev(int n){
    double avg=0;
    int a[n];
    for(int i=0; i<n; i++){
        scanf("%d", &a[i]);
        avg+=(double)a[i];
        // printf("%.6lf\n", avg);
        // printf(".\n");
    }
    avg=avg/n;
    // printf("%.6lf\n", avg);
    double vrnc=0;
    for(int i=0; i<n; i++){
        vrnc+=(a[i]-avg)*(a[i]-avg);
    }
    // printf("%.6lf\n", vrnc);
    vrnc=vrnc/n;
    // printf("%.6lf\n", vrnc);
    return sqrt(vrnc);
}

int main(){
    int n;
    scanf("%d", &n);
    while(n!=0){
        printf("%.6lf\n", stddev(n));
        scanf("%d", &n);
    }
    return 0;
}


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

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
#define endl "\n"

int a[1000005];
vector<int> prime;

void Prime_seive() {
	a[0] = a[1] = 1;
	for(int i=2; i*i<=1000000; i++) {
		if(a[i] == 0) {
			for(int j=2*i; j<=1000000; j+=i) {
				a[j] = 1;
			}
		}
	}
	for(int i=2; i<=1000000; i++) {
		if(a[i] == 0)
			prime.push_back(i);
	}
}

void testCase() {
	Prime_seive();
	int n;
	cin >> n;
	vector<int> ans;
	sort(prime.begin(), prime.end());
	int val = n;
	int i=0;
	while (val > 1 && i < prime.size()) {
		while (val%prime[i] == 0) {
			ans.push_back(prime[i]);
			val = val/prime[i];
		}
		i++;
	}
	if (val > 1)
		ans.push_back(val);
	cout << n << ":";
	for (int i=0; i<ans.size(); i++)
		cout << " " << ans[i];
	cout << endl;
}

int main() {
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	testCase();
	return 0;
}


Measured memory_bytes: 7332
#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>;

ll ka(int si){
    ll ans3=1;
    rep(i,si){
        ans3*=2;
    }
    return ans3;
}

int main(){
    ll a,b;
    cin >> a >> b;
    if(a!=0){
    --a;
    }
    vector <ll> b3(50,0),b2(50,0);
    vector <ll> a3(50,0),a2(50,0);

    rep(i,50){
        a3[i]=(a>>i)&1;
        b3[i]=(b>>i)&1;
        //cout << b3[i] << endl;
    }
    ll k,k2;
    int y;

    rep(i,50){
        k=ll(ka(i));
        rep(j,i+1){
            if(b3[i-j]==0){
                k-=ll(ka(i-j));
            }
        }
        if(k<0){
            k=0;
        }
        b>>=1;
        
        b2[i]=b*ll(ka(i));
        b2[i]+=k;
        if(b==0){
            y=i;
            break;
        }
    }
    rep(i,y+1){
        k=ll(ka(i));
        rep(j,i+1){
            if(a3[i-j]==0){
                k-=ll(ka(i-j));
            }
        }
        if(k<0){
            k=0;
        }
        a>>=1;
        
        a2[i]=a*ll(ka(i));
        a2[i]+=k;
        if(a==0){
            
            break;
        }
        
    }

    
    

    vector <int> ans(50,0);
    rep(i,50){
        //cout << a2[i]  << " " << b2[i] << endl;
        b2[i]-=a2[i];
        if(b2[i]%2==1){
        ans[i]=1;
        }
    }

    ll ans2;
    ans2=0;
    rep(i,y+1){
        if(ans[i]==1){
        ans2+=ll(ka(i));
        }
    }

    cout << ans2 << endl;


    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class Program
	{
		static void Main(string[] args)
		{
			int a = Int32.Parse(Console.ReadLine());
			string s = Console.ReadLine();

			if(a >= 3200)
				Console.WriteLine(s);
			else
				Console.WriteLine("red");
		}
	}
}


Measured memory_bytes: 11092
#include <iostream>
using namespace std;
int main() {
    int n;
    cin >> n;
    long long a;
    long long b = 1000000;
    long long c = -1000000;
    long long d = 0;
    for (int i = 0; i < n; i++){
        cin >> a;
        if (a < b) b = a;
        if (a > c) c = a;
        d += a;
    }
    cout << b << ' ' << c << ' ' << d << endl;
    return 0;
}



Measured memory_bytes: 3096
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <cmath>
#include <limits>
#include <tuple>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;

int main()
{
	int N, M;
	cin >> N >> M;
	vector<set<int>> G(N, set<int>());
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		G[a].insert(b);
		G[b].insert(a);
	}
	bool ans = false;
	for (auto i : G[0]) {
		if (G[i].find(N-1) != G[i].end()) {
			ans = true;
			break;
		}
	}
	cout << (ans ? "POSSIBLE" : "IMPOSSIBLE") << endl;
	return 0;
}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  string S;
  cin >> S;

  string ans;
  ans = "";
  for(int i = 0; i + 8 < S.length(); i++){
    ans += S[i];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 764
a=input()
a=a.replace("BC","X")
a=a[::-1]
X_c=0
ans=0
for i in range(len(a)):
   if a[i]=="X":
      X_c+=1
   elif a[i]=="A":
      ans+=X_c
   else:
      X_c=0
print(ans)

Measured memory_bytes: 9200
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;

namespace atcorder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] strArray = Console.ReadLine().Split(' ').ToArray();
            string S = strArray[0];
            string T = strArray[1];
            int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            int A = intArray[0];
            int B = intArray[1];
            string U = Console.ReadLine();
            if(S == U)
            {
                A--;
            }
            else
            {
                B--;
            }
            Console.WriteLine(A + " " + B);
        }
    }
}

//文字配列の取得
//string[] strArray = Console.ReadLine().Split(' ').ToArray();
//string S = strArray[0];
//string T = strArray[1];

//文字列の取得
//string s = Console.ReadLine();

//数字配列の取得
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];

//数字の取得
//int N = int.Parse(Console.ReadLine());

//リスト型(int)の取得
//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());

//出力
//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.WriteLine(cnt);




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

int main() {
    int a, b, h, m; cin >> a >> b >> h >> m;
    double rad, result;
    rad = abs(30.0*h+0.5*m-6*m)*M_PI/180;
    result = sqrt(a*a + b*b - 2*a*b*cos(rad));
    cout << fixed << setprecision(10) << result << endl;
    return 0;
}

Measured memory_bytes: 4228
#include <bits/stdc++.h>
using namespace std;
string s , t; int dp[3000][3000] , path[3000];
int f( int si = 0 , int ti = 0 )
{
    if( si == s.size() || ti == t.size() ) return 0;
    int &d = dp[si][ti];
    if( d != -1 ) return d;
    if( s[si] == t[ti] )
        return d = f(si+1,ti+1)+1;
    return d = max( f(si+1,ti) , f(si,ti+1) );
}
void print()
{
    int i = 0 , j = 0;
    while ( i < s.size() && j < t.size() )
    {
        if( s[i] == t[j] )
        {
            cout << s[i];
            ++i,++j;
        }
        else
            if( dp[i+1][j] > dp[i][j+1] )
                ++i;
            else
                ++j;
    }
}
int main()
{
    memset(dp,-1,sizeof dp);
    cin >> s >> t;
    f();
    print();
    return 0;
}

Measured memory_bytes: 35712
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
  String c1 = sc.next();
  String c2 = sc.next();
  if(c1.charAt(0) == c2.charAt(2) && c1.charAt(1) == c2.charAt(1) && c1.charAt(2) == c2.charAt(0))
    System.out.println("YES");
  else System.out.println("NO");
}
}

Measured memory_bytes: 21972
<?php

$N=trim(fgets(STDIN));
for($i=0;$i<$N;$i++){
    $a=  str_split( trim(fgets(STDIN)));
    sort($a);
    $b=(int)implode($a);
    rsort($a);
    $c=(int)implode($a);
    echo $c-$b.PHP_EOL;
}

Measured memory_bytes: 6560
#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define PI acos(-1)
typedef long long int ll;
typedef long double ld;

int main(void) {
  int   scan;

  ll    answer;
  ll    k; 
  answer = 1;
  scan = scanf("%lld", &k);

  ll    mod;
  mod = k % 10;
  if (mod == 0 || mod == 2 || mod == 4 || mod == 5 || mod == 6 || mod == 8) {
    printf("-1");
    return (0);
  }

  if (k % 7 == 0) {
    k = k / 7;
  } 
  
  ll  p;
  ll  l;
  l = 9 * k;
  p = 1;
  while (1) {
    p = 10 * p % l;
    if (p == 1) {
      break ;
    } else {
      answer++;
    }
  }

  printf("%lld", answer);

  return (0);
}



Measured memory_bytes: 1704
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//絶対値
long long int change_plus(long long int a) {
	if (a < 0) { return -a; }
	if (a >= 0) { return a; }
}
//大小比較(大)
long long int big(long long int a, long long int b) {
	if (a >= b) {
		return a;
	}
	else {
		return b;
	}
}

//大小比較(小)
long long int small(long long int a, long long int b) {
	if (a >= b) {
		return b;
	}
	else {
		return a;
	}
}

main() {
	long long int n, m, k = 0;
	char str[5];
	scanf("%lld%lld%lld",&n,&m,&k);
	 printf("%lld",n+m+k-big(big(n,m),k));
	
	

}

Measured memory_bytes: 128
import sys
from collections import deque
input = sys.stdin.readline
H, W = map(int, input().split())
G = [[0]*(H*W) for _ in range(H*W)]
S = [list(input()) for i in range(H)]
dot = 0
for i in range(H*W) :
    h = i//W
    w = i%W
    if S[h][w] != "#" :
        dot += 1
        if h > 1 and S[h-1][w] == "." :
            j = (h-1)*W + w
            G[i][j] = G[j][i] = 1
        if h < H-1 and S[h+1][w] == "." :
            j = (h+1)*W + w
            G[i][j] = G[j][i] = 1
        if w > 1 and S[h][w-1] == "." :
            j = h*W + w-1
            G[i][j] = G[j][i] = 1
        if w < W-1 and S[h][w+1] == "." :
            j = h*W + w+1
            G[i][j] = G[j][i] = 1

def bfs(s) :
    q = deque([s])
    dist[s] = 0
    while q :
        now = q.popleft()
        for i in range(H*W) :
            if G[now][i] == 1 :
                if dist[i] != -1 :
                    continue
                else :
                    dist[i] = dist[now] + 1
                    q.append(i)
    return dist[H*W-1]

dist = [-1 for _ in range(H*W)]
ans = bfs(0)
if ans == -1 :
    print(-1)
else :
    print(dot - ans - 1)


Measured memory_bytes: 91868
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
int main() {
	string s;
	cin >> s;
	puts(s == "ABC" ? "ARC" : "ABC");
	return 0;
}

Measured memory_bytes: 3592
"""
author : halo2halo
date : 8, Jan, 2020
problem : ABC149
"""

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

S, T = read().decode('utf-8').split()

answer = T + S
print(answer)


Measured memory_bytes: 2940
#include<stdio.h>

long double ans[302][302][302], n;

long double solve(int one, int two, int three)
{
	if( ans[one][two][three] != -1 )
		return ans[one][two][three];
	long double day1 = 0, day2 = 0, day3 = 0, count = 0, day = n/(one+two+three);;
	if( !one && !two && !three )
		return 0;
//	printf("%lf %lf %lf\n", n, one, n/one);
	if( one )
	{
		count++;
		day1 = day + solve(one-1, two, three);
	}
	if( two )
	{
		count++;
		day2 = day + solve(one+1, two-1, three);
	}
	if( three )
	{
		count++;
		day3 = day + solve(one, two+1, three-1);
	}
//	printf("one: %d two: %d three: %d\n  1: %Lf   2: %Lf     3: %Lf\n%Lf\n", one, two, three, day1, day2, day3, n/(one+two+three));
	
//	printf("ans: %Lf\n\n",  ans[one][two][three] = ( day1 + day2 + day3 + count*n/(one+two+three) ) / count);
//	printf("%Lf\n\n", ans[one][two][three] = count*n/(one+two+three) + day1 + day2 + day3);
	ans[one][two][three] = ( one*day1 + two*day2 + three*day3 ) / ( one + two + three );
	return ans[one][two][three];
}

int main()
{
	for(int i=0; i<302; i++)
		for(int j=0; j<302; j++)
			for(int k=0; k<302; k++)
				ans[i][j][k] = -1;
	int one = 0, two = 0, three = 0, a;
	scanf("%Lf", &n);
//	printf("n: %Lf\n", n);
	for(double i=0; i<n-0.5; i += 1)
	{
		scanf("%d", &a);
		if( 0.5 < a && a < 1.5 )
			one++;
		else if( 1.5 < a && a < 2.5 )
			two++;
		else
			three++;
	}
	printf("%.12Lf", solve(one,two,three));
	return 0;
}


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

#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

// vector<vector<int>> data(3, vector<int>(4));

struct Edge {
	ll to, id;
	Edge(ll to, ll id): to(to), id(id) {}
};

vector<Edge> G[55];

vector<ll> es;

bool dfs(ll v, ll tv, ll p = -1) {
	if (p == -1) es = vector<ll>();
	if (v == tv) return true;
	for (Edge e : G[v]) {
		if (e.to == p) continue;
		if (dfs(e.to, tv, v)) {
			es.emplace_back(e.id);
			return true;
		}
	}
	return false;
}

int main(){	
	long long M;
	long long N;
	scanf("%lld",&N);

	for(int i = 0 ; i <= (N-1)-1 ; i++){
		ll a, b;
		scanf("%lld",&a);
		scanf("%lld",&b);
		a--; b--;

		G[a].emplace_back(b, i);
		G[b].emplace_back(a, i);
	}

	scanf("%lld",&M);
	vector<ll> eset(M);
	rep(i, M) {
		ll u, v;
		cin >> u >> v;
		u--; v--;
		dfs(u, v);
		for (ll e : es) {
			eset[i] |= 1LL<<e;
		}
	}

	ll res = 0;

	rep(i, 1<<M) {
		ll mask = 0;
		rep(j, M) {
			if (i>>j&1) mask |= eset[j];
		}
		ll white = __builtin_popcountll(mask);
		ll now = 1LL<<(N-1-white);
		if (__builtin_popcountll(i)%2 == 0) res += now; else res -= now;
 	}
	cout << res << endl;
	return 0;
}



Measured memory_bytes: 256
from heapq import heappop,heappush

h,w = map(int, input().split())
s = [[x for x in input()] for _ in range(h)]

delta = [(-1,0),(1,0),(0,1),(0,-1)]

edges = [[-1 for _ in range(h*w)] for __ in range(h*w)]

for i in range(h):
    for j in range(w):
        if s[i][j] == '.':
            for x in delta:
                to_i = i+x[0]
                to_j = j+x[1]
                if 0 <= to_i < h and 0 <= to_j < w:
                    if s[to_i][to_j] == '.':
                        edges[i*w+j][to_i*w+to_j] = 1
                        edges[to_i*w+to_j][i*w+j] = 1

n = h*w

def dijkstra(s,n,edges):
    #edges[i][j] : the cost of i→j
    #import 'heap'
    d = [10**13] * n
    d[s] = 0
    q = [(0,s)]
    while q:
        dist_u, u = heappop(q)
        if d[u] < dist_u:
            continue
        for v, c in enumerate(edges[u]):
            if c >= 0:
                if d[v] > dist_u + c:
                    d[v] = dist_u + c
                    heappush(q, (d[v], v))
    return d

ans = 0

for i in range(h):
    for j in range(w):
        d = dijkstra(i*w+j,n,edges)
        for l in d:
            if l < 10**6:
                ans = max(ans,l)

print(ans)


Measured memory_bytes: 59356
#include <stdio.h>
int main(void){
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if(x-r>=0 && x+r<=W && y-r>=0 && y+r<=H)
        puts("Yes");
    else
	puts("No");
    return 0;
}

Measured memory_bytes: 584
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import *
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    m, d = LI()
    ans = 0
    for i in range(1, m + 1):
        for j in range(10, d + 1):
            if int(str(j)[0]) < 2 or int(str(j)[1]) < 2:
                continue
            if i == int(str(j)[0]) * int(str(j)[1]):
                ans += 1
    print(ans)
    return

#B
def B():
    n, l = LI()
    a = LI()
    d0 = defaultdict(int)
    d1 = defaultdict(int)
    for i in a:
        d0[i] += 1
    for i in range(n):
        b = 0
        for k in range(i+1, n):
            if a[i] > a[k]:
                b += 1
        d1[i] = b
    ans = 0
    d2 = list(d0.items())
    d2.sort()
    d3 = defaultdict(int)
    d = 0
    for key, value in d2:
        d3[key] = d
        d += value
    for i in range(n):
        ans += d3[a[i]] * l * (l-1) // 2 + d1[i] * l
        ans %= mod
    print(ans % mod)
    return

#C
def C():
    n = II()
    s = S()
    if s[0] == "W":
        print(0)
        return
    lis = [0] * (2 * n)
    l = [0] * (2 * n)
    l[0] = 1
    for i in range(1, 2 * n):
        lis[i] = (lis[i-1] ^ (s[i] == s[i-1]))
        l[i] += l[i - 1] + (lis[i] == 0)
    ans = 1
    if l[-1] != n or s[0] == "W":
        print(0)
        return
    k = 1
    for i in range(2 * n):
        if lis[i]:
            ans *= l[i] - (k - 1)
            ans %= mod
            k += 1
    print(ans * math.factorial(n) % mod)
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    C()


Measured memory_bytes: 66416
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int ll
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

signed main() {
    int n, m;
    cin >> n >> m;
    int time = 100 * (n - m) + 1900 * m;
    double k = pow(2, -m);
    double ans = 1 / k;
    cout << time * ans << "\n";
}

Measured memory_bytes: 4152
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

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

    int res=0;
    for (int i=1;i<=N;i++){
	res+=abs(a[i]-a[i-1]);
    }
    res+=abs(a[N]);

    for (int i=1;i<=N;i++){
	int sub=abs(a[i]-a[i-1])+abs(a[i+1]-a[i])-abs(a[i+1]-a[i-1]);
	cout << res-sub << endl;
    }

    return 0;
}

Measured memory_bytes: 1664
n = int(input())
def isPrime(x):
    if x == 2:
        return True
    if x < 2 or x%2 == 0:
        return False
    i = 3
    while i < int(x**0.5)+1:
        if x % i == 0:
            return False
        i += 2
    return True

ans = 0
for _ in range(n):
    num = int(input())
    ans += isPrime(num)
print(ans)


Measured memory_bytes: 5672
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()

city = [LIST() for _ in range(N)]

per = [i for i in range(N)]

a = list(permutations(per))

sums = 0
for i in a:
	path = 0
	for j in range(N - 1):
		path += sqrt((city[i[j]][0] - city[i[j+1]][0])**2 + (city[i[j]][1] - city[i[j+1]][1])**2 )
	sums += path

print(sums/len(list(a)))

Measured memory_bytes: 69356
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<set>
#define INF 100000.0
using namespace std;
struct S{
	int town;
	int from;
	int v;
	double cost;
	void set(int a,int b,int c,double d){
		town=a;from=b;v=c;cost=d;
	}
	inline bool operator<(const S &a)const{
		return this->cost<a.cost;
	}
};
double dp[30][30][31];
int d[30][30];
int c[30][30];
multiset<S> Set;
multiset<S>::iterator it; 
int main(){	
	int n,m;
	int s,g;
	int x,y,t,u;
	double min;
	bool start;
	S a,b;
	while(cin>>n>>m,n||m){
		memset(d,-1,sizeof(d));
		memset(c,-1,sizeof(c));
		for(int i=0;i<n;i++)for(int j=0;j<30;j++)for(int k=1;k<31;k++)dp[i][j][k]=INF;
		cin>>s>>g;
		s--;g--;
		for(int i=0;i<m;i++){
			cin>>x>>y;
			x--;y--;
			cin>>t;
			d[y][x]=d[x][y]=t;
			cin>>t;
			c[y][x]=c[x][y]=t;
		}
		a.set(s,-1,1,0.0);
		Set.insert(a);
		start=true;
		while(!Set.empty()){
			it=Set.begin();
			a=*it;
			Set.erase(it);
			if(dp[a.town][a.from][a.v] < a.cost)continue;
			for(int i=0;i<n;i++){
				t=d[a.town][i];
				if(a.from==i || t==-1)continue;
				for(int j=-1;j<=1;j++){
					u=c[a.town][i];
					if(a.v+j<1 || a.v+j>u)continue;
					if(start && j!=0)continue;
					b.set(i,a.town,a.v+j,a.cost+(double)t/(a.v+j));
					if(b.cost < dp[b.town][b.from][b.v]){
						dp[b.town][b.from][b.v]= b.cost;
						Set.insert(b);
					}
				}
			}
			start=false;
		}
		min=INF;
		for(int i=0;i<n;i++)if(dp[g][i][1]<min)min=dp[g][i][1];
		if(min!=INF)printf("%.5f\n",min);//cout<<min<<endl;
		else cout<<"unreachable\n";
	}
	return 0;
}

Measured memory_bytes: 2092
using System.ComponentModel.Design;
using System.Collections.Generic;
using System;
using System.Linq;
using static System.Console;

class P
{
    static void Main()
    {
        var d = new Dictionary<int, int>();
        var n = int.Parse(ReadLine());
        var l = ReadLine().Split().Select(int.Parse).ToList();
        foreach (var e in l)
        {
            if (d.ContainsKey(e)) d[e]++;
            else d[e] = 1;
        }
        var keys = d.Keys.OrderBy(x => x).ToList();
        var ans = 0;
        if (l.Count >= 3)
        {
            for (int i = 0; i < keys.Count - 2; i++)
            {
                for (int j = i + 1; j < keys.Count - 1; j++)
                {
                    for (int k = j + 1; k < keys.Count; k++)
                    {
                        int first = keys[i], second = keys[j], third = keys[k];
                        var max = new int[] {first, second, third}.Max();
                        var sum = first + second + third;
                        if (first == second || second == third || third == first) break;
                        if (max >= sum - max) break;
                        ans += d[first] * d[second] * d[third];
                    }
                }
            }
        }
        WriteLine(ans);
    }
}

Measured memory_bytes: 39292
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int num1[12];
int num2[12];
int main()
{
    int n;
    cin>>n;
    while(n--)
    {
        memset(num1,0,sizeof(num1));
        memset(num2,0,sizeof(num2));
        int num;
        int ans1=1,ans2=0;
        cin>>num;
        num1[0]=num;
        for(int i=1;i<=9;i++)
        {
            cin>>num;
            if(num>num1[ans1-1])
                num1[ans1++]=num;
            else
            {
                num2[ans2++]=num;
            }
        }
        /*for(int i=0;i<ans1;i++)
            cout<<num1[i]<<" ";
        cout<<endl;
        for(int i=0;i<ans2;i++)
            cout<<num2[i]<<" ";
        cout<<endl;*/
        int flag=0;
        for(int i=1;i<ans2;i++)
        {
            if(num2[i]<num2[i-1])
            {
                flag=1;
                break;
            }
        }
        if(flag)
            cout<<"NO"<<endl;
        else
            cout<<"YES"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3056
#define _GLIBCXX_DEBUG
#include"bits/stdc++.h"

using namespace std;

//loops
#define REP(i,n) for(int i=0;i<(ll)(n);i++)
#define REPD(i,n) for(int i=(ll)(n)-1;i>=0;i--)
#define OneToN(i,n) for(int i=1;i<(ll)(n+1);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)

//arrays
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define add push_back

//pair
#define fir first
#define sec second

//types
#define ll long long
#define vec vector
//UNCOMMENT WHEN NEEDED
//#define int ll

//input
template <class T> T get(){ T s; cin >> s; return(s);}
#define gi get<int>()
#define gs get<string>()

template <class T> vector<T> getv(int n) { vec<T> v(n); REP(i, n) cin >> v[i]; return v; }
#define gim(n) getv<int>(n)
#define gsm(n) getv<string>(n)

//output
void print(int a){ cout << a << endl; }
void print(string a){ cout << a << endl; }
void print(double a, int dig){ cout << std::setprecision(dig) << a << endl; }

template <class T = int>
void print(vec<T> v){ for (T item: v) { cout << item << " "; } cout << endl; }

void YesNo1(bool i = true){ return print(i?"Yes":"No"); }
void YESNO2(bool i = true){ return print(i?"Yes":"N1010o"); }

//debug output
#define var_name(var) #var
template <class T> void debug(T &var, int nest = 0, string before = "") { cout << string("          ", nest) << before; print(var); }

//name replacement
#define y0 y0__
#define y1 y1__
#define j0 j0__
#define j1 j1__
#define next next__
#define prev prev__

//bool lambdas
#define lamb(exp) [](auto i){return exp;}
#define isEven [](int i){return i % 2 == 0;}
#define isOdd [](int i){return i % 2 != 0;}

//constants
const ll INF = 1e18;
const int MOD = 10000007;

void Main() {
    //code here
    int n = gi;
    vec<int> nums = gim(n);
    sort(ALL(nums));
    nums.erase(unique(ALL(nums)), nums.end());
    print(nums.size());
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Main();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
/*
	Karya anak bangsa yang paling agung
	Author : Yohandi or... bukan..
*/

#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define endl "\n"

#define all(a) a.begin(),a.end()
#define lb(a,x) (lower_bound(all(a),x)-a.begin())
#define ub(a,x) (upper_bound(all(a),x)-a.begin())

#define rep(a,x,y) for(int a=(int)x;a<=(int)y;++a)
#define repd(a,x,y,d) for(int a=(int)x;a<=(int)y;a+=d)
#define res(a,x,y) for(int a=(int)x;a>=(int)y;--a)
#define resd(a,x,y,d) for(int a=(int)x;a>=(int)y;a-=d)

// Ordered Set, Ordered Multiset
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define o_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
#define o_multiset tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
using namespace __gnu_pbds;
// .order_of_key(x) -> Number of elements less than x
// * .find_by_order(k) -> Kth smallest element (0-based)
// .erase(x) -> Remove all elements equal to x

#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
using lint=long long;

mt19937 rng(time(NULL));

lint Power(lint A,lint B,lint C){
	if(!B) return 1LL;
	lint tmp=Power(A,B>>1,C);
	return tmp*tmp%C*(B&1?A:1)%C;
}

int T;

int main(){
//	ios_base::sync_with_stdio(0);
//	cin.tie(0); cout.tie(0);
	T=1;
//	cin>>T;
	rep(t,1,T){
        int X,Y;
        cin>>X>>Y;
        if(Y%2!=0){
            cout<<"No\n";
        } else {
            if(2*X<=Y&&Y<=4*X) cout<<"Yes\n"; else cout<<"No\n";
        }
	}
	return 0;
}




Measured memory_bytes: 3676
#include <iostream>
#include <string>
using namespace std;
int H, W;
string s[10];
int main() {
  cin >> H >> W;
  int cnt = 0;
  for(int i = 0; i < H; ++i){
    cin >> s[i];
  }
  for(int i = 0; i < H; ++i){
    for(int j = 0; j < W; ++j){
      if(s[i][j] == '#') ++cnt;
    } 
  }
  
  cout << (cnt == H + W - 1 ? "P" : "Imp") << "ossible" << endl;
  return 0;
}


Measured memory_bytes: 256
open System
open System.IO

let rec readlines () = seq {
    let line = Console.ReadLine()
    if not (isNull line) then
        yield line
        yield! readlines ()
}

let readFields() = readlines() 
                    |> Seq.filter (String.IsNullOrEmpty >> not) 
                    |> Seq.collect (fun(x) -> x.Split ' ' ) 
                    |> Seq.filter (String.IsNullOrEmpty >> not)

[<EntryPoint>]
let main argv =
    readFields() 
            |> Seq.map ((fun(x) -> Int32.Parse(x)) >> (fun(y) -> y % 2 = 0 && y % 3 <> 0 && y % 5 <> 0))
            |> Seq.exists id
            |> fun denied -> if denied then "DENIED" else "APPROVED" 
            |> printfn "%s"
    
    0

Measured memory_bytes: 14300
d,g = gets.split.map(&:to_i)

pa,ca = d.times.map{gets.split.map(&:to_i)}.transpose
min = 10**9

(1<<d).times{|i|
  s = ((1<<d)+i).to_s(2)[1..-1]
  ans = 0
  score = 0
  d.times{|j|
    if s[j]==?1
      score += (j+1)*100*pa[j] + ca[j]
      ans += pa[j]
    end
  }
  
  yet = s.rindex(?0)
  
  if score<g
    m = ((g-score)/(yet+1)+99)/100
    if m < pa[yet]
      ans += m
      score += (yet+1)*100
    else
      next
    end
  end
  
  min = ans if ans < min
}

p min

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define ld long double
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
template <typename T> using ord_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int n0 = 2e5 + 123, inf = 1e9;
int n, x[n0], y[n0], u[n0], res = inf;
map <int, array <int, 4>> smp, dmp, lmp, lmp2;

void chmin(int & a, int b) {
  if (!a) {
    a = b;
    return;
  }
  if (x[a] + y[a] > x[b] + y[b]) {
    a = b;
  }
}

void chmax(int & a, int b) {
  if (!a) {
    a = b;
    return;
  }
  if (x[a] + y[a] < x[b] + y[b]) {
    a = b;
  }
}

void upd(int i, int j) {
  if (!i || !j) return;
  if (x[j] < x[i]) swap(i, j);
  if (u[i] != 1 && u[j] != 3) return;
  if (y[j] < y[i]) swap(i, j);
  if (u[i] != 0 && u[j] != 2) return;
  res = min(res, y[j] - y[i]);
}

void lupd(int i, int j) {
  if (!i || !j) return;
  if (u[j] < u[i]) swap(i, j);
  int d = x[j] + y[j] - x[i] - y[i];
  if (d > 0) res = min(res, d / 2);
}

int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  #ifdef LOCAL
  freopen("input.txt", "r", stdin);
  #endif

  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x[i] >> y[i];
    x[i] *= 10, y[i] *= 10;
    char ch;
    cin >> ch;
    if (ch == 'R') u[i] = 1;
    if (ch == 'D') u[i] = 2;
    if (ch == 'L') u[i] = 3;
    if (u[i] & 1) {
      lupd(i, lmp[y[i]][(u[i] + 2) % 4]);
      lupd(i, lmp2[y[i]][(u[i] + 2) % 4]);
      chmin(lmp[y[i]][u[i]], i);
      chmax(lmp2[y[i]][u[i]], i);
    }	else {
      lupd(i, lmp[x[i]][(u[i] + 2) % 4]);
      lupd(i, lmp2[x[i]][(u[i] + 2) % 4]);
      chmin(lmp[x[i]][u[i]], i);
      chmax(lmp2[x[i]][u[i]], i);
    }
    upd(i, smp[x[i] + y[i]][(u[i] + 1) % 4]);
    upd(i, smp[x[i] + y[i]][(u[i] + 3) % 4]);
    upd(i, dmp[x[i] - y[i]][(u[i] + 1) % 4]);
    upd(i, dmp[x[i] - y[i]][(u[i] + 3) % 4]);

    smp[x[i] + y[i]][u[i]] = i;
    dmp[x[i] - y[i]][u[i]] = i;
  }
  if (res == inf) cout << "SAFE";
  else cout << res;
}

Measured memory_bytes: 55380
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define maxn 100005
#define Mod 1000000007
typedef pair<int,int> pii;
typedef map<int,int> mii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<long long> vll;
typedef vector<bool> vb;
typedef set<int> si; 
#define fori(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,b,a) for(int i = (b); i >= (a); --i)
#define all(a) (a).begin(), (a).end()
#define __builtin_popcountll bitCountLL
#define __builtin_popcount bitCount
//__builtin_ctz 末尾0的个数, __builtin_clz 前导0的个数
//__builtin_ffs 最后一个1的位置
const int INF = 2e9;
const ll ML = 4e18;

void solve() {
    int n;
    cin >> n;
    if(n % 1000 == 0) cout << 0 << endl;
    else cout << 1000 - n % 1000 << endl;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
	//cout.precision(30); cout << fixed;
	//freopen("D:\\data_in.txt", "r", stdin);
    solve();
    
    /*clock_t start,finish;
    start = clock();
   
    finish = clock();
    cout << "\n" << (double)(finish - start) / (double)(CLOCKS_PER_SEC) * 1000 << "ms" << endl;
    */
    return 0;
}

/***************************************************************
 question:
 idea:
 tag:
 record:
 ***************************************************************/


Measured memory_bytes: 3652