akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		String s = in.next();
		int r = solve(s);
		System.out.println(r);
		in.close();
	}

	private static int solve(String s) {
		int r = 1;
		for (int i = 1; i < s.length(); i++)
			if (s.charAt(i - 1) != s.charAt(i))
				r++;
		return r;
	}
}

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

int main()
{
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    if(abs(a-c)<=k||(abs(a-b)<=k&&abs(b-c)<=k))
    {
        cout<<"Yes"<<endl;
        return 0;
    }
    else
    {
        cout<<"No"<<endl;
        return 0;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=a; i<=b; i++)
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define INF 1000000000000
#define MOD 10000007
#define PI 3.14159265359
#define dij priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>>
typedef long long ll;
//
int main(){
    string s;
    cin>>s;
    
    int ma=0;
    FOR(i,1,s.length()){
      
        FOR(j,0,s.length()-1-i+1){
            bool flag=true;  
            string t=s.substr(j,i);
//            cout<<t<<endl;
            for(auto e:t){
                if(e!='A'&&e!='T'&&e!='G'&&e!='C')flag=false;
            }
            if(flag)ma=i;
        }
    }
    cout<<ma<<endl;
}


Measured memory_bytes: 3600
n,c = map(int,input().split())
xv = [list(map(int,input().split())) for _ in range(n)]

l1 = 0
r1 = 0
l1_tmp = 0
l2_tmp = 0
r1_tmp = 0
r2_tmp = 0
now = 0
lil = []
lir = []
ll = []
lr = []

for x,v in xv:
    r1_tmp += v - (x - now)
    r2_tmp = r1_tmp - x
    r1 = max(r1, r1_tmp)
    lir.append(r2_tmp)
    lr.append(r1_tmp)
    now = x

xv = xv[::-1]
now = 0

for x,v in xv:
    x = c - x
    l1_tmp += v - (x - now)
    l2_tmp = l1_tmp - x
    l1 = max(l1, l1_tmp)
    lil.append(l2_tmp)
    ll.append(l1_tmp)
    now = x

max_idx = 0
lir = lir[::-1]
lir2 = []
lil2 = []
for i in range(n):
    lir2.append((lir[i], i))
for i in range(n):
    lil2.append((lil[i], n-i-1))

lir2.sort(reverse = True)
lil2.sort(reverse = True)

count = 0
ans = 0
for i in range(n-1):
    while lir2[count][1] <= i:
        count += 1
        if count > n:
            break
    ans = max(ans, ll[i]+lir2[count][0])

count = 0
for i in range(n-1):
    while lil2[count][1] <= i:
        count += 1
        if count > n:
            break
    ans = max(ans, lr[i]+lil2[count][0])

print(max(r1, l1, ans))


Measured memory_bytes: 83160
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(),vec.end()
#define rever(vec) reverse(all(vec));
#define cend cout << endl;
#define prique(T) priority_queue<T,vector<T>,greater<T>>
struct edge { int to, cost; };
typedef pair<int, int> P;
const int mod = 1e9 + 7, inf = 1e16;

int modpow(int x, int n) {
	if (n == 0) return 1;
	if (n % 2) return x * modpow(x * x % mod, n / 2) % mod;
	return  modpow(x * x % mod, n / 2) % mod;
}
int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int n, x;
int l[114];
int d[114];
int ans = 0;
signed main() {
	cin >> n >> x;
	rep(i, n) {
		cin >> l[i];
	}
	rep(i, n + 1) {
		if (i != 0) {
			d[i] = d[i - 1] + l[i - 1];
		}
		if (d[i] <= x) {
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>
#include <set>
#include <map>
#include <type_traits>
#include <cstdint>
#include <queue>
#define _USE_MATH_DEFINES
#include <math.h>

typedef long long ll;

using namespace std;

//素因数分解
void factoring(ll n, map<ll, ll>& mp) {
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			mp[i]++;
			n /= i;
		}
	}
	if (n != 1) mp[n]++;
}

//絶対値
template<class T, class U = std::make_unsigned_t<T>>
U SafeAbs( T x ) {
    return x < 0 ? -static_cast<uintmax_t>(x) : x;
}

//最大・最小
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;
}

//xのn乗
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
//xの逆元
ll mod_inv(ll x, ll mod) {//O(log(mod))
    return mod_pow(x, mod - 2, mod);
}

//nCr
ll ncr(ll n, ll r, ll mod){
	ll res=1;
	ll num=1,den=1;
	for(ll i=n;i>=n-r+1;i--){
		(den*=i)%=mod;
	}
	for(ll i=1;i<=r;i++){
		(num*=i)%=mod;
	}
	
	res=den*mod_inv(num,mod);

	return res%mod;
}


//二分探索
bool isOk(ll index, ll key,vector<ll> &a, bool g){
	if(g){
		if(a[index]<key){
			return true;
		}
	}
	else{
		if(a[index]>key){
			return true;
		}
	}
	return false;
}

ll bin_search(ll key, vector<ll> &a, bool g){
	
	ll l=-1;
	ll r=a.size();

	if(g){
		l=a.size();
		r=-1;
	}

	while(abs(r-l)>1){
		ll mid = (l+r)/2;
		if(isOk(mid, key, a, g)){
			r=mid;
		}
		else{
			l=mid;
		}
	}
	return r;
}


//深さ優先探索
void dfs(vector<string> &m,vector<vector<bool>> &seen, ll x, ll y, ll h, ll w){

	seen[y][x]=true;

	
	for(ll i=0;i<4;i++){
		ll nx=x,ny=y;
		if(i==0){ //up
			ny=y-1;
		}
		else if(i==1){ //down
			ny=y+1;
		}
		else if(i==2){ //right
			nx=x+1;
		}
		else{ //left
			nx=x-1;
		}

		if(nx<0 || nx>=w || ny<0 || ny>=h){
			continue;
		}
		if(seen[ny][nx]){
			continue;
		}
		
		if(m[ny][nx]=='#'){
			continue;
		}

		dfs(m,seen,nx,ny,h,w);
	}
}

const ll MOD = 1000000007;
void solve(){
	ll n,k;
	cin>>n>>k;

	ll ans=0;

	vector<ll> rui(n+1,0);
	for(ll i=0;i<n+1;i++){
		rui[i+1]=rui[i]+(i+1);
	}

	for(ll i=k;i<=n+1;i++){
		if(n-i>=0){
			ans+=((rui[n]-rui[n-i])-(rui[i-1])+1);
			ans%=MOD;
		}
		else{
			ans++;
		}
	}
	

	cout<<ans%MOD<<endl;

}

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


Measured memory_bytes: 4788
#include <iostream>
#include <vector>

long long pow(long long a,long long b,long long mod){
 if(b==0){
  return 1;
 }else{
  long long tmp=a;
  a*=a;
  a%=mod;
  if(b%2==0){
   return pow(a,b/2,mod);
  }else{
   return (pow(a,b/2,mod)*tmp)%mod;
  }
 }
}

long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a%b, y, x);
    y -= a/b * x;
    return d;
}

