akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for(ll i=(ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
constexpr ll INF = 1LL<<60;

int main() {
    ll n, m, s;
    cin >> n >> m >> s;
    struct edge {
        ll to, coin, time;
    };
    vector<vector<edge>> g(n); 
    REP(i, m) {
        ll u, v, a, b;
        cin >> u >> v >> a >> b;
        u--, v--;
        g[u].push_back({v, a, b});
        g[v].push_back({u, a, b});
    }
    vector<ll> c(n), d(n);
    REP(i, n) cin >> c[i] >> d[i];

    chmin(s, 5000LL);
    vector<vector<ll>> dist(n, vector<ll>(5010, INF));
    dist[0][s] = 0;
    struct state {
        ll cost, vtx, coin;
        bool operator<(const state &r) const {
            return cost > r.cost;
        };
    };
    priority_queue<state> que;
    que.push({0, 0, s});
    while(que.size()) {
        state st = que.top(); que.pop();
        if(dist[st.vtx][st.coin] < st.cost) continue;
        for(auto e: g[st.vtx]) {
            if(st.coin >= e.coin && dist[e.to][st.coin-e.coin] > dist[st.vtx][st.coin] + e.time) {
                dist[e.to][st.coin-e.coin] = dist[st.vtx][st.coin] + e.time;
                que.push({dist[e.to][st.coin-e.coin], e.to, st.coin-e.coin});
            }
        }
        if(st.coin+c[st.vtx] < 5010 && dist[st.vtx][st.coin+c[st.vtx]] > dist[st.vtx][st.coin] + d[st.vtx]) {
            dist[st.vtx][st.coin+c[st.vtx]] = dist[st.vtx][st.coin] + d[st.vtx];
            que.push({dist[st.vtx][st.coin+c[st.vtx]], st.vtx, st.coin+c[st.vtx]});
        }
    }

    FOR(i, 1, n) {
        ll ans = INF;
        REP(j, 5010) chmin(ans, dist[i][j]);
        cout << ans << "\n";
    }

    return 0;
}


Measured memory_bytes: 11424
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
//BEGIN CUT HERE
template<typename T>
struct AbsoluteSum{
  multiset<T> lp,rp;
  T sum;
  AbsoluteSum():sum(0){}
  T insert(T x){
    if(lp.empty()){
      lp.emplace(x);
      rp.emplace(x);
      return T(0);
    }
    auto p=interval();
    lp.emplace(x);
    rp.emplace(x);
    if(p.first<=x&&x<=p.second) return T(0);
    while(*lp.rbegin()>*rp.begin()){
      T a=*lp.rbegin();
      T b=*rp.begin();
      lp.erase(lp.find(a));
      rp.erase(rp.find(b));
      rp.emplace(a);
      lp.emplace(b);
    }
    T res=min(abs(p.first-x),abs(p.second-x));
    sum+=res;
    return res;
  }

  T erase(T x){
    assert(lp.count(x)+rp.count(x)>=2);
    if(lp.count(x)&&rp.count(x)){
      lp.erase(lp.find(x));
      rp.erase(rp.find(x));
      return T(0);
    }
    if(lp.count(x)){
      lp.erase(lp.find(x));
      lp.erase(lp.find(x));
      lp.emplace(*rp.begin());
      rp.erase(rp.begin());
    }else{
      rp.erase(rp.find(x));
      rp.erase(rp.find(x));
      rp.emplace(*lp.rbegin());
      lp.erase(lp.find(*lp.rbegin()));
    }
    auto p=interval();
    T res=min(abs(p.first-x),abs(p.second-x));
    sum-=res;
    return res;
  }

  pair<T, T> interval(){
    assert(!lp.empty());
    return make_pair(*lp.rbegin(),*rp.begin());
  }

  T value(){return sum;}
};
//END CUT HERE
//INSERT ABOVE HERE
signed ABC127_F(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  int q;
  cin>>q;
  using ll = long long;
  AbsoluteSum<ll> as;
  ll sum=0;
  for(int i=0;i<q;i++){
    int t;
    cin>>t;
    if(t==1){
      ll a,b;
      cin>>a>>b;
      as.insert(a);
      sum+=b;
    }
    if(t==2){
      cout<<as.interval().first<<" "<<sum+as.value()<<"\n";
    }
  }
  cout<<flush;
  return 0;
}
/*
  verified on 2019/06/19
  https://atcoder.jp/contests/abc127/tasks/abc127_f
*/

signed YUKI_837(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  using ll = long long;

  int n;
  cin>>n;
  vector<ll> ys(n);
  for(int i=0;i<n;i++) cin>>ys[i];
  sort(ys.begin(),ys.end());
  if(ys.front()==ys.back()){
    cout<<1<<endl;
    return 0;
  }

  AbsoluteSum<ll> as;
  vector<ll> dp(n,0);
  for(int i=0;i<n;i++){
    as.insert(ys[i]);
    dp[i]+=as.value();
  }
  for(int i=0;i<n;i++){
    as.erase(ys[i]);
    dp[i]+=as.value();
  }

  cout<<*min_element(dp.begin(),dp.end())<<endl;
  return 0;
}
/*
  verified on 2019/06/19
  https://yukicoder.me/problems/no/837
*/

signed main(){
  ABC127_F();
  //YUKI_837();
  return 0;
}


Measured memory_bytes: 19072
n,r[12],c;double d[12][16],M[12][4096];double S(b,l,i){double*m=M[l]+b,s,t;for((s=*m)?i=0:!b?s=r[i=0,l]:(i=n,s=1e3);i;)b&1<<--i&&(t=d[l][i]+S(b^1<<i,i),s=t<s?t:s);return*m=s;}main(L,i,j){double s,t;for(;~scanf("%d",&L);puts(s>L?"NA":"OK")){for(n=0;scanf("%d%c",r+n++,&c),c-10;);for(i=n;i--;)for(j=n;j--;)d[i][j]=2*sqrt(r[i]*r[j]);memset(M,0,393216);s=1e3;for(i=n;i--;s=t<s?t:s)t=r[i]+S((1<<n)-1-(1<<i),i);}}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();

        System.out.printf("%d %d %f\n", a / b, a % b, (double)a / b);
    }
}

