akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <string.h>
#define int long long

using namespace std;

int n,k,ans=0;

signed main()
{
	scanf("%lld%lld",&n,&k);
	for(int b=k+1;b<=n;b++)
	{
		for(int d=0;b*d+k<=n;d++)
		{
			ans+=min((d+1)*b-1,n)-max(b*d+k,1ll)+1;
		}
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>
#define mod  1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;

using ll = long long;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> X(M);
  for(int i = 0; i < M; i++) cin >> X[i];
  sort(all(X));
  vector<ll> cost;
  for(int i = 1; i < X.size(); i++){
    cost.push_back(X[i] - X[i - 1]);
  }
  sort(all(cost));
  ll ans = 0;
  for(int i = 0; i < max((int)cost.size() - N + 1, 0); i++) ans += cost[i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (long long i = 0, _n = (n); i < _n; i++)
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
int main () 
{
  int n;
    cin>>n;
    vi v(n);
    rep(i,n)cin>>v[i];
    vi dp(n+1,INT_MAX);
    dp[0]=0;
    dp[1]=0;
    dp[2]=abs(v[0]-v[1]);
    for(int i=3;i<=n;i++){
        dp[i]=min(dp[i-1]+abs(v[i-1]-v[i-2]),dp[i-2]+abs(v[i-1]-v[i-3]));
    }
    cout<<dp[n];
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>
#include <set>

using ll = long long;
using namespace std;
typedef unsigned long long ull;
typedef pair<ll, ll>P;

const ll MOD = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
string abc = "abcdefghijklmnopqrstuvwxyz";
struct edge { ll to, cost; };
struct etree { ll from, to, cost; };
struct people { ll v, k, year; };
bool comp(const etree& e1, const etree& e2) {
	return e1.cost < e2.cost;
}
bool comp2(const people& e1, const people& e2) {
	return e1.year < e2.year;
}
#define ALL(x) (x).begin(),(x).end()


int main() {
	int n, m, count[100010] = { 0 };
	cin >> n >> m;
	for (int i = 0;i < m;i++) {
		int a, b;
		cin >> a >> b;
		count[a - 1]++;
		count[b - 1]++;
	}
	for (int i = 0;i < n;i++) {
		if (count[i] % 2 == 1) {
			cout << "NO" << endl;
			exit(0);
		}
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;

using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int a;
  string s;
  cin>>a>>s;
  if(a>=3200){
    cout << s;
  }else cout <<"red";

  return 0;
}


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


int main() {
	int N;
	cin >> N;
	string Nstr = to_string(N);
	int sum = 0;
	for(int i = 0; i < Nstr.size(); i++){
		sum += Nstr[i] - '0';
	}
	if(N % sum == 0){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>
#define N 400086
#define ll long long
using namespace std;
int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
ll a[N];
int main(){
    int n=read();
    for(int i=1;i<=n;i++)a[i]=read()-i;
    int n1=0,n2=0,n0=0;
    sort(a+1,a+n+1);
    for(int i=1;i<=n;i++){
        if(a[i]>0)n1++;if(a[i]<0)n2++;if(a[i]==0)n0++;
    }
    if(n1>n2+n0){
        int now=0;
        for(int i=1;i<=n;i++)if(a[i]==0)now=i;
        if(!now)for(int i=1;i<=n;i++)if(a[i]>0){now=i-1;break;}
        int x=n1-n2-n0;
        if(x&1)x=x/2+1;else x=x/2;
        if(now+x>=n)now=n;else now=now+x;
        int tmp=a[now];
        for(int i=1;i<=n;i++)a[i]=a[i]-tmp;
    }
    if(n2>n1+n0){
        int now=0;
        for(int i=n;i;i--)if(a[i]==0)now=i;
        if(!now)for(int i=1;i<=n;i++)if(a[i]>0){now=i;break;}
        int x=n2-n1-n0;
        if(x&1)x=x/2+1;else x=x/2;
        if(now-x<=0)now=1;else now=now-x;
        int tmp=a[now];
        for(int i=1;i<=n;i++)a[i]=a[i]-tmp;
    }
    ll ans=0;
    for(int i=1;i<=n;i++)if(a[i]>0)ans+=a[i];else ans-=a[i];
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
typedef long long ll;
using namespace std;
int main(void){
int n,k;
  cin >> n >>k;
  int snake[60];
  for(int i=0;i<n;++i){
     cin >> snake[i];
  }
  int ans=0;
  std::sort(snake,snake+n,greater<int>());
  for(int i=0;i<k;i++){
     ans += snake[i];
  }
  cout << ans;
return 0;
}


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

#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

const int N = 1e6+5;
  
int f[N];
int cnt[N]; 
  
void sieve() 
{ 
    f[1] = 1; 
    for (int i=2; i < N; i++) 
        f[i] = i; 
  
    for (int i=4; i<N; i+=2) 
        f[i] = 2; 
  
    for (int i=3; i*i<N; i++) 
    { 
        if (f[i] == i) 
        { 
            for (int j=i*i; j<N; j+=i) 
  
                if (f[j]==j) 
                    f[j] = i; 
        } 
    } 
} 
bool ok = true;
void F(int x) 
{ 
	vector<int> res;
    while (x != 1) 
    { 
    	res.push_back(f[x]);
        x = x / f[x]; 
    }
   	for(auto p : res){
   		if(cnt[p]){
    		ok = false;
    	}
   	} 
   	for(auto p : res) cnt[p]++;
} 

void solve(){
	sieve();
	int n;
	cin >> n;
	int g;
	cin >> g;
	F(g);
	for(int i = 1, tmp;i < n;i++){
		cin >> tmp;
		g = gcd(g,tmp);
		F(tmp);
	}
	if(ok){
		cout << "pairwise coprime\n";
		return;
	}
	if(g==1){
		cout << "setwise coprime\n";
		return;
	}else{
		cout << "not coprime\n";
		return;
	}
}

signed main(){
	fastio
	int t = 1;
	//cin >> t;
	while(t--) solve();
}

Measured memory_bytes: 19200
# ===================================
# (c) MidAndFeed aka ASilentVoice
# ===================================
# import math 
# import collections
# import string
# ===================================
import numpy as np
n, k = [int(x) for x in input().split()]
q = np.array([int(x) for x in input().split()])
ans = np.zeros(n, dtype=int)

for i in range(1, n):
	start = max(0, i-k)
	ans[i] = min(ans[start:i] + np.abs(q[i] - q[start:i]))

print(ans[n-1])

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

vector<int> sam, ans;

int main()
{
	int n, x;
	cin >> n;
	for(int i = 0; i < n; i++) 
	{
		cin >> x;
		sam.push_back(x);
	}
	ans = sam;
	sort(ans.begin(), ans.end());
	int cen1 = ans[n/2-1], cen2 = ans[n/2];
	for(int i = 0; i < n; i++)
	{
		int cen = (sam[i] >= cen2) ? cen1:cen2;
		cout << cen << endl;
	}
	return 0;
}

Measured memory_bytes: 3828
use std::io;
use std::collections::HashMap;

fn read_line() -> String {
    let mut line = String::new();

    io::stdin().read_line(&mut line)
        .expect("Failed to read line");
    return line;
}
fn to_i(s: &str) -> i64 {
    return s.trim().parse()
        .expect("Please type a number!");
}
fn read_nums() -> Vec<i64>
{
    let line = read_line();
    let items: Vec<&str> = line.split(' ').collect();

    let mut nums: Vec<i64> = Vec::new();

    for item in items {
        nums.push(to_i(item));
    }
    return nums;
}


fn main() {
    //println!("start");
    let ab = read_nums();
    let a = ab[0];
    let b = ab[1];
    let ab = a+b;
    if ab%2 ==0 {
        let ret = ab/2;
        print!("{}", ret);
    }else {
        print!("IMPOSSIBLE");
    }
    
    
}   

Measured memory_bytes: 4352
var
  c:char;
  s:string;
  a,b:longint;
begin
  while not eof do
   begin
    read(c);
    if c<>'B' then s:=s+c;
    if(c='B')and(length(s)<>0)then
     delete(s,length(s),1);
   end;
  writeln(s);
end.

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
using namespace std;
using ll = long long;

int main() {
  int N;
  cin >> N;
  set<int> s;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    s.insert(a);
  }
  int res = (N % 2 == s.size() % 2 ? s.size() : s.size() - 1);
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 4992
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<iomanip>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)
// cout << setprecision(10)

using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

int N, K;
int main(void){
    cin >> N >> K;
    if(K > (N - 1)*(N - 2) / 2){
        cout << -1 << endl;
        return 0;
    }
    int M = (N-1) + ((N - 1)*(N - 2) / 2 - K);
    cout << M << endl;
    REP(i, N-1) cout << 1 << " " << i + 2 << endl;
    int count = 0;
    for (int i = 2;i <= N; i++){
        for (int j = i+1;j <= N;j++){
            if (count++ >= ((N - 1)*(N - 2) / 2 - K)) break;
            cout << i << " " << j << endl;
        }
        if (count >= ((N - 1)*(N - 2) / 2 - K)) break;
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

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

    string s; cin >> s;
    vector<int> A = {0,0,0};
    rep(i,s.size()) A[s[i] - 'a'] ++;
    int x = *min_element(A.begin(),A.end());
    rep(i,3) A[i] -= x;
    sort(A.begin(),A.end());
    if (A[2] == 0 || A[2] == 1) cout << "YES" << '\n';
    else cout << "NO" << '\n';
    return 0;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>    
using namespace std;
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define int long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define fone for(i=0;i<n;i++)
#define endl "\n"
const ll MOD     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N          = 5000*100+1;
const ll N2      = 1000*1000+5;
const ld PI  = 3.14159265;
const ll R   = 250;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;} 
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
    }


signed main ()
{
  fastio();
  int n;
  cin>>n;
  int a[N2];

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

  int i;
  int ans=0;
  int flag=0;
  int dp[n];
  fill(dp,0);
  dp[0]=0;
  dp[1]=abs(a[1]-a[0]);
  dp[2]=abs(a[2]-a[0]);
    for(int i=3;i<n;i++)
  {
    dp[i]=min(abs(a[i]-a[i-2])+dp[i-2],abs(a[i]-a[i-1])+dp[i-1]);
  }
  cout<<dp[n-1]<<endl;

return 0;
  
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define nd second
#define st first
#define pb push_back
#define pa make_pair

using namespace std;
typedef long long int lo;

lo a,b,c,d,e,g,h[500005],arr[500005];

int main(){
	// freopen("in.txt","r",stdin);
	// freopen("out.txt","w",stdout);
	cin >> a;
	for(lo i=1;i<=a;i++){
		cin >> arr[i];
	}
	bool ok=0;
	for(lo i=1;i<=a;i++){
		if(arr[i]!=i){
			if(ok==1 or arr[arr[i]]!=i){
				cout << "NO";
				return 0;
			}
			else if(arr[arr[i]]==i){
				swap(arr[i],arr[arr[i]]);
				ok=1;
			}
		}
	}
	cout << "YES";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
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;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o setconst ll MOD = 1e9+7;return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD;
template<typename T>
struct SegmentTree{
private:
    int n;
    vector<T> node;
public:
    T merge(T x,T y){
        return x|y;
    }
    SegmentTree(vector<T> v){
        int sz=(int)v.size();
        n=1; while(n<sz)n*=2;
        node.resize(2*n-1,0);
        for(int i=0;i<sz;i++) node[i+n-1]=v[i];
        for(int i=n-2;i>=0;i--){
            node[i]=merge(node[2*i+1],node[2*i+2]);
        }
    }
    void update(int x,T val){
        x+=(n-1);
        node[x]=val;
        while(x>0){
            x=(x-1)/2;
            node[x]=merge(node[2*x+1],node[2*x+2]);
        }
    }
    T query(int a,int b,int idx=0,int l=0,int r=-1){ /* get [a,b) */
        if(r<0) r=n;
        if(r<=a||b<=l) return 0;
        if(a<=l&&r<=b) return node[idx];
        T vl=query(a,b,2*idx+1,l,(l+r)/2);
        T vr=query(a,b,2*idx+2,(l+r)/2,r);
        return merge(vl,vr);
    };
};

signed main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n; string s;
    cin >> n >> s;
    vector<ll> v(n);
    rep(i,n){
        int x=s[i]-'a';
        v[i]=(1ull<<x);
    }
    SegmentTree<ll> seg(v);
    int q; cin >> q;
    rep(i,q){
        int b; cin >> b;
        if(b==1){
            int x; char c;
            cin >> x >> c;
            x--;
            int val=c-'a';
            seg.update(x,(1ull<<val));
        }else{
            int l,r; cin >> l >> r;
            l--;
            int ans=__builtin_popcount(seg.query(l,r));
            cout << ans << "\n";
        }
    }
}


Measured memory_bytes: 19856
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define fi first
#define se second
#define INF 1000000009
#define lINF 1000000000000000009
typedef long long ll;

int main(){
  string s;
  cin>>s;
  deque<char>d;
  rep(i,s.size()){
    d.push_back(s[i]);
  }

  int q;
  cin>>q;
  bool f=false;
  rep(i,q){
    int t;
    cin>>t;
    if(t==1){
      f=!f;
    }
    else{
      int r;
      char c;
      cin>>r>>c;
      r--;
      if((!r)^f){
        d.push_front(c);
      }
      else{
        d.push_back(c);
      }
    }
  }

  if(f)reverse(d.begin(),d.end());
  rep(i,d.size()){
    cout<<d[i];
  }
  cout<<endl;

  return(0);
}



Measured memory_bytes: 896
#include<iostream>
#include<cmath>
#include<iomanip>

int main(){
    double x1,x2,y1,y2;
    long double distance;

    std::cin>>x1>>y1>>x2>>y2;

    distance=sqrt(pow(x2-x1,2)+pow(y2-y1,2));

    std::cout<<std::fixed;
    std::cout<<std::setprecision(5)<<distance<<std::endl;

    return 0;
}



Measured memory_bytes: 3276
#include<stdio.h>
#include<stdlib.h>
int N,M,P,D[10005],i,p,q;
int cmp(int *a,int *b){return *a<*b;}
int cmp2(int *a,int *b){return *a>*b;}
int f(int a,int b){int t=abs(a-b);return t>N/2?N-t:t;}
int ch()
{
	int i,d,t,r=999999999;
	for(i=1,d=0;i<=M;i++)
	{
		d+=f(D[i],D[i-1]);
	}
	for(i=1;i<=M;i++)
	{
		t=d+f(P,D[i])-f(D[i],D[i-1]);
		r=r>t?t:r;
	}
	return r;
}
int main()
{
	scanf("%d%d%d",&N,&M,&P);
	for(i=0;i<M;i++)scanf("%d",D+i);
	qsort(D,M,sizeof(int),cmp);D[M]=D[0];
	p=ch();
	qsort(D,M,sizeof(int),cmp2);D[M]=D[0];
	q=ch();
	printf("%d\n",(p>q?q:p)*100);
	return 0;
}

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

using namespace std;

int main(){
    double n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    
    cout<<min(ceil(n/a)*b,ceil(n/c)*d)<<endl;
    
    return 0;
}


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

using namespace std;

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

    int n;
    cin >> n;
    int ac = 0, wa = 0, tle = 0, re = 0;
    for(int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        if(s == "AC")
            ac++;
        else if(s == "WA")
            wa++;
        else if(s == "TLE")
            tle++;
        else
            re++;
    }
    cout << "AC x " << ac << "\n";
    cout << "WA x " << wa << "\n";
    cout << "TLE x " << tle << "\n";
    cout << "RE x " << re << "\n";

    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
using namespace std;
char a[1010];
int len=0;
void reead()
{
	char ch=getchar();
	while(ch>='a'&&ch<='z')
	{
		a[len++]=ch;
		ch=getchar();
	}
}
int main()
{
	reead();
	len-=1;
	for(int i=0;i<=len;i++) printf("%c",a[i]);
	if(a[len]=='s') printf("es");
	else printf("s");
	return 0;
 } 

Measured memory_bytes: 3760
//#pragma GCC optimize("O3")
#ifdef ONPC
#include "bits/stdc++.h"
#else
#include <bits/stdc++.h>
#endif

using namespace std;

//defines
typedef long long ll;
typedef long double ld;
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define prev _prev
#define y0 y00
#define y1 y11

//permanent constants
const ld pi = acos(-1.0);
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int digarr[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
const int dxo[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dyo[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
const int dxk[8] = {-1, -2, -1, 2, -2, 1, 1, 2};
const int dyk[8] = {-2, -1, 2, -1, 1, -2, 2, 1};
const int alf = 26;
const int dig = 10;
const int two = 2;
const int th = 3;
const ll prost = 239;
const ll bt = 30;
const ld eps = 1e-8;
const ll INF = (ll)(1e18 + 239);
const ll BIG = (ll)(1e9 + 239);
const int MOD = 998244353;
const ll MOD2 = (ll)MOD * (ll)MOD;

//random
mt19937 rnd(239); //(chrono::high_resolution_clock::now().time_since_epoch().count());

//constants
const int M = (int)(2e5 + 239);
const int N = (int)(2e3 + 239);
const int L = 18;
const int T = (1 << 19);
const int B = (int)sqrt(M);
const int X = 1e4 + 239;

int dp[two][M];
string s;

int32_t main()
{
#ifdef ONPC
    freopen("input.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> s;
    int n = s.size();
    int l = 1;
    int p = 1;
    int ans = 1;
    while (p < n)
    {
        if (l == 2 || s[p] != s[p - 1])
        {
            ans++;
            l = 1;
            p++;
        }
        else
        {
            if (p + 1 == n)
                break;
            l = 2;
            p += 2;
            ans++;
        }
    }
    cout << ans;
    return 0;
}

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

double waterTemp(int t1, int v1, int t2, int v2){
	return (double)(t1*v1+t2*v2)/(v1+v2);	
}

int main(){
	int T,D,ta,tb,da,db;
	
	cin >> T >> D;
	cin >> ta >> tb;
	cin >> da >> db;
	
	double diff=100000;
	
	for(int i=0; i*da<=D; ++i){
		for(int j=0; i*da+j*db<=D; ++j){
			double tmp = waterTemp(ta,i*da,tb,j*db);
			double td = tmp-T;
			if(td<0) td=-td;
			
			if(td<diff) diff=td;
		}	
	}
	
	printf("%.10lf\n", diff);
}

Measured memory_bytes: 1196
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
int n,m,lp[100010],rp[100010],w[100010];
bool used[100010],vis[400040];
long long dis[100010];
vector<int>E[400040];
priority_queue<pair<long long,int> >q;
void add(int k,int l,int r,int ll,int rr,int id)
{
	if(l>rr||r<ll)return ;
	if(l>=ll&&r<=rr)return E[k].push_back(id),void();
	add(k<<1,l,l+r>>1,ll,rr,id);
	add(k<<1|1,(l+r>>1)+1,r,ll,rr,id);
}
int find(int k,int l,int r,int ll,int rr)
{
	if(l>rr||r<ll||vis[k])return 0;
	if(l==r)return vis[k]=1,l;
	int ret=0;
	if(ret=find(k<<1,l,l+r>>1,ll,rr))return vis[k]=vis[k<<1]&vis[k<<1|1],ret;
	if(ret=find(k<<1|1,(l+r>>1)+1,r,ll,rr))return vis[k]=vis[k<<1]&vis[k<<1|1],ret;
	vis[k]=vis[k<<1]&vis[k<<1|1];
	return 0;
}
void query(int k,int l,int r,int p)
{
	int x;
	for(auto u:E[k])
		if(!used[u])
		{
			used[u]=1;
			q.push(make_pair(-dis[p]-w[u],u));
		}
	E[k].clear();
	if(l==r)return ;
	if(p<=l+r>>1)query(k<<1,l,l+r>>1,p);
	else query(k<<1|1,(l+r>>1)+1,r,p);	
}
int main()
{
	scanf("%d %d",&n,&m);
	int x,y;
	for(int i=1;i<=m;++i)
	{
		scanf("%d %d %d",&lp[i],&rp[i],&w[i]);
		add(1,1,n,lp[i],rp[i],i);
	}
	query(1,1,n,1);
	find(1,1,n,1,1);
	while(!q.empty())
	{
		x=q.top().second;
	//	printf("%d\n",x);
		while(y=find(1,1,n,lp[x],rp[x]))dis[y]=-q.top().first,query(1,1,n,y);
		q.pop();
	}
	if(dis[n])printf("%lld",dis[n]);
	else printf("-1");
	return 0;
}


Measured memory_bytes: 24056
#include <stdio.h>

int main()
{
    int a,b;
    int c,d;
    while(1){
    scanf("%d %d",&a,&b);
    if(a==0 && b==0) return 0;
    for(c=0;c<a;c++)
    {
        for(d=1;d<=b;d++)
        {
            printf("#");
            if(d==b) printf("\n");
        }
    }
    printf("\n");
    }
    return 0;
}

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

int main() {
  string s;
  cin>>s;
  int n=s.size();
  int p=0;
  for(int i=0;i<n;i++){
    if(s.at(i)!=s.at(n-1-i)){
      p++;
    }
  }
  cout<<p/2<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  int H,W;
  cin>>H>>W;
  char temp;
  int S[H][W];
  for (int i=0;i<H;i++){
    for (int j=0;j<W;j++){
      cin>>temp;
      if(temp=='#') S[i][j]=1;
      else S[i][j]=0;
    }
  }
  bool can=true;
  for (int i=0;i<H;i++){
    for (int j=0;j<W;j++){
      bool can2=false;
      if (S[i][j]==1){
        if(i-1>=0 && S[i-1][j]==1) can2=true;
        if(i+1<H && S[i+1][j]==1) can2=true;
        if(j-1>=0 && S[i][j-1]==1) can2=true;
        if(j+1<W && S[i][j+1]==1) can2=true;
        if (can2==false) {
          can=false;
          i=100;j=100;
        }
      }
    }
  }
  if(can) cout<<"Yes";
  else cout<<"No";
  return 0;
}


Measured memory_bytes: 256
n, d = gets.split.map(&:to_i)

xs = []
n.times do |i|
  xs << gets.split.map(&:to_i)
end

cnt = 0
n.times do |i|
  (i+1).upto(n-1) do |j|
    dst = 0
    xs[i].zip(xs[j]) do |a, b|
      dst += (a - b) * (a - b)
    end

    cnt += 1 if (Math.sqrt(dst)).floor ** 2 == dst
  end
end

p cnt


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string A, B;
  cin >> A;
  B = A.at(A.size() - 1);
  if(B == "s"){
    A += "es";
  }
  else{
    A += "s";
  }
  cout << A << endl;
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
int cmp(const void *a, const void *b);
//your code here!

int main(void){
    ll A, B;
    scanf("%lld %lld", &A, &B);
    if(A==B) printf("Draw\n");
    else if(A>B){
        if(B==1)printf("Bob\n");
        else printf("Alice\n");
    }
    else{
        if(A==1) printf("Alice\n");
        else printf("Bob\n");
    }
    return 0;
}

int cmp(const void *a, const void *b){
    ll A=*(ll *)a, B=*(ll *)b;
    if(A==B)return 0;
    else return A>B ? 1:-1;//昇順ソート
}


Measured memory_bytes: 128
#include<stdio.h>

#define S 100003

int N;
char list[S];
char s[S];

char getInv(char c){
	if( c == 'S' ){
		return 'W';
	}
	return 'S';
}

void output(){
	int i;
	for( i = 1; i <= N; i++ ){ printf("%c", list[i]); }
	printf("\n");
	return;
}

/*
void say(){
	int r, i;
	const char Sans[2] = {'x', 'o'};
	const char Wans[2] = {'o', 'x'};
	list[0] = list[N];
	list[N+1] = list[1];
	for( i = 1; i <= N; i++ ){
		if( list[i-1] == list[i+1] ){
			r = 1;
		}else{
			r = 0;
		}
		if( list[i] == 'S' ){
			printf("%c", Sans[r]);
		}else{
			printf("%c", Wans[r]);
		}
	}
	printf("\n");
	return;
}
*/

int get(int i){
	int re = 0;
	if( i > N+1 ){
		if( list[1] == list[N+1] && list[2] == list[N+2] ){
			output();
			return 1;
		}
	}else if( i == 1 ){
		list[i+1] = 'S';
		re = get(i+1);
		if( re ){ return 1; }
		list[i+1] = 'W';
		re = get(i+1);
		if( re ){ return 1; }
	}else{
		if( list[i] == 'S' && s[i] == 'o' ){
			list[i+1] = list[i-1];
		}
		if( list[i] == 'S' && s[i] == 'x' ){
			list[i+1] = getInv(list[i-1]);
		}
		if( list[i] == 'W' && s[i] == 'o' ){
			list[i+1] = getInv(list[i-1]);
		}
		if( list[i] == 'W' && s[i] == 'x' ){
			list[i+1] = list[i-1];
		}
		re = get(i+1);
	}
	return re;
}

int main(){
	int i;
	scanf("%d\n", &N);
	for( i = 1; i <= N; i++ ){
		scanf("%c", &s[i]);
	}
	s[N+1] = s[1];
	list[1] = 'S';
	if( get(1) ){ return 0; }
	list[1] = 'W';
	if( get(1) ){ return 0; }
	printf("-1\n");
	return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};
const ll INF = 1001001001;

int main(){
    int A,B;
    cin >> A >> B;
    if(A>=1 && A<=9 && B>=1 && B<=9){
        cout << A*B << endl;
    }
    else{
        cout << -1 << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
//int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n;
int a[110];
int ans=0;

int main(){
	cin>>n;
	REP(i,n)
		cin>>a[i];
	
	for(int i=1;i<n;i++){
		if(a[i-1]==a[i]){
			ans++;
			a[i]=-1;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const long long INF = 1001001001;
const long long MOD = 1000000007;
const double EPS = 1e-10;

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

int h,w,sy,sx,gy,gx;
int grid[1010][1010];
string s[1010];

void bfs(int n,int y,int x){
    queue<P> que;
    grid[y][x]=n;
    que.push(P(y,x));
    while(!que.empty()){
        P t=que.front(); que.pop();
        int cy=t.first,cx=t.second;
        for(int i=0;i<4;i++){
            int ny=cy+dy[i],nx=cx+dx[i];
            if(0<=ny&&ny<h&&0<=nx&&nx<w&&s[ny][nx]=='.'){
                if(grid[ny][nx]!=-1)continue;
                grid[ny][nx]=n;
                que.push(P(ny,nx));
            }
        }
    }
}

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

    cin>>h>>w>>sy>>sx>>gy>>gx;
    sy--,sx--,gy--,gx--;
    for(int i=0;i<h;i++)cin>>s[i];
    for(int i=0;i<1010;i++){
        for(int j=0;j<1010;j++){
            grid[i][j]=-1;
        }
    }
    int n=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(grid[i][j]!=-1||s[i][j]=='#')continue;
            bfs(n,i,j);
            n++;
        }
    }
    // 頂点数n
    vector<int> es[n];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j]=='#')continue;
            for(int ty=-2;ty<=2;ty++){
                for(int tx=-2;tx<=2;tx++){
                    int ny=i+ty,nx=j+tx;
                    if(0<=ny&&ny<h&&0<=nx&&nx<w&&s[ny][nx]=='.'){
                        if(grid[ny][nx]!=grid[i][j]){
                            es[grid[i][j]].emplace_back(grid[ny][nx]);
                            es[grid[ny][nx]].emplace_back(grid[i][j]);
                        }
                    }
                }
            }
        }
    }
    int dist[n];
    for(int i=0;i<n;i++)dist[i]=INF;
    dist[grid[sy][sx]]=0;
    queue<P> que;
    que.push(P(0,grid[sy][sx]));
    while(!que.empty()){
        P t=que.front(); que.pop();
        int v=t.second;
        for(auto u:es[v]){
            if(dist[u]!=INF)continue;
            if(dist[u]>dist[v]+1){
                dist[u]=dist[v]+1;
                que.push(P(dist[u],u));
            }
        }
    }
    if(dist[grid[gy][gx]]==INF)cout<<-1<<endl;
    else cout<<dist[grid[gy][gx]]<<endl;
}

/*
各連結成分に整数を割りふる
任意のマスがどの整数を割りふられた連結成分に属するかの判定
連結成分Aに属するマスから連結成分Bに属するマスにワープできるとき、AとBの間に重み1の辺をはる
できたグラフの始点から終点への最短距離を求める
*/

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

using namespace std;
typedef long long ll;

#define rep(i , j , n) for(long long i = j ; i <= n ; i++)
#define per(i , j , n) for(long long i = j ; i >= n ; i--)

const ll N = 123456;
const ll mod = 1e9 + 7;

ll power(ll a , ll b) {
    if(b == 0) return 1LL;
    ll d = power(a , b / 2);
    d *= d;
    d %= mod;

    if(b % 2 != 0) d *= a;

    d %= mod;

    return d;
}

ll inverse_mod(ll a) {
    return power(a , mod - 2);
}

ll f[N];

ll ncr(ll no , ll r) {
    if(r == 0) return 1LL;
    if(r > no) return 0LL;
    if(r == no) return 1LL;
    ll ans = f[no];
    ans *= inverse_mod(f[r]);
    ans %= mod;
    ans *= inverse_mod(f[no - r]);
    ans %= mod;
    return ans;
}

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

    int a;
    cin >> a;

    string s;
    cin >> s;

    if(a  < 3200) cout << "red" << endl;
    else cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int h,w,d;
int a[500][500];
struct node
{
    int x,y;
    node(){}
    node(int x,int y):x(x),y(y){}
}p[90005];

int pre[90005];

int dis(int q,int w){
    return abs(p[q].x-p[w].x)+abs(p[q].y-p[w].y);
}

int main()
{
    cin>>h>>w>>d;
    for(int i=1;i<=h;i++)
        for(int j=1;j<=w;j++){
        scanf("%d",&a[i][j]);
        p[a[i][j]].x=i;p[a[i][j]].y=j;
    }
    int q;cin>>q;
    int l,r;

    int maxv = h*w;

        for(int i=d+1;i<=maxv;i++){
            pre[i] = pre[i-d] + dis(i,i-d);
        }
        while(q--){
            scanf("%d%d",&l,&r);
            printf("%d\n",pre[r]-pre[l]);
        }
    return 0;
}


Measured memory_bytes: 2816
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int md=1000000007;
int n,a[105],f[55][105][105],pl,pr,i,j,k,x;
int main()
{
	scanf("%d",&n);
	for(i=1;i<=2*n-1;++i)
		scanf("%d",a+i);
	sort(a+1,a+2*n);
	f[n][1][0]=1;
	for(i=n-1;i>=1;--i)
	{
		pl=(a[i+1]!=a[i]),pr=(a[2*n-i-1]!=a[2*n-i]);
		for(j=0;j<=2*n;++j)
			for(k=0;k<=2*n;++k)
				if(f[i+1][j][k])
				{
					for(x=1;x<=j+pl;++x)
						f[i][j+pl-x+1][k+pr+(x>1)]=(f[i][j+pl-x+1][k+pr+(x>1)]+f[i+1][j][k])%md;
					for(x=1;x<=k+pr;++x)
						f[i][j+pl+1][k+pr-x]=(f[i][j+pl+1][k+pr-x]+f[i+1][j][k])%md;
				}
	}
	x=0;
	for(j=0;j<=2*n;++j)
		for(k=0;k<=2*n;++k)
			x=(x+f[1][j][k])%md;
	printf("%d",x);
	return 0;
}


Measured memory_bytes: 1408
a, b, c = map(int, input().split())

maxNum = max(a,max(b,c))

if maxNum == a:
    sumNumString = str(a) + str(b)
    sumNum = int(sumNumString)
    print(sumNum+c)
elif maxNum == b:
    sumNumString = str(b) + str(a)
    sumNum = int(sumNumString)
    print(sumNum+c)
else:
    sumNumString = str(c) + str(a)
    sumNum = int(sumNumString)
    print(sumNum+b)





Measured memory_bytes: 3060
/*
 * Copyright Narushima Hironori. All rights reserved.
 */
import java.io.*;

/**
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0106
 */
public class Main {
	
	static class Shop {
		
		int price, volume, discountedPrice, discountPer;
		
		Shop(int volume, int price, double discount, int per) {
			this.volume = volume;
			this.price = price;
			
			discountedPrice = (int) (price * per - price * per * discount);
			discountPer = per;
		}
		
		int calcPrice(int count) {
			int total = 0;
			while(count >= discountPer) {
				total += discountedPrice;
				count -= discountPer;
			}
			return total + price * count;
		}
		
		int maxBuyCount(int buyVolume) {
			return buyVolume / volume;
		}
		
	}

	Shop[] shops = {
			new Shop(200, 380, 0.20, 5),
			new Shop(300, 550, 0.15, 4),
			new Shop(500, 850, 0.12, 3)
	};
	
	public int calc(int volume) {
		if(volume % 100 != 0) {
			throw new IllegalArgumentException();
		}
		
		int[] buyCounts = new int[shops.length + 1];
		buyCounts[shops.length] = Integer.MAX_VALUE;
		calc(buyCounts, 0, volume);
		return buyCounts[shops.length];
	}

	void calc(int[] count, int shopIndex, int buyVolume) {
		if(shops.length == shopIndex) {
			if(buyVolume == 0) {
				int total = 0;
				for (int i = 0; i < shops.length; i++) {
					total += shops[i].calcPrice(count[i]);
				}
				if(count[shopIndex] > total) {
					count[shopIndex] = total;
				}
			}
		} else {
			Shop shop = shops[shopIndex];
			int maxBuyCount = shop.maxBuyCount(buyVolume);
			for (int buyCount = 0; buyCount <= maxBuyCount; buyCount++) {
				count[shopIndex] = buyCount;
				int nextBuyVolume = buyVolume - shop.volume * buyCount;
				calc(count, shopIndex + 1, nextBuyVolume);
			}
		}
	}

	public static void main(String[] args) throws IOException {
		Main calculator = new Main();
		
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		for (String l; (l = r.readLine()).length() > 0;) {
			int volume = Integer.parseInt(l);
			if(volume == 0) {
				break;
			}
			System.out.println(calculator.calc(volume));
		}
	}


}

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

const int N = 20;

typedef long long LL;

int a[N];

LL dfs(int l, int r, int tl, int tr) {
    if (l > r) return 0;
    LL res = 1e18; 
    for (int i = l; i <= r; i++) 
        res = min(res, dfs(l, i - 1, tl, tl + tr) + dfs(i + 1, r, tl + tr, tr) + (LL)a[i] * (tl + tr));
    return res;
}

int main() {
    int n; scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    printf("%lld\n", dfs(2, n - 1, 1, 1) + a[1] + a[n]);
    return 0;
}//

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <numeric>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;
int ans[1010][1010];
int A[101010];
int main(){
    int H, W, N;
    cin >> H >> W >> N;
    REP(i, N){
        cin  >> A[i];
    }
    int cu = 0;
    REP(y, H){
        REP(x, W){
            ans[y][x] = cu + 1;
            A[cu]--;
            if(!A[cu])
                cu++;
        }
    }
    REP(y, H){
        REP(_x, W){
            int x;
            if(y % 2 == 0)
                x = _x;
            else
                x = W - 1 - _x;
            
            if(_x)
                cout << " ";
            cout << ans[y][x];
            }
        cout << endl;
    }
    return 0;
}

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

int main(void){
    int N,t; cin >> N >> t;
    int T[N];
    for(int i=0; i<N; i++) cin >> T[i];

    long long time=0L;
    for(int i=1; i<N; i++){
        if(T[i]-T[i-1]<t) time+=T[i]-T[i-1];
        else time+=t;
    }
    time+=t;

    cout << time << endl;
    return 0;
}

Measured memory_bytes: 1024
coin_list = []
for i in range(3):
    s = int(input())
    coin_list.append(s)
target = int(input())
counter = 0

for a in range(coin_list[0]+1):
    for b in range(coin_list[1]+1):
        for c in range(coin_list[2]+1):
            total = 500*a + 100*b + 50*c
            if total == target:
                counter = counter + 1

print(counter)

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

using namespace std;

const int OO = 1e9;
const double EPS = 1e-9;

#define ndl cout << '\n'
#define sz(v) int(v.size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define present(a, x) (a.find(x) != a.end())
#ifdef LOCAL
#define db(...) ({cout << "> Line " << __LINE__  \
		<< ": "; _db(#__VA_ARGS__, __VA_ARGS__);})
#define RNG() rng()
#else
#define db(...) true
#define RNG() true
#endif

template<class T>
void _db(const char *dbStr, T e) {
	cout << dbStr << " = " << e << endl;
}
template<class T, class... L>
void _db(const char *dbStr, T e, L... r) {
  while(*dbStr != ',') cout << *dbStr++;
  cout << " = " << e << ','; _db(dbStr + 1, r...);
}
template<class S, class T>
ostream& operator<<(ostream& o, const map<S, T>& v) {
	o << "["; int i = 0;
	for (const pair<S, T>& pr : v) o << (!i++ ? "" : ", ") << "{"
	<< pr.fs << " : " << pr.sc << "}"; return o << "]";
}
template<template <class, class...> class S, class T, class... L>
ostream& operator<<(ostream& o, const S<T, L...>& v) {
	o << "["; int i = 0;
	for (const auto& e : v) o << (!i++ ? "" : ", ") << e;
	return o << "]";
}
template<class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& pr) {
	return o << "(" << pr.fs << ", " << pr.sc << ")";
}
ostream& operator<<(ostream& o, const string& s) {
	for (const char& c : s) o << c;
	return o;
}

template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = VV<V<T>>;
using ll = long long;
using pii = pair<int, int>;
using vi = V<int>;
using vii = V<pii>;
using vvi = VV<int>;
using mii = map<int, int>;
using umii = unordered_map<int, int>;
using si = set<int>;
using usi = unordered_set<int>;





int main() {
	#ifdef LOCAL
	auto stTime = clock();
//	freopen("in.txt", "r", stdin);
	mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
	#endif
	ios::sync_with_stdio(false);
	cout.precision(10);
	cin.tie(0);

	string s;
	cin >> s;
	int n = sz(s);
	vi v;

	for (auto& c : s) {
		if (c == s[0])
			v.pb(0);
		else if (c == s.back())
			v.pb(1);
	}

	int l = sz(v);

	for (int i = 1; i < sz(v); ++i) {
		l += v[i] == v[i - 1];
	}

	if ((n - l) % 2 == 0)
		cout << "Second\n";
	else
		cout << "First\n";



	#ifdef LOCAL
	cout << "\n\n\nExecution time: " <<
		(clock() - stTime) * 1e3 / CLOCKS_PER_SEC << " ms" << endl;
	#endif
	return 0;
}


Measured memory_bytes: 1020
n, m = map(int, input().split())
hlist = list(map(int, input().split()))
rlist = [list(map(int, input().split())) for i in range(m)]

list = [1]*n
for i in range(m):
    a = rlist[i][0] - 1
    b = rlist[i][1] - 1
    if hlist[a] <= hlist[b]:
        list[a] = 0
    if hlist[a] >= hlist[b]:
        list[b] = 0

print(list.count(1))

Measured memory_bytes: 31756
#include <bits/stdc++.h>
using namespace std;
int main(){//gotoを使ってみよう
    char s[4];
    string a,b;
    std::cin >> s;

    a.push_back(s[0]);
    a.push_back(s[1]);
    b.push_back(s[2]);
    b.push_back(s[3]);
    int aa,bb;
    aa=stoi(a);
    bb=stoi(b);
    if(aa>=1&&aa<=12){
        if(bb>=1&&bb<=12){
            std::cout << "AMBIGUOUS" << std::endl;
        }else{
            std::cout << "MMYY" << std::endl;
        }
    }else{
         if(bb>=1&&bb<=12){
            std::cout << "YYMM" << std::endl;
        }else{
            std::cout << "NA" << std::endl;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace::std;

int main() {
    int array[10];

    for(int i=0;i<10;i++)
        cin >> array[i];

    sort(array,array+10);

    cout << array[9] << endl << array[8] << endl << array[7] << endl;
    return 0;
}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pi;
 
 
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
 
const int MOD = 1000000007;
const ll INF = 1e18;
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin >>n;
	vi N(n);
	int count =0;
	int small=INT_MAX;
	int x;
	F0R(i,n)
	{
		 cin>>x;
		 if (x<small)
		 {
			 small=x;
		 }
		 else count++;
			 
	}
	cout<<n-count<<endl;
	
	
		
	
    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String age = scanner.nextLine();

		switch (age) {
		case "1":
			System.out.println("Hello World");
			break;
		case "2":
			int a = Integer.parseInt(scanner.nextLine());
			int b = Integer.parseInt(scanner.nextLine());
			System.out.println(a + b);
			break;
		default:
			break;
		}
	}
}

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

int main() {
    int N, K;
    cin >> N >> K;
    int ans = K;

    if(N == 1) {
        cout << ans;
    }
    else {
        for(int i = 1; i <= N-1; i++) {
            ans *= K-1;
        }
        cout << ans;
    }
    
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
struct Edge {
  int from, to, cost, dist;
  Edge(int from, int to, int dist, int cost) : from(from), to(to), dist(dist), cost(cost) {}
};
bool operator> (Edge &e1, Edge &e2) {
  return e1.dist < e2.dist;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  while(1) {
    int n, m; cin >> n >> m;
    if(n == 0) break;
    vector<vector<Edge>> g(n);
    for(int i=0;i<m;++i) {
      int u, v, d, c; cin >> u >> v >> d >> c;
      u--; v--;
      g[u].push_back(Edge(u, v, d, c));
      g[v].push_back(Edge(v, u, d, c));
    }
    vector<vector<int>> in(n);
    vector<vector<int>> in2(n);
    priority_queue<P> pq;
    vector<int> d(n, INF);
    d[0] = 0;
    pq.push({0, 0});
    while(!pq.empty()) {
      P now = pq.top(); pq.pop();
      int dist = now.first, idx = now.second;
      for(int i=0;i<(int)(g[idx].size());++i) {
        auto next = g[idx][i];
        if(d[next.to] < dist + next.dist) continue;
        else if(d[next.to] == dist + next.dist) {
          in[next.to].push_back(next.cost);
          in2[next.to].push_back(idx);
        }
        else if(d[next.to] > dist + next.dist) {
          in[next.to].clear();
          in2[next.to].clear();
          in[next.to].push_back(next.cost);
          in2[next.to].push_back(idx);
          d[next.to] = dist + next.dist;
          pq.push({dist + next.dist, next.to});
        }
      }
    }
    int ans = 0;
    for(int i=1;i<n;++i) {
      int mi = INF;
      for(int j=0;j<(int)(in[i].size());++j) {
        mi = min(mi, in[i][j]);
      }
      ans += mi;
    }
    cout << ans << endl;
  }
}



Measured memory_bytes: 4828
#include <iostream>
#include <map>

using namespace std;

int main() {
  int N, M;
  cin >> N;
  map<string, int> S, T;
  string s;
  for (int i = 0; i < N; i++) {
    cin >> s;
    if (S.find(s) != S.end()) {
      S[s]++;
    } else {
      S[s] = 1;
    }
  }
  cin >> M;
  for (int i = 0; i < M; i++) {
    cin >> s;
    if (T.find(s) != T.end()) {
      T[s]++;
    } else {
      T[s] = 1;
    }
  }

  int score = 0;
  int max_score = 0;
  for (auto it = S.begin(); it != S.end(); it++) {
    score = it->second;
    map<string, int>::iterator itr = T.find(it->first);
    if (itr != T.end()) {
      score -= itr->second;
    }
    max_score = max(max_score, score);
  }
  cout << max_score << endl;
}


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

    return 0;
}


Measured memory_bytes: 2036
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define IOS ios::sync_with_stdio(0);cin.tie(0);


int main()
{
    IOS;
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int N; cin>>N;
    if (N%1000 == 0)
    {
        cout<<"0"<<endl;
    }
    else
    {
        int change = 1000 - N%1000;
        cout<<change<<endl;
    }

    return 0;

}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
int k,a,b;

int main(){
    cin >> k >> a >> b;
    long long ans=1;
    int l=0;
    if(a>=b-2)
    {
    	cout << ans+k << endl;
	}
	else
	{
		k-=a-1;
		ans=a;
		if(k%2==0)
		{
			ans+=(long long)(b-a)*k/2;
		}
		else
		{
			ans+=(long long)(b-a)*(k-1)/2;
			ans++;
		}
		cout << ans << endl;
	}
    return 0;
}


Measured memory_bytes: 256
N=gets.chomp.to_i
s=gets.chomp.to_s

ary = s.split('')

r_count = 0
b_count = 0
ary.each do |char|
  if char == "R"
    r_count += 1
  else
    b_count += 1
  end
end

if r_count > b_count
  puts 'Yes'
else
  puts 'No'
end

Measured memory_bytes: 1788
#include <iostream>
typedef long long int ll;
using namespace std;

int main() {
   string s,t;
   cin>>s>>t;
  
   int n=s.length(),count,min=9999,k;
   int left=0,right=(t.length());
   //cout<<n<<"\n"<<right;
   while(right<=n)
   {   
       count=0;k=0;
       for(int j=left;j<right;j++)
       {   
           
         if(s[j] != t[k])
           {
               count++;
           }
           k++;
       }
      // cout<<count<<"\n";
       if(min>count)
            min=count;
       right++;
       left++;
       count=0;
   }
   cout<<min;
}

Measured memory_bytes: 3616
/*
Keep clam  Believe youself
*/
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<stack>
#include<set>
#include<cmath>
#define Xiaobo main
#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
const int maxn=2e5+7;
const int mod=1e9+7;
const double eps=1e-15;
const double pi=acos(-1);
const int INF=0x3f3f3f3f;
typedef long long ll;
ll read(){ll c = getchar(),Nig = 1,x = 0;while(!isdigit(c) && c!='-')c = getchar();if(c == '-')Nig = -1,c = getchar();while(isdigit(c))x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();return Nig*x;}
ll gcd(ll a,ll b){ return b==0?a:gcd(b,a%b);}
//别急 dp找状态 问题看看本身的规律 贪心找方法
int Xiaobo()
{
	int a,b;
	cin>>a>>b;
	int flag=0;
	for(int i=max(a,b);i<max(a,b)*1.0/(0.08)+10;i++)
	{
		int x=i*0.08;
		int y=i*0.1;
		if(x==a&&y==b) {
			flag=1;
			cout<<i<<'\n';
			break;
		} 
	}
	if(!flag) cout<<-1<<'\n';
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

long long A,B,K;

int main()
{
	cin >> A >> B >> K;
	long long tmp=min(A,K);
	A-=tmp;
	K-=tmp;
	B-=min(B,K);
	cout << A << " " << B << endl;
	return 0;
}

Measured memory_bytes: 256