akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <stdlib.h>

using namespace std;

class stack
{
	public:
	int s[100];
	int t;

public:
	void initialize();
	void push(int x);
	int pop();
};

void stack::initialize()
{
	t = 0;
}

void stack::push(int x)
{
	s[t] = x;
	t++;
}

int stack::pop()
{
	t--;
	return s[t];
}



int main()
{
	stack st;
	string ch;
	int a,b;

	st.initialize();

	while(cin >> ch)
	{
		if (ch == "+")
		{
			a = st.pop();
			
			b = st.pop();
			
			st.push(a+b);

		}
		else if (ch == "-")
		{
			a = st.pop();
			
			b = st.pop();
			
			st.push(b-a);
		}
		else if (ch == "*")
		{
			a = st.pop();
			
			b = st.pop();
			
			st.push(a*b);
		}
		else
		{
			st.push(atoi(ch.c_str()));
		}
	}

	cout << st.s[0] << "\n";

	return 0;
}

Measured memory_bytes: 3164
def partition(A, p, r):
    x = A[r][1]
    i = p-1
    for j in range(p, r):
        if A[j][1] <= x:
            i += 1
            memo = A[i]
            A[i] = A[j]
            A[j] = memo
    memo = A[i+1]
    A[i+1] = A[r]
    A[r] = memo
    return i+1

def quicksort(A, p, r):
    if p < r:
        q = partition(A, p, r)
        quicksort(A, p, q-1)
        quicksort(A, q+1, r)


n = int(input())
card = []
for i in range(n):
    word, num = input().split()
    card.append([word, int(num), int(i)])

def checkstable(card):
    for i in range(len(card) - 1):
        if card[i][1] == card[i + 1][1] and card[i][2] > card[i+1][2]:
            return "Not stable"
    return "Stable"

quicksort(card, 0, n-1)

print(checkstable(card))
for c in card:
    print(c[0], c[1])


Measured memory_bytes: 22000
#include<bits/stdc++.h>
const int maxn = 100035;
 
int a[maxn],n,l,t,x,cnt;
 
int main()
{
    scanf("%d%d%d",&n,&l,&t);
    for (int i=1; i<=n; i++)
    {
        scanf("%d%d",&a[i],&x);
        a[i] += x==1?t:-t;
        cnt += a[i]/l;
        if (a[i]%l<0) cnt--;
        ((a[i]%=l)+=l)%=l;
    }
    std::sort(a+1, a+n+1);
    ((cnt%=n)+=n)%=n;
    // for (int i=1; i<=n; i++) printf("%d\n",a[i]);
    for (int i=cnt+1; i<=n; i++) printf("%d\n",a[i]);
    for (int i=1; i<=cnt; i++) printf("%d\n",a[i]);
    return 0;
}

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

#define count_ones __builtin_popcountl
#define all(a) a.begin(), a.end()
#define gcd(a, b) __gcd(a, b)
#define lca(a, b) a / __gcd(a, b) * b
typedef long long ll;
typedef long long ld;
typedef unsigned long long ull;
using namespace std;

int main() {
    ios::sync_with_stdio(false);

    ll n;
    cin >> n;
    vector<ll> d(n);
    for (ll i = 0; i < n; i++) {
        cin >> d[i];
    }

    ull sum = 0;

    for (ll i = 0; i < n; i++) {
        for (ll j = i + 1; j < n; j++) {
            sum += d[i] * d[j];
        }
    }

    cout << sum;

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeSet;

import javax.swing.*;

import static java.util.Arrays.binarySearch;
import static java.util.Arrays.copyOfRange;

public class Main {

    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;

        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }
}

class Task {

    private static int mod = 1000000007;


    public void solve(int testNumber, InputReader in, PrintWriter out) {
        String[] s = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
        String t = in.next();
        for (int i = 0; i < s.length; i++) {
            if (s[i].equals(t)) {
                out.println(7 - i);
            }
        }

    }


}

class InputReader {

    private final BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String nextLine() {
        try {
            return reader.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(nextLine());
        }
        return tokenizer.nextToken();
    }

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

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

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

}


Measured memory_bytes: 23508
def isCLKWISE(ph) : return not ((ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0)
def ConvexHullScan(P) :
 P = sorted(P)
 phU = []
 phU.append(P[0])
 phU.append(P[1])
 for p in P[2:] :
  phU.append(p)
  if isCLKWISE(phU) : continue
  while(True) :
   del phU[-2]
   try:
    if isCLKWISE(phU) : break
   except IndexError : break
 phL = []
 phL.append(P[-1])
 phL.append(P[-2])
 for p in P[-3::-1] :
  phL.append(p)
  if isCLKWISE(phL) : continue
  while(True) :
   del phL[-2]
   try:
    if isCLKWISE(phL) : break
   except IndexError : break
 ph = phU + phL[1:-1]
 return ph
n = range(int(input()))
P = [[int(x) for x in input().split()] for _ in n]
P = ConvexHullScan(P)
P.reverse()
print(len(P))
idx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(P)])[2]
P = P[idx:] + P[:idx]
for p in P : print(p[0],p[1])

Measured memory_bytes: 33192
#include <iostream>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <cstring>
#include <string.h>
#include <sstream>
#include <iomanip>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <tuple>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using vec = vector<T>;
template<typename T> using prior = priority_queue<T>;

const ll MOD = 1e9+7;
const ll SPMOD = 998244353;
const double PI  = 3.14159265358;
const double EPS = 1e-8;
 
#define INT_MX 2147483647
#define INF ((int)1e9)
#define LLINF ((ll)1e18)
#define F first
#define S second
#define MP(x,y) make_pair(x,y)
#define siz(v) ((int)v.size())
#define rs(n) resize(n)
#define ALL(v) v.begin(),v.end()
#define reset(v) memset((v),0,sizeof(v))
#define Unique(v) v.rs(unique(ALL(v))-v.begin())
#define EB emplace_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define __ <<' '<<
#define kiyohime ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

// template
ll POW();
int gcd(int a, int b);
// end of template

#define N 110