Measured memory_bytes: 26460
#include <stdio.h>
#include <string.h>
#define N 100
void up(void);
int A[N];
int main(void){
	int ans,i;
	char str[N];

	for( ;fgets(str,sizeof(str),stdin)!=NULL; ){
		ans=5;
		for(i=0;i<9;i++){
			if(str[i]=='o')
				A[i+1]=1;
			else if(str[i]=='x')
				A[i+1]=0;
			else if(str[i]=='s')
				A[i+1]=5;
		}
		up();	
	}
	return 0;
}

void up(void){
	int i,ans;
		for(i=1;i<8;i+=3){
			if(A[i]==A[i+1] && A[i+1]==A[i+2] && A[i]!=5){
				ans=A[i];
				goto out;
			}
		}
		for(i=1;i<4;i+=1){
			if(A[i]==A[i+3] && A[i+3]==A[i+6] && A[i]!=5){
				ans=A[i];
				goto out;
			}
		}
		if(A[1]==A[5] && A[5]==A[9] && A[1]!=5){
			ans=A[1];
			goto out;
		}
		if(A[3]==A[5] && A[5]==A[7] && A[3]!=5){
			ans=A[3];
			goto out;
		}
		out:;
		if(ans==1)
			printf("o\n");
		else if(ans==0)
			printf("x\n");
		else
			printf("d\n");
}

Measured memory_bytes: 524
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		no1();
	}

	static void no1() {
		try (Scanner sc = new Scanner(System.in)) {
			Integer N = sc.nextInt();
			Integer a = sc.nextInt();
			Integer b = sc.nextInt();

			int ans = 0;
			for (int i = 1; i <= N; i++) {
				String str = String.valueOf(i);
				char[] ch = str.toCharArray();

				int sum = 0;
				for (int j = 0; j < ch.length; j++) {
					sum += Character.getNumericValue(ch[j]);
				}
				if (a <= sum && sum <= b) {
					ans += i;
				}
			}
			System.out.println(ans);
		}
	}
}


Measured memory_bytes: 23636
def main():
    a = input()
    b = input()
    c = input()

    d = {"a": a, "b": b, "c": c}

    now_player = "a"
    while True:
        if len(d[now_player]) == 0:
            break

        next_player = d[now_player][0]
        d[now_player] = d[now_player][1:]
        now_player = next_player

    print(now_player.upper())


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <stdio.h>
int main(){
    int n=0, a=0, b=0;
    scanf("%d %d %d", &n, &a, &b);
    int sum=0;
    for(int i=1;i <=n;i++){
        int num = i;
        int temp=0;
        while(num>0){
            temp+=num%10;
            num/=10;
}
        if(temp>=a&&temp<=b){
        sum +=i;
        }

    }
    printf("%d", sum);
    return 0;}

Measured memory_bytes: 1732
#include <stdio.h>
#include <stack>
using namespace std;
const int N=1e5+10;
int p[N],val[N];
stack<int>s[N];
int find(int n){
    if(p[n]==n)return n;
    return p[n]=find(p[n]);
}
int main(){
    int n,q,l,r,temp,a,b;
    scanf("%d%d",&n,&q);
    for(int i=0;i<n;i++){
        p[i]=i;
        val[i]=0;
        s[i].push(i);
    }
    while(q--){
        scanf("%d%d%d",&temp,&l,&r);
        if(temp==1){
            if(find(l)!=find(r))printf("?\n");
            else printf("%d\n",val[r]-val[l]);
        }
        else{
            scanf("%d",&temp);
            a=find(l);
            b=find(r);
            if(a==b)continue;
            if(s[a].size()>s[b].size()){
                p[b]=a;
                temp+=val[l]-val[r];
                while(!s[b].empty()){
                    val[s[b].top()]+=temp;
                    s[a].push(s[b].top());
                    s[b].pop();
                }
            }
            else{
                p[a]=b;
                temp=val[r]-temp-val[l];
                while(!s[a].empty()){
                    val[s[a].top()]+=temp;
                    s[b].push(s[a].top());
                    s[a].pop();
                }
            }
        }
    }
    
}


Measured memory_bytes: 70844
L,R = map(int,input().split())
if R-L >= 2019:
    modL = 0
    modR = 2018
else:
    l = L%2019
    r = R%2019
    if r>l:
        modR = r
        modL = l
    else:
        modL = r
        modR = l+2019

ans = 100000000
for x in range(modL+1,modR+1):
    for y in range(modL,x):
        ans = min(ans,(x*y)%2019)
print(ans)

Measured memory_bytes: 41836
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;