int main(){
 long long N,M,K;
 std::cin>>N>>M>>K;
 long long mod=998244353;
 //long long mod=1000000007;

 long long ans=(pow(M-1,N-1,mod)*M)%mod;
 long long cur=1;
 long long prod=1;
 for(int i=1;i<=K;i++){
  if(N-i>0){
   cur=pow(M-1,N-1-i,mod);
   cur*=M;
   cur%=mod;
   prod*=(N-i);
   prod%=mod;
   long long x,y;
   extGCD(i,mod,x,y);
   x=(x%mod+mod)%mod;
   prod*=x;
   prod%=mod;
   cur*=prod;
   cur%=mod;
   ans+=cur;
   ans%=mod;
  }else{
   break;
  }
 }
 
 std::cout<<ans<<std::endl;
 return 0;
}

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

int main(){
  int n;
  cin >>n;
  vector<int> a(n);
  rep(i,n) cin >>a[i];
  int cnt = 0;
  bool can = true;
  while(true){
    rep(i,n){
      if(a[i]%2!=0) {
        can = false;
      }
    }
    if(!can) break;
    rep(i,n) {
      a[i] /= 2;
    }
    cnt++;
  }
  cout << cnt << endl;
  return 0;
}


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


int main(){
  int w[10],k[10];
  int wmax1=0,wmax2=0,wmax3=0,kmax1=0,kmax2=0,kmax3=0;
  int wtotal=0,ktotal=0;
  for(int i=0;i<10;i++){
    cin>>w[i];
  }
  for(int i=0;i<10;i++){
    cin>>k[i];
  }
  for(int j=0;j<10;j++){
    if(wmax1<w[j]){
      wmax3=wmax2;
      wmax2=wmax1;
      wmax1=w[j];
    }else if(wmax2<w[j]){
      wmax3=wmax2;
      wmax2=w[j];
    }else if(wmax3<w[j]){
      wmax3=w[j];
    }
  }
  for(int j=0;j<10;j++){
    if(kmax1<k[j]){
      kmax3=kmax2;
      kmax2=kmax1;
      kmax1=k[j];
    }else if(kmax2<k[j]){
      kmax3=kmax2;
      kmax2=k[j];
    }else if(kmax3<k[j]){
      kmax3=k[j];
    }
  }
  wtotal=wmax1+wmax2+wmax3;
  ktotal=kmax1+kmax2+kmax3;
  cout<<wtotal<<" "<<ktotal<<endl;

  return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<algorithm>
#include<functional>
#include<vector>
using namespace std;
int main(void)
{
	int examnum;
	long long int ability[100000];
	long long int necessary[100000];
	long long int mergin[100000];
	cin>>examnum;
	for(int i=0;i<examnum;i++)
	{
		cin>>ability[i];
	}
	int merginindex=0;
	long long int husai=0;
	int mainasu=0;
	for(int i=0;i<examnum;i++)
	{
		cin>>necessary[i];
		if(ability[i]==necessary[i]){}
		else if(ability[i]>necessary[i]){
			mergin[merginindex]=ability[i]-necessary[i];
		merginindex++;
		}else{
		husai+=(-ability[i]+necessary[i]);
		mainasu++;
		}
	}
	if(merginindex>0)
	sort(mergin,mergin+merginindex,greater<long long int>());
	
	int counter=0;
	for(int i=0;i<merginindex&&husai>0;i++)
	{
		husai-=mergin[i];
		counter++;
	}
	counter+=mainasu;
	if(counter>=0&&husai<=0)cout<<counter;
	else cout<<-1;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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; }

struct UnionFind {
   vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

   UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化，自分自身が根とする
       for(int i = 0; i < N; i++) par[i] = i;
   }

   int root(int x) { // データxの根を再帰で得る：root(x) = {xの木の根}
       if (par[x] == x) return x;
       return par[x] = root(par[x]);
   }

   void unite(int x, int y) { // xとyの木を併合
       int rx = root(x); //xの根をrx
       int ry = root(y); //yの根をry
       if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
       par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
   }

   bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
       int rx = root(x);
       int ry = root(y);
       return rx == ry;
   }
};