void solve(){
    int a, b, c;
    
    cin >> a >> b >> c;
    
    cout << c __ a __ b << '\n';
    
}

int main(){
    kiyohime
    int T = 1;
    
//    cin >> T;
    while(T--){
        solve();
    }
}


// templates

ll POW(ll a, ll b, ll m = MOD){
    ll res = 1;
    while(b){
        if(b&1) res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

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


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)));
#define Mx(a , b) ((a) > (b) ? (a) : (b))
#define Mn(a , b) ((a) < (b) ? (a) : (b))

const double EPS = 1e-10;
const int INF = 2147483647;

int N , A;
int x[51];
LL dp[51][51][2501];
LL ans;

int main(){
	scanf("%d%d" , &N , &A);
	for(int i = 1 ; i <= N ; ++i){
		scanf("%d" , x + i);
	}
	dp[0][0][0] = 1;
	for(int i = 1 ; i <= N ; ++i){
		dp[i][0][0] = 1;
		for(int j = 1 ; j <= i ; ++j){
			for(int k = N * A ; k >= x[i] ; --k){
				dp[i][j][k] = dp[i - 1][j - 1][k - x[i]] + dp[i - 1][j][k];
			}
			for(int k = x[i] - 1 ; k > 0 ; --k){
				dp[i][j][k] = dp[i - 1][j][k];
			}
		}
	}
	for(int i = 1 ; i <= N ; ++i){
		ans += dp[N][i][A * i];
	}
	printf("%lld\n" , ans);
	return 0;
}