typedef long long LL;
LL M,H,CK,CK1,CK2,b1,b2,b3,Max,Min,ans,a3,a4;
//LL a1 = 1 << 30;
//LL a2 = 1 << 30;
int main()
{
	scanf("%I64d %I64d",&H,&M);
	if((H * M)%3 == 0)printf("0\n");
	else
	{
	LL	a1 = min(M,H);
			for(LL i = 1;i < H;i++){
				b1 = i*M;
				b2 = (H - i) * (M/2);
				b3 = (H - i) * ((M/2) + M%2);
				CK1 = min(b1,b2);
				CK1 = min(CK1,b3);
				CK2 = max(b1,b2);
				CK2 = max(CK2,b3);
				CK = (CK2 - CK1);
				a1 = min(CK,a1);
		}
			for(LL i = 1;i < M;i++){
				b1 = i*H;
				b2 = (M - i) * (H/2);
				b3 = (M - i) * ((H/2) + H%2);
				CK1 = min(b1,b2);
				CK1 = min(CK1,b3);
				CK2 = max(b1,b2);
				CK2 = max(CK2,b3);
				CK = (CK2-CK1);
				a1 = min(CK,a1);
			}
		ans = a1;
		printf("%I64d\n",ans);
	}
}

Measured memory_bytes: 128
from collections import Counter

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

count = Counter(Alist)
res = 1
if N % 2 ==0:
    for i in range(1,N,2):
        if count[i] != 2:
            print(0)
            exit()
else:
    if count[0] != 1:
        print(0)
        exit()
    else:
        for i in range(2,N,2):
            if count[i] != 2:
                print(0)
                exit()
print(2**(N//2) % (10**9+7))

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

int H, W, K, A[309][309], num;
int cnt[309];
char c[309][309];

void solve(int cl, int cr) {
	vector<int> P;
	for (int i = cl; i <= cr; i++) {
		for (int j = 1; j <= W; j++) {
			if (c[i][j] == '#') P.push_back(j);
		}
	}
	sort(P.begin(), P.end());

	for (int i = 0; i < P.size(); i++) {
		int v1 = 1, v2 = W;
		if (i >= 1) v1 = P[i - 1] + 1;
		if (i < (int)P.size() - 1) v2 = P[i];

		num++;
		for (int j = cl; j <= cr; j++) {
			for (int k = v1; k <= v2; k++) A[j][k] = num;
		}
	}
}

int main() {
	cin >> H >> W >> K;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			cin >> c[i][j];
			if (c[i][j] == '#') cnt[i]++;
		}
	}

	vector<int> vec;
	for (int i = 1; i <= H; i++) { if (cnt[i] >= 1) vec.push_back(i); }
	for (int i = 0; i < vec.size(); i++) {
		int v1 = 1, v2 = H;
		if (i >= 1) v1 = vec[i - 1] + 1;
		if (i < (int)vec.size() - 1) v2 = vec[i];

		solve(v1, v2);
	}

	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			if (j >= 2) cout << " "; cout << A[i][j];
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (ll)(v).size()
#define inf 1e18
#define md 998244353
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(o,0,n)cout<<v[o]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define M 1000010
ll ex(ll a,ll b){ll ans=1;while(b){if(b&1)ans=(ans*a)%md;a=(a*a)%md,b/=2;}return ans;} 
inline ll add(ll a,ll b){a=a%md+b%md;if(a>md)a%=md;return a;}
inline ll sub(ll a,ll b){a=a%md-b%md;if(a<0)a+=md;return a;}
inline ll mul(ll a,ll b){a%=md,b%=md;return (a*b)%md;}
ll iv(ll x){return ex(x,md-2);}


ll d[M],cnt[M];
int main(){
    IOS;
 	
 	ll n;cin>>n;
 	ll ans=0;
 	rep(i,0,n){
 		ll x;cin>>x; cnt[x]++;
 		ans=sub(ans,x);
 	}
 	rep(i,1,M)d[i]=iv(i);
 	rep(i,1,M)for(ll j=2*i;j<M;j+=i)d[j]=sub(d[j],d[i]);
 	rep(i,1,M){
 		ll x=0;
 		for(ll j=i;j<M;j+=i)x=add(x,mul(j,cnt[j]));
 		x=mul(x,x);
 		ans=add(ans,mul(d[i],x));
 	}
 	ans=mul(ans,iv(2));						
 	cout<<ans;
 	
	
    return 0;
}

Measured memory_bytes: 19268
#include<bits/stdc++.h>
#define fr first
#define sc second
#define vec vector
#define ms multiset
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define int long long
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
const int inf = 1e9+7;
const int nmax = 500005;
const ll linf = LLONG_MAX;

ll n , m , a[100005] , lcm = 1 , v2;
bool diferent_v2 = false;
int32_t main(){
    cin >> n >> m;
    for(int i = 1; i <= n ; i++){
        cin >> a[i];
        a[i]/= 2;
        lcm = a[i] * lcm /(__gcd(a[i],lcm));
        if(i > 1 && (v2 != __gcd(a[i] ,(long long)1<<32)))diferent_v2 = true;
        v2 =  __gcd(a[i] ,(long long)1<<32);
    }
    if(diferent_v2){
        cout << 0 << '\n';
        return 0;
    }
    //nr de numere impare de la 1 la m/lcm
    ll ct = m/lcm;
    cout << (ct + 1)/2;

}



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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define bit(n) (1LL << (n))

using namespace std;

typedef long long ll;

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin>>n;
  
  int p[n], q[n];
  
  rep(i,n) cin>>p[i];
  rep(i,n) cin>>q[i];
  
  vector<int> v(n);
  rep(i,n) v[i]=i+1;
  
  int a=0;
  int b=0;
  int index = 0;
  
  do{ 
    ++ index;
    int num[n];
    rep(i,n) {
      num[i]=v[i];
    }
    
    bool isP=true;
    bool isQ=true;
    
    rep(i,n) {
      if(num[i]!=p[i]) isP=false;
      if(num[i]!=q[i]) isQ=false;
    }
    
    if(isP) a=index;
    if(isQ) b=index;
    
  } while(next_permutation(v.begin(),v.end()));
  
  cout<<abs(a-b);
}

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