int main(int argc, char const *argv[]) {
  int n,m;
  cin >> n >> m;
  vector<int> x(m),y(m),z(m);
  rep(i,m){
    cin >> x[i] >> y[i] >> z[i];
    x[i]--,y[i]--,z[i]--;
  }

  UnionFind uf(n);
  rep(i,m) uf.unite(x[i],y[i]);
  set<int> set;
  rep(i,n) set.insert(uf.root(i));
  cout << set.size() << endl;
    
  return 0;
}


Measured memory_bytes: 6400
// default code for competitive programming
// ver 3.1415 {{{

// Includes
#include <bits/stdc++.h>

// Defines
#define NAME(x) #x
#define SZ(c) (int)(c).size()
#define ALL(c) (c).begin(), (c).end()
#define FOR(i, e) for( int i = 0 ; i < (e) ; i++ )
#define ITER(it, c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define REP(i, s, e) for(int i = (s); i <= (e); i++)
#define REPD(i, s, e) for(int i = (s); i >= (e); i--)
#define IOS ios_base::sync_with_stdio( 0 )
#define DEBUG 1
#define fst first
#define snd second
#define PB push_back
#ifdef ONLINE_JUDGE
#define FILE( fn ) \
    freopen(fn".in","r",stdin); \
    freopen(fn".out","w",stdout);
#else
#define FILE( fn )
#endif

#ifdef AKAI
#define debug( ... ) fprintf( stderr , __VA_ARGS__ )
#else
#define debug( ... )
#endif

using namespace std;

// Typedefs
typedef double real;
typedef long long ll;
typedef pair<ll, int> pli;
typedef tuple<ll, int> tli;
typedef pair<int, int> pii;
typedef tuple<int, int> tii;
typedef unsigned long long ull;

// Some common const.
const double EPS = 1e-8;
const double Pi = acos(-1);

// Equal for double
bool inline equ(double a, double b)
{return fabs(a - b) < EPS;}

int _R( int& x ) { return scanf( "%d" , &x ); }
int _R( ll& x ) { return scanf( "%" PRId64 , &x ); }
int _R( double& x ) { return scanf( "%lf" , &x ); }
int _R( char* s ) { return scanf( "%s" , s ); }

int R() { return 0; }

template< typename T1 , typename... T2 >
int R( T1& x , T2&... tail )
{
  int tmp = _R( x );
  return tmp + R( tail... );
}

template< typename Iter , typename F >
inline void out( Iter s , Iter e , F of )
{
  bool flag = 0;
  for( Iter it = s ; it != e ; it++ )
  {
    if( flag ) printf( " " );
    else flag = 1;
    of( *it );
  }
  puts( "" );
}

// }}}
// start ~~QAQ~~

int main() {
  ll A , B , C;
  R( A , B , C );
  ll dC = abs( A*B*(C/2-C+C/2) );
  ll dB = abs( A*C*(B/2-B+B/2) );
  ll dA = abs( C*B*(A/2-A+A/2) );
  printf( "%lld\n" , min( dC , min( dB , dA ) ) );
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REP3(i,st,en) for(ll (i)=(st);(i)<(en);(i)++)

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long double a, b, c;
  cin >> a >> b >> c;
  long double n = 2;
  cout << ((n*sqrtl(a*b) < (c-a-b)) ? "Yes" : "No") << "\n";
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")
#pragma GCC optimize("Os")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(int i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcountll(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
using namespace std;
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
void vok()
{
    FAST
    FO
    FI
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
}
int main()
{
    vok();
    int x,y;
    IN x>>y;
    if(((4*x)-y)%2==0 && ((4*x)-y)/2<=x && ((4*x)-y)/2>=0)
    {
        OUT "Yes"<<endl
    }
    else
    {
        OUT "No"<<endl
    }
    return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<string>
#include<stack>
#include<vector>
#include<algorithm>
#include<cmath>
#include<functional>

using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	vector<int>xs, ys, xc, yc;
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		xs.push_back(x); ys.push_back(y);
	}
	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		xc.push_back(x); yc.push_back(y);
	}
	vector<int>ans(n);
	for (int i = 0; i < n; i++) {
		int min = 1000000000;
		for (int j = 0; j < m; j++) {
			if (abs(xs[i] - xc[j]) + abs(ys[i] - yc[j]) < min) {
				min = abs(xs[i] - xc[j]) + abs(ys[i] - yc[j]);
				ans[i] = j+1;
			}
		}
	}
	for (auto a : ans) {
		cout << a << endl;
	}
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

void swap(int *, int *);

int main(void) 
{
	int w, n, a, b;
	int i, j;
	int *lots;

	scanf("%d", &w);
	scanf(" %d", &n);

	lots = (int *) malloc(sizeof(int) * w);

	for (i = 0; i < w; i++) 
		lots[i] = i + 1;

	for (i = 0; i < n; i++) {
		scanf("%d,%d", &a, &b);
		swap(&lots[a - 1], &lots[b - 1]);
	}

	for (i = 0; i < w; i++) 
		printf("%d\n", lots[i]);

	return 0;
}

void swap(int *x, int *y) 
{
	int tmp;

	tmp = *x;
	*x  = *y;
	*y  = tmp;
}

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

int main(){
  int n;
  cin >>n;
  int sum=100000;
  int interest;
  for(int i =1 ; i<=n;i++){
    interest=sum*0.05;
    if (interest%1000>0)
    interest=(interest-interest%1000) + 1000;

    sum+= interest;
  }
  cout << sum<<endl;;
}