Measured memory_bytes: 25472
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main (){
  int N;
  vector<int> A;
  cin >> N;
  int a;
  for(int i=0;i<N;i++){
    cin >>a;
    A.push_back(a);
  }
  sort(A.begin(),A.end());
  int count=1;
  long long int C=0;

  for(int i=1;i<N;i++){
    if(2*(A[i-1]+C)<A[i]){
      count=1;
    }else{
      count++;
    }
    C+=A[i-1];
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 892
#include<stdio.h>
int main()
{
    int a[10];
    int b,j;
    for(b=0;b<=9;b++)
        scanf("%d",&a[b]);
    int c,d;
    for(c=0;c<=8;c++)
        for(d=0;d<=8-c;d++)
        if(a[d]<a[d+1])
    {j=a[d];
    a[d]=a[d+1];
    a[d+1]=j;

    }
    for(j=0;j<=2;j++)
        printf("%d\n",a[j]);
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair

using namespace std;

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

template <typename T> inline int Chkmax (T &a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> inline int Chkmin (T &a, T b) { return a > b ? a = b, 1 : 0; }

template <typename T> inline T read(){
    T sum = 0;
    int fl = 1,ch = getchar();
    for(; !isdigit(ch); ch = getchar()) if(ch == '-') fl = -1;
    for(; isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) + ch - '0';
    return sum * fl;
}

const int maxn = 2000 + 5;

int n,sum = 0;
int a[maxn];

bitset <maxn * maxn> status;

inline void Solve (){
	sort(a + 1,a + n + 1);
	for(int i = 1; i <= n; i++){
		sum += a[i];
		status |= status << a[i];
		status[a[i]] = 1;
	}
	int len = status.count() / 2;
	for(int i = sum; i; i--){
		if(status[i]){
			if(!len){
				printf("%d",i);
				return;
			}
			len--;
		}
	}
}

inline void Input (){
	n = read<int>();
	for(int i = 1; i <= n; i++){
		a[i] = read<int>();
	}
}

int main(){
	Input();
	Solve();
	return 0;
}

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

ans=10**12

for i in range(2**N):
    cnt=0
    cost=0
    h=0
    for j in range(N):
        if (i>>j)&1==1:
            cnt+=1
            if h>=a[j]:
                cost+=h+1-a[j]
                h+=1
            else:
                h=max(h,a[j])
        else:
            h=max(h,a[j])

    if cnt>=K:
        ans=min(ans,cost)

print(ans)


Measured memory_bytes: 44140
n = gets.to_i
s = gets.chomp
cands = []
10.times do |i|
  10.times do |j|
    10.times do |k|
      cands << "#{i}#{j}#{k}"
    end
  end
end
# p cands

index = Array.new(10){[]}

s.each_char.with_index do |c, i|
  index[c.to_i] << i
end
cnt = index.map(&:size)
# p index
# p cnt
ans = 0
cands.each do |num|
  flag = false
  10.times do |i|
    a = num.count(i.to_s)
    if cnt[i] < a
      flag = true
      break
    end
  end
  next if flag
  a = num[0].to_i
  ai = index[a][0]
  b = num[1].to_i
  bi = index[b].bsearch{|x| x > ai}
  next if bi.nil?
  c = num[2].to_i
  ci = index[c][-1]
  next if ci <= bi
  ans += 1
end

p ans

Measured memory_bytes: 2812
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main(){
  int A, B; cin >> A >> B;
  int mishiyou = 1;
  int count = 0;
  while(mishiyou < B){
    mishiyou--;
    mishiyou += A;
    count++;
  }
  cout << count << endl;
}

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

typedef long long ll;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

const char nl = '\n';

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	// freopen("input.in", "r", stdin);
	// freopen("input.out", "w", stdout);
	ll x, k, d; cin >> x >> k >> d;
	ll ans;
	if (abs(x) / d <= k) {
		if ((k - abs(x) / d) & 1) ans = min(abs(abs(x) - (abs(x) / d + 1) * d), abs(abs(x) + (abs(x) / d + 1) * d));
		else ans = abs(x) - abs(x) / d * d;
	} else ans = abs(abs(x) - k * d);
	cout << ans << nl;
}

Measured memory_bytes: 3652
use proconio::input;

fn main() {
    input! {
        _: usize,
        s: String
    };

    let mut d: Vec<isize> = [0].to_vec();

    for p in &s.chars().collect::<Vec<char>>() {
        if *p == '(' {
            d.push(d.last().unwrap() + 1);
        } else {
            d.push(d.last().unwrap() - 1);
        }
    }

    for _ in 0..*d.iter().min().unwrap() * (-1) {
        print!("(");
    }
    print!("{}", s);
    for _ in 0..*d.last().unwrap() - *d.iter().min().unwrap() {
        print!(")");
    }
    println!("");
}


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

int main() 
{
	int a,minn=99999999;
	cin>>a;
	int b[111];
	for(int i=1;i<=a;i++)
	{
		cin>>b[i];
	}
	for(int i=0;i<=101;i++)
	{
		int s=0;
		for(int j=1;j<=a;j++)
		{
			s+=(b[j]-i)*(b[j]-i);
		}
		if(s<minn)minn=s;
	}
	cout<<minn;
	return 0;
}

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

typedef vector<int> vi;

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

	string x, y;
	int t[1001][1001];

	while(n--) {
		cin >> x >> y;
		int xs = x.size(), ys = y.size();
		for (int i = 1; i <= xs; i++)
			for (int j = 1; j <= ys; j++) {
				t[i][j] = x[i - 1] == y[j - 1] ?
					t[i - 1][j - 1] + 1 :
					max(t[i - 1][j], t[i][j - 1]);
			}
		cout << t[xs][ys] << endl;
	}
}



Measured memory_bytes: 6984
#include <cstdio>
#include <cmath>
using namespace std;
const double EPS = 1e-10;
typedef struct{
  double x,y;
}point;

int main(void){
  int n;
  char str[200];
  point A,B,C,D;

  fgets(str,sizeof(str),stdin);
  sscanf(str,"%d",&n);
  while(n--){
    fgets(str,sizeof(str),stdin);
    sscanf(str,"%lf %lf %lf %lf %lf %lf %lf %lf",&A.x,&A.y,&B.x,&B.y,&C.x,&C.y,&D.x,&D.y);
    if(fabs((B.x-A.x)*(D.y-C.y)-(D.x-C.x)*(B.y-A.y)) < EPS){
      printf("YES\n");
    }
    else{
      printf("NO\n");
    }
  }
  return 0;
}

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


signed main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
 
    string s;
    cin>>s;

    ll MOD=1e9+7;

    int n=s.size();
    ll dp[n+1][13]={};
    dp[0][0]=1;


    for(int i=0;i<n;i++){
        for(int j=0;j<13;j++){
            if(s[i]=='?'){
                for(int k=0;k<=9;k++){
                    int next = (j*10+k)%13;
                    dp[i+1][next] += dp[i][j];
                    dp[i+1][next]%=MOD;
                }
            }
            else {
                int next = (j*10+s[i]-'0')%13;
                dp[i+1][next] += dp[i][j];
                dp[i+1][next]%=MOD;
            }
        }
    }
    cout<<dp[n][5]<<endl;
}


Measured memory_bytes: 10576
n = int(input())
ta = [list(map(int, input().split())) for _ in range(n)]
pt, pa = 1, 1
for i in range(n):
    t, a = ta[i]
    v = max((pt + t - 1) // t, (pa + a - 1) // a)
    pt = v * t
    pa = v * a

print(pt + pa)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,a[2005];
	cin >> n;
	for (int i=1;i<=2*n;i++) cin >> a[i];
	sort(a+1,a+1+2*n);
	int ans=0;
	for (int i=1;i<=2*n;i+=2) ans+=a[i];
	cout << ans << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a =  readLine()!!.split(" ").map(String::toInt)

    op142c(a)
}

fun op142c(a: List<Int>) {
    val map = mutableMapOf<Int,Int>()
    IntRange(1,a.size).forEach { map[it] = a[it-1] }
    val orderedMap = map.toList().sortedBy { it.second }.toMap()
    orderedMap.forEach{
        print(it.key)
        print(" ")
    }
}


Measured memory_bytes: 97920
#include <bits/stdc++.h>
const long long MOD = 1e9+7;
using namespace std;
#define ll long long
#define ar array

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

	string S,T;
	cin >> S >> T;
	int ans = 0;

	for (int i = 0; i < 3; i++) {
		if (S[i]==T[i]) ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3556
require 'set'
n = gets.to_i

array = []
n.times do
  s = gets.chomp!
  array << s
end

shiritori = (array.size-1).times.all? {|i|
  array[i][-1] == array[i + 1][0]
}

words = Set[]
array.each do |a|
  words << a
end

dup = (array.size == words.size)

puts(shiritori && dup ? 'Yes' : 'No')

Measured memory_bytes: 1916
#2041~
import sys
[a,b,c,d] = list(map(int,input().split()))

#print(a,b,c,d)

#たて
e=d-b
#横
f=c-a

g=""

for i in range(e):
    g=g+"U"
for i in range(f):
    g=g+"R"

for i in range(e):
    g=g+"D"
for i in range(f):
    g=g+"L"

g=g+"L"
for i in range(e+1):
    g=g+"U"
for i in range(f+1):
    g=g+"R"
g=g+"D"

g=g+"R"
for i in range(e+1):
    g=g+"D"
for i in range(f+1):
    g=g+"L"
g=g+"U"

print(g)


Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        if (n < 5){
            System.out.println("0");
            return;
        }
        int sum = 0;
        while (n > 4){
            if (n / 500 > 0){
                sum += n / 500 * 1000;
                n %= 500;
            }
            if(n > 4){
                sum += n / 5 * 5;
                n %= 5;
            }
        }
        System.out.print(sum);
    }

}


Measured memory_bytes: 24020
S = input()
N = len(S)
res = 0
for i in range(N):
  if S[i] in "ACGT":
    cnt = 1
    for j in range(i+1, N):
      if S[j] in "ACGT":
        cnt += 1
      else:
        break
    res = max(res, cnt)

print(res)

Measured memory_bytes: 61776
n, k = map(int, input().split())
if n < k:
    print(1)
    exit(0)