int main() 
{

	int n;
	cin >> n;
	int arr[n];
	for(int i=0; i<n; i++)
		cin >> arr[i];
	int ans = 0;
  int minimum = INT_MAX;
  for(int i =0; i<n; i++)
  {
    if(minimum > arr[i]) ans++;
    minimum = min(arr[i], minimum);
  }
  
  cout << ans << endl;
	
}

Measured memory_bytes: 1024
import copy
s = list(input())
t = list(input())
ans_list = []
n = len(s)
m = len(t)
for i in range(n-m+1):
  s_copy = copy.copy(s)
  judgement = True
  for j in range(m):
    if s_copy[i+j] != "?" and s_copy[i+j] != t[j]:
      judgement = False
      break
    else:
      s_copy[i+j] = t[j]
  if judgement:
    ans_list.append(s_copy)
x = len(ans_list)
if ans_list != []:
  for l in range(x):
    for k in range(n):
      if ans_list[l][k] == "?":
        ans_list[l][k] = "a"
  ans_list.sort()
  print("".join(ans_list[0]))
else:
  print("UNRESTORABLE")

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

a.sort()

ans =0

while a[0]<=a[2]-2:
    a[0]+=2
    ans +=1

while a[1]<=a[2]-2:
    a[1]+=2
    ans+=1

if a[0]==a[1] and a[1]!=a[2]:
    ans +=1
elif a[0]==a[1] and a[1]==a[2]:
    ans +=0
else:
    ans +=2

print(ans)

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, A, B;
    cin >> N >> A >> B;
    ll ans = INF;
    if ((B - A) % 2 == 0) {
        ans = (B - A) / 2;
    }
    else {
        ans = std::min((B - A - 1) / 2 + A, (N - (A + (N - B + 1))) / 2 + (N - B + 1));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N, L = map(int, input().split())

T = []
for i in range(N):
    t = L + (i + 1) - 1
    T.append(t)

if T[0] >= 0:
    ans = sum(T[1:])
elif T[-1] <= 0:
    ans = sum(T[:-1])
else:
    for ti in T:
        if ti >= 0:
            min_plus = ti
            break
    ans = sum(T) - min_plus

print(ans)


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

vector<vector<int>> d(10, vector<int>(10, 1e9));
void warshall_floyd()
{
    for(int k = 0; k < 10; k++){
        for(int i = 0; i < 10; i++){
            for(int j = 0; j < 10; j++){
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}

int main(){
    int h, w;
    cin >> h >> w;
    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            cin >> d[i][j];
        }
    }
    vector<vector<int>> a(h, vector<int>(w, 0));
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> a[i][j];
        }
    }
    int ans = 0;
    warshall_floyd();
    for (int i = 0; i < h; i++)
    {
        for(int j = 0; j < w; j++){
            if(a[i][j]!=-1 && a[i][j]!=1){
                ans += d[a[i][j]][1];
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
long long inf=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  string s;
  cin>>s;
  s[5]=' ';
  s[13]=' ';
  cout<<s<<endl;
  return 0;
}


Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if 500*a + 100*b + 50*c == X:
                ans += 1
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>

#include<queue>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
 
#define INF (1e9)
typedef long long unsigned int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
 

 
int vector_finder(std::vector<int> vec, int number) {
  size_t index = std::distance( vec.begin(), std::find(vec.begin(), vec.end(), number) );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

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

int N,K;
ll ans = 0;

void counter(int n){
	while(1){
		if(n%2==0){
			n /= 2;
			ans++;
		}
		else{
			break;
		}
	}
}

int main()
{
	cin >> N;
	int A[N];
	int idx;

	REP(i,N){
		cin >> A[i];
		if(A[i]%2==0){
			counter(A[i]);
		}
	}

	cout << ans << endl;

	return 0;
}

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

int main() {
    int n,k,temp;
    cin>>n>>k;
    ll ans=0;
    rep(i,n) {
        cin>>temp;
        ans+=min(2*temp,2*abs(temp-k));
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))

int n;
lli as[20005]={},bs[20005]={};

int main(void){
	scanf("%d",&n);
	reg(i,1,n)as[i]=bs[i]=1;
	ireg(i,1,n){
		int a;
		scanf("%d",&a);
		as[a+1]+=i; bs[a-1]+=i;
	}
	rep(i,n)as[i+1]+=as[i];
	irep(i,n)bs[i]+=bs[i+1];
	
	reg(i,1,n)printf("%lld ",as[i]);
	puts("");
	reg(i,1,n)printf("%lld ",bs[i]);
	puts("");
	
	return 0;
}






Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int dp[55][3010];
    int n,m,s;
    while(1){
        for(int i=0;i<55;i++)
        for(int j=0;j<3010;j++)dp[i][j]=0;
        cin >> n >> m >> s;
        if(n==0&&m==0&&s==0)break;
        int bin = n*n;
        dp[0][0]=1;
        for(int k=1;k<=m;k++)
        for(int i=bin;i>0;i--){
            for(int j=k;j<=s;j++){
               dp[i][j] = (dp[i-1][j-k]+dp[i][j])%100000;
            }
        }
        cout << dp[bin][s] << endl;
    }
    return 0;
}

Measured memory_bytes: 1804
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		int H = sc.nextInt();

		int W = sc.nextInt();

		int ans = 0;


		for(int i=0;i<N;i++) {

			int a = sc.nextInt();

			int b = sc.nextInt();

			if(a>=H && b>=W) ans++;
		}

		System.out.println(ans);

	}

}


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

#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef pair<int,int> pii;

const int maxn=100005;
int n;
pii a[maxn],b[maxn];

namespace Dsu{
	int f[maxn];
	void init(){
		REP(i,n)f[i]=i;
	}
	int find(int x){
		return f[x]==x?x:f[x]=find(f[x]);
	}
	void merge(int x,int y){
		f[find(x)]=find(y);
	}
}

int main(){
	scanf("%d",&n);
	Dsu::init();
	REP(i,n)scanf("%d",&a[i].fst),a[i].snd=i;
	REP(i,n)scanf("%d",&b[i].fst),b[i].snd=i;
	sort(a+1,a+1+n);
	sort(b+1,b+1+n);
	REP(i,n){
		if(a[i].fst>b[i].fst){
			puts("No");
			return 0;
		}
		Dsu::merge(a[i].snd,b[i].snd);
	}
	int cnt=0;
	REP(i,n)if(Dsu::find(i)==i)cnt++;
	if(cnt>1){
		puts("Yes");
		return 0;
	}
	REP(i,n-1)if(a[i+1].fst<=b[i].fst){
		puts("Yes");
		return 0;
	}
	puts("No");
	return 0;
}

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

int main()
{
	int res = 0;
	string s, t("CODEFESTIVAL2016");
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] != t[i])
			res++;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