Measured memory_bytes: 2996
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int a[10],b[10],num[10];
int main()
{  int n;
    cin>>n;
    for(int i=0;i<n;i++)
      {
          cin>>a[i];
          num[i]=i+1;
      }
      int c=0;
      for(int i=0;i<n;i++)
      cin>>b[i];
      int ansa=0,ansb=0;
      do{
          c++;
          bool fa=1,fb=1;
          for(int i=0;i<n;i++)
           {
               if(a[i]!=num[i])
                 {fa=0;}
               if(b[i]!=num[i])
                 { fb=0; }
           }
           if(fa==1)
             {ansa=c;}
             if(fb==1)
             {ansb=c;}
      }while(next_permutation(num,num+n));
    cout<<abs(ansa-ansb);
    
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end()
using namespace std;

int main() {
long long int X;cin >> X;
bool C = 0;

for(long long int A = -200; A < 200; A++){
for(long long int B = -200; B < 200; B++){

if(pow(A, 5) - pow(B, 5) == X){cout << A << " " << B;C = 1;}

}if(C)break;}
}

Measured memory_bytes: 4012
K = int(input())

dp = [[str(i)] for i in range(1, 10)]
count = 9

ansFlag = False
while (True):
    if K <= 9:
        break
    for i in range(9):
        numList = dp[i]
        newNumList = []
        for n in numList:
            lastNum = n[-1]
            if int(lastNum) >= 1:
                newNum1 = str(n) + str(int(lastNum) - 1)
                count += 1
                newNumList.append(newNum1)
                if count == K:
                    ansFlag = True
                    break

            newNum2 = str(n) + str(int(lastNum))
            count += 1
            newNumList.append(newNum2)
            if count == K:
                ansFlag = True
                break

            if int(lastNum) <= 8:
                newNum3 = str(n) + str(int(lastNum) + 1)
                count += 1
                newNumList.append(newNum3)
                if count == K:
                    ansFlag = True
                    break
        if ansFlag:
            break
        dp[i] = newNumList
    if ansFlag:
        break

ans = K
if K >= 10:
    ans = newNumList[-1]

print(ans)





Measured memory_bytes: 46680
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	string s;
	cin>>s;
	int a = 0;
	for(auto c: s) a += c-'0';
	cout<<a<<endl;
	return 0;
}


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

using namespace std;

int main(){
  long long num1, num2;
  cin>> num1>> num2;
  int sum = (num1+num2)/2;
  if(abs(num1-sum) == abs(num2-sum)){
   cout<<abs(sum)<<endl;
}else{
   cout<<"IMPOSSIBLE"<<endl;
}
}

Measured memory_bytes: 256
# -*- coding:utf-8 -*-

if __name__ == '__main__':

	N = int(raw_input())

	for i in range(0,N):

		a, b, c = raw_input().split()
		triangle = [int(a),int(b),int(c)]
		triangle.sort()
		
		if(triangle[2]**2 == triangle[0]**2 + triangle[1]**2):
			print 'YES'
		else :
			print 'NO'

Measured memory_bytes: 4236
"use strict";
const Main = (input) =>{
   let xs = input.trim().split(' ');
   let a = xs[0] - xs[1];
   let b = xs[2] - a;
   if(b <= 0){
   console.log(0);
   }else{
   console.log(b);
   }

}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

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

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define RREP(i,a) for(int i = a;i >= 0;i--)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define rrep(i,n) for(int i = n - 1;i >= 0;i--)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
#define range(x,min,max) ((min) <= (x) && (x) <= (max))
#define xyrange(x, minX, maxX, y, minY, maxY) (range(x, minX, maxX) && range(y, minY, maxY))

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef pair<int,int> PII;
typedef vector<PII> VPII;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};
const int INF = 0x3f3f3f3f;

int N;
string s;

string sim(string init_s) {
	string res = init_s;
	REP (i, 1, s.size() - 1) {
		if (res[i] == 'S' && s[i] == 'o') {
			res += res[i - 1];
		} else if (res[i] == 'S' && s[i] == 'x') {
			res += (res[i - 1] == 'S'? 'W' : 'S');
		} else if (res[i] == 'W' && s[i] == 'o') {
			res += (res[i - 1] == 'S'? 'W' : 'S');
		} else {
			res += res[i - 1];
		}
	}
	return res;
}

string solve() {
	s = s[s.size() - 1] + s;
	s += s[1];
	VS pats;
	pats.pb(sim("SS"));
	pats.pb(sim("WS"));
	pats.pb(sim("SW"));
	pats.pb(sim("WW"));
	for (auto& pat : pats) {
		if (pat[1] == pat[pat.size() - 1] && pat[0] == pat[pat.size() - 2]) return pat.substr(1, pat.size() - 2);
	}
	return "NA";
}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	cin >> N >> s;
	string ans = solve();
	if (ans == "NA") {
		cout << -1 << endl;
	} else {
		cout << ans << endl;
	}
	return 0;
}



Measured memory_bytes: 1004
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
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; }


map<int,int> m;
int maxsum;
ll ans1,ans2;