MOD = pow(10, 9) + 7
count = 0
while n+1 >= k:
    minv = k * (k-1) // 2
    maxv = ((n+1) * n // 2) - ((n-k) * (n-k+1) // 2)

    count += (maxv - minv + 1)
    count %= MOD
    k += 1

print(count)


Measured memory_bytes: 9124
n,W=map(int, input().split())
a=[]
max_v=0
for _ in range(n):
    w,v=map(int, input().split())
    a.append((w,v))
    max_v+=v

dp=[[float('inf') for j in range(max_v+1)] for i in range(n+1)] # dp[n][v] = min weight using up to n-th items and value = v

for i in range(1,n+1):
    w,v=a.pop()
    for j in range(max_v+1):
        if j-v>=0:
            dp[i][j]=min(
                dp[i-1][j-v]+w # use j-th item (w,v)
                ,dp[i-1][j])
        else:
            dp[i][j]=dp[i-1][j]
    dp[i][v]=min(w,dp[i-1][v])
    
ans=0
for j in range(max_v+1):
    if dp[n][j]<=W:
        ans=j
print(ans)


Measured memory_bytes: 319808
using System;
using System.Linq;

namespace D
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            for(int i=0; i < n - 1; i++)
            {
                if (A[i] < 0) 
                {
                    A[i] *= (-1);
                    A[i+1] *= (-1);
                } 
            }
            long sum = 0;
            if (A[n - 1] < 0)
            {
                A[n - 1] *= -1;
                int min = A.Min();
                sum -= 2 * min;
            }
            for (int i = 0; i < n; i++)
            {
                sum += A[i];
            }
            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 39516
/**
*    author:  yuya1234
*    created: 22.07.2020 09:18:22
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
long double eps = 1.0E-14;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define FORV(i,v) for(auto i=v.begin(); i!=v.end();i++)

#define SORT(s) sort((s).begin(),(s).end())
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

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; }
template<class T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<class T>T lcm(T a,T b){return gcd(a,b)*(a/gcd(a,b))*(b/gcd(a,b));}

int MOD=1000000007;

long long fibo(int n, vector<long long> &memo) {
    // ベースケース
    if (n == 0) return 0;
    else if (n == 1) return 1;

    // メモをチェック (既に計算済みなら答えをリターンする)
    if (memo[n] != -1) return memo[n];

    // 答えをメモしながら、再帰呼び出し
    return memo[n] = (fibo(n-1, memo) + fibo(n-2, memo)) % MOD;
}


int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  //cout<<fixed<<setprecision(15);

  int n,m;
  cin>>n>>m;

  int a[m+1];
  bool flg=false;
  FOR(i,0,m-1)
  {
    cin>>a[i];
    if(i!=0 && a[i-1]+1==a[i])flg=true;
  }
  a[m]=n+1;

  if(flg)
  {
    cout<<0<<endl;
    return 0;
  }

  ll sum=1;
  vector<ll> memo(n+2, -1);
  FORD(i,m,1)
  {
    //cout<<a[i]<<" "<<a[i-1]<<" "<<a[i]-a[i-1]<<" "<<fibo(a[i]-a[i-1]-1,memo)<<endl;
    sum*=fibo(a[i]-a[i-1]-1,memo);
    sum%=MOD;
  }

  //cout<<a[0]<<" "<<fibo(a[0],memo)<<endl;
  sum*=fibo(a[0],memo);
  sum%=MOD;

  cout<<sum<<endl;

  return 0;
}

Measured memory_bytes: 8560
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int n, t, e, x[maxn];
long long f[maxn];
struct Seg {
	long long tr[maxn << 2];
	inline void Upd(int o, int l, int r, int p, long long d) {
		if(l == r)
			return tr[o] = d, void();
		int mid = (l + r) >> 1;
		if(p <= mid)
			Upd(o << 1, l, mid, p, d);
		else
			Upd(o << 1 | 1, mid + 1, r, p, d);
		tr[o] = min(tr[o << 1], tr[o << 1 | 1]);
	}
	inline long long Ask(int o, int l, int r, int ql, int qr) {
		if(ql > qr)
			return 1e18;
		if(ql <= l && r <= qr)
			return tr[o];
		int mid = (l + r) >> 1;
		long long ans = 1e18;
		if(ql <= mid)
			ans = min(ans, Ask(o << 1, l, mid, ql, qr));
		if(qr > mid)
			ans = min(ans, Ask(o << 1 | 1, mid + 1, r, ql, qr));
		return ans;
	}
}g, h;
int main() {
	scanf("%d%d%d", &n, &e, &t);
	for(int i = 1; i <= n; ++ i)
		scanf("%d", &x[i]);
	memset(f, 0x3f, sizeof f);
	f[0] = 0, g.Upd(1, 0, n, 0, 0), h.Upd(1, 0, n, 0, - 1ll * 2 * x[1]);
	for(int i = 1; i <= n; ++ i) {
		/*
		for(int j = 0; j < i; ++ j) {
			if(t / 2 >= x[i] - x[j + 1])
				f[i] = min(f[i], f[j] - x[j] + t + x[i]);
			if(t / 2 <= x[i] - x[j + 1])
				f[i] = min(f[i], f[j] - 2 * x[j + 1] - x[j] + 3 * x[i]);
		}
		*/
		// p = j + 1
		int p = lower_bound(x, x + i, x[i] - t / 2) - x;
		// cerr << p <<" " << x[i] << " " << x[p] << endl;
		f[i] = min(g.Ask(1, 0, n, p - 1, i - 1) + t + x[i], h.Ask(1, 0, n, 0, p - 2) + 1ll * 3 * x[i]);
		if(i < n)
			// g[i] = f[i] - x[i], h[i] = f[i] - x[i] - 2 * x[i + 1];
			g.Upd(1, 0, n, i, f[i] - x[i]), h.Upd(1, 0, n, i, f[i] - x[i] - 1ll * 2 * x[i + 1]);
		
	}
	/*
	for(int i = 0; i <= n; ++ i)
		cerr << f[i] <<" ";
	cerr << endl;
	*/
	printf("%lld\n", f[n] + e - x[n]);

}

Measured memory_bytes: 9072
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template < typename T > string tost( const T& n ) { ostringstream stm; stm << n; return stm.str();}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
int const INF = 1001001001;


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