n=int(input())
from math import floor,sqrt
sqset=set()
for i in range(1,200):
  sqset.add(i**2)
def func(m):
  r=0
  for x in range(1,floor(sqrt(m))+1):
    for y in range(1,floor(sqrt(m))+1):
      a=x+y
      b=x**2+y**2+x*y-m
      d=a**2-4*b
      if d in sqset:
        if (sqrt(d)-a)>0 and (sqrt(d)-a)%2==0:
          r+=1
  return r
for i in range(1,n+1):
  print(func(i))

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

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

int main(){
  int n, x, ret;
  cin >> n >> x >> ret;
  ret = abs(ret-x);
  for(int i=1; i<n; i++){
    int t;
    cin >> t;
    ret = gcd(ret, abs(x-t));
  }
  cout << ret;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

ans = 0

for i in range(len(a)-1):
    if a[i]+1 == a[i+1]:
        ans += c[a[i]-1]
    else:
        continue

print(ans+sum(b))

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

int n,m;
char s[305];
inline void init(){
	gets(s+1);
	n=strlen(s+1);
	scanf("%d",&m);
}

int dp[305][305][305],ans;
inline void solve(){
	for(int k=0;k<=m;++k)
		for(int i=1;i<=n;++i)
			for(int j=n;j>=i;--j){
				int &f=dp[i][j][k];
				f=max(dp[i-1][j][k],dp[i][j+1][k]);
				if(s[i]==s[j])f=max(f,dp[i-1][j+1][k]+1);
				else if(k)f=max(f,dp[i-1][j+1][k-1]+1);
				ans=max(ans,i==j?f*2-1:f*2);
			}
	printf("%d\n",ans);
}

int main(){
	init();
	solve();
	return 0;
} 

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) for (auto i = mp.begin(); i != mp.end(); ++i) { cout << i->first <<":"<<i->second << endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<" ";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k,r,s,p;
    string t;
    cin>>n>>k>>r>>s>>p>>t;
    ll ans=0;
    string choice = "";

    for(int i=0; i<n; i++) {

        if (i >= k && t[i-k] == t[i]) {
            t[i] = 'x';
        } else if (t[i] =='s'){
            ans += r;
        } else if (t[i] =='p'){
            ans += s;
        } else if (t[i] =='r'){
            ans += p;
        } 
    }

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


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#define Endl endl
#define mp make_pair
#define ll long long 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define over(A) {cout<<A<<endl;exit(0);}
#define all(A) A.begin(),A.end()
#define ceil(a,b) ((a-1)/b+1)
#define srand() mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand(l,r) uniform_int_distribution<int>(l,r)(rng)
typedef unsigned long long ull;
const int inf=1039074182;
using namespace std;

int main()
{
//	freopen("input.txt","r",stdin);
	int a,b;
	cin>>a>>b;
	cout<<max(a+b,max(a-b,a*b))<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

int p[200001],r[200001];
void init(){rep(i,200001)p[i]=i,r[i]=0;}
int find(int x){return (p[x]==x)?x:(p[x]=find(p[x]));}
void unite(int x,int y) {
  x=find(x),y=find(y);
  if(x==y)return;
  if(r[x]<r[y])p[x]=y;
  else{p[y]=x;if(r[x]==r[y])r[x]++;}
}
bool same(int x,int y){return find(x)==find(y);}

void Main() {
  init();
  ll n,m,k;
  cin >> n >> m >> k;
  vector<ll> v[n],g[n];
  rep(i,m) {
    int x,y;
    cin >> x >> y;
    x--,y--;
    unite(x,y);
    g[x].pb(y);
    g[y].pb(x);
  }
  rep(i,k) {
    int x,y;
    cin >> x >> y;
    x--,y--;
    v[x].pb(y);
    v[y].pb(x);
  }
  set<ll> s[n];
  rep(i,n) s[find(i)].in(i);
  ll d[n];
  mem(d);
  rep(i,n) {
    d[i]=s[find(i)].size()-1;
    rep(j,g[i].size()) {
      if(s[find(i)].count(g[i][j])) d[i]--;
    }
    rep(j,v[i].size()) {
      if(s[find(i)].count(v[i][j])) d[i]--;
    }
  }
  PR(d,n);
}

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


Measured memory_bytes: 24692
from bisect import*
N = int(input())
P = []

for i in range(N):
    h, p = map(int, input().split())
    P.append((h+p, h, p))
P.sort()

dp = [10**18]*(N+1)
dp[0] = 0
for i in range(N):
    k, h, p = P[i]
    idx = bisect(dp, h)
    for j in range(idx-1, -1, -1):
        dp[j+1] = min(dp[j]+p, dp[j+1])
    #print(idx)
    #print(dp[:idx+1])
print(bisect(dp, 10**17)-1)


Measured memory_bytes: 47448
#include <cstdio>
#include <algorithm>
using namespace std;
int m, n, val, digit[10], done;

int f(int x, int v)
{
    int ret = 987654321;
    if( v > 10 ) return 987654321;
    if( x >= m ) return x;
    for(int i = 0 ; i < 10 ; i++ )
        if( !digit[i] )
            ret = min( ret, f(x*10+i, v+1) );
    return ret;
}

int main()
{
    scanf("%d%d", &m, &n);
    for(int t, i = 0 ; i < n ; i++ )
        scanf("%d", &t), digit[t]++;
    printf("%d", f(0, 0));
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
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;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int n, m; cin >> n >> m;
    vector<int> s(n), c(n);
    rep(i,m) {
        cin >> s[i] >> c[i];
        s[i]--;
    }

    string ans;
    
    if (n == 1) ans = "0";
    else ans = "1";
    rep(i,n-1) {
        ans += '0';
    }

    rep(i,m) {
        ans[s[i]] = c[i]+'0';
    }

    rep(i,m) {
        if (ans[s[i]] != c[i]+'0') {
            cout << -1 << endl;
            return 0;
        }
    }

    if (n >= 2 && ans[0] == '0') {
        cout << -1 << endl;
        return 0;
    }

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


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<complex>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
#define N 200010
ll n,q,a[N],b[N];
map<ll,ll> mp;
void Erase(ll x){
    mp[x]--;
    if(mp[x]==0)mp.erase(x);
}
int main(){
    cin>>n>>q;
    lol(i,2*n)cin>>a[i];
    lol(i,2*n)cin>>b[i];
    
    ll sum=a[0]+a[2*n-1];
    ll cnt=0;
    for(int i=1;i<=2*n-2;i++){
	sum+=max(a[i],b[i]);
	if(a[i]>b[i])cnt++;
	mp[abs(a[i]-b[i])]++;
    }
    
    lol(u,q){
	ll p,x,y;
	cin>>p>>x>>y;
	p--;
	if(p==0||p==2*n-1){
	    sum=sum-a[p]+x;
	}
	else{
	    sum-=max(a[p],b[p]);
	    sum+=max(x,y);
	    
	    if(a[p]>b[p])cnt--;
	    Erase(abs(a[p]-b[p]));
	    
	    if(x>y)cnt++;
	    else mp[abs(x-y)]++;
	}
	a[p]=x,b[p]=y;
	ll ans=sum;
	if(cnt%2==1){
	    ans-=mp.begin()->first;
	}
	cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 17280
#include <stdio.h>

int main()
{
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);

  if ((a == c && b == a && b == c) || (a != c && b != a && b != c)) {
    puts("No");
  }
  else
  {
    puts("Yes");
  }
  
  return 0;
}

Measured memory_bytes: 1664
/**
 *    DP
 *    26.04.2020 11:01
**/

#include <bits/stdc++.h>

using namespace std;

const int N_MAX = 1e5 + 5;
vector<int> adj [N_MAX]; // a -> b, a -> c, adj[a] = b, c
vector<int> in_degree (N_MAX, 0); // number of edges going in node i
vector<int> dis (N_MAX, 0); // dis[i] = max distance to node i

void dfs (int n) {
  for (int k : adj[n]) {
    dis[k] = max(dis[k], dis[n] + 1);
    in_degree[k]--;
    if (in_degree[k] == 0) dfs(k);
  }
  return;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, M, a, b, ans = 0;
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> a >> b;
    adj[a].push_back(b);
    in_degree[b]++;
  }
  /*
    create imaginary connection from node 0 to all other nodes
    use dfs from node 0 to all other nodes, find maximum length
    return length - 1
    save max length at node i as dp[i]
  */
  for (int i = 1; i <= N; i++) {
    adj[0].push_back(i);
    in_degree[i]++;
  }
  dfs(0);
  for (int i = 0; i <= N; i++) {
    ans = max(ans, dis[i]);
  }
  cout << ans - 1 << "\n";
  return 0;
}


Measured memory_bytes: 8056
import java.util.*;
 
public class Main {
  public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    String k = null;
    List<String> ans = new ArrayList<String>();
    
    for(int i = 0; i < str.length(); i++) {
      k = str.substring(i, i+1);
      
      if(k.equals("0")){
        ans.add("0");
      }else if(k.equals("1")){
        ans.add("1");
      }else if(k.equals("B")){
        if(ans.size() > 0){
          ans.remove(ans.size()-1);
        }
      }
    }
      
    for(int j=0; j<ans.size(); j++){
      System.out.print(ans.get(j));
    }
  }
}

Measured memory_bytes: 35628
N, X, Y = map(int, input().split())


ans = [0] * (N-1)
for i in range(1, N):
    for j in range(i+1,N+1):
        
        d = min(j-i, abs(i-X)+abs(j-Y)+1)
        ans[d-1] += 1
for i in ans:
    print(i)
    

Measured memory_bytes: 3444
from sys import stdin
from math import gcd
def main():
    #入力
    readline=stdin.readline
    k=int(readline())
    ans=0
    for a in range(1,k+1):
        for b in range(1,k+1):
            for c in range(1,k+1):
                ans+=gcd(a,gcd(b,c))

    print(ans)
if __name__=="__main__":
    main()

Measured memory_bytes: 9176
H,W = map(int, input().split())
N = int(input())
As = list(map(int, input().split()))
li = []
for i,a in enumerate(As):
    li += [i+1]*a
# print(li)
fields = []
for i in range(H):
    ind_s = i*W
    ind_y = (i+1)*W
    if i % 2 == 1:
        fields.append(li[ind_s:ind_y][::-1])
    else:
        fields.append(li[ind_s:ind_y])
for r in fields:
    print(*r)

Measured memory_bytes: 3956
#include<stdio.h>
int main()
{
char a,b;
scanf("%c %c",&a,&b);
if(a=='D')
{if(b=='D')
printf("H");
else
printf("D");}
if(a=='H')
{if(b=='D')
printf("D");
else
printf("H");}
return 0;
}


Measured memory_bytes: 128
require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

def get_ints
  gets.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

A, B = get_ints

puts A * B


Measured memory_bytes: 14452
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);


		int n = Integer.parseInt(scanner.nextLine());

		char[] list = scanner.nextLine().toCharArray();

		int count = 0;

		for(int i = 0; i < n; i++) {

			for(int j = i + 1; j < n && list[i] == list[j]; j++) {

				i ++;
			}

			count++;

		}
		System.out.println(count);
	}
}