int main() {
  int N;
  scanf("%d", &N);
  ll a[N];
  for (int i = 0; i < N; ++i) {
    scanf("%lld", &a[i]);
  }

  sort(a,a+N,greater<ll>());

  int ref = 0;
  bool side1 = false;
  bool side2 = false;
  while(ref<=N-2 && side1 == false){
    if(a[ref]==a[ref+1]){
      ans1 = a[ref];
      side1 = true;
      ref += 2;
    }
    else ref++;
  }
  while(ref<=N-2 && side2 == false){
    if(a[ref]==a[ref+1]){
      ans2 = a[ref];
      side2 = true;
    }
    else ref++;
  }

  cout << ans1 * ans2 << endl;



  

  

}



Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h> //function atoi reader
#include<string.h>
#define N 2
int main(){
  int x[98],i = 0,j = 0,n[100],sum;
  char s[100];
 
  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
    n[i - 2] = n[i - 2] + n[i - 1];
    i--;
     
 
    } else if ( s[0] == '-' ){
    n[i - 2] = n[i - 2] - n[i - 1];
    i--;
 
    } else if ( s[0] == '*' ){
    n[i - 2] = n[i - 2] * n[i - 1];
    i--;
     
 
    } else {
      n[i] = atoi(s);
    i++;
 
    }
  }
 
printf("%d\n",n[0]);
  return 0;
}

Measured memory_bytes: 548
#include"bits/stdc++.h"
using namespace std;
#define ll long long
#define LL long long
#define MOD 1000000007
ll N, M, K,H,W, ans, mi1,mi2,sum;
string s;
int main() {
	cin >> N;
	vector<LL> A(N),B(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		B[i] = A[i];
	}
	sort(A.begin(), A.end());
	for (int i = 0; i < N; i++) {
		if (B[i] == A[N - 1]) {
			cout << A[N - 2] << endl;
		}
		else {
			cout << A[N - 1] << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 4736
//   Rishabh Agarwal
#include <bits/stdc++.h>
#define F first
#define S second
#define MAX 10000003
using namespace std;

typedef long long int ll;
const ll mod = 1e17;
long double PI=3.1415926;

ll power(ll a,ll b){
    if(b==0){
        return 1;
    }
    ll temp=power(a,b/2)%mod;
    if(b%2==0){
        return (temp*temp)%mod;
    }
    else{
        return ((a*temp)%mod*temp)%mod;
    }
}

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

//vector<ll>v;
//vector<ll>::iterator it;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int T;
    T=1;
    //cin>>T;
    while(T--){
    	ll n,i;
    	cin>>n;
    	ll a[n+1];
    	for(i=0;i<n+1;i++)
    	{
    		cin>>a[i];
		}
		ll b[n+1];
		b[n]=a[n];
		for(i=n-1;i>=0;i--)
		{
			b[i]=b[i+1]+a[i];
		}
		ll c[n+1];
		c[0]=1;
		for(i=1;i<n+1;i++)
		{
			c[i]=min(b[i],2*(c[i-1]-a[i-1]));
		}
		int x=1;
		ll ans=0;
		for(i=0;i<n+1;i++)
		{
			if(c[i]<a[i])
			{
				x=0;
				
			}
			ans+=c[i];
		}
		if(x==0)
		{
			cout<<-1<<"\n";
		}
		else
		{
			cout<<ans;
		}

    }
    return 0;
}


Measured memory_bytes: 5948
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
int n,m;
vector<int>g[100005],g2[100005];
int S,T;
int dist[100005][3];
void run(){
	queue<pair<int,int> >q;
	q.push(make_pair(S,0));
	memset(dist,inf,sizeof dist);
	dist[S][0]=0;
	while(!q.empty()){
		pair<int,int>x=q.front();q.pop();
		for(auto to:g[x.first]){
			int cost=x.second%3==2?1:0;
			int nxt=(x.second+1)%3;
			if(dist[to][nxt]>dist[x.first][x.second]){
				dist[to][nxt]=dist[x.first][x.second]+cost;
				q.push(make_pair(to,nxt));
			}
		}
	}
	cout<<((dist[T][0]==inf)?-1:dist[T][0])<<endl;
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		int a,b;
		cin>>a>>b;
		g[a].push_back(b);
		g2[b].push_back(a);
	}
	cin>>S>>T;
	run();
	return 0;
}

Measured memory_bytes: 12416
#include <bits/stdc++.h>
#define sz(v) (int)v.size()
#define v(x) vector<x>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

const int INF = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    vector<int> x(n);
    for(auto &i : x){
        cin >> i;
    }
    int ans = INF;
    for(int i = 0; i <= 100; i++) {
        int sump = 0;
        for(auto j : x) {
            sump += (j - i) * (j - i);
        }
        ans = min(ans, sump);
    }
    cout<<ans;
}

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

using namespace std;

bool seen = false;
int n;
int ans = 0;
char c[212123];
int w[212123];
int b[212123];

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> c[i];
    }
    for (int i = 0; i < n; i++) {
        w[i+1] = w[i] + (c[i] == '#');
    }
    for (int i = n; i; i--) {
        b[i-1] = b[i] + (c[i] == '.');
    }
    ans = n;
    for (int i = 0; i <= n; i++) {
        //cout << w[i] << ' ' << b[i] << '\n';
        ans = min(ans, w[i] + b[i]);
    }
    cout << ans << '\n';
    return 0;
}



Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
int main() {
  int64_t n,m,k,c=-2,d=-2,i,j,l,ans;
  cin>>n>>m>>k;
  vector<int64_t> a(n),b(m);
  for(i=0;i<n;i++){
    cin>>a.at(i);
    if(i>0) a.at(i)+=a.at(i-1);
    if(a.at(i)>k && c==-2) c=i-1;
  }
  if(c==-2) c=n-1;
  for(i=0;i<m;i++){
    cin>>b.at(i);
    if(i>0) b.at(i)+=b.at(i-1);
    if(b.at(i)>k && d==-2) d=i-1;
  }
  if(d==-2) d=m-1;
  ans=c+1;
  l=0;
  for(i=c;i>=0;i--){
    for(j=l;j<=d;j++) if(a.at(i)+b.at(j)>k) break;
    if(ans<i+1+j) ans=i+1+j;
    if(j>0) l=j-1;
  }
  ans=max(ans,d+1);
  cout<<ans<<endl;
}

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