int N;
cin >> N;
vector<string> S(N);
map<char, int> mp;
rep(i,N) {
    cin >> S[i];
    mp[S[i][0]]++;
}
vl name;
name.push_back(mp['M']);
name.push_back(mp['A']);
name.push_back(mp['R']);
name.push_back(mp['C']);
name.push_back(mp['H']);
ll ans = 0;
for(int i = 0; i < 3; ++i) {
    for(int j = i+1; j < 4; ++j) {
        for(int k = j+1; k < 5; ++k) {
            ans += name[i]*name[j]*name[k];
        } 
    }
}
cout << ans << endl;
return 0;
}

Measured memory_bytes: 5760
#include "bits/stdc++.h"
using namespace std;

class LazySegmentTree {
private:
	long long Size;
	vector<long long> Node, Lazy;
public:
	LazySegmentTree(long long N) {
		Size = 1;
		while (Size < N) Size <<= 1;
		Node.assign(Size * 2, 0);
		Lazy.assign(Size * 2, 0);
	}
	void Eval(long long K, long long L, long long R) {
		Node[K] += Lazy[K] * (R - L);
		if (R - L > 1) {
			Lazy[K * 2] += Lazy[K];
			Lazy[K * 2 + 1] += Lazy[K];
		}
		Lazy[K] = 0;
	}
	void Update(long long A, long long B, long long X, long long K, long long L, long long R) {
		Eval(K, L, R);
		if (B <= L || R <= A) return;
		if (A <= L && R <= B) {
			Lazy[K] += X;
			Eval(K, L, R);
			return;
		}
		Update(A, B, X, K * 2, L, (L + R) / 2);
		Update(A, B, X, K * 2 + 1, (L + R) / 2, R);
		Node[K] = Node[K * 2] + Node[K * 2 + 1];
	}
	void Update(long long A, long long B, long long X) {
		Update(A, B, X, 1, 0, Size);
	}
	long long Query(long long A, long long B, long long K, long long L, long long R) {
		Eval(K, L, R);
		if (B <= L || R <= A) return 0;
		if (A <= L && R <= B) return Node[K];
		return Query(A, B, K * 2, L, (L + R) / 2) + Query(A, B, K * 2 + 1, (L + R) / 2, R);
	}
	long long Query(long long A, long long B) {
		return Query(A, B, 1, 0, Size);
	}
};

int main() {
	long long N, Q;
	cin >> N >> Q;
	LazySegmentTree Seg(N);
	for (int i = 0; i < Q; i++) {
		long long Com;
		cin >> Com;
		if (Com == 0) {
			long long A, B, X;
			cin >> A >> B >> X;
			Seg.Update(A - 1, B, X);
		}
		else {
			long long A, B;
			cin >> A >> B;
			cout << Seg.Query(A - 1, B) << endl;
		}
	}
}


Measured memory_bytes: 7016
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
#define REP(i,a,n) for(int (i)=(a); (i)<(int)(n); (i)++)
#define rep(i,n) REP(i,0,n)
#define vec vector 


int main(){
  int N, M;
  cin >> N >> M;
  
  vector<int> s(M);
  vector<int> c(M);
  rep(i, M) {
    cin >> s.at(i);
    cin >> c.at(i);
  }

  vector<int> target_int(N, 0);
  int res = 0;

  rep(i, M){
    if(target_int.at(s.at(i)-1) == 0){
      target_int.at(s.at(i)-1) = c.at(i);
    }else{
      if(target_int.at(s.at(i)-1) != c.at(i)) res = -1;
    }
  }
  
  if(N != 1){
    rep(i, M){
      if(s.at(i) == 1 && c.at(i) == 0) res = -1;
    }
  }
  
  //1桁の数以外の場合は頭を1にする。
  if(target_int.at(0) == 0 && N != 1) target_int.at(0) = 1;
  
  
  
  if(res != -1){
    rep(i, N){
      cout << target_int.at(i);
    }
  }else{
    cout << res;
  }
}

Measured memory_bytes: 256
n, m = map(int, input().split())
al = []
bl = []
for i in range(n):
    a, b = map(int, input().split())
    al.append([a, b])
for j in range(m):
    c, d = map(int, input().split())
    bl.append([c,d])

def check(a,b):
    x = a[0] - b[0]
    y = a[1] - b[1]
    if x < 0:
        x = -x
    if y < 0:
        y = -y
    return x + y

for a in al:
    min = 1000000000
    cnt = 1
    for b in bl:
        tmp = check(a,b)
        if tmp < min:
            ans = cnt
            min = tmp
        cnt += 1
    print(ans)

Measured memory_bytes: 9228
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 100100100100;
const ll MOD = 1000000007;


ll combination(ll n, ll r){
    if(n < r) return 0;
    if(r == 0||r == n) return 1;
    else if(r == 1) return n;
    return (combination(n - 1, r - 1) + combination(n - 1, r));
}

bool checkKaibun(string str){
    string checkStr = str;
    reverse(checkStr.begin(), checkStr.end());
    if(str == checkStr) return true;
    else return false;
}

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


ll mpow(ll x, ll n){//繰り返し二乗法 計算量O(logN)
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans * x % MOD;
        x = x * x % MOD;
        n  = n >> 1;
    }
    return ans;
}

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


int main(){
    int N;
    string str;
    cin >> N >> str;
    int ans = 0;
    string pass = "000";
    rep(i, 1000){
        //passが作れるか
        int testIndex = 0;
        rep(j, N){
            if(pass[testIndex] == str[j])testIndex++;
        }
        if(testIndex == 3) ans++;
        int num = stoi(pass);
        num++;
        string s = to_string(num);
        if(num < 10){
            pass[2] = s[0];
            pass[0] = '0';
            pass[1] = '0';
        }else if(num < 100){
            pass[0] = '0';
            pass[1] = s[0];
            pass[2] = s[1];
        }else pass = s;
    }
    cout << ans << endl;
}  