Measured memory_bytes: 26060
import itertools
n,m=map(int,input().split())
edge=[list(map(int,input().split())) for i in range(m)]
ans=0
nums=[i for i in range(1,n+1)]
rout=itertools.permutations(nums,n)
for r in rout:
  if r[0]!=1:
    continue
  lim=0
  while lim<n-1:
    if [r[lim],r[lim+1]] in edge or [r[lim+1],r[lim]] in edge:
      lim+=1
    else:
      lim=0
      break
  if lim:
    ans+=1
print(ans)

Measured memory_bytes: 3064
from math import factorial

def c(n,k):
    return factorial(n)/(factorial(n-k) * factorial(k))

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

o = 0
e = 0

for i in A:
    if i % 2 == 0:
        e += 1
    else:
        o += 1
on = o // 2

a = []
b = []
ans = 0

if P == 0:
    for i in range(e+1):
        a.append(c(e,i))
    for i in range(on+1):
        b.append(c(o,i*2))        
    for i in a:
        for j in b:
            ans += i * j
else:
    for i in range(e+1):
        a.append(c(e,i))
    for i in range(1,o+1)[::2]:
        b.append(c(o,i))        
    for i in a:
        for j in b:
            ans += i * j

ans = int(ans)
print(ans)

Measured memory_bytes: 3064
//AtCoder ABC067 C - Splitting Pile
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
#if LOCAL&0
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    ll N;
    cin>>N;
    vector<ll> an(N+1,0);
    for(ll i=1;i<=N;++i){
        cin>>an[i];
    }
    ll sum=0;
    vector<ll> acc(N+1,0);
    for(ll i=1;i<=N;++i){
        sum+=an[i];
        acc[i]=sum;
    }
    ll ans=INT64_MAX;
    for(ll i=1;i<N;++i){
        ll x=acc[i];
        ll y=acc[N]-acc[i];
        ans = min(abs(x-y),ans);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3328
import java.util.*;

public class Main {
    public static void main(String args[]) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        Map<Character, List<Integer>> posMap = new HashMap<>();
        for(int i = 0; i < s.length(); i++) {
        	char c = s.charAt(i);
        	if(!posMap.containsKey(c))
        		posMap.put(c, new ArrayList<>());
        	posMap.get(c).add(i);
        }

        int min = s.length() / 2;
        for(List<Integer> list : posMap.values()) {
        	if(list.size() == 1) continue;
        	Collections.sort(list);
        	
        	int maxDist = list.get(0);
        	for(int i = 1; i < list.size(); i++) {
        	    int dist = Math.abs(list.get(i) - list.get(i-1) - 1);
        		maxDist = Math.max(maxDist, dist);
        	}
        	maxDist = Math.max(maxDist, Math.abs(s.length() - list.get(list.size() - 1) - 1));

        	min = Math.min(min, maxDist);
        }
        System.out.println(min);
    }
}