int main(){
    int N,M;
    cin >> N >> M ;
    int day = 0 , v;
    rep(i,M) {
        cin >> v;
        day += v ;
    }
    if(day > N) cout << -1 << endl;
    else cout << N - day << endl ;
}

Measured memory_bytes: 3636
N, M = map(int, input().split())
x = list(map(int, input().split()))
x = list(sorted(x))
d = [x1 - x0 for x1, x0 in zip(x[1:], x)]
d = list(sorted(d))

ans = 0
for i in range(M - N): # (M - 1) - (N - 1)
    ans += d[i]
print(ans)


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

int X,Y;
vector<vector<int>> s;

int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
using P = pair<int,int>;

int solve(int y, int x, set<P> st){
    if((int)st.size() > 10) return INF;
    int res = INF;
    rep(k,4){
        int d = 1;
        while(true){
            int ny = y+d*dy[k], nx = x+d*dx[k];
            if(!(ny>=0 && nx>=0 && ny<Y && nx<X)) break;
            if(s[ny][nx] == 3) return st.size();
            if(s[ny][nx] == 1 && st.count({ny,nx})==0){
                if(d > 1){
                    st.insert({ny,nx});
                    res = min(solve(ny-dy[k],nx-dx[k],st),res);
                    st.erase({ny,nx});
                }
                break;
            }
            d++;
        }
    }
    return res;
}

int main(void){
    while(cin>>X>>Y, X|Y){
        s.clear(); s.resize(Y);
        int sy=0,sx=0;
        rep(y,Y){
            s[y].resize(X);
            rep(x,X){
                cin>>s[y][x];
                if(s[y][x] == 2) sy = y, sx = x;
            }
        }
        int res = solve(sy,sx,{{sy,sx}});
        cout<<(res>10 ? -1 : res)<<endl;
    }
    return 0;
}



Measured memory_bytes: 3024
#重複なし
q = int(input( ))
st = set()
for i in range(q):
    cmmd,tx = map(int, input().split( ))
    if cmmd == 0:
        st.add(tx) 
        print(len(st)) 
    else:
        if tx in st:
            print(1)
        else:
            print(0)
        


Measured memory_bytes: 23360
#ifndef BZ
#ifndef __clang__
#pragma GCC optimize "-O3"
#endif
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

const int MAXN = 100;

int a[MAXN];
int n;


int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	int mn = *min_element(a, a + n);
	int mx = *max_element(a, a + n);
	vector<pair<int, int>> ans;
	if (abs(mn) > abs(mx)) {
		int pos = min_element(a, a + n) - a;
		for (int i = 0; i < n; ++i)
			if (a[i] > 0)
				ans.emplace_back(pos, i);
		for (int i = n - 2; i >= 0; --i)
			ans.emplace_back(i + 1, i);
	}
	else {
		int pos = max_element(a, a + n) - a;
		for (int i = 0; i < n; ++i)
			if (a[i] < 0)
				ans.emplace_back(pos, i);
		for (int i = 1; i < n; ++i)
			ans.emplace_back(i - 1, i);
	}
	cout << ans.size() << "\n";
	for (auto e: ans)
		cout << e.first + 1 << " " << e.second + 1 << "\n";
	return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<algorithm>
typedef long long ll;
#define INF 100000000000000
using namespace std;

int main() {
	ll a[10001];
	a[0] = 0;
	int b, c;
	scanf("%d%d", &b, &c);
	for (int d = 1; d <= b * 100; d++) {
		a[d] = INF;
	}
	for (int e = 0; e < b; e++) {
		int f, g;
		scanf("%d%d", &f, &g);
		for (int h = b * 100; h >= f; h--) {
			a[h] = min(a[h], a[h - f] + g);
		}
	}
	int s = 0;
	for (int i = 0; i <= b * 100; i++) {
		if (a[i] <= c)s = i;
	}
	printf("%d\n", s);
}

Measured memory_bytes: 3256
if __name__ == '__main__':
    N, M = map(int, input().split())
    # k1 s11, s12, s13, ..., s1k1
    KS_list = [list(map(int, input().split())) for i in range(M)]
    P_list = list(map(int, input().split()))

    answer = 0
    for i in range(2**N):
        pattern = str(bin(i)).replace('0b','').zfill(N)
        is_all_light_on = True
        for j in range(M):
            KS_j = KS_list[j]
                # list(map(int, KS_list[j].split()))
            K_j = KS_j[0]
            S_j = KS_j[1::]

            on_switch_cnt = 0
            for s in S_j:
                if pattern[s-1] == '1':
                    on_switch_cnt += 1

            if on_switch_cnt%2 != P_list[j]:
                is_all_light_on = False

        if is_all_light_on == True:
            answer += 1
    print(answer)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;