Measured memory_bytes: 256
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

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

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N := sc.nextInt()
	A := make([]map[int]int, N)
	AA := make([]int, N)
	for i := 0; i < N; i++ {
		a := sc.nextInt()
		A[i] = primeFactors(a)
		AA[i] = a
	}
	G := make(map[int]int)
	for i := 0; i < N; i++ {
		for k, v := range A[i] {
			if G[k] < v {
				G[k] = v
			}
		}
	}
	gcd := 1
	for k, v := range G {
		gcd *= modPow(k, v, MOD)
		gcd %= MOD
	}
	ans := 0
	for i := 0; i < N; i++ {
		res := 1
		res *= gcd * modInv(AA[i], MOD) % MOD
		res %= MOD
		ans += res
		ans %= MOD
	}

	fmt.Fprintln(wtr, ans)
}

func primeFactors(n int) map[int]int {
	pfs := make(map[int]int)
	for n%2 == 0 {
		pfs[2]++
		n = n / 2
	}
	for i := 3; i*i <= n; i = i + 2 {
		for n%i == 0 {
			pfs[i]++
			n = n / i
		}
	}
	if n > 2 {
		pfs[n]++
	}

	return pfs
}

func modPow(a, n, mod int) int {
	res := 1
	for n > 0 {
		if (n & 1) > 0 {
			res = res * a % mod
		}
		a = a * a % mod
		n >>= 1
	}
	return res
}

func modInv(a, mod int) int {
	b := mod
	u := 1
	v := 0
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= mod
	if u < 0 {
		u += mod
	}
	return u
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
	using namespace std;
	typedef long long ll;
	#define endl "\n"
	#define space " "
	#define ll long long int
	#define vl vector<ll>
	#define vvl vector < vll >
	#define pii pair<int,int>
	#define pll pair<ll,ll>
	#define vpl vector < pll >
	#define mod 1000000007
	#define pi 3.1415926535897932384626433
	#define inf 1000000000000000001;
	#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y) 
	#define mem(a,val) memset(a,val,sizeof(a))
	#define pb push_back
	#define f first
	#define s second
	
	void solve()
	{
		string s; cin>>s;
		int c=0;
		if(s=="RRR") c=3;
		else if(s=="RRS" || s=="SRR") c=2;
		else if(s=="RSS" || s=="SRS" || s=="SSR" || s=="RSR") c=1;
		else c=0;
		cout<<c;
	}

	signed main()
	{

	fast;
	#ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
     #endif

	ll T=1;
	// cin>>T;
	while(T--)
	{
		solve();
	}
	return 0;
	}


Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#define rep(i, m, n) for(int i = m;i < n;i++)
#define repr(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define lint long long;
#define INF 999999999
using namespace std;

//ユークリッドの互除法
long long gcd(long long a, long long b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

//最小公倍数を求める
long long lcd(long long a, long long b){
    long long g = gcd(a,b);
    return a / g * b;
}


int main(){
    long long n; cin >> n;
    long long ans = 0;
if(n == 1){
    cin >> ans;
    goto end;
}
//最初の二個
long long t1, t2;
cin >> t1 >> t2;
ans = lcd(t1, t2);

//最小公倍数の更新
long long temp;
if(n == 1) goto end;
if(n == 2) goto end;
rep(i, 2, n){
    cin >> temp;
    ans = lcd(ans, temp);
}
end:;
cout << ans << endl;

return 0;
}


Measured memory_bytes: 256
#![allow(
  non_snake_case,
  unused_variables,
  unused_assignments,
  unused_mut,
  unused_imports,
  dead_code
)]
//use proconio::fastout;
use proconio::{input, marker::*};
//use std::collections::*;
use std::cmp::*;

fn main() {
  input! {
    D:i64,T:i64,S:i64
  }

  println!("{}", if D <= T * S { "Yes" } else { "No" });
}


Measured memory_bytes: 2156
import bisect
from collections import deque

n = int(input())
#c = []
c = deque([])
for i in range(n):
    a = int(input())
    if i == 0:
        c.append(a)
    else:
        ind = bisect.bisect_left(c,a)
        if ind > 0:
            c[ind-1] = a
        else:
            c.appendleft(a)

print(len(c))

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

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

using namespace std;

template<class G>
class Fenwick_tree_dual{
	vector<G> a;
public:
	Fenwick_tree_dual(int n):a(n){}
	void add(int l,int r,G val){
		if(l==0){
			for(r--;r>=0;r=(r&(r+1))-1) a[r]+=val;
			return;
		}
		add(0,r,val);
		add(0,l,-val);
	}
	G sum(int i){
		G res{};
		for(;i<a.size();i|=i+1) res+=a[i];
		return res;
	}
};

struct interval{
	int l,r;
	bool operator<(const interval& I)const{ return r-l<I.r-I.l; }
};