Measured memory_bytes: 23124
#include<iostream>
#include<string>
#include<complex>
#include<vector>
#include<algorithm>
#include<functional>
#include<array>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define INF 1e+9


int main() {
	int n;
	cin >> n;
	ll a[200005];
	for (int i = 0;i < n;i++) {
		cin >> a[i];
		a[i] -= i;
	
	}
	sort(a, a + n);
	ll mid = a[n / 2];
	ll ans = 0;
	for (int i = 0;i < n;i++) {
		ans += abs(a[i] - mid);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long mod = 1e9 + 7;
const int iINF = 0x3f3f3f3f;
const long long INF = 1LL << 60;
using namespace std;

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

int main()
{
  int n, k;
  cin >> n >> k;
  if (k % 2 == 0)
  {

    cout << ll(pow(n / k, 3) + pow((n + k / 2) / k, 3)) << endl;
  }
  else
  {
    cout << ll(pow(n / k, 3)) << endl;
  }
  return 0;
}


Measured memory_bytes: 4108
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include <bitset>
using namespace std;
const int mod=1e9+7;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,x,n) for (int i= x;i<n;i++)
#define all(v) v.begin(), v.end()
#define nepe(v) next_permutation(all(v))
#define F first 
#define S second
#define PB push_back 
#define MP make_pair
using ll = long long;
using vi = vector<int>; 
using vvi = vector<vi>;
using vl=vector<long long>;
using vp =vector<pair<int,int>>;

typedef pair<int,int> P;
string s;
int k;
ll INF = 10000000000000000;

int main(){
    int N;
    cin >>N;
    vi dist(N,0);
    vector<set<P>> ST(N);
    rep(i,N-1){
        int u,v;
        ll w;
        cin >>u>>v>>w;
        u--;
        v--;
        int ww =w%2;
        ST[u].insert(MP(v,ww));
        ST[v].insert(MP(u,ww));
    }
    stack<int>  l;
    l.push(0);
    while(!l.empty()){
        int n = l.top();
        l.pop();
        for(auto value:ST[n]){
            l.push(value.F);
            dist[value.F] = (dist[n]+value.S)%2;
            ST[value.F].erase(MP(n,value.S));
        }
    }
    rep(i,N){
        cout <<dist[i]<<endl;
    }
}

Measured memory_bytes: 14848
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
	    Scanner std = new Scanner(System.in);
	    int a = Integer.parseInt(std.next());
	    int b = Integer.parseInt(std.next());
	    int c = Integer.parseInt(std.next());
	    int temp = 0;
	    if(a>b){temp=a;a=b;b=temp;}
	    if(b>c){temp=b;b=c;c=temp;}
	    if(a>b){temp=a;a=b;b=temp;}
	    System.out.println(a+" "+b+" "+c);
	}
}

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