int main()
{
  string s, t;
  cin >> s >> t;
  int a,b;
  cin >> a >> b;
  string u;
  cin >> u;
  if(s==u){
    a--;
  }else b--;
  printf("%d %d", a,b);

}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long n = in.nextLong();
            for (long i = 0; i <= 100000; i++) {
                if (i * i > n) {
                    out.println((i - 1) * (i - 1));
                    return;
                }
            }
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

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

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
int main(){
    char s;
    cin >> s;
    if(s == 'a' || s == 'i' || s == 'u' || s == 'e' || s == 'o') cout << "vowel" << endl;
    else cout << "consonant" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <math.h>
#include <map>
#include <unordered_map>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define ci(x) cin >>x
#define co(x) cout<<x<<endl
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
long long fac(ll a) {
 long long ans=1;
 while(a>1){
 ans*=a;
 ans%=1000000007;
     a--;
    }
    return ans;
     }
int main() {
  ll A;
  ll B;
  cin >>A>>B;
  double a1=(double)A/(double)0.08;
   double a2=(double)(A+1)/(double)0.08;
   double b1=(double)B/(double)0.10;
   double b2=(double)(B+1)/(double)0.10;
  ll z=0;
repl(i,1,2000) {
  if((a1<=i) &&(i<a2) &&(b1<=i) &&(i<b2)) {
    cout <<i<<endl;
    z=1;
    break;
  }
  else {
    continue;
  }
}
  
 
  if(z==0) {
cout<<-1<<endl;
  }
  
  
}
    
    
    
 

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

int main(){
  string s;
  cin >> s;
  string t;
  for ( int i = s.length()-1; i >= 0; i--){
    string tt = "";
    tt += s[i];
    tt += t;
    t = tt;
    if ( t == "dream" || t == "dreamer" || t == "erase" || t == "eraser"){
      t = "";
    }
  }
  if ( t == ""){
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int main(void)
{
  int n = 0;
  int i = 0;
  long a[10000] = {0};
  long min = 1000001;
  long max = -1000001;
  long sum = 0;

  scanf("%d", &n);

  for(i = 0; i < n; i++)
    scanf("%ld", &a[i]);

  for(i = 0; i < n; i++){
    if(a[i] > max)
      max = a[i];
    
    if(a[i] < min)
      min = a[i];

    sum += a[i];
  } 

  printf("%ld %ld %ld\n", min, max, sum);
  
  return 0;
}

Measured memory_bytes: 2824
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,x;
    char y;
    vector<int> s(13,0);
    vector<int> h(13,0);
    vector<int> c(13,0);
    vector<int> d(13,0);
    scanf("%d", &n);
    for(int i=1;i<=n;i++){
        cin >> y >> x;
        if(y=='S')s[x]=x;
        else if(y=='H')h[x]=x;
        else if(y=='C')c[x]=x;
        else if(y=='D')d[x]=x;
    }
    for(int i=1;i<=13;i++){
        if(s[i] == 0) cout << 'S' << " " << i << endl;
    }
    for(int i=1;i<=13;i++){
        if(h[i] == 0) cout << 'H' << " " << i << endl;
    }   
    for(int i=1;i<=13;i++){
        if(c[i] == 0) cout << 'C' << " " << i << endl;
    }    
    for(int i=1;i<=13;i++){
        if(d[i] == 0) cout << 'D' << " " << i << endl;
    }
    return 0;
}


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

int main(){
    int n,k;cin>>n>>k;
    string s;cin>>s;
    vector<int> v;
    for(int i=0;i<n;){
        int cnt=0;
        char c=s[i];
        while(c==s[i]){
            cnt++;
            i++;
        }
        v.push_back(cnt);
    }
    if((int)v.size()<=2*k+1){
        cout<<n-1<<endl;
        return 0;
    }
    int sum=0;
    for(int i=0;i<=2*k;i++){
        sum+=v[i];
    }
    int ans=sum-1;
    for(int i=2*k+1;i<(int)v.size();i++){
        ans+=v[i]-1;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1020
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    int N;
    string s, T1, T2;
    cin >> N;
    cin >> s;
    T1 = s.substr(0,N/2);
    T2 = s.substr(N/2,N/2);
    if (T1.compare(T2) == 0 && N%2 == 0)
        cout << "Yes\n";
    else
        cout << "No\n";
}


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

Measured memory_bytes: 128
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
#include<cctype>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iomanip>
#include<sstream>
#include<cstdlib>
#include<ctime>
#include<list>
#include<deque>
#include<bitset>
#include<fstream>
#define ld double
#define ull unsigned long long 
#define ll long long 
#define pii pair<int,int >
#define iiii pair<int,pii >
#define mp make_pair 
#define INF 1000000000
#define MOD 1000000007 
#define rep(i,x) for(int (i)=0;(i)<(x);(i)++)
inline int getint()
{
	int x=0,p=1;char c;
	c=getchar();
	while (c<=32)c=getchar();
	if(c==45)p=-p,c=getchar();
	while (c>32)x=x*10+c-48,c=getchar();
	return x*p;
}
using namespace std;
//
const int maxn=1e5+5;
int n,par[maxn];
ll res;
vector<pii >Sx,Sy;
vector<iiii >E;
//
void finit()
{
	rep(i,n)par[i]=i;
}
int fF(int x)
{
	if(par[x]==x)return x;
	return par[x]=fF(par[x]);
}
bool fU(int x,int y)
{
	x=fF(x);y=fF(y);
	if(x==y)return false;
	par[x]=y;
	return true;
}
int main()
{
	n=getint();
	rep(i,n)
	{
		int x=getint(),y=getint();
		Sx.push_back(mp(x,i));
		Sy.push_back(mp(y,i));
	}
	sort(Sx.begin(),Sx.end());
	sort(Sy.begin(),Sy.end());
	rep(i,n-1)
	{
		E.push_back(mp(abs(Sy[i+1].first-Sy[i].first),mp(Sy[i].second,Sy[i+1].second)));
		E.push_back(mp(abs(Sx[i+1].first-Sx[i].first),mp(Sx[i].second,Sx[i+1].second)));
	}
	sort(E.begin(),E.end());
	finit();
	rep(i,E.size())
	{
		ll len=1ll*E[i].first;
		int x=E[i].second.first,y=E[i].second.second;
		if(fU(x,y))res+=len;
	}
	printf("%lld\n",res);
	return 0;	
} 

Measured memory_bytes: 7144
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

string s;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> s;
    int bs = 0;
    ll ans = 0;
    for(auto &i : s){
        if(i == 'W') ans += bs;
        else bs++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 720
N, K = map(int, input().split())
l = []
i = 0
for x in input().split():
    A = int(x)
    if K < N - i:
        l.insert(0, A)
    if i >= K:
        if l.pop() < A:
            print("Yes")
        else:
            print("No")
    i = i + 1


Measured memory_bytes: 94232
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))
n = int(input())
s = []
for _ in range(n):
    s.append(''.join(sorted(input())))
s.sort()
ans = 0
cnt = 0
for i in range(1, n):
    if s[i - 1] == s[i]:
        cnt += 1
    else:
        ans += (cnt * (cnt + 1) // 2)
        cnt = 0
else:
    ans += (cnt * (cnt + 1) // 2)
print(ans)

Measured memory_bytes: 12832
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){ return (int)s.size(); }

int main(){
    string s; cin >> s;
    ll k; cin >> k;
    rep(i,SIZE(s)){
        if(s[i] != '1'){
            cout << s[i] << endl;
            return 0;
        } else if(i+1 == k) break;
    }
    cout << 1 << endl;
    return 0;
}


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


int main(){
    int n;cin >> n;
    vector<vector<P>> G(n);
    rep(i,n){
        int a;cin >> a;
        rep(j,a){
            int x,y;cin >> x >> y;
            --x;
            G[i].push_back(make_pair(x,y));
        }
    }
    int ans = 0;
    rep(i,1<<n){
        vector<int> horu(n,-1);
        bool flag = true;
        int temp = 0;
        rep(j,n){
            if(i>>j&1) {
                horu[j] = 1;
            }else horu[j] = 0;
        }
        rep(j,n) if(horu[j]) for(P p:G[j]) if(horu[p.first]!=p.second) flag = false;
        if(flag) ans = max(ans,__builtin_popcount(i));
    }

    cout << ans << endl;
}

Measured memory_bytes: 3636
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり

N = I()
H = LI()
ans = 0
r = 0
for i in range(N):
    if H[i] >= r:
        ans += 1
        r = H[i]
print(ans)


Measured memory_bytes: 61912
def is_prime(n):
    for i in range(2, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            return False
    return n != 1

x = int(input())
k = x
while(True):
    if is_prime(k):
        print(k)
        break
    else:
        k += 1

Measured memory_bytes: 2940
#include <stdio.h>

int main()
{
    int a,b,i,x=0;

    scanf("%d %d" , &a, &b);

    for(i=0; i<2; i++)
    {
        if(a>b)
        {
            x=x+a;
            a=a-1;
            continue;
        }
        if(a<b)
        {
            x=x+b;
            b=b-1;
            continue;
        }
        if(a==b)
        {
            x=x+a;
            a=a-1;
            continue;
        }
    }

    printf("%d", x);

    return 0;

}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
int main(void){
    int P[5];
    int sum=0;
    int max=0;
    for(int i=0;i<5;i++){
        cin>>P[i];
        if(P[i]%10==0){
            sum+=P[i];
        }
        else{
            sum+=int(P[i]/10+1)*10;
            if(10-P[i]%10>max){
                max=10-P[i]%10;
            }
        }
    }
    cout<<sum-max<<endl;
}


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

bool eight(int N){
  int div=0;
  for(int i=1; i<=sqrt(N); i++){
    if (N%i==0) div+=2;
    if (N%i==0 && i*i==N) div++;
  }
  if (div==8) return true;
  else return false;
}

int main(){
  int N;
  cin >> N;
  
  int ans=0;
  for(int i=3; i<=N; i+=2){
    if (eight(i)) ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
//
//  main.cpp
//  CoderWork
//
//  Created by Minoru Hayashi on 2020/02/29.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//

#include <bits/stdc++.h>
using namespace std;

#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(n) begin(n), end(n)

using ll = long long;

template<class T> inline bool chmin(T& a, T b){ if(a>b){a=b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b){ if(a<b){a=b; return 1;} return 0;}

 const int INF = 1LL<<29;
// const ll MOD = 1000000007;

//#define __DBG__


void solve(void){

  int A, B, M;
  
  cin >> A >> B >> M;
  
  vector<int> a(A),b(B);
  map<string,int> Q;
  vector<tuple<int,int,int>> R;

  
  REP(i,A){
    cin >> a[i];
    a[i];
  }
  REP(i,B){
    cin >> b[i];
    b[i];
  }
  REP(i,M){
    int x,y,c;
    cin >> x >> y >> c;
    R.push_back(make_tuple(x,y,c));
  }
  
  vector<int> DP;
  
  REP(i,R.size()){
    DP.push_back(a[get<0>(R[i])-1]+b[get<1>(R[i])-1]-get<2>(R[i]));
  }
  
  sort(ALL(DP));
  
  sort(ALL(a));
  sort(ALL(b));
  
  if(a[0]+b[0]<DP[0]){
    cout << a[0]+b[0] << endl;
  }
  else
  {
    cout << DP[0] << endl;
  }
  
  return;
}

int main(int argc, const char * argv[]) {



    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);
  
    solve();
 
    return 0;
}



Measured memory_bytes: 3188