int main(){
	int n,m; scanf("%d%d",&n,&m);
	vector<interval> I(n);
	rep(i,n) scanf("%d%d",&I[i].l,&I[i].r), I[i].r++;

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

	int idx=0;
	Fenwick_tree_dual<int> F(m+1);
	for(int d=1;d<=m;d++){
		while(idx<n && I[idx].r-I[idx].l<=d){
			F.add(I[idx].l,I[idx].r,1);
			idx++;
		}

		int ans=n-idx;
		for(int x=d;x<=m;x+=d) ans+=F.sum(x);
		printf("%d\n",ans);
	}

	return 0;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
char s[10000];
int S,X,Y,dx[4]={1,0,-1,0},dy[4]={0,1,0,-1},dir=0,p,q;
bool f[20000];
vector<int>u,v;
int main(){
	scanf("%s",s),S=strlen(s),scanf("%d%d",&X,&Y);
	for(int i=0,j=0;i<S;){
		while(j<S&&s[j]=='F')j++,p+=dx[dir],q+=dy[dir];
		if(i){
			if(dir==0)u.push_back(i-j);
			if(dir==1)v.push_back(i-j);
			if(dir==2)u.push_back(j-i);
			if(dir==3)v.push_back(j-i);
		}
//		printf("%d %d\n",i,j);
		j++,i=j;
		dir=(dir+1)%4;
	}
//	for(int i=0;i<u.size();i++)printf("%d ",u[i]);puts("");
//	for(int i=0;i<v.size();i++)printf("%d ",v[i]);puts("");
	X-=p,Y-=q;
	if((X&1)||(Y&1)){puts("No");return 0;}
	X>>=1,Y>>=1;
	
	f[S]=true;
	for(int i=0;i<u.size();i++){
		if(u[i]==0)continue;
		if(u[i]>0)for(int j=S-u[i];j>=-S;j--)f[S+j+u[i]]|=f[S+j];
		if(u[i]<0)for(int j=-S-u[i];j<=S;j++)f[S+j+u[i]]|=f[S+j];
	}
	if(!f[S+X]){puts("No");return 0;}
	
	memset(f,0,sizeof(f));
	
	f[S]=true;
	for(int i=0;i<v.size();i++){
		if(v[i]==0)continue;
		if(v[i]>0)for(int j=S-v[i];j>=-S;j--)f[S+j+v[i]]|=f[S+j];
		if(v[i]<0)for(int j=-S-v[i];j<=S;j++)f[S+j+v[i]]|=f[S+j];
	}
	if(!f[S+Y]){puts("No");return 0;}
	
	puts("Yes");
	return 0;
}

Measured memory_bytes: 384
A,V=map(int,input().split())
B,W=map(int,input().split())
T=int(input())

if A<B:
  if A+V*T>=B+W*T:
    print('YES')
  else:
    print('NO')
    
else:
  if A-V*T<=B-W*T:
    print('YES')
  else:
    print('NO')

Measured memory_bytes: 9124
#include<iostream>
#include<algorithm>
#include<map>
#include<cstdio>
#include<cstring>
#include<cmath>
#define ll long long
#define lson (rt<< 1)
#define rson (rt<< 1 | 1)
#define gmid ((l+r)>> 1 )
using namespace std;

const int maxn=200050;

int f[maxn],s[maxn];

int find(int x)
{
	if(f[x]==x) return x;
	else return f[x]=find(f[x]);
}

int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;++i)
	  {
	  	  f[i]=i;
	  	  s[i]=0;
	  }
	for(int i=1;i<=m;++i)
	  {
	  	  int x,y;
	  	  cin>>x>>y;
	  	  if(find(x)!=find(y))
	  	  {
	  	  	  f[find(x)]=find(y);
	  	  }
	  }
	int ans=0;  
	for(int i=1;i<=n;++i)
	  {
	  	  if(s[find(i)]==0)
	  	  {
	  	  	  ans++;
	  	  	  s[find(i)]=1;
	  	  }
	  }  
	cout<<ans-1<<endl;  
}


Measured memory_bytes: 4408
#import numpy as np
def cir(x1, y1, x2, y2, x3, y3):
    """
    3点を通る円の中心と半径を取得
    """
    d = 2 * ((y1 - y3) * (x1 - x2) - (y1 - y2) * (x1 - x3))
    if d==0:
        return None
    x = ((y1 - y3) * (y1 ** 2 - y2 ** 2 + x1 ** 2 - x2 ** 2) - (y1 - y2) * (y1 ** 2 - y3 ** 2 + x1 ** 2 - x3 ** 2)) / (1.0*d)
    y = ((x1 - x3) * (x1 ** 2 - x2 ** 2 + y1 ** 2 - y2 ** 2) - (x1 - x2) * (x1 ** 2 - x3 ** 2 + y1 ** 2 - y3 ** 2)) / (-d*1.0)
    r = ((x - x1) ** 2 + (y - y1) ** 2)**0.5
    return [[x, y], r]
n=int(input())
l=[]
for i in range(n):
    l.append(list(map(float,input().split())))
ans=10**10
for i in range(n):
    for j in range(n):
        for k in range(n):
            if i<j<k:
                z=cir(l[i][0],l[i][1],l[j][0],l[j][1],l[k][0],l[k][1])
                if z:
                    f=0
                    x=z[0][0]
                    y=z[0][1]
                    r=z[1]
                    for m in l:
                        if ((m[0]-x)**2+(m[1]-y)**2)**0.5<=r:
                            f+=1
                    if f==n:
                        ans=min(ans,r)
def cir2(p,q):
    x1=p[0]
    y1=p[1]
    x2=q[0]
    y2=q[1]
    return [(x1+x2)*0.5,(y1+y2)*0.5,(((x1-x2)**2+(y1-y2)**2)**0.5)*0.5]
for i in range(n):
    for j in range(n):
        if i<j:
            z=cir2(l[i],l[j])
            x=z[0]
            y=z[1]
            r=z[2]
            f=0
            for m in l:
                if ((x-m[0])**2+(y-m[1])**2)**0.5<=r:
                    f+=1
            if f==n:
                ans=min(ans,r)
print(ans)
                   

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

using namespace std;