#define endl '\n'
#define pb push_back

int n, k;
int a[100005], dp[100005];

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

  cin >> n >> k;
  for(int i=1; i<=n; i++){
    cin >> a[i];
  }

  dp[0]=0;
  for(int t=1; t<=k; t++){
    vector <int> lz;
    for(int i=1; i<=n; i++){
      if(t-a[i]>=0) lz.pb(dp[t-a[i]]);
    }
    sort(lz.begin(), lz.end());
    int mex=0;
    for(int i=0; i<lz.size(); i++){
      if(mex<lz[i]) break;
      if(mex==lz[i]) mex++;
    }
    dp[t]=mex;
  }

  if(dp[k]) cout << "First" << endl;
  else cout << "Second" << endl;
}

Measured memory_bytes: 640
import java.util.*;

public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        final int n = sc.nextInt();
        final int m = sc.nextInt();
        int lMax = Integer.MIN_VALUE;
        int rMin = Integer.MAX_VALUE;

        for (int i = 0;i<m;++i)
        {
            int l = sc.nextInt();
            int r = sc.nextInt();
            if (lMax < l) lMax = l;
            if (rMin > r) rMin = r;
        }

        int count = 0;
        for (int i = 0;i<=n;++i) if (lMax <= i && rMin >= i) ++count;

        System.out.println(count);
        sc.close();
    }
}

Measured memory_bytes: 63376
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <limits.h>
#include <map>
#include <numeric>

namespace test {
	std::string to_string (char val) {
		return std::string (1, val);
		// return std::string{val};
	}
	//if( str.find ("r") != string::npos)
}

using namespace std;
typedef long long int llint;

int main (void) {
	string a, b,c; cin >> a >> b >> c;
	cout << ( a[a.size () - 1] == b[0] && b[b.size () - 1] == c[0] ? "YES" : "NO" ) << endl;
	return 0;
}

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

int main() {
  
  int N, A, B;
  cin >> N >> A >> B;
  
  int ans = 0;
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      for (int k = 0; k < 10; k++) {
        for (int l = 0; l < 10; l++) {
          if (1000 * i + 100 * j + 10 * k + l > N) break;
          
          if (i + j + k + l >= A && i + j + k + l <= B) {
            ans += 1000 * i + 100 * j + 10 * k + l;
          }
        }
      }
    }
  }
  
  if (A == 1 && N == 10000) ans += 10000;
  cout << ans << endl;
  
  
}

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

int main(void) {
    int N;cin>>N;
    int sum = 0;
    for (int i = 1; i <= N; i++) {
        int p;cin>>p;
        if (p != i) sum++;
    }
    if (sum == 0 || sum == 2) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
struct edge{int from, to;};
ll mod=1e9+7;

int main(){
    int n;
    cin>>n;
    ll mul=1;
    rep(i,n){
        mul*=(i+1);
        mul%=mod;
    }
    cout <<mul<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int a,b,c,d,e,f,g,h,i,j,k;
    while(1){
    scanf("%d",&a);
    d=0;e=0;f=0;g=0;h=0;i=0;j=0;
    if(a==0){
        break;
    }
    for(b=0;b<a;b++){
        scanf("%d",&c);
        if(c<10){
            d=d+1;
        }else if(10<=c&&c<20){
        e=e+1;
        }else if(20<=c&&c<30){
        f=f+1;
        }else if(30<=c&&c<40){
        g=g+1;
        }else if(40<=c&&c<50){
        h=h+1;
        }else if(50<=c&&c<60){
        i=i+1;
        }else if(60<=c){
        j=j+1;
        }
    }printf("%d\n%d\n%d\n%d\n%d\n%d\n%d\n",d,e,f,g,h,i,j);
    }
    return 0;
}

Measured memory_bytes: 600
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int k, x;
	cin >> k >> x;
	int l = x - k + 1;
	int r = x + k - 1;
	for (int i = l; i <= r; i++)
		printf("%d%c", i, " \n"[i == r]);
	return 0;
}


Measured memory_bytes: 256