int main(){
  int n,i;
  cin >> n;
  while(n!=0){
    int score[101];
    for(i=0;i<n;i++) cin >> score[i];
    sort(score,score+n);
    int sum=0;
    for(i=1;i<n-1;i++) sum+=score[i];
    cout << sum/(n-2) << endl;
    cin >> n;
  }
  
  return 0;
}

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

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

    int p[n], incorrect=0;
    for(int i=0; i<n; i++){
        cin>>p[i];
        if(p[i] != i+1) incorrect++;
    }
    if(incorrect == 0 || incorrect == 2){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <cstring>
using namespace std;

int w,h;
pair<int,int> sa,sb,ga,gb;
char mapA[52][52], mapB[52][52];
bool memo[52][52][52][52];

int dxa[] = {0,0,1,-1};
int dxb[] = {0,0,-1,1};
int dya[] = {1,-1,0,0};
int dyb[] = {1,-1,0,0};

bool solve(pair<int,int> posA, pair<int,int> posB){
	queue< pair< pair<int,int>, pair<int,int> > > q;
	q.push(pair< pair<int,int>, pair<int,int> >(posA,posB));
	
	while(!q.empty()){
		posA = q.front().first;
		posB = q.front().second;
		q.pop();

		for(int i=0;i<4;i++){
			pair<int,int> na = pair<int,int>(posA.first+dxa[i], posA.second+dya[i]);
			pair<int,int> nb = pair<int,int>(posB.first+dxb[i], posB.second+dyb[i]);
			
			if(na.first<0 || na.first>=w || na.second<0 || na.second>=h || mapA[na.second][na.first]=='#') na = posA;
			if(nb.first<0 || nb.first>=w || nb.second<0 || nb.second>=h || mapB[nb.second][nb.first]=='#') nb = posB;

			if(na == ga && nb == gb) return true;
			if(na == ga || nb == gb) continue;
			if(memo[na.first][na.second][nb.first][nb.second]) continue;

			q.push(pair< pair<int,int>, pair<int,int> >(na,nb));
			memo[na.first][na.second][nb.first][nb.second] = true;
		}
	}
	return false;
}

int main(void){
	while(cin>>w>>h && (w||h)){
		memset(memo,0,sizeof(memo));
		for(int i=0;i<h;i++){
			cin>>mapA[i]>>mapB[i];
			for(int j=0;j<w;j++){
				if(mapA[i][j] == 'L'){
					sa = pair<int,int>(j,i);
				}
				else if(mapA[i][j] == '%'){
					ga = pair<int,int>(j,i);
				}
				if(mapB[i][j] == 'R'){
					sb = pair<int,int>(j,i);
				}
				else if(mapB[i][j] == '%'){
					gb = pair<int,int>(j,i);
				}
			}
		}

		if(solve(sa,sb)) cout<<"Yes\n";
		else cout<<"No\n";
	}

	return 0;
}

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

#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT_ON(bit, i) (((bit >> i) & 1) > 0)

typedef long long LL;
template<typename T> std::vector<T> make_v(size_t a){return std::vector<T>(a);}
template<typename T,typename... Ts> auto make_v(size_t a, Ts... ts){ return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}    // C++14
template<typename T,typename V> typename std::enable_if<std::is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename std::enable_if<std::is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
template<class T> inline T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> inline void print(T x) { std::cout << x << std::endl; }
template<class T> inline void print_vec(const std::vector<T> &v) { for (int i = 0; i < v.size(); ++i) {  if (i != 0) {std::cout << " ";} std::cout << v[i];} std::cout << "\n"; }
template<class T> inline bool inside(T y, T x, T H, T W) {return 0 <= y and y < H and 0 <= x and x < W; }
template<class T> inline double euclidean_distance(T y1, T x1, T y2, T x2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); }
template<class T> inline double manhattan_distance(T y1, T x1, T y2, T x2) { return abs(x1 - x2) + abs(y1 - y2); }
template<typename T> T &chmin(T &a, const T &b) { return a = std::min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = std::max(a, b); }

template<class T> inline std::vector<T> unique(std::vector<T> v) {
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    return v;
}
// 初項s, 交差dのn個の数列の和
long long sum_of_arithmetic_progression(long long s, long long d, long long n) {
    return n * (2 * s + (n - 1) * d) / 2;
}

const int INF = 1 << 30;
const double EPS = 1e-9;
const long double PI = acos(-1.0);
const std::vector<int> dy4 = {0, -1, 0, 1}, dx4 = {1, 0, -1, 0};
const std::vector<int> dy8 = { 0, -1, 0, 1, 1, -1, -1, 1 }, dx8 = { 1, 0, -1, 0, 1, 1, -1, -1 };


using namespace std;


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

    int N;
    cin >> N;
    auto P = make_v<double>(N);

    FOR(i, 0, N) {
        cin >> P[i];
    }

    auto dp = make_v<double>(N + 1, N + 10);
    dp[0][0] = 1;

    FOR(i, 0, N) {
        FOR(j, 0, N + 1) {
            // 表
            dp[i + 1][j + 1] += dp[i][j] * P[i];

            // 裏
            dp[i + 1][j] += dp[i][j] * (1 - P[i]);
        }
    }

    double ans = 0.0;
    FOR(h, 0, N + 1) {
        int t = N - h;
        if (h > t) {
            ans += dp[N][h];
        }
    }

    cout << fixed;
    cout << setprecision(10) << ans << endl;

    return 0;
}



Measured memory_bytes: 70912
a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
c=[2]
g=[a,b,c]
x,y=map(int,input().split())
def gomi():
  for i in g:
    if x in i and y in i:
      print("Yes")
      return
  print("No")
  return
gomi()


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
namespace CsProgramSpace
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> li = new List<int>();
            int temp;
            while(true)
            {
                temp = int.Parse(Console.ReadLine());
                if (temp == 0) break;
                li.Add(temp);
            }
            int c = 0;
            foreach (int i in li)
            {
                c++;
                Console.WriteLine(string.Format("Case {0}: {1}", c, i));
            }
        }
    }
}


Measured memory_bytes: 18048
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;

int main(){
    lint l, r;
    scanf("%lld%lld", &l, &r);
    if(r-l >= 2018){
        printf("0\n");
        return 0;
    }
    l %= 2019;
    r %= 2019;
    if(l > r) r += 2019;
    lint ans = 2019;
    For(i, l, r+1)For(j, i+1, r+1) ans = min(ans, (lint)i*j%2019);
    printf("%lld\n", ans);
}

Measured memory_bytes: 256
<?php
  list($n) = explode(" ", trim(fgets(STDIN)));
  list($s) = explode(" ", trim(fgets(STDIN)));
  
  $l = 0;
  $r = 0;
  for ($i=0; $i<$n; $i++) {
    if($s[$i] == '('){
      $r++;
    }else{
      if($r == 0){
        $l++;
      }else{
        $r--;
      }
    }
  }

  for ($i=0; $i<$l; $i++) {
    echo "(";
  }

  echo $s;

  for ($i=0; $i<$r; $i++) {
    echo ")";
  }



Measured memory_bytes: 16104
n, k, s = map(int, input().split())

if s == 10**9:
    for _ in range(k):
        print(s, end=" ")
    for j in range(n-k):
        print(10**9-1, end=" ")
else:
    for _ in range(k):
        print(s, end=" ")
    for j in range(n-k):
        print(10**9, end=" ")


Measured memory_bytes: 